Compare commits
No commits in common. "master" and "gh-pages" have entirely different histories.
1
.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
/telaen/nbproject/private/
|
372
CHANGELOG.md
|
@ -1,372 +0,0 @@
|
|||
INTRO: This documents the changes made to Telaen.
|
||||
|
||||
First of all: Telaen would be nowhere without the effort of many beta
|
||||
testers, other bug-and-patch submitters.
|
||||
|
||||
Telaen was originally based on Uebimiau.
|
||||
|
||||
LICENSE: Telaen is released under the GPLv2.
|
||||
|
||||
|
||||
CHANGELOG:
|
||||
----------------------------------------------------------------
|
||||
|
||||
2.0.0-dev
|
||||
|
||||
* Vcard support via https://github.com/jimjag/vCard-parser
|
||||
* Use better HTML sanitizer: *htmLawed*
|
||||
* Use better HTML->Txt converter: *Html2Text*
|
||||
* More robust MIME Message parsing
|
||||
* Drop support for PHP 5.3 and older
|
||||
* Email message cache no longer stored in Session data
|
||||
* Explicit error handler
|
||||
* Communication w/ IMAP and POP3 servers now uses PHP streams
|
||||
* 3rd party dependencies now located in ./vendor directory for
|
||||
future Composer compatibility
|
||||
* Updated *PHPMailer* (5.2.9), *iCalcreator* (2.20.2), *tinymce* (4.1.6),
|
||||
*Smarty* (3.1.21)
|
||||
|
||||
1.3.2
|
||||
|
||||
* [New] Performance enhancements : avoid array copying
|
||||
* [Fix] Prevent direct access to libs even if not using web-server ACLs
|
||||
(security)
|
||||
* [New] Update to *tiny_mce* 3.5.8
|
||||
* [New] Update to *Smarty* 2.6.27
|
||||
* [Fix] Correct bug w/ *PHPMailer* 5 compatibility
|
||||
|
||||
1.3.1
|
||||
|
||||
* [Fix] Sanitize `f_email` and `redir` url
|
||||
|
||||
1.3.0
|
||||
|
||||
* [New] Support for *PHPMailer* 5.2.1.
|
||||
* [New] Now includes an embedded appointment/event Calendar using the
|
||||
iCal format under the hood.
|
||||
* [New] Ability to display a System-wide "news" banner via
|
||||
inc/news/news.system.php
|
||||
* [New] Major speed improvements when handling the POP3 Inbox. Even
|
||||
though it's not recommended to store all your Email in the POP3
|
||||
Inbox, lots of people do which slowed down Telaen.
|
||||
* [Fix] No longer extracts vars willy-nilly from $_GET, $_POST, or
|
||||
$_FILES.
|
||||
* [Misc] Moved all `class.\*.php` files to `./inc/class/`. and all `config.\*`
|
||||
files to `./inc/config/`. This means that upgrading may involve
|
||||
moving and/or deleting older stale versions of files.
|
||||
* [New] Upgraded to latest *TinyMce*.
|
||||
|
||||
1.2.1
|
||||
|
||||
* [New] New **Forwarded** status flag and icon added.
|
||||
* [New] Since `ereg\*` is deprecated, all regexes now use the `preg_\*`
|
||||
family.
|
||||
* [New] *Smarty* upgraded to 2.6.26
|
||||
* [New] *PHPMailer* upgraded to 2.0.3
|
||||
* [Fix] Users cannot create folder that have the same names as system
|
||||
folders
|
||||
|
||||
1.2.0
|
||||
|
||||
[Released]
|
||||
|
||||
1.2.0-RC1
|
||||
|
||||
* [New] Updated Thai translation
|
||||
* [Fix] Sorting by To in Sent Messages now works.
|
||||
* [Fix] HTML Emails now have plain-text component, so that SpamAssassin
|
||||
doesn't score them too badly.
|
||||
* [Fix] Fixed bug on IMAP when using prefix
|
||||
|
||||
1.2.0-beta1
|
||||
|
||||
* [New] Removed support for versions of PHP < 4.1.0
|
||||
* [New] Smarty upgraded to 2.6.18.
|
||||
* [New] Quota handling can now be set per user or per domain (or any
|
||||
combination) via the new $quota_limits config variable.
|
||||
* [New] Uses POP3 UIDL for better message tracking. If server does not
|
||||
provide a UIDL, we create our own.
|
||||
* [New] Email filters
|
||||
* [New] Ajax function: session is mantained alive in the compose page,
|
||||
allowing writing long email without lose work.
|
||||
* [New] Login page now alerts when you kicked out on a session expire.
|
||||
* [Fix] Fixed regression with forward/reply of email with embedded
|
||||
images. downloads.php causes logout on recipient if uses telaen.
|
||||
* [Fix] Various performance improvements
|
||||
* [Fix] IMAP bug: extra text added on saved sent message cause wrong
|
||||
date/time display
|
||||
* [Fix] Hide attachments links only if they are embedded images. Some
|
||||
clients (like pine) set Content-Id on all attachment types.
|
||||
|
||||
``1.1.3
|
||||
|
||||
* [New] Added Malay translation
|
||||
* [New] Updates to some languages
|
||||
* [New] Included Outlook theme into package
|
||||
* [Fix] Solved bug with imap when move or delete multiple message only
|
||||
one was moved or deleted.
|
||||
|
||||
1.1.3-rc2:
|
||||
|
||||
* [Fix] Added check for on CAPA detection, avoid hangs when command is
|
||||
not supported.
|
||||
* [Fix] Removed target->new on attach download (not open), causes blank
|
||||
window remains open on IE.
|
||||
* [New] de lang up-to-date
|
||||
|
||||
1.1.3-rc1:
|
||||
|
||||
* [Fix] check_install.php(.txt) now correctly checks memory_limit
|
||||
value.
|
||||
* [New] Now automatically detects if the POP3 server supports
|
||||
PIPELINING, APOP, ATOP and UIDL. Can be overruled (enable or
|
||||
disable) from config.php.
|
||||
* [Fix] Email parsing enhancement, now can parse correctly
|
||||
multipart/alternative emails with multipart/mixed nested content.
|
||||
This emails are usually generate form Apple Mail Clients Also
|
||||
attachments types with dots (like application/vnd.ms-exel) are
|
||||
detected correctly.
|
||||
* [New] Little usability issue, error/badlogin pages are merged with
|
||||
login page, the errors are simply displayed in a box. This also
|
||||
removes unuseful/redudant code. To use this feature, themes need to
|
||||
update their login.htm file (look at default/login.htm for
|
||||
guidance).
|
||||
* [New] TinyMce updated to version 2.0.9
|
||||
* [New] New feauture: Button for download the entire message
|
||||
|
||||
|
||||
1.1.2:
|
||||
|
||||
* [New] Moved to subversion. This allowed us to rearrange the default
|
||||
layout more easily and move the bundled Smarty package from
|
||||
underneath the telaen path.
|
||||
* [New] Provide notice that the ./smarty/ directory should be moved
|
||||
someplace outside of the web-space. Done by renaming the directory.
|
||||
* [New] Updated Smarty to 2.6.16 Updated tinyMce to 2.0.8
|
||||
* [New] Added korean language.
|
||||
* [Fix] Fixed error when using TOP retrieve mode, the msg[size]
|
||||
contained an EOF that caused a bad response on the next command.
|
||||
Also improved the move function, the message is deleted only if the
|
||||
copy is done on filesystem.
|
||||
* [New] Added APOP login support. To enable, add `$mail_use_apop = yes;` to your config.php file.
|
||||
* [Fix] Better header parsing, support multi-line headers avoid wrong
|
||||
content-type detect.
|
||||
* [Fix] Bug on attachment filename, sometimes the name ends with ';'
|
||||
when receving emails from Hotmail accounts.
|
||||
* [Fix] Use the configured port on ONE-FOR-ALL mode, not depending from
|
||||
protocol.
|
||||
* [Fix] Use relative path on redir.php links, avoid problems on https
|
||||
servers.
|
||||
|
||||
|
||||
1.1.1:
|
||||
|
||||
* Fixed little bug on catch-address where wrong address was added to
|
||||
addressbook.
|
||||
|
||||
1.1.1-rc2:
|
||||
|
||||
* Fixed problem where messages disappear on refresh with zero quota.
|
||||
* Little fixes on themes.
|
||||
|
||||
1.1.1-rc1:
|
||||
|
||||
* Added sort for personal folders on folders list and fixed a bug can
|
||||
cause duplicate entries in the list.
|
||||
* Fixed problem with missing header info when using IMAP. Also
|
||||
addresses possible "double showing" of SPAM email both Inbox and
|
||||
Spam folder.
|
||||
* Solved issue when attached images with upcase or capitalized
|
||||
extension (like .JPG or .Gif) are not displayed inline
|
||||
* Added check for exclude user address in reply-all
|
||||
* Added ability to require a return-receipt on a new message
|
||||
* Improved signature/footer attach and multiple quotes on HTML messages
|
||||
* umask value and default directory permission bitmask now configurable
|
||||
via the config.php file. Useful for some environs that need a more
|
||||
"open" permission setup. NOTE: this requires people upgrading from
|
||||
1.1.0 or earlier to modify their config.security.php file! Look at
|
||||
the config.security.php.default file for these variable settings.
|
||||
* Templates improvements: - now header.htm contains also the <head>
|
||||
section of html - meta tags output in <head> instead of a bad echo
|
||||
- menu.htm template used instead of nav_menu.htm - webmail title
|
||||
configurable in config.php - little restyling on quick address
|
||||
window (mozilla style) - added a different header for popups
|
||||
* New check on quick address window, avoid to add an address multiple
|
||||
times.
|
||||
|
||||
1.1.0:
|
||||
|
||||
* Updated Smarty to version 2.6.14
|
||||
* Added $phpmailer_sendmail and $phpmailer_timeout to
|
||||
config.php.default to allow admin to easily override PHPMailer's
|
||||
default sendmail path and SMTP timeout
|
||||
* Changed attachment window size to something large enough to be
|
||||
readable, but not too large.
|
||||
|
||||
1.1.0-rc2:
|
||||
|
||||
* Updated TinyMCE to latest rev.
|
||||
* Fixed bug on email time calc.
|
||||
* Adjusted titles alignment an other little improvements on themes.
|
||||
|
||||
1.1.0-rc1:
|
||||
|
||||
* Fix bug where selected messages disappear from list on mark/unmark
|
||||
read functions with 20 or more messages.
|
||||
* Fix bug where auto-deleting SPAM could affect other messages in the
|
||||
INBOX.
|
||||
* Fix nasty bug where CC addresses were not being delivered if using
|
||||
the 'mail' Mailer (PHPMailer bug).
|
||||
* Templates improvement, now we have a page header and footer included
|
||||
in all pages (actually not for login and pop-ups). This allow a
|
||||
faster style personalization.
|
||||
|
||||
1.1.0-beta2:
|
||||
|
||||
* Telaen is now aware of the SpamAssassin X-Spam-Level header, and
|
||||
allows users to control auto-SPAM detection sensitivity and SPAM
|
||||
folder autopopulation. For example, a user can specify a
|
||||
sensitivity of 2 (very sensitive), and all messages that have a
|
||||
X-Spam-Level of 2 or more will get auto-moved to the SPAM folder.
|
||||
* Bundled themes converted to be xhtml1.0 compliant.
|
||||
* Force magic_quotes_runtime to be disabled, since it conflicts with
|
||||
Smarty.
|
||||
* Fix issue with message lists when quotas are not used.
|
||||
|
||||
* Provide ways to work around some issues with Redirects. We can now
|
||||
select whether these redirects are performed via HTTP redirects
|
||||
(the Location header) or via META REFRESH and Javascript (see
|
||||
$redirects_use_meta). Also, we can select whether the URLs used for
|
||||
redirects are absolute (as required by HTTP) or relative (see
|
||||
$redirects_are_relative).
|
||||
* New feature: mark as read/unread on message list
|
||||
|
||||
1.1.0-beta1:
|
||||
|
||||
* Fixed problem with possible incorrect redirects. Instead of checking
|
||||
that $_SERVER['HTTPS'] is non-empty, we check explicitly for it
|
||||
being set to 'on'. The official PHP docs are misleading (wrong)
|
||||
here.
|
||||
* Add in extra/check_install.php.txt which performs some simple tests
|
||||
of your installation and setup.
|
||||
* No longer require short_open_tag.
|
||||
* Some under-the-hood code improvements.
|
||||
* Remove the SPAM folder from the list of "folders that stuff can be
|
||||
moved to by the user."
|
||||
* The Advanced HTML Editor is now TinyMCE, which is bundled with
|
||||
Telaen. Changes to the newmsg.htm template file may be required
|
||||
(depending on the template) to fully use this.
|
||||
* Now, whenever Telaen adds body content (eg: whenever we parseBody), we
|
||||
choose to sanitize or not. This means that messages are sanitized
|
||||
when printed or forwarded/replied to. Added a global variable,
|
||||
$sanitize_html to control this ($allow_scripts also works, but is
|
||||
being depreciated since it doesn't reflect what we're really
|
||||
concerned about).
|
||||
* Fixed bug where show_body was not using the correct charset (since it
|
||||
was removed by HTMLFilter).
|
||||
* Removed old krufty session code to use native PHP session()
|
||||
capability.
|
||||
* Removed the tid/lid/sid stuff from the URL. Stored in user sessions,
|
||||
as it should be.
|
||||
|
||||
1.0.0:
|
||||
|
||||
* Revised de.txt and pt_BR.txt files.
|
||||
|
||||
1.0.0-RC2:
|
||||
|
||||
* Fix the default theme to use a draft Telaen logo instead of the old
|
||||
Uebimiau one.
|
||||
* The preferences page is now shown whenever the previously used
|
||||
version and the present version differ by either the Major or Minor
|
||||
version number. For example, moving from 1.0.0 to 1.0.1 will not
|
||||
make it happen, but going from 1.0.4 to 1.1.0 will. This therefore
|
||||
sets the assumption of what the "API" is :)
|
||||
* HTML Emails are now filtered through HTMLFilter, to protect against
|
||||
XSS attacks.
|
||||
* We no longer get that weird '1' on the upper left of the message list
|
||||
page.
|
||||
* Add in a method to adjust for server timezone offsets, if we can't
|
||||
figure out the real offset.
|
||||
* Use output buffering within process.php to prevent breakage with
|
||||
redirects.
|
||||
* Force exit after all redirects.
|
||||
* All redirects are now HTTP/1.1 compliant (ie: the use absolute URLs).
|
||||
* Some HTML cleanups for the default theme.
|
||||
|
||||
1.0.0-RC1:
|
||||
|
||||
* Fix calculation of timezones.
|
||||
* Rename of class files and other notices from Uebimiau to Telaen.
|
||||
* Enable marking READ messages as either READ or UNREAD upon logout.
|
||||
The default is UNREAD. This allows users who check their mail with
|
||||
other Email clients to see those messages as "new" and unread.
|
||||
SysAdmin can overrule user prefs by setting:
|
||||
$force_unmark_read_overrule; $force_unmark_read_settingyes; in
|
||||
config.php. Changes: o en_UK.txt: prf_unmark_read_on_exit o
|
||||
preferences.htm
|
||||
|
||||
----------------------------------------------------------------
|
||||
Uebimiau - the "jimjag" patches:
|
||||
----------------------------------------------------------------
|
||||
-------- 2.7.8p3 --------
|
||||
|
||||
* "What is SPAM" regex now definable for
|
||||
each UM class.
|
||||
|
||||
* Enable auto-population of the spam folder and add a user pref to
|
||||
auto-delete it at logout time. Spam folder options require the
|
||||
_autospamfolder variable in the Uebimiau class be TRUE. o
|
||||
en_UK.txt: spam_extended prf_empty_spam_on_exit o preferences.htm
|
||||
|
||||
* Make the spam folder a system folder.
|
||||
|
||||
* If using cookies, have the login page explain why a login may not
|
||||
have succeeded due to cookie error (eg: user does not have cookies
|
||||
enabled). Only important if using cookie security. This required
|
||||
changes to the login themes and the lang file. o en_UK.txt
|
||||
:lng_cookie_not_enabled lng_cookie_not_valid o login.htm
|
||||
|
||||
* Store version number in pref's file; since new versions might change
|
||||
or add preferences, this means that UM can now direct the user to
|
||||
their Preferences page as soon as the login after an upgrade
|
||||
(similar to the First Login). Updated preference page theme. o
|
||||
preferences.htm
|
||||
|
||||
* Address book now usable with CC and BCC fields. o newmsg.htm
|
||||
|
||||
* Fold in many improvements submitted by MBR (Martin Blapp) regarding
|
||||
file and folder speedups, detection of ATOP and pipelining support,
|
||||
and spam folders.
|
||||
|
||||
-------- 2.7.8p2 --------
|
||||
|
||||
* Change format of session ID to be more file
|
||||
system friendly.
|
||||
|
||||
* Folders are now mode 700, for security.
|
||||
|
||||
* No longer depend on the bundled versions of PHPMailer or Smarty,
|
||||
which were kind of old. Instead, force any custom changes to these
|
||||
external projects to be local in scope, allowing us to upgrade them
|
||||
as needed, or to use system-installed versions. (we *do* bundle
|
||||
what we need, for completeness, and to make it a one-shot
|
||||
installation - we just bundle the latest, non-altered versions, but
|
||||
we don't require the version we bundle).
|
||||
|
||||
* Fix some incorrect regex matching, especially when they touch the
|
||||
file system (like allowed folder names).
|
||||
|
||||
* Fix MSIE display errors (usually exhibited as just a blank page)
|
||||
especially with attachments.
|
||||
|
||||
* On login, do the inbox/attachments clean-up. Many people don't bother
|
||||
to logout. :)
|
||||
|
||||
* Auto-clean the server-side inbox and attachments folder to save disk
|
||||
space.
|
||||
|
||||
* Misc code cleanups.
|
||||
|
||||
-- Jim Jagielski / jim@jaguNET.com
|
||||
|
68
INSTALL.txt
|
@ -1,68 +0,0 @@
|
|||
----------------------------------------------------
|
||||
INSTALL
|
||||
----------------------------------------------------
|
||||
- Read the README file... really, you should!
|
||||
|
||||
- Unpack the package (.tar.gz or .zip file) into temporary directory.
|
||||
|
||||
- Move the 'telaen' folder to where you want it under your
|
||||
public webspace.
|
||||
eg /home/httpd/webmail (*unix) or c:\inetpub\wwwroot\webmail (Win32).
|
||||
|
||||
- Make a non web-shared folder (users cannot see this folder through a web
|
||||
browser), eg. /home/telaen or c:\winnt\temp\telaen
|
||||
|
||||
- IMPORTANT: If using the bundled Smarty package, move the ./smarty_move_me/
|
||||
directory to a non web-shared folder.
|
||||
|
||||
- The user which the webserver is running (nobody, apache, IUSR_machine,etc)
|
||||
need permission to write on this folder. It is best to make
|
||||
it owned by the webserver ID and mode 700.
|
||||
|
||||
- The default configuration is stored in "inc/config/configv2.php.default".
|
||||
Any and all changes should be placed in the "inc/config/configv2.php"
|
||||
file; there is no need to copy over settings which don't have any
|
||||
local changes, but if you prefer to just copy configv2.php.default
|
||||
to configv2.php and make your edits there, that is fine too.
|
||||
All instructions are commented on in this file; pay attention to
|
||||
the $config['temporary_folder'] variable and the SMARTY_DIR define!
|
||||
Set them according your above folder names.
|
||||
|
||||
- Check your installation setup by performing the following
|
||||
tasks:
|
||||
o Rename extra/check_install.php.txt to extra/check_install.php
|
||||
o Access check_install.php via your browser, eg:
|
||||
http://jimjag.github.io/telaen/telaen/extra/check_install.php
|
||||
o Make any required changes.
|
||||
o Be SURE to REMOVE check_install.php or RENAME it back to
|
||||
check_install.php.txt !!!
|
||||
|
||||
- Ensure that the ./inc/ directory cannot be accessed directly.
|
||||
There are many ways to do this, but the easiest is using
|
||||
ACLs:
|
||||
<Location /webmail/inc> # or whatever
|
||||
order allow,deny
|
||||
deny from all
|
||||
</Location>
|
||||
|
||||
---------------
|
||||
PERFORMANCE
|
||||
---------------
|
||||
|
||||
The performance of Telaen, of course, depends on the speed of
|
||||
your Webserver, PHP and your POP3/IMAP Email server. Even so,
|
||||
here are some helpful hints:
|
||||
|
||||
a. Use Apache 2.4.
|
||||
b. Just for Telaen, configure PHP with a large memory
|
||||
allocation and a long (or non-existent) time-limit.
|
||||
c. Use a good PHP cache, like XCache or APC.
|
||||
d. If possible, host your Email server on your Web server,
|
||||
so you can connect to the loopback address.
|
||||
e. IMAP itself is a faster interface, so use that if you can.
|
||||
f. If using POP3, there are some additional hints:
|
||||
1. Encourage people to use Folders and to keep their
|
||||
Inbox as small as possible.
|
||||
2. Remove any SPAM as quickly as possible.
|
||||
g. Enabling quotas involves some overhead which you
|
||||
may wish to avoid.
|
281
LICENSE.txt
|
@ -1,281 +0,0 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
108
README.md
|
@ -1,108 +0,0 @@
|
|||
# Telaen - A full-featured yet simple web-based e-mail client written in PHP
|
||||
|
||||
## Overview
|
||||
|
||||
Telaen is a web-based e-mail client written in PHP. What is particularly
|
||||
nice about Telaen is that it is fast, lean and simple, but also extremely
|
||||
powerful. It does not require much more than a "standard" PHP
|
||||
installation, nor does it require an external database. It supports multiple
|
||||
folders, both POP3 and IMAP, is SPAM aware and incorporates WYSIWYG editors
|
||||
for Email composition. It supports multiple languages as well as
|
||||
multiple themes (or "skins").
|
||||
|
||||
Telaen 1.3.x is compatible with PHP4 and PHP5. Starting with Telaen
|
||||
2.x, we require PHP 5.4 and later.
|
||||
|
||||
We recommend that you read the other documents in the docs/ subdirectory,
|
||||
especially the CHANGELOG.txt and INSTALL.txt files.
|
||||
|
||||
## Design Philosophy
|
||||
|
||||
First of all, Telaen is designed and architectured to be as small
|
||||
and as compact as possible; some may even say Telaen is "minimalistic".
|
||||
The reason is that as projects get larger and more complex, they are
|
||||
more difficult to update, to vet and review, and to keep secure.
|
||||
Simplicity, after all, is a virtue.
|
||||
|
||||
The other basic philosophy is to leverage PHP and existing 3rd
|
||||
party libraries as much as possible, but without making the level
|
||||
of dependencies onerous for the sys-admin. There's no need to
|
||||
re-create the wheel, unless we can do it faster, or easier.
|
||||
|
||||
Finally, as ex-sys-admins ourselves, as well as developers,
|
||||
Telaen is designed to be plug-and-play. Plugins are a great
|
||||
idea, and maybe Telaen will support them in the future, but
|
||||
requiring sys-admins to find, install, config and debug Plugins
|
||||
to add basic features that should be core to a webapp, doesn't
|
||||
make sense to us.
|
||||
|
||||
## Why you might need it
|
||||
|
||||
Other PHP-based webmails require external database support as well as a long
|
||||
laundry-list of other PHP libs and extensions; not Telaen. If
|
||||
you need an powerful yet simple and clean webmail system, Telaen will likely fit the bill.
|
||||
|
||||
And, if you are stuck running ancient Uebimiau, you should
|
||||
really move to Telaen asap.
|
||||
|
||||
## License
|
||||
|
||||
Telaen is free software distributed under GPLv2 terms; see www.gnu.org for
|
||||
more informations. You can use or redistribute this software, but need to
|
||||
preserve the credits of author. Please read LICENSE for information on the
|
||||
software availability and distribution.
|
||||
|
||||
## Features
|
||||
|
||||
- SMTP Compatible
|
||||
- POP3 Compatible
|
||||
- IMAP Compatible
|
||||
- MIME Compatible
|
||||
- Receive Attachments
|
||||
- Send Attachments
|
||||
- Folders/E-mail management support (Trash/Inbox/Sent/[Personal])
|
||||
- Address book
|
||||
- Language support
|
||||
- Themes support
|
||||
- Search in messages
|
||||
- Personalized ordering of messages
|
||||
- Personal preferences
|
||||
- HTML e-mail support (read/write)
|
||||
- Quota Limit
|
||||
- Auto population of SPAM folder for tagged SPAM messages
|
||||
|
||||
## Localization
|
||||
|
||||
PHPMailer defaults to English, but supports other language and UI themes (or 'skins').
|
||||
|
||||
## Documentation
|
||||
|
||||
You'll find some basic user-level docs in the docs folder
|
||||
|
||||
## Dependencies
|
||||
|
||||
Telaen is designed to work with as a vanilla, bare-bones build of PHP as
|
||||
possible. The below external dependencies are bundled for convenience:
|
||||
|
||||
- Smarty
|
||||
- TinyMCE
|
||||
- PHPMailer
|
||||
- iCalCreator (https://github.com/jimjag/iCalcreator.git fork)
|
||||
- vCard-parser (https://github.com/jimjag/vCard-parser fork)
|
||||
- Html2Text.php
|
||||
|
||||
Telaen is designed to work with both the bundled as well as the system-provided
|
||||
versions of these tools.
|
||||
|
||||
No external database is required.
|
||||
|
||||
## Contributing
|
||||
|
||||
Please submit bug reports, suggestions and pull requests to the [GitHub issue tracker](https://github.com/jimjag/telaen/issues).
|
||||
|
||||
We're particularly interested in fixing edge-cases, expanding test coverage and freshing-up
|
||||
the user UI.
|
||||
|
||||
## Changelog
|
||||
|
||||
See [CHANGELOG.md](https://github.com/jimjag/telaen/blob/master/CHANGELOG.md)
|
BIN
images/code.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
images/pattern.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
images/tar.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
images/telaen-logo.jpg
Normal file
After Width: | Height: | Size: 45 KiB |
BIN
images/top.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
images/zip.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
181
index.html
Normal file
|
@ -0,0 +1,181 @@
|
|||
<!doctype html>
|
||||
<!-- The Time Machine GitHub pages theme was designed and developed by Jon Rohan, on Feb 7, 2012. -->
|
||||
<!-- Follow him for fun. http://twitter.com/jonrohan. Tail his code on http://github.com/jonrohan -->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
|
||||
<link rel="stylesheet" href="stylesheets/stylesheet.css" media="screen"/>
|
||||
<link rel="stylesheet" href="stylesheets/pygment_trac.css"/>
|
||||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="javascripts/script.js"></script>
|
||||
|
||||
<title>Telaen</title>
|
||||
<meta name="description" content="Telaen is a webmail interface written in PHP. It does not require any external database and is compatible with POP3 or IMAP so it runs under any Server supporting PHP with Sendmail, QMAIL, Postfix, etc... Additional skins and languages can be easily integrated.">
|
||||
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="wrapper">
|
||||
<header>
|
||||
<h1 class="title">Telaen</h1>
|
||||
<h1 class="title"><img src="images/telaen-logo.jpg" alt="Telaen"></h1>
|
||||
</header>
|
||||
<div id="container">
|
||||
<p class="tagline">Telaen is a webmail interface written in PHP. It does not require any database and is compatible with POP3 or IMAP so it runs under any Server supporting PHP with Sendmail, QMAIL, Postfix, etc... Additional skins and languages can be easily integrated.</p>
|
||||
<div id="main" role="main">
|
||||
<div class="download-bar">
|
||||
<div class="inner">
|
||||
<a href="https://github.com/jimjag/telaen/tarball/telaen_1.x" class="download-button tar"><span>Download 1.3.2</span></a>
|
||||
<a href="https://github.com/jimjag/telaen/zipball/telaen_1.x" class="download-button zip"><span>Download 1.3.2</span></a>
|
||||
<a href="https://github.com/jimjag/telaen" class="code">View Telaen on GitHub</a>
|
||||
</div>
|
||||
<span class="blc"></span><span class="trc"></span>
|
||||
</div>
|
||||
<article class="markdown-body">
|
||||
<h1>
|
||||
<a name="telaen---a-full-featured-yet-simple-web-based-e-mail-client-written-in-php" class="anchor" href="#telaen---a-full-featured-yet-simple-web-based-e-mail-client-written-in-php"><span class="octicon octicon-link"></span></a>Telaen - A full-featured yet simple web-based e-mail client written in PHP</h1>
|
||||
|
||||
<h2>
|
||||
<a name="overview" class="anchor" href="#overview"><span class="octicon octicon-link"></span></a>Overview</h2>
|
||||
|
||||
<p>Telaen is a web-based e-mail client written in PHP. What is particularly
|
||||
nice about Telaen is that it is fast, lean and simple, but also extremely
|
||||
powerful. It does not require much more than a "standard" PHP
|
||||
installation, nor does it require an external database. It supports multiple
|
||||
folders, POP3 and IMAP, is SPAM aware and incorporates WYSIWYG editors
|
||||
for Email composition. It supports multiple languages as well as
|
||||
multiple themes (or "skins").</p>
|
||||
|
||||
<p>Telaen 1.3.x is compatible with PHP4 and PHP5. Starting with Telaen
|
||||
2.x, support for PHP4 will be dropped.</p>
|
||||
|
||||
<p>Telaen was originally based on Uebimiau.</p>
|
||||
|
||||
<p>We recommend that you read the other documents in the docs/ subdirectory,
|
||||
especially the CHANGELOG.txt and INSTALL.txt files.</p>
|
||||
|
||||
<h2>
|
||||
<a name="design-philosophy" class="anchor" href="#design-philosophy"><span class="octicon octicon-link"></span></a>Design Philosophy</h2>
|
||||
<p>First of all, Telaen is designed and architectured to be as small
|
||||
and as compact as possible; some may even say Telaen is "minimalistic".
|
||||
The reason is that as projects get larger and more complex, they are
|
||||
more difficult to update, to vet and review, and to keep secure.
|
||||
Simplicity, after all, is a virtue.</p>
|
||||
|
||||
<p>The other basic philosophy is to leverage PHP and existing 3rd
|
||||
party libraries as much as possible, but without making the level
|
||||
of dependencies onerous for the sys-admin. There's no need to
|
||||
re-create the wheel, unless we can do it faster, or easier.</p>
|
||||
|
||||
<p>Finally, as ex-sys-admins ourselves, as well as developers,
|
||||
Telaen is designed to be plug-and-play. Plugins are a great
|
||||
idea, and maybe Telaen will support them in the future, but
|
||||
requiring sys-admins to find, install, config and debug Plugins
|
||||
to add basic features that should be core to a webapp, doesn't
|
||||
make sense to us.</p>
|
||||
|
||||
<h2>
|
||||
<a name="why-you-might-need-it" class="anchor" href="#why-you-might-need-it"><span class="octicon octicon-link"></span></a>Why you might need it</h2>
|
||||
|
||||
<p>Other PHP-based webmails require external database support as well as a long
|
||||
laundry-list of other PHP libs and extensions; not Telaen. If
|
||||
you need an powerful yet simple and clean webmail system, Telaen will likely fit the bill.</p>
|
||||
|
||||
<p>And, if you are stuck running ancient Uebimiau, you should
|
||||
really move to Telaen asap.</p>
|
||||
|
||||
<h2>
|
||||
<a name="license" class="anchor" href="#license"><span class="octicon octicon-link"></span></a>License</h2>
|
||||
|
||||
<p>Telaen is free software distributed under GPLv2 terms; see <a href="http://www.gnu.org">www.gnu.org</a> for
|
||||
more informations. You can use or redistribute this software, but need to
|
||||
preserve the credits of author. Please read LICENSE for information on the
|
||||
software availability and distribution.</p>
|
||||
|
||||
<h2>
|
||||
<a name="features" class="anchor" href="#features"><span class="octicon octicon-link"></span></a>Features</h2>
|
||||
|
||||
<ul>
|
||||
<li>SMTP Compatible</li>
|
||||
<li>POP3 Compatible</li>
|
||||
<li>IMAP Compatible</li>
|
||||
<li>MIME Compatible</li>
|
||||
<li>Receive Attachments</li>
|
||||
<li>Send Attachments</li>
|
||||
<li>Folders/E-mail management support (Trash/Inbox/Sent/[Personal])</li>
|
||||
<li>Address book</li>
|
||||
<li>Language support</li>
|
||||
<li>Themes support</li>
|
||||
<li>Search in messages</li>
|
||||
<li>Personalized ordering of messages</li>
|
||||
<li>Personal preferences</li>
|
||||
<li>HTML e-mails (read/write)</li>
|
||||
<li>Quota Limit</li>
|
||||
<li>Auto population of SPAM folder for tagged SPAM messages</li>
|
||||
</ul><h2>
|
||||
<a name="localization" class="anchor" href="#localization"><span class="octicon octicon-link"></span></a>Localization</h2>
|
||||
|
||||
<p>PHPMailer defaults to English, but supports other language and UI themes (or 'skins').</p>
|
||||
|
||||
<h2>
|
||||
<a name="documentation" class="anchor" href="#documentation"><span class="octicon octicon-link"></span></a>Documentation</h2>
|
||||
|
||||
<p>You'll find some basic user-level docs in the docs folder</p>
|
||||
|
||||
<h2>
|
||||
<a name="dependencies" class="anchor" href="#dependencies"><span class="octicon octicon-link"></span></a>Dependencies</h2>
|
||||
|
||||
<p>Telaen is designed to work with as a vanilla, bare-bones build of PHP as
|
||||
possible. The below external dependencies are bundled for convenience:</p>
|
||||
|
||||
<ul>
|
||||
<li>Smarty</li>
|
||||
<li>TinyMCE</li>
|
||||
<li>PHPMailer</li>
|
||||
<li>iCalCreator</li>
|
||||
</ul>
|
||||
<p>Telaen is designed to work with both the bundled as well as the system-provided
|
||||
versions of these tools.</p>
|
||||
|
||||
<p>No external database is required.</p>
|
||||
|
||||
<h2>
|
||||
<a name="contributing" class="anchor" href="#contributing"><span class="octicon octicon-link"></span></a>Contributing</h2>
|
||||
|
||||
<p>Please submit bug reports, suggestions and pull requests to the <a href="https://github.com/jimjag/telaen/issues">GitHub issue tracker</a>.</p>
|
||||
|
||||
<p>We're particularly interested in fixing edge-cases, expanding test coverage and freshing-up
|
||||
the user UI.</p>
|
||||
|
||||
<h2>
|
||||
<a name="changelog" class="anchor" href="#changelog"><span class="octicon octicon-link"></span></a>Changelog</h2>
|
||||
|
||||
<p>See <a href="https://github.com/jimjag/telaen/blob/master/CHANGELOG.md">CHANGELOG.md</a> in ./docs/</p>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
<div class="owner">
|
||||
<p><a href="https://github.com/jimjag" class="avatar"><img src="https://secure.gravatar.com/avatar/a86203bd1e538f2a4e58eb8850fb66ef?s=30&d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png" width="48" height="48"/></a> <a href="https://github.com/jimjag">jimjag</a> maintains <a href="https://github.com/jimjag/telaen">Telaen</a></p>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="creds">
|
||||
<small>This page generated using <a href="https://pages.github.com/">GitHub Pages</a><br/>theme by <a href="http://twitter.com/jonrohan/">Jon Rohan</a></small>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
<div class="current-section">
|
||||
<a href="#top">Scroll to top</a>
|
||||
<a href="https://github.com/jimjag/telaen/tarball/master" class="tar">tar</a><a href="https://github.com/jimjag/telaen/zipball/master" class="zip">zip</a><a href="" class="code">source code</a>
|
||||
<p class="name"></p>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
52
javascripts/script.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
(function($) {
|
||||
$(document).ready(function(){
|
||||
|
||||
// putting lines by the pre blocks
|
||||
$("pre").each(function(){
|
||||
var pre = $(this).text().split("\n");
|
||||
var lines = new Array(pre.length+1);
|
||||
for(var i = 0; i < pre.length; i++) {
|
||||
var wrap = Math.floor(pre[i].split("").length / 70)
|
||||
if (pre[i]==""&&i==pre.length-1) {
|
||||
lines.splice(i, 1);
|
||||
} else {
|
||||
lines[i] = i+1;
|
||||
for(var j = 0; j < wrap; j++) {
|
||||
lines[i] += "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$(this).before("<pre class='lines'>" + lines.join("\n") + "</pre>");
|
||||
});
|
||||
|
||||
var headings = [];
|
||||
|
||||
var collectHeaders = function(){
|
||||
headings.push({"top":$(this).offset().top - 15,"text":$(this).text()});
|
||||
}
|
||||
|
||||
if($(".markdown-body h1").length > 1) $(".markdown-body h1").each(collectHeaders)
|
||||
else if($(".markdown-body h2").length > 1) $(".markdown-body h2").each(collectHeaders)
|
||||
else if($(".markdown-body h3").length > 1) $(".markdown-body h3").each(collectHeaders)
|
||||
|
||||
$(window).scroll(function(){
|
||||
if(headings.length==0) return true;
|
||||
var scrolltop = $(window).scrollTop() || 0;
|
||||
if(headings[0] && scrolltop < headings[0].top) {
|
||||
$(".current-section").css({"opacity":0,"visibility":"hidden"});
|
||||
return false;
|
||||
}
|
||||
$(".current-section").css({"opacity":1,"visibility":"visible"});
|
||||
for(var i in headings) {
|
||||
if(scrolltop >= headings[i].top) {
|
||||
$(".current-section .name").text(headings[i].text);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(".current-section a").click(function(){
|
||||
$(window).scrollTop(0);
|
||||
return false;
|
||||
})
|
||||
});
|
||||
})(jQuery)
|
1
params.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"name":"Telaen","tagline":"Telaen is a webmail interface written in PHP. It does not require any database and is compatible with POP3 or IMAP so it runs under any Server supporting PHP with Sendmail or QMAIL. Additional skins and languages can be easily integrated.","body":"# Telaen - A full-featured yet simple web-based e-mail client written in PHP\r\n\r\n## Overview\r\n\r\nTelaen is a web-based e-mail client written in PHP. What is particularly\r\nnice about Telaen is that it is fast, lean and simple, but also extremely\r\npowerful. It does not require much more than a \"standard\" PHP\r\ninstallation, nor does it require a database. It supports multiple\r\nfolders, POP3 and IMAP, is SPAM aware and incorporates a WYSIWYG editor\r\nfor Email composition. It supports multiple languages as well as\r\nmultiple themes (or \"skins\").\r\n\r\nTelaen 1.3.x is compatible with PHP4 and PHP5. Starting with Telaen\r\n2.x, support for PHP4 will be dropped.\r\n\r\nTelaen was originally based on Uebimiau.\r\n\r\nWe recommend that you read the other documents in the docs/ subdirectory,\r\nespecially the CHANGELOG.txt and INSTALL.txt files.\r\n\r\n## Why you might need it\r\n\r\nOther PHP-based webmails require database support as well as a long\r\nlaundry-list of other PHP libs and extensions; not Telaen. If\r\nyou need an expandable, powerful yet simple webmail system,\r\nTelaen will likely fit the bill.\r\n\r\nAnd, if you are stuck running ancient Uebimiau, you should\r\nreally move to Telaen asap.\r\n\r\n## License\r\n\r\nTelaen is free software distributed under GPLv2 terms; see www.gnu.org for\r\nmore informations. You can use or redistribute this software, but need to\r\npreserve the credits of author. Please read LICENSE for information on the\r\nsoftware availability and distribution.\r\n\r\n## Features\r\n\r\n- SMTP Compatible\r\n- POP3 Compatible\r\n- IMAP Compatible\r\n- MIME Compatible\r\n- Receive Attachments\r\n- Send Attachments\r\n- Folders/E-mail management support (Trash/Inbox/Sent/[Personal])\r\n- Address book\r\n- Language support\r\n- Themes support\r\n- Search in messages\r\n- Personalized order messages\r\n- Personal preferences\r\n- Send HTML e-mails\r\n- Quota Limit\r\n- Auto population of SPAM folder for tagged SPAM messages\r\n\r\n## Localization\r\nPHPMailer defaults to English, but supports other language and UI themes (or 'skins').\r\n\r\n## Documentation\r\n\r\nYou'll find some basic user-level docs in the docs folder\r\n\r\n## Dependencies\r\n\r\nTelaen is designed to work with as a vanilla, bare-bones build of PHP as\r\npossible. The below external dependencies are bundled for convenience:\r\n\r\n- Smarty\r\n- TinyMCE\r\n- PHPMailer\r\n- iCalCreator\r\n\r\nTelaen is designed to work with both the bundled as well as the system-provided\r\nversions of these tools.\r\n\r\nNo database is required.\r\n\r\n## Contributing\r\n\r\nPlease submit bug reports, suggestions and pull requests to the [GitHub issue tracker](https://github.com/jimjag/telaen/issues).\r\n\r\nWe're particularly interested in fixing edge-cases, expanding test coverage and dropping support for PHP4, PHP5.1\r\nand PHP5.2.\r\n\r\n## Changelog\r\n\r\nSee CHANGELOG.md in ./docs/\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}
|
Before Width: | Height: | Size: 219 KiB |
Before Width: | Height: | Size: 216 KiB |
Before Width: | Height: | Size: 267 KiB |
Before Width: | Height: | Size: 203 KiB |
Before Width: | Height: | Size: 198 KiB |
Before Width: | Height: | Size: 187 KiB |
Before Width: | Height: | Size: 198 KiB |
Before Width: | Height: | Size: 220 KiB |
Before Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 337 KiB |
Before Width: | Height: | Size: 113 KiB |
|
@ -1,2 +0,0 @@
|
|||
.DS_Store
|
||||
*~
|
|
@ -1,458 +0,0 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
|
@ -1,477 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Project: Smarty: the PHP compiling template engine
|
||||
* File: SmartyBC.class.php
|
||||
* SVN: $Id: $
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* For questions, help, comments, discussion, etc., please join the
|
||||
* Smarty mailing list. Send a blank e-mail to
|
||||
* smarty-discussion-subscribe@googlegroups.com
|
||||
*
|
||||
* @link http://www.smarty.net/
|
||||
* @copyright 2008 New Digital Group, Inc.
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
* @author Rodney Rehm
|
||||
* @package Smarty
|
||||
*/
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once dirname(__FILE__) . '/Smarty.class.php';
|
||||
|
||||
/**
|
||||
* Smarty Backward Compatibility Wrapper Class
|
||||
*
|
||||
* @package Smarty
|
||||
*/
|
||||
class SmartyBC extends Smarty
|
||||
{
|
||||
/**
|
||||
* Smarty 2 BC
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $_version = self::SMARTY_VERSION;
|
||||
|
||||
/**
|
||||
* This is an array of directories where trusted php scripts reside.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $trusted_dir = array();
|
||||
|
||||
/**
|
||||
* Initialize new SmartyBC object
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for assign_by_ref
|
||||
*
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed &$value the referenced value to assign
|
||||
*/
|
||||
public function assign_by_ref($tpl_var, &$value)
|
||||
{
|
||||
$this->assignByRef($tpl_var, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for append_by_ref
|
||||
*
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed &$value the referenced value to append
|
||||
* @param boolean $merge flag if array elements shall be merged
|
||||
*/
|
||||
public function append_by_ref($tpl_var, &$value, $merge = false)
|
||||
{
|
||||
$this->appendByRef($tpl_var, $value, $merge);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear the given assigned template variable.
|
||||
*
|
||||
* @param string $tpl_var the template variable to clear
|
||||
*/
|
||||
public function clear_assign($tpl_var)
|
||||
{
|
||||
$this->clearAssign($tpl_var);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers custom function to be used in templates
|
||||
*
|
||||
* @param string $function the name of the template function
|
||||
* @param string $function_impl the name of the PHP function to register
|
||||
* @param bool $cacheable
|
||||
* @param mixed $cache_attrs
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function register_function($function, $function_impl, $cacheable = true, $cache_attrs = null)
|
||||
{
|
||||
$this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister custom function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
*/
|
||||
public function unregister_function($function)
|
||||
{
|
||||
$this->unregisterPlugin('function', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers object to be used in templates
|
||||
*
|
||||
* @param string $object name of template object
|
||||
* @param object $object_impl the referenced PHP object to register
|
||||
* @param array $allowed list of allowed methods (empty = all)
|
||||
* @param boolean $smarty_args smarty argument format, else traditional
|
||||
* @param array $block_methods list of methods that are block format
|
||||
*
|
||||
* @throws SmartyException
|
||||
* @internal param array $block_functs list of methods that are block format
|
||||
*/
|
||||
public function register_object(
|
||||
$object,
|
||||
$object_impl,
|
||||
$allowed = array(),
|
||||
$smarty_args = true,
|
||||
$block_methods = array()
|
||||
) {
|
||||
settype($allowed, 'array');
|
||||
settype($smarty_args, 'boolean');
|
||||
$this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister object
|
||||
*
|
||||
* @param string $object name of template object
|
||||
*/
|
||||
public function unregister_object($object)
|
||||
{
|
||||
$this->unregisterObject($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers block function to be used in templates
|
||||
*
|
||||
* @param string $block name of template block
|
||||
* @param string $block_impl PHP function to register
|
||||
* @param bool $cacheable
|
||||
* @param mixed $cache_attrs
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function register_block($block, $block_impl, $cacheable = true, $cache_attrs = null)
|
||||
{
|
||||
$this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister block function
|
||||
*
|
||||
* @param string $block name of template function
|
||||
*/
|
||||
public function unregister_block($block)
|
||||
{
|
||||
$this->unregisterPlugin('block', $block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers compiler function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
* @param string $function_impl name of PHP function to register
|
||||
* @param bool $cacheable
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function register_compiler_function($function, $function_impl, $cacheable = true)
|
||||
{
|
||||
$this->registerPlugin('compiler', $function, $function_impl, $cacheable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister compiler function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
*/
|
||||
public function unregister_compiler_function($function)
|
||||
{
|
||||
$this->unregisterPlugin('compiler', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers modifier to be used in templates
|
||||
*
|
||||
* @param string $modifier name of template modifier
|
||||
* @param string $modifier_impl name of PHP function to register
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function register_modifier($modifier, $modifier_impl)
|
||||
{
|
||||
$this->registerPlugin('modifier', $modifier, $modifier_impl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister modifier
|
||||
*
|
||||
* @param string $modifier name of template modifier
|
||||
*/
|
||||
public function unregister_modifier($modifier)
|
||||
{
|
||||
$this->unregisterPlugin('modifier', $modifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a resource to fetch a template
|
||||
*
|
||||
* @param string $type name of resource
|
||||
* @param array $functions array of functions to handle resource
|
||||
*/
|
||||
public function register_resource($type, $functions)
|
||||
{
|
||||
$this->registerResource($type, $functions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a resource
|
||||
*
|
||||
* @param string $type name of resource
|
||||
*/
|
||||
public function unregister_resource($type)
|
||||
{
|
||||
$this->unregisterResource($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a prefilter function to apply
|
||||
* to a template before compiling
|
||||
*
|
||||
* @param callable $function
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function register_prefilter($function)
|
||||
{
|
||||
$this->registerFilter('pre', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a prefilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_prefilter($function)
|
||||
{
|
||||
$this->unregisterFilter('pre', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a postfilter function to apply
|
||||
* to a compiled template after compilation
|
||||
*
|
||||
* @param callable $function
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function register_postfilter($function)
|
||||
{
|
||||
$this->registerFilter('post', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a postfilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_postfilter($function)
|
||||
{
|
||||
$this->unregisterFilter('post', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an output filter function to apply
|
||||
* to a template output
|
||||
*
|
||||
* @param callable $function
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function register_outputfilter($function)
|
||||
{
|
||||
$this->registerFilter('output', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister an outputfilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_outputfilter($function)
|
||||
{
|
||||
$this->unregisterFilter('output', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* load a filter of specified type and name
|
||||
*
|
||||
* @param string $type filter type
|
||||
* @param string $name filter name
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function load_filter($type, $name)
|
||||
{
|
||||
$this->loadFilter($type, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear cached content for the given template and cache id
|
||||
*
|
||||
* @param string $tpl_file name of template file
|
||||
* @param string $cache_id name of cache_id
|
||||
* @param string $compile_id name of compile_id
|
||||
* @param string $exp_time expiration time
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
|
||||
{
|
||||
return $this->clearCache($tpl_file, $cache_id, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear the entire contents of cache (all templates)
|
||||
*
|
||||
* @param string $exp_time expire time
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear_all_cache($exp_time = null)
|
||||
{
|
||||
return $this->clearCache(null, null, null, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* test to see if valid cache exists for this template
|
||||
*
|
||||
* @param string $tpl_file name of template file
|
||||
* @param string $cache_id
|
||||
* @param string $compile_id
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function is_cached($tpl_file, $cache_id = null, $compile_id = null)
|
||||
{
|
||||
return $this->isCached($tpl_file, $cache_id, $compile_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear all the assigned template variables.
|
||||
*/
|
||||
public function clear_all_assign()
|
||||
{
|
||||
$this->clearAllAssign();
|
||||
}
|
||||
|
||||
/**
|
||||
* clears compiled version of specified template resource,
|
||||
* or all compiled template files if one is not specified.
|
||||
* This function is for advanced use only, not normally needed.
|
||||
*
|
||||
* @param string $tpl_file
|
||||
* @param string $compile_id
|
||||
* @param string $exp_time
|
||||
*
|
||||
* @return boolean results of {@link smarty_core_rm_auto()}
|
||||
*/
|
||||
public function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
|
||||
{
|
||||
return $this->clearCompiledTemplate($tpl_file, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether requested template exists.
|
||||
*
|
||||
* @param string $tpl_file
|
||||
*
|
||||
* @return bool
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function template_exists($tpl_file)
|
||||
{
|
||||
return $this->templateExists($tpl_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing template variables
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_template_vars($name = null)
|
||||
{
|
||||
return $this->getTemplateVars($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing config variables
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_config_vars($name = null)
|
||||
{
|
||||
return $this->getConfigVars($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* load configuration values
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $section
|
||||
* @param string $scope
|
||||
*/
|
||||
public function config_load($file, $section = null, $scope = 'global')
|
||||
{
|
||||
$this->ConfigLoad($file, $section, $scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* return a reference to a registered object
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function get_registered_object($name)
|
||||
{
|
||||
return $this->getRegisteredObject($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear configuration values
|
||||
*
|
||||
* @param string $var
|
||||
*/
|
||||
public function clear_config($var = null)
|
||||
{
|
||||
$this->clearConfig($var);
|
||||
}
|
||||
|
||||
/**
|
||||
* trigger Smarty error
|
||||
*
|
||||
* @param string $error_msg
|
||||
* @param integer $error_type
|
||||
*/
|
||||
public function trigger_error($error_msg, $error_type = E_USER_WARNING)
|
||||
{
|
||||
trigger_error("Smarty error: $error_msg", $error_type);
|
||||
}
|
||||
}
|
|
@ -1,160 +0,0 @@
|
|||
{capture name='_smarty_debug' assign=debug_output}
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>Smarty Debug Console</title>
|
||||
<style type="text/css">
|
||||
{literal}
|
||||
body, h1, h2, h3, td, th, p {
|
||||
font-family: sans-serif;
|
||||
font-weight: normal;
|
||||
font-size: 0.9em;
|
||||
margin: 1px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
text-align: left;
|
||||
padding: 2px;
|
||||
background-color: #f0c040;
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
background-color: #9B410E;
|
||||
color: white;
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
padding: 2px;
|
||||
border-top: 1px solid black;
|
||||
}
|
||||
h3 {
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
color: black;
|
||||
font-size: 0.7em;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
body {
|
||||
background: black;
|
||||
}
|
||||
|
||||
p, table, div {
|
||||
background: #f0ead8;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
th, td {
|
||||
font-family: monospace;
|
||||
vertical-align: top;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
td {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.odd {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
.even {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.exectime {
|
||||
font-size: 0.8em;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#bold div {
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
}
|
||||
#blue h3 {
|
||||
color: blue;
|
||||
}
|
||||
#normal div {
|
||||
color: black;
|
||||
font-weight: normal;
|
||||
}
|
||||
#table_assigned_vars th {
|
||||
color: blue;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#table_config_vars th {
|
||||
color: maroon;
|
||||
}
|
||||
|
||||
{/literal}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Smarty {Smarty::SMARTY_VERSION} Debug Console
|
||||
- {if isset($template_name)}{$template_name|debug_print_var nofilter} {/if}{if !empty($template_data)}Total Time {$execution_time|string_format:"%.5f"}{/if}</h1>
|
||||
|
||||
{if !empty($template_data)}
|
||||
<h2>included templates & config files (load time in seconds)</h2>
|
||||
<div>
|
||||
{foreach $template_data as $template}
|
||||
<font color=brown>{$template.name}</font>
|
||||
<br /> <span class="exectime">
|
||||
(compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"})
|
||||
</span>
|
||||
<br />
|
||||
{/foreach}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<h2>assigned template variables</h2>
|
||||
|
||||
<table id="table_assigned_vars">
|
||||
{foreach $assigned_vars as $vars}
|
||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
||||
<td><h3><font color=blue>${$vars@key}</font></h3>
|
||||
{if isset($vars['nocache'])}<b>Nocache</b><br />{/if}
|
||||
{if isset($vars['scope'])}<b>Origin:</b> {$vars['scope']|debug_print_var nofilter}{/if}
|
||||
</td>
|
||||
<td><h3>Value</h3>{$vars['value']|debug_print_var:10:80 nofilter}</td>
|
||||
<td>{if isset($vars['attributes'])}<h3>Attributes</h3>{$vars['attributes']|debug_print_var nofilter} {/if}</td>
|
||||
{/foreach}
|
||||
</table>
|
||||
|
||||
<h2>assigned config file variables</h2>
|
||||
|
||||
<table id="table_config_vars">
|
||||
{foreach $config_vars as $vars}
|
||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
||||
<td><h3><font color=blue>#{$vars@key}#</font></h3>
|
||||
{if isset($vars['scope'])}<b>Origin:</b> {$vars['scope']|debug_print_var nofilter}{/if}
|
||||
</td>
|
||||
<td>{$vars['value']|debug_print_var:10:80 nofilter}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
{/capture}
|
||||
<script type="text/javascript">
|
||||
{$id = '__Smarty__'}
|
||||
{if $display_mode}{$id = "$offset$template_name"|md5}{/if}
|
||||
_smarty_console = window.open("", "console{$id}", "width=1024,height=600,left={$offset},top={$offset},resizable,scrollbars=yes");
|
||||
_smarty_console.document.write("{$debug_output|escape:'javascript' nofilter}");
|
||||
_smarty_console.document.close();
|
||||
</script>
|
|
@ -1,121 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin to format text blocks
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsBlock
|
||||
*/
|
||||
/**
|
||||
* Smarty {textformat}{/textformat} block plugin
|
||||
* Type: block function
|
||||
* Name: textformat
|
||||
* Purpose: format text a certain way with preset styles
|
||||
* or custom wrap/indent settings
|
||||
* Params:
|
||||
*
|
||||
* - style - string (email)
|
||||
* - indent - integer (0)
|
||||
* - wrap - integer (80)
|
||||
* - wrap_char - string ("\n")
|
||||
* - indent_char - string (" ")
|
||||
* - wrap_boundary - boolean (true)
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
|
||||
* (Smarty online manual)
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param string $content contents of the block
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
* @param boolean &$repeat repeat flag
|
||||
*
|
||||
* @return string content re-formatted
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
function smarty_block_textformat($params, $content, Smarty_Internal_Template $template, &$repeat)
|
||||
{
|
||||
if (is_null($content)) {
|
||||
return;
|
||||
}
|
||||
if (Smarty::$_MBSTRING) {
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_modifier_mb_wordwrap',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
$style = null;
|
||||
$indent = 0;
|
||||
$indent_first = 0;
|
||||
$indent_char = ' ';
|
||||
$wrap = 80;
|
||||
$wrap_char = "\n";
|
||||
$wrap_cut = false;
|
||||
$assign = null;
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'style':
|
||||
case 'indent_char':
|
||||
case 'wrap_char':
|
||||
case 'assign':
|
||||
$$_key = (string)$_val;
|
||||
break;
|
||||
case 'indent':
|
||||
case 'indent_first':
|
||||
case 'wrap':
|
||||
$$_key = (int)$_val;
|
||||
break;
|
||||
case 'wrap_cut':
|
||||
$$_key = (bool)$_val;
|
||||
break;
|
||||
default:
|
||||
trigger_error("textformat: unknown attribute '{$_key}'");
|
||||
}
|
||||
}
|
||||
if ($style === 'email') {
|
||||
$wrap = 72;
|
||||
}
|
||||
// split into paragraphs
|
||||
$_paragraphs = preg_split('![\r\n]{2}!', $content);
|
||||
foreach ($_paragraphs as &$_paragraph) {
|
||||
if (!$_paragraph) {
|
||||
continue;
|
||||
}
|
||||
// convert mult. spaces & special chars to single space
|
||||
$_paragraph =
|
||||
preg_replace(
|
||||
array(
|
||||
'!\s+!' . Smarty::$_UTF8_MODIFIER,
|
||||
'!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER
|
||||
),
|
||||
array(
|
||||
' ',
|
||||
''
|
||||
),
|
||||
$_paragraph
|
||||
);
|
||||
// indent first line
|
||||
if ($indent_first > 0) {
|
||||
$_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph;
|
||||
}
|
||||
// wordwrap sentences
|
||||
if (Smarty::$_MBSTRING) {
|
||||
$_paragraph = smarty_modifier_mb_wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
|
||||
} else {
|
||||
$_paragraph = wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
|
||||
}
|
||||
// indent lines
|
||||
if ($indent > 0) {
|
||||
$_paragraph = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraph);
|
||||
}
|
||||
}
|
||||
$_output = implode($wrap_char . $wrap_char, $_paragraphs);
|
||||
if ($assign) {
|
||||
$template->assign($assign, $_output);
|
||||
} else {
|
||||
return $_output;
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
/**
|
||||
* Smarty {counter} function plugin
|
||||
* Type: function
|
||||
* Name: counter
|
||||
* Purpose: print out a counter value
|
||||
*
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @link http://www.smarty.net/manual/en/language.function.counter.php {counter}
|
||||
* (Smarty online manual)
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function smarty_function_counter($params, $template)
|
||||
{
|
||||
static $counters = array();
|
||||
$name = (isset($params[ 'name' ])) ? $params[ 'name' ] : 'default';
|
||||
if (!isset($counters[ $name ])) {
|
||||
$counters[ $name ] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1);
|
||||
}
|
||||
$counter =& $counters[ $name ];
|
||||
if (isset($params[ 'start' ])) {
|
||||
$counter[ 'start' ] = $counter[ 'count' ] = (int)$params[ 'start' ];
|
||||
}
|
||||
if (!empty($params[ 'assign' ])) {
|
||||
$counter[ 'assign' ] = $params[ 'assign' ];
|
||||
}
|
||||
if (isset($counter[ 'assign' ])) {
|
||||
$template->assign($counter[ 'assign' ], $counter[ 'count' ]);
|
||||
}
|
||||
if (isset($params[ 'print' ])) {
|
||||
$print = (bool)$params[ 'print' ];
|
||||
} else {
|
||||
$print = empty($counter[ 'assign' ]);
|
||||
}
|
||||
if ($print) {
|
||||
$retval = $counter[ 'count' ];
|
||||
} else {
|
||||
$retval = null;
|
||||
}
|
||||
if (isset($params[ 'skip' ])) {
|
||||
$counter[ 'skip' ] = $params[ 'skip' ];
|
||||
}
|
||||
if (isset($params[ 'direction' ])) {
|
||||
$counter[ 'direction' ] = $params[ 'direction' ];
|
||||
}
|
||||
if ($counter[ 'direction' ] === 'down') {
|
||||
$counter[ 'count' ] -= $counter[ 'skip' ];
|
||||
} else {
|
||||
$counter[ 'count' ] += $counter[ 'skip' ];
|
||||
}
|
||||
return $retval;
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
/**
|
||||
* Smarty {cycle} function plugin
|
||||
* Type: function
|
||||
* Name: cycle
|
||||
* Date: May 3, 2002
|
||||
* Purpose: cycle through given values
|
||||
* Params:
|
||||
*
|
||||
* - name - name of cycle (optional)
|
||||
* - values - comma separated list of values to cycle, or an array of values to cycle
|
||||
* (this can be left out for subsequent calls)
|
||||
* - reset - boolean - resets given var to true
|
||||
* - print - boolean - print var or not. default is true
|
||||
* - advance - boolean - whether or not to advance the cycle
|
||||
* - delimiter - the value delimiter, default is ","
|
||||
* - assign - boolean, assigns to template var instead of printed.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* {cycle values="#eeeeee,#d0d0d0d"}
|
||||
* {cycle name=row values="one,two,three" reset=true}
|
||||
* {cycle name=row}
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credit to Mark Priatel <mpriatel@rogers.com>
|
||||
* @author credit to Gerard <gerard@interfold.com>
|
||||
* @author credit to Jason Sweat <jsweat_php@yahoo.com>
|
||||
* @version 1.3
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function smarty_function_cycle($params, $template)
|
||||
{
|
||||
static $cycle_vars;
|
||||
$name = (empty($params[ 'name' ])) ? 'default' : $params[ 'name' ];
|
||||
$print = (isset($params[ 'print' ])) ? (bool)$params[ 'print' ] : true;
|
||||
$advance = (isset($params[ 'advance' ])) ? (bool)$params[ 'advance' ] : true;
|
||||
$reset = (isset($params[ 'reset' ])) ? (bool)$params[ 'reset' ] : false;
|
||||
if (!isset($params[ 'values' ])) {
|
||||
if (!isset($cycle_vars[ $name ][ 'values' ])) {
|
||||
trigger_error('cycle: missing \'values\' parameter');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (isset($cycle_vars[ $name ][ 'values' ]) && $cycle_vars[ $name ][ 'values' ] !== $params[ 'values' ]) {
|
||||
$cycle_vars[ $name ][ 'index' ] = 0;
|
||||
}
|
||||
$cycle_vars[ $name ][ 'values' ] = $params[ 'values' ];
|
||||
}
|
||||
if (isset($params[ 'delimiter' ])) {
|
||||
$cycle_vars[ $name ][ 'delimiter' ] = $params[ 'delimiter' ];
|
||||
} elseif (!isset($cycle_vars[ $name ][ 'delimiter' ])) {
|
||||
$cycle_vars[ $name ][ 'delimiter' ] = ',';
|
||||
}
|
||||
if (is_array($cycle_vars[ $name ][ 'values' ])) {
|
||||
$cycle_array = $cycle_vars[ $name ][ 'values' ];
|
||||
} else {
|
||||
$cycle_array = explode($cycle_vars[ $name ][ 'delimiter' ], $cycle_vars[ $name ][ 'values' ]);
|
||||
}
|
||||
if (!isset($cycle_vars[ $name ][ 'index' ]) || $reset) {
|
||||
$cycle_vars[ $name ][ 'index' ] = 0;
|
||||
}
|
||||
if (isset($params[ 'assign' ])) {
|
||||
$print = false;
|
||||
$template->assign($params[ 'assign' ], $cycle_array[ $cycle_vars[ $name ][ 'index' ] ]);
|
||||
}
|
||||
if ($print) {
|
||||
$retval = $cycle_array[ $cycle_vars[ $name ][ 'index' ] ];
|
||||
} else {
|
||||
$retval = null;
|
||||
}
|
||||
if ($advance) {
|
||||
if ($cycle_vars[ $name ][ 'index' ] >= count($cycle_array) - 1) {
|
||||
$cycle_vars[ $name ][ 'index' ] = 0;
|
||||
} else {
|
||||
$cycle_vars[ $name ][ 'index' ]++;
|
||||
}
|
||||
}
|
||||
return $retval;
|
||||
}
|
|
@ -1,204 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
/**
|
||||
* Smarty {fetch} plugin
|
||||
* Type: function
|
||||
* Name: fetch
|
||||
* Purpose: fetch file, web or ftp data and display results
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.fetch.php {fetch}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
*
|
||||
* @throws SmartyException
|
||||
* @return string|null if the assign parameter is passed, Smarty assigns the result to a template variable
|
||||
*/
|
||||
function smarty_function_fetch($params, $template)
|
||||
{
|
||||
if (empty($params[ 'file' ])) {
|
||||
trigger_error('[plugin] fetch parameter \'file\' cannot be empty', E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
// strip file protocol
|
||||
if (stripos($params[ 'file' ], 'file://') === 0) {
|
||||
$params[ 'file' ] = substr($params[ 'file' ], 7);
|
||||
}
|
||||
$protocol = strpos($params[ 'file' ], '://');
|
||||
if ($protocol !== false) {
|
||||
$protocol = strtolower(substr($params[ 'file' ], 0, $protocol));
|
||||
}
|
||||
if (isset($template->smarty->security_policy)) {
|
||||
if ($protocol) {
|
||||
// remote resource (or php stream, …)
|
||||
if (!$template->smarty->security_policy->isTrustedUri($params[ 'file' ])) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// local file
|
||||
if (!$template->smarty->security_policy->isTrustedResourceDir($params[ 'file' ])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
$content = '';
|
||||
if ($protocol === 'http') {
|
||||
// http fetch
|
||||
if ($uri_parts = parse_url($params[ 'file' ])) {
|
||||
// set defaults
|
||||
$host = $server_name = $uri_parts[ 'host' ];
|
||||
$timeout = 30;
|
||||
$accept = 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*';
|
||||
$agent = 'Smarty Template Engine ' . Smarty::SMARTY_VERSION;
|
||||
$referer = '';
|
||||
$uri = !empty($uri_parts[ 'path' ]) ? $uri_parts[ 'path' ] : '/';
|
||||
$uri .= !empty($uri_parts[ 'query' ]) ? '?' . $uri_parts[ 'query' ] : '';
|
||||
$_is_proxy = false;
|
||||
if (empty($uri_parts[ 'port' ])) {
|
||||
$port = 80;
|
||||
} else {
|
||||
$port = $uri_parts[ 'port' ];
|
||||
}
|
||||
if (!empty($uri_parts[ 'user' ])) {
|
||||
$user = $uri_parts[ 'user' ];
|
||||
}
|
||||
if (!empty($uri_parts[ 'pass' ])) {
|
||||
$pass = $uri_parts[ 'pass' ];
|
||||
}
|
||||
// loop through parameters, setup headers
|
||||
foreach ($params as $param_key => $param_value) {
|
||||
switch ($param_key) {
|
||||
case 'file':
|
||||
case 'assign':
|
||||
case 'assign_headers':
|
||||
break;
|
||||
case 'user':
|
||||
if (!empty($param_value)) {
|
||||
$user = $param_value;
|
||||
}
|
||||
break;
|
||||
case 'pass':
|
||||
if (!empty($param_value)) {
|
||||
$pass = $param_value;
|
||||
}
|
||||
break;
|
||||
case 'accept':
|
||||
if (!empty($param_value)) {
|
||||
$accept = $param_value;
|
||||
}
|
||||
break;
|
||||
case 'header':
|
||||
if (!empty($param_value)) {
|
||||
if (!preg_match('![\w\d-]+: .+!', $param_value)) {
|
||||
trigger_error("[plugin] invalid header format '{$param_value}'", E_USER_NOTICE);
|
||||
return;
|
||||
} else {
|
||||
$extra_headers[] = $param_value;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'proxy_host':
|
||||
if (!empty($param_value)) {
|
||||
$proxy_host = $param_value;
|
||||
}
|
||||
break;
|
||||
case 'proxy_port':
|
||||
if (!preg_match('!\D!', $param_value)) {
|
||||
$proxy_port = (int)$param_value;
|
||||
} else {
|
||||
trigger_error("[plugin] invalid value for attribute '{$param_key }'", E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 'agent':
|
||||
if (!empty($param_value)) {
|
||||
$agent = $param_value;
|
||||
}
|
||||
break;
|
||||
case 'referer':
|
||||
if (!empty($param_value)) {
|
||||
$referer = $param_value;
|
||||
}
|
||||
break;
|
||||
case 'timeout':
|
||||
if (!preg_match('!\D!', $param_value)) {
|
||||
$timeout = (int)$param_value;
|
||||
} else {
|
||||
trigger_error("[plugin] invalid value for attribute '{$param_key}'", E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
trigger_error("[plugin] unrecognized attribute '{$param_key}'", E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!empty($proxy_host) && !empty($proxy_port)) {
|
||||
$_is_proxy = true;
|
||||
$fp = fsockopen($proxy_host, $proxy_port, $errno, $errstr, $timeout);
|
||||
} else {
|
||||
$fp = fsockopen($server_name, $port, $errno, $errstr, $timeout);
|
||||
}
|
||||
if (!$fp) {
|
||||
trigger_error("[plugin] unable to fetch: $errstr ($errno)", E_USER_NOTICE);
|
||||
return;
|
||||
} else {
|
||||
if ($_is_proxy) {
|
||||
fputs($fp, 'GET ' . $params[ 'file' ] . " HTTP/1.0\r\n");
|
||||
} else {
|
||||
fputs($fp, "GET $uri HTTP/1.0\r\n");
|
||||
}
|
||||
if (!empty($host)) {
|
||||
fputs($fp, "Host: $host\r\n");
|
||||
}
|
||||
if (!empty($accept)) {
|
||||
fputs($fp, "Accept: $accept\r\n");
|
||||
}
|
||||
if (!empty($agent)) {
|
||||
fputs($fp, "User-Agent: $agent\r\n");
|
||||
}
|
||||
if (!empty($referer)) {
|
||||
fputs($fp, "Referer: $referer\r\n");
|
||||
}
|
||||
if (isset($extra_headers) && is_array($extra_headers)) {
|
||||
foreach ($extra_headers as $curr_header) {
|
||||
fputs($fp, $curr_header . "\r\n");
|
||||
}
|
||||
}
|
||||
if (!empty($user) && !empty($pass)) {
|
||||
fputs($fp, 'Authorization: BASIC ' . base64_encode("$user:$pass") . "\r\n");
|
||||
}
|
||||
fputs($fp, "\r\n");
|
||||
while (!feof($fp)) {
|
||||
$content .= fgets($fp, 4096);
|
||||
}
|
||||
fclose($fp);
|
||||
$csplit = preg_split("!\r\n\r\n!", $content, 2);
|
||||
$content = $csplit[ 1 ];
|
||||
if (!empty($params[ 'assign_headers' ])) {
|
||||
$template->assign($params[ 'assign_headers' ], preg_split("!\r\n!", $csplit[ 0 ]));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
trigger_error("[plugin fetch] unable to parse URL, check syntax", E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$content = @file_get_contents($params[ 'file' ]);
|
||||
if ($content === false) {
|
||||
throw new SmartyException("{fetch} cannot read resource '" . $params[ 'file' ] . "'");
|
||||
}
|
||||
}
|
||||
if (!empty($params[ 'assign' ])) {
|
||||
$template->assign($params[ 'assign' ], $content);
|
||||
} else {
|
||||
return $content;
|
||||
}
|
||||
}
|
|
@ -1,286 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
/**
|
||||
* Smarty {html_checkboxes} function plugin
|
||||
* File: function.html_checkboxes.php
|
||||
* Type: function
|
||||
* Name: html_checkboxes
|
||||
* Date: 24.Feb.2003
|
||||
* Purpose: Prints out a list of checkbox input types
|
||||
* Examples:
|
||||
*
|
||||
* {html_checkboxes values=$ids output=$names}
|
||||
* {html_checkboxes values=$ids name='box' separator='<br>' output=$names}
|
||||
* {html_checkboxes values=$ids checked=$checked separator='<br>' output=$names}
|
||||
*
|
||||
* Params:
|
||||
*
|
||||
* - name (optional) - string default "checkbox"
|
||||
* - values (required) - array
|
||||
* - options (optional) - associative array
|
||||
* - checked (optional) - array default not set
|
||||
* - separator (optional) - ie <br> or
|
||||
* - output (optional) - the output next to each checkbox
|
||||
* - assign (optional) - assign the output as an array to this variable
|
||||
* - escape (optional) - escape the content (not value), defaults to true
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
|
||||
* (Smarty online manual)
|
||||
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
||||
* @author credits to Monte Ohrt <monte at ohrt dot com>
|
||||
* @version 1.0
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
*
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
function smarty_function_html_checkboxes($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_function_escape_special_chars',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
$name = 'checkbox';
|
||||
$values = null;
|
||||
$options = null;
|
||||
$selected = array();
|
||||
$separator = '';
|
||||
$escape = true;
|
||||
$labels = true;
|
||||
$label_ids = false;
|
||||
$output = null;
|
||||
$extra = '';
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'name':
|
||||
case 'separator':
|
||||
$$_key = (string)$_val;
|
||||
break;
|
||||
case 'escape':
|
||||
case 'labels':
|
||||
case 'label_ids':
|
||||
$$_key = (bool)$_val;
|
||||
break;
|
||||
case 'options':
|
||||
$$_key = (array)$_val;
|
||||
break;
|
||||
case 'values':
|
||||
case 'output':
|
||||
$$_key = array_values((array)$_val);
|
||||
break;
|
||||
case 'checked':
|
||||
case 'selected':
|
||||
if (is_array($_val)) {
|
||||
$selected = array();
|
||||
foreach ($_val as $_sel) {
|
||||
if (is_object($_sel)) {
|
||||
if (method_exists($_sel, '__toString')) {
|
||||
$_sel = smarty_function_escape_special_chars((string)$_sel->__toString());
|
||||
} else {
|
||||
trigger_error(
|
||||
'html_checkboxes: selected attribute contains an object of class \'' .
|
||||
get_class($_sel) . '\' without __toString() method',
|
||||
E_USER_NOTICE
|
||||
);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
$_sel = smarty_function_escape_special_chars((string)$_sel);
|
||||
}
|
||||
$selected[ $_sel ] = true;
|
||||
}
|
||||
} elseif (is_object($_val)) {
|
||||
if (method_exists($_val, '__toString')) {
|
||||
$selected = smarty_function_escape_special_chars((string)$_val->__toString());
|
||||
} else {
|
||||
trigger_error(
|
||||
'html_checkboxes: selected attribute is an object of class \'' . get_class($_val) .
|
||||
'\' without __toString() method',
|
||||
E_USER_NOTICE
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$selected = smarty_function_escape_special_chars((string)$_val);
|
||||
}
|
||||
break;
|
||||
case 'checkboxes':
|
||||
trigger_error(
|
||||
'html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead',
|
||||
E_USER_WARNING
|
||||
);
|
||||
$options = (array)$_val;
|
||||
break;
|
||||
case 'assign':
|
||||
break;
|
||||
case 'strict':
|
||||
break;
|
||||
case 'disabled':
|
||||
case 'readonly':
|
||||
if (!empty($params[ 'strict' ])) {
|
||||
if (!is_scalar($_val)) {
|
||||
trigger_error(
|
||||
"html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
|
||||
E_USER_NOTICE
|
||||
);
|
||||
}
|
||||
if ($_val === true || $_val === $_key) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
|
||||
}
|
||||
break;
|
||||
}
|
||||
// omit break; to fall through!
|
||||
// no break
|
||||
default:
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
} else {
|
||||
trigger_error("html_checkboxes: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isset($options) && !isset($values)) {
|
||||
return '';
|
||||
} /* raise error here? */
|
||||
$_html_result = array();
|
||||
if (isset($options)) {
|
||||
foreach ($options as $_key => $_val) {
|
||||
$_html_result[] =
|
||||
smarty_function_html_checkboxes_output(
|
||||
$name,
|
||||
$_key,
|
||||
$_val,
|
||||
$selected,
|
||||
$extra,
|
||||
$separator,
|
||||
$labels,
|
||||
$label_ids,
|
||||
$escape
|
||||
);
|
||||
}
|
||||
} else {
|
||||
foreach ($values as $_i => $_key) {
|
||||
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
|
||||
$_html_result[] =
|
||||
smarty_function_html_checkboxes_output(
|
||||
$name,
|
||||
$_key,
|
||||
$_val,
|
||||
$selected,
|
||||
$extra,
|
||||
$separator,
|
||||
$labels,
|
||||
$label_ids,
|
||||
$escape
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!empty($params[ 'assign' ])) {
|
||||
$template->assign($params[ 'assign' ], $_html_result);
|
||||
} else {
|
||||
return implode("\n", $_html_result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $value
|
||||
* @param $output
|
||||
* @param $selected
|
||||
* @param $extra
|
||||
* @param $separator
|
||||
* @param $labels
|
||||
* @param $label_ids
|
||||
* @param bool $escape
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_html_checkboxes_output(
|
||||
$name,
|
||||
$value,
|
||||
$output,
|
||||
$selected,
|
||||
$extra,
|
||||
$separator,
|
||||
$labels,
|
||||
$label_ids,
|
||||
$escape = true
|
||||
) {
|
||||
$_output = '';
|
||||
if (is_object($value)) {
|
||||
if (method_exists($value, '__toString')) {
|
||||
$value = (string)$value->__toString();
|
||||
} else {
|
||||
trigger_error(
|
||||
'html_options: value is an object of class \'' . get_class($value) .
|
||||
'\' without __toString() method',
|
||||
E_USER_NOTICE
|
||||
);
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$value = (string)$value;
|
||||
}
|
||||
if (is_object($output)) {
|
||||
if (method_exists($output, '__toString')) {
|
||||
$output = (string)$output->__toString();
|
||||
} else {
|
||||
trigger_error(
|
||||
'html_options: output is an object of class \'' . get_class($output) .
|
||||
'\' without __toString() method',
|
||||
E_USER_NOTICE
|
||||
);
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$output = (string)$output;
|
||||
}
|
||||
if ($labels) {
|
||||
if ($label_ids) {
|
||||
$_id = smarty_function_escape_special_chars(
|
||||
preg_replace(
|
||||
'![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER,
|
||||
'_',
|
||||
$name . '_' . $value
|
||||
)
|
||||
);
|
||||
$_output .= '<label for="' . $_id . '">';
|
||||
} else {
|
||||
$_output .= '<label>';
|
||||
}
|
||||
}
|
||||
$name = smarty_function_escape_special_chars($name);
|
||||
$value = smarty_function_escape_special_chars($value);
|
||||
if ($escape) {
|
||||
$output = smarty_function_escape_special_chars($output);
|
||||
}
|
||||
$_output .= '<input type="checkbox" name="' . $name . '[]" value="' . $value . '"';
|
||||
if ($labels && $label_ids) {
|
||||
$_output .= ' id="' . $_id . '"';
|
||||
}
|
||||
if (is_array($selected)) {
|
||||
if (isset($selected[ $value ])) {
|
||||
$_output .= ' checked="checked"';
|
||||
}
|
||||
} elseif ($value === $selected) {
|
||||
$_output .= ' checked="checked"';
|
||||
}
|
||||
$_output .= $extra . ' />' . $output;
|
||||
if ($labels) {
|
||||
$_output .= '</label>';
|
||||
}
|
||||
$_output .= $separator;
|
||||
return $_output;
|
||||
}
|
|
@ -1,158 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
/**
|
||||
* Smarty {html_image} function plugin
|
||||
* Type: function
|
||||
* Name: html_image
|
||||
* Date: Feb 24, 2003
|
||||
* Purpose: format HTML tags for the image
|
||||
* Examples: {html_image file="/images/masthead.gif"}
|
||||
* Output: <img src="/images/masthead.gif" width=400 height=23>
|
||||
* Params:
|
||||
*
|
||||
* - file - (required) - file (and path) of image
|
||||
* - height - (optional) - image height (default actual height)
|
||||
* - width - (optional) - image width (default actual width)
|
||||
* - basedir - (optional) - base directory for absolute paths, default is environment variable DOCUMENT_ROOT
|
||||
* - path_prefix - prefix for path output (optional, default empty)
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.image.php {html_image}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credits to Duda <duda@big.hu>
|
||||
* @version 1.0
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
*
|
||||
* @throws SmartyException
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
*/
|
||||
function smarty_function_html_image($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_function_escape_special_chars',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
$alt = '';
|
||||
$file = '';
|
||||
$height = '';
|
||||
$width = '';
|
||||
$extra = '';
|
||||
$prefix = '';
|
||||
$suffix = '';
|
||||
$path_prefix = '';
|
||||
$basedir = isset($_SERVER[ 'DOCUMENT_ROOT' ]) ? $_SERVER[ 'DOCUMENT_ROOT' ] : '';
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'file':
|
||||
case 'height':
|
||||
case 'width':
|
||||
case 'dpi':
|
||||
case 'path_prefix':
|
||||
case 'basedir':
|
||||
$$_key = $_val;
|
||||
break;
|
||||
case 'alt':
|
||||
if (!is_array($_val)) {
|
||||
$$_key = smarty_function_escape_special_chars($_val);
|
||||
} else {
|
||||
throw new SmartyException(
|
||||
"html_image: extra attribute '{$_key}' cannot be an array",
|
||||
E_USER_NOTICE
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'link':
|
||||
case 'href':
|
||||
$prefix = '<a href="' . $_val . '">';
|
||||
$suffix = '</a>';
|
||||
break;
|
||||
default:
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
} else {
|
||||
throw new SmartyException(
|
||||
"html_image: extra attribute '{$_key}' cannot be an array",
|
||||
E_USER_NOTICE
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (empty($file)) {
|
||||
trigger_error('html_image: missing \'file\' parameter', E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
if ($file[ 0 ] === '/') {
|
||||
$_image_path = $basedir . $file;
|
||||
} else {
|
||||
$_image_path = $file;
|
||||
}
|
||||
// strip file protocol
|
||||
if (stripos($params[ 'file' ], 'file://') === 0) {
|
||||
$params[ 'file' ] = substr($params[ 'file' ], 7);
|
||||
}
|
||||
$protocol = strpos($params[ 'file' ], '://');
|
||||
if ($protocol !== false) {
|
||||
$protocol = strtolower(substr($params[ 'file' ], 0, $protocol));
|
||||
}
|
||||
if (isset($template->smarty->security_policy)) {
|
||||
if ($protocol) {
|
||||
// remote resource (or php stream, …)
|
||||
if (!$template->smarty->security_policy->isTrustedUri($params[ 'file' ])) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// local file
|
||||
if (!$template->smarty->security_policy->isTrustedResourceDir($_image_path)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($params[ 'width' ]) || !isset($params[ 'height' ])) {
|
||||
// FIXME: (rodneyrehm) getimagesize() loads the complete file off a remote resource, use custom [jpg,png,gif]header reader!
|
||||
if (!$_image_data = @getimagesize($_image_path)) {
|
||||
if (!file_exists($_image_path)) {
|
||||
trigger_error("html_image: unable to find '{$_image_path}'", E_USER_NOTICE);
|
||||
return;
|
||||
} elseif (!is_readable($_image_path)) {
|
||||
trigger_error("html_image: unable to read '{$_image_path}'", E_USER_NOTICE);
|
||||
return;
|
||||
} else {
|
||||
trigger_error("html_image: '{$_image_path}' is not a valid image file", E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!isset($params[ 'width' ])) {
|
||||
$width = $_image_data[ 0 ];
|
||||
}
|
||||
if (!isset($params[ 'height' ])) {
|
||||
$height = $_image_data[ 1 ];
|
||||
}
|
||||
}
|
||||
if (isset($params[ 'dpi' ])) {
|
||||
if (strstr($_SERVER[ 'HTTP_USER_AGENT' ], 'Mac')) {
|
||||
// FIXME: (rodneyrehm) wrong dpi assumption
|
||||
// don't know who thought this up… even if it was true in 1998, it's definitely wrong in 2011.
|
||||
$dpi_default = 72;
|
||||
} else {
|
||||
$dpi_default = 96;
|
||||
}
|
||||
$_resize = $dpi_default / $params[ 'dpi' ];
|
||||
$width = round($width * $_resize);
|
||||
$height = round($height * $_resize);
|
||||
}
|
||||
return $prefix . '<img src="' . $path_prefix . $file . '" alt="' . $alt . '" width="' . $width . '" height="' .
|
||||
$height . '"' . $extra . ' />' . $suffix;
|
||||
}
|
|
@ -1,230 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
/**
|
||||
* Smarty {html_options} function plugin
|
||||
* Type: function
|
||||
* Name: html_options
|
||||
* Purpose: Prints the list of <option> tags generated from
|
||||
* the passed parameters
|
||||
* Params:
|
||||
*
|
||||
* - name (optional) - string default "select"
|
||||
* - values (required) - if no options supplied) - array
|
||||
* - options (required) - if no values supplied) - associative array
|
||||
* - selected (optional) - string default not set
|
||||
* - output (required) - if not options supplied) - array
|
||||
* - id (optional) - string default not set
|
||||
* - class (optional) - string default not set
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.options.php {html_image}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Ralf Strehle (minor optimization) <ralf dot strehle at yahoo dot de>
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @param \Smarty_Internal_Template $template
|
||||
*
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
function smarty_function_html_options($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_function_escape_special_chars',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
$name = null;
|
||||
$values = null;
|
||||
$options = null;
|
||||
$selected = null;
|
||||
$output = null;
|
||||
$id = null;
|
||||
$class = null;
|
||||
$extra = '';
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'name':
|
||||
case 'class':
|
||||
case 'id':
|
||||
$$_key = (string)$_val;
|
||||
break;
|
||||
case 'options':
|
||||
$options = (array)$_val;
|
||||
break;
|
||||
case 'values':
|
||||
case 'output':
|
||||
$$_key = array_values((array)$_val);
|
||||
break;
|
||||
case 'selected':
|
||||
if (is_array($_val)) {
|
||||
$selected = array();
|
||||
foreach ($_val as $_sel) {
|
||||
if (is_object($_sel)) {
|
||||
if (method_exists($_sel, '__toString')) {
|
||||
$_sel = smarty_function_escape_special_chars((string)$_sel->__toString());
|
||||
} else {
|
||||
trigger_error(
|
||||
'html_options: selected attribute contains an object of class \'' .
|
||||
get_class($_sel) . '\' without __toString() method',
|
||||
E_USER_NOTICE
|
||||
);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
$_sel = smarty_function_escape_special_chars((string)$_sel);
|
||||
}
|
||||
$selected[ $_sel ] = true;
|
||||
}
|
||||
} elseif (is_object($_val)) {
|
||||
if (method_exists($_val, '__toString')) {
|
||||
$selected = smarty_function_escape_special_chars((string)$_val->__toString());
|
||||
} else {
|
||||
trigger_error(
|
||||
'html_options: selected attribute is an object of class \'' . get_class($_val) .
|
||||
'\' without __toString() method',
|
||||
E_USER_NOTICE
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$selected = smarty_function_escape_special_chars((string)$_val);
|
||||
}
|
||||
break;
|
||||
case 'strict':
|
||||
break;
|
||||
case 'disabled':
|
||||
case 'readonly':
|
||||
if (!empty($params[ 'strict' ])) {
|
||||
if (!is_scalar($_val)) {
|
||||
trigger_error(
|
||||
"html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
|
||||
E_USER_NOTICE
|
||||
);
|
||||
}
|
||||
if ($_val === true || $_val === $_key) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
|
||||
}
|
||||
break;
|
||||
}
|
||||
// omit break; to fall through!
|
||||
// no break
|
||||
default:
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
} else {
|
||||
trigger_error("html_options: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isset($options) && !isset($values)) {
|
||||
/* raise error here? */
|
||||
return '';
|
||||
}
|
||||
$_html_result = '';
|
||||
$_idx = 0;
|
||||
if (isset($options)) {
|
||||
foreach ($options as $_key => $_val) {
|
||||
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx);
|
||||
}
|
||||
} else {
|
||||
foreach ($values as $_i => $_key) {
|
||||
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
|
||||
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx);
|
||||
}
|
||||
}
|
||||
if (!empty($name)) {
|
||||
$_html_class = !empty($class) ? ' class="' . $class . '"' : '';
|
||||
$_html_id = !empty($id) ? ' id="' . $id . '"' : '';
|
||||
$_html_result =
|
||||
'<select name="' . $name . '"' . $_html_class . $_html_id . $extra . '>' . "\n" . $_html_result .
|
||||
'</select>' . "\n";
|
||||
}
|
||||
return $_html_result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @param $value
|
||||
* @param $selected
|
||||
* @param $id
|
||||
* @param $class
|
||||
* @param $idx
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_html_options_optoutput($key, $value, $selected, $id, $class, &$idx)
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
$_key = smarty_function_escape_special_chars($key);
|
||||
$_html_result = '<option value="' . $_key . '"';
|
||||
if (is_array($selected)) {
|
||||
if (isset($selected[ $_key ])) {
|
||||
$_html_result .= ' selected="selected"';
|
||||
}
|
||||
} elseif ($_key === $selected) {
|
||||
$_html_result .= ' selected="selected"';
|
||||
}
|
||||
$_html_class = !empty($class) ? ' class="' . $class . ' option"' : '';
|
||||
$_html_id = !empty($id) ? ' id="' . $id . '-' . $idx . '"' : '';
|
||||
if (is_object($value)) {
|
||||
if (method_exists($value, '__toString')) {
|
||||
$value = smarty_function_escape_special_chars((string)$value->__toString());
|
||||
} else {
|
||||
trigger_error(
|
||||
'html_options: value is an object of class \'' . get_class($value) .
|
||||
'\' without __toString() method',
|
||||
E_USER_NOTICE
|
||||
);
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$value = smarty_function_escape_special_chars((string)$value);
|
||||
}
|
||||
$_html_result .= $_html_class . $_html_id . '>' . $value . '</option>' . "\n";
|
||||
$idx++;
|
||||
} else {
|
||||
$_idx = 0;
|
||||
$_html_result =
|
||||
smarty_function_html_options_optgroup(
|
||||
$key,
|
||||
$value,
|
||||
$selected,
|
||||
!empty($id) ? ($id . '-' . $idx) : null,
|
||||
$class,
|
||||
$_idx
|
||||
);
|
||||
$idx++;
|
||||
}
|
||||
return $_html_result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @param $values
|
||||
* @param $selected
|
||||
* @param $id
|
||||
* @param $class
|
||||
* @param $idx
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_html_options_optgroup($key, $values, $selected, $id, $class, &$idx)
|
||||
{
|
||||
$optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n";
|
||||
foreach ($values as $key => $value) {
|
||||
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected, $id, $class, $idx);
|
||||
}
|
||||
$optgroup_html .= "</optgroup>\n";
|
||||
return $optgroup_html;
|
||||
}
|
|
@ -1,266 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
/**
|
||||
* Smarty {html_radios} function plugin
|
||||
* File: function.html_radios.php
|
||||
* Type: function
|
||||
* Name: html_radios
|
||||
* Date: 24.Feb.2003
|
||||
* Purpose: Prints out a list of radio input types
|
||||
* Params:
|
||||
*
|
||||
* - name (optional) - string default "radio"
|
||||
* - values (required) - array
|
||||
* - options (required) - associative array
|
||||
* - checked (optional) - array default not set
|
||||
* - separator (optional) - ie <br> or
|
||||
* - output (optional) - the output next to each radio button
|
||||
* - assign (optional) - assign the output as an array to this variable
|
||||
* - escape (optional) - escape the content (not value), defaults to true
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* {html_radios values=$ids output=$names}
|
||||
* {html_radios values=$ids name='box' separator='<br>' output=$names}
|
||||
* {html_radios values=$ids checked=$checked separator='<br>' output=$names}
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}
|
||||
* (Smarty online manual)
|
||||
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
||||
* @author credits to Monte Ohrt <monte at ohrt dot com>
|
||||
* @version 1.0
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
*
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
function smarty_function_html_radios($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_function_escape_special_chars',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
$name = 'radio';
|
||||
$values = null;
|
||||
$options = null;
|
||||
$selected = null;
|
||||
$separator = '';
|
||||
$escape = true;
|
||||
$labels = true;
|
||||
$label_ids = false;
|
||||
$output = null;
|
||||
$extra = '';
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'name':
|
||||
case 'separator':
|
||||
$$_key = (string)$_val;
|
||||
break;
|
||||
case 'checked':
|
||||
case 'selected':
|
||||
if (is_array($_val)) {
|
||||
trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
|
||||
} elseif (is_object($_val)) {
|
||||
if (method_exists($_val, '__toString')) {
|
||||
$selected = smarty_function_escape_special_chars((string)$_val->__toString());
|
||||
} else {
|
||||
trigger_error(
|
||||
'html_radios: selected attribute is an object of class \'' . get_class($_val) .
|
||||
'\' without __toString() method',
|
||||
E_USER_NOTICE
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$selected = (string)$_val;
|
||||
}
|
||||
break;
|
||||
case 'escape':
|
||||
case 'labels':
|
||||
case 'label_ids':
|
||||
$$_key = (bool)$_val;
|
||||
break;
|
||||
case 'options':
|
||||
$$_key = (array)$_val;
|
||||
break;
|
||||
case 'values':
|
||||
case 'output':
|
||||
$$_key = array_values((array)$_val);
|
||||
break;
|
||||
case 'radios':
|
||||
trigger_error(
|
||||
'html_radios: the use of the "radios" attribute is deprecated, use "options" instead',
|
||||
E_USER_WARNING
|
||||
);
|
||||
$options = (array)$_val;
|
||||
break;
|
||||
case 'assign':
|
||||
break;
|
||||
case 'strict':
|
||||
break;
|
||||
case 'disabled':
|
||||
case 'readonly':
|
||||
if (!empty($params[ 'strict' ])) {
|
||||
if (!is_scalar($_val)) {
|
||||
trigger_error(
|
||||
"html_options: {$_key} attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute",
|
||||
E_USER_NOTICE
|
||||
);
|
||||
}
|
||||
if ($_val === true || $_val === $_key) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
|
||||
}
|
||||
break;
|
||||
}
|
||||
// omit break; to fall through!
|
||||
// no break
|
||||
default:
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
} else {
|
||||
trigger_error("html_radios: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isset($options) && !isset($values)) {
|
||||
/* raise error here? */
|
||||
return '';
|
||||
}
|
||||
$_html_result = array();
|
||||
if (isset($options)) {
|
||||
foreach ($options as $_key => $_val) {
|
||||
$_html_result[] =
|
||||
smarty_function_html_radios_output(
|
||||
$name,
|
||||
$_key,
|
||||
$_val,
|
||||
$selected,
|
||||
$extra,
|
||||
$separator,
|
||||
$labels,
|
||||
$label_ids,
|
||||
$escape
|
||||
);
|
||||
}
|
||||
} else {
|
||||
foreach ($values as $_i => $_key) {
|
||||
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
|
||||
$_html_result[] =
|
||||
smarty_function_html_radios_output(
|
||||
$name,
|
||||
$_key,
|
||||
$_val,
|
||||
$selected,
|
||||
$extra,
|
||||
$separator,
|
||||
$labels,
|
||||
$label_ids,
|
||||
$escape
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!empty($params[ 'assign' ])) {
|
||||
$template->assign($params[ 'assign' ], $_html_result);
|
||||
} else {
|
||||
return implode("\n", $_html_result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $value
|
||||
* @param $output
|
||||
* @param $selected
|
||||
* @param $extra
|
||||
* @param $separator
|
||||
* @param $labels
|
||||
* @param $label_ids
|
||||
* @param $escape
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_html_radios_output(
|
||||
$name,
|
||||
$value,
|
||||
$output,
|
||||
$selected,
|
||||
$extra,
|
||||
$separator,
|
||||
$labels,
|
||||
$label_ids,
|
||||
$escape
|
||||
) {
|
||||
$_output = '';
|
||||
if (is_object($value)) {
|
||||
if (method_exists($value, '__toString')) {
|
||||
$value = (string)$value->__toString();
|
||||
} else {
|
||||
trigger_error(
|
||||
'html_options: value is an object of class \'' . get_class($value) .
|
||||
'\' without __toString() method',
|
||||
E_USER_NOTICE
|
||||
);
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$value = (string)$value;
|
||||
}
|
||||
if (is_object($output)) {
|
||||
if (method_exists($output, '__toString')) {
|
||||
$output = (string)$output->__toString();
|
||||
} else {
|
||||
trigger_error(
|
||||
'html_options: output is an object of class \'' . get_class($output) .
|
||||
'\' without __toString() method',
|
||||
E_USER_NOTICE
|
||||
);
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$output = (string)$output;
|
||||
}
|
||||
if ($labels) {
|
||||
if ($label_ids) {
|
||||
$_id = smarty_function_escape_special_chars(
|
||||
preg_replace(
|
||||
'![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER,
|
||||
'_',
|
||||
$name . '_' . $value
|
||||
)
|
||||
);
|
||||
$_output .= '<label for="' . $_id . '">';
|
||||
} else {
|
||||
$_output .= '<label>';
|
||||
}
|
||||
}
|
||||
$name = smarty_function_escape_special_chars($name);
|
||||
$value = smarty_function_escape_special_chars($value);
|
||||
if ($escape) {
|
||||
$output = smarty_function_escape_special_chars($output);
|
||||
}
|
||||
$_output .= '<input type="radio" name="' . $name . '" value="' . $value . '"';
|
||||
if ($labels && $label_ids) {
|
||||
$_output .= ' id="' . $_id . '"';
|
||||
}
|
||||
if ($value === $selected) {
|
||||
$_output .= ' checked="checked"';
|
||||
}
|
||||
$_output .= $extra . ' />' . $output;
|
||||
if ($labels) {
|
||||
$_output .= '</label>';
|
||||
}
|
||||
$_output .= $separator;
|
||||
return $_output;
|
||||
}
|
|
@ -1,388 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
/**
|
||||
* Smarty {html_select_date} plugin
|
||||
* Type: function
|
||||
* Name: html_select_date
|
||||
* Purpose: Prints the dropdowns for date selection.
|
||||
* ChangeLog:
|
||||
*
|
||||
* - 1.0 initial release
|
||||
* - 1.1 added support for +/- N syntax for begin
|
||||
* and end year values. (Monte)
|
||||
* - 1.2 added support for yyyy-mm-dd syntax for
|
||||
* time value. (Jan Rosier)
|
||||
* - 1.3 added support for choosing format for
|
||||
* month values (Gary Loescher)
|
||||
* - 1.3.1 added support for choosing format for
|
||||
* day values (Marcus Bointon)
|
||||
* - 1.3.2 support negative timestamps, force year
|
||||
* dropdown to include given date unless explicitly set (Monte)
|
||||
* - 1.3.4 fix behaviour of 0000-00-00 00:00:00 dates to match that
|
||||
* of 0000-00-00 dates (cybot, boots)
|
||||
* - 2.0 complete rewrite for performance,
|
||||
* added attributes month_names, *_id
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
|
||||
* (Smarty online manual)
|
||||
* @version 2.0
|
||||
* @author Andrei Zmievski
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @param \Smarty_Internal_Template $template
|
||||
*
|
||||
* @return string
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
function smarty_function_html_select_date($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_function_escape_special_chars',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
// generate timestamps used for month names only
|
||||
static $_month_timestamps = null;
|
||||
static $_current_year = null;
|
||||
if ($_month_timestamps === null) {
|
||||
$_current_year = date('Y');
|
||||
$_month_timestamps = array();
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$_month_timestamps[ $i ] = mktime(0, 0, 0, $i, 1, 2000);
|
||||
}
|
||||
}
|
||||
/* Default values. */
|
||||
$prefix = 'Date_';
|
||||
$start_year = null;
|
||||
$end_year = null;
|
||||
$display_days = true;
|
||||
$display_months = true;
|
||||
$display_years = true;
|
||||
$month_format = '%B';
|
||||
/* Write months as numbers by default GL */
|
||||
$month_value_format = '%m';
|
||||
$day_format = '%02d';
|
||||
/* Write day values using this format MB */
|
||||
$day_value_format = '%d';
|
||||
$year_as_text = false;
|
||||
/* Display years in reverse order? Ie. 2000,1999,.... */
|
||||
$reverse_years = false;
|
||||
/* Should the select boxes be part of an array when returned from PHP?
|
||||
e.g. setting it to "birthday", would create "birthday[Day]",
|
||||
"birthday[Month]" & "birthday[Year]". Can be combined with prefix */
|
||||
$field_array = null;
|
||||
/* <select size>'s of the different <select> tags.
|
||||
If not set, uses default dropdown. */
|
||||
$day_size = null;
|
||||
$month_size = null;
|
||||
$year_size = null;
|
||||
/* Unparsed attributes common to *ALL* the <select>/<input> tags.
|
||||
An example might be in the template: all_extra ='class ="foo"'. */
|
||||
$all_extra = null;
|
||||
/* Separate attributes for the tags. */
|
||||
$day_extra = null;
|
||||
$month_extra = null;
|
||||
$year_extra = null;
|
||||
/* Order in which to display the fields.
|
||||
"D" -> day, "M" -> month, "Y" -> year. */
|
||||
$field_order = 'MDY';
|
||||
/* String printed between the different fields. */
|
||||
$field_separator = "\n";
|
||||
$option_separator = "\n";
|
||||
$time = null;
|
||||
// $all_empty = null;
|
||||
// $day_empty = null;
|
||||
// $month_empty = null;
|
||||
// $year_empty = null;
|
||||
$extra_attrs = '';
|
||||
$all_id = null;
|
||||
$day_id = null;
|
||||
$month_id = null;
|
||||
$year_id = null;
|
||||
foreach ($params as $_key => $_value) {
|
||||
switch ($_key) {
|
||||
case 'time':
|
||||
if (!is_array($_value) && $_value !== null) {
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_make_timestamp',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
$time = smarty_make_timestamp($_value);
|
||||
}
|
||||
break;
|
||||
case 'month_names':
|
||||
if (is_array($_value) && count($_value) === 12) {
|
||||
$$_key = $_value;
|
||||
} else {
|
||||
trigger_error('html_select_date: month_names must be an array of 12 strings', E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
case 'prefix':
|
||||
case 'field_array':
|
||||
case 'start_year':
|
||||
case 'end_year':
|
||||
case 'day_format':
|
||||
case 'day_value_format':
|
||||
case 'month_format':
|
||||
case 'month_value_format':
|
||||
case 'day_size':
|
||||
case 'month_size':
|
||||
case 'year_size':
|
||||
case 'all_extra':
|
||||
case 'day_extra':
|
||||
case 'month_extra':
|
||||
case 'year_extra':
|
||||
case 'field_order':
|
||||
case 'field_separator':
|
||||
case 'option_separator':
|
||||
case 'all_empty':
|
||||
case 'month_empty':
|
||||
case 'day_empty':
|
||||
case 'year_empty':
|
||||
case 'all_id':
|
||||
case 'month_id':
|
||||
case 'day_id':
|
||||
case 'year_id':
|
||||
$$_key = (string)$_value;
|
||||
break;
|
||||
case 'display_days':
|
||||
case 'display_months':
|
||||
case 'display_years':
|
||||
case 'year_as_text':
|
||||
case 'reverse_years':
|
||||
$$_key = (bool)$_value;
|
||||
break;
|
||||
default:
|
||||
if (!is_array($_value)) {
|
||||
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
|
||||
} else {
|
||||
trigger_error("html_select_date: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Note: date() is faster than strftime()
|
||||
// Note: explode(date()) is faster than date() date() date()
|
||||
if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) {
|
||||
if (isset($params[ 'time' ][ $prefix . 'Year' ])) {
|
||||
// $_REQUEST[$field_array] given
|
||||
foreach (array(
|
||||
'Y' => 'Year',
|
||||
'm' => 'Month',
|
||||
'd' => 'Day'
|
||||
) as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName =
|
||||
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
|
||||
date($_elementKey);
|
||||
}
|
||||
} elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Year' ])) {
|
||||
// $_REQUEST given
|
||||
foreach (array(
|
||||
'Y' => 'Year',
|
||||
'm' => 'Month',
|
||||
'd' => 'Day'
|
||||
) as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ?
|
||||
$params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey);
|
||||
}
|
||||
} else {
|
||||
// no date found, use NOW
|
||||
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d'));
|
||||
}
|
||||
} elseif ($time === null) {
|
||||
if (array_key_exists('time', $params)) {
|
||||
$_year = $_month = $_day = $time = null;
|
||||
} else {
|
||||
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d'));
|
||||
}
|
||||
} else {
|
||||
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d', $time));
|
||||
}
|
||||
// make syntax "+N" or "-N" work with $start_year and $end_year
|
||||
// Note preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match) is slower than trim+substr
|
||||
foreach (array(
|
||||
'start',
|
||||
'end'
|
||||
) as $key) {
|
||||
$key .= '_year';
|
||||
$t = $$key;
|
||||
if ($t === null) {
|
||||
$$key = (int)$_current_year;
|
||||
} elseif ($t[ 0 ] === '+') {
|
||||
$$key = (int)($_current_year + (int)trim(substr($t, 1)));
|
||||
} elseif ($t[ 0 ] === '-') {
|
||||
$$key = (int)($_current_year - (int)trim(substr($t, 1)));
|
||||
} else {
|
||||
$$key = (int)$$key;
|
||||
}
|
||||
}
|
||||
// flip for ascending or descending
|
||||
if (($start_year > $end_year && !$reverse_years) || ($start_year < $end_year && $reverse_years)) {
|
||||
$t = $end_year;
|
||||
$end_year = $start_year;
|
||||
$start_year = $t;
|
||||
}
|
||||
// generate year <select> or <input>
|
||||
if ($display_years) {
|
||||
$_extra = '';
|
||||
$_name = $field_array ? ($field_array . '[' . $prefix . 'Year]') : ($prefix . 'Year');
|
||||
if ($all_extra) {
|
||||
$_extra .= ' ' . $all_extra;
|
||||
}
|
||||
if ($year_extra) {
|
||||
$_extra .= ' ' . $year_extra;
|
||||
}
|
||||
if ($year_as_text) {
|
||||
$_html_years =
|
||||
'<input type="text" name="' . $_name . '" value="' . $_year . '" size="4" maxlength="4"' . $_extra .
|
||||
$extra_attrs . ' />';
|
||||
} else {
|
||||
$_html_years = '<select name="' . $_name . '"';
|
||||
if ($year_id !== null || $all_id !== null) {
|
||||
$_html_years .= ' id="' . smarty_function_escape_special_chars(
|
||||
$year_id !== null ?
|
||||
($year_id ? $year_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($year_size) {
|
||||
$_html_years .= ' size="' . $year_size . '"';
|
||||
}
|
||||
$_html_years .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($year_empty) || isset($all_empty)) {
|
||||
$_html_years .= '<option value="">' . (isset($year_empty) ? $year_empty : $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
$op = $start_year > $end_year ? -1 : 1;
|
||||
for ($i = $start_year; $op > 0 ? $i <= $end_year : $i >= $end_year; $i += $op) {
|
||||
$_html_years .= '<option value="' . $i . '"' . ($_year == $i ? ' selected="selected"' : '') . '>' . $i .
|
||||
'</option>' . $option_separator;
|
||||
}
|
||||
$_html_years .= '</select>';
|
||||
}
|
||||
}
|
||||
// generate month <select> or <input>
|
||||
if ($display_months) {
|
||||
$_extra = '';
|
||||
$_name = $field_array ? ($field_array . '[' . $prefix . 'Month]') : ($prefix . 'Month');
|
||||
if ($all_extra) {
|
||||
$_extra .= ' ' . $all_extra;
|
||||
}
|
||||
if ($month_extra) {
|
||||
$_extra .= ' ' . $month_extra;
|
||||
}
|
||||
$_html_months = '<select name="' . $_name . '"';
|
||||
if ($month_id !== null || $all_id !== null) {
|
||||
$_html_months .= ' id="' . smarty_function_escape_special_chars(
|
||||
$month_id !== null ?
|
||||
($month_id ? $month_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($month_size) {
|
||||
$_html_months .= ' size="' . $month_size . '"';
|
||||
}
|
||||
$_html_months .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($month_empty) || isset($all_empty)) {
|
||||
$_html_months .= '<option value="">' . (isset($month_empty) ? $month_empty : $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[ $i ]) :
|
||||
($month_format === '%m' ? $_val : strftime($month_format, $_month_timestamps[ $i ]));
|
||||
$_value = $month_value_format === '%m' ? $_val : strftime($month_value_format, $_month_timestamps[ $i ]);
|
||||
$_html_months .= '<option value="' . $_value . '"' . ($_val == $_month ? ' selected="selected"' : '') .
|
||||
'>' . $_text . '</option>' . $option_separator;
|
||||
}
|
||||
$_html_months .= '</select>';
|
||||
}
|
||||
// generate day <select> or <input>
|
||||
if ($display_days) {
|
||||
$_extra = '';
|
||||
$_name = $field_array ? ($field_array . '[' . $prefix . 'Day]') : ($prefix . 'Day');
|
||||
if ($all_extra) {
|
||||
$_extra .= ' ' . $all_extra;
|
||||
}
|
||||
if ($day_extra) {
|
||||
$_extra .= ' ' . $day_extra;
|
||||
}
|
||||
$_html_days = '<select name="' . $_name . '"';
|
||||
if ($day_id !== null || $all_id !== null) {
|
||||
$_html_days .= ' id="' .
|
||||
smarty_function_escape_special_chars(
|
||||
$day_id !== null ? ($day_id ? $day_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($day_size) {
|
||||
$_html_days .= ' size="' . $day_size . '"';
|
||||
}
|
||||
$_html_days .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($day_empty) || isset($all_empty)) {
|
||||
$_html_days .= '<option value="">' . (isset($day_empty) ? $day_empty : $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
for ($i = 1; $i <= 31; $i++) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $day_format === '%02d' ? $_val : sprintf($day_format, $i);
|
||||
$_value = $day_value_format === '%02d' ? $_val : sprintf($day_value_format, $i);
|
||||
$_html_days .= '<option value="' . $_value . '"' . ($_val == $_day ? ' selected="selected"' : '') . '>' .
|
||||
$_text . '</option>' . $option_separator;
|
||||
}
|
||||
$_html_days .= '</select>';
|
||||
}
|
||||
// order the fields for output
|
||||
$_html = '';
|
||||
for ($i = 0; $i <= 2; $i++) {
|
||||
switch ($field_order[ $i ]) {
|
||||
case 'Y':
|
||||
case 'y':
|
||||
if (isset($_html_years)) {
|
||||
if ($_html) {
|
||||
$_html .= $field_separator;
|
||||
}
|
||||
$_html .= $_html_years;
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
case 'M':
|
||||
if (isset($_html_months)) {
|
||||
if ($_html) {
|
||||
$_html .= $field_separator;
|
||||
}
|
||||
$_html .= $_html_months;
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
if (isset($_html_days)) {
|
||||
if ($_html) {
|
||||
$_html .= $field_separator;
|
||||
}
|
||||
$_html .= $_html_days;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $_html;
|
||||
}
|
|
@ -1,354 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
/**
|
||||
* Smarty {html_select_time} function plugin
|
||||
* Type: function
|
||||
* Name: html_select_time
|
||||
* Purpose: Prints the dropdowns for time selection
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
|
||||
* (Smarty online manual)
|
||||
* @author Roberto Berto <roberto@berto.net>
|
||||
* @author Monte Ohrt <monte AT ohrt DOT com>
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @param \Smarty_Internal_Template $template
|
||||
*
|
||||
* @return string
|
||||
* @uses smarty_make_timestamp()
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
function smarty_function_html_select_time($params, Smarty_Internal_Template $template)
|
||||
{
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_function_escape_special_chars',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
$prefix = 'Time_';
|
||||
$field_array = null;
|
||||
$field_separator = "\n";
|
||||
$option_separator = "\n";
|
||||
$time = null;
|
||||
$display_hours = true;
|
||||
$display_minutes = true;
|
||||
$display_seconds = true;
|
||||
$display_meridian = true;
|
||||
$hour_format = '%02d';
|
||||
$hour_value_format = '%02d';
|
||||
$minute_format = '%02d';
|
||||
$minute_value_format = '%02d';
|
||||
$second_format = '%02d';
|
||||
$second_value_format = '%02d';
|
||||
$hour_size = null;
|
||||
$minute_size = null;
|
||||
$second_size = null;
|
||||
$meridian_size = null;
|
||||
$all_empty = null;
|
||||
$hour_empty = null;
|
||||
$minute_empty = null;
|
||||
$second_empty = null;
|
||||
$meridian_empty = null;
|
||||
$all_id = null;
|
||||
$hour_id = null;
|
||||
$minute_id = null;
|
||||
$second_id = null;
|
||||
$meridian_id = null;
|
||||
$use_24_hours = true;
|
||||
$minute_interval = 1;
|
||||
$second_interval = 1;
|
||||
$extra_attrs = '';
|
||||
$all_extra = null;
|
||||
$hour_extra = null;
|
||||
$minute_extra = null;
|
||||
$second_extra = null;
|
||||
$meridian_extra = null;
|
||||
foreach ($params as $_key => $_value) {
|
||||
switch ($_key) {
|
||||
case 'time':
|
||||
if (!is_array($_value) && $_value !== null) {
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_make_timestamp',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
$time = smarty_make_timestamp($_value);
|
||||
}
|
||||
break;
|
||||
case 'prefix':
|
||||
case 'field_array':
|
||||
case 'field_separator':
|
||||
case 'option_separator':
|
||||
case 'all_extra':
|
||||
case 'hour_extra':
|
||||
case 'minute_extra':
|
||||
case 'second_extra':
|
||||
case 'meridian_extra':
|
||||
case 'all_empty':
|
||||
case 'hour_empty':
|
||||
case 'minute_empty':
|
||||
case 'second_empty':
|
||||
case 'meridian_empty':
|
||||
case 'all_id':
|
||||
case 'hour_id':
|
||||
case 'minute_id':
|
||||
case 'second_id':
|
||||
case 'meridian_id':
|
||||
case 'hour_format':
|
||||
case 'hour_value_format':
|
||||
case 'minute_format':
|
||||
case 'minute_value_format':
|
||||
case 'second_format':
|
||||
case 'second_value_format':
|
||||
$$_key = (string)$_value;
|
||||
break;
|
||||
case 'display_hours':
|
||||
case 'display_minutes':
|
||||
case 'display_seconds':
|
||||
case 'display_meridian':
|
||||
case 'use_24_hours':
|
||||
$$_key = (bool)$_value;
|
||||
break;
|
||||
case 'minute_interval':
|
||||
case 'second_interval':
|
||||
case 'hour_size':
|
||||
case 'minute_size':
|
||||
case 'second_size':
|
||||
case 'meridian_size':
|
||||
$$_key = (int)$_value;
|
||||
break;
|
||||
default:
|
||||
if (!is_array($_value)) {
|
||||
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
|
||||
} else {
|
||||
trigger_error("html_select_date: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) {
|
||||
if (isset($params[ 'time' ][ $prefix . 'Hour' ])) {
|
||||
// $_REQUEST[$field_array] given
|
||||
foreach (array(
|
||||
'H' => 'Hour',
|
||||
'i' => 'Minute',
|
||||
's' => 'Second'
|
||||
) as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName =
|
||||
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
|
||||
date($_elementKey);
|
||||
}
|
||||
$_meridian =
|
||||
isset($params[ 'time' ][ $prefix . 'Meridian' ]) ? (' ' . $params[ 'time' ][ $prefix . 'Meridian' ]) :
|
||||
'';
|
||||
$time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian);
|
||||
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
|
||||
} elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Hour' ])) {
|
||||
// $_REQUEST given
|
||||
foreach (array(
|
||||
'H' => 'Hour',
|
||||
'i' => 'Minute',
|
||||
's' => 'Second'
|
||||
) as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ?
|
||||
$params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey);
|
||||
}
|
||||
$_meridian = isset($params[ 'time' ][ $field_array ][ $prefix . 'Meridian' ]) ?
|
||||
(' ' . $params[ 'time' ][ $field_array ][ $prefix . 'Meridian' ]) : '';
|
||||
$time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian);
|
||||
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
|
||||
} else {
|
||||
// no date found, use NOW
|
||||
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d'));
|
||||
}
|
||||
} elseif ($time === null) {
|
||||
if (array_key_exists('time', $params)) {
|
||||
$_hour = $_minute = $_second = $time = null;
|
||||
} else {
|
||||
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s'));
|
||||
}
|
||||
} else {
|
||||
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
|
||||
}
|
||||
// generate hour <select>
|
||||
if ($display_hours) {
|
||||
$_html_hours = '';
|
||||
$_extra = '';
|
||||
$_name = $field_array ? ($field_array . '[' . $prefix . 'Hour]') : ($prefix . 'Hour');
|
||||
if ($all_extra) {
|
||||
$_extra .= ' ' . $all_extra;
|
||||
}
|
||||
if ($hour_extra) {
|
||||
$_extra .= ' ' . $hour_extra;
|
||||
}
|
||||
$_html_hours = '<select name="' . $_name . '"';
|
||||
if ($hour_id !== null || $all_id !== null) {
|
||||
$_html_hours .= ' id="' .
|
||||
smarty_function_escape_special_chars(
|
||||
$hour_id !== null ? ($hour_id ? $hour_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($hour_size) {
|
||||
$_html_hours .= ' size="' . $hour_size . '"';
|
||||
}
|
||||
$_html_hours .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($hour_empty) || isset($all_empty)) {
|
||||
$_html_hours .= '<option value="">' . (isset($hour_empty) ? $hour_empty : $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
$start = $use_24_hours ? 0 : 1;
|
||||
$end = $use_24_hours ? 23 : 12;
|
||||
for ($i = $start; $i <= $end; $i++) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $hour_format === '%02d' ? $_val : sprintf($hour_format, $i);
|
||||
$_value = $hour_value_format === '%02d' ? $_val : sprintf($hour_value_format, $i);
|
||||
if (!$use_24_hours) {
|
||||
$_hour12 = $_hour == 0 ? 12 : ($_hour <= 12 ? $_hour : $_hour - 12);
|
||||
}
|
||||
$selected = $_hour !== null ? ($use_24_hours ? $_hour == $_val : $_hour12 == $_val) : null;
|
||||
$_html_hours .= '<option value="' . $_value . '"' . ($selected ? ' selected="selected"' : '') . '>' .
|
||||
$_text . '</option>' . $option_separator;
|
||||
}
|
||||
$_html_hours .= '</select>';
|
||||
}
|
||||
// generate minute <select>
|
||||
if ($display_minutes) {
|
||||
$_html_minutes = '';
|
||||
$_extra = '';
|
||||
$_name = $field_array ? ($field_array . '[' . $prefix . 'Minute]') : ($prefix . 'Minute');
|
||||
if ($all_extra) {
|
||||
$_extra .= ' ' . $all_extra;
|
||||
}
|
||||
if ($minute_extra) {
|
||||
$_extra .= ' ' . $minute_extra;
|
||||
}
|
||||
$_html_minutes = '<select name="' . $_name . '"';
|
||||
if ($minute_id !== null || $all_id !== null) {
|
||||
$_html_minutes .= ' id="' . smarty_function_escape_special_chars(
|
||||
$minute_id !== null ?
|
||||
($minute_id ? $minute_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($minute_size) {
|
||||
$_html_minutes .= ' size="' . $minute_size . '"';
|
||||
}
|
||||
$_html_minutes .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($minute_empty) || isset($all_empty)) {
|
||||
$_html_minutes .= '<option value="">' . (isset($minute_empty) ? $minute_empty : $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
$selected = $_minute !== null ? ($_minute - $_minute % $minute_interval) : null;
|
||||
for ($i = 0; $i <= 59; $i += $minute_interval) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $minute_format === '%02d' ? $_val : sprintf($minute_format, $i);
|
||||
$_value = $minute_value_format === '%02d' ? $_val : sprintf($minute_value_format, $i);
|
||||
$_html_minutes .= '<option value="' . $_value . '"' . ($selected === $i ? ' selected="selected"' : '') .
|
||||
'>' . $_text . '</option>' . $option_separator;
|
||||
}
|
||||
$_html_minutes .= '</select>';
|
||||
}
|
||||
// generate second <select>
|
||||
if ($display_seconds) {
|
||||
$_html_seconds = '';
|
||||
$_extra = '';
|
||||
$_name = $field_array ? ($field_array . '[' . $prefix . 'Second]') : ($prefix . 'Second');
|
||||
if ($all_extra) {
|
||||
$_extra .= ' ' . $all_extra;
|
||||
}
|
||||
if ($second_extra) {
|
||||
$_extra .= ' ' . $second_extra;
|
||||
}
|
||||
$_html_seconds = '<select name="' . $_name . '"';
|
||||
if ($second_id !== null || $all_id !== null) {
|
||||
$_html_seconds .= ' id="' . smarty_function_escape_special_chars(
|
||||
$second_id !== null ?
|
||||
($second_id ? $second_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($second_size) {
|
||||
$_html_seconds .= ' size="' . $second_size . '"';
|
||||
}
|
||||
$_html_seconds .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($second_empty) || isset($all_empty)) {
|
||||
$_html_seconds .= '<option value="">' . (isset($second_empty) ? $second_empty : $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
$selected = $_second !== null ? ($_second - $_second % $second_interval) : null;
|
||||
for ($i = 0; $i <= 59; $i += $second_interval) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $second_format === '%02d' ? $_val : sprintf($second_format, $i);
|
||||
$_value = $second_value_format === '%02d' ? $_val : sprintf($second_value_format, $i);
|
||||
$_html_seconds .= '<option value="' . $_value . '"' . ($selected === $i ? ' selected="selected"' : '') .
|
||||
'>' . $_text . '</option>' . $option_separator;
|
||||
}
|
||||
$_html_seconds .= '</select>';
|
||||
}
|
||||
// generate meridian <select>
|
||||
if ($display_meridian && !$use_24_hours) {
|
||||
$_html_meridian = '';
|
||||
$_extra = '';
|
||||
$_name = $field_array ? ($field_array . '[' . $prefix . 'Meridian]') : ($prefix . 'Meridian');
|
||||
if ($all_extra) {
|
||||
$_extra .= ' ' . $all_extra;
|
||||
}
|
||||
if ($meridian_extra) {
|
||||
$_extra .= ' ' . $meridian_extra;
|
||||
}
|
||||
$_html_meridian = '<select name="' . $_name . '"';
|
||||
if ($meridian_id !== null || $all_id !== null) {
|
||||
$_html_meridian .= ' id="' . smarty_function_escape_special_chars(
|
||||
$meridian_id !== null ?
|
||||
($meridian_id ? $meridian_id :
|
||||
$_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($meridian_size) {
|
||||
$_html_meridian .= ' size="' . $meridian_size . '"';
|
||||
}
|
||||
$_html_meridian .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($meridian_empty) || isset($all_empty)) {
|
||||
$_html_meridian .= '<option value="">' . (isset($meridian_empty) ? $meridian_empty : $all_empty) .
|
||||
'</option>' . $option_separator;
|
||||
}
|
||||
$_html_meridian .= '<option value="am"' . ($_hour > 0 && $_hour < 12 ? ' selected="selected"' : '') .
|
||||
'>AM</option>' . $option_separator . '<option value="pm"' .
|
||||
($_hour < 12 ? '' : ' selected="selected"') . '>PM</option>' . $option_separator .
|
||||
'</select>';
|
||||
}
|
||||
$_html = '';
|
||||
foreach (array(
|
||||
'_html_hours',
|
||||
'_html_minutes',
|
||||
'_html_seconds',
|
||||
'_html_meridian'
|
||||
) as $k) {
|
||||
if (isset($$k)) {
|
||||
if ($_html) {
|
||||
$_html .= $field_separator;
|
||||
}
|
||||
$_html .= $$k;
|
||||
}
|
||||
}
|
||||
return $_html;
|
||||
}
|
|
@ -1,164 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
/**
|
||||
* Smarty {html_table} function plugin
|
||||
* Type: function
|
||||
* Name: html_table
|
||||
* Date: Feb 17, 2003
|
||||
* Purpose: make an html table from an array of data
|
||||
* Params:
|
||||
*
|
||||
* - loop - array to loop through
|
||||
* - cols - number of columns, comma separated list of column names
|
||||
* or array of column names
|
||||
* - rows - number of rows
|
||||
* - table_attr - table attributes
|
||||
* - th_attr - table heading attributes (arrays are cycled)
|
||||
* - tr_attr - table row attributes (arrays are cycled)
|
||||
* - td_attr - table cell attributes (arrays are cycled)
|
||||
* - trailpad - value to pad trailing cells with
|
||||
* - caption - text for caption element
|
||||
* - vdir - vertical direction (default: "down", means top-to-bottom)
|
||||
* - hdir - horizontal direction (default: "right", means left-to-right)
|
||||
* - inner - inner loop (default "cols": print $loop line by line,
|
||||
* $loop will be printed column by column otherwise)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* {table loop=$data}
|
||||
* {table loop=$data cols=4 tr_attr='"bgcolor=red"'}
|
||||
* {table loop=$data cols="first,second,third" tr_attr=$colors}
|
||||
*
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credit to Messju Mohr <messju at lammfellpuschen dot de>
|
||||
* @author credit to boots <boots dot smarty at yahoo dot com>
|
||||
* @version 1.1
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.table.php {html_table}
|
||||
* (Smarty online manual)
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_html_table($params)
|
||||
{
|
||||
$table_attr = 'border="1"';
|
||||
$tr_attr = '';
|
||||
$th_attr = '';
|
||||
$td_attr = '';
|
||||
$cols = $cols_count = 3;
|
||||
$rows = 3;
|
||||
$trailpad = ' ';
|
||||
$vdir = 'down';
|
||||
$hdir = 'right';
|
||||
$inner = 'cols';
|
||||
$caption = '';
|
||||
$loop = null;
|
||||
if (!isset($params[ 'loop' ])) {
|
||||
trigger_error("html_table: missing 'loop' parameter", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
foreach ($params as $_key => $_value) {
|
||||
switch ($_key) {
|
||||
case 'loop':
|
||||
$$_key = (array)$_value;
|
||||
break;
|
||||
case 'cols':
|
||||
if (is_array($_value) && !empty($_value)) {
|
||||
$cols = $_value;
|
||||
$cols_count = count($_value);
|
||||
} elseif (!is_numeric($_value) && is_string($_value) && !empty($_value)) {
|
||||
$cols = explode(',', $_value);
|
||||
$cols_count = count($cols);
|
||||
} elseif (!empty($_value)) {
|
||||
$cols_count = (int)$_value;
|
||||
} else {
|
||||
$cols_count = $cols;
|
||||
}
|
||||
break;
|
||||
case 'rows':
|
||||
$$_key = (int)$_value;
|
||||
break;
|
||||
case 'table_attr':
|
||||
case 'trailpad':
|
||||
case 'hdir':
|
||||
case 'vdir':
|
||||
case 'inner':
|
||||
case 'caption':
|
||||
$$_key = (string)$_value;
|
||||
break;
|
||||
case 'tr_attr':
|
||||
case 'td_attr':
|
||||
case 'th_attr':
|
||||
$$_key = $_value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$loop_count = count($loop);
|
||||
if (empty($params[ 'rows' ])) {
|
||||
/* no rows specified */
|
||||
$rows = ceil($loop_count / $cols_count);
|
||||
} elseif (empty($params[ 'cols' ])) {
|
||||
if (!empty($params[ 'rows' ])) {
|
||||
/* no cols specified, but rows */
|
||||
$cols_count = ceil($loop_count / $rows);
|
||||
}
|
||||
}
|
||||
$output = "<table $table_attr>\n";
|
||||
if (!empty($caption)) {
|
||||
$output .= '<caption>' . $caption . "</caption>\n";
|
||||
}
|
||||
if (is_array($cols)) {
|
||||
$cols = ($hdir === 'right') ? $cols : array_reverse($cols);
|
||||
$output .= "<thead><tr>\n";
|
||||
for ($r = 0; $r < $cols_count; $r++) {
|
||||
$output .= '<th' . smarty_function_html_table_cycle('th', $th_attr, $r) . '>';
|
||||
$output .= $cols[ $r ];
|
||||
$output .= "</th>\n";
|
||||
}
|
||||
$output .= "</tr></thead>\n";
|
||||
}
|
||||
$output .= "<tbody>\n";
|
||||
for ($r = 0; $r < $rows; $r++) {
|
||||
$output .= "<tr" . smarty_function_html_table_cycle('tr', $tr_attr, $r) . ">\n";
|
||||
$rx = ($vdir === 'down') ? $r * $cols_count : ($rows - 1 - $r) * $cols_count;
|
||||
for ($c = 0; $c < $cols_count; $c++) {
|
||||
$x = ($hdir === 'right') ? $rx + $c : $rx + $cols_count - 1 - $c;
|
||||
if ($inner !== 'cols') {
|
||||
/* shuffle x to loop over rows*/
|
||||
$x = floor($x / $cols_count) + ($x % $cols_count) * $rows;
|
||||
}
|
||||
if ($x < $loop_count) {
|
||||
$output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">" . $loop[ $x ] . "</td>\n";
|
||||
} else {
|
||||
$output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">$trailpad</td>\n";
|
||||
}
|
||||
}
|
||||
$output .= "</tr>\n";
|
||||
}
|
||||
$output .= "</tbody>\n";
|
||||
$output .= "</table>\n";
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $var
|
||||
* @param $no
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_html_table_cycle($name, $var, $no)
|
||||
{
|
||||
if (!is_array($var)) {
|
||||
$ret = $var;
|
||||
} else {
|
||||
$ret = $var[ $no % count($var) ];
|
||||
}
|
||||
return ($ret) ? ' ' . $ret : '';
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
/**
|
||||
* Smarty {mailto} function plugin
|
||||
* Type: function
|
||||
* Name: mailto
|
||||
* Date: May 21, 2002
|
||||
* Purpose: automate mailto address link creation, and optionally encode them.
|
||||
* Params:
|
||||
*
|
||||
* - address - (required) - e-mail address
|
||||
* - text - (optional) - text to display, default is address
|
||||
* - encode - (optional) - can be one of:
|
||||
* * none : no encoding (default)
|
||||
* * javascript : encode with javascript
|
||||
* * javascript_charcode : encode with javascript charcode
|
||||
* * hex : encode with hexadecimal (no javascript)
|
||||
* - cc - (optional) - address(es) to carbon copy
|
||||
* - bcc - (optional) - address(es) to blind carbon copy
|
||||
* - subject - (optional) - e-mail subject
|
||||
* - newsgroups - (optional) - newsgroup(s) to post to
|
||||
* - followupto - (optional) - address(es) to follow up to
|
||||
* - extra - (optional) - extra tags for the href link
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* {mailto address="me@domain.com"}
|
||||
* {mailto address="me@domain.com" encode="javascript"}
|
||||
* {mailto address="me@domain.com" encode="hex"}
|
||||
* {mailto address="me@domain.com" subject="Hello to you!"}
|
||||
* {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
|
||||
* {mailto address="me@domain.com" extra='class="mailto"'}
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto}
|
||||
* (Smarty online manual)
|
||||
* @version 1.2
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credits to Jason Sweat (added cc, bcc and subject functionality)
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_mailto($params)
|
||||
{
|
||||
static $_allowed_encoding =
|
||||
array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true);
|
||||
$extra = '';
|
||||
if (empty($params[ 'address' ])) {
|
||||
trigger_error("mailto: missing 'address' parameter", E_USER_WARNING);
|
||||
return;
|
||||
} else {
|
||||
$address = $params[ 'address' ];
|
||||
}
|
||||
$text = $address;
|
||||
// netscape and mozilla do not decode %40 (@) in BCC field (bug?)
|
||||
// so, don't encode it.
|
||||
$search = array('%40', '%2C');
|
||||
$replace = array('@', ',');
|
||||
$mail_parms = array();
|
||||
foreach ($params as $var => $value) {
|
||||
switch ($var) {
|
||||
case 'cc':
|
||||
case 'bcc':
|
||||
case 'followupto':
|
||||
if (!empty($value)) {
|
||||
$mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value));
|
||||
}
|
||||
break;
|
||||
case 'subject':
|
||||
case 'newsgroups':
|
||||
$mail_parms[] = $var . '=' . rawurlencode($value);
|
||||
break;
|
||||
case 'extra':
|
||||
case 'text':
|
||||
$$var = $value;
|
||||
// no break
|
||||
default:
|
||||
}
|
||||
}
|
||||
if ($mail_parms) {
|
||||
$address .= '?' . join('&', $mail_parms);
|
||||
}
|
||||
$encode = (empty($params[ 'encode' ])) ? 'none' : $params[ 'encode' ];
|
||||
if (!isset($_allowed_encoding[ $encode ])) {
|
||||
trigger_error(
|
||||
"mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex",
|
||||
E_USER_WARNING
|
||||
);
|
||||
return;
|
||||
}
|
||||
// FIXME: (rodneyrehm) document.write() excues me what? 1998 has passed!
|
||||
if ($encode === 'javascript') {
|
||||
$string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');';
|
||||
$js_encode = '';
|
||||
for ($x = 0, $_length = strlen($string); $x < $_length; $x++) {
|
||||
$js_encode .= '%' . bin2hex($string[ $x ]);
|
||||
}
|
||||
return '<script type="text/javascript">eval(unescape(\'' . $js_encode . '\'))</script>';
|
||||
} elseif ($encode === 'javascript_charcode') {
|
||||
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
|
||||
for ($x = 0, $y = strlen($string); $x < $y; $x++) {
|
||||
$ord[] = ord($string[ $x ]);
|
||||
}
|
||||
$_ret = "<script type=\"text/javascript\" language=\"javascript\">\n" . "{document.write(String.fromCharCode(" .
|
||||
implode(',', $ord) . "))" . "}\n" . "</script>\n";
|
||||
return $_ret;
|
||||
} elseif ($encode === 'hex') {
|
||||
preg_match('!^(.*)(\?.*)$!', $address, $match);
|
||||
if (!empty($match[ 2 ])) {
|
||||
trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
$address_encode = '';
|
||||
for ($x = 0, $_length = strlen($address); $x < $_length; $x++) {
|
||||
if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[ $x ])) {
|
||||
$address_encode .= '%' . bin2hex($address[ $x ]);
|
||||
} else {
|
||||
$address_encode .= $address[ $x ];
|
||||
}
|
||||
}
|
||||
$text_encode = '';
|
||||
for ($x = 0, $_length = strlen($text); $x < $_length; $x++) {
|
||||
$text_encode .= '&#x' . bin2hex($text[ $x ]) . ';';
|
||||
}
|
||||
$mailto = "mailto:";
|
||||
return '<a href="' . $mailto . $address_encode . '" ' . $extra . '>' . $text_encode . '</a>';
|
||||
} else {
|
||||
// no encoding
|
||||
return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
|
||||
}
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* This plugin is only for Smarty2 BC
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
/**
|
||||
* Smarty {math} function plugin
|
||||
* Type: function
|
||||
* Name: math
|
||||
* Purpose: handle math computations in template
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.math.php {math}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function smarty_function_math($params, $template)
|
||||
{
|
||||
static $_allowed_funcs =
|
||||
array(
|
||||
'int' => true,
|
||||
'abs' => true,
|
||||
'ceil' => true,
|
||||
'cos' => true,
|
||||
'exp' => true,
|
||||
'floor' => true,
|
||||
'log' => true,
|
||||
'log10' => true,
|
||||
'max' => true,
|
||||
'min' => true,
|
||||
'pi' => true,
|
||||
'pow' => true,
|
||||
'rand' => true,
|
||||
'round' => true,
|
||||
'sin' => true,
|
||||
'sqrt' => true,
|
||||
'srand' => true,
|
||||
'tan' => true
|
||||
);
|
||||
// be sure equation parameter is present
|
||||
if (empty($params[ 'equation' ])) {
|
||||
trigger_error("math: missing equation parameter", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
$equation = $params[ 'equation' ];
|
||||
// make sure parenthesis are balanced
|
||||
if (substr_count($equation, '(') !== substr_count($equation, ')')) {
|
||||
trigger_error("math: unbalanced parenthesis", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
// disallow backticks
|
||||
if (strpos($equation, '`') !== false) {
|
||||
trigger_error("math: backtick character not allowed in equation", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
// also disallow dollar signs
|
||||
if (strpos($equation, '$') !== false) {
|
||||
trigger_error("math: dollar signs not allowed in equation", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
foreach ($params as $key => $val) {
|
||||
if ($key !== 'equation' && $key !== 'format' && $key !== 'assign') {
|
||||
// make sure value is not empty
|
||||
if (strlen($val) === 0) {
|
||||
trigger_error("math: parameter '{$key}' is empty", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
if (!is_numeric($val)) {
|
||||
trigger_error("math: parameter '{$key}' is not numeric", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// match all vars in equation, make sure all are passed
|
||||
preg_match_all('!(?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)!', $equation, $match);
|
||||
foreach ($match[ 1 ] as $curr_var) {
|
||||
if ($curr_var && !isset($params[ $curr_var ]) && !isset($_allowed_funcs[ $curr_var ])) {
|
||||
trigger_error(
|
||||
"math: function call '{$curr_var}' not allowed, or missing parameter '{$curr_var}'",
|
||||
E_USER_WARNING
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
foreach ($params as $key => $val) {
|
||||
if ($key !== 'equation' && $key !== 'format' && $key !== 'assign') {
|
||||
$equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
|
||||
}
|
||||
}
|
||||
$smarty_math_result = null;
|
||||
eval("\$smarty_math_result = " . $equation . ";");
|
||||
if (empty($params[ 'format' ])) {
|
||||
if (empty($params[ 'assign' ])) {
|
||||
return $smarty_math_result;
|
||||
} else {
|
||||
$template->assign($params[ 'assign' ], $smarty_math_result);
|
||||
}
|
||||
} else {
|
||||
if (empty($params[ 'assign' ])) {
|
||||
printf($params[ 'format' ], $smarty_math_result);
|
||||
} else {
|
||||
$template->assign($params[ 'assign' ], sprintf($params[ 'format' ], $smarty_math_result));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,145 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
/**
|
||||
* Smarty capitalize modifier plugin
|
||||
* Type: modifier
|
||||
* Name: capitalize
|
||||
* Purpose: capitalize words in the string
|
||||
* {@internal {$string|capitalize:true:true} is the fastest option for MBString enabled systems }}
|
||||
*
|
||||
* @param string $string string to capitalize
|
||||
* @param boolean $uc_digits also capitalize "x123" to "X123"
|
||||
* @param boolean $lc_rest capitalize first letters, lowercase all following letters "aAa" to "Aaa"
|
||||
*
|
||||
* @return string capitalized string
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = false)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if ($lc_rest) {
|
||||
// uppercase (including hyphenated words)
|
||||
$upper_string = mb_convert_case($string, MB_CASE_TITLE, Smarty::$_CHARSET);
|
||||
} else {
|
||||
// uppercase word breaks
|
||||
$upper_string = preg_replace_callback(
|
||||
"!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER,
|
||||
'smarty_mod_cap_mbconvert_cb',
|
||||
$string
|
||||
);
|
||||
}
|
||||
// check uc_digits case
|
||||
if (!$uc_digits) {
|
||||
if (preg_match_all(
|
||||
"!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER,
|
||||
$string,
|
||||
$matches,
|
||||
PREG_OFFSET_CAPTURE
|
||||
)
|
||||
) {
|
||||
foreach ($matches[ 1 ] as $match) {
|
||||
$upper_string =
|
||||
substr_replace(
|
||||
$upper_string,
|
||||
mb_strtolower($match[ 0 ], Smarty::$_CHARSET),
|
||||
$match[ 1 ],
|
||||
strlen($match[ 0 ])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$upper_string =
|
||||
preg_replace_callback(
|
||||
"!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER,
|
||||
'smarty_mod_cap_mbconvert2_cb',
|
||||
$upper_string
|
||||
);
|
||||
return $upper_string;
|
||||
}
|
||||
// lowercase first
|
||||
if ($lc_rest) {
|
||||
$string = strtolower($string);
|
||||
}
|
||||
// uppercase (including hyphenated words)
|
||||
$upper_string =
|
||||
preg_replace_callback(
|
||||
"!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER,
|
||||
'smarty_mod_cap_ucfirst_cb',
|
||||
$string
|
||||
);
|
||||
// check uc_digits case
|
||||
if (!$uc_digits) {
|
||||
if (preg_match_all(
|
||||
"!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER,
|
||||
$string,
|
||||
$matches,
|
||||
PREG_OFFSET_CAPTURE
|
||||
)
|
||||
) {
|
||||
foreach ($matches[ 1 ] as $match) {
|
||||
$upper_string =
|
||||
substr_replace($upper_string, strtolower($match[ 0 ]), $match[ 1 ], strlen($match[ 0 ]));
|
||||
}
|
||||
}
|
||||
}
|
||||
$upper_string = preg_replace_callback(
|
||||
"!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER,
|
||||
'smarty_mod_cap_ucfirst2_cb',
|
||||
$upper_string
|
||||
);
|
||||
return $upper_string;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Bug: create_function() use exhausts memory when used in long loops
|
||||
* Fix: use declared functions for callbacks instead of using create_function()
|
||||
* Note: This can be fixed using anonymous functions instead, but that requires PHP >= 5.3
|
||||
*
|
||||
* @author Kyle Renfrow
|
||||
*/
|
||||
/**
|
||||
* @param $matches
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_mod_cap_mbconvert_cb($matches)
|
||||
{
|
||||
return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 2 ]), MB_CASE_UPPER, Smarty::$_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $matches
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_mod_cap_mbconvert2_cb($matches)
|
||||
{
|
||||
return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 3 ]), MB_CASE_UPPER, Smarty::$_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $matches
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_mod_cap_ucfirst_cb($matches)
|
||||
{
|
||||
return stripslashes($matches[ 1 ]) . ucfirst(stripslashes($matches[ 2 ]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $matches
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_mod_cap_ucfirst2_cb($matches)
|
||||
{
|
||||
return stripslashes($matches[ 1 ]) . ucfirst(stripslashes($matches[ 3 ]));
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
/**
|
||||
* Smarty date_format modifier plugin
|
||||
* Type: modifier
|
||||
* Name: date_format
|
||||
* Purpose: format datestamps via strftime
|
||||
* Input:
|
||||
* - string: input date string
|
||||
* - format: strftime format for output
|
||||
* - default_date: default date if $string is empty
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input date string
|
||||
* @param string $format strftime format for output
|
||||
* @param string $default_date default date if $string is empty
|
||||
* @param string $formatter either 'strftime' or 'auto'
|
||||
*
|
||||
* @return string |void
|
||||
* @uses smarty_make_timestamp()
|
||||
*/
|
||||
function smarty_modifier_date_format($string, $format = null, $default_date = '', $formatter = 'auto')
|
||||
{
|
||||
if ($format === null) {
|
||||
$format = Smarty::$_DATE_FORMAT;
|
||||
}
|
||||
/**
|
||||
* require_once the {@link shared.make_timestamp.php} plugin
|
||||
*/
|
||||
static $is_loaded = false;
|
||||
if (!$is_loaded) {
|
||||
if (!is_callable('smarty_make_timestamp')) {
|
||||
include_once SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php';
|
||||
}
|
||||
$is_loaded = true;
|
||||
}
|
||||
if ($string !== '' && $string !== '0000-00-00' && $string !== '0000-00-00 00:00:00') {
|
||||
$timestamp = smarty_make_timestamp($string);
|
||||
} elseif ($default_date !== '') {
|
||||
$timestamp = smarty_make_timestamp($default_date);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if ($formatter === 'strftime' || ($formatter === 'auto' && strpos($format, '%') !== false)) {
|
||||
if (Smarty::$_IS_WINDOWS) {
|
||||
$_win_from = array(
|
||||
'%D',
|
||||
'%h',
|
||||
'%n',
|
||||
'%r',
|
||||
'%R',
|
||||
'%t',
|
||||
'%T'
|
||||
);
|
||||
$_win_to = array(
|
||||
'%m/%d/%y',
|
||||
'%b',
|
||||
"\n",
|
||||
'%I:%M:%S %p',
|
||||
'%H:%M',
|
||||
"\t",
|
||||
'%H:%M:%S'
|
||||
);
|
||||
if (strpos($format, '%e') !== false) {
|
||||
$_win_from[] = '%e';
|
||||
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
|
||||
}
|
||||
if (strpos($format, '%l') !== false) {
|
||||
$_win_from[] = '%l';
|
||||
$_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
|
||||
}
|
||||
$format = str_replace($_win_from, $_win_to, $format);
|
||||
}
|
||||
return strftime($format, $timestamp);
|
||||
} else {
|
||||
return date($format, $timestamp);
|
||||
}
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Debug
|
||||
*/
|
||||
/**
|
||||
* Smarty debug_print_var modifier plugin
|
||||
* Type: modifier
|
||||
* Name: debug_print_var
|
||||
* Purpose: formats variable contents for display in the console
|
||||
*
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param array|object $var variable to be formatted
|
||||
* @param int $max maximum recursion depth if $var is an array or object
|
||||
* @param int $length maximum string length if $var is a string
|
||||
* @param int $depth actual recursion depth
|
||||
* @param array $objects processed objects in actual depth to prevent recursive object processing
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth = 0, $objects = array())
|
||||
{
|
||||
$_replace = array("\n" => '\n', "\r" => '\r', "\t" => '\t');
|
||||
switch (gettype($var)) {
|
||||
case 'array':
|
||||
$results = '<b>Array (' . count($var) . ')</b>';
|
||||
if ($depth === $max) {
|
||||
break;
|
||||
}
|
||||
foreach ($var as $curr_key => $curr_val) {
|
||||
$results .= '<br>' . str_repeat(' ', $depth * 2) . '<b>' . strtr($curr_key, $_replace) .
|
||||
'</b> => ' .
|
||||
smarty_modifier_debug_print_var($curr_val, $max, $length, ++$depth, $objects);
|
||||
$depth--;
|
||||
}
|
||||
break;
|
||||
case 'object':
|
||||
$object_vars = get_object_vars($var);
|
||||
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
|
||||
if (in_array($var, $objects)) {
|
||||
$results .= ' called recursive';
|
||||
break;
|
||||
}
|
||||
if ($depth === $max) {
|
||||
break;
|
||||
}
|
||||
$objects[] = $var;
|
||||
foreach ($object_vars as $curr_key => $curr_val) {
|
||||
$results .= '<br>' . str_repeat(' ', $depth * 2) . '<b> ->' . strtr($curr_key, $_replace) .
|
||||
'</b> = ' . smarty_modifier_debug_print_var($curr_val, $max, $length, ++$depth, $objects);
|
||||
$depth--;
|
||||
}
|
||||
break;
|
||||
case 'boolean':
|
||||
case 'NULL':
|
||||
case 'resource':
|
||||
if (true === $var) {
|
||||
$results = 'true';
|
||||
} elseif (false === $var) {
|
||||
$results = 'false';
|
||||
} elseif (null === $var) {
|
||||
$results = 'null';
|
||||
} else {
|
||||
$results = htmlspecialchars((string)$var);
|
||||
}
|
||||
$results = '<i>' . $results . '</i>';
|
||||
break;
|
||||
case 'integer':
|
||||
case 'float':
|
||||
$results = htmlspecialchars((string)$var);
|
||||
break;
|
||||
case 'string':
|
||||
$results = strtr($var, $_replace);
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (mb_strlen($var, Smarty::$_CHARSET) > $length) {
|
||||
$results = mb_substr($var, 0, $length - 3, Smarty::$_CHARSET) . '...';
|
||||
}
|
||||
} else {
|
||||
if (isset($var[ $length ])) {
|
||||
$results = substr($var, 0, $length - 3) . '...';
|
||||
}
|
||||
}
|
||||
$results = htmlspecialchars('"' . $results . '"', ENT_QUOTES, Smarty::$_CHARSET);
|
||||
break;
|
||||
case 'unknown type':
|
||||
default:
|
||||
$results = strtr((string)$var, $_replace);
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (mb_strlen($results, Smarty::$_CHARSET) > $length) {
|
||||
$results = mb_substr($results, 0, $length - 3, Smarty::$_CHARSET) . '...';
|
||||
}
|
||||
} else {
|
||||
if (strlen($results) > $length) {
|
||||
$results = substr($results, 0, $length - 3) . '...';
|
||||
}
|
||||
}
|
||||
$results = htmlspecialchars($results, ENT_QUOTES, Smarty::$_CHARSET);
|
||||
}
|
||||
return $results;
|
||||
}
|
|
@ -1,255 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
/**
|
||||
* Smarty escape modifier plugin
|
||||
* Type: modifier
|
||||
* Name: escape
|
||||
* Purpose: escape string for output
|
||||
*
|
||||
* @link http://www.smarty.net/docs/en/language.modifier.escape
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input string
|
||||
* @param string $esc_type escape type
|
||||
* @param string $char_set character set, used for htmlspecialchars() or htmlentities()
|
||||
* @param boolean $double_encode encode already encoded entitites again, used for htmlspecialchars() or htmlentities()
|
||||
*
|
||||
* @return string escaped input string
|
||||
*/
|
||||
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
|
||||
{
|
||||
static $_double_encode = null;
|
||||
static $is_loaded_1 = false;
|
||||
static $is_loaded_2 = false;
|
||||
if ($_double_encode === null) {
|
||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||
}
|
||||
if (!$char_set) {
|
||||
$char_set = Smarty::$_CHARSET;
|
||||
}
|
||||
switch ($esc_type) {
|
||||
case 'html':
|
||||
if ($_double_encode) {
|
||||
// php >=5.3.2 - go native
|
||||
return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
} else {
|
||||
if ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
} else {
|
||||
// php <5.2.3 - prevent double encoding
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
$string = str_replace(
|
||||
array(
|
||||
'%%%SMARTY_START%%%',
|
||||
'%%%SMARTY_END%%%'
|
||||
),
|
||||
array(
|
||||
'&',
|
||||
';'
|
||||
),
|
||||
$string
|
||||
);
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
// no break
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
// mb_convert_encoding ignores htmlspecialchars()
|
||||
if ($_double_encode) {
|
||||
// php >=5.3.2 - go native
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
} else {
|
||||
if ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
} else {
|
||||
// php <5.2.3 - prevent double encoding
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
$string =
|
||||
str_replace(
|
||||
array(
|
||||
'%%%SMARTY_START%%%',
|
||||
'%%%SMARTY_END%%%'
|
||||
),
|
||||
array(
|
||||
'&',
|
||||
';'
|
||||
),
|
||||
$string
|
||||
);
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
// htmlentities() won't convert everything, so use mb_convert_encoding
|
||||
return mb_convert_encoding($string, 'HTML-ENTITIES', $char_set);
|
||||
}
|
||||
// no MBString fallback
|
||||
if ($_double_encode) {
|
||||
return htmlentities($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
} else {
|
||||
if ($double_encode) {
|
||||
return htmlentities($string, ENT_QUOTES, $char_set);
|
||||
} else {
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlentities($string, ENT_QUOTES, $char_set);
|
||||
$string = str_replace(
|
||||
array(
|
||||
'%%%SMARTY_START%%%',
|
||||
'%%%SMARTY_END%%%'
|
||||
),
|
||||
array(
|
||||
'&',
|
||||
';'
|
||||
),
|
||||
$string
|
||||
);
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
// no break
|
||||
case 'url':
|
||||
return rawurlencode($string);
|
||||
case 'urlpathinfo':
|
||||
return str_replace('%2F', '/', rawurlencode($string));
|
||||
case 'quotes':
|
||||
// escape unescaped single quotes
|
||||
return preg_replace("%(?<!\\\\)'%", "\\'", $string);
|
||||
case 'hex':
|
||||
// escape every byte into hex
|
||||
// Note that the UTF-8 encoded character ä will be represented as %c3%a4
|
||||
$return = '';
|
||||
$_length = strlen($string);
|
||||
for ($x = 0; $x < $_length; $x++) {
|
||||
$return .= '%' . bin2hex($string[ $x ]);
|
||||
}
|
||||
return $return;
|
||||
case 'hexentity':
|
||||
$return = '';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (!$is_loaded_1) {
|
||||
if (!is_callable('smarty_mb_to_unicode')) {
|
||||
include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php';
|
||||
}
|
||||
$is_loaded_1 = true;
|
||||
}
|
||||
$return = '';
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
$return .= '&#x' . strtoupper(dechex($unicode)) . ';';
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
// no MBString fallback
|
||||
$_length = strlen($string);
|
||||
for ($x = 0; $x < $_length; $x++) {
|
||||
$return .= '&#x' . bin2hex($string[ $x ]) . ';';
|
||||
}
|
||||
return $return;
|
||||
case 'decentity':
|
||||
$return = '';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (!$is_loaded_1) {
|
||||
if (!is_callable('smarty_mb_to_unicode')) {
|
||||
include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php';
|
||||
}
|
||||
$is_loaded_1 = true;
|
||||
}
|
||||
$return = '';
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
$return .= '&#' . $unicode . ';';
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
// no MBString fallback
|
||||
$_length = strlen($string);
|
||||
for ($x = 0; $x < $_length; $x++) {
|
||||
$return .= '&#' . ord($string[ $x ]) . ';';
|
||||
}
|
||||
return $return;
|
||||
case 'javascript':
|
||||
// escape quotes and backslashes, newlines, etc.
|
||||
return strtr(
|
||||
$string,
|
||||
array(
|
||||
'\\' => '\\\\',
|
||||
"'" => "\\'",
|
||||
'"' => '\\"',
|
||||
"\r" => '\\r',
|
||||
"\n" => '\\n',
|
||||
'</' => '<\/'
|
||||
)
|
||||
);
|
||||
case 'mail':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (!$is_loaded_2) {
|
||||
if (!is_callable('smarty_mb_str_replace')) {
|
||||
include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php';
|
||||
}
|
||||
$is_loaded_2 = true;
|
||||
}
|
||||
return smarty_mb_str_replace(
|
||||
array(
|
||||
'@',
|
||||
'.'
|
||||
),
|
||||
array(
|
||||
' [AT] ',
|
||||
' [DOT] '
|
||||
),
|
||||
$string
|
||||
);
|
||||
}
|
||||
// no MBString fallback
|
||||
return str_replace(
|
||||
array(
|
||||
'@',
|
||||
'.'
|
||||
),
|
||||
array(
|
||||
' [AT] ',
|
||||
' [DOT] '
|
||||
),
|
||||
$string
|
||||
);
|
||||
case 'nonstd':
|
||||
// escape non-standard chars, such as ms document quotes
|
||||
$return = '';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (!$is_loaded_1) {
|
||||
if (!is_callable('smarty_mb_to_unicode')) {
|
||||
include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php';
|
||||
}
|
||||
$is_loaded_1 = true;
|
||||
}
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
if ($unicode >= 126) {
|
||||
$return .= '&#' . $unicode . ';';
|
||||
} else {
|
||||
$return .= chr($unicode);
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
$_length = strlen($string);
|
||||
for ($_i = 0; $_i < $_length; $_i++) {
|
||||
$_ord = ord(substr($string, $_i, 1));
|
||||
// non-standard char, escape it
|
||||
if ($_ord >= 126) {
|
||||
$return .= '&#' . $_ord . ';';
|
||||
} else {
|
||||
$return .= substr($string, $_i, 1);
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
default:
|
||||
return $string;
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
/**
|
||||
* Smarty wordwrap modifier plugin
|
||||
* Type: modifier
|
||||
* Name: mb_wordwrap
|
||||
* Purpose: Wrap a string to a given number of characters
|
||||
*
|
||||
* @link http://php.net/manual/en/function.wordwrap.php for similarity
|
||||
*
|
||||
* @param string $str the string to wrap
|
||||
* @param int $width the width of the output
|
||||
* @param string $break the character used to break the line
|
||||
* @param boolean $cut ignored parameter, just for the sake of
|
||||
*
|
||||
* @return string wrapped string
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
function smarty_modifier_mb_wordwrap($str, $width = 75, $break = "\n", $cut = false)
|
||||
{
|
||||
// break words into tokens using white space as a delimiter
|
||||
$tokens = preg_split('!(\s)!S' . Smarty::$_UTF8_MODIFIER, $str, -1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE);
|
||||
$length = 0;
|
||||
$t = '';
|
||||
$_previous = false;
|
||||
$_space = false;
|
||||
foreach ($tokens as $_token) {
|
||||
$token_length = mb_strlen($_token, Smarty::$_CHARSET);
|
||||
$_tokens = array($_token);
|
||||
if ($token_length > $width) {
|
||||
if ($cut) {
|
||||
$_tokens = preg_split(
|
||||
'!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER,
|
||||
$_token,
|
||||
-1,
|
||||
PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE
|
||||
);
|
||||
}
|
||||
}
|
||||
foreach ($_tokens as $token) {
|
||||
$_space = !!preg_match('!^\s$!S' . Smarty::$_UTF8_MODIFIER, $token);
|
||||
$token_length = mb_strlen($token, Smarty::$_CHARSET);
|
||||
$length += $token_length;
|
||||
if ($length > $width) {
|
||||
// remove space before inserted break
|
||||
if ($_previous) {
|
||||
$t = mb_substr($t, 0, -1, Smarty::$_CHARSET);
|
||||
}
|
||||
if (!$_space) {
|
||||
// add the break before the token
|
||||
if (!empty($t)) {
|
||||
$t .= $break;
|
||||
}
|
||||
$length = $token_length;
|
||||
}
|
||||
} elseif ($token === "\n") {
|
||||
// hard break must reset counters
|
||||
$length = 0;
|
||||
}
|
||||
$_previous = $_space;
|
||||
// add the token
|
||||
$t .= $token;
|
||||
}
|
||||
}
|
||||
return $t;
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
/**
|
||||
* Smarty regex_replace modifier plugin
|
||||
* Type: modifier
|
||||
* Name: regex_replace
|
||||
* Purpose: regular expression search/replace
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php
|
||||
* regex_replace (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input string
|
||||
* @param string|array $search regular expression(s) to search for
|
||||
* @param string|array $replace string(s) that should be replaced
|
||||
* @param int $limit the maximum number of replacements
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_regex_replace($string, $search, $replace, $limit = -1)
|
||||
{
|
||||
if (is_array($search)) {
|
||||
foreach ($search as $idx => $s) {
|
||||
$search[ $idx ] = _smarty_regex_replace_check($s);
|
||||
}
|
||||
} else {
|
||||
$search = _smarty_regex_replace_check($search);
|
||||
}
|
||||
return preg_replace($search, $replace, $string, $limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $search string(s) that should be replaced
|
||||
*
|
||||
* @return string
|
||||
* @ignore
|
||||
*/
|
||||
function _smarty_regex_replace_check($search)
|
||||
{
|
||||
// null-byte injection detection
|
||||
// anything behind the first null-byte is ignored
|
||||
if (($pos = strpos($search, "\0")) !== false) {
|
||||
$search = substr($search, 0, $pos);
|
||||
}
|
||||
// remove eval-modifier from $search
|
||||
if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[ 1 ], 'e') !== false)) {
|
||||
$search = substr($search, 0, -strlen($match[ 1 ])) . preg_replace('![e\s]+!', '', $match[ 1 ]);
|
||||
}
|
||||
return $search;
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
/**
|
||||
* Smarty replace modifier plugin
|
||||
* Type: modifier
|
||||
* Name: replace
|
||||
* Purpose: simple search/replace
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param string $string input string
|
||||
* @param string $search text to search for
|
||||
* @param string $replace replacement text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_replace($string, $search, $replace)
|
||||
{
|
||||
static $is_loaded = false;
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (!$is_loaded) {
|
||||
if (!is_callable('smarty_mb_str_replace')) {
|
||||
include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php';
|
||||
}
|
||||
$is_loaded = true;
|
||||
}
|
||||
return smarty_mb_str_replace($search, $replace, $string);
|
||||
}
|
||||
return str_replace($search, $replace, $string);
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
/**
|
||||
* Smarty spacify modifier plugin
|
||||
* Type: modifier
|
||||
* Name: spacify
|
||||
* Purpose: add spaces between characters in a string
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input string
|
||||
* @param string $spacify_char string to insert between characters.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_spacify($string, $spacify_char = ' ')
|
||||
{
|
||||
// well… what about charsets besides latin and UTF-8?
|
||||
return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY));
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
/**
|
||||
* Smarty truncate modifier plugin
|
||||
* Type: modifier
|
||||
* Name: truncate
|
||||
* Purpose: Truncate a string to a certain length if necessary,
|
||||
* optionally splitting in the middle of a word, and
|
||||
* appending the $etc string or inserting $etc into the middle.
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input string
|
||||
* @param integer $length length of truncated text
|
||||
* @param string $etc end string
|
||||
* @param boolean $break_words truncate at word boundary
|
||||
* @param boolean $middle truncate in the middle of text
|
||||
*
|
||||
* @return string truncated string
|
||||
*/
|
||||
function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false)
|
||||
{
|
||||
if ($length === 0) {
|
||||
return '';
|
||||
}
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (mb_strlen($string, Smarty::$_CHARSET) > $length) {
|
||||
$length -= min($length, mb_strlen($etc, Smarty::$_CHARSET));
|
||||
if (!$break_words && !$middle) {
|
||||
$string = preg_replace(
|
||||
'/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER,
|
||||
'',
|
||||
mb_substr($string, 0, $length + 1, Smarty::$_CHARSET)
|
||||
);
|
||||
}
|
||||
if (!$middle) {
|
||||
return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc;
|
||||
}
|
||||
return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc .
|
||||
mb_substr($string, -$length / 2, $length, Smarty::$_CHARSET);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
// no MBString fallback
|
||||
if (isset($string[ $length ])) {
|
||||
$length -= min($length, strlen($etc));
|
||||
if (!$break_words && !$middle) {
|
||||
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1));
|
||||
}
|
||||
if (!$middle) {
|
||||
return substr($string, 0, $length) . $etc;
|
||||
}
|
||||
return substr($string, 0, $length / 2) . $etc . substr($string, -$length / 2);
|
||||
}
|
||||
return $string;
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty cat modifier plugin
|
||||
* Type: modifier
|
||||
* Name: cat
|
||||
* Date: Feb 24, 2003
|
||||
* Purpose: catenate a value to a variable
|
||||
* Input: string to catenate
|
||||
* Example: {$var|cat:"foo"}
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
|
||||
* (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_cat($params)
|
||||
{
|
||||
return '(' . implode(').(', $params) . ')';
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty count_characters modifier plugin
|
||||
* Type: modifier
|
||||
* Name: count_characters
|
||||
* Purpose: count the number of characters in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online
|
||||
* manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_characters($params)
|
||||
{
|
||||
if (!isset($params[ 1 ]) || $params[ 1 ] !== 'true') {
|
||||
return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[ 0 ] . ', $tmp)';
|
||||
}
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strlen(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strlen(' . $params[ 0 ] . ')';
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty count_paragraphs modifier plugin
|
||||
* Type: modifier
|
||||
* Name: count_paragraphs
|
||||
* Purpose: count the number of paragraphs in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* count_paragraphs (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_paragraphs($params)
|
||||
{
|
||||
// count \r or \n characters
|
||||
return '(preg_match_all(\'#[\r\n]+#\', ' . $params[ 0 ] . ', $tmp)+1)';
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty count_sentences modifier plugin
|
||||
* Type: modifier
|
||||
* Name: count_sentences
|
||||
* Purpose: count the number of sentences in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* count_sentences (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_sentences($params)
|
||||
{
|
||||
// find periods, question marks, exclamation marks with a word before but not after.
|
||||
return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[ 0 ] . ', $tmp)';
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty count_words modifier plugin
|
||||
* Type: modifier
|
||||
* Name: count_words
|
||||
* Purpose: count the number of words in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_count_words($params)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
// return 'preg_match_all(\'#[\w\pL]+#' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
|
||||
// expression taken from http://de.php.net/manual/en/function.str-word-count.php#85592
|
||||
return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . Smarty::$_UTF8_MODIFIER . '\', ' .
|
||||
$params[ 0 ] . ', $tmp)';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'str_word_count(' . $params[ 0 ] . ')';
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty default modifier plugin
|
||||
* Type: modifier
|
||||
* Name: default
|
||||
* Purpose: designate default value for empty variables
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_default($params)
|
||||
{
|
||||
$output = $params[ 0 ];
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = "''";
|
||||
}
|
||||
array_shift($params);
|
||||
foreach ($params as $param) {
|
||||
$output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)';
|
||||
}
|
||||
return $output;
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty escape modifier plugin
|
||||
* Type: modifier
|
||||
* Name: escape
|
||||
* Purpose: escape string for output
|
||||
*
|
||||
* @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_TemplateCompilerBase $compiler
|
||||
*
|
||||
* @return string with compiled code
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
static $_double_encode = null;
|
||||
static $is_loaded = false;
|
||||
$compiler->template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_literal_compiler_param',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
if ($_double_encode === null) {
|
||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||
}
|
||||
try {
|
||||
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
||||
$char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET);
|
||||
$double_encode = smarty_literal_compiler_param($params, 3, true);
|
||||
if (!$char_set) {
|
||||
$char_set = Smarty::$_CHARSET;
|
||||
}
|
||||
switch ($esc_type) {
|
||||
case 'html':
|
||||
if ($_double_encode) {
|
||||
return 'htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
||||
var_export($double_encode, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
return 'htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
// no break
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if ($_double_encode) {
|
||||
// php >=5.2.3 - go native
|
||||
return 'mb_convert_encoding(htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' .
|
||||
var_export($char_set, true) . ', ' . var_export($double_encode, true) .
|
||||
'), "HTML-ENTITIES", ' . var_export($char_set, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return 'mb_convert_encoding(htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' .
|
||||
var_export($char_set, true) . '), "HTML-ENTITIES", ' . var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
}
|
||||
// no MBString fallback
|
||||
if ($_double_encode) {
|
||||
// php >=5.2.3 - go native
|
||||
return 'htmlentities(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
||||
var_export($double_encode, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return 'htmlentities(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
// no break
|
||||
case 'url':
|
||||
return 'rawurlencode(' . $params[ 0 ] . ')';
|
||||
case 'urlpathinfo':
|
||||
return 'str_replace("%2F", "/", rawurlencode(' . $params[ 0 ] . '))';
|
||||
case 'quotes':
|
||||
// escape unescaped single quotes
|
||||
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[ 0 ] . ')';
|
||||
case 'javascript':
|
||||
// escape quotes and backslashes, newlines, etc.
|
||||
return 'strtr(' .
|
||||
$params[ 0 ] .
|
||||
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
|
||||
}
|
||||
} catch (SmartyException $e) {
|
||||
// pass through to regular plugin fallback
|
||||
}
|
||||
// could not optimize |escape call, so fallback to regular plugin
|
||||
if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) {
|
||||
$compiler->required_plugins[ 'nocache' ][ 'escape' ][ 'modifier' ][ 'file' ] =
|
||||
SMARTY_PLUGINS_DIR . 'modifier.escape.php';
|
||||
$compiler->required_plugins[ 'nocache' ][ 'escape' ][ 'modifier' ][ 'function' ] =
|
||||
'smarty_modifier_escape';
|
||||
} else {
|
||||
$compiler->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'file' ] =
|
||||
SMARTY_PLUGINS_DIR . 'modifier.escape.php';
|
||||
$compiler->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'function' ] =
|
||||
'smarty_modifier_escape';
|
||||
}
|
||||
return 'smarty_modifier_escape(' . join(', ', $params) . ')';
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty from_charset modifier plugin
|
||||
* Type: modifier
|
||||
* Name: from_charset
|
||||
* Purpose: convert character encoding from $charset to internal encoding
|
||||
*
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_from_charset($params)
|
||||
{
|
||||
if (!Smarty::$_MBSTRING) {
|
||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||
return $params[ 0 ];
|
||||
}
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = '"ISO-8859-1"';
|
||||
}
|
||||
return 'mb_convert_encoding(' . $params[ 0 ] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[ 1 ] . ')';
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty indent modifier plugin
|
||||
* Type: modifier
|
||||
* Name: indent
|
||||
* Purpose: indent lines of text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_indent($params)
|
||||
{
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = 4;
|
||||
}
|
||||
if (!isset($params[ 2 ])) {
|
||||
$params[ 2 ] = "' '";
|
||||
}
|
||||
return 'preg_replace(\'!^!m\',str_repeat(' . $params[ 2 ] . ',' . $params[ 1 ] . '),' . $params[ 0 ] . ')';
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty lower modifier plugin
|
||||
* Type: modifier
|
||||
* Name: lower
|
||||
* Purpose: convert string to lowercase
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_lower($params)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strtolower(' . $params[ 0 ] . ')';
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty noprint modifier plugin
|
||||
* Type: modifier
|
||||
* Name: noprint
|
||||
* Purpose: return an empty string
|
||||
*
|
||||
* @author Uwe Tews
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_noprint()
|
||||
{
|
||||
return "''";
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty string_format modifier plugin
|
||||
* Type: modifier
|
||||
* Name: string_format
|
||||
* Purpose: format strings via sprintf
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_string_format($params)
|
||||
{
|
||||
return 'sprintf(' . $params[ 1 ] . ',' . $params[ 0 ] . ')';
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty strip modifier plugin
|
||||
* Type: modifier
|
||||
* Name: strip
|
||||
* Purpose: Replace all repeated spaces, newlines, tabs
|
||||
* with a single space or supplied replacement string.
|
||||
* Example: {$var|strip} {$var|strip:" "}
|
||||
* Date: September 25th, 2002
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_strip($params)
|
||||
{
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = "' '";
|
||||
}
|
||||
return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty strip_tags modifier plugin
|
||||
* Type: modifier
|
||||
* Name: strip_tags
|
||||
* Purpose: strip html tags from text
|
||||
*
|
||||
* @link http://www.smarty.net/docs/en/language.modifier.strip.tags.tpl strip_tags (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_strip_tags($params)
|
||||
{
|
||||
if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') === 'true') {
|
||||
return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})";
|
||||
} else {
|
||||
return 'strip_tags(' . $params[ 0 ] . ')';
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty to_charset modifier plugin
|
||||
* Type: modifier
|
||||
* Name: to_charset
|
||||
* Purpose: convert character encoding from internal encoding to $charset
|
||||
*
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_to_charset($params)
|
||||
{
|
||||
if (!Smarty::$_MBSTRING) {
|
||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||
return $params[ 0 ];
|
||||
}
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = '"ISO-8859-1"';
|
||||
}
|
||||
return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 1 ] . ', "' . addslashes(Smarty::$_CHARSET) . '")';
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty unescape modifier plugin
|
||||
* Type: modifier
|
||||
* Name: unescape
|
||||
* Purpose: unescape html entities
|
||||
*
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_unescape($params)
|
||||
{
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = 'html';
|
||||
}
|
||||
if (!isset($params[ 2 ])) {
|
||||
$params[ 2 ] = '\'' . addslashes(Smarty::$_CHARSET) . '\'';
|
||||
} else {
|
||||
$params[ 2 ] = "'{$params[ 2 ]}'";
|
||||
}
|
||||
switch (trim($params[ 1 ], '"\'')) {
|
||||
case 'entity':
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'HTML-ENTITIES\')';
|
||||
}
|
||||
return 'html_entity_decode(' . $params[ 0 ] . ', ENT_NOQUOTES, ' . $params[ 2 ] . ')';
|
||||
case 'html':
|
||||
return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)';
|
||||
case 'url':
|
||||
return 'rawurldecode(' . $params[ 0 ] . ')';
|
||||
default:
|
||||
return $params[ 0 ];
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty upper modifier plugin
|
||||
* Type: modifier
|
||||
* Name: lower
|
||||
* Purpose: convert string to uppercase
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_upper($params)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strtoupper(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strtoupper(' . $params[ 0 ] . ')';
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty wordwrap modifier plugin
|
||||
* Type: modifier
|
||||
* Name: wordwrap
|
||||
* Purpose: wrap a string of text at a given length
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
*
|
||||
* @return string with compiled code
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
function smarty_modifiercompiler_wordwrap($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = 80;
|
||||
}
|
||||
if (!isset($params[ 2 ])) {
|
||||
$params[ 2 ] = '"\n"';
|
||||
}
|
||||
if (!isset($params[ 3 ])) {
|
||||
$params[ 3 ] = 'false';
|
||||
}
|
||||
$function = 'wordwrap';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
$function = $compiler->getPlugin('mb_wordwrap', 'modifier');
|
||||
}
|
||||
return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')';
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFilter
|
||||
*/
|
||||
/**
|
||||
* Smarty trimwhitespace outputfilter plugin
|
||||
* Trim unnecessary whitespace from HTML markup.
|
||||
*
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param string $source input string
|
||||
*
|
||||
* @return string filtered output
|
||||
* @todo substr_replace() is not overloaded by mbstring.func_overload - so this function might fail!
|
||||
*/
|
||||
function smarty_outputfilter_trimwhitespace($source)
|
||||
{
|
||||
$store = array();
|
||||
$_store = 0;
|
||||
$_offset = 0;
|
||||
// Unify Line-Breaks to \n
|
||||
$source = preg_replace('/\015\012|\015|\012/', "\n", $source);
|
||||
// capture Internet Explorer and KnockoutJS Conditional Comments
|
||||
if (preg_match_all(
|
||||
'#<!--((\[[^\]]+\]>.*?<!\[[^\]]+\])|(\s*/?ko\s+.+))-->#is',
|
||||
$source,
|
||||
$matches,
|
||||
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
|
||||
)
|
||||
) {
|
||||
foreach ($matches as $match) {
|
||||
$store[] = $match[ 0 ][ 0 ];
|
||||
$_length = strlen($match[ 0 ][ 0 ]);
|
||||
$replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
|
||||
$source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length);
|
||||
$_offset += $_length - strlen($replace);
|
||||
$_store++;
|
||||
}
|
||||
}
|
||||
// Strip all HTML-Comments
|
||||
// yes, even the ones in <script> - see http://stackoverflow.com/a/808850/515124
|
||||
$source = preg_replace('#<!--.*?-->#ms', '', $source);
|
||||
// capture html elements not to be messed with
|
||||
$_offset = 0;
|
||||
if (preg_match_all(
|
||||
'#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
|
||||
$source,
|
||||
$matches,
|
||||
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
|
||||
)
|
||||
) {
|
||||
foreach ($matches as $match) {
|
||||
$store[] = $match[ 0 ][ 0 ];
|
||||
$_length = strlen($match[ 0 ][ 0 ]);
|
||||
$replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
|
||||
$source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length);
|
||||
$_offset += $_length - strlen($replace);
|
||||
$_store++;
|
||||
}
|
||||
}
|
||||
$expressions = array(// replace multiple spaces between tags by a single space
|
||||
// can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements
|
||||
'#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2',
|
||||
// remove spaces between attributes (but not in attribute values!)
|
||||
'#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5',
|
||||
// note: for some very weird reason trim() seems to remove spaces inside attributes.
|
||||
// maybe a \0 byte or something is interfering?
|
||||
'#^\s+<#Ss' => '<',
|
||||
'#>\s+$#Ss' => '>',
|
||||
);
|
||||
$source = preg_replace(array_keys($expressions), array_values($expressions), $source);
|
||||
// note: for some very weird reason trim() seems to remove spaces inside attributes.
|
||||
// maybe a \0 byte or something is interfering?
|
||||
// $source = trim( $source );
|
||||
$_offset = 0;
|
||||
if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
||||
foreach ($matches as $match) {
|
||||
$_length = strlen($match[ 0 ][ 0 ]);
|
||||
$replace = $store[ $match[ 1 ][ 0 ] ];
|
||||
$source = substr_replace($source, $replace, $match[ 0 ][ 1 ] + $_offset, $_length);
|
||||
$_offset += strlen($replace) - $_length;
|
||||
$_store++;
|
||||
}
|
||||
}
|
||||
return $source;
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty shared plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsShared
|
||||
*/
|
||||
/**
|
||||
* escape_special_chars common function
|
||||
* Function: smarty_function_escape_special_chars
|
||||
* Purpose: used by other smarty functions to escape
|
||||
* special chars except for already escaped ones
|
||||
*
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string text that should by escaped
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_escape_special_chars($string)
|
||||
{
|
||||
if (!is_array($string)) {
|
||||
if (version_compare(PHP_VERSION, '5.2.3', '>=')) {
|
||||
$string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false);
|
||||
} else {
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlspecialchars($string);
|
||||
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
|
||||
}
|
||||
}
|
||||
return $string;
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsShared
|
||||
*/
|
||||
/**
|
||||
* evaluate compiler parameter
|
||||
*
|
||||
* @param array $params parameter array as given to the compiler function
|
||||
* @param integer $index array index of the parameter to convert
|
||||
* @param mixed $default value to be returned if the parameter is not present
|
||||
*
|
||||
* @return mixed evaluated value of parameter or $default
|
||||
* @throws SmartyException if parameter is not a literal (but an expression, variable, …)
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
function smarty_literal_compiler_param($params, $index, $default = null)
|
||||
{
|
||||
// not set, go default
|
||||
if (!isset($params[ $index ])) {
|
||||
return $default;
|
||||
}
|
||||
// test if param is a literal
|
||||
if (!preg_match('/^([\'"]?)[a-zA-Z0-9-]+(\\1)$/', $params[ $index ])) {
|
||||
throw new SmartyException(
|
||||
'$param[' . $index .
|
||||
'] is not a literal and is thus not evaluatable at compile time'
|
||||
);
|
||||
}
|
||||
$t = null;
|
||||
eval("\$t = " . $params[ $index ] . ";");
|
||||
return $t;
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty shared plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsShared
|
||||
*/
|
||||
/**
|
||||
* Function: smarty_make_timestamp
|
||||
* Purpose: used by other smarty functions to make a timestamp from a string.
|
||||
*
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param DateTime|int|string $string date object, timestamp or string that can be converted using strtotime()
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function smarty_make_timestamp($string)
|
||||
{
|
||||
if (empty($string)) {
|
||||
// use "now":
|
||||
return time();
|
||||
} elseif ($string instanceof DateTime
|
||||
|| (interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface)
|
||||
) {
|
||||
return (int)$string->format('U'); // PHP 5.2 BC
|
||||
} elseif (strlen($string) === 14 && ctype_digit($string)) {
|
||||
// it is mysql timestamp format of YYYYMMDDHHMMSS?
|
||||
return mktime(
|
||||
substr($string, 8, 2),
|
||||
substr($string, 10, 2),
|
||||
substr($string, 12, 2),
|
||||
substr($string, 4, 2),
|
||||
substr($string, 6, 2),
|
||||
substr($string, 0, 4)
|
||||
);
|
||||
} elseif (is_numeric($string)) {
|
||||
// it is a numeric string, we handle it as timestamp
|
||||
return (int)$string;
|
||||
} else {
|
||||
// strtotime should handle it
|
||||
$time = strtotime($string);
|
||||
if ($time === -1 || $time === false) {
|
||||
// strtotime() was not able to parse $string, use "now":
|
||||
return time();
|
||||
}
|
||||
return $time;
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty shared plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsShared
|
||||
*/
|
||||
if (!function_exists('smarty_mb_str_replace')) {
|
||||
/**
|
||||
* Multibyte string replace
|
||||
*
|
||||
* @param string|string[] $search the string to be searched
|
||||
* @param string|string[] $replace the replacement string
|
||||
* @param string $subject the source string
|
||||
* @param int &$count number of matches found
|
||||
*
|
||||
* @return string replaced string
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
function smarty_mb_str_replace($search, $replace, $subject, &$count = 0)
|
||||
{
|
||||
if (!is_array($search) && is_array($replace)) {
|
||||
return false;
|
||||
}
|
||||
if (is_array($subject)) {
|
||||
// call mb_replace for each single string in $subject
|
||||
foreach ($subject as &$string) {
|
||||
$string = smarty_mb_str_replace($search, $replace, $string, $c);
|
||||
$count += $c;
|
||||
}
|
||||
} elseif (is_array($search)) {
|
||||
if (!is_array($replace)) {
|
||||
foreach ($search as &$string) {
|
||||
$subject = smarty_mb_str_replace($string, $replace, $subject, $c);
|
||||
$count += $c;
|
||||
}
|
||||
} else {
|
||||
$n = max(count($search), count($replace));
|
||||
while ($n--) {
|
||||
$subject = smarty_mb_str_replace(current($search), current($replace), $subject, $c);
|
||||
$count += $c;
|
||||
next($search);
|
||||
next($replace);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$parts = mb_split(preg_quote($search), $subject);
|
||||
$count = count($parts) - 1;
|
||||
$subject = implode($replace, $parts);
|
||||
}
|
||||
return $subject;
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty shared plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsShared
|
||||
*/
|
||||
/**
|
||||
* convert characters to their decimal unicode equivalents
|
||||
*
|
||||
* @link http://www.ibm.com/developerworks/library/os-php-unicode/index.html#listing3 for inspiration
|
||||
*
|
||||
* @param string $string characters to calculate unicode of
|
||||
* @param string $encoding encoding of $string, if null mb_internal_encoding() is used
|
||||
*
|
||||
* @return array sequence of unicodes
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
function smarty_mb_to_unicode($string, $encoding = null)
|
||||
{
|
||||
if ($encoding) {
|
||||
$expanded = mb_convert_encoding($string, 'UTF-32BE', $encoding);
|
||||
} else {
|
||||
$expanded = mb_convert_encoding($string, 'UTF-32BE');
|
||||
}
|
||||
return unpack('N*', $expanded);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert unicodes to the character of given encoding
|
||||
*
|
||||
* @link http://www.ibm.com/developerworks/library/os-php-unicode/index.html#listing3 for inspiration
|
||||
*
|
||||
* @param integer|array $unicode single unicode or list of unicodes to convert
|
||||
* @param string $encoding encoding of returned string, if null mb_internal_encoding() is used
|
||||
*
|
||||
* @return string unicode as character sequence in given $encoding
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
function smarty_mb_from_unicode($unicode, $encoding = null)
|
||||
{
|
||||
$t = '';
|
||||
if (!$encoding) {
|
||||
$encoding = mb_internal_encoding();
|
||||
}
|
||||
foreach ((array)$unicode as $utf32be) {
|
||||
$character = pack('N*', $utf32be);
|
||||
$t .= mb_convert_encoding($character, $encoding, 'UTF-32BE');
|
||||
}
|
||||
return $t;
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFilter
|
||||
*/
|
||||
/**
|
||||
* Smarty htmlspecialchars variablefilter plugin
|
||||
*
|
||||
* @param string $source input string
|
||||
* @param \Smarty_Internal_Template $template
|
||||
*
|
||||
* @return string filtered output
|
||||
*/
|
||||
function smarty_variablefilter_htmlspecialchars($source, Smarty_Internal_Template $template)
|
||||
{
|
||||
return htmlspecialchars($source, ENT_QUOTES, Smarty::$_CHARSET);
|
||||
}
|
|
@ -1,219 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Cacher
|
||||
*/
|
||||
|
||||
/**
|
||||
* Cache Handler API
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Cacher
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
abstract class Smarty_CacheResource
|
||||
{
|
||||
/**
|
||||
* resource types provided by the core
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $sysplugins = array('file' => 'smarty_internal_cacheresource_file.php',);
|
||||
|
||||
/**
|
||||
* populate Cached Object with meta data from Resource
|
||||
*
|
||||
* @param \Smarty_Template_Cached $cached cached object
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract public function populate(\Smarty_Template_Cached $cached, Smarty_Internal_Template $_template);
|
||||
|
||||
/**
|
||||
* populate Cached Object with timestamp and exists from Resource
|
||||
*
|
||||
* @param Smarty_Template_Cached $cached
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract public function populateTimestamp(Smarty_Template_Cached $cached);
|
||||
|
||||
/**
|
||||
* Read the cached template and process header
|
||||
*
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
* @param boolean $update flag if called because cache update
|
||||
*
|
||||
* @return boolean true or false if the cached content does not exist
|
||||
*/
|
||||
abstract public function process(
|
||||
Smarty_Internal_Template $_template,
|
||||
Smarty_Template_Cached $cached = null,
|
||||
$update = false
|
||||
);
|
||||
|
||||
/**
|
||||
* Write the rendered template output to cache
|
||||
*
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
* @param string $content content to cache
|
||||
*
|
||||
* @return boolean success
|
||||
*/
|
||||
abstract public function writeCachedContent(Smarty_Internal_Template $_template, $content);
|
||||
|
||||
/**
|
||||
* Read cached template from cache
|
||||
*
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
*
|
||||
* @return string content
|
||||
*/
|
||||
abstract public function readCachedContent(Smarty_Internal_Template $_template);
|
||||
|
||||
/**
|
||||
* Return cached content
|
||||
*
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function getCachedContent(Smarty_Internal_Template $_template)
|
||||
{
|
||||
if ($_template->cached->handler->process($_template)) {
|
||||
ob_start();
|
||||
$unifunc = $_template->cached->unifunc;
|
||||
$unifunc($_template);
|
||||
return ob_get_clean();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty cache
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
||||
*
|
||||
* @return integer number of cache files deleted
|
||||
*/
|
||||
abstract public function clearAll(Smarty $smarty, $exp_time = null);
|
||||
|
||||
/**
|
||||
* Empty cache for a specific template
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param string $resource_name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
||||
*
|
||||
* @return integer number of cache files deleted
|
||||
*/
|
||||
abstract public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time);
|
||||
|
||||
/**
|
||||
* @param Smarty $smarty
|
||||
* @param Smarty_Template_Cached $cached
|
||||
*
|
||||
* @return bool|null
|
||||
*/
|
||||
public function locked(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
// theoretically locking_timeout should be checked against time_limit (max_execution_time)
|
||||
$start = microtime(true);
|
||||
$hadLock = null;
|
||||
while ($this->hasLock($smarty, $cached)) {
|
||||
$hadLock = true;
|
||||
if (microtime(true) - $start > $smarty->locking_timeout) {
|
||||
// abort waiting for lock release
|
||||
return false;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
return $hadLock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check is cache is locked for this template
|
||||
*
|
||||
* @param Smarty $smarty
|
||||
* @param Smarty_Template_Cached $cached
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
// check if lock exists
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock cache for this template
|
||||
*
|
||||
* @param Smarty $smarty
|
||||
* @param Smarty_Template_Cached $cached
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function acquireLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
// create lock
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock cache for this template
|
||||
*
|
||||
* @param Smarty $smarty
|
||||
* @param Smarty_Template_Cached $cached
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function releaseLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
// release lock
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Cache Resource Handler
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param string $type name of the cache resource
|
||||
*
|
||||
* @throws SmartyException
|
||||
* @return Smarty_CacheResource Cache Resource Handler
|
||||
*/
|
||||
public static function load(Smarty $smarty, $type = null)
|
||||
{
|
||||
if (!isset($type)) {
|
||||
$type = $smarty->caching_type;
|
||||
}
|
||||
// try smarty's cache
|
||||
if (isset($smarty->_cache[ 'cacheresource_handlers' ][ $type ])) {
|
||||
return $smarty->_cache[ 'cacheresource_handlers' ][ $type ];
|
||||
}
|
||||
// try registered resource
|
||||
if (isset($smarty->registered_cache_resources[ $type ])) {
|
||||
// do not cache these instances as they may vary from instance to instance
|
||||
return $smarty->_cache[ 'cacheresource_handlers' ][ $type ] = $smarty->registered_cache_resources[ $type ];
|
||||
}
|
||||
// try sysplugins dir
|
||||
if (isset(self::$sysplugins[ $type ])) {
|
||||
$cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
|
||||
return $smarty->_cache[ 'cacheresource_handlers' ][ $type ] = new $cache_resource_class();
|
||||
}
|
||||
// try plugins dir
|
||||
$cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type);
|
||||
if ($smarty->loadPlugin($cache_resource_class)) {
|
||||
return $smarty->_cache[ 'cacheresource_handlers' ][ $type ] = new $cache_resource_class();
|
||||
}
|
||||
// give up
|
||||
throw new SmartyException("Unable to load cache resource '{$type}'");
|
||||
}
|
||||
}
|
|
@ -1,297 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Cacher
|
||||
*/
|
||||
|
||||
/**
|
||||
* Cache Handler API
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Cacher
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
{
|
||||
/**
|
||||
* fetch cached content and its modification time from data source
|
||||
*
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param string $content cached content
|
||||
* @param integer $mtime cache modification timestamp (epoch)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime);
|
||||
|
||||
/**
|
||||
* Fetch cached content's modification timestamp from data source
|
||||
* {@internal implementing this method is optional.
|
||||
* Only implement it if modification times can be accessed faster than loading the complete cached content.}}
|
||||
*
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
*
|
||||
* @return integer|boolean timestamp (epoch) the template was modified, or false if not found
|
||||
*/
|
||||
protected function fetchTimestamp($id, $name, $cache_id, $compile_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save content to cache
|
||||
*
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param integer|null $exp_time seconds till expiration or null
|
||||
* @param string $content content to cache
|
||||
*
|
||||
* @return boolean success
|
||||
*/
|
||||
abstract protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content);
|
||||
|
||||
/**
|
||||
* Delete content from cache
|
||||
*
|
||||
* @param string|null $name template name
|
||||
* @param string|null $cache_id cache id
|
||||
* @param string|null $compile_id compile id
|
||||
* @param integer|null $exp_time seconds till expiration time in seconds or null
|
||||
*
|
||||
* @return integer number of deleted caches
|
||||
*/
|
||||
abstract protected function delete($name, $cache_id, $compile_id, $exp_time);
|
||||
|
||||
/**
|
||||
* populate Cached Object with meta data from Resource
|
||||
*
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template)
|
||||
{
|
||||
$_cache_id = isset($cached->cache_id) ? preg_replace('![^\w\|]+!', '_', $cached->cache_id) : null;
|
||||
$_compile_id = isset($cached->compile_id) ? preg_replace('![^\w]+!', '_', $cached->compile_id) : null;
|
||||
$path = $cached->source->uid . $_cache_id . $_compile_id;
|
||||
$cached->filepath = sha1($path);
|
||||
if ($_template->smarty->cache_locking) {
|
||||
$cached->lock_id = sha1('lock.' . $path);
|
||||
}
|
||||
$this->populateTimestamp($cached);
|
||||
}
|
||||
|
||||
/**
|
||||
* populate Cached Object with timestamp and exists from Resource
|
||||
*
|
||||
* @param Smarty_Template_Cached $cached
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function populateTimestamp(Smarty_Template_Cached $cached)
|
||||
{
|
||||
$mtime =
|
||||
$this->fetchTimestamp($cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id);
|
||||
if ($mtime !== null) {
|
||||
$cached->timestamp = $mtime;
|
||||
$cached->exists = !!$cached->timestamp;
|
||||
return;
|
||||
}
|
||||
$timestamp = null;
|
||||
$this->fetch(
|
||||
$cached->filepath,
|
||||
$cached->source->name,
|
||||
$cached->cache_id,
|
||||
$cached->compile_id,
|
||||
$cached->content,
|
||||
$timestamp
|
||||
);
|
||||
$cached->timestamp = isset($timestamp) ? $timestamp : false;
|
||||
$cached->exists = !!$cached->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the cached template and process the header
|
||||
*
|
||||
* @param \Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
* @param boolean $update flag if called because cache update
|
||||
*
|
||||
* @return boolean true or false if the cached content does not exist
|
||||
*/
|
||||
public function process(
|
||||
Smarty_Internal_Template $_smarty_tpl,
|
||||
Smarty_Template_Cached $cached = null,
|
||||
$update = false
|
||||
) {
|
||||
if (!$cached) {
|
||||
$cached = $_smarty_tpl->cached;
|
||||
}
|
||||
$content = $cached->content ? $cached->content : null;
|
||||
$timestamp = $cached->timestamp ? $cached->timestamp : null;
|
||||
if ($content === null || !$timestamp) {
|
||||
$this->fetch(
|
||||
$_smarty_tpl->cached->filepath,
|
||||
$_smarty_tpl->source->name,
|
||||
$_smarty_tpl->cache_id,
|
||||
$_smarty_tpl->compile_id,
|
||||
$content,
|
||||
$timestamp
|
||||
);
|
||||
}
|
||||
if (isset($content)) {
|
||||
eval('?>' . $content);
|
||||
$cached->content = null;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the rendered template output to cache
|
||||
*
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
* @param string $content content to cache
|
||||
*
|
||||
* @return boolean success
|
||||
*/
|
||||
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
||||
{
|
||||
return $this->save(
|
||||
$_template->cached->filepath,
|
||||
$_template->source->name,
|
||||
$_template->cache_id,
|
||||
$_template->compile_id,
|
||||
$_template->cache_lifetime,
|
||||
$content
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read cached template from cache
|
||||
*
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
*
|
||||
* @return string|boolean content
|
||||
*/
|
||||
public function readCachedContent(Smarty_Internal_Template $_template)
|
||||
{
|
||||
$content = $_template->cached->content ? $_template->cached->content : null;
|
||||
$timestamp = null;
|
||||
if ($content === null) {
|
||||
$timestamp = null;
|
||||
$this->fetch(
|
||||
$_template->cached->filepath,
|
||||
$_template->source->name,
|
||||
$_template->cache_id,
|
||||
$_template->compile_id,
|
||||
$content,
|
||||
$timestamp
|
||||
);
|
||||
}
|
||||
if (isset($content)) {
|
||||
return $content;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty cache
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
||||
*
|
||||
* @return integer number of cache files deleted
|
||||
*/
|
||||
public function clearAll(Smarty $smarty, $exp_time = null)
|
||||
{
|
||||
return $this->delete(null, null, null, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty cache for a specific template
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param string $resource_name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
||||
*
|
||||
* @return int number of cache files deleted
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
|
||||
{
|
||||
$cache_name = null;
|
||||
if (isset($resource_name)) {
|
||||
$source = Smarty_Template_Source::load(null, $smarty, $resource_name);
|
||||
if ($source->exists) {
|
||||
$cache_name = $source->name;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return $this->delete($cache_name, $cache_id, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check is cache is locked for this template
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
*
|
||||
* @return boolean true or false if cache is locked
|
||||
*/
|
||||
public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
$id = $cached->lock_id;
|
||||
$name = $cached->source->name . '.lock';
|
||||
$mtime = $this->fetchTimestamp($id, $name, $cached->cache_id, $cached->compile_id);
|
||||
if ($mtime === null) {
|
||||
$this->fetch($id, $name, $cached->cache_id, $cached->compile_id, $content, $mtime);
|
||||
}
|
||||
return $mtime && ($t = time()) - $mtime < $smarty->locking_timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock cache for this template
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
*
|
||||
* @return bool|void
|
||||
*/
|
||||
public function acquireLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
$cached->is_locked = true;
|
||||
$id = $cached->lock_id;
|
||||
$name = $cached->source->name . '.lock';
|
||||
$this->save($id, $name, $cached->cache_id, $cached->compile_id, $smarty->locking_timeout, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock cache for this template
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
*
|
||||
* @return bool|void
|
||||
*/
|
||||
public function releaseLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
$cached->is_locked = false;
|
||||
$name = $cached->source->name . '.lock';
|
||||
$this->delete($name, $cached->cache_id, $cached->compile_id, null);
|
||||
}
|
||||
}
|
|
@ -1,538 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Cacher
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Cache Handler Base for Key/Value Storage Implementations
|
||||
* This class implements the functionality required to use simple key/value stores
|
||||
* for hierarchical cache groups. key/value stores like memcache or APC do not support
|
||||
* wildcards in keys, therefore a cache group cannot be cleared like "a|*" - which
|
||||
* is no problem to filesystem and RDBMS implementations.
|
||||
* This implementation is based on the concept of invalidation. While one specific cache
|
||||
* can be identified and cleared, any range of caches cannot be identified. For this reason
|
||||
* each level of the cache group hierarchy can have its own value in the store. These values
|
||||
* are nothing but microtimes, telling us when a particular cache group was cleared for the
|
||||
* last time. These keys are evaluated for every cache read to determine if the cache has
|
||||
* been invalidated since it was created and should hence be treated as inexistent.
|
||||
* Although deep hierarchies are possible, they are not recommended. Try to keep your
|
||||
* cache groups as shallow as possible. Anything up 3-5 parents should be ok. So
|
||||
* »a|b|c« is a good depth where »a|b|c|d|e|f|g|h|i|j|k« isn't. Try to join correlating
|
||||
* cache groups: if your cache groups look somewhat like »a|b|$page|$items|$whatever«
|
||||
* consider using »a|b|c|$page-$items-$whatever« instead.
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Cacher
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
{
|
||||
/**
|
||||
* cache for contents
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $contents = array();
|
||||
|
||||
/**
|
||||
* cache for timestamps
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $timestamps = array();
|
||||
|
||||
/**
|
||||
* populate Cached Object with meta data from Resource
|
||||
*
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template)
|
||||
{
|
||||
$cached->filepath = $_template->source->uid . '#' . $this->sanitize($cached->source->resource) . '#' .
|
||||
$this->sanitize($cached->cache_id) . '#' . $this->sanitize($cached->compile_id);
|
||||
$this->populateTimestamp($cached);
|
||||
}
|
||||
|
||||
/**
|
||||
* populate Cached Object with timestamp and exists from Resource
|
||||
*
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function populateTimestamp(Smarty_Template_Cached $cached)
|
||||
{
|
||||
if (!$this->fetch(
|
||||
$cached->filepath,
|
||||
$cached->source->name,
|
||||
$cached->cache_id,
|
||||
$cached->compile_id,
|
||||
$content,
|
||||
$timestamp,
|
||||
$cached->source->uid
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
$cached->content = $content;
|
||||
$cached->timestamp = (int)$timestamp;
|
||||
$cached->exists = !!$cached->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the cached template and process the header
|
||||
*
|
||||
* @param \Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
* @param boolean $update flag if called because cache update
|
||||
*
|
||||
* @return boolean true or false if the cached content does not exist
|
||||
*/
|
||||
public function process(
|
||||
Smarty_Internal_Template $_smarty_tpl,
|
||||
Smarty_Template_Cached $cached = null,
|
||||
$update = false
|
||||
) {
|
||||
if (!$cached) {
|
||||
$cached = $_smarty_tpl->cached;
|
||||
}
|
||||
$content = $cached->content ? $cached->content : null;
|
||||
$timestamp = $cached->timestamp ? $cached->timestamp : null;
|
||||
if ($content === null || !$timestamp) {
|
||||
if (!$this->fetch(
|
||||
$_smarty_tpl->cached->filepath,
|
||||
$_smarty_tpl->source->name,
|
||||
$_smarty_tpl->cache_id,
|
||||
$_smarty_tpl->compile_id,
|
||||
$content,
|
||||
$timestamp,
|
||||
$_smarty_tpl->source->uid
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (isset($content)) {
|
||||
eval('?>' . $content);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the rendered template output to cache
|
||||
*
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
* @param string $content content to cache
|
||||
*
|
||||
* @return boolean success
|
||||
*/
|
||||
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
||||
{
|
||||
$this->addMetaTimestamp($content);
|
||||
return $this->write(array($_template->cached->filepath => $content), $_template->cache_lifetime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read cached template from cache
|
||||
*
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
*
|
||||
* @return string|false content
|
||||
*/
|
||||
public function readCachedContent(Smarty_Internal_Template $_template)
|
||||
{
|
||||
$content = $_template->cached->content ? $_template->cached->content : null;
|
||||
$timestamp = null;
|
||||
if ($content === null) {
|
||||
if (!$this->fetch(
|
||||
$_template->cached->filepath,
|
||||
$_template->source->name,
|
||||
$_template->cache_id,
|
||||
$_template->compile_id,
|
||||
$content,
|
||||
$timestamp,
|
||||
$_template->source->uid
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (isset($content)) {
|
||||
return $content;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty cache
|
||||
* {@internal the $exp_time argument is ignored altogether }}
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param integer $exp_time expiration time [being ignored]
|
||||
*
|
||||
* @return integer number of cache files deleted [always -1]
|
||||
* @uses purge() to clear the whole store
|
||||
* @uses invalidate() to mark everything outdated if purge() is inapplicable
|
||||
*/
|
||||
public function clearAll(Smarty $smarty, $exp_time = null)
|
||||
{
|
||||
if (!$this->purge()) {
|
||||
$this->invalidate(null);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty cache for a specific template
|
||||
* {@internal the $exp_time argument is ignored altogether}}
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param string $resource_name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param integer $exp_time expiration time [being ignored]
|
||||
*
|
||||
* @return int number of cache files deleted [always -1]
|
||||
* @throws \SmartyException
|
||||
* @uses buildCachedFilepath() to generate the CacheID
|
||||
* @uses invalidate() to mark CacheIDs parent chain as outdated
|
||||
* @uses delete() to remove CacheID from cache
|
||||
*/
|
||||
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
|
||||
{
|
||||
$uid = $this->getTemplateUid($smarty, $resource_name);
|
||||
$cid = $uid . '#' . $this->sanitize($resource_name) . '#' . $this->sanitize($cache_id) . '#' .
|
||||
$this->sanitize($compile_id);
|
||||
$this->delete(array($cid));
|
||||
$this->invalidate($cid, $resource_name, $cache_id, $compile_id, $uid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template's unique ID
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param string $resource_name template name
|
||||
*
|
||||
* @return string filepath of cache file
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
protected function getTemplateUid(Smarty $smarty, $resource_name)
|
||||
{
|
||||
if (isset($resource_name)) {
|
||||
$source = Smarty_Template_Source::load(null, $smarty, $resource_name);
|
||||
if ($source->exists) {
|
||||
return $source->uid;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize CacheID components
|
||||
*
|
||||
* @param string $string CacheID component to sanitize
|
||||
*
|
||||
* @return string sanitized CacheID component
|
||||
*/
|
||||
protected function sanitize($string)
|
||||
{
|
||||
$string = trim($string, '|');
|
||||
if (!$string) {
|
||||
return '';
|
||||
}
|
||||
return preg_replace('#[^\w\|]+#S', '_', $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch and prepare a cache object.
|
||||
*
|
||||
* @param string $cid CacheID to fetch
|
||||
* @param string $resource_name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param string $content cached content
|
||||
* @param integer &$timestamp cached timestamp (epoch)
|
||||
* @param string $resource_uid resource's uid
|
||||
*
|
||||
* @return boolean success
|
||||
*/
|
||||
protected function fetch(
|
||||
$cid,
|
||||
$resource_name = null,
|
||||
$cache_id = null,
|
||||
$compile_id = null,
|
||||
&$content = null,
|
||||
&$timestamp = null,
|
||||
$resource_uid = null
|
||||
) {
|
||||
$t = $this->read(array($cid));
|
||||
$content = !empty($t[ $cid ]) ? $t[ $cid ] : null;
|
||||
$timestamp = null;
|
||||
if ($content && ($timestamp = $this->getMetaTimestamp($content))) {
|
||||
$invalidated =
|
||||
$this->getLatestInvalidationTimestamp($cid, $resource_name, $cache_id, $compile_id, $resource_uid);
|
||||
if ($invalidated > $timestamp) {
|
||||
$timestamp = null;
|
||||
$content = null;
|
||||
}
|
||||
}
|
||||
return !!$content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add current microtime to the beginning of $cache_content
|
||||
* {@internal the header uses 8 Bytes, the first 4 Bytes are the seconds, the second 4 Bytes are the microseconds}}
|
||||
*
|
||||
* @param string &$content the content to be cached
|
||||
*/
|
||||
protected function addMetaTimestamp(&$content)
|
||||
{
|
||||
$mt = explode(' ', microtime());
|
||||
$ts = pack('NN', $mt[ 1 ], (int)($mt[ 0 ] * 100000000));
|
||||
$content = $ts . $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the timestamp the $content was cached
|
||||
*
|
||||
* @param string &$content the cached content
|
||||
*
|
||||
* @return float the microtime the content was cached
|
||||
*/
|
||||
protected function getMetaTimestamp(&$content)
|
||||
{
|
||||
extract(unpack('N1s/N1m/a*content', $content));
|
||||
/**
|
||||
* @var int $s
|
||||
* @var int $m
|
||||
*/
|
||||
return $s + ($m / 100000000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate CacheID
|
||||
*
|
||||
* @param string $cid CacheID
|
||||
* @param string $resource_name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param string $resource_uid source's uid
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function invalidate(
|
||||
$cid = null,
|
||||
$resource_name = null,
|
||||
$cache_id = null,
|
||||
$compile_id = null,
|
||||
$resource_uid = null
|
||||
) {
|
||||
$now = microtime(true);
|
||||
$key = null;
|
||||
// invalidate everything
|
||||
if (!$resource_name && !$cache_id && !$compile_id) {
|
||||
$key = 'IVK#ALL';
|
||||
} // invalidate all caches by template
|
||||
else {
|
||||
if ($resource_name && !$cache_id && !$compile_id) {
|
||||
$key = 'IVK#TEMPLATE#' . $resource_uid . '#' . $this->sanitize($resource_name);
|
||||
} // invalidate all caches by cache group
|
||||
else {
|
||||
if (!$resource_name && $cache_id && !$compile_id) {
|
||||
$key = 'IVK#CACHE#' . $this->sanitize($cache_id);
|
||||
} // invalidate all caches by compile id
|
||||
else {
|
||||
if (!$resource_name && !$cache_id && $compile_id) {
|
||||
$key = 'IVK#COMPILE#' . $this->sanitize($compile_id);
|
||||
} // invalidate by combination
|
||||
else {
|
||||
$key = 'IVK#CID#' . $cid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->write(array($key => $now));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the latest timestamp known to the invalidation chain
|
||||
*
|
||||
* @param string $cid CacheID to determine latest invalidation timestamp of
|
||||
* @param string $resource_name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param string $resource_uid source's filepath
|
||||
*
|
||||
* @return float the microtime the CacheID was invalidated
|
||||
*/
|
||||
protected function getLatestInvalidationTimestamp(
|
||||
$cid,
|
||||
$resource_name = null,
|
||||
$cache_id = null,
|
||||
$compile_id = null,
|
||||
$resource_uid = null
|
||||
) {
|
||||
// abort if there is no CacheID
|
||||
if (false && !$cid) {
|
||||
return 0;
|
||||
}
|
||||
// abort if there are no InvalidationKeys to check
|
||||
if (!($_cid = $this->listInvalidationKeys($cid, $resource_name, $cache_id, $compile_id, $resource_uid))) {
|
||||
return 0;
|
||||
}
|
||||
// there are no InValidationKeys
|
||||
if (!($values = $this->read($_cid))) {
|
||||
return 0;
|
||||
}
|
||||
// make sure we're dealing with floats
|
||||
$values = array_map('floatval', $values);
|
||||
return max($values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate a CacheID into the list of applicable InvalidationKeys.
|
||||
* Splits 'some|chain|into|an|array' into array( '#clearAll#', 'some', 'some|chain', 'some|chain|into', ... )
|
||||
*
|
||||
* @param string $cid CacheID to translate
|
||||
* @param string $resource_name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param string $resource_uid source's filepath
|
||||
*
|
||||
* @return array list of InvalidationKeys
|
||||
* @uses $invalidationKeyPrefix to prepend to each InvalidationKey
|
||||
*/
|
||||
protected function listInvalidationKeys(
|
||||
$cid,
|
||||
$resource_name = null,
|
||||
$cache_id = null,
|
||||
$compile_id = null,
|
||||
$resource_uid = null
|
||||
) {
|
||||
$t = array('IVK#ALL');
|
||||
$_name = $_compile = '#';
|
||||
if ($resource_name) {
|
||||
$_name .= $resource_uid . '#' . $this->sanitize($resource_name);
|
||||
$t[] = 'IVK#TEMPLATE' . $_name;
|
||||
}
|
||||
if ($compile_id) {
|
||||
$_compile .= $this->sanitize($compile_id);
|
||||
$t[] = 'IVK#COMPILE' . $_compile;
|
||||
}
|
||||
$_name .= '#';
|
||||
$cid = trim($cache_id, '|');
|
||||
if (!$cid) {
|
||||
return $t;
|
||||
}
|
||||
$i = 0;
|
||||
while (true) {
|
||||
// determine next delimiter position
|
||||
$i = strpos($cid, '|', $i);
|
||||
// add complete CacheID if there are no more delimiters
|
||||
if ($i === false) {
|
||||
$t[] = 'IVK#CACHE#' . $cid;
|
||||
$t[] = 'IVK#CID' . $_name . $cid . $_compile;
|
||||
$t[] = 'IVK#CID' . $_name . $_compile;
|
||||
break;
|
||||
}
|
||||
$part = substr($cid, 0, $i);
|
||||
// add slice to list
|
||||
$t[] = 'IVK#CACHE#' . $part;
|
||||
$t[] = 'IVK#CID' . $_name . $part . $_compile;
|
||||
// skip past delimiter position
|
||||
$i++;
|
||||
}
|
||||
return $t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check is cache is locked for this template
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
*
|
||||
* @return boolean true or false if cache is locked
|
||||
*/
|
||||
public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
$key = 'LOCK#' . $cached->filepath;
|
||||
$data = $this->read(array($key));
|
||||
return $data && time() - $data[ $key ] < $smarty->locking_timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock cache for this template
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
*
|
||||
* @return bool|void
|
||||
*/
|
||||
public function acquireLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
$cached->is_locked = true;
|
||||
$key = 'LOCK#' . $cached->filepath;
|
||||
$this->write(array($key => time()), $smarty->locking_timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock cache for this template
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
*
|
||||
* @return bool|void
|
||||
*/
|
||||
public function releaseLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
$cached->is_locked = false;
|
||||
$key = 'LOCK#' . $cached->filepath;
|
||||
$this->delete(array($key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read values for a set of keys from cache
|
||||
*
|
||||
* @param array $keys list of keys to fetch
|
||||
*
|
||||
* @return array list of values with the given keys used as indexes
|
||||
*/
|
||||
abstract protected function read(array $keys);
|
||||
|
||||
/**
|
||||
* Save values for a set of keys to cache
|
||||
*
|
||||
* @param array $keys list of values to save
|
||||
* @param int $expire expiration time
|
||||
*
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
abstract protected function write(array $keys, $expire = null);
|
||||
|
||||
/**
|
||||
* Remove values from cache
|
||||
*
|
||||
* @param array $keys list of keys to delete
|
||||
*
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
abstract protected function delete(array $keys);
|
||||
|
||||
/**
|
||||
* Remove *all* values from cache
|
||||
*
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function purge()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Plugin Data
|
||||
* This file contains the data object
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Template
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* class for the Smarty data object
|
||||
* The Smarty data object will hold Smarty variables in the current scope
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Template
|
||||
*/
|
||||
class Smarty_Data extends Smarty_Internal_Data
|
||||
{
|
||||
/**
|
||||
* Counter
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public static $count = 0;
|
||||
|
||||
/**
|
||||
* Data block name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $dataObjectName = '';
|
||||
|
||||
/**
|
||||
* Smarty object
|
||||
*
|
||||
* @var Smarty
|
||||
*/
|
||||
public $smarty = null;
|
||||
|
||||
/**
|
||||
* create Smarty data object
|
||||
*
|
||||
* @param Smarty|array $_parent parent template
|
||||
* @param Smarty|Smarty_Internal_Template $smarty global smarty instance
|
||||
* @param string $name optional data block name
|
||||
*
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public function __construct($_parent = null, $smarty = null, $name = null)
|
||||
{
|
||||
parent::__construct();
|
||||
self::$count++;
|
||||
$this->dataObjectName = 'Data_object ' . (isset($name) ? "'{$name}'" : self::$count);
|
||||
$this->smarty = $smarty;
|
||||
if (is_object($_parent)) {
|
||||
// when object set up back pointer
|
||||
$this->parent = $_parent;
|
||||
} elseif (is_array($_parent)) {
|
||||
// set up variable values
|
||||
foreach ($_parent as $_key => $_val) {
|
||||
$this->tpl_vars[ $_key ] = new Smarty_Variable($_val);
|
||||
}
|
||||
} elseif ($_parent !== null) {
|
||||
throw new SmartyException('Wrong type for template variables');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Smarty {block} tag class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_Internal_Block
|
||||
{
|
||||
/**
|
||||
* Block name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name = '';
|
||||
|
||||
/**
|
||||
* Hide attribute
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $hide = false;
|
||||
|
||||
/**
|
||||
* Append attribute
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $append = false;
|
||||
|
||||
/**
|
||||
* prepend attribute
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $prepend = false;
|
||||
|
||||
/**
|
||||
* Block calls $smarty.block.child
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $callsChild = false;
|
||||
|
||||
/**
|
||||
* Inheritance child block
|
||||
*
|
||||
* @var Smarty_Internal_Block|null
|
||||
*/
|
||||
public $child = null;
|
||||
|
||||
/**
|
||||
* Inheritance calling parent block
|
||||
*
|
||||
* @var Smarty_Internal_Block|null
|
||||
*/
|
||||
public $parent = null;
|
||||
|
||||
/**
|
||||
* Inheritance Template index
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tplIndex = 0;
|
||||
|
||||
/**
|
||||
* Smarty_Internal_Block constructor.
|
||||
* - if outer level {block} of child template ($state === 1) save it as child root block
|
||||
* - otherwise process inheritance and render
|
||||
*
|
||||
* @param string $name block name
|
||||
* @param int|null $tplIndex index of outer level {block} if nested
|
||||
*/
|
||||
public function __construct($name, $tplIndex)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->tplIndex = $tplIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiled block code overloaded by {block} class
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
*/
|
||||
public function callBlock(Smarty_Internal_Template $tpl)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,239 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin CacheResource File
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Cacher
|
||||
* @author Uwe Tews
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class does contain all necessary methods for the HTML cache on file system
|
||||
* Implements the file system as resource for the HTML cache Version ussing nocache inserts.
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Cacher
|
||||
*/
|
||||
class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
{
|
||||
/**
|
||||
* populate Cached Object with meta data from Resource
|
||||
*
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template)
|
||||
{
|
||||
$source = &$_template->source;
|
||||
$smarty = &$_template->smarty;
|
||||
$_compile_dir_sep = $smarty->use_sub_dirs ? DIRECTORY_SEPARATOR : '^';
|
||||
$_filepath = sha1($source->uid . $smarty->_joined_template_dir);
|
||||
$cached->filepath = $smarty->getCacheDir();
|
||||
if (isset($_template->cache_id)) {
|
||||
$cached->filepath .= preg_replace(
|
||||
array(
|
||||
'![^\w|]+!',
|
||||
'![|]+!'
|
||||
),
|
||||
array(
|
||||
'_',
|
||||
$_compile_dir_sep
|
||||
),
|
||||
$_template->cache_id
|
||||
) . $_compile_dir_sep;
|
||||
}
|
||||
if (isset($_template->compile_id)) {
|
||||
$cached->filepath .= preg_replace('![^\w]+!', '_', $_template->compile_id) . $_compile_dir_sep;
|
||||
}
|
||||
// if use_sub_dirs, break file into directories
|
||||
if ($smarty->use_sub_dirs) {
|
||||
$cached->filepath .= $_filepath[ 0 ] . $_filepath[ 1 ] . DIRECTORY_SEPARATOR . $_filepath[ 2 ] .
|
||||
$_filepath[ 3 ] .
|
||||
DIRECTORY_SEPARATOR .
|
||||
$_filepath[ 4 ] . $_filepath[ 5 ] . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
$cached->filepath .= $_filepath;
|
||||
$basename = $source->handler->getBasename($source);
|
||||
if (!empty($basename)) {
|
||||
$cached->filepath .= '.' . $basename;
|
||||
}
|
||||
if ($smarty->cache_locking) {
|
||||
$cached->lock_id = $cached->filepath . '.lock';
|
||||
}
|
||||
$cached->filepath .= '.php';
|
||||
$cached->timestamp = $cached->exists = is_file($cached->filepath);
|
||||
if ($cached->exists) {
|
||||
$cached->timestamp = filemtime($cached->filepath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* populate Cached Object with timestamp and exists from Resource
|
||||
*
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function populateTimestamp(Smarty_Template_Cached $cached)
|
||||
{
|
||||
$cached->timestamp = $cached->exists = is_file($cached->filepath);
|
||||
if ($cached->exists) {
|
||||
$cached->timestamp = filemtime($cached->filepath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the cached template and process its header
|
||||
*
|
||||
* @param \Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
* @param bool $update flag if called because cache update
|
||||
*
|
||||
* @return boolean true or false if the cached content does not exist
|
||||
*/
|
||||
public function process(
|
||||
Smarty_Internal_Template $_smarty_tpl,
|
||||
Smarty_Template_Cached $cached = null,
|
||||
$update = false
|
||||
) {
|
||||
$_smarty_tpl->cached->valid = false;
|
||||
if ($update && defined('HHVM_VERSION')) {
|
||||
eval('?>' . file_get_contents($_smarty_tpl->cached->filepath));
|
||||
return true;
|
||||
} else {
|
||||
return @include $_smarty_tpl->cached->filepath;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the rendered template output to cache
|
||||
*
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
* @param string $content content to cache
|
||||
*
|
||||
* @return bool success
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
||||
{
|
||||
if ($_template->smarty->ext->_writeFile->writeFile(
|
||||
$_template->cached->filepath,
|
||||
$content,
|
||||
$_template->smarty
|
||||
) === true
|
||||
) {
|
||||
if (function_exists('opcache_invalidate')
|
||||
&& (!function_exists('ini_get') || strlen(ini_get('opcache.restrict_api'))) < 1
|
||||
) {
|
||||
opcache_invalidate($_template->cached->filepath, true);
|
||||
} elseif (function_exists('apc_compile_file')) {
|
||||
apc_compile_file($_template->cached->filepath);
|
||||
}
|
||||
$cached = $_template->cached;
|
||||
$cached->timestamp = $cached->exists = is_file($cached->filepath);
|
||||
if ($cached->exists) {
|
||||
$cached->timestamp = filemtime($cached->filepath);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read cached template from cache
|
||||
*
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
*
|
||||
* @return string content
|
||||
*/
|
||||
public function readCachedContent(Smarty_Internal_Template $_template)
|
||||
{
|
||||
if (is_file($_template->cached->filepath)) {
|
||||
return file_get_contents($_template->cached->filepath);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty cache
|
||||
*
|
||||
* @param Smarty $smarty
|
||||
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
||||
*
|
||||
* @return integer number of cache files deleted
|
||||
*/
|
||||
public function clearAll(Smarty $smarty, $exp_time = null)
|
||||
{
|
||||
return $smarty->ext->_cacheResourceFile->clear($smarty, null, null, null, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty cache for a specific template
|
||||
*
|
||||
* @param Smarty $smarty
|
||||
* @param string $resource_name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
||||
*
|
||||
* @return integer number of cache files deleted
|
||||
*/
|
||||
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
|
||||
{
|
||||
return $smarty->ext->_cacheResourceFile->clear($smarty, $resource_name, $cache_id, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check is cache is locked for this template
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
*
|
||||
* @return boolean true or false if cache is locked
|
||||
*/
|
||||
public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
||||
clearstatcache(true, $cached->lock_id);
|
||||
} else {
|
||||
clearstatcache();
|
||||
}
|
||||
if (is_file($cached->lock_id)) {
|
||||
$t = filemtime($cached->lock_id);
|
||||
return $t && (time() - $t < $smarty->locking_timeout);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock cache for this template
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
*
|
||||
* @return bool|void
|
||||
*/
|
||||
public function acquireLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
$cached->is_locked = true;
|
||||
touch($cached->lock_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock cache for this template
|
||||
*
|
||||
* @param Smarty $smarty Smarty object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
*
|
||||
* @return bool|void
|
||||
*/
|
||||
public function releaseLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
$cached->is_locked = false;
|
||||
@unlink($cached->lock_id);
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Append
|
||||
* Compiles the {append} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Append Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Append extends Smarty_Internal_Compile_Assign
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {append} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
// the following must be assigned at runtime because it will be overwritten in parent class
|
||||
$this->required_attributes = array('var', 'value');
|
||||
$this->shorttag_order = array('var', 'value');
|
||||
$this->optional_attributes = array('scope', 'index');
|
||||
$this->mapCache = array();
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
// map to compile assign attributes
|
||||
if (isset($_attr[ 'index' ])) {
|
||||
$_params[ 'smarty_internal_index' ] = '[' . $_attr[ 'index' ] . ']';
|
||||
unset($_attr[ 'index' ]);
|
||||
} else {
|
||||
$_params[ 'smarty_internal_index' ] = '[]';
|
||||
}
|
||||
$_new_attr = array();
|
||||
foreach ($_attr as $key => $value) {
|
||||
$_new_attr[] = array($key => $value);
|
||||
}
|
||||
// call compile assign
|
||||
return parent::compile($_new_attr, $compiler, $_params);
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Assign
|
||||
* Compiles the {assign} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Assign Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $option_flags = array('nocache', 'noscope');
|
||||
|
||||
/**
|
||||
* Valid scope names
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $valid_scopes = array(
|
||||
'local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT,
|
||||
'root' => Smarty::SCOPE_ROOT, 'global' => Smarty::SCOPE_GLOBAL,
|
||||
'tpl_root' => Smarty::SCOPE_TPL_ROOT, 'smarty' => Smarty::SCOPE_SMARTY
|
||||
);
|
||||
|
||||
/**
|
||||
* Compiles code for the {assign} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
// the following must be assigned at runtime because it will be overwritten in Smarty_Internal_Compile_Append
|
||||
$this->required_attributes = array('var', 'value');
|
||||
$this->shorttag_order = array('var', 'value');
|
||||
$this->optional_attributes = array('scope');
|
||||
$this->mapCache = array();
|
||||
$_nocache = false;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
// nocache ?
|
||||
if ($_var = $compiler->getId($_attr[ 'var' ])) {
|
||||
$_var = "'{$_var}'";
|
||||
} else {
|
||||
$_var = $_attr[ 'var' ];
|
||||
}
|
||||
if ($compiler->tag_nocache || $compiler->nocache) {
|
||||
$_nocache = true;
|
||||
// create nocache var to make it know for further compiling
|
||||
$compiler->setNocacheInVariable($_attr[ 'var' ]);
|
||||
}
|
||||
// scope setup
|
||||
if ($_attr[ 'noscope' ]) {
|
||||
$_scope = -1;
|
||||
} else {
|
||||
$_scope = $compiler->convertScope($_attr, $this->valid_scopes);
|
||||
}
|
||||
// optional parameter
|
||||
$_params = '';
|
||||
if ($_nocache || $_scope) {
|
||||
$_params .= ' ,' . var_export($_nocache, true);
|
||||
}
|
||||
if ($_scope) {
|
||||
$_params .= ' ,' . $_scope;
|
||||
}
|
||||
if (isset($parameter[ 'smarty_internal_index' ])) {
|
||||
$output =
|
||||
"<?php \$_tmp_array = isset(\$_smarty_tpl->tpl_vars[{$_var}]) ? \$_smarty_tpl->tpl_vars[{$_var}]->value : array();\n";
|
||||
$output .= "if (!is_array(\$_tmp_array) || \$_tmp_array instanceof ArrayAccess) {\n";
|
||||
$output .= "settype(\$_tmp_array, 'array');\n";
|
||||
$output .= "}\n";
|
||||
$output .= "\$_tmp_array{$parameter['smarty_internal_index']} = {$_attr['value']};\n";
|
||||
$output .= "\$_smarty_tpl->_assignInScope({$_var}, \$_tmp_array{$_params});?>";
|
||||
} else {
|
||||
$output = "<?php \$_smarty_tpl->_assignInScope({$_var}, {$_attr['value']}{$_params});?>";
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
}
|
|
@ -1,189 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Smarty.
|
||||
*
|
||||
* (c) 2015 Uwe Tews
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Class
|
||||
*
|
||||
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||
*/
|
||||
class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inheritance
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('name');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('name');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $option_flags = array('hide', 'nocache');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('assign');
|
||||
|
||||
/**
|
||||
* Compiles code for the {block} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
if (!isset($compiler->_cache[ 'blockNesting' ])) {
|
||||
$compiler->_cache[ 'blockNesting' ] = 0;
|
||||
}
|
||||
if ($compiler->_cache[ 'blockNesting' ] === 0) {
|
||||
// make sure that inheritance gets initialized in template code
|
||||
$this->registerInit($compiler);
|
||||
$this->option_flags = array('hide', 'nocache', 'append', 'prepend');
|
||||
} else {
|
||||
$this->option_flags = array('hide', 'nocache');
|
||||
}
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
++$compiler->_cache[ 'blockNesting' ];
|
||||
$_className = 'Block_' . preg_replace('![^\w]+!', '_', uniqid(mt_rand(), true));
|
||||
$compiler->_cache[ 'blockName' ][ $compiler->_cache[ 'blockNesting' ] ] = $_attr[ 'name' ];
|
||||
$compiler->_cache[ 'blockClass' ][ $compiler->_cache[ 'blockNesting' ] ] = $_className;
|
||||
$compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ] = array();
|
||||
$compiler->_cache[ 'blockParams' ][ 1 ][ 'subBlocks' ][ trim($_attr[ 'name' ], '"\'') ][] = $_className;
|
||||
$this->openTag(
|
||||
$compiler,
|
||||
'block',
|
||||
array(
|
||||
$_attr, $compiler->nocache, $compiler->parser->current_buffer,
|
||||
$compiler->template->compiled->has_nocache_code,
|
||||
$compiler->template->caching
|
||||
)
|
||||
);
|
||||
$compiler->saveRequiredPlugins(true);
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
|
||||
$compiler->template->compiled->has_nocache_code = false;
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile BlockClose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_Inheritance
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {/block} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return bool true
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
list($_attr, $_nocache, $_buffer, $_has_nocache_code, $_caching) = $this->closeTag($compiler, array('block'));
|
||||
// init block parameter
|
||||
$_block = $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ];
|
||||
unset($compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ]);
|
||||
$_name = $_attr[ 'name' ];
|
||||
$_assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : null;
|
||||
unset($_attr[ 'assign' ], $_attr[ 'name' ]);
|
||||
foreach ($_attr as $name => $stat) {
|
||||
if ((is_bool($stat) && $stat !== false) || (!is_bool($stat) && $stat !== 'false')) {
|
||||
$_block[ $name ] = 'true';
|
||||
}
|
||||
}
|
||||
$_className = $compiler->_cache[ 'blockClass' ][ $compiler->_cache[ 'blockNesting' ] ];
|
||||
// get compiled block code
|
||||
$_functionCode = $compiler->parser->current_buffer;
|
||||
// setup buffer for template function code
|
||||
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
|
||||
$output = "<?php\n";
|
||||
$output .= "/* {block {$_name}} */\n";
|
||||
$output .= "class {$_className} extends Smarty_Internal_Block\n";
|
||||
$output .= "{\n";
|
||||
foreach ($_block as $property => $value) {
|
||||
$output .= "public \${$property} = " . var_export($value, true) . ";\n";
|
||||
}
|
||||
$output .= "public function callBlock(Smarty_Internal_Template \$_smarty_tpl) {\n";
|
||||
$output .= $compiler->compileRequiredPlugins();
|
||||
$compiler->restoreRequiredPlugins();
|
||||
if ($compiler->template->compiled->has_nocache_code) {
|
||||
$output .= "\$_smarty_tpl->cached->hashes['{$compiler->template->compiled->nocache_hash}'] = true;\n";
|
||||
}
|
||||
if (isset($_assign)) {
|
||||
$output .= "ob_start();\n";
|
||||
}
|
||||
$output .= "?>\n";
|
||||
$compiler->parser->current_buffer->append_subtree(
|
||||
$compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Tag(
|
||||
$compiler->parser,
|
||||
$output
|
||||
)
|
||||
);
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
||||
$output = "<?php\n";
|
||||
if (isset($_assign)) {
|
||||
$output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n";
|
||||
}
|
||||
$output .= "}\n";
|
||||
$output .= "}\n";
|
||||
$output .= "/* {/block {$_name}} */\n\n";
|
||||
$output .= "?>\n";
|
||||
$compiler->parser->current_buffer->append_subtree(
|
||||
$compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Tag(
|
||||
$compiler->parser,
|
||||
$output
|
||||
)
|
||||
);
|
||||
$compiler->blockOrFunctionCode .= $compiler->parser->current_buffer->to_smarty_php($compiler->parser);
|
||||
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
|
||||
// restore old status
|
||||
$compiler->template->compiled->has_nocache_code = $_has_nocache_code;
|
||||
$compiler->tag_nocache = $compiler->nocache;
|
||||
$compiler->nocache = $_nocache;
|
||||
$compiler->parser->current_buffer = $_buffer;
|
||||
$output = "<?php \n";
|
||||
if ($compiler->_cache[ 'blockNesting' ] === 1) {
|
||||
$output .= "\$_smarty_tpl->inheritance->instanceBlock(\$_smarty_tpl, '$_className', $_name);\n";
|
||||
} else {
|
||||
$output .= "\$_smarty_tpl->inheritance->instanceBlock(\$_smarty_tpl, '$_className', $_name, \$this->tplIndex);\n";
|
||||
}
|
||||
$output .= "?>\n";
|
||||
--$compiler->_cache[ 'blockNesting' ];
|
||||
if ($compiler->_cache[ 'blockNesting' ] === 0) {
|
||||
unset($compiler->_cache[ 'blockNesting' ]);
|
||||
}
|
||||
$compiler->has_code = true;
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
return $output;
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Smarty.
|
||||
*
|
||||
* (c) 2015 Uwe Tews
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Child Class
|
||||
*
|
||||
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||
*/
|
||||
class Smarty_Internal_Compile_Block_Child extends Smarty_Internal_Compile_Child
|
||||
{
|
||||
/**
|
||||
* Tag name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $tag = 'block_child';
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Smarty.
|
||||
*
|
||||
* (c) 2015 Uwe Tews
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Parent Class
|
||||
*
|
||||
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||
*/
|
||||
class Smarty_Internal_Compile_Block_Parent extends Smarty_Internal_Compile_Child
|
||||
{
|
||||
/**
|
||||
* Tag name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $tag = 'block_parent';
|
||||
|
||||
/**
|
||||
* Block type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $blockType = 'Parent';
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Break
|
||||
* Compiles the {break} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Break Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('levels');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('levels');
|
||||
|
||||
/**
|
||||
* Tag name may be overloaded by Smarty_Internal_Compile_Continue
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $tag = 'break';
|
||||
|
||||
/**
|
||||
* Compiles code for the {break} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
list($levels, $foreachLevels) = $this->checkLevels($args, $compiler);
|
||||
$output = "<?php ";
|
||||
if ($foreachLevels > 0 && $this->tag === 'continue') {
|
||||
$foreachLevels--;
|
||||
}
|
||||
if ($foreachLevels > 0) {
|
||||
/* @var Smarty_Internal_Compile_Foreach $foreachCompiler */
|
||||
$foreachCompiler = $compiler->getTagCompiler('foreach');
|
||||
$output .= $foreachCompiler->compileRestore($foreachLevels);
|
||||
}
|
||||
$output .= "{$this->tag} {$levels};?>";
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* check attributes and return array of break and foreach levels
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return array
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function checkLevels($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
static $_is_loopy = array('for' => true, 'foreach' => true, 'while' => true, 'section' => true);
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
}
|
||||
if (isset($_attr[ 'levels' ])) {
|
||||
if (!is_numeric($_attr[ 'levels' ])) {
|
||||
$compiler->trigger_template_error('level attribute must be a numeric constant', null, true);
|
||||
}
|
||||
$levels = $_attr[ 'levels' ];
|
||||
} else {
|
||||
$levels = 1;
|
||||
}
|
||||
$level_count = $levels;
|
||||
$stack_count = count($compiler->_tag_stack) - 1;
|
||||
$foreachLevels = 0;
|
||||
$lastTag = '';
|
||||
while ($level_count > 0 && $stack_count >= 0) {
|
||||
if (isset($_is_loopy[ $compiler->_tag_stack[ $stack_count ][ 0 ] ])) {
|
||||
$lastTag = $compiler->_tag_stack[ $stack_count ][ 0 ];
|
||||
if ($level_count === 0) {
|
||||
break;
|
||||
}
|
||||
$level_count--;
|
||||
if ($compiler->_tag_stack[ $stack_count ][ 0 ] === 'foreach') {
|
||||
$foreachLevels++;
|
||||
}
|
||||
}
|
||||
$stack_count--;
|
||||
}
|
||||
if ($level_count !== 0) {
|
||||
$compiler->trigger_template_error("cannot {$this->tag} {$levels} level(s)", null, true);
|
||||
}
|
||||
if ($lastTag === 'foreach' && $this->tag === 'break' && $foreachLevels > 0) {
|
||||
$foreachLevels--;
|
||||
}
|
||||
return array($levels, $foreachLevels);
|
||||
}
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Function_Call
|
||||
* Compiles the calls of user defined tags defined by {function}
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Function_Call Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('name');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('name');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('_any');
|
||||
|
||||
/**
|
||||
* Compiles the calls of user defined tags defined by {function}
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
// save possible attributes
|
||||
if (isset($_attr[ 'assign' ])) {
|
||||
// output will be stored in a smarty variable instead of being displayed
|
||||
$_assign = $_attr[ 'assign' ];
|
||||
}
|
||||
//$_name = trim($_attr['name'], "''");
|
||||
$_name = $_attr[ 'name' ];
|
||||
unset($_attr[ 'name' ], $_attr[ 'assign' ], $_attr[ 'nocache' ]);
|
||||
// set flag (compiled code of {function} must be included in cache file
|
||||
if (!$compiler->template->caching || $compiler->nocache || $compiler->tag_nocache) {
|
||||
$_nocache = 'true';
|
||||
} else {
|
||||
$_nocache = 'false';
|
||||
}
|
||||
$_paramsArray = array();
|
||||
foreach ($_attr as $_key => $_value) {
|
||||
if (is_int($_key)) {
|
||||
$_paramsArray[] = "$_key=>$_value";
|
||||
} else {
|
||||
$_paramsArray[] = "'$_key'=>$_value";
|
||||
}
|
||||
}
|
||||
$_params = 'array(' . implode(',', $_paramsArray) . ')';
|
||||
//$compiler->suppressNocacheProcessing = true;
|
||||
// was there an assign attribute
|
||||
if (isset($_assign)) {
|
||||
$_output =
|
||||
"<?php ob_start();\n\$_smarty_tpl->smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
|
||||
} else {
|
||||
$_output =
|
||||
"<?php \$_smarty_tpl->smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});?>\n";
|
||||
}
|
||||
return $_output;
|
||||
}
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Capture
|
||||
* Compiles the {capture} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Capture Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('name');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('name', 'assign', 'append');
|
||||
|
||||
/**
|
||||
* Compiles code for the {$smarty.capture.xxx}
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public static function compileSpecialVariable(
|
||||
$args,
|
||||
Smarty_Internal_TemplateCompilerBase $compiler,
|
||||
$parameter = null
|
||||
) {
|
||||
return '$_smarty_tpl->smarty->ext->_capture->getBuffer($_smarty_tpl' .
|
||||
(isset($parameter[ 1 ]) ? ", {$parameter[ 1 ]})" : ')');
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles code for the {capture} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param null $parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = null)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args, $parameter, 'capture');
|
||||
$buffer = isset($_attr[ 'name' ]) ? $_attr[ 'name' ] : "'default'";
|
||||
$assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : 'null';
|
||||
$append = isset($_attr[ 'append' ]) ? $_attr[ 'append' ] : 'null';
|
||||
$compiler->_cache[ 'capture_stack' ][] = array($compiler->nocache);
|
||||
// maybe nocache because of nocache variables
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
$_output = "<?php \$_smarty_tpl->smarty->ext->_capture->open(\$_smarty_tpl, $buffer, $assign, $append);?>";
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Captureclose Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {/capture} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param null $parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args, $parameter, '/capture');
|
||||
// must endblock be nocache?
|
||||
if ($compiler->nocache) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
list($compiler->nocache) = array_pop($compiler->_cache[ 'capture_stack' ]);
|
||||
return "<?php \$_smarty_tpl->smarty->ext->_capture->close(\$_smarty_tpl);?>";
|
||||
}
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Smarty.
|
||||
*
|
||||
* (c) 2015 Uwe Tews
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Child Class
|
||||
*
|
||||
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||
*/
|
||||
class Smarty_Internal_Compile_Child extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('assign');
|
||||
|
||||
/**
|
||||
* Tag name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $tag = 'child';
|
||||
|
||||
/**
|
||||
* Block type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $blockType = 'Child';
|
||||
|
||||
/**
|
||||
* Compiles code for the {child} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$tag = isset($parameter[ 0 ]) ? "'{$parameter[0]}'" : "'{{$this->tag}}'";
|
||||
if (!isset($compiler->_cache[ 'blockNesting' ])) {
|
||||
$compiler->trigger_template_error(
|
||||
"{$tag} used outside {block} tags ",
|
||||
$compiler->parser->lex->taglineno
|
||||
);
|
||||
}
|
||||
$compiler->has_code = true;
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
if ($this->blockType === 'Child') {
|
||||
$compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ][ 'callsChild' ] = 'true';
|
||||
}
|
||||
$_assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : null;
|
||||
$output = "<?php \n";
|
||||
if (isset($_assign)) {
|
||||
$output .= "ob_start();\n";
|
||||
}
|
||||
$output .= '$_smarty_tpl->inheritance->call' . $this->blockType . '($_smarty_tpl, $this' .
|
||||
($this->blockType === 'Child' ? '' : ", {$tag}") . ");\n";
|
||||
if (isset($_assign)) {
|
||||
$output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n";
|
||||
}
|
||||
$output .= "?>\n";
|
||||
return $output;
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Config Load
|
||||
* Compiles the {config load} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Config Load Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('file');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('file', 'section');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('section', 'scope');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $option_flags = array('nocache', 'noscope');
|
||||
|
||||
/**
|
||||
* Valid scope names
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $valid_scopes = array(
|
||||
'local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT,
|
||||
'root' => Smarty::SCOPE_ROOT, 'tpl_root' => Smarty::SCOPE_TPL_ROOT,
|
||||
'smarty' => Smarty::SCOPE_SMARTY, 'global' => Smarty::SCOPE_SMARTY
|
||||
);
|
||||
|
||||
/**
|
||||
* Compiles code for the {config_load} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
}
|
||||
// save possible attributes
|
||||
$conf_file = $_attr[ 'file' ];
|
||||
if (isset($_attr[ 'section' ])) {
|
||||
$section = $_attr[ 'section' ];
|
||||
} else {
|
||||
$section = 'null';
|
||||
}
|
||||
// scope setup
|
||||
if ($_attr[ 'noscope' ]) {
|
||||
$_scope = -1;
|
||||
} else {
|
||||
$_scope = $compiler->convertScope($_attr, $this->valid_scopes);
|
||||
}
|
||||
// create config object
|
||||
$_output =
|
||||
"<?php\n\$_smarty_tpl->smarty->ext->configLoad->_loadConfigFile(\$_smarty_tpl, {$conf_file}, {$section}, {$_scope});\n?>\n";
|
||||
return $_output;
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Continue
|
||||
* Compiles the {continue} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Continue Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Continue extends Smarty_Internal_Compile_Break
|
||||
{
|
||||
/**
|
||||
* Tag name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $tag = 'continue';
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Debug
|
||||
* Compiles the {debug} tag.
|
||||
* It opens a window the the Smarty Debugging Console.
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Debug Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Debug extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {debug} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
// compile always as nocache
|
||||
$compiler->tag_nocache = true;
|
||||
// display debug template
|
||||
$_output =
|
||||
"<?php \$_smarty_debug = new Smarty_Internal_Debug;\n \$_smarty_debug->display_debug(\$_smarty_tpl);\n";
|
||||
$_output .= "unset(\$_smarty_debug);\n?>";
|
||||
return $_output;
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Eval
|
||||
* Compiles the {eval} tag.
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Eval Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Eval extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('var');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('assign');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('var', 'assign');
|
||||
|
||||
/**
|
||||
* Compiles code for the {eval} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if (isset($_attr[ 'assign' ])) {
|
||||
// output will be stored in a smarty variable instead of being displayed
|
||||
$_assign = $_attr[ 'assign' ];
|
||||
}
|
||||
// create template object
|
||||
$_output =
|
||||
"\$_template = new {$compiler->smarty->template_class}('eval:'.{$_attr[ 'var' ]}, \$_smarty_tpl->smarty, \$_smarty_tpl);";
|
||||
//was there an assign attribute?
|
||||
if (isset($_assign)) {
|
||||
$_output .= "\$_smarty_tpl->assign($_assign,\$_template->fetch());";
|
||||
} else {
|
||||
$_output .= 'echo $_template->fetch();';
|
||||
}
|
||||
return "<?php $_output ?>";
|
||||
}
|
||||
}
|
|
@ -1,158 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile extend
|
||||
* Compiles the {extends} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile extend Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inheritance
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('file');
|
||||
|
||||
/**
|
||||
* Array of names of optional attribute required by tag
|
||||
* use array('_any') if there is no restriction of attributes names
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $optional_attributes = array('extends_resource');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('file');
|
||||
|
||||
/**
|
||||
* Compiles code for the {extends} tag extends: resource
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', $compiler->parser->lex->line - 1);
|
||||
}
|
||||
if (strpos($_attr[ 'file' ], '$_tmp') !== false) {
|
||||
$compiler->trigger_template_error('illegal value for file attribute', $compiler->parser->lex->line - 1);
|
||||
}
|
||||
// add code to initialize inheritance
|
||||
$this->registerInit($compiler, true);
|
||||
$file = trim($_attr[ 'file' ], '\'"');
|
||||
if (strlen($file) > 8 && substr($file, 0, 8) === 'extends:') {
|
||||
// generate code for each template
|
||||
$files = array_reverse(explode('|', substr($file, 8)));
|
||||
$i = 0;
|
||||
foreach ($files as $file) {
|
||||
if ($file[ 0 ] === '"') {
|
||||
$file = trim($file, '".');
|
||||
} else {
|
||||
$file = "'{$file}'";
|
||||
}
|
||||
$i++;
|
||||
if ($i === count($files) && isset($_attr[ 'extends_resource' ])) {
|
||||
$this->compileEndChild($compiler);
|
||||
}
|
||||
$this->compileInclude($compiler, $file);
|
||||
}
|
||||
if (!isset($_attr[ 'extends_resource' ])) {
|
||||
$this->compileEndChild($compiler);
|
||||
}
|
||||
} else {
|
||||
$this->compileEndChild($compiler, $_attr[ 'file' ]);
|
||||
}
|
||||
$compiler->has_code = false;
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add code for inheritance endChild() method to end of template
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param null|string $template optional inheritance parent template
|
||||
*
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
private function compileEndChild(Smarty_Internal_TemplateCompilerBase $compiler, $template = null)
|
||||
{
|
||||
$inlineUids = '';
|
||||
if (isset($template) && $compiler->smarty->merge_compiled_includes) {
|
||||
$code = $compiler->compileTag('include', array($template, array('scope' => 'parent')));
|
||||
if (preg_match('/([,][\s]*[\'][a-z0-9]+[\'][,][\s]*[\']content.*[\'])[)]/', $code, $match)) {
|
||||
$inlineUids = $match[ 1 ];
|
||||
}
|
||||
}
|
||||
$compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag(
|
||||
$compiler->parser,
|
||||
'<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl' .
|
||||
(isset($template) ?
|
||||
", {$template}{$inlineUids}" :
|
||||
'') . ");\n?>"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add code for including subtemplate to end of template
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param string $template subtemplate name
|
||||
*
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
private function compileInclude(Smarty_Internal_TemplateCompilerBase $compiler, $template)
|
||||
{
|
||||
$compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag(
|
||||
$compiler->parser,
|
||||
$compiler->compileTag(
|
||||
'include',
|
||||
array(
|
||||
$template,
|
||||
array('scope' => 'parent')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create source code for {extends} from source components array
|
||||
*
|
||||
* @param \Smarty_Internal_Template $template
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function extendsSourceArrayCode(Smarty_Internal_Template $template)
|
||||
{
|
||||
$resources = array();
|
||||
foreach ($template->source->components as $source) {
|
||||
$resources[] = $source->resource;
|
||||
}
|
||||
return $template->smarty->left_delimiter . 'extends file=\'extends:' . join('|', $resources) .
|
||||
'\' extends_resource=true' . $template->smarty->right_delimiter;
|
||||
}
|
||||
}
|
|
@ -1,164 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile For
|
||||
* Compiles the {for} {forelse} {/for} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile For Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {for} tag
|
||||
* Smarty 3 does implement two different syntax's:
|
||||
* - {for $var in $array}
|
||||
* For looping over arrays or iterators
|
||||
* - {for $x=0; $x<$y; $x++}
|
||||
* For general loops
|
||||
* The parser is generating different sets of attribute by which this compiler can
|
||||
* determine which syntax is used.
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter)
|
||||
{
|
||||
$compiler->loopNesting++;
|
||||
if ($parameter === 0) {
|
||||
$this->required_attributes = array('start', 'to');
|
||||
$this->optional_attributes = array('max', 'step');
|
||||
} else {
|
||||
$this->required_attributes = array('start', 'ifexp', 'var', 'step');
|
||||
$this->optional_attributes = array();
|
||||
}
|
||||
$this->mapCache = array();
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$output = "<?php\n";
|
||||
if ($parameter === 1) {
|
||||
foreach ($_attr[ 'start' ] as $_statement) {
|
||||
if (is_array($_statement[ 'var' ])) {
|
||||
$var = $_statement[ 'var' ][ 'var' ];
|
||||
$index = $_statement[ 'var' ][ 'smarty_internal_index' ];
|
||||
} else {
|
||||
$var = $_statement[ 'var' ];
|
||||
$index = '';
|
||||
}
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var] = new Smarty_Variable(null, \$_smarty_tpl->isRenderingCache);\n";
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->value{$index} = {$_statement['value']};\n";
|
||||
}
|
||||
if (is_array($_attr[ 'var' ])) {
|
||||
$var = $_attr[ 'var' ][ 'var' ];
|
||||
$index = $_attr[ 'var' ][ 'smarty_internal_index' ];
|
||||
} else {
|
||||
$var = $_attr[ 'var' ];
|
||||
$index = '';
|
||||
}
|
||||
$output .= "if ($_attr[ifexp]) {\nfor (\$_foo=true;$_attr[ifexp]; \$_smarty_tpl->tpl_vars[$var]->value{$index}$_attr[step]) {\n";
|
||||
} else {
|
||||
$_statement = $_attr[ 'start' ];
|
||||
if (is_array($_statement[ 'var' ])) {
|
||||
$var = $_statement[ 'var' ][ 'var' ];
|
||||
$index = $_statement[ 'var' ][ 'smarty_internal_index' ];
|
||||
} else {
|
||||
$var = $_statement[ 'var' ];
|
||||
$index = '';
|
||||
}
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var] = new Smarty_Variable(null, \$_smarty_tpl->isRenderingCache);";
|
||||
if (isset($_attr[ 'step' ])) {
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->step = $_attr[step];";
|
||||
} else {
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->step = 1;";
|
||||
}
|
||||
if (isset($_attr[ 'max' ])) {
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->total = (int) min(ceil((\$_smarty_tpl->tpl_vars[$var]->step > 0 ? $_attr[to]+1 - ($_statement[value]) : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$var]->step)),$_attr[max]);\n";
|
||||
} else {
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->total = (int) ceil((\$_smarty_tpl->tpl_vars[$var]->step > 0 ? $_attr[to]+1 - ($_statement[value]) : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$var]->step));\n";
|
||||
}
|
||||
$output .= "if (\$_smarty_tpl->tpl_vars[$var]->total > 0) {\n";
|
||||
$output .= "for (\$_smarty_tpl->tpl_vars[$var]->value{$index} = $_statement[value], \$_smarty_tpl->tpl_vars[$var]->iteration = 1;\$_smarty_tpl->tpl_vars[$var]->iteration <= \$_smarty_tpl->tpl_vars[$var]->total;\$_smarty_tpl->tpl_vars[$var]->value{$index} += \$_smarty_tpl->tpl_vars[$var]->step, \$_smarty_tpl->tpl_vars[$var]->iteration++) {\n";
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->first = \$_smarty_tpl->tpl_vars[$var]->iteration === 1;";
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->last = \$_smarty_tpl->tpl_vars[$var]->iteration === \$_smarty_tpl->tpl_vars[$var]->total;";
|
||||
}
|
||||
$output .= '?>';
|
||||
$this->openTag($compiler, 'for', array('for', $compiler->nocache));
|
||||
// maybe nocache because of nocache variables
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
// return compiled code
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Forelse Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {forelse} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
list($openTag, $nocache) = $this->closeTag($compiler, array('for'));
|
||||
$this->openTag($compiler, 'forelse', array('forelse', $nocache));
|
||||
return "<?php }} else { ?>";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Forclose Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {/for} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler, $parameter)
|
||||
{
|
||||
$compiler->loopNesting--;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
// must endblock be nocache?
|
||||
if ($compiler->nocache) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
list($openTag, $compiler->nocache) = $this->closeTag($compiler, array('for', 'forelse'));
|
||||
$output = "<?php }\n";
|
||||
if ($openTag !== 'forelse') {
|
||||
$output .= "}\n";
|
||||
}
|
||||
$output .= "?>";
|
||||
return $output;
|
||||
}
|
||||
}
|
|
@ -1,345 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreach
|
||||
* Compiles the {foreach} {foreachelse} {/foreach} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreach Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_ForeachSection
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('from', 'item');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('name', 'key', 'properties');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('from', 'item', 'key', 'name');
|
||||
|
||||
/**
|
||||
* counter
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $counter = 0;
|
||||
|
||||
/**
|
||||
* Name of this tag
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $tagName = 'foreach';
|
||||
|
||||
/**
|
||||
* Valid properties of $smarty.foreach.name.xxx variable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $nameProperties = array('first', 'last', 'index', 'iteration', 'show', 'total');
|
||||
|
||||
/**
|
||||
* Valid properties of $item@xxx variable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $itemProperties = array('first', 'last', 'index', 'iteration', 'show', 'total', 'key');
|
||||
|
||||
/**
|
||||
* Flag if tag had name attribute
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $isNamed = false;
|
||||
|
||||
/**
|
||||
* Compiles code for the {foreach} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
$compiler->loopNesting++;
|
||||
// init
|
||||
$this->isNamed = false;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$from = $_attr[ 'from' ];
|
||||
$item = $compiler->getId($_attr[ 'item' ]);
|
||||
if ($item === false) {
|
||||
$item = $compiler->getVariableName($_attr[ 'item' ]);
|
||||
}
|
||||
$key = $name = null;
|
||||
$attributes = array('item' => $item);
|
||||
if (isset($_attr[ 'key' ])) {
|
||||
$key = $compiler->getId($_attr[ 'key' ]);
|
||||
if ($key === false) {
|
||||
$key = $compiler->getVariableName($_attr[ 'key' ]);
|
||||
}
|
||||
$attributes[ 'key' ] = $key;
|
||||
}
|
||||
if (isset($_attr[ 'name' ])) {
|
||||
$this->isNamed = true;
|
||||
$name = $attributes[ 'name' ] = $compiler->getId($_attr[ 'name' ]);
|
||||
}
|
||||
foreach ($attributes as $a => $v) {
|
||||
if ($v === false) {
|
||||
$compiler->trigger_template_error("'{$a}' attribute/variable has illegal value", null, true);
|
||||
}
|
||||
}
|
||||
$fromName = $compiler->getVariableName($_attr[ 'from' ]);
|
||||
if ($fromName) {
|
||||
foreach (array('item', 'key') as $a) {
|
||||
if (isset($attributes[ $a ]) && $attributes[ $a ] === $fromName) {
|
||||
$compiler->trigger_template_error(
|
||||
"'{$a}' and 'from' may not have same variable name '{$fromName}'",
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$itemVar = "\$_smarty_tpl->tpl_vars['{$item}']";
|
||||
$local = '$__foreach_' . $attributes[ 'item' ] . '_' . $this->counter++ . '_';
|
||||
// search for used tag attributes
|
||||
$itemAttr = array();
|
||||
$namedAttr = array();
|
||||
$this->scanForProperties($attributes, $compiler);
|
||||
if (!empty($this->matchResults[ 'item' ])) {
|
||||
$itemAttr = $this->matchResults[ 'item' ];
|
||||
}
|
||||
if (!empty($this->matchResults[ 'named' ])) {
|
||||
$namedAttr = $this->matchResults[ 'named' ];
|
||||
}
|
||||
if (isset($_attr[ 'properties' ]) && preg_match_all('/[\'](.*?)[\']/', $_attr[ 'properties' ], $match)) {
|
||||
foreach ($match[ 1 ] as $prop) {
|
||||
if (in_array($prop, $this->itemProperties)) {
|
||||
$itemAttr[ $prop ] = true;
|
||||
} else {
|
||||
$compiler->trigger_template_error("Invalid property '{$prop}'", null, true);
|
||||
}
|
||||
}
|
||||
if ($this->isNamed) {
|
||||
foreach ($match[ 1 ] as $prop) {
|
||||
if (in_array($prop, $this->nameProperties)) {
|
||||
$nameAttr[ $prop ] = true;
|
||||
} else {
|
||||
$compiler->trigger_template_error("Invalid property '{$prop}'", null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($itemAttr[ 'first' ])) {
|
||||
$itemAttr[ 'index' ] = true;
|
||||
}
|
||||
if (isset($namedAttr[ 'first' ])) {
|
||||
$namedAttr[ 'index' ] = true;
|
||||
}
|
||||
if (isset($namedAttr[ 'last' ])) {
|
||||
$namedAttr[ 'iteration' ] = true;
|
||||
$namedAttr[ 'total' ] = true;
|
||||
}
|
||||
if (isset($itemAttr[ 'last' ])) {
|
||||
$itemAttr[ 'iteration' ] = true;
|
||||
$itemAttr[ 'total' ] = true;
|
||||
}
|
||||
if (isset($namedAttr[ 'show' ])) {
|
||||
$namedAttr[ 'total' ] = true;
|
||||
}
|
||||
if (isset($itemAttr[ 'show' ])) {
|
||||
$itemAttr[ 'total' ] = true;
|
||||
}
|
||||
$keyTerm = '';
|
||||
if (isset($attributes[ 'key' ])) {
|
||||
$keyTerm = "\$_smarty_tpl->tpl_vars['{$key}']->value => ";
|
||||
}
|
||||
if (isset($itemAttr[ 'key' ])) {
|
||||
$keyTerm = "{$itemVar}->key => ";
|
||||
}
|
||||
if ($this->isNamed) {
|
||||
$foreachVar = "\$_smarty_tpl->tpl_vars['__smarty_foreach_{$attributes['name']}']";
|
||||
}
|
||||
$needTotal = isset($itemAttr[ 'total' ]);
|
||||
// Register tag
|
||||
$this->openTag(
|
||||
$compiler,
|
||||
'foreach',
|
||||
array('foreach', $compiler->nocache, $local, $itemVar, empty($itemAttr) ? 1 : 2)
|
||||
);
|
||||
// maybe nocache because of nocache variables
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
// generate output code
|
||||
$output = "<?php\n";
|
||||
$output .= "\$_from = \$_smarty_tpl->smarty->ext->_foreach->init(\$_smarty_tpl, $from, " .
|
||||
var_export($item, true);
|
||||
if ($name || $needTotal || $key) {
|
||||
$output .= ', ' . var_export($needTotal, true);
|
||||
}
|
||||
if ($name || $key) {
|
||||
$output .= ', ' . var_export($key, true);
|
||||
}
|
||||
if ($name) {
|
||||
$output .= ', ' . var_export($name, true) . ', ' . var_export($namedAttr, true);
|
||||
}
|
||||
$output .= ");\n";
|
||||
if (isset($itemAttr[ 'show' ])) {
|
||||
$output .= "{$itemVar}->show = ({$itemVar}->total > 0);\n";
|
||||
}
|
||||
if (isset($itemAttr[ 'iteration' ])) {
|
||||
$output .= "{$itemVar}->iteration = 0;\n";
|
||||
}
|
||||
if (isset($itemAttr[ 'index' ])) {
|
||||
$output .= "{$itemVar}->index = -1;\n";
|
||||
}
|
||||
$output .= "if (\$_from !== null) {\n";
|
||||
$output .= "foreach (\$_from as {$keyTerm}{$itemVar}->value) {\n";
|
||||
if (isset($attributes[ 'key' ]) && isset($itemAttr[ 'key' ])) {
|
||||
$output .= "\$_smarty_tpl->tpl_vars['{$key}']->value = {$itemVar}->key;\n";
|
||||
}
|
||||
if (isset($itemAttr[ 'iteration' ])) {
|
||||
$output .= "{$itemVar}->iteration++;\n";
|
||||
}
|
||||
if (isset($itemAttr[ 'index' ])) {
|
||||
$output .= "{$itemVar}->index++;\n";
|
||||
}
|
||||
if (isset($itemAttr[ 'first' ])) {
|
||||
$output .= "{$itemVar}->first = !{$itemVar}->index;\n";
|
||||
}
|
||||
if (isset($itemAttr[ 'last' ])) {
|
||||
$output .= "{$itemVar}->last = {$itemVar}->iteration === {$itemVar}->total;\n";
|
||||
}
|
||||
if (isset($foreachVar)) {
|
||||
if (isset($namedAttr[ 'iteration' ])) {
|
||||
$output .= "{$foreachVar}->value['iteration']++;\n";
|
||||
}
|
||||
if (isset($namedAttr[ 'index' ])) {
|
||||
$output .= "{$foreachVar}->value['index']++;\n";
|
||||
}
|
||||
if (isset($namedAttr[ 'first' ])) {
|
||||
$output .= "{$foreachVar}->value['first'] = !{$foreachVar}->value['index'];\n";
|
||||
}
|
||||
if (isset($namedAttr[ 'last' ])) {
|
||||
$output .= "{$foreachVar}->value['last'] = {$foreachVar}->value['iteration'] === {$foreachVar}->value['total'];\n";
|
||||
}
|
||||
}
|
||||
if (!empty($itemAttr)) {
|
||||
$output .= "{$local}saved = {$itemVar};\n";
|
||||
}
|
||||
$output .= '?>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles code for to restore saved template variables
|
||||
*
|
||||
* @param int $levels number of levels to restore
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compileRestore($levels)
|
||||
{
|
||||
return "\$_smarty_tpl->smarty->ext->_foreach->restore(\$_smarty_tpl, {$levels});";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreachelse Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {foreachelse} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
list($openTag, $nocache, $local, $itemVar, $restore) = $this->closeTag($compiler, array('foreach'));
|
||||
$this->openTag($compiler, 'foreachelse', array('foreachelse', $nocache, $local, $itemVar, 0));
|
||||
$output = "<?php\n";
|
||||
if ($restore === 2) {
|
||||
$output .= "{$itemVar} = {$local}saved;\n";
|
||||
}
|
||||
$output .= "}\n} else {\n?>";
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreachclose Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {/foreach} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
$compiler->loopNesting--;
|
||||
// must endblock be nocache?
|
||||
if ($compiler->nocache) {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
list(
|
||||
$openTag, $compiler->nocache, $local, $itemVar, $restore
|
||||
) = $this->closeTag($compiler, array('foreach', 'foreachelse'));
|
||||
$output = "<?php\n";
|
||||
if ($restore === 2) {
|
||||
$output .= "{$itemVar} = {$local}saved;\n";
|
||||
}
|
||||
if ($restore > 0) {
|
||||
$output .= "}\n";
|
||||
}
|
||||
$output .= "}\n";
|
||||
/* @var Smarty_Internal_Compile_Foreach $foreachCompiler */
|
||||
$foreachCompiler = $compiler->getTagCompiler('foreach');
|
||||
$output .= $foreachCompiler->compileRestore(1);
|
||||
$output .= "?>";
|
||||
return $output;
|
||||
}
|
||||
}
|
|
@ -1,231 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Function
|
||||
* Compiles the {function} {/function} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Function Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('name');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('name');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('_any');
|
||||
|
||||
/**
|
||||
* Compiles code for the {function} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return bool true
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
}
|
||||
unset($_attr[ 'nocache' ]);
|
||||
$_name = trim($_attr[ 'name' ], '\'"');
|
||||
$compiler->parent_compiler->tpl_function[ $_name ] = array();
|
||||
$save = array(
|
||||
$_attr, $compiler->parser->current_buffer, $compiler->template->compiled->has_nocache_code,
|
||||
$compiler->template->caching
|
||||
);
|
||||
$this->openTag($compiler, 'function', $save);
|
||||
// Init temporary context
|
||||
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
|
||||
$compiler->template->compiled->has_nocache_code = false;
|
||||
$compiler->saveRequiredPlugins(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Functionclose Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compiler object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
private $compiler = null;
|
||||
|
||||
/**
|
||||
* Compiles code for the {/function} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object|\Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return bool true
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
$saved_data = $this->closeTag($compiler, array('function'));
|
||||
$_attr = $saved_data[ 0 ];
|
||||
$_name = trim($_attr[ 'name' ], '\'"');
|
||||
$compiler->parent_compiler->tpl_function[ $_name ][ 'compiled_filepath' ] =
|
||||
$compiler->parent_compiler->template->compiled->filepath;
|
||||
$compiler->parent_compiler->tpl_function[ $_name ][ 'uid' ] = $compiler->template->source->uid;
|
||||
$_parameter = $_attr;
|
||||
unset($_parameter[ 'name' ]);
|
||||
// default parameter
|
||||
$_paramsArray = array();
|
||||
foreach ($_parameter as $_key => $_value) {
|
||||
if (is_int($_key)) {
|
||||
$_paramsArray[] = "$_key=>$_value";
|
||||
} else {
|
||||
$_paramsArray[] = "'$_key'=>$_value";
|
||||
}
|
||||
}
|
||||
if (!empty($_paramsArray)) {
|
||||
$_params = 'array(' . implode(',', $_paramsArray) . ')';
|
||||
$_paramsCode = "\$params = array_merge($_params, \$params);\n";
|
||||
} else {
|
||||
$_paramsCode = '';
|
||||
}
|
||||
$_functionCode = $compiler->parser->current_buffer;
|
||||
// setup buffer for template function code
|
||||
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
|
||||
$_funcName = "smarty_template_function_{$_name}_{$compiler->template->compiled->nocache_hash}";
|
||||
$_funcNameCaching = $_funcName . '_nocache';
|
||||
if ($compiler->template->compiled->has_nocache_code) {
|
||||
$compiler->parent_compiler->tpl_function[ $_name ][ 'call_name_caching' ] = $_funcNameCaching;
|
||||
$output = "<?php\n";
|
||||
$output .= "/* {$_funcNameCaching} */\n";
|
||||
$output .= "if (!function_exists('{$_funcNameCaching}')) {\n";
|
||||
$output .= "function {$_funcNameCaching} (Smarty_Internal_Template \$_smarty_tpl,\$params) {\n";
|
||||
$output .= "ob_start();\n";
|
||||
$output .= $compiler->compileRequiredPlugins();
|
||||
$output .= "\$_smarty_tpl->compiled->has_nocache_code = true;\n";
|
||||
$output .= $_paramsCode;
|
||||
$output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}\n";
|
||||
$output .= "\$params = var_export(\$params, true);\n";
|
||||
$output .= "echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
|
||||
$output .= "\\\$_smarty_tpl->smarty->ext->_tplFunction->saveTemplateVariables(\\\$_smarty_tpl, '{$_name}');\nforeach (\$params as \\\$key => \\\$value) {\n\\\$_smarty_tpl->tpl_vars[\\\$key] = new Smarty_Variable(\\\$value, \\\$_smarty_tpl->isRenderingCache);\n}\n?>";
|
||||
$output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";?>";
|
||||
$compiler->parser->current_buffer->append_subtree(
|
||||
$compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Tag(
|
||||
$compiler->parser,
|
||||
$output
|
||||
)
|
||||
);
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
||||
$output = "<?php echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
|
||||
$output .= "\\\$_smarty_tpl->smarty->ext->_tplFunction->restoreTemplateVariables(\\\$_smarty_tpl, '{$_name}');?>\n";
|
||||
$output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";\n?>";
|
||||
$output .= "<?php echo str_replace('{$compiler->template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash, ob_get_clean());\n";
|
||||
$output .= "}\n}\n";
|
||||
$output .= "/*/ {$_funcName}_nocache */\n\n";
|
||||
$output .= "?>\n";
|
||||
$compiler->parser->current_buffer->append_subtree(
|
||||
$compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Tag(
|
||||
$compiler->parser,
|
||||
$output
|
||||
)
|
||||
);
|
||||
$_functionCode = new Smarty_Internal_ParseTree_Tag(
|
||||
$compiler->parser,
|
||||
preg_replace_callback(
|
||||
"/((<\?php )?echo '\/\*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/([\S\s]*?)\/\*\/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/",
|
||||
array($this, 'removeNocache'),
|
||||
$_functionCode->to_smarty_php($compiler->parser)
|
||||
)
|
||||
);
|
||||
}
|
||||
$compiler->parent_compiler->tpl_function[ $_name ][ 'call_name' ] = $_funcName;
|
||||
$output = "<?php\n";
|
||||
$output .= "/* {$_funcName} */\n";
|
||||
$output .= "if (!function_exists('{$_funcName}')) {\n";
|
||||
$output .= "function {$_funcName}(Smarty_Internal_Template \$_smarty_tpl,\$params) {\n";
|
||||
$output .= $_paramsCode;
|
||||
$output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}\n";
|
||||
$output .= $compiler->compileCheckPlugins(array_merge($compiler->required_plugins[ 'compiled' ],
|
||||
$compiler->required_plugins[ 'nocache' ]));
|
||||
$output .= "?>\n";
|
||||
$compiler->parser->current_buffer->append_subtree(
|
||||
$compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Tag(
|
||||
$compiler->parser,
|
||||
$output
|
||||
)
|
||||
);
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
||||
$output = "<?php\n}}\n";
|
||||
$output .= "/*/ {$_funcName} */\n\n";
|
||||
$output .= "?>\n";
|
||||
$compiler->parser->current_buffer->append_subtree(
|
||||
$compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Tag(
|
||||
$compiler->parser,
|
||||
$output
|
||||
)
|
||||
);
|
||||
$compiler->parent_compiler->blockOrFunctionCode .= $compiler->parser->current_buffer->to_smarty_php($compiler->parser);
|
||||
// restore old buffer
|
||||
$compiler->parser->current_buffer = $saved_data[ 1 ];
|
||||
// restore old status
|
||||
$compiler->restoreRequiredPlugins();
|
||||
$compiler->template->compiled->has_nocache_code = $saved_data[ 2 ];
|
||||
$compiler->template->caching = $saved_data[ 3 ];
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove nocache code
|
||||
*
|
||||
* @param $match
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function removeNocache($match)
|
||||
{
|
||||
$code =
|
||||
preg_replace(
|
||||
"/((<\?php )?echo '\/\*%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/)|(\/\*\/%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/",
|
||||
'',
|
||||
$match[ 0 ]
|
||||
);
|
||||
$code = str_replace(array('\\\'', '\\\\\''), array('\'', '\\\''), $code);
|
||||
return $code;
|
||||
}
|
||||
}
|