Merge branch 'zap' into dev

This commit is contained in:
zotlabs 2018-09-19 20:48:14 -07:00
commit 551314201c
247 changed files with 9915 additions and 5211 deletions

View file

@ -100,6 +100,7 @@ class ActivityStreams {
$this->tgt['actor'] = $this->get_actor('actor',$this->tgt);
$this->parent_id = $this->get_property_obj('inReplyTo');
if(! $this->parent_id) {
$this->parent_id = $this->obj['inReplyTo'];
}

View file

@ -496,7 +496,7 @@ define ( 'ACTIVITY_UNFRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'remove-friend' );
define ( 'ACTIVITY_JOIN', NAMESPACE_ACTIVITY_SCHEMA . 'join' );
define ( 'ACTIVITY_FAVORITE', NAMESPACE_ACTIVITY_SCHEMA . 'favorite' );
define ( 'ACTIVITY_CREATE', NAMESPACE_ACTIVITY_SCHEMA . 'create' );
//define ( 'ACTIVITY_CREATE', NAMESPACE_ACTIVITY_SCHEMA . 'create' );
define ( 'ACTIVITY_DELETE', NAMESPACE_ACTIVITY_SCHEMA . 'delete' );
define ( 'ACTIVITY_WIN', NAMESPACE_ACTIVITY_SCHEMA . 'win' );
define ( 'ACTIVITY_LOSE', NAMESPACE_ACTIVITY_SCHEMA . 'lose' );

View file

@ -39,7 +39,8 @@
"lukasreschke/id3parser": "^0.0.1",
"smarty/smarty": "~3.1",
"ramsey/uuid": "^3.8",
"twbs/bootstrap": "4.1.3"
"twbs/bootstrap": "4.1.3",
"indieweb/rel-me": "dev-master"
},
"require-dev" : {
"phpunit/phpunit" : "@stable",

154
composer.lock generated
View file

@ -1,10 +1,10 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "b7862124a9afe837c7eef8ee66f02ff4",
"content-hash": "2b4464b5361722e7347cf0c1a4b94c15",
"packages": [
{
"name": "bshaffer/oauth2-server-php",
@ -156,17 +156,52 @@
"time": "2018-02-23T01:58:20+00:00"
},
{
"name": "league/html-to-markdown",
"version": "4.7.0",
"name": "indieweb/rel-me",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/html-to-markdown.git",
"reference": "76c076483cef89860d32a3fd25312f5a42848a8c"
"url": "https://github.com/indieweb/rel-me.git",
"reference": "6a6c9de41f5b18ef99243340a365949f2c47df0e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/76c076483cef89860d32a3fd25312f5a42848a8c",
"reference": "76c076483cef89860d32a3fd25312f5a42848a8c",
"url": "https://api.github.com/repos/indieweb/rel-me/zipball/6a6c9de41f5b18ef99243340a365949f2c47df0e",
"reference": "6a6c9de41f5b18ef99243340a365949f2c47df0e",
"shasum": ""
},
"require": {
"mf2/mf2": "0.2.*",
"php": ">=5.3"
},
"require-dev": {
"barnabywalters/mf-cleaner": "*",
"phpunit/phpunit": "*"
},
"type": "library",
"autoload": {
"files": [
"RelMe.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Functions for discovering, consuming and verifying rel-me microformat",
"time": "2016-09-08T17:20:47+00:00"
},
{
"name": "league/html-to-markdown",
"version": "4.8.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/html-to-markdown.git",
"reference": "f9a879a068c68ff47b722de63f58bec79e448f9d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/f9a879a068c68ff47b722de63f58bec79e448f9d",
"reference": "f9a879a068c68ff47b722de63f58bec79e448f9d",
"shasum": ""
},
"require": {
@ -185,7 +220,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.8-dev"
"dev-master": "4.9-dev"
}
},
"autoload": {
@ -198,17 +233,17 @@
"MIT"
],
"authors": [
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "http://www.colinodell.com",
"role": "Lead Developer"
},
{
"name": "Nick Cernis",
"email": "nick@cern.is",
"homepage": "http://modernnerd.net",
"role": "Original Author"
},
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "https://www.colinodell.com",
"role": "Lead Developer"
}
],
"description": "An HTML-to-markdown conversion helper for PHP",
@ -217,7 +252,7 @@
"html",
"markdown"
],
"time": "2018-05-19T23:47:12+00:00"
"time": "2018-09-18T12:18:08+00:00"
},
{
"name": "lukasreschke/id3parser",
@ -254,6 +289,59 @@
],
"time": "2016-04-04T09:34:50+00:00"
},
{
"name": "mf2/mf2",
"version": "v0.2.12",
"source": {
"type": "git",
"url": "https://github.com/indieweb/php-mf2.git",
"reference": "6701504876d6c9242eb310b35f41d40d9785ab4e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/indieweb/php-mf2/zipball/6701504876d6c9242eb310b35f41d40d9785ab4e",
"reference": "6701504876d6c9242eb310b35f41d40d9785ab4e",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"suggest": {
"barnabywalters/mf-cleaner": "To more easily handle the canonical data php-mf2 gives you"
},
"bin": [
"bin/fetch-mf2",
"bin/parse-mf2"
],
"type": "library",
"autoload": {
"files": [
"Mf2/Parser.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Barnaby Walters",
"homepage": "http://waterpigs.co.uk"
}
],
"description": "A pure, generic microformats2 parser — makes HTML as easy to consume as a JSON API",
"keywords": [
"html",
"microformats",
"microformats 2",
"parser",
"semantic"
],
"time": "2015-07-12T14:10:01+00:00"
},
{
"name": "michelf/php-markdown",
"version": "1.8.0",
@ -1002,16 +1090,16 @@
},
{
"name": "smarty/smarty",
"version": "v3.1.32",
"version": "v3.1.33",
"source": {
"type": "git",
"url": "https://github.com/smarty-php/smarty.git",
"reference": "ac9d4b587e5bf53381e21881820a9830765cb459"
"reference": "dd55b23121e55a3b4f1af90a707a6c4e5969530f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/smarty-php/smarty/zipball/ac9d4b587e5bf53381e21881820a9830765cb459",
"reference": "ac9d4b587e5bf53381e21881820a9830765cb459",
"url": "https://api.github.com/repos/smarty-php/smarty/zipball/dd55b23121e55a3b4f1af90a707a6c4e5969530f",
"reference": "dd55b23121e55a3b4f1af90a707a6c4e5969530f",
"shasum": ""
},
"require": {
@ -1051,7 +1139,7 @@
"keywords": [
"templating"
],
"time": "2018-04-24T14:53:33+00:00"
"time": "2018-09-12T20:54:16+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -2544,21 +2632,24 @@
},
{
"name": "phpunit/php-file-iterator",
"version": "2.0.1",
"version": "2.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "cecbc684605bb0cc288828eb5d65d93d5c676d3c"
"reference": "050bedf145a257b1ff02746c31894800e5122946"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cecbc684605bb0cc288828eb5d65d93d5c676d3c",
"reference": "cecbc684605bb0cc288828eb5d65d93d5c676d3c",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946",
"reference": "050bedf145a257b1ff02746c31894800e5122946",
"shasum": ""
},
"require": {
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^7.1"
},
"type": "library",
"extra": {
"branch-alias": {
@ -2587,7 +2678,7 @@
"filesystem",
"iterator"
],
"time": "2018-06-11T11:44:00+00:00"
"time": "2018-09-13T20:33:42+00:00"
},
{
"name": "phpunit/php-text-template",
@ -2730,16 +2821,16 @@
},
{
"name": "phpunit/phpunit",
"version": "7.3.2",
"version": "7.3.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "34705f81bddc3f505b9599a2ef96e2b4315ba9b8"
"reference": "7b331efabbb628c518c408fdfcaf571156775de2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/34705f81bddc3f505b9599a2ef96e2b4315ba9b8",
"reference": "34705f81bddc3f505b9599a2ef96e2b4315ba9b8",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7b331efabbb628c518c408fdfcaf571156775de2",
"reference": "7b331efabbb628c518c408fdfcaf571156775de2",
"shasum": ""
},
"require": {
@ -2810,7 +2901,7 @@
"testing",
"xunit"
],
"time": "2018-08-22T06:39:21+00:00"
"time": "2018-09-08T15:14:29+00:00"
},
{
"name": "psr/container",
@ -4293,6 +4384,7 @@
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"indieweb/rel-me": 20,
"phpunit/phpunit": 0,
"behat/behat": 0,
"behat/mink-extension": 0,

1
vendor/bin/fetch-mf2 vendored Symbolic link
View file

@ -0,0 +1 @@
../mf2/mf2/bin/fetch-mf2

1
vendor/bin/parse-mf2 vendored Symbolic link
View file

@ -0,0 +1 @@
../mf2/mf2/bin/parse-mf2

View file

@ -377,7 +377,7 @@ class ClassLoader
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
$search = $subPath.'\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {

View file

@ -1,21 +1,56 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Composer
Upstream-Contact: Jordi Boggiano <j.boggiano@seld.be>
Source: https://github.com/composer/composer
Copyright (c) Nils Adermann, Jordi Boggiano
Files: *
Copyright: 2016, Nils Adermann <naderman@naderman.de>
2016, Jordi Boggiano <j.boggiano@seld.be>
License: Expat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
Files: src/Composer/Util/TlsHelper.php
Copyright: 2016, Nils Adermann <naderman@naderman.de>
2016, Jordi Boggiano <j.boggiano@seld.be>
2013, Evan Coury <me@evancoury.com>
License: Expat and BSD-2-Clause
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
License: BSD-2-Clause
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
.
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License: Expat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -300,6 +300,7 @@ return array(
'League\\HTMLToMarkdown\\ElementInterface' => $vendorDir . '/league/html-to-markdown/src/ElementInterface.php',
'League\\HTMLToMarkdown\\Environment' => $vendorDir . '/league/html-to-markdown/src/Environment.php',
'League\\HTMLToMarkdown\\HtmlConverter' => $vendorDir . '/league/html-to-markdown/src/HtmlConverter.php',
'League\\HTMLToMarkdown\\HtmlConverterInterface' => $vendorDir . '/league/html-to-markdown/src/HtmlConverterInterface.php',
'Michelf\\Markdown' => $vendorDir . '/michelf/php-markdown/Michelf/Markdown.php',
'Michelf\\MarkdownExtra' => $vendorDir . '/michelf/php-markdown/Michelf/MarkdownExtra.php',
'Michelf\\MarkdownInterface' => $vendorDir . '/michelf/php-markdown/Michelf/MarkdownInterface.php',
@ -830,8 +831,8 @@ return array(
'Zotlabs\\Daemon\\Onepoll' => $baseDir . '/Zotlabs/Daemon/Onepoll.php',
'Zotlabs\\Daemon\\Poller' => $baseDir . '/Zotlabs/Daemon/Poller.php',
'Zotlabs\\Daemon\\Queue' => $baseDir . '/Zotlabs/Daemon/Queue.php',
'Zotlabs\\Daemon\\Ratenotif' => $baseDir . '/Zotlabs/Daemon/Ratenotif.php',
'Zotlabs\\Daemon\\Thumbnail' => $baseDir . '/Zotlabs/Daemon/Thumbnail.php',
'Zotlabs\\Daemon\\Xchan_photo' => $baseDir . '/Zotlabs/Daemon/Xchan_photo.php',
'Zotlabs\\Extend\\Hook' => $baseDir . '/Zotlabs/Extend/Hook.php',
'Zotlabs\\Extend\\Route' => $baseDir . '/Zotlabs/Extend/Route.php',
'Zotlabs\\Extend\\Widget' => $baseDir . '/Zotlabs/Extend/Widget.php',
@ -850,6 +851,7 @@ return array(
'Zotlabs\\Lib\\Config' => $baseDir . '/Zotlabs/Lib/Config.php',
'Zotlabs\\Lib\\DB_Upgrade' => $baseDir . '/Zotlabs/Lib/DB_Upgrade.php',
'Zotlabs\\Lib\\DReport' => $baseDir . '/Zotlabs/Lib/DReport.php',
'Zotlabs\\Lib\\Discover' => $baseDir . '/Zotlabs/Lib/Discover.php',
'Zotlabs\\Lib\\Enotify' => $baseDir . '/Zotlabs/Lib/Enotify.php',
'Zotlabs\\Lib\\ExtendedZip' => $baseDir . '/Zotlabs/Lib/ExtendedZip.php',
'Zotlabs\\Lib\\Group' => $baseDir . '/Zotlabs/Lib/Group.php',
@ -862,8 +864,6 @@ return array(
'Zotlabs\\Lib\\Libzotdir' => $baseDir . '/Zotlabs/Lib/Libzotdir.php',
'Zotlabs\\Lib\\MarkdownSoap' => $baseDir . '/Zotlabs/Lib/MarkdownSoap.php',
'Zotlabs\\Lib\\MessageFilter' => $baseDir . '/Zotlabs/Lib/MessageFilter.php',
'Zotlabs\\Lib\\NativeWiki' => $baseDir . '/Zotlabs/Lib/NativeWiki.php',
'Zotlabs\\Lib\\NativeWikiPage' => $baseDir . '/Zotlabs/Lib/NativeWikiPage.php',
'Zotlabs\\Lib\\PConfig' => $baseDir . '/Zotlabs/Lib/PConfig.php',
'Zotlabs\\Lib\\Permcat' => $baseDir . '/Zotlabs/Lib/Permcat.php',
'Zotlabs\\Lib\\PermissionDescription' => $baseDir . '/Zotlabs/Lib/PermissionDescription.php',
@ -874,12 +874,12 @@ return array(
'Zotlabs\\Lib\\System' => $baseDir . '/Zotlabs/Lib/System.php',
'Zotlabs\\Lib\\Techlevels' => $baseDir . '/Zotlabs/Lib/Techlevels.php',
'Zotlabs\\Lib\\ThreadItem' => $baseDir . '/Zotlabs/Lib/ThreadItem.php',
'Zotlabs\\Lib\\ThreadListener' => $baseDir . '/Zotlabs/Lib/ThreadListener.php',
'Zotlabs\\Lib\\ThreadStream' => $baseDir . '/Zotlabs/Lib/ThreadStream.php',
'Zotlabs\\Lib\\Verify' => $baseDir . '/Zotlabs/Lib/Verify.php',
'Zotlabs\\Lib\\Webfinger' => $baseDir . '/Zotlabs/Lib/Webfinger.php',
'Zotlabs\\Lib\\XConfig' => $baseDir . '/Zotlabs/Lib/XConfig.php',
'Zotlabs\\Lib\\Zotfinger' => $baseDir . '/Zotlabs/Lib/Zotfinger.php',
'Zotlabs\\Module\\Achievements' => $baseDir . '/Zotlabs/Module/Achievements.php',
'Zotlabs\\Module\\Acl' => $baseDir . '/Zotlabs/Module/Acl.php',
'Zotlabs\\Module\\Admin' => $baseDir . '/Zotlabs/Module/Admin.php',
'Zotlabs\\Module\\Admin\\Account_edit' => $baseDir . '/Zotlabs/Module/Admin/Account_edit.php',
@ -894,15 +894,14 @@ return array(
'Zotlabs\\Module\\Admin\\Security' => $baseDir . '/Zotlabs/Module/Admin/Security.php',
'Zotlabs\\Module\\Admin\\Site' => $baseDir . '/Zotlabs/Module/Admin/Site.php',
'Zotlabs\\Module\\Admin\\Themes' => $baseDir . '/Zotlabs/Module/Admin/Themes.php',
'Zotlabs\\Module\\Affinity' => $baseDir . '/Zotlabs/Module/Affinity.php',
'Zotlabs\\Module\\Api' => $baseDir . '/Zotlabs/Module/Api.php',
'Zotlabs\\Module\\Appman' => $baseDir . '/Zotlabs/Module/Appman.php',
'Zotlabs\\Module\\Apporder' => $baseDir . '/Zotlabs/Module/Apporder.php',
'Zotlabs\\Module\\Apps' => $baseDir . '/Zotlabs/Module/Apps.php',
'Zotlabs\\Module\\Article_edit' => $baseDir . '/Zotlabs/Module/Article_edit.php',
'Zotlabs\\Module\\Articles' => $baseDir . '/Zotlabs/Module/Articles.php',
'Zotlabs\\Module\\Apschema' => $baseDir . '/Zotlabs/Module/Apschema.php',
'Zotlabs\\Module\\Attach' => $baseDir . '/Zotlabs/Module/Attach.php',
'Zotlabs\\Module\\Authorize' => $baseDir . '/Zotlabs/Module/Authorize.php',
'Zotlabs\\Module\\Authtest' => $baseDir . '/Zotlabs/Module/Authtest.php',
'Zotlabs\\Module\\Block' => $baseDir . '/Zotlabs/Module/Block.php',
'Zotlabs\\Module\\Blocks' => $baseDir . '/Zotlabs/Module/Blocks.php',
'Zotlabs\\Module\\Bookmarks' => $baseDir . '/Zotlabs/Module/Bookmarks.php',
@ -940,14 +939,13 @@ return array(
'Zotlabs\\Module\\Events' => $baseDir . '/Zotlabs/Module/Events.php',
'Zotlabs\\Module\\Fbrowser' => $baseDir . '/Zotlabs/Module/Fbrowser.php',
'Zotlabs\\Module\\Feed' => $baseDir . '/Zotlabs/Module/Feed.php',
'Zotlabs\\Module\\Fhublocs' => $baseDir . '/Zotlabs/Module/Fhublocs.php',
'Zotlabs\\Module\\File_upload' => $baseDir . '/Zotlabs/Module/File_upload.php',
'Zotlabs\\Module\\Filer' => $baseDir . '/Zotlabs/Module/Filer.php',
'Zotlabs\\Module\\Filerm' => $baseDir . '/Zotlabs/Module/Filerm.php',
'Zotlabs\\Module\\Filestorage' => $baseDir . '/Zotlabs/Module/Filestorage.php',
'Zotlabs\\Module\\Finger' => $baseDir . '/Zotlabs/Module/Finger.php',
'Zotlabs\\Module\\Follow' => $baseDir . '/Zotlabs/Module/Follow.php',
'Zotlabs\\Module\\Getfile' => $baseDir . '/Zotlabs/Module/Getfile.php',
'Zotlabs\\Module\\Go' => $baseDir . '/Zotlabs/Module/Go.php',
'Zotlabs\\Module\\Group' => $baseDir . '/Zotlabs/Module/Group.php',
'Zotlabs\\Module\\Hashtags' => $baseDir . '/Zotlabs/Module/Hashtags.php',
'Zotlabs\\Module\\Hcard' => $baseDir . '/Zotlabs/Module/Hcard.php',
@ -970,7 +968,6 @@ return array(
'Zotlabs\\Module\\Logout' => $baseDir . '/Zotlabs/Module/Logout.php',
'Zotlabs\\Module\\Lostpass' => $baseDir . '/Zotlabs/Module/Lostpass.php',
'Zotlabs\\Module\\Magic' => $baseDir . '/Zotlabs/Module/Magic.php',
'Zotlabs\\Module\\Mail' => $baseDir . '/Zotlabs/Module/Mail.php',
'Zotlabs\\Module\\Manage' => $baseDir . '/Zotlabs/Module/Manage.php',
'Zotlabs\\Module\\Menu' => $baseDir . '/Zotlabs/Module/Menu.php',
'Zotlabs\\Module\\Message' => $baseDir . '/Zotlabs/Module/Message.php',
@ -983,13 +980,12 @@ return array(
'Zotlabs\\Module\\Notes' => $baseDir . '/Zotlabs/Module/Notes.php',
'Zotlabs\\Module\\Notifications' => $baseDir . '/Zotlabs/Module/Notifications.php',
'Zotlabs\\Module\\Notify' => $baseDir . '/Zotlabs/Module/Notify.php',
'Zotlabs\\Module\\Nullbox' => $baseDir . '/Zotlabs/Module/Nullbox.php',
'Zotlabs\\Module\\OAuth2TestVehicle' => $baseDir . '/Zotlabs/Module/Oauth2testvehicle.php',
'Zotlabs\\Module\\Oauthinfo' => $baseDir . '/Zotlabs/Module/Oauthinfo.php',
'Zotlabs\\Module\\Ochannel' => $baseDir . '/Zotlabs/Module/Ochannel.php',
'Zotlabs\\Module\\Oembed' => $baseDir . '/Zotlabs/Module/Oembed.php',
'Zotlabs\\Module\\Oep' => $baseDir . '/Zotlabs/Module/Oep.php',
'Zotlabs\\Module\\Oexchange' => $baseDir . '/Zotlabs/Module/Oexchange.php',
'Zotlabs\\Module\\Ofeed' => $baseDir . '/Zotlabs/Module/Ofeed.php',
'Zotlabs\\Module\\Online' => $baseDir . '/Zotlabs/Module/Online.php',
'Zotlabs\\Module\\Owa' => $baseDir . '/Zotlabs/Module/Owa.php',
'Zotlabs\\Module\\Page' => $baseDir . '/Zotlabs/Module/Page.php',
@ -1001,8 +997,6 @@ return array(
'Zotlabs\\Module\\Ping' => $baseDir . '/Zotlabs/Module/Ping.php',
'Zotlabs\\Module\\Poco' => $baseDir . '/Zotlabs/Module/Poco.php',
'Zotlabs\\Module\\Poke' => $baseDir . '/Zotlabs/Module/Poke.php',
'Zotlabs\\Module\\Post' => $baseDir . '/Zotlabs/Module/Post.php',
'Zotlabs\\Module\\Prate' => $baseDir . '/Zotlabs/Module/Prate.php',
'Zotlabs\\Module\\Pretheme' => $baseDir . '/Zotlabs/Module/Pretheme.php',
'Zotlabs\\Module\\Probe' => $baseDir . '/Zotlabs/Module/Probe.php',
'Zotlabs\\Module\\Profile' => $baseDir . '/Zotlabs/Module/Profile.php',
@ -1012,9 +1006,6 @@ return array(
'Zotlabs\\Module\\Pubsites' => $baseDir . '/Zotlabs/Module/Pubsites.php',
'Zotlabs\\Module\\Pubstream' => $baseDir . '/Zotlabs/Module/Pubstream.php',
'Zotlabs\\Module\\Randprof' => $baseDir . '/Zotlabs/Module/Randprof.php',
'Zotlabs\\Module\\Rate' => $baseDir . '/Zotlabs/Module/Rate.php',
'Zotlabs\\Module\\Ratings' => $baseDir . '/Zotlabs/Module/Ratings.php',
'Zotlabs\\Module\\Ratingsearch' => $baseDir . '/Zotlabs/Module/Ratingsearch.php',
'Zotlabs\\Module\\Rbmark' => $baseDir . '/Zotlabs/Module/Rbmark.php',
'Zotlabs\\Module\\React' => $baseDir . '/Zotlabs/Module/React.php',
'Zotlabs\\Module\\Regdir' => $baseDir . '/Zotlabs/Module/Regdir.php',
@ -1034,6 +1025,7 @@ return array(
'Zotlabs\\Module\\Settings\\Display' => $baseDir . '/Zotlabs/Module/Settings/Display.php',
'Zotlabs\\Module\\Settings\\Featured' => $baseDir . '/Zotlabs/Module/Settings/Featured.php',
'Zotlabs\\Module\\Settings\\Features' => $baseDir . '/Zotlabs/Module/Settings/Features.php',
'Zotlabs\\Module\\Settings\\Network' => $baseDir . '/Zotlabs/Module/Settings/Network.php',
'Zotlabs\\Module\\Settings\\Oauth' => $baseDir . '/Zotlabs/Module/Settings/Oauth.php',
'Zotlabs\\Module\\Settings\\Oauth2' => $baseDir . '/Zotlabs/Module/Settings/Oauth2.php',
'Zotlabs\\Module\\Settings\\Permcats' => $baseDir . '/Zotlabs/Module/Settings/Permcats.php',
@ -1044,7 +1036,6 @@ return array(
'Zotlabs\\Module\\Siteinfo' => $baseDir . '/Zotlabs/Module/Siteinfo.php',
'Zotlabs\\Module\\Sitelist' => $baseDir . '/Zotlabs/Module/Sitelist.php',
'Zotlabs\\Module\\Smilies' => $baseDir . '/Zotlabs/Module/Smilies.php',
'Zotlabs\\Module\\Snap' => $baseDir . '/Zotlabs/Module/Snap.php',
'Zotlabs\\Module\\Sources' => $baseDir . '/Zotlabs/Module/Sources.php',
'Zotlabs\\Module\\Sslify' => $baseDir . '/Zotlabs/Module/Sslify.php',
'Zotlabs\\Module\\Starred' => $baseDir . '/Zotlabs/Module/Starred.php',
@ -1069,17 +1060,12 @@ return array(
'Zotlabs\\Module\\Webfinger' => $baseDir . '/Zotlabs/Module/Webfinger.php',
'Zotlabs\\Module\\Webpages' => $baseDir . '/Zotlabs/Module/Webpages.php',
'Zotlabs\\Module\\Well_known' => $baseDir . '/Zotlabs/Module/Well_known.php',
'Zotlabs\\Module\\Wfinger' => $baseDir . '/Zotlabs/Module/Wfinger.php',
'Zotlabs\\Module\\Wiki' => $baseDir . '/Zotlabs/Module/Wiki.php',
'Zotlabs\\Module\\Xchan' => $baseDir . '/Zotlabs/Module/Xchan.php',
'Zotlabs\\Module\\Xpoco' => $baseDir . '/Zotlabs/Module/Xpoco.php',
'Zotlabs\\Module\\Xrd' => $baseDir . '/Zotlabs/Module/Xrd.php',
'Zotlabs\\Module\\Xref' => $baseDir . '/Zotlabs/Module/Xref.php',
'Zotlabs\\Module\\Zfinger' => $baseDir . '/Zotlabs/Module/Zfinger.php',
'Zotlabs\\Module\\Zot' => $baseDir . '/Zotlabs/Module/Zot.php',
'Zotlabs\\Module\\Zot_probe' => $baseDir . '/Zotlabs/Module/Zot_probe.php',
'Zotlabs\\Module\\Zotfeed' => $baseDir . '/Zotlabs/Module/Zotfeed.php',
'Zotlabs\\Module\\Zping' => $baseDir . '/Zotlabs/Module/Zping.php',
'Zotlabs\\Render\\Comanche' => $baseDir . '/Zotlabs/Render/Comanche.php',
'Zotlabs\\Render\\SimpleTemplate' => $baseDir . '/Zotlabs/Render/SimpleTemplate.php',
'Zotlabs\\Render\\SmartyInterface' => $baseDir . '/Zotlabs/Render/SmartyInterface.php',
@ -1319,6 +1305,7 @@ return array(
'Zotlabs\\Update\\_1217' => $baseDir . '/Zotlabs/Update/_1217.php',
'Zotlabs\\Update\\_1218' => $baseDir . '/Zotlabs/Update/_1218.php',
'Zotlabs\\Update\\_1219' => $baseDir . '/Zotlabs/Update/_1219.php',
'Zotlabs\\Update\\_1220' => $baseDir . '/Zotlabs/Update/_1220.php',
'Zotlabs\\Web\\CheckJS' => $baseDir . '/Zotlabs/Web/CheckJS.php',
'Zotlabs\\Web\\Controller' => $baseDir . '/Zotlabs/Web/Controller.php',
'Zotlabs\\Web\\HTTPHeaders' => $baseDir . '/Zotlabs/Web/HTTPHeaders.php',
@ -1331,7 +1318,6 @@ return array(
'Zotlabs\\Web\\WebServer' => $baseDir . '/Zotlabs/Web/WebServer.php',
'Zotlabs\\Widget\\Activity' => $baseDir . '/Zotlabs/Widget/Activity.php',
'Zotlabs\\Widget\\Activity_filter' => $baseDir . '/Zotlabs/Widget/Activity_filter.php',
'Zotlabs\\Widget\\Activity_order' => $baseDir . '/Zotlabs/Widget/Activity_order.php',
'Zotlabs\\Widget\\Admin' => $baseDir . '/Zotlabs/Widget/Admin.php',
'Zotlabs\\Widget\\Affinity' => $baseDir . '/Zotlabs/Widget/Affinity.php',
'Zotlabs\\Widget\\Album' => $baseDir . '/Zotlabs/Widget/Album.php',
@ -1381,6 +1367,7 @@ return array(
'Zotlabs\\Widget\\Settings_menu' => $baseDir . '/Zotlabs/Widget/Settings_menu.php',
'Zotlabs\\Widget\\Shortprofile' => $baseDir . '/Zotlabs/Widget/Shortprofile.php',
'Zotlabs\\Widget\\Sitesearch' => $baseDir . '/Zotlabs/Widget/Sitesearch.php',
'Zotlabs\\Widget\\Stream_order' => $baseDir . '/Zotlabs/Widget/Stream_order.php',
'Zotlabs\\Widget\\Suggestedchats' => $baseDir . '/Zotlabs/Widget/Suggestedchats.php',
'Zotlabs\\Widget\\Suggestions' => $baseDir . '/Zotlabs/Widget/Suggestions.php',
'Zotlabs\\Widget\\Tagcloud' => $baseDir . '/Zotlabs/Widget/Tagcloud.php',
@ -1388,9 +1375,6 @@ return array(
'Zotlabs\\Widget\\Tasklist' => $baseDir . '/Zotlabs/Widget/Tasklist.php',
'Zotlabs\\Widget\\Vcard' => $baseDir . '/Zotlabs/Widget/Vcard.php',
'Zotlabs\\Widget\\Website_portation_tools' => $baseDir . '/Zotlabs/Widget/Website_portation_tools.php',
'Zotlabs\\Widget\\Wiki_list' => $baseDir . '/Zotlabs/Widget/Wiki_list.php',
'Zotlabs\\Widget\\Wiki_page_history' => $baseDir . '/Zotlabs/Widget/Wiki_page_history.php',
'Zotlabs\\Widget\\Wiki_pages' => $baseDir . '/Zotlabs/Widget/Wiki_pages.php',
'Zotlabs\\Widget\\Zcard' => $baseDir . '/Zotlabs/Widget/Zcard.php',
'Zotlabs\\Zot6\\Finger' => $baseDir . '/Zotlabs/Zot6/Finger.php',
'Zotlabs\\Zot6\\HTTPSig' => $baseDir . '/Zotlabs/Zot6/HTTPSig.php',

View file

@ -12,8 +12,10 @@ return array(
'a1cce3d26cc15c00fcd0b3354bd72c88' => $vendorDir . '/sabre/event/lib/Promise/functions.php',
'3569eecfeed3bcf0bad3c998a494ecb8' => $vendorDir . '/sabre/xml/lib/Deserializer/functions.php',
'93aa591bc4ca510c520999e34229ee79' => $vendorDir . '/sabre/xml/lib/Serializer/functions.php',
'757772e28a0943a9afe83def8db95bdf' => $vendorDir . '/mf2/mf2/Mf2/Parser.php',
'ebdb698ed4152ae445614b69b5e4bb6a' => $vendorDir . '/sabre/http/lib/functions.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
'2cffec82183ee1cea088009cef9a6fc3' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
'20ed976102eb0f85eff007c4d1dc1db8' => $vendorDir . '/indieweb/rel-me/RelMe.php',
'f084d01b0a599f67676cffef638aa95b' => $vendorDir . '/smarty/smarty/libs/bootstrap.php',
);

View file

@ -13,9 +13,11 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'a1cce3d26cc15c00fcd0b3354bd72c88' => __DIR__ . '/..' . '/sabre/event/lib/Promise/functions.php',
'3569eecfeed3bcf0bad3c998a494ecb8' => __DIR__ . '/..' . '/sabre/xml/lib/Deserializer/functions.php',
'93aa591bc4ca510c520999e34229ee79' => __DIR__ . '/..' . '/sabre/xml/lib/Serializer/functions.php',
'757772e28a0943a9afe83def8db95bdf' => __DIR__ . '/..' . '/mf2/mf2/Mf2/Parser.php',
'ebdb698ed4152ae445614b69b5e4bb6a' => __DIR__ . '/..' . '/sabre/http/lib/functions.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
'2cffec82183ee1cea088009cef9a6fc3' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
'20ed976102eb0f85eff007c4d1dc1db8' => __DIR__ . '/..' . '/indieweb/rel-me/RelMe.php',
'f084d01b0a599f67676cffef638aa95b' => __DIR__ . '/..' . '/smarty/smarty/libs/bootstrap.php',
);
@ -468,6 +470,7 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'League\\HTMLToMarkdown\\ElementInterface' => __DIR__ . '/..' . '/league/html-to-markdown/src/ElementInterface.php',
'League\\HTMLToMarkdown\\Environment' => __DIR__ . '/..' . '/league/html-to-markdown/src/Environment.php',
'League\\HTMLToMarkdown\\HtmlConverter' => __DIR__ . '/..' . '/league/html-to-markdown/src/HtmlConverter.php',
'League\\HTMLToMarkdown\\HtmlConverterInterface' => __DIR__ . '/..' . '/league/html-to-markdown/src/HtmlConverterInterface.php',
'Michelf\\Markdown' => __DIR__ . '/..' . '/michelf/php-markdown/Michelf/Markdown.php',
'Michelf\\MarkdownExtra' => __DIR__ . '/..' . '/michelf/php-markdown/Michelf/MarkdownExtra.php',
'Michelf\\MarkdownInterface' => __DIR__ . '/..' . '/michelf/php-markdown/Michelf/MarkdownInterface.php',
@ -998,8 +1001,8 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Daemon\\Onepoll' => __DIR__ . '/../..' . '/Zotlabs/Daemon/Onepoll.php',
'Zotlabs\\Daemon\\Poller' => __DIR__ . '/../..' . '/Zotlabs/Daemon/Poller.php',
'Zotlabs\\Daemon\\Queue' => __DIR__ . '/../..' . '/Zotlabs/Daemon/Queue.php',
'Zotlabs\\Daemon\\Ratenotif' => __DIR__ . '/../..' . '/Zotlabs/Daemon/Ratenotif.php',
'Zotlabs\\Daemon\\Thumbnail' => __DIR__ . '/../..' . '/Zotlabs/Daemon/Thumbnail.php',
'Zotlabs\\Daemon\\Xchan_photo' => __DIR__ . '/../..' . '/Zotlabs/Daemon/Xchan_photo.php',
'Zotlabs\\Extend\\Hook' => __DIR__ . '/../..' . '/Zotlabs/Extend/Hook.php',
'Zotlabs\\Extend\\Route' => __DIR__ . '/../..' . '/Zotlabs/Extend/Route.php',
'Zotlabs\\Extend\\Widget' => __DIR__ . '/../..' . '/Zotlabs/Extend/Widget.php',
@ -1018,6 +1021,7 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Lib\\Config' => __DIR__ . '/../..' . '/Zotlabs/Lib/Config.php',
'Zotlabs\\Lib\\DB_Upgrade' => __DIR__ . '/../..' . '/Zotlabs/Lib/DB_Upgrade.php',
'Zotlabs\\Lib\\DReport' => __DIR__ . '/../..' . '/Zotlabs/Lib/DReport.php',
'Zotlabs\\Lib\\Discover' => __DIR__ . '/../..' . '/Zotlabs/Lib/Discover.php',
'Zotlabs\\Lib\\Enotify' => __DIR__ . '/../..' . '/Zotlabs/Lib/Enotify.php',
'Zotlabs\\Lib\\ExtendedZip' => __DIR__ . '/../..' . '/Zotlabs/Lib/ExtendedZip.php',
'Zotlabs\\Lib\\Group' => __DIR__ . '/../..' . '/Zotlabs/Lib/Group.php',
@ -1030,8 +1034,6 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Lib\\Libzotdir' => __DIR__ . '/../..' . '/Zotlabs/Lib/Libzotdir.php',
'Zotlabs\\Lib\\MarkdownSoap' => __DIR__ . '/../..' . '/Zotlabs/Lib/MarkdownSoap.php',
'Zotlabs\\Lib\\MessageFilter' => __DIR__ . '/../..' . '/Zotlabs/Lib/MessageFilter.php',
'Zotlabs\\Lib\\NativeWiki' => __DIR__ . '/../..' . '/Zotlabs/Lib/NativeWiki.php',
'Zotlabs\\Lib\\NativeWikiPage' => __DIR__ . '/../..' . '/Zotlabs/Lib/NativeWikiPage.php',
'Zotlabs\\Lib\\PConfig' => __DIR__ . '/../..' . '/Zotlabs/Lib/PConfig.php',
'Zotlabs\\Lib\\Permcat' => __DIR__ . '/../..' . '/Zotlabs/Lib/Permcat.php',
'Zotlabs\\Lib\\PermissionDescription' => __DIR__ . '/../..' . '/Zotlabs/Lib/PermissionDescription.php',
@ -1042,12 +1044,12 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Lib\\System' => __DIR__ . '/../..' . '/Zotlabs/Lib/System.php',
'Zotlabs\\Lib\\Techlevels' => __DIR__ . '/../..' . '/Zotlabs/Lib/Techlevels.php',
'Zotlabs\\Lib\\ThreadItem' => __DIR__ . '/../..' . '/Zotlabs/Lib/ThreadItem.php',
'Zotlabs\\Lib\\ThreadListener' => __DIR__ . '/../..' . '/Zotlabs/Lib/ThreadListener.php',
'Zotlabs\\Lib\\ThreadStream' => __DIR__ . '/../..' . '/Zotlabs/Lib/ThreadStream.php',
'Zotlabs\\Lib\\Verify' => __DIR__ . '/../..' . '/Zotlabs/Lib/Verify.php',
'Zotlabs\\Lib\\Webfinger' => __DIR__ . '/../..' . '/Zotlabs/Lib/Webfinger.php',
'Zotlabs\\Lib\\XConfig' => __DIR__ . '/../..' . '/Zotlabs/Lib/XConfig.php',
'Zotlabs\\Lib\\Zotfinger' => __DIR__ . '/../..' . '/Zotlabs/Lib/Zotfinger.php',
'Zotlabs\\Module\\Achievements' => __DIR__ . '/../..' . '/Zotlabs/Module/Achievements.php',
'Zotlabs\\Module\\Acl' => __DIR__ . '/../..' . '/Zotlabs/Module/Acl.php',
'Zotlabs\\Module\\Admin' => __DIR__ . '/../..' . '/Zotlabs/Module/Admin.php',
'Zotlabs\\Module\\Admin\\Account_edit' => __DIR__ . '/../..' . '/Zotlabs/Module/Admin/Account_edit.php',
@ -1062,15 +1064,14 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Module\\Admin\\Security' => __DIR__ . '/../..' . '/Zotlabs/Module/Admin/Security.php',
'Zotlabs\\Module\\Admin\\Site' => __DIR__ . '/../..' . '/Zotlabs/Module/Admin/Site.php',
'Zotlabs\\Module\\Admin\\Themes' => __DIR__ . '/../..' . '/Zotlabs/Module/Admin/Themes.php',
'Zotlabs\\Module\\Affinity' => __DIR__ . '/../..' . '/Zotlabs/Module/Affinity.php',
'Zotlabs\\Module\\Api' => __DIR__ . '/../..' . '/Zotlabs/Module/Api.php',
'Zotlabs\\Module\\Appman' => __DIR__ . '/../..' . '/Zotlabs/Module/Appman.php',
'Zotlabs\\Module\\Apporder' => __DIR__ . '/../..' . '/Zotlabs/Module/Apporder.php',
'Zotlabs\\Module\\Apps' => __DIR__ . '/../..' . '/Zotlabs/Module/Apps.php',
'Zotlabs\\Module\\Article_edit' => __DIR__ . '/../..' . '/Zotlabs/Module/Article_edit.php',
'Zotlabs\\Module\\Articles' => __DIR__ . '/../..' . '/Zotlabs/Module/Articles.php',
'Zotlabs\\Module\\Apschema' => __DIR__ . '/../..' . '/Zotlabs/Module/Apschema.php',
'Zotlabs\\Module\\Attach' => __DIR__ . '/../..' . '/Zotlabs/Module/Attach.php',
'Zotlabs\\Module\\Authorize' => __DIR__ . '/../..' . '/Zotlabs/Module/Authorize.php',
'Zotlabs\\Module\\Authtest' => __DIR__ . '/../..' . '/Zotlabs/Module/Authtest.php',
'Zotlabs\\Module\\Block' => __DIR__ . '/../..' . '/Zotlabs/Module/Block.php',
'Zotlabs\\Module\\Blocks' => __DIR__ . '/../..' . '/Zotlabs/Module/Blocks.php',
'Zotlabs\\Module\\Bookmarks' => __DIR__ . '/../..' . '/Zotlabs/Module/Bookmarks.php',
@ -1108,14 +1109,13 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Module\\Events' => __DIR__ . '/../..' . '/Zotlabs/Module/Events.php',
'Zotlabs\\Module\\Fbrowser' => __DIR__ . '/../..' . '/Zotlabs/Module/Fbrowser.php',
'Zotlabs\\Module\\Feed' => __DIR__ . '/../..' . '/Zotlabs/Module/Feed.php',
'Zotlabs\\Module\\Fhublocs' => __DIR__ . '/../..' . '/Zotlabs/Module/Fhublocs.php',
'Zotlabs\\Module\\File_upload' => __DIR__ . '/../..' . '/Zotlabs/Module/File_upload.php',
'Zotlabs\\Module\\Filer' => __DIR__ . '/../..' . '/Zotlabs/Module/Filer.php',
'Zotlabs\\Module\\Filerm' => __DIR__ . '/../..' . '/Zotlabs/Module/Filerm.php',
'Zotlabs\\Module\\Filestorage' => __DIR__ . '/../..' . '/Zotlabs/Module/Filestorage.php',
'Zotlabs\\Module\\Finger' => __DIR__ . '/../..' . '/Zotlabs/Module/Finger.php',
'Zotlabs\\Module\\Follow' => __DIR__ . '/../..' . '/Zotlabs/Module/Follow.php',
'Zotlabs\\Module\\Getfile' => __DIR__ . '/../..' . '/Zotlabs/Module/Getfile.php',
'Zotlabs\\Module\\Go' => __DIR__ . '/../..' . '/Zotlabs/Module/Go.php',
'Zotlabs\\Module\\Group' => __DIR__ . '/../..' . '/Zotlabs/Module/Group.php',
'Zotlabs\\Module\\Hashtags' => __DIR__ . '/../..' . '/Zotlabs/Module/Hashtags.php',
'Zotlabs\\Module\\Hcard' => __DIR__ . '/../..' . '/Zotlabs/Module/Hcard.php',
@ -1138,7 +1138,6 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Module\\Logout' => __DIR__ . '/../..' . '/Zotlabs/Module/Logout.php',
'Zotlabs\\Module\\Lostpass' => __DIR__ . '/../..' . '/Zotlabs/Module/Lostpass.php',
'Zotlabs\\Module\\Magic' => __DIR__ . '/../..' . '/Zotlabs/Module/Magic.php',
'Zotlabs\\Module\\Mail' => __DIR__ . '/../..' . '/Zotlabs/Module/Mail.php',
'Zotlabs\\Module\\Manage' => __DIR__ . '/../..' . '/Zotlabs/Module/Manage.php',
'Zotlabs\\Module\\Menu' => __DIR__ . '/../..' . '/Zotlabs/Module/Menu.php',
'Zotlabs\\Module\\Message' => __DIR__ . '/../..' . '/Zotlabs/Module/Message.php',
@ -1151,13 +1150,12 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Module\\Notes' => __DIR__ . '/../..' . '/Zotlabs/Module/Notes.php',
'Zotlabs\\Module\\Notifications' => __DIR__ . '/../..' . '/Zotlabs/Module/Notifications.php',
'Zotlabs\\Module\\Notify' => __DIR__ . '/../..' . '/Zotlabs/Module/Notify.php',
'Zotlabs\\Module\\Nullbox' => __DIR__ . '/../..' . '/Zotlabs/Module/Nullbox.php',
'Zotlabs\\Module\\OAuth2TestVehicle' => __DIR__ . '/../..' . '/Zotlabs/Module/Oauth2testvehicle.php',
'Zotlabs\\Module\\Oauthinfo' => __DIR__ . '/../..' . '/Zotlabs/Module/Oauthinfo.php',
'Zotlabs\\Module\\Ochannel' => __DIR__ . '/../..' . '/Zotlabs/Module/Ochannel.php',
'Zotlabs\\Module\\Oembed' => __DIR__ . '/../..' . '/Zotlabs/Module/Oembed.php',
'Zotlabs\\Module\\Oep' => __DIR__ . '/../..' . '/Zotlabs/Module/Oep.php',
'Zotlabs\\Module\\Oexchange' => __DIR__ . '/../..' . '/Zotlabs/Module/Oexchange.php',
'Zotlabs\\Module\\Ofeed' => __DIR__ . '/../..' . '/Zotlabs/Module/Ofeed.php',
'Zotlabs\\Module\\Online' => __DIR__ . '/../..' . '/Zotlabs/Module/Online.php',
'Zotlabs\\Module\\Owa' => __DIR__ . '/../..' . '/Zotlabs/Module/Owa.php',
'Zotlabs\\Module\\Page' => __DIR__ . '/../..' . '/Zotlabs/Module/Page.php',
@ -1169,8 +1167,6 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Module\\Ping' => __DIR__ . '/../..' . '/Zotlabs/Module/Ping.php',
'Zotlabs\\Module\\Poco' => __DIR__ . '/../..' . '/Zotlabs/Module/Poco.php',
'Zotlabs\\Module\\Poke' => __DIR__ . '/../..' . '/Zotlabs/Module/Poke.php',
'Zotlabs\\Module\\Post' => __DIR__ . '/../..' . '/Zotlabs/Module/Post.php',
'Zotlabs\\Module\\Prate' => __DIR__ . '/../..' . '/Zotlabs/Module/Prate.php',
'Zotlabs\\Module\\Pretheme' => __DIR__ . '/../..' . '/Zotlabs/Module/Pretheme.php',
'Zotlabs\\Module\\Probe' => __DIR__ . '/../..' . '/Zotlabs/Module/Probe.php',
'Zotlabs\\Module\\Profile' => __DIR__ . '/../..' . '/Zotlabs/Module/Profile.php',
@ -1180,9 +1176,6 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Module\\Pubsites' => __DIR__ . '/../..' . '/Zotlabs/Module/Pubsites.php',
'Zotlabs\\Module\\Pubstream' => __DIR__ . '/../..' . '/Zotlabs/Module/Pubstream.php',
'Zotlabs\\Module\\Randprof' => __DIR__ . '/../..' . '/Zotlabs/Module/Randprof.php',
'Zotlabs\\Module\\Rate' => __DIR__ . '/../..' . '/Zotlabs/Module/Rate.php',
'Zotlabs\\Module\\Ratings' => __DIR__ . '/../..' . '/Zotlabs/Module/Ratings.php',
'Zotlabs\\Module\\Ratingsearch' => __DIR__ . '/../..' . '/Zotlabs/Module/Ratingsearch.php',
'Zotlabs\\Module\\Rbmark' => __DIR__ . '/../..' . '/Zotlabs/Module/Rbmark.php',
'Zotlabs\\Module\\React' => __DIR__ . '/../..' . '/Zotlabs/Module/React.php',
'Zotlabs\\Module\\Regdir' => __DIR__ . '/../..' . '/Zotlabs/Module/Regdir.php',
@ -1202,6 +1195,7 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Module\\Settings\\Display' => __DIR__ . '/../..' . '/Zotlabs/Module/Settings/Display.php',
'Zotlabs\\Module\\Settings\\Featured' => __DIR__ . '/../..' . '/Zotlabs/Module/Settings/Featured.php',
'Zotlabs\\Module\\Settings\\Features' => __DIR__ . '/../..' . '/Zotlabs/Module/Settings/Features.php',
'Zotlabs\\Module\\Settings\\Network' => __DIR__ . '/../..' . '/Zotlabs/Module/Settings/Network.php',
'Zotlabs\\Module\\Settings\\Oauth' => __DIR__ . '/../..' . '/Zotlabs/Module/Settings/Oauth.php',
'Zotlabs\\Module\\Settings\\Oauth2' => __DIR__ . '/../..' . '/Zotlabs/Module/Settings/Oauth2.php',
'Zotlabs\\Module\\Settings\\Permcats' => __DIR__ . '/../..' . '/Zotlabs/Module/Settings/Permcats.php',
@ -1212,7 +1206,6 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Module\\Siteinfo' => __DIR__ . '/../..' . '/Zotlabs/Module/Siteinfo.php',
'Zotlabs\\Module\\Sitelist' => __DIR__ . '/../..' . '/Zotlabs/Module/Sitelist.php',
'Zotlabs\\Module\\Smilies' => __DIR__ . '/../..' . '/Zotlabs/Module/Smilies.php',
'Zotlabs\\Module\\Snap' => __DIR__ . '/../..' . '/Zotlabs/Module/Snap.php',
'Zotlabs\\Module\\Sources' => __DIR__ . '/../..' . '/Zotlabs/Module/Sources.php',
'Zotlabs\\Module\\Sslify' => __DIR__ . '/../..' . '/Zotlabs/Module/Sslify.php',
'Zotlabs\\Module\\Starred' => __DIR__ . '/../..' . '/Zotlabs/Module/Starred.php',
@ -1237,17 +1230,12 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Module\\Webfinger' => __DIR__ . '/../..' . '/Zotlabs/Module/Webfinger.php',
'Zotlabs\\Module\\Webpages' => __DIR__ . '/../..' . '/Zotlabs/Module/Webpages.php',
'Zotlabs\\Module\\Well_known' => __DIR__ . '/../..' . '/Zotlabs/Module/Well_known.php',
'Zotlabs\\Module\\Wfinger' => __DIR__ . '/../..' . '/Zotlabs/Module/Wfinger.php',
'Zotlabs\\Module\\Wiki' => __DIR__ . '/../..' . '/Zotlabs/Module/Wiki.php',
'Zotlabs\\Module\\Xchan' => __DIR__ . '/../..' . '/Zotlabs/Module/Xchan.php',
'Zotlabs\\Module\\Xpoco' => __DIR__ . '/../..' . '/Zotlabs/Module/Xpoco.php',
'Zotlabs\\Module\\Xrd' => __DIR__ . '/../..' . '/Zotlabs/Module/Xrd.php',
'Zotlabs\\Module\\Xref' => __DIR__ . '/../..' . '/Zotlabs/Module/Xref.php',
'Zotlabs\\Module\\Zfinger' => __DIR__ . '/../..' . '/Zotlabs/Module/Zfinger.php',
'Zotlabs\\Module\\Zot' => __DIR__ . '/../..' . '/Zotlabs/Module/Zot.php',
'Zotlabs\\Module\\Zot_probe' => __DIR__ . '/../..' . '/Zotlabs/Module/Zot_probe.php',
'Zotlabs\\Module\\Zotfeed' => __DIR__ . '/../..' . '/Zotlabs/Module/Zotfeed.php',
'Zotlabs\\Module\\Zping' => __DIR__ . '/../..' . '/Zotlabs/Module/Zping.php',
'Zotlabs\\Render\\Comanche' => __DIR__ . '/../..' . '/Zotlabs/Render/Comanche.php',
'Zotlabs\\Render\\SimpleTemplate' => __DIR__ . '/../..' . '/Zotlabs/Render/SimpleTemplate.php',
'Zotlabs\\Render\\SmartyInterface' => __DIR__ . '/../..' . '/Zotlabs/Render/SmartyInterface.php',
@ -1487,6 +1475,7 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Update\\_1217' => __DIR__ . '/../..' . '/Zotlabs/Update/_1217.php',
'Zotlabs\\Update\\_1218' => __DIR__ . '/../..' . '/Zotlabs/Update/_1218.php',
'Zotlabs\\Update\\_1219' => __DIR__ . '/../..' . '/Zotlabs/Update/_1219.php',
'Zotlabs\\Update\\_1220' => __DIR__ . '/../..' . '/Zotlabs/Update/_1220.php',
'Zotlabs\\Web\\CheckJS' => __DIR__ . '/../..' . '/Zotlabs/Web/CheckJS.php',
'Zotlabs\\Web\\Controller' => __DIR__ . '/../..' . '/Zotlabs/Web/Controller.php',
'Zotlabs\\Web\\HTTPHeaders' => __DIR__ . '/../..' . '/Zotlabs/Web/HTTPHeaders.php',
@ -1499,7 +1488,6 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Web\\WebServer' => __DIR__ . '/../..' . '/Zotlabs/Web/WebServer.php',
'Zotlabs\\Widget\\Activity' => __DIR__ . '/../..' . '/Zotlabs/Widget/Activity.php',
'Zotlabs\\Widget\\Activity_filter' => __DIR__ . '/../..' . '/Zotlabs/Widget/Activity_filter.php',
'Zotlabs\\Widget\\Activity_order' => __DIR__ . '/../..' . '/Zotlabs/Widget/Activity_order.php',
'Zotlabs\\Widget\\Admin' => __DIR__ . '/../..' . '/Zotlabs/Widget/Admin.php',
'Zotlabs\\Widget\\Affinity' => __DIR__ . '/../..' . '/Zotlabs/Widget/Affinity.php',
'Zotlabs\\Widget\\Album' => __DIR__ . '/../..' . '/Zotlabs/Widget/Album.php',
@ -1549,6 +1537,7 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Widget\\Settings_menu' => __DIR__ . '/../..' . '/Zotlabs/Widget/Settings_menu.php',
'Zotlabs\\Widget\\Shortprofile' => __DIR__ . '/../..' . '/Zotlabs/Widget/Shortprofile.php',
'Zotlabs\\Widget\\Sitesearch' => __DIR__ . '/../..' . '/Zotlabs/Widget/Sitesearch.php',
'Zotlabs\\Widget\\Stream_order' => __DIR__ . '/../..' . '/Zotlabs/Widget/Stream_order.php',
'Zotlabs\\Widget\\Suggestedchats' => __DIR__ . '/../..' . '/Zotlabs/Widget/Suggestedchats.php',
'Zotlabs\\Widget\\Suggestions' => __DIR__ . '/../..' . '/Zotlabs/Widget/Suggestions.php',
'Zotlabs\\Widget\\Tagcloud' => __DIR__ . '/../..' . '/Zotlabs/Widget/Tagcloud.php',
@ -1556,9 +1545,6 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Widget\\Tasklist' => __DIR__ . '/../..' . '/Zotlabs/Widget/Tasklist.php',
'Zotlabs\\Widget\\Vcard' => __DIR__ . '/../..' . '/Zotlabs/Widget/Vcard.php',
'Zotlabs\\Widget\\Website_portation_tools' => __DIR__ . '/../..' . '/Zotlabs/Widget/Website_portation_tools.php',
'Zotlabs\\Widget\\Wiki_list' => __DIR__ . '/../..' . '/Zotlabs/Widget/Wiki_list.php',
'Zotlabs\\Widget\\Wiki_page_history' => __DIR__ . '/../..' . '/Zotlabs/Widget/Wiki_page_history.php',
'Zotlabs\\Widget\\Wiki_pages' => __DIR__ . '/../..' . '/Zotlabs/Widget/Wiki_pages.php',
'Zotlabs\\Widget\\Zcard' => __DIR__ . '/../..' . '/Zotlabs/Widget/Zcard.php',
'Zotlabs\\Zot6\\Finger' => __DIR__ . '/../..' . '/Zotlabs/Zot6/Finger.php',
'Zotlabs\\Zot6\\HTTPSig' => __DIR__ . '/../..' . '/Zotlabs/Zot6/HTTPSig.php',

View file

@ -155,18 +155,55 @@
]
},
{
"name": "league/html-to-markdown",
"version": "4.7.0",
"version_normalized": "4.7.0.0",
"name": "indieweb/rel-me",
"version": "dev-master",
"version_normalized": "9999999-dev",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/html-to-markdown.git",
"reference": "76c076483cef89860d32a3fd25312f5a42848a8c"
"url": "https://github.com/indieweb/rel-me.git",
"reference": "6a6c9de41f5b18ef99243340a365949f2c47df0e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/76c076483cef89860d32a3fd25312f5a42848a8c",
"reference": "76c076483cef89860d32a3fd25312f5a42848a8c",
"url": "https://api.github.com/repos/indieweb/rel-me/zipball/6a6c9de41f5b18ef99243340a365949f2c47df0e",
"reference": "6a6c9de41f5b18ef99243340a365949f2c47df0e",
"shasum": ""
},
"require": {
"mf2/mf2": "0.2.*",
"php": ">=5.3"
},
"require-dev": {
"barnabywalters/mf-cleaner": "*",
"phpunit/phpunit": "*"
},
"time": "2016-09-08T17:20:47+00:00",
"type": "library",
"installation-source": "source",
"autoload": {
"files": [
"RelMe.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Functions for discovering, consuming and verifying rel-me microformat"
},
{
"name": "league/html-to-markdown",
"version": "4.8.0",
"version_normalized": "4.8.0.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/html-to-markdown.git",
"reference": "f9a879a068c68ff47b722de63f58bec79e448f9d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/html-to-markdown/zipball/f9a879a068c68ff47b722de63f58bec79e448f9d",
"reference": "f9a879a068c68ff47b722de63f58bec79e448f9d",
"shasum": ""
},
"require": {
@ -179,14 +216,14 @@
"phpunit/phpunit": "4.*",
"scrutinizer/ocular": "~1.1"
},
"time": "2018-05-19T23:47:12+00:00",
"time": "2018-09-18T12:18:08+00:00",
"bin": [
"bin/html-to-markdown"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.8-dev"
"dev-master": "4.9-dev"
}
},
"installation-source": "dist",
@ -200,17 +237,17 @@
"MIT"
],
"authors": [
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "http://www.colinodell.com",
"role": "Lead Developer"
},
{
"name": "Nick Cernis",
"email": "nick@cern.is",
"homepage": "http://modernnerd.net",
"role": "Original Author"
},
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "https://www.colinodell.com",
"role": "Lead Developer"
}
],
"description": "An HTML-to-markdown conversion helper for PHP",
@ -257,6 +294,61 @@
"tags"
]
},
{
"name": "mf2/mf2",
"version": "v0.2.12",
"version_normalized": "0.2.12.0",
"source": {
"type": "git",
"url": "https://github.com/indieweb/php-mf2.git",
"reference": "6701504876d6c9242eb310b35f41d40d9785ab4e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/indieweb/php-mf2/zipball/6701504876d6c9242eb310b35f41d40d9785ab4e",
"reference": "6701504876d6c9242eb310b35f41d40d9785ab4e",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"suggest": {
"barnabywalters/mf-cleaner": "To more easily handle the canonical data php-mf2 gives you"
},
"time": "2015-07-12T14:10:01+00:00",
"bin": [
"bin/fetch-mf2",
"bin/parse-mf2"
],
"type": "library",
"installation-source": "dist",
"autoload": {
"files": [
"Mf2/Parser.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Barnaby Walters",
"homepage": "http://waterpigs.co.uk"
}
],
"description": "A pure, generic microformats2 parser — makes HTML as easy to consume as a JSON API",
"keywords": [
"html",
"microformats",
"microformats 2",
"parser",
"semantic"
]
},
{
"name": "michelf/php-markdown",
"version": "1.8.0",
@ -1029,23 +1121,23 @@
},
{
"name": "smarty/smarty",
"version": "v3.1.32",
"version_normalized": "3.1.32.0",
"version": "v3.1.33",
"version_normalized": "3.1.33.0",
"source": {
"type": "git",
"url": "https://github.com/smarty-php/smarty.git",
"reference": "ac9d4b587e5bf53381e21881820a9830765cb459"
"reference": "dd55b23121e55a3b4f1af90a707a6c4e5969530f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/smarty-php/smarty/zipball/ac9d4b587e5bf53381e21881820a9830765cb459",
"reference": "ac9d4b587e5bf53381e21881820a9830765cb459",
"url": "https://api.github.com/repos/smarty-php/smarty/zipball/dd55b23121e55a3b4f1af90a707a6c4e5969530f",
"reference": "dd55b23121e55a3b4f1af90a707a6c4e5969530f",
"shasum": ""
},
"require": {
"php": ">=5.2"
},
"time": "2018-04-24T14:53:33+00:00",
"time": "2018-09-12T20:54:16+00:00",
"type": "library",
"extra": {
"branch-alias": {

3
vendor/indieweb/rel-me/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
.DS_Store
/vendor/
composer.phar

10
vendor/indieweb/rel-me/.travis.yml vendored Normal file
View file

@ -0,0 +1,10 @@
language: php
php:
- 5.3
- 5.4
- 5.5
- nightly
sudo: false
before_script:
- composer self-update
- composer install --prefer-dist --no-interaction

80
vendor/indieweb/rel-me/README.md vendored Normal file
View file

@ -0,0 +1,80 @@
# rel-me
A set of PHP functions for discovering, consuming and verifying the [rel-me](http://microformats.org/wiki/rel-me) microformat. This is mainly useful for implementing [relmeauth](http://indiewebcamp.com/relmeauth).
[![Build Status](https://travis-ci.org/indieweb/rel-me.svg?branch=master)](http://travis-ci.org/indieweb/rel-me)
## Usage
Install using [composer](https://getcomposer.org) with `./composer.phar require indieweb/rel-me:dev-master`
### Resolve and test a profile URL
```php
<?php
// Register the composer autoloader (assumed in future code samples.)
require 'vendor/autoload.php';
// This is a profile URL a user has given you, or you have parsed from a page somewhere.
$givenProfileUrl = 'http://waterpigs.co.uk';
list($resolvedProfileUrl, $isSecure, $redirectChain) = IndieWeb\relMeDocumentUrl($givenProfileUrl);
if ($isSecure) {
// $resolvedProfileUrl is the final resolved profile URL derived from the given one.
} else {
echo 'Your profile URL redirected insecurely (changed protocols)';
// Here you might use the $redirectChain (list of URLs) to present a more useful error message.
}
```
### Find all `rel=me` links on a page
```php
// This should be derived and checked using relMeDocumentUrl().
$resolvedProfileUrl = 'http://waterpigs.co.uk';
$relMeLinks = IndieWeb\relMeLinks($resolvedProfileUrl);
```
### Test whether or not a backlinking `rel=me` URL can be securely considered to link
```php
// A rel=me link from a silo profile page.
$inboundRelMeUrl = 'http://t.co/qhZqdUcTbQ';
// The derived profile document URL to test for matches of.
$meUrl = 'http://waterpigs.co.uk';
list($matches, $secure, $redirectChain) = IndieWeb\backlinkingRelMeUrlMatches($inboundRelMeUrl, $meUrl);
if ($matches) {
if ($secure) {
echo "{$inboundRelMeUrl} is a secure, valid link to {$meUrl}";
} else {
echo "{$inboundRelMeUrl} isnt a secure link to {$meUrl} because it redirects insecurely (changes protocols)";
// Here you might use the $redirectChain (list of URLs) to present a more useful error message.
}
} else {
echo "None of that silo backlinks redirect chain match {$meUrl}";
}
```
### Utility Functions
* `string $url = IndieWeb\unparseUrl(array $parsedUrl)` takes the output of core `parse_url()` and makes it into a URL again
* `string $url = IndieWeb\normaliseUrl($url)` normalises a URL by parsing, then unparsing it
* `list(string $body, array $headers, array $info) = IndieWeb\httpGet($url)` performs a basic HTTP GET on a URL
* `string $nextUrl | null = IndieWeb\followOneRedirect($url)` fetches a URL and returns the redirect URL if its a redirect, else `null`
* `bool $match = IndieWeb\urlsMatchOtherThanScheme($url1, $url2)` compares two URLs and returns whether or not they are the same, ignoring differences in their scheme
## Testing
Run the test suite with `./vendor/bin/phpunit`
Theres also an experimental HTML+microformats test suite which can be run with `./tests/html-test-runner.php`
## Version History
### 0.1.0 2014-01-04
* Initial extraction from indiewebify.me, conversion into a composer package

226
vendor/indieweb/rel-me/RelMe.php vendored Normal file
View file

@ -0,0 +1,226 @@
<?php
namespace IndieWeb;
use DOMDocument;
use DOMXPath;
use Mf2; // for relative URL resolver
// force loading of resolveUrl function
class_exists('Mf2\Parser');
/**
* Adapted from php.net, added TESTING flag and header title case normalisation
*/
if (!function_exists('http_parse_headers') or defined('TESTING')) {
function http_parse_headers($raw_headers) {
$headers = array();
$key = '';
foreach (explode("\n", $raw_headers) as $i => $h) {
$h = explode(':', $h, 2);
$headerName = implode('-', array_map('ucfirst', explode('-', $h[0])));
// If dealing with a key:value line
if (isset($h[1])) {
if (!isset($headers[$headerName]))
$headers[$headerName] = trim($h[1]);
elseif (is_array($headers[$headerName])) {
$headers[$headerName] = array_merge($headers[$headerName], array(trim($h[1])));
} else {
$headers[$headerName] = array_merge(array($headers[$headerName]), array(trim($h[1])));
}
$key = $headerName;
} else {
// dealing with a continued line, $key is the last seen key
if (substr($h[0], 0, 1) == "\t")
$headers[$key] .= "\r\n\t" . trim($h[0]);
elseif (!$key) // I have no idea what this is supposed to be doing
$headers[0] = trim($h[0]);
}
}
return $headers;
}
}
/**
* Unparse URL
*
* Given an assoc. array of the form produced by parse_url, return a string
*
* Adapted from http://www.php.net/manual/en/function.parse-url.php#106731
*
* Note: the scheme and host are forced to lowercase to avoid case-sensitive issues.
*
* @param array $parsed_url
* @return string
*/
function unparseUrl(array $parsed_url) {
$user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
$pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
return implode('', array(
isset($parsed_url['scheme']) ? strtolower($parsed_url['scheme']) . '://' : '',
$user,
($user || $pass) ? "$pass@" : '',
isset($parsed_url['host']) ? strtolower($parsed_url['host']) : '',
isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '',
isset($parsed_url['path']) ? $parsed_url['path'] : '/',
isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '',
isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '',
));
}
function normaliseUrl($url) {
return $url === null ? null : unparseUrl(parse_url($url));
}
function httpGet($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$rawHeaders = mb_substr($response, 0, $info['header_size']);
$headers = http_parse_headers($rawHeaders);
$body = mb_substr($response, $info['header_size']);
return array($body, $headers, $info);
}
function followOneRedirect($url) {
list($body, $headers, $info) = httpGet($url);
if (strpos($info['http_code'], '3') === 0 and isset($headers['Location'])) {
return is_array($headers['Location'])
? current($headers['Location'])
: $headers['Location'];
} else {
return null;
}
}
/**
* rel-me Document URL
*
* Given a URL, resolves any redirects and returns the resolved URL, whether or not
* the redirect chain is secure (doesnt change protocol) and the redirect chain,
* for inspection.
*
* Example usage:
*
* list($profileUrl, $isSecure, $redirectChain) = IndieWeb\relMeDocumentUrl($me);
*
* $followOneRedirect defaults to IndieWeb\followOneRedirect but can be replaced for
* testing purposes.
*
* Returns [string URL, bool isSecure, array redirectChain]
* @return array
*/
function relMeDocumentUrl($url, $followOneRedirect = null) {
if (!is_callable($followOneRedirect))
$followOneRedirect = __NAMESPACE__ . '\followOneRedirect';
$previous = array();
$secure = true;
$is_https = false;
$currentUrl = $url;
while (true) {
// TODO: is resolving this URL correct behaviour here?
// should it be resolved just to the host?
$redirectedUrl = Mf2\resolveUrl($currentUrl, $followOneRedirect($currentUrl));
if ($redirectedUrl === null):
break;
elseif (in_array($redirectedUrl, $previous)):
break;
elseif ($is_https && parse_url($currentUrl, PHP_URL_SCHEME) !== parse_url($redirectedUrl, PHP_URL_SCHEME)):
$secure = false;
$previous[] = $currentUrl = $redirectedUrl;
break;
else:
if (parse_url($currentUrl, PHP_URL_SCHEME) == 'https') {
$is_https = true;
}
$currentUrl = $redirectedUrl;
$previous[] = $currentUrl;
endif;
}
return array($currentUrl, $secure, $previous);
}
/**
* rel-me links
* given the HTML and URL of a page, returns all the rel-me links found on that page
* @return array
*/
function relMeLinks($html, $url) {
$parser = new Mf2\Parser($html, $url);
$mf = $parser->parse();
$relMeLinks = @($mf['rels']['me'] ?: array());
return array_unique($relMeLinks);
}
/**
* URLs match other than scheme
* Given two URLs, checks if they are the same, ignorning their schemes
* @todo write tests for this
* @return bool
*/
function urlsMatchOtherThanScheme($url1, $url2) {
$p1 = parse_url($url1);
$p2 = parse_url($url2);
$p1['scheme'] = 'http';
$p2['scheme'] = 'http';
return unparseUrl($p1) === unparseUrl($p2);
}
/**
* Backlinking rel-me URL matches
*
* Used to check whether an inbound (silo to indie homepage) rel-me link can securely
* be considered to link to the indie profile URL. Given a back-linking URL and a profile
* URL, returns an array of [(bool) matches, (bool) secure, (array) redirect chain)]
*
* Example Usage:
*
* list($matches, $secure, $previous) = IndieWeb\backlinkingRelMeUrlMatches($inboundRelMeUrl, $meUrl);
*
* $followOneRedirect defaults to IndieWeb\followOneRedirect but can be replaced for
* testing purposes.
* @return array [matches, secure, previous]
*/
function backlinkingRelMeUrlMatches($backlinking, $meUrl, $followOneRedirect=null) {
if ($followOneRedirect === null)
$followOneRedirect = __NAMESPACE__ . '\followOneRedirect';
$meUrl = normaliseUrl($meUrl);
$previous = array();
$currentUrl = normaliseUrl($backlinking);
while (true) {
if ($currentUrl === $meUrl)
return array(true, true, $previous); // the URLs match and are secure
$redirectedUrl = normaliseUrl($followOneRedirect($currentUrl));
if ($redirectedUrl === null or in_array($redirectedUrl, $previous)):
return array(false, true, $previous); // The URLs dont match but are secure
elseif (parse_url($redirectedUrl, PHP_URL_SCHEME) !== parse_url($currentUrl, PHP_URL_SCHEME)):
if (urlsMatchOtherThanScheme($redirectedUrl, $meUrl)):
return array(true, false, $previous);
else:
return array(false, false, $previous);
endif;
else:
$currentUrl = $redirectedUrl;
$previous[] = $currentUrl;
endif;
}
}

16
vendor/indieweb/rel-me/composer.json vendored Normal file
View file

@ -0,0 +1,16 @@
{
"name": "indieweb/rel-me",
"description": "Functions for discovering, consuming and verifying rel-me microformat",
"license": "MIT",
"require": {
"php": ">=5.3",
"mf2/mf2": "0.2.*"
},
"require-dev": {
"phpunit/phpunit": "*",
"barnabywalters/mf-cleaner": "*"
},
"autoload": {
"files": ["RelMe.php"]
}
}

1071
vendor/indieweb/rel-me/composer.lock generated vendored Normal file

File diff suppressed because it is too large Load diff

7
vendor/indieweb/rel-me/phpunit.xml vendored Normal file
View file

@ -0,0 +1,7 @@
<phpunit bootstrap="tests/bootstrap.php">
<testsuites>
<testsuite name="Tests">
<directory>tests/</directory>
</testsuite>
</testsuites>
</phpunit>

View file

@ -4,6 +4,24 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
## [Unreleased][unreleased]
## [4.8.0] - 2018-09-18
### Added
- Added support for email auto-linking
- Added a new interface (`HtmlConverterInterface`) for the main `HtmlConverter` class
- Added additional test cases (#14)
### Changed
- The `italic_style` option now defaults to `'*'` so that in-word emphasis is handled properly (#75)
### Fixed
- Fixed several issues of `<code>` and `<pre>` tags not converting to blocks or inlines properly (#26, #70, #102, #140, #161, #162)
- Fixed in-word emphasis using underscores as delimiter (#75)
- Fixed character escaping inside of `<div>` elements
- Fixed header edge cases
### Deprecated
- The `bold_style` and `italic_style` options have been deprecated (#75)
## [4.7.0] - 2018-05-19
### Added
- Added `setOptions()` function for chainable calling (#149)
@ -217,7 +235,8 @@ not ideally set, so this releases fixes that. Moving forwards this should reduce
### Added
- Initial release
[unreleased]: https://github.com/thephpleague/html-to-markdown/compare/4.7.0...master
[unreleased]: https://github.com/thephpleague/html-to-markdown/compare/4.8.0...master
[4.8.0]: https://github.com/thephpleague/html-to-markdown/compare/4.7.0...4.8.0
[4.7.0]: https://github.com/thephpleague/html-to-markdown/compare/4.6.2...4.7.0
[4.6.2]: https://github.com/thephpleague/html-to-markdown/compare/4.6.1...4.6.2
[4.6.1]: https://github.com/thephpleague/html-to-markdown/compare/4.6.0...4.6.1

View file

@ -9,7 +9,7 @@
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "http://www.colinodell.com",
"homepage": "https://www.colinodell.com",
"role": "Lead Developer"
},
{
@ -42,7 +42,7 @@
"bin": ["bin/html-to-markdown"],
"extra": {
"branch-alias": {
"dev-master": "4.8-dev"
"dev-master": "4.9-dev"
}
}
}

View file

@ -12,6 +12,8 @@ class Configuration
public function __construct(array $config = array())
{
$this->config = $config;
$this->checkForDeprecatedOptions($config);
}
/**
@ -19,6 +21,7 @@ class Configuration
*/
public function merge(array $config = array())
{
$this->checkForDeprecatedOptions($config);
$this->config = array_replace_recursive($this->config, $config);
}
@ -27,6 +30,7 @@ class Configuration
*/
public function replace(array $config = array())
{
$this->checkForDeprecatedOptions($config);
$this->config = $config;
}
@ -36,6 +40,7 @@ class Configuration
*/
public function setOption($key, $value)
{
$this->checkForDeprecatedOptions(array($key => $value));
$this->config[$key] = $value;
}
@ -57,4 +62,15 @@ class Configuration
return $this->config[$key];
}
private function checkForDeprecatedOptions(array $config)
{
foreach ($config as $key => $value) {
if ($key === 'bold_style' && $value !== '**') {
@trigger_error('Customizing the bold_style option is deprecated and may be removed in the next major version', E_USER_DEPRECATED);
} elseif ($key === 'italic_style' && $value !== '*') {
@trigger_error('Customizing the italic_style option is deprecated and may be removed in the next major version', E_USER_DEPRECATED);
}
}
}
}

View file

@ -13,7 +13,7 @@ class CodeConverter implements ConverterInterface
*/
public function convert(ElementInterface $element)
{
$language = null;
$language = '';
// Checking for language class on the code block
$classes = $element->getAttribute('class');
@ -24,8 +24,7 @@ class CodeConverter implements ConverterInterface
foreach ($classes as $class) {
if (strpos($class, 'language-') !== false) {
// Found one, save it as the selected language and stop looping over the classes.
// The space after the language avoids gluing the actual code with the language tag
$language = str_replace('language-', '', $class) . ' ';
$language = str_replace('language-', '', $class);
break;
}
}
@ -39,14 +38,13 @@ class CodeConverter implements ConverterInterface
$code = preg_replace('/<code\b[^>]*>/', '', $code);
$code = str_replace('</code>', '', $code);
// Checking if the code has multiple lines
$lines = preg_split('/\r\n|\r|\n/', $code);
if (count($lines) > 1) {
// Multiple lines detected, adding three backticks and newlines
$markdown .= '```' . $language . "\n" . $code . "\n" . '```' . "\n\n";
// Checking if it's a code block or span
if ($this->shouldBeBlock($element, $code)) {
// Code block detected, newlines will be added in parent
$markdown .= '```' . $language . "\n" . $code . "\n" . '```';
} else {
// One line of code, wrapping it on one backtick.
$markdown .= '`' . $language . $code . '`';
// One line of code, wrapping it on one backtick, removing new lines
$markdown .= '`' . preg_replace('/\r\n|\r|\n/', '', $code) . '`';
}
return $markdown;
@ -59,4 +57,23 @@ class CodeConverter implements ConverterInterface
{
return array('code');
}
/**
* @param ElementInterface $element
* @param string $code
*
* @return bool
*/
private function shouldBeBlock(ElementInterface $element, $code)
{
if ($element->getParent()->getTagName() == 'pre') {
return true;
}
if (preg_match('/[^\s]` `/', $code)) {
return true;
}
return false;
}
}

View file

@ -34,6 +34,10 @@ class HeaderConverter implements ConverterInterface, ConfigurationAwareInterface
$level = (int) substr($element->getTagName(), 1, 1);
$style = $this->config->getOption('header_style', self::STYLE_SETEXT);
if (strlen($element->getValue()) === 0) {
return '';
}
if (($level === 1 || $level === 2) && !$element->isDescendantOf('blockquote') && $style === self::STYLE_SETEXT) {
return $this->createSetextHeader($level, $element->getValue());
}

View file

@ -21,6 +21,8 @@ class LinkConverter implements ConverterInterface
$markdown = '[' . $text . '](' . $href . ' "' . $title . '")';
} elseif ($href === $text && $this->isValidAutolink($href)) {
$markdown = '<' . $href . '>';
} elseif ($href === 'mailto:' . $text && $this->isValidEmail($text)) {
$markdown = '<' . $text . '>';
} else {
$markdown = '[' . $text . '](' . $href . ')';
}
@ -49,4 +51,15 @@ class LinkConverter implements ConverterInterface
{
return preg_match('/^[A-Za-z][A-Za-z0-9.+-]{1,31}:[^<>\x00-\x20]*/i', $href) === 1;
}
/**
* @param string $email
*
* @return bool
*/
private function isValidEmail($email)
{
// Email validation is messy business, but this should cover most cases
return filter_var($email, FILTER_VALIDATE_EMAIL);
}
}

View file

@ -13,8 +13,6 @@ class PreformattedConverter implements ConverterInterface
*/
public function convert(ElementInterface $element)
{
$markdown = '';
$pre_content = html_entity_decode($element->getChildrenAsString());
$pre_content = str_replace(array('<pre>', '</pre>'), '', $pre_content);
@ -28,28 +26,22 @@ class PreformattedConverter implements ConverterInterface
$firstBacktick = strpos(trim($pre_content), '`');
$lastBacktick = strrpos(trim($pre_content), '`');
if ($firstBacktick === 0 && $lastBacktick === strlen(trim($pre_content)) - 1) {
return $pre_content;
return $pre_content . "\n\n";
}
// If the execution reaches this point it means it's just a pre tag, with no code tag nested
// Empty lines are a special case
if ($pre_content === '') {
return "```\n```\n";
return "```\n```\n\n";
}
// Normalizing new lines
$pre_content = preg_replace('/\r\n|\r|\n/', PHP_EOL, $pre_content);
// Is it a single line?
if (strpos($pre_content, PHP_EOL) === false) {
// One line of code, wrapping it on one backtick.
return '`' . $pre_content . '`';
}
$pre_content = preg_replace('/\r\n|\r|\n/', "\n", $pre_content);
// Ensure there's a newline at the end
if (strrpos($pre_content, PHP_EOL) !== strlen($pre_content) - 1) {
$pre_content .= PHP_EOL;
if (strrpos($pre_content, "\n") !== strlen($pre_content) - strlen("\n")) {
$pre_content .= "\n";
}
// Use three backticks

View file

@ -22,7 +22,9 @@ class TextConverter implements ConverterInterface
$markdown = preg_replace('~\s+~u', ' ', $markdown);
// Escape the following characters: '*', '_', '[', ']' and '\'
$markdown = preg_replace('~([*_\\[\\]\\\\])~u', '\\\\$1', $markdown);
if ($element->getParent() && $element->getParent()->getTagName() !== 'div') {
$markdown = preg_replace('~([*_\\[\\]\\\\])~u', '\\\\$1', $markdown);
}
$markdown = preg_replace('~^#~u', '\\\\#', $markdown);

View file

@ -14,7 +14,7 @@ namespace League\HTMLToMarkdown;
*
* @license http://www.opensource.org/licenses/mit-license.php MIT
*/
class HtmlConverter
class HtmlConverter implements HtmlConverterInterface
{
/**
* @var Environment
@ -35,8 +35,8 @@ class HtmlConverter
'header_style' => 'setext', // Set to 'atx' to output H1 and H2 headers as # Header1 and ## Header2
'suppress_errors' => true, // Set to false to show warnings when loading malformed HTML
'strip_tags' => false, // Set to true to strip tags that don't have markdown equivalents. N.B. Strips tags, not their content. Useful to clean MS Word HTML output.
'bold_style' => '**', // Set to '__' if you prefer the underlined style
'italic_style' => '_', // Set to '*' if you prefer the asterisk style
'bold_style' => '**', // DEPRECATED: Set to '__' if you prefer the underlined style
'italic_style' => '*', // DEPRECATED: Set to '_' if you prefer the underlined style
'remove_nodes' => '', // space-separated list of dom nodes that should be removed. example: 'meta style script'
'hard_break' => false, // Set to true to turn <br> into `\n` instead of ` \n`
'list_item_style' => '-', // Set the default character for each <li> in a <ul>. Can be '-', '*', or '+'

View file

@ -0,0 +1,26 @@
<?php
namespace League\HTMLToMarkdown;
/**
* Interface for an HTML-to-Markdown converter.
*
* @author Colin O'Dell <colinodell@gmail.com>
*
* @link https://github.com/thephpleague/html-to-markdown/ Latest version on GitHub.
*
* @license http://www.opensource.org/licenses/mit-license.php MIT
*/
interface HtmlConverterInterface
{
/**
* Convert the given $html to Markdown
*
* @param string $html
*
* @throws \InvalidArgumentException
*
* @return string The Markdown version of the html
*/
public function convert($html);
}

7
vendor/mf2/mf2/.gitignore vendored Normal file
View file

@ -0,0 +1,7 @@
.DS_Store
/nbproject
composer.phar
/vendor/
/tmp
.idea/
/bin/test

1441
vendor/mf2/mf2/Mf2/Parser.php vendored Normal file

File diff suppressed because it is too large Load diff

401
vendor/mf2/mf2/README.md vendored Normal file
View file

@ -0,0 +1,401 @@
php-mf2
=======
php-mf2 is a pure, generic [microformats-2](http://microformats.org/wiki/microformats-2) parser. It makes HTML as easy to consume as JSON.
Instead of having a hard-coded list of all the different microformats, it follows a set of procedures to handle different property types (e.g. `p-` for plaintext, `u-` for URL, etc). This allows for a very small and maintainable parser.
## Installation
There are two ways of installing php-mf2. I **highly recommend** installing php-mf2 using [Composer](http://getcomposer.org). The rest of the documentation assumes that you have done so.
To install using Composer, run `./composer.phar require mf2/mf2:~0.2`
If you cant or dont want to use Composer, then php-mf2 can be installed the old way by downloading [`/Mf2/Parser.php`](https://raw.githubusercontent.com/indieweb/php-mf2/master/Mf2/Parser.php), adding it to your project and requiring it from files you want to call its functions from, like this:
```php
<?php
require_once 'Mf2/Parser.php';
// Now all the functions documented below are available, for example:
$mf = Mf2\fetch('https://waterpigs.co.uk');
```
### Signed Code Verification
From v0.2.9, php-mf2s version tags are signed using GPG by barnaby@waterpigs.co.uk. This allows you to cryptographically verify that youre using the right code. To do so you will need my key — you dont have it, get it like this:
```bash
gpg --recv-keys 7D49834B0416CFA3
```
Then verify the installed files like this:
```bash
# in your project root
cd vendor/mf2/mf2
git tag -v v0.2.9
```
If nothing went wrong, you should see the tag commit message, ending something like this:
```
gpg: Signature made Wed 6 Aug 10:04:20 2014 GMT using RSA key ID 2B2BBB65
gpg: Good signature from "Barnaby Walters <barnaby@waterpigs.co.uk>"
gpg: aka "[jpeg image of size 12805]"
```
Possible issues:
* **Git complains that theres no such tag**: check for a .git file in the source folder; odds are you have the prefer-dist setting enabled and composer is just extracting a zip rather than checking out from git.
* **Git complains the gpg command doesnt exist**: If you successfully imported my key then you obviously do have gpg installed, but you might have gpg2, whereas git looks for gpg. Solution: tell git which binary to use: `git config --global gpg.program 'gpg2'`
## Usage
php-mf2 is PSR-0 autoloadable, so simply include Composers auto-generated autoload file (`/vendor/autoload.php`) and you can start using it. These two functions cover most situations:
* To fetch microformats from a URL, call `Mf2\fetch($url)`
* To parse microformats from HTML, call `Mf2\parse($html, $url)`, where `$url` is the URL from which `$html` was loaded, if any. This parameter is required for correct relative URL parsing and must not be left out unless parsing HTML which is not loaded from the web.
## Examples
### Fetching microformats from a page
```php
<?php
namespace YourApp;
require '/vendor/autoload.php';
use Mf2;
// (Above code (or equivalent) assumed in future examples)
$mf = Mf2\fetch('http://microformats.org');
foreach ($mf['items'] as $microformat) {
echo "A {$microformat['type'][0]} called {$microformat['properties']['name'][0]}\n";
}
```
### Parsing microformats from a HTML string
Here we demonstrate parsing of microformats2 implied property parsing, where an entire h-card with name and URL properties is created using a single `h-card` class.
```php
<?php
$output = Mf2\parse('<a class="h-card" href="https://waterpigs.co.uk/">Barnaby Walters</a>');
```
`$output` is a canonical microformats2 array structure like:
```json
{
"items": [{
"type": ["h-card"],
"properties": {
"name": ["Barnaby Walters"],
"url": ["https://waterpigs.co.uk/"]
}
}],
"rels": {}
}
```
If no microformats are found, `items` will be an empty array.
Note that, whilst the property prefixes are stripped, the prefix of the `h-*` classname(s) in the "type" array are retained.
### Parsing a document with relative URLs
Most of the time youll be getting your input HTML from a URL. You should pass that URL as the second parameter to `Mf2\parse()` so that any relative URLs in the document can be resolved. For example, say you got the following HTML from `http://example.org`:
```html
<div class="h-card">
<h1 class="p-name">Mr. Example</h1>
<img class="u-photo" alt="" src="photo.png" />
</div>
```
Parsing like this:
```php
$output = Mf2\parse($html, 'http://example.org');
```
will result in the following output, with relative URLs made absolute:
```json
{
"items": [{
"type": ["h-card"],
"properties": {
"photo": ["http://example.org/photo.png"]
}
}],
"rels": {}
}
```
php-mf2 correctly handles relative URL resolution according to the URI and HTML specs, including correct use of the `<base>` element.
### Parsing `rel` and `rel=alternate` values
php-mf2 also parses any link relations in the document, placing them into two top-level arrays — one for `rel=alternate` and another for all other rel values, e.g. when parsing:
```html
<a rel="me" href="https://twitter.com/barnabywalters">Me on twitter</a>
<link rel="alternate etc" href="http://example.com/notes.atom" />
```
parsing will result in the following keys:
```json
{
"items": [],
"rels": {
"me": ["https://twitter.com/barnabywalters"]
},
"alternates": [{
"url": "http://example.com/notes.atom",
"rel": "etc"
}]
}
```
Protip: if youre not bothered about the microformats2 data and just want rels and alternates, you can improve performance by creating a `Mf2\Parser` object (see below) and calling `->parseRelsAndAlternates()` instead of `->parse()`, e.g.
```php
<?php
$parser = new Mf2\Parser('<link rel="…');
$relsAndAlternates = $parser->parseRelsAndAlternates();
```
### Debugging Mf2\fetch
`Mf2\fetch()` will attempt to parse any response served with “HTML” in the content-type, regardless of what the status code is. If it receives a non-HTML response it will return null.
To learn what the HTTP status code for any request was, or learn more about the request, pass a variable name as the third parameter to `Mf2\fetch()` — this will be filled with the contents of `curl_getinfo()`, e.g:
```php
<?php
$mf = Mf2\fetch('http://waterpigs.co.uk/this-page-doesnt-exist', true, $curlInfo);
if ($curlInfo['http_code'] == '404') {
// This page doesnt exist.
}
```
If it was HTML then it is still parsed, as there are cases where error pages contain microformats — for example a deleted h-entry resulting in a 410 Gone response containing a stub h-entry with amn explanation for the deletion.
### Getting more control by creating a Parser object
The `Mf2\parse()` function covers the most common usage patterns by internally creating an instance of `Mf2\Parser` and returning the output all in one step. For some advanced usage you can also create an instance of `Mf2\Parser` yourself.
The constructor takes two arguments, the input HTML (or a DOMDocument) and the URL to use as a base URL. Once you have a parser, there are a few other things you can do:
### Selectively parsing a document
There are several ways to selectively parse microformats from a document. If you wish to only parse microformats from an element with a particular ID, `Parser::parseFromId($id) ` is the easiest way.
If your needs are more complex, `Parser::parse` accepts an optional context DOMNode as its second parameter. Typically youd use `Parser::query` to run XPath queries on the document to get the element you want to parse from under, then pass it to `Parser::parse`. Example usage:
```php
$doc = 'More microformats, more microformats <div id="parse-from-here"><span class="h-card">This shows up</span></div> yet more ignored content';
$parser = new Mf2\Parser($doc);
$parser->parseFromId('parse-from-here'); // returns a document with only the h-card descended from div#parse-from-here
$elementIWant = $parser->query('an xpath query')[0];
$parser->parse(true, $elementIWant); // returns a document with only mfs under the selected element
```
### Generating output for JSON serialization with JSON-mode
Due to a quirk with the way PHP arrays work, there is an edge case ([reported](https://github.com/indieweb/php-mf2/issues/29) by Tom Morris) in which a document with no rel values, when serialised as JSON, results in an empty object as the rels value rather than an empty array. Replacing this in code with a stdClass breaks PHP iteration over the values.
As of version 0.2.6, the default behaviour is back to being PHP-friendly, so if you want to produce results specifically for serialisation as JSON (for example if you run a HTML -> JSON service, or want to run tests against JSON fixtures), enable JSON mode:
```php
// …by passing true as the third constructor:
$jsonParser = new Mf2\Parser($html, $url, true);
```
### Classic Microformats Markup
php-mf2 has some support for parsing classic microformats markup. Its enabled by default, but can be turned off by calling `Mf2\parse($html, $url, false);` or `$parser->parse(false);` if youre instanciating a parser yourself.
In previous versions of php-mf2 you could also add your own class mappings — officially this is no longer supported.
* If the built in mappings dont successfully parse some classic microformats markup then raise an issue and well fix it.
* If you want to screen-scrape websites which dont use mf2 into mf2 data structures, consider contributing to [php-mf2-shim](https://github.com/indieweb/php-mf2-shim)
* If you *really* need to make one-off changes to the default mappings… It is possible. But you have to figure it out for yourself ;)
## Security
**No filtering of content takes place in mf2\Parser, so treat its output as you would any untrusted data from the source of the parsed document.**
Some tips:
* All content apart from the 'html' key in dictionaries produced by parsing an `e-*` property is not HTML-escaped. For example, `<span class="p-name">&lt;code&gt;</span>` will result in `"name": ["<code>"]`. At the very least, HTML-escape all properties before echoing them out in HTML
* If youre using the raw HTML content under the 'html' key of dictionaries produced by parsing `e-*` properties, you SHOULD purify the HTML before displaying it to prevent injection of arbitrary code. For PHP I recommend using [HTML Purifier](http://htmlpurifier.org)
TODO: move this section to a security/consumption best practises page on the wiki
## Contributing
Issues and bug reports are very welcome. If you know how to write tests then please do so as code always expresses problems and intent much better than English, and gives me a way of measuring whether or not fixes have actually solved your problem. If you dont know how to write tests, dont worry :) Just include as much useful information in the issue as you can.
Pull requests very welcome, please try to maintain stylistic, structural and naming consistency with the existing codebase, and dont be too upset if I make naming changes :)
### How to make a Pull Request
1. Fork the repo to your github account
2. Clone a copy to your computer (simply installing php-mf2 using composer only works for using it, not developing it)
3. Install the dev dependencies with `./composer.phar install`
4. Run PHPUnit with `./vendor/bin/phpunit`
5. Make your changes
6. Add PHPUnit tests for your changes, either in an existing test file if suitable, or a new one
7. Make sure your tests pass (`./vendor/bin/phpunit`), preferably using both PHP 5.3 and 5.4
8. Go to your fork of the repo on github.com and make a pull request, preferably with a short summary, detailed description and references to issues/parsing specs as appropriate
9. Bask in the warm feeling of having contributed to a piece of free software
### Testing
There are currently two separate test suites: one, in `tests/Mf2`, is written in phpunit, containing many microformats parsing examples as well as internal parser tests and regression tests for specific issues over php-mf2s history. Run it with `./vendor/bin/phpunit`.
The other, in `tests/test-suite`, is a custom test harness which hooks up php-mf2 to the cross-platform microformats test suite. Each test consists of a HTML file and a corresponding JSON file, and the suite can be run with `php ./tests/test-suite/test-suite.php`.
Currently php-mf2 passes the majority of its own test case, and a good percentage of the cross-platform tests. Contributors should ALWAYS test against the PHPUnit suite to ensure any changes dont negatively impact php-mf2, and SHOULD run the cross-platform suite, especially if youre changing parsing behaviour.
### Changelog
#### v0.2.10
2015-04-29
* Merged #58, fixing some parsing bugs and adding support for area element parsing. Thanks so much for your hard work and patience, <a class="h-card" href="http://ben.thatmustbe.me/">Ben</a>!
#### v0.2.9
2014-08-06
* Added backcompat classmap for hProduct, associated tests
* Started GPG signing version tags as barnaby@waterpigs.co.uk, fingerprint CBC7 7876 BF7C 9637 B6AE 77BA 7D49 834B 0416 CFA3
#### v0.2.8
2014-07-17
* Fixed issue #51 causing php-mf2 to not work with PHP 5.3
* Fixed issue #52 correctly handling the `<template>` element by ignoring it
* Fixed issue #53 improving the plaintext parsing of `<img>` elements
#### v0.2.7
2014-06-18
* Added `Mf2\fetch()` which fetches content from a URL and returns parsed microformats
* Added implied `dt-end` discovery (thanks for all your hard work, @gRegorLove!)
* Fixed issue causing classnames like `blah e- blah` to produce properties with numeric keys (thanks @aaronpk and @gRegorLove)
* Fixed issue causing resolved URLs to not include port numbers (thanks @aaronpk)
#### v0.2.6
* Added JSON mode as long-term fix for #29
* Fixed bug causing microformats nested under multiple property names to be parsed only once
#### v0.2.5
* Removed conditional replacing empty rel list with stdclass. Original purpose was to make JSON-encoding the output from the parser correct but it also caused Fatal Errors due to trying to treat stdclass as array.
#### v0.2.4
#### v0.2.3
* Made p-* parsing consistent with implied name parsing
* Stopped collapsing whitespace in p-* properties
* Implemented unicodeTrim which removes &nbsp; characters as well as regex \s
* Added support for implied name via abbr[title]
* Prevented excessively nested value-class elements from being parsed incorrectly, removed incorrect separator which was getting added in some cases
* Updated u-* parsing to be spec-compliant, matching [href] before value-class and only attempting URL resolution for URL attributes
* Added support for input[value] parsing
* Tests for all the above
#### v0.2.2
* Made resolveUrl method public, allowing advanced parsers and subclasses to make use of it
* Fixed bug causing multiple duplicate property values to appear
#### v0.2.1
* Fixed bug causing classic microformats property classnames to not be parsed correctly
#### v0.2.0 (BREAKING CHANGES)
* Namespace change from mf2 to Mf2, for PSR-0 compatibility
* `Mf2\parse()` function added to simplify the most common case of just parsing some HTML
* Updated e-* property parsing rules to match mf2 parsing spec — instead of producing inconsistent HTML content, it now produces dictionaries like <pre><code>
{
"html": "<b>The Content</b>",
"value: "The Content"
}
</code></pre>
* Removed `htmlSafe` options as new e-* parsing rules make them redundant
* Moved a whole load of static functions out of the class and into standalone functions
* Changed autoloading to always include Parser.php instead of using classmap
#### v0.1.23
* Made some changes to the way back-compatibility with classic microformats are handled, ignoring classic property classnames inside mf2 roots and outside classic roots
* Deprecated ability to add new classmaps, removed twitter classmap. Use [php-mf2-shim](http://github.com/indieweb/php-mf2-shim) instead, its better
#### v0.1.22
* Converts classic microformats by default
#### v0.1.21
* Removed webignition dependency, also removing ext-intl dependency. php-mf2 is now a standalone, single file library again
* Replaced webignition URL resolving with custom code passing almost all tests, courtesy of <a class="h-card" href="http://aaronparecki.com">Aaron Parecki</a>
#### v0.1.20
* Added in almost-perfect custom URL resolving code
#### v0.1.19 (2013-06-11)
* Required stable version of webigniton/absolute-url-resolver, hopefully resolving versioning problems
#### v0.1.18 (2013-06-05)
* Fixed problems with isElementParsed, causing elements to be incorrectly parsed
* Cleaned up some test files
#### v0.1.17
* Rewrote some PHP 5.4 array syntax which crept into 0.1.16 so php-mf2 still works on PHP 5.3
* Fixed a bug causing weird partial microformats to be added to parent microformats if they had doubly property-nested children
* Finally actually licensed this project under a real license (MIT, in composer.json)
* Suggested barnabywalters/mf-cleaner in composer.json
#### v0.1.16
* Ability to parse from only an ID
* Context DOMElement can be passed to $parse
* Parser::query runs XPath queries on the current document
* When parsing e-* properties, elements with @src, @data or @href have relative URLs resolved in the output
#### v0.1.15
* Added html-safe options
* Added rel+rel-alternate parsing

42
vendor/mf2/mf2/bin/fetch-mf2 vendored Executable file
View file

@ -0,0 +1,42 @@
#!/usr/bin/env php
<?php
$files = array(
__DIR__ . '/../vendor/autoload.php',
__DIR__ . '/../../../autoload.php',
__DIR__ . '/../Mf2/Parser.php'
);
foreach ($files as $file) {
if (file_exists($file)) {
require $file;
define('COMPOSER_INSTALL_LOCATION', $file);
break;
}
}
if (!defined('COMPOSER_INSTALL_LOCATION')) {
die('A composer /vendor/autoload.php file could not be found. You need to install composer: https://getcomposer.org/download');
}
$url = $argv[1];
if (empty($url)) {
die("Please provide a URL to fetch+parse, e.g. bin/fetch-mf2 waterpigs.co.uk/notes");
}
if (!file_exists($url)) {
if (!preg_match('|https?://|', $url)) {
$url = 'http://' . $url;
}
}
$html = file_get_contents($url);
$result = Mf2\parse($html, $url);
if (defined('JSON_PRETTY_PRINT')) {
echo json_encode($result, JSON_PRETTY_PRINT);
} else {
echo json_encode($result);
}

37
vendor/mf2/mf2/bin/parse-mf2 vendored Executable file
View file

@ -0,0 +1,37 @@
#!/usr/bin/env php
<?php
$files = array(
__DIR__ . '/../vendor/autoload.php',
__DIR__ . '/../../../autoload.php',
__DIR__ . '/../Mf2/Parser.php'
);
foreach ($files as $file) {
if (file_exists($file)) {
require $file;
define('COMPOSER_INSTALL_LOCATION', $file);
break;
}
}
if (!defined('COMPOSER_INSTALL_LOCATION')) {
die('A composer /vendor/autoload.php file could not be found. You need to install composer: https://getcomposer.org/download');
}
if (!empty($argv[1])) {
$url = $argv[1];
if (!preg_match('|https?://|', $url)) {
$url = 'http://' . $url;
}
} else {
$url = null;
}
$result = Mf2\parse(fgets(STDIN), $url);
if (defined('JSON_PRETTY_PRINT')) {
echo json_encode($result, JSON_PRETTY_PRINT);
} else {
echo json_encode($result);
}

26
vendor/mf2/mf2/composer.json vendored Normal file
View file

@ -0,0 +1,26 @@
{
"name": "mf2/mf2",
"type": "library",
"description": "A pure, generic microformats2 parser — makes HTML as easy to consume as a JSON API",
"keywords": ["microformats", "microformats 2", "parser", "semantic", "html"],
"authors" : [
{
"name": "Barnaby Walters",
"homepage": "http://waterpigs.co.uk"
}
],
"bin": ["bin/fetch-mf2", "bin/parse-mf2"],
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"autoload": {
"files": ["Mf2/Parser.php"]
},
"license": "MIT",
"suggest": {
"barnabywalters/mf-cleaner": "To more easily handle the canonical data php-mf2 gives you"
}
}

438
vendor/mf2/mf2/composer.lock generated vendored Normal file
View file

@ -0,0 +1,438 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "4ddb858a7bdae5163307bd104589bd95",
"packages": [],
"packages-dev": [
{
"name": "phpunit/php-code-coverage",
"version": "1.2.18",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b",
"reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"phpunit/php-file-iterator": ">=1.3.0@stable",
"phpunit/php-text-template": ">=1.2.0@stable",
"phpunit/php-token-stream": ">=1.1.3,<1.3.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*@dev"
},
"suggest": {
"ext-dom": "*",
"ext-xdebug": ">=2.0.5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev"
}
},
"autoload": {
"classmap": [
"PHP/"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
""
],
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"role": "lead"
}
],
"description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
"homepage": "https://github.com/sebastianbergmann/php-code-coverage",
"keywords": [
"coverage",
"testing",
"xunit"
],
"time": "2014-09-02 10:13:14"
},
{
"name": "phpunit/php-file-iterator",
"version": "1.4.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "a923bb15680d0089e2316f7a4af8f437046e96bb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a923bb15680d0089e2316f7a4af8f437046e96bb",
"reference": "a923bb15680d0089e2316f7a4af8f437046e96bb",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"role": "lead"
}
],
"description": "FilterIterator implementation that filters files based on a list of suffixes.",
"homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
"keywords": [
"filesystem",
"iterator"
],
"time": "2015-04-02 05:19:05"
},
{
"name": "phpunit/php-text-template",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-text-template.git",
"reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
"reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"autoload": {
"classmap": [
"Text/"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
""
],
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"role": "lead"
}
],
"description": "Simple template engine.",
"homepage": "https://github.com/sebastianbergmann/php-text-template/",
"keywords": [
"template"
],
"time": "2014-01-30 17:20:04"
},
{
"name": "phpunit/php-timer",
"version": "1.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-timer.git",
"reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
"reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"autoload": {
"classmap": [
"PHP/"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
""
],
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"role": "lead"
}
],
"description": "Utility class for timing",
"homepage": "https://github.com/sebastianbergmann/php-timer/",
"keywords": [
"timer"
],
"time": "2013-08-02 07:42:54"
},
{
"name": "phpunit/php-token-stream",
"version": "1.2.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/ad4e1e23ae01b483c16f600ff1bebec184588e32",
"reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2-dev"
}
},
"autoload": {
"classmap": [
"PHP/"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
""
],
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"role": "lead"
}
],
"description": "Wrapper around PHP's tokenizer extension.",
"homepage": "https://github.com/sebastianbergmann/php-token-stream/",
"keywords": [
"tokenizer"
],
"time": "2014-03-03 05:10:30"
},
{
"name": "phpunit/phpunit",
"version": "3.7.38",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/38709dc22d519a3d1be46849868aa2ddf822bcf6",
"reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-dom": "*",
"ext-json": "*",
"ext-pcre": "*",
"ext-reflection": "*",
"ext-spl": "*",
"php": ">=5.3.3",
"phpunit/php-code-coverage": "~1.2",
"phpunit/php-file-iterator": "~1.3",
"phpunit/php-text-template": "~1.1",
"phpunit/php-timer": "~1.0",
"phpunit/phpunit-mock-objects": "~1.2",
"symfony/yaml": "~2.0"
},
"require-dev": {
"pear-pear.php.net/pear": "1.9.4"
},
"suggest": {
"phpunit/php-invoker": "~1.1"
},
"bin": [
"composer/bin/phpunit"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.7.x-dev"
}
},
"autoload": {
"classmap": [
"PHPUnit/"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
"",
"../../symfony/yaml/"
],
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "The PHP Unit Testing framework.",
"homepage": "http://www.phpunit.de/",
"keywords": [
"phpunit",
"testing",
"xunit"
],
"time": "2014-10-17 09:04:17"
},
{
"name": "phpunit/phpunit-mock-objects",
"version": "1.2.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875",
"reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"phpunit/php-text-template": ">=1.1.1@stable"
},
"suggest": {
"ext-soap": "*"
},
"type": "library",
"autoload": {
"classmap": [
"PHPUnit/"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
""
],
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"role": "lead"
}
],
"description": "Mock Object library for PHPUnit",
"homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
"keywords": [
"mock",
"xunit"
],
"time": "2013-01-13 10:24:48"
},
{
"name": "symfony/yaml",
"version": "v2.6.6",
"target-dir": "Symfony/Component/Yaml",
"source": {
"type": "git",
"url": "https://github.com/symfony/Yaml.git",
"reference": "174f009ed36379a801109955fc5a71a49fe62dd4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/174f009ed36379a801109955fc5a71a49fe62dd4",
"reference": "174f009ed36379a801109955fc5a71a49fe62dd4",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.6-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\Yaml\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
}
],
"description": "Symfony Yaml Component",
"homepage": "http://symfony.com",
"time": "2015-03-30 15:54:10"
}
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=5.3.0"
},
"platform-dev": []
}

8
vendor/mf2/mf2/phpunit.xml vendored Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<phpunit bootstrap="tests/Mf2/bootstrap.php">
<testsuites>
<testsuite name="php-mf2">
<directory suffix="Test.php">tests/Mf2</directory>
</testsuite>
</testsuites>
</phpunit>

View file

@ -2,7 +2,14 @@
This file contains a brief description of new features which have been added to Smarty 3.1
Smarty 3.1.32 New tags for inheritance parent and child
Smarty 3.1.33-dev
Variable capture name in Smarty special variable
================================================
{$smarty.capture.$foo} can now be used to access the content of a named
capture block
Smarty 3.1.32
New tags for inheritance parent and child
=========================================
{parent} == {$smarty.block.parent}
{child} == {$smarty.block.child}

View file

@ -1,4 +1,46 @@
===== 3.1.32 ===== (24.04.2018)
===== 3.1.33 release ===== 12.09.2018
===== 3.1.33-dev-12 =====
03.09.2018
- bugfix {foreach} using new style property access like {$item@property} on
Smarty 2 style named foreach loop could produce errors https://github.com/smarty-php/smarty/issues/484
31.08.2018
- bugfix some custom left and right delimiters like '{^' '^}' did not work
https://github.com/smarty-php/smarty/issues/450 https://github.com/smarty-php/smarty/pull/482
- reformating for PSR-2 coding standards https://github.com/smarty-php/smarty/pull/483
- bugfix on Windows absolute filepathes did fail if the drive letter was followed by a linux DIRECTORY_SEPARATOR
like C:/ at Smarty > 3.1.33-dev-5 https://github.com/smarty-php/smarty/issues/451
- PSR-2 code style fixes for config and template file Lexer/Parser generated with
the Smarty Lexer/Parser generator from https://github.com/smarty-php/smarty-lexer
https://github.com/smarty-php/smarty/pull/483
26.08.2018
- bugfix/enhancement {capture} allow variable as capture block name in Smarty special variable
like $smarty.capture.$foo https://github.com/smarty-php/smarty/issues/478 https://github.com/smarty-php/smarty/pull/481
===== 3.1.33-dev-6 =====
19.08.2018
- fix PSR-2 coding standards and PHPDoc blocks https://github.com/smarty-php/smarty/pull/452
https://github.com/smarty-php/smarty/pull/475
https://github.com/smarty-php/smarty/pull/473
- bugfix PHP5.2 compatibility https://github.com/smarty-php/smarty/pull/472
===== 3.1.33-dev-4 =====
17.05.2018
- bugfix strip-block produces different output in Smarty v3.1.32 https://github.com/smarty-php/smarty/issues/436
- bugfix Smarty::compileAllTemplates ignores `$extension` parameter https://github.com/smarty-php/smarty/issues/437
https://github.com/smarty-php/smarty/pull/438
- improvement do not compute total property in {foreach} if not needed https://github.com/smarty-php/smarty/issues/443
- bugfix plugins may not be loaded when setMergeCompiledIncludes is true https://github.com/smarty-php/smarty/issues/435
26.04.2018
- bugfix regarding Security Vulnerability did not solve the problem under Linux.
Security issue CVE-2018-16831
===== 3.1.32 ===== (24.04.2018)
24.04.2018
- bugfix possible Security Vulnerability in Smarty_Security class.

View file

@ -2,7 +2,9 @@
"name": "smarty/smarty",
"type": "library",
"description": "Smarty - the compiling PHP template engine",
"keywords": ["templating"],
"keywords": [
"templating"
],
"homepage": "http://www.smarty.net",
"license": "LGPL-3.0",
"authors": [
@ -28,12 +30,13 @@
"php": ">=5.2"
},
"autoload": {
"files": ["libs/bootstrap.php"]
"files": [
"libs/bootstrap.php"
]
},
"extra": {
"branch-alias": {
"dev-master": "3.1.x-dev"
}
}
}
}

View file

@ -4,27 +4,32 @@
*
* @package Example-application
*/
require '../libs/Smarty.class.php';
$smarty = new Smarty;
//$smarty->force_compile = true;
$smarty->debugging = true;
$smarty->caching = true;
$smarty->cache_lifetime = 120;
$smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
$smarty->assign("FirstName", array("John", "Mary", "James", "Henry"));
$smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
$smarty->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"), array("I", "J", "K", "L"),
array("M", "N", "O", "P")));
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
$smarty->assign(
"Class",
array(
array("A", "B", "C", "D"),
array("E", "F", "G", "H"),
array("I", "J", "K", "L"),
array("M", "N", "O", "P")
)
);
$smarty->assign(
"contacts",
array(
array("phone" => "1", "fax" => "2", "cell" => "3"),
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")
)
);
$smarty->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX"));
$smarty->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas"));
$smarty->assign("option_selected", "NE");
$smarty->display('index.tpl');

View file

@ -11,6 +11,11 @@
*/
class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
{
/**
* Smarty_CacheResource_Apc constructor.
*
* @throws \Exception
*/
public function __construct()
{
// test if APC is present
@ -22,7 +27,7 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
/**
* Read values for a set of keys from cache
*
* @param array $keys list of keys to fetch
* @param array $keys list of keys to fetch
*
* @return array list of values with the given keys used as indexes
* @return boolean true on success, false on failure
@ -34,15 +39,14 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
foreach ($res as $k => $v) {
$_res[ $k ] = $v;
}
return $_res;
}
/**
* Save values for a set of keys to cache
*
* @param array $keys list of values to save
* @param int $expire expiration time
* @param array $keys list of values to save
* @param int $expire expiration time
*
* @return boolean true on success, false on failure
*/
@ -51,14 +55,13 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
foreach ($keys as $k => $v) {
apc_store($k, $v, $expire);
}
return true;
}
/**
* Remove values from cache
*
* @param array $keys list of keys to delete
* @param array $keys list of keys to delete
*
* @return boolean true on success, false on failure
*/
@ -67,7 +70,6 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
foreach ($keys as $k) {
apc_delete($k);
}
return true;
}

View file

@ -19,6 +19,9 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
*/
protected $memcache = null;
/**
* Smarty_CacheResource_Memcache constructor.
*/
public function __construct()
{
if (class_exists('Memcached')) {
@ -32,7 +35,7 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
/**
* Read values for a set of keys from cache
*
* @param array $keys list of keys to fetch
* @param array $keys list of keys to fetch
*
* @return array list of values with the given keys used as indexes
* @return boolean true on success, false on failure
@ -50,15 +53,14 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
foreach ($res as $k => $v) {
$_res[ $lookup[ $k ] ] = $v;
}
return $_res;
}
/**
* Save values for a set of keys to cache
*
* @param array $keys list of values to save
* @param int $expire expiration time
* @param array $keys list of values to save
* @param int $expire expiration time
*
* @return boolean true on success, false on failure
*/
@ -68,14 +70,13 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
$k = sha1($k);
$this->memcache->set($k, $v, 0, $expire);
}
return true;
}
/**
* Remove values from cache
*
* @param array $keys list of keys to delete
* @param array $keys list of keys to delete
*
* @return boolean true on success, false on failure
*/
@ -85,7 +86,6 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
$k = sha1($k);
$this->memcache->delete($k);
}
return true;
}
@ -96,6 +96,6 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
*/
protected function purge()
{
$this->memcache->flush();
return $this->memcache->flush();
}
}

View file

@ -24,38 +24,55 @@
*/
class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
{
// PDO instance
/**
* @var \PDO
*/
protected $db;
/**
* @var \PDOStatement
*/
protected $fetch;
/**
* @var \PDOStatement
*/
protected $fetchTimestamp;
/**
* @var \PDOStatement
*/
protected $save;
/**
* Smarty_CacheResource_Mysql constructor.
*
* @throws \SmartyException
*/
public function __construct()
{
try {
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
}
catch (PDOException $e) {
} catch (PDOException $e) {
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
}
$this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id');
$this->fetchTimestamp = $this->db->prepare('SELECT modified FROM output_cache WHERE id = :id');
$this->save = $this->db->prepare('REPLACE INTO output_cache (id, name, cache_id, compile_id, content)
VALUES (:id, :name, :cache_id, :compile_id, :content)');
$this->save = $this->db->prepare(
'REPLACE INTO output_cache (id, name, cache_id, compile_id, content)
VALUES (:id, :name, :cache_id, :compile_id, :content)'
);
}
/**
* 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)
* @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
*/
@ -76,12 +93,13 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
/**
* Fetch cached content's modification timestamp from data source
*
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the complete cached content.
* @note 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
* @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
*/
@ -90,37 +108,40 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
$this->fetchTimestamp->execute(array('id' => $id));
$mtime = strtotime($this->fetchTimestamp->fetchColumn());
$this->fetchTimestamp->closeCursor();
return $mtime;
}
/**
* 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 time in seconds or null
* @param string $content 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 time in seconds or null
* @param string $content content to cache
*
* @return boolean success
*/
protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content)
{
$this->save->execute(array('id' => $id, 'name' => $name, 'cache_id' => $cache_id, 'compile_id' => $compile_id,
'content' => $content,));
$this->save->execute(
array('id' => $id,
'name' => $name,
'cache_id' => $cache_id,
'compile_id' => $compile_id,
'content' => $content,)
);
return !!$this->save->rowCount();
}
/**
* Delete content from cache
*
* @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 $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
*
* @return integer number of deleted caches
*/
@ -130,8 +151,7 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) {
// returning the number of deleted caches would require a second query to count them
$query = $this->db->query('TRUNCATE TABLE output_cache');
return - 1;
return -1;
}
// build the filter
$where = array();
@ -149,12 +169,15 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
}
// equal test cache_id and match sub-groups
if ($cache_id !== null) {
$where[] = '(cache_id = ' . $this->db->quote($cache_id) . ' OR cache_id LIKE ' .
$this->db->quote($cache_id . '|%') . ')';
$where[] =
'(cache_id = ' .
$this->db->quote($cache_id) .
' OR cache_id LIKE ' .
$this->db->quote($cache_id . '|%') .
')';
}
// run delete query
$query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where));
return $query->rowCount();
}
}

View file

@ -29,28 +29,27 @@
*/
class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
{
protected $fetchStatements = Array('default' => 'SELECT %2$s
/**
* @var string[]
*/
protected $fetchStatements = array('default' => 'SELECT %2$s
FROM %1$s
WHERE 1
AND id = :id
AND cache_id IS NULL
AND compile_id IS NULL',
'withCacheId' => 'SELECT %2$s
FROM %1$s
WHERE 1
AND id = :id
AND cache_id = :cache_id
AND compile_id IS NULL',
'withCompileId' => 'SELECT %2$s
FROM %1$s
WHERE 1
AND id = :id
AND compile_id = :compile_id
AND cache_id IS NULL',
'withCacheIdAndCompileId' => 'SELECT %2$s
FROM %1$s
WHERE 1
@ -58,6 +57,9 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
AND cache_id = :cache_id
AND compile_id = :compile_id');
/**
* @var string
*/
protected $insertStatement = 'INSERT INTO %s
SET id = :id,
@ -76,113 +78,130 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
expire = DATE_ADD(CURRENT_TIMESTAMP, INTERVAL :expire SECOND),
content = :content';
/**
* @var string
*/
protected $deleteStatement = 'DELETE FROM %1$s WHERE %2$s';
/**
* @var string
*/
protected $truncateStatement = 'TRUNCATE TABLE %s';
/**
* @var string
*/
protected $fetchColumns = 'modified, content';
/**
* @var string
*/
protected $fetchTimestampColumns = 'modified';
protected $pdo, $table, $database;
/**
* @var \PDO
*/
protected $pdo;
/*
* Constructor
*
* @param PDO $pdo PDO : active connection
* @param string $table : table (or view) name
* @param string $database : optional - if table is located in another db
/**
* @var
*/
protected $table;
/**
* @var null
*/
protected $database;
/**
* Constructor
*
* @param PDO $pdo PDO : active connection
* @param string $table : table (or view) name
* @param string $database : optional - if table is located in another db
*
* @throws \SmartyException
*/
public function __construct(PDO $pdo, $table, $database = null)
{
if (is_null($table)) {
throw new SmartyException("Table name for caching can't be null");
}
$this->pdo = $pdo;
$this->table = $table;
$this->database = $database;
$this->fillStatementsWithTableName();
}
/*
* Fills the table name into the statements.
*
* @return Current Instance
* @access protected
/**
* Fills the table name into the statements.
*
* @return $this Current Instance
* @access protected
*/
protected function fillStatementsWithTableName()
{
foreach ($this->fetchStatements AS &$statement) {
foreach ($this->fetchStatements as &$statement) {
$statement = sprintf($statement, $this->getTableName(), '%s');
}
$this->insertStatement = sprintf($this->insertStatement, $this->getTableName());
$this->deleteStatement = sprintf($this->deleteStatement, $this->getTableName(), '%s');
$this->truncateStatement = sprintf($this->truncateStatement, $this->getTableName());
return $this;
}
/*
* Gets the fetch statement, depending on what you specify
*
* @param string $columns : the column(s) name(s) you want to retrieve from the database
* @param string $id unique cache content identifier
* @param string|null $cache_id cache id
* @param string|null $compile_id compile id
* @access protected
/**
* Gets the fetch statement, depending on what you specify
*
* @param string $columns : the column(s) name(s) you want to retrieve from the database
* @param string $id unique cache content identifier
* @param string|null $cache_id cache id
* @param string|null $compile_id compile id
*
* @access protected
* @return \PDOStatement
*/
protected function getFetchStatement($columns, $id, $cache_id = null, $compile_id = null)
{
$args = array();
if (!is_null($cache_id) && !is_null($compile_id)) {
$query = $this->fetchStatements[ 'withCacheIdAndCompileId' ] AND
$args = Array('id' => $id, 'cache_id' => $cache_id, 'compile_id' => $compile_id);
$query = $this->fetchStatements[ 'withCacheIdAndCompileId' ] and
$args = array('id' => $id, 'cache_id' => $cache_id, 'compile_id' => $compile_id);
} elseif (is_null($cache_id) && !is_null($compile_id)) {
$query = $this->fetchStatements[ 'withCompileId' ] AND
$args = Array('id' => $id, 'compile_id' => $compile_id);
$query = $this->fetchStatements[ 'withCompileId' ] and
$args = array('id' => $id, 'compile_id' => $compile_id);
} elseif (!is_null($cache_id) && is_null($compile_id)) {
$query = $this->fetchStatements[ 'withCacheId' ] AND $args = Array('id' => $id, 'cache_id' => $cache_id);
$query = $this->fetchStatements[ 'withCacheId' ] and $args = array('id' => $id, 'cache_id' => $cache_id);
} else {
$query = $this->fetchStatements[ 'default' ] AND $args = Array('id' => $id);
$query = $this->fetchStatements[ 'default' ] and $args = array('id' => $id);
}
$query = sprintf($query, $columns);
$stmt = $this->pdo->prepare($query);
foreach ($args AS $key => $value) {
foreach ($args as $key => $value) {
$stmt->bindValue($key, $value);
}
return $stmt;
}
/**
* fetch cached content and its modification time from data source
*
* @param string $id unique cache content identifier
* @param string $name template name
* @param string|null $cache_id cache id
* @param string|null $compile_id compile id
* @param string $content cached content
* @param integer $mtime cache modification timestamp (epoch)
* @param string $id unique cache content identifier
* @param string $name template name
* @param string|null $cache_id cache id
* @param string|null $compile_id compile id
* @param string $content cached content
* @param integer $mtime cache modification timestamp (epoch)
*
* @return void
* @access protected
*/
protected function fetch($id, $name, $cache_id = null, $compile_id = null, &$content, &$mtime)
{
$stmt = $this->getFetchStatement($this->fetchColumns, $id, $cache_id, $compile_id);
$stmt->execute();
$row = $stmt->fetch();
$stmt->closeCursor();
if ($row) {
$content = $this->outputContent($row[ 'content' ]);
$mtime = strtotime($row[ 'modified' ]);
@ -197,10 +216,10 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
* {@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|null $cache_id cache id
* @param string|null $compile_id compile id
* @param string $id unique cache content identifier
* @param string $name template name
* @param string|null $cache_id cache id
* @param string|null $compile_id compile id
*
* @return integer|boolean timestamp (epoch) the template was modified, or false if not found
* @access protected
@ -212,7 +231,6 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
// $stmt -> closeCursor();
// return $mtime;
// }
/**
* Save content to cache
*
@ -228,38 +246,37 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
*/
protected function save($id, $name, $cache_id = null, $compile_id = null, $exp_time, $content)
{
$stmt = $this->pdo->prepare($this->insertStatement);
$stmt->bindValue('id', $id);
$stmt->bindValue('name', $name);
$stmt->bindValue('cache_id', $cache_id, (is_null($cache_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR);
$stmt->bindValue('compile_id', $compile_id, (is_null($compile_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR);
$stmt->bindValue('expire', (int) $exp_time, PDO::PARAM_INT);
$stmt->bindValue('expire', (int)$exp_time, PDO::PARAM_INT);
$stmt->bindValue('content', $this->inputContent($content));
$stmt->execute();
return !!$stmt->rowCount();
}
/*
* Encodes the content before saving to database
*
* @param string $content
* @return string $content
* @access protected
/**
* Encodes the content before saving to database
*
* @param string $content
*
* @return string $content
* @access protected
*/
protected function inputContent($content)
{
return $content;
}
/*
* Decodes the content before saving to database
*
* @param string $content
* @return string $content
* @access protected
/**
* Decodes the content before saving to database
*
* @param string $content
*
* @return string $content
* @access protected
*/
protected function outputContent($content)
{
@ -272,43 +289,46 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
* @param string|null $name template name
* @param string|null $cache_id cache id
* @param string|null $compile_id compile id
* @param integer|null|-1 $exp_time seconds till expiration or null
* @param integer|null|-1 $exp_time seconds till expiration or null
*
* @return integer number of deleted caches
* @access protected
* @access protected
*/
protected function delete($name = null, $cache_id = null, $compile_id = null, $exp_time = null)
{
// delete the whole cache
// delete the whole cache
if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) {
// returning the number of deleted caches would require a second query to count them
// returning the number of deleted caches would require a second query to count them
$this->pdo->query($this->truncateStatement);
return - 1;
return -1;
}
// build the filter
// build the filter
$where = array();
// equal test name
// equal test name
if ($name !== null) {
$where[] = 'name = ' . $this->pdo->quote($name);
}
// equal test cache_id and match sub-groups
// equal test cache_id and match sub-groups
if ($cache_id !== null) {
$where[] = '(cache_id = ' . $this->pdo->quote($cache_id) . ' OR cache_id LIKE ' .
$this->pdo->quote($cache_id . '|%') . ')';
$where[] =
'(cache_id = ' .
$this->pdo->quote($cache_id) .
' OR cache_id LIKE ' .
$this->pdo->quote($cache_id . '|%') .
')';
}
// equal test compile_id
// equal test compile_id
if ($compile_id !== null) {
$where[] = 'compile_id = ' . $this->pdo->quote($compile_id);
}
// for clearing expired caches
// for clearing expired caches
if ($exp_time === Smarty::CLEAR_EXPIRED) {
$where[] = 'expire < CURRENT_TIMESTAMP';
} // range test expiration time
elseif ($exp_time !== null) {
$where[] = 'modified < DATE_SUB(NOW(), INTERVAL ' . intval($exp_time) . ' SECOND)';
}
// run delete query
// run delete query
$query = $this->pdo->query(sprintf($this->deleteStatement, join(' AND ', $where)));
return $query->rowCount();
}
@ -324,4 +344,3 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
return (is_null($this->database)) ? "`{$this->table}`" : "`{$this->database}`.`{$this->table}`";
}
}

View file

@ -1,4 +1,5 @@
<?php
require_once 'cacheresource.pdo.php';
/**
* PDO Cache Handler with GZIP support
@ -11,33 +12,31 @@
* @require Smarty_CacheResource_Pdo class
* @author Beno!t POLASZEK - 2014
*/
require_once 'cacheresource.pdo.php';
class Smarty_CacheResource_Pdo_Gzip extends Smarty_CacheResource_Pdo
{
/*
* Encodes the content before saving to database
*
* @param string $content
* @return string $content
* @access protected
/**
* Encodes the content before saving to database
*
* @param string $content
*
* @return string $content
* @access protected
*/
protected function inputContent($content)
{
return gzdeflate($content);
}
/*
* Decodes the content before saving to database
*
* @param string $content
* @return string $content
* @access protected
/**
* Decodes the content before saving to database
*
* @param string $content
*
* @return string $content
* @access protected
*/
protected function outputContent($content)
{
return gzinflate($content);
}
}
}

View file

@ -13,8 +13,8 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends
/**
* populate Source Object with meta data from Resource
*
* @param Smarty_Template_Source $source source object
* @param Smarty_Internal_Template $_template template object
* @param Smarty_Template_Source $source source object
* @param Smarty_Internal_Template $_template template object
*
* @return void
*/
@ -32,15 +32,13 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends
$sources[ $s->uid ] = $s;
$uid .= $s->filepath;
$timestamp = $s->timestamp > $timestamp ? $s->timestamp : $timestamp;
}
catch (SmartyException $e) {
} catch (SmartyException $e) {
}
}
if (!$sources) {
$source->exists = false;
return;
}
$sources = array_reverse($sources, true);
reset($sources);
$s = current($sources);
@ -51,15 +49,14 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends
$source->timestamp = $timestamp;
}
/*
/**
* Disable timestamp checks for extendsall resource.
* The individual source components will be checked.
*
* @return bool
* @return bool false
*/
public function checkTimestamps()
{
return false;
}
}

View file

@ -12,28 +12,46 @@
* PRIMARY KEY (`name`)
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
* Demo data:
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello
* world"}{$x}');</pre>
*
*
* @package Resource-examples
* @author Rodney Rehm
*/
class Smarty_Resource_Mysql extends Smarty_Resource_Custom
{
// PDO instance
/**
* PDO instance
*
* @var \PDO
*/
protected $db;
// prepared fetch() statement
/**
* prepared fetch() statement
*
* @var \PDOStatement
*/
protected $fetch;
// prepared fetchTimestamp() statement
/**
* prepared fetchTimestamp() statement
*
* @var \PDOStatement
*/
protected $mtime;
/**
* Smarty_Resource_Mysql constructor.
*
* @throws \SmartyException
*/
public function __construct()
{
try {
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
}
catch (PDOException $e) {
} catch (PDOException $e) {
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
}
$this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
@ -43,9 +61,9 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom
/**
* Fetch a template and its modification time from database
*
* @param string $name template name
* @param string $source template source
* @param integer $mtime template modification timestamp (epoch)
* @param string $name template name
* @param string $source template source
* @param integer $mtime template modification timestamp (epoch)
*
* @return void
*/
@ -66,9 +84,10 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom
/**
* Fetch a template's modification time from database
*
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the comple template source.
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than
* loading the comple template source.
*
* @param string $name template name
* @param string $name template name
*
* @return integer timestamp (epoch) the template was modified
*/
@ -77,7 +96,6 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom
$this->mtime->execute(array('name' => $name));
$mtime = $this->mtime->fetchColumn();
$this->mtime->closeCursor();
return strtotime($mtime);
}
}

View file

@ -14,25 +14,39 @@
* PRIMARY KEY (`name`)
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
* Demo data:
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello
* world"}{$x}');</pre>
*
*
* @package Resource-examples
* @author Rodney Rehm
*/
class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
{
// PDO instance
/**
* PDO instance
*
* @var \PDO
*/
protected $db;
// prepared fetch() statement
/**
* prepared fetch() statement
*
* @var \PDOStatement
*/
protected $fetch;
/**
* Smarty_Resource_Mysqls constructor.
*
* @throws \SmartyException
*/
public function __construct()
{
try {
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
}
catch (PDOException $e) {
} catch (PDOException $e) {
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
}
$this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
@ -41,9 +55,9 @@ class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
/**
* Fetch a template and its modification time from database
*
* @param string $name template name
* @param string $source template source
* @param integer $mtime template modification timestamp (epoch)
* @param string $name template name
* @param string $source template source
* @param integer $mtime template modification timestamp (epoch)
*
* @return void
*/

View file

@ -2,14 +2,14 @@
/**
* Smarty Autoloader
*
* @package Smarty
* @package Smarty
*/
/**
* Smarty Autoloader
*
* @package Smarty
* @author Uwe Tews
* @package Smarty
* @author Uwe Tews
* Usage:
* require_once '...path/Autoloader.php';
* Smarty_Autoloader::register();
@ -20,7 +20,7 @@
*/
class Smarty_Autoloader
{
/**
/**
* Filepath to Smarty root
*
* @var string
@ -54,8 +54,8 @@ class Smarty_Autoloader
if (!defined('SMARTY_SPL_AUTOLOAD')) {
define('SMARTY_SPL_AUTOLOAD', 0);
}
if (SMARTY_SPL_AUTOLOAD &&
set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
if (SMARTY_SPL_AUTOLOAD
&& set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
) {
$registeredAutoLoadFunctions = spl_autoload_functions();
if (!isset($registeredAutoLoadFunctions[ 'spl_autoload' ])) {

View file

@ -27,7 +27,7 @@
* @author Uwe Tews <uwe dot tews at gmail dot com>
* @author Rodney Rehm
* @package Smarty
* @version 3.1.32
* @version 3.1.33
*/
/**
* set SMARTY_DIR to absolute path to Smarty library files.
@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.32';
const SMARTY_VERSION = '3.1.33';
/**
* define variable scopes
*/
@ -166,133 +166,157 @@ class Smarty extends Smarty_Internal_TemplateBase
const PLUGIN_COMPILER = 'compiler';
const PLUGIN_MODIFIER = 'modifier';
const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler';
/**
* assigned global tpl vars
*/
public static $global_tpl_vars = array();
/**
* Flag denoting if Multibyte String functions are available
*/
public static $_MBSTRING = SMARTY_MBSTRING;
/**
* The character set to adhere to (e.g. "UTF-8")
*/
public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET;
/**
* The date format to be used internally
* (accepts date() and strftime())
*/
public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT;
/**
* Flag denoting if PCRE should run in UTF-8 mode
*/
public static $_UTF8_MODIFIER = 'u';
/**
* Flag denoting if operating system is windows
*/
public static $_IS_WINDOWS = false;
/**
* auto literal on delimiters with whitespace
*
* @var boolean
*/
public $auto_literal = true;
/**
* display error on not assigned variables
*
* @var boolean
*/
public $error_unassigned = false;
/**
* look up relative file path in include_path
*
* @var boolean
*/
public $use_include_path = false;
/**
* flag if template_dir is normalized
*
* @var bool
*/
public $_templateDirNormalized = false;
/**
* joined template directory string used in cache keys
*
* @var string
*/
public $_joined_template_dir = null;
/**
* flag if config_dir is normalized
*
* @var bool
*/
public $_configDirNormalized = false;
/**
* joined config directory string used in cache keys
*
* @var string
*/
public $_joined_config_dir = null;
/**
* default template handler
*
* @var callable
*/
public $default_template_handler_func = null;
/**
* default config handler
*
* @var callable
*/
public $default_config_handler_func = null;
/**
* default plugin handler
*
* @var callable
*/
public $default_plugin_handler_func = null;
/**
* flag if template_dir is normalized
*
* @var bool
*/
public $_compileDirNormalized = false;
/**
* flag if plugins_dir is normalized
*
* @var bool
*/
public $_pluginsDirNormalized = false;
/**
* flag if template_dir is normalized
*
* @var bool
*/
public $_cacheDirNormalized = false;
/**
* force template compiling?
*
* @var boolean
*/
public $force_compile = false;
/**
/**
* use sub dirs for compiled/cached files?
*
* @var boolean
*/
public $use_sub_dirs = false;
/**
* allow ambiguous resources (that are made unique by the resource handler)
*
* @var boolean
*/
public $allow_ambiguous_resources = false;
/**
* merge compiled includes
*
* @var boolean
*/
public $merge_compiled_includes = false;
/*
* flag for behaviour when extends: resource and {extends} tag are used simultaneous
* if false disable execution of {extends} in templates called by extends resource.
@ -301,30 +325,35 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var boolean
*/
public $extends_recursion = true;
/**
* force cache file creation
*
* @var boolean
*/
public $force_cache = false;
/**
* template left-delimiter
*
* @var string
*/
public $left_delimiter = "{";
/**
* template right-delimiter
*
* @var string
*/
public $right_delimiter = "}";
/**
* array of strings which shall be treated as literal by compiler
*
* @var array string
*/
public $literals = array();
/**
* class name
* This should be instance of Smarty_Security.
@ -333,24 +362,28 @@ class Smarty extends Smarty_Internal_TemplateBase
* @see Smarty_Security
*/
public $security_class = 'Smarty_Security';
/**
* implementation of security class
*
* @var Smarty_Security
*/
public $security_policy = null;
/**
* controls handling of PHP-blocks
*
* @var integer
*/
public $php_handling = self::PHP_PASSTHRU;
/**
* controls if the php template file resource is allowed
*
* @var bool
*/
public $allow_php_templates = false;
/**
* debug mode
* Setting this to true enables the debug-console.
@ -358,6 +391,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var boolean
*/
public $debugging = false;
/**
* This determines if debugging is enable-able from the browser.
* <ul>
@ -368,6 +402,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string
*/
public $debugging_ctrl = 'NONE';
/**
* Name of debugging URL-param.
* Only used when $debugging_ctrl is set to 'URL'.
@ -376,54 +411,63 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string
*/
public $smarty_debug_id = 'SMARTY_DEBUG';
/**
* Path of debug template.
*
* @var string
*/
public $debug_tpl = null;
/**
* When set, smarty uses this value as error_reporting-level.
*
* @var int
*/
public $error_reporting = null;
/**
* Controls whether variables with the same name overwrite each other.
*
* @var boolean
*/
public $config_overwrite = true;
/**
* Controls whether config values of on/true/yes and off/false/no get converted to boolean.
*
* @var boolean
*/
public $config_booleanize = true;
/**
* Controls whether hidden config sections/vars are read from the file.
*
* @var boolean
*/
public $config_read_hidden = false;
/**
* locking concurrent compiles
*
* @var boolean
*/
public $compile_locking = true;
/**
* Controls whether cache resources should use locking mechanism
*
* @var boolean
*/
public $cache_locking = false;
/**
* seconds to wait for acquiring a lock before ignoring the write lock
*
* @var float
*/
public $locking_timeout = 10;
/**
* resource type used if none given
* Must be an valid key of $registered_resources.
@ -431,6 +475,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string
*/
public $default_resource_type = 'file';
/**
* caching type
* Must be an element of $cache_resource_types.
@ -438,160 +483,189 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string
*/
public $caching_type = 'file';
/**
* config type
*
* @var string
*/
public $default_config_type = 'file';
/**
* check If-Modified-Since headers
*
* @var boolean
*/
public $cache_modified_check = false;
/**
* registered plugins
*
* @var array
*/
public $registered_plugins = array();
/**
* registered objects
*
* @var array
*/
public $registered_objects = array();
/**
* registered classes
*
* @var array
*/
public $registered_classes = array();
/**
* registered filters
*
* @var array
*/
public $registered_filters = array();
/**
* registered resources
*
* @var array
*/
public $registered_resources = array();
/**
* registered cache resources
*
* @var array
*/
public $registered_cache_resources = array();
/**
* autoload filter
*
* @var array
*/
public $autoload_filters = array();
/**
* default modifier
*
* @var array
*/
public $default_modifiers = array();
/**
* autoescape variable output
*
* @var boolean
*/
public $escape_html = false;
/**
* start time for execution time calculation
*
* @var int
*/
public $start_time = 0;
/**
* required by the compiler for BC
*
* @var string
*/
public $_current_file = null;
/**
* internal flag to enable parser debugging
*
* @var bool
*/
public $_parserdebug = false;
/**
* This object type (Smarty = 1, template = 2, data = 4)
*
* @var int
*/
public $_objType = 1;
/**
* Debug object
*
* @var Smarty_Internal_Debug
*/
public $_debug = null;
/**
* template directory
*
* @var array
*/
protected $template_dir = array('./templates/');
/**
* flags for normalized template directory entries
*
* @var array
*/
protected $_processedTemplateDir = array();
/**
* config directory
*
* @var array
*/
protected $config_dir = array('./configs/');
/**
* flags for normalized template directory entries
*
* @var array
*/
protected $_processedConfigDir = array();
/**
* compile directory
*
* @var string
*/
protected $compile_dir = './templates_c/';
/**
* plugins directory
*
* @var array
*/
protected $plugins_dir = array();
/**
* cache directory
*
* @var string
*/
protected $cache_dir = './cache/';
/**
* removed properties
*
* @var string[]
*/
protected $obsoleteProperties = array('resource_caching', 'template_resource_caching', 'direct_access_security',
'_dir_perms', '_file_perms', 'plugin_search_order',
'inheritance_merge_compiled_includes', 'resource_cache_mode',);
protected $obsoleteProperties = array(
'resource_caching', 'template_resource_caching', 'direct_access_security',
'_dir_perms', '_file_perms', 'plugin_search_order',
'inheritance_merge_compiled_includes', 'resource_cache_mode',
);
/**
* List of private properties which will call getter/setter on a direct access
*
* @var string[]
*/
protected $accessMap = array('template_dir' => 'TemplateDir', 'config_dir' => 'ConfigDir',
'plugins_dir' => 'PluginsDir', 'compile_dir' => 'CompileDir',
'cache_dir' => 'CacheDir',);
protected $accessMap = array(
'template_dir' => 'TemplateDir', 'config_dir' => 'ConfigDir',
'plugins_dir' => 'PluginsDir', 'compile_dir' => 'CompileDir',
'cache_dir' => 'CacheDir',
);
/**
* Initialize new Smarty object
@ -618,7 +692,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Enable error handler to mute expected messages
*
* @return boolean
* @return boolean
* @deprecated
*/
public static function muteExpectedErrors()
@ -639,7 +713,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Check if a template resource exists
*
* @param string $resource_name template name
* @param string $resource_name template name
*
* @return bool status
* @throws \SmartyException
@ -654,10 +728,10 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Loads security class and enables security
*
* @param string|Smarty_Security $security_class if a string is used, it must be class-name
* @param string|Smarty_Security $security_class if a string is used, it must be class-name
*
* @return Smarty current Smarty instance for chaining
* @throws SmartyException when an invalid class name is provided
* @throws \SmartyException
*/
public function enableSecurity($security_class = null)
{
@ -679,9 +753,9 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Add template directory(s)
*
* @param string|array $template_dir directory(s) of template sources
* @param string $key of the array element to assign the template dir to
* @param bool $isConfig true for config_dir
* @param string|array $template_dir directory(s) of template sources
* @param string $key of the array element to assign the template dir to
* @param bool $isConfig true for config_dir
*
* @return Smarty current Smarty instance for chaining
*/
@ -747,8 +821,8 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Set template directory
*
* @param string|array $template_dir directory(s) of template sources
* @param bool $isConfig true for config_dir
* @param string|array $template_dir directory(s) of template sources
* @param bool $isConfig true for config_dir
*
* @return \Smarty current Smarty instance for chaining
*/
@ -835,7 +909,7 @@ class Smarty extends Smarty_Internal_TemplateBase
$this->plugins_dir = (array)$this->plugins_dir;
}
foreach ($this->plugins_dir as $k => $v) {
$this->plugins_dir[ $k ] = $this->_realpath(rtrim($v, "/\\") . DIRECTORY_SEPARATOR, true);
$this->plugins_dir[ $k ] = $this->_realpath(rtrim($v, '/\\') . DIRECTORY_SEPARATOR, true);
}
$this->_cache[ 'plugin_files' ] = array();
$this->_pluginsDirNormalized = true;
@ -846,7 +920,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Set plugins directory
*
* @param string|array $plugins_dir directory(s) of plugins
* @param string|array $plugins_dir directory(s) of plugins
*
* @return Smarty current Smarty instance for chaining
*/
@ -901,7 +975,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Set cache directory
*
* @param string $cache_dir directory to store cached templates in
* @param string $cache_dir directory to store cached templates in
*
* @return Smarty current Smarty instance for chaining
*/
@ -915,11 +989,11 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* creates a template object
*
* @param string $template the resource handle of the template file
* @param mixed $cache_id cache id to be used with this template
* @param mixed $compile_id compile id to be used with this template
* @param object $parent next higher level of Smarty variables
* @param boolean $do_clone flag is Smarty object shall be cloned
* @param string $template the resource handle of the template file
* @param mixed $cache_id cache id to be used with this template
* @param mixed $compile_id compile id to be used with this template
* @param object $parent next higher level of Smarty variables
* @param boolean $do_clone flag is Smarty object shall be cloned
*
* @return \Smarty_Internal_Template template object
* @throws \SmartyException
@ -946,7 +1020,7 @@ class Smarty extends Smarty_Internal_TemplateBase
Smarty_Internal_Template::$isCacheTplObj[ $_templateId ];
$tpl->inheritance = null;
$tpl->tpl_vars = $tpl->config_vars = array();
} else if (!$do_clone && isset(Smarty_Internal_Template::$tplObjCache[ $_templateId ])) {
} elseif (!$do_clone && isset(Smarty_Internal_Template::$tplObjCache[ $_templateId ])) {
$tpl = clone Smarty_Internal_Template::$tplObjCache[ $_templateId ];
$tpl->inheritance = null;
$tpl->tpl_vars = $tpl->config_vars = array();
@ -981,11 +1055,11 @@ class Smarty extends Smarty_Internal_TemplateBase
* class name format: Smarty_PluginType_PluginName
* plugin filename format: plugintype.pluginname.php
*
* @param string $plugin_name class plugin name to load
* @param bool $check check if already loaded
* @param string $plugin_name class plugin name to load
* @param bool $check check if already loaded
*
* @throws SmartyException
* @return string |boolean filepath of loaded file or false
* @throws \SmartyException
*/
public function loadPlugin($plugin_name, $check = true)
{
@ -1004,12 +1078,13 @@ class Smarty extends Smarty_Internal_TemplateBase
* @return string
* @throws \SmartyException
*/
public function _getTemplateId($template_name,
$cache_id = null,
$compile_id = null,
$caching = null,
Smarty_Internal_Template $template = null)
{
public function _getTemplateId(
$template_name,
$cache_id = null,
$compile_id = null,
$caching = null,
Smarty_Internal_Template $template = null
) {
$template_name = (strpos($template_name, ':') === false) ? "{$this->default_resource_type}:{$template_name}" :
$template_name;
$cache_id = $cache_id === null ? $this->cache_id : $cache_id;
@ -1033,33 +1108,22 @@ class Smarty extends Smarty_Internal_TemplateBase
* - remove /./ and /../
* - make it absolute if required
*
* @param string $path file path
* @param bool $realpath if true - convert to absolute
* false - convert to relative
* null - keep as it is but remove /./ /../
* @param string $path file path
* @param bool $realpath if true - convert to absolute
* false - convert to relative
* null - keep as it is but
* remove /./ /../
*
* @return string
*/
public function _realpath($path, $realpath = null)
{
static $nds = null;
static $sepDotsep = null;
static $sepDot = null;
static $sepSep =null;
if (!isset($nds)) {
$nds = array('/' => '\\', '\\' => '/');
$sepDotsep = DIRECTORY_SEPARATOR . '.' . DIRECTORY_SEPARATOR;
$sepDot = DIRECTORY_SEPARATOR . '.';
$sepSep = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
}
// normalize DIRECTORY_SEPARATOR
$path = str_replace(array($nds[DIRECTORY_SEPARATOR], $sepDotsep), DIRECTORY_SEPARATOR, $path);
if (strpos($path,$sepDot) === false && (($realpath === false && $path[0] === '.') || $realpath === null) && $path[0] !== '\\') {
return $path;
}
preg_match('%^(?<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(.*))$%u',
$path,
$parts);
$nds = array('/' => '\\', '\\' => '/');
preg_match(
'%^(?<root>(?:[[:alpha:]]:[\\\\/]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(.*))$%u',
$path,
$parts
);
$path = $parts[ 'path' ];
if ($parts[ 'root' ] === '\\') {
$parts[ 'root' ] = substr(getcwd(), 0, 2) . $parts[ 'root' ];
@ -1068,24 +1132,18 @@ class Smarty extends Smarty_Internal_TemplateBase
$path = getcwd() . DIRECTORY_SEPARATOR . $path;
}
}
// remove noop 'DIRECTORY_SEPARATOR DIRECTORY_SEPARATOR' and 'DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR' patterns
$path = str_replace(array($sepDotsep,$sepSep), DIRECTORY_SEPARATOR, $path);
// resolve '..DIRECTORY_SEPARATOR' pattern, smallest first
if (strpos($path, '..' . DIRECTORY_SEPARATOR) !== false &&
preg_match_all('#[\\\\/]([.][.][\\\\/])+#u', $path, $match)
) {
$counts = array();
foreach ($match[ 0 ] as $m) {
$counts[] = (int)((strlen($m) - 1) / 3);
}
sort($counts);
foreach ($counts as $count) {
$path = preg_replace('#([\\\\/]+[^\\\\/]+){' . $count .
'}[\\\\/]+([.][.][\\\\/]+){' . $count . '}#u',
DIRECTORY_SEPARATOR,
$path);
}
}
// normalize DIRECTORY_SEPARATOR
$path = str_replace($nds[ DIRECTORY_SEPARATOR ], DIRECTORY_SEPARATOR, $path);
$parts[ 'root' ] = str_replace($nds[ DIRECTORY_SEPARATOR ], DIRECTORY_SEPARATOR, $parts[ 'root' ]);
do {
$path = preg_replace(
array('#[\\\\/]{2}#', '#[\\\\/][.][\\\\/]#', '#[\\\\/]([^\\\\/.]+)[\\\\/][.][.][\\\\/]#'),
DIRECTORY_SEPARATOR,
$path,
-1,
$count
);
} while ($count > 0);
return $realpath !== false ? $parts[ 'root' ] . $path : str_ireplace(getcwd(), '.', $parts[ 'root' ] . $path);
}
@ -1279,19 +1337,18 @@ class Smarty extends Smarty_Internal_TemplateBase
* Calls the appropriate getter function.
* Issues an E_USER_NOTICE if no valid getter is found.
*
* @param string $name property name
* @param string $name property name
*
* @return mixed
* @throws \SmartyException
*/
public function __get($name)
{
if (isset($this->accessMap[ $name ])) {
$method = 'get' . $this->accessMap[ $name ];
return $this->{$method}();
} else if (isset($this->_cache[ $name ])) {
} elseif (isset($this->_cache[ $name ])) {
return $this->_cache[ $name ];
} else if (in_array($name, $this->obsoleteProperties)) {
} elseif (in_array($name, $this->obsoleteProperties)) {
return null;
} else {
trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
@ -1307,21 +1364,18 @@ class Smarty extends Smarty_Internal_TemplateBase
* @param string $name property name
* @param mixed $value parameter passed to setter
*
* @throws \SmartyException
*/
public function __set($name, $value)
{
if (isset($this->accessMap[ $name ])) {
$method = 'set' . $this->accessMap[ $name ];
$this->{$method}($value);
} else if (in_array($name, $this->obsoleteProperties)) {
} elseif (in_array($name, $this->obsoleteProperties)) {
return;
} elseif (is_object($value) && method_exists($value, $name)) {
$this->$name = $value;
} else {
if (is_object($value) && method_exists($value, $name)) {
$this->$name = $value;
} else {
trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
}
trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
}
}
@ -1345,7 +1399,6 @@ class Smarty extends Smarty_Internal_TemplateBase
* Normalize template_dir or config_dir
*
* @param bool $isConfig true for config_dir
*
*/
private function _normalizeTemplateConfig($isConfig)
{

View file

@ -28,7 +28,7 @@
/**
* @ignore
*/
require_once(dirname(__FILE__) . '/Smarty.class.php');
require_once dirname(__FILE__) . '/Smarty.class.php';
/**
* Smarty Backward Compatibility Wrapper Class
@ -53,7 +53,6 @@ class SmartyBC extends Smarty
/**
* Initialize new SmartyBC object
*
*/
public function __construct()
{
@ -127,12 +126,16 @@ class SmartyBC extends Smarty
* @param boolean $smarty_args smarty argument format, else traditional
* @param array $block_methods list of methods that are block format
*
* @throws SmartyException
* @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())
{
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);
@ -326,10 +329,10 @@ class SmartyBC extends Smarty
/**
* 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
* @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
*/
@ -341,7 +344,7 @@ class SmartyBC extends Smarty
/**
* clear the entire contents of cache (all templates)
*
* @param string $exp_time expire time
* @param string $exp_time expire time
*
* @return boolean
*/
@ -353,9 +356,9 @@ class SmartyBC extends Smarty
/**
* 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
* @param string $tpl_file name of template file
* @param string $cache_id
* @param string $compile_id
*
* @return bool
* @throws \Exception
@ -379,9 +382,9 @@ class SmartyBC extends Smarty
* 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
* @param string $tpl_file
* @param string $compile_id
* @param string $exp_time
*
* @return boolean results of {@link smarty_core_rm_auto()}
*/
@ -393,7 +396,7 @@ class SmartyBC extends Smarty
/**
* Checks whether requested template exists.
*
* @param string $tpl_file
* @param string $tpl_file
*
* @return bool
* @throws \SmartyException
@ -406,7 +409,7 @@ class SmartyBC extends Smarty
/**
* Returns an array containing template variables
*
* @param string $name
* @param string $name
*
* @return array
*/
@ -418,7 +421,7 @@ class SmartyBC extends Smarty
/**
* Returns an array containing config variables
*
* @param string $name
* @param string $name
*
* @return array
*/
@ -442,7 +445,7 @@ class SmartyBC extends Smarty
/**
* return a reference to a registered object
*
* @param string $name
* @param string $name
*
* @return object
*/

View file

@ -1,5 +1,5 @@
<?php
/*
/**
* This file is part of the Smarty package.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
@ -7,11 +7,10 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
/**
* Load and register Smarty Autoloader
*/
if (!class_exists('Smarty_Autoloader')) {
require dirname(__FILE__) . '/Autoloader.php';
include dirname(__FILE__) . '/Autoloader.php';
}
Smarty_Autoloader::register(true);

View file

@ -113,10 +113,10 @@
<div>
{foreach $template_data as $template}
<font color=brown>{$template.name}</font>
<br>&nbsp;&nbsp;<span class="exectime">
<br />&nbsp;&nbsp;<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>
<br />
{/foreach}
</div>
{/if}
@ -127,7 +127,7 @@
{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['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>

View file

@ -20,7 +20,6 @@
* - indent_char - string (" ")
* - wrap_boundary - boolean (true)
*
*
* @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
* (Smarty online manual)
*
@ -39,10 +38,15 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
return;
}
if (Smarty::$_MBSTRING) {
$template->_checkPlugins(array(array('function' => 'smarty_modifier_mb_wordwrap',
'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php')));
$template->_checkPlugins(
array(
array(
'function' => 'smarty_modifier_mb_wordwrap',
'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php'
)
)
);
}
$style = null;
$indent = 0;
$indent_first = 0;
@ -51,47 +55,48 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
$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;
$$_key = (string)$_val;
break;
case 'indent':
case 'indent_first':
case 'wrap':
$$_key = (int) $_val;
$$_key = (int)$_val;
break;
case 'wrap_cut':
$$_key = (bool) $_val;
$$_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);
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;
@ -108,7 +113,6 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
}
}
$_output = implode($wrap_char . $wrap_char, $_paragraphs);
if ($assign) {
$template->assign($assign, $_output);
} else {

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {counter} function plugin
* Type: function
@ -24,50 +23,40 @@
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' ];
$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' ];
$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;
}

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {cycle} function plugin
* Type: function
@ -29,34 +28,29 @@
* {cycle name=row values="one,two,three" reset=true}
* {cycle name=row}
*
*
* @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
* @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
* @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;
$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 {
@ -65,41 +59,34 @@ function smarty_function_cycle($params, $template)
}
$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' ] ++;
$cycle_vars[ $name ][ 'index' ]++;
}
}
return $retval;
}

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {fetch} plugin
* Type: function
@ -26,20 +25,16 @@ 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, …)
@ -53,7 +48,6 @@ function smarty_function_fetch($params, $template)
}
}
}
$content = '';
if ($protocol === 'http') {
// http fetch
@ -104,7 +98,6 @@ function smarty_function_fetch($params, $template)
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;
@ -118,10 +111,9 @@ function smarty_function_fetch($params, $template)
break;
case 'proxy_port':
if (!preg_match('!\D!', $param_value)) {
$proxy_port = (int) $param_value;
$proxy_port = (int)$param_value;
} else {
trigger_error("[plugin] invalid value for attribute '{$param_key }'", E_USER_NOTICE);
return;
}
break;
@ -137,16 +129,14 @@ function smarty_function_fetch($params, $template)
break;
case 'timeout':
if (!preg_match('!\D!', $param_value)) {
$timeout = (int) $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;
}
}
@ -156,10 +146,8 @@ function smarty_function_fetch($params, $template)
} 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) {
@ -187,23 +175,19 @@ function smarty_function_fetch($params, $template)
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 {
@ -212,7 +196,6 @@ function smarty_function_fetch($params, $template)
throw new SmartyException("{fetch} cannot read resource '" . $params[ 'file' ] . "'");
}
}
if (!empty($params[ 'assign' ])) {
$template->assign($params[ 'assign' ], $content);
} else {

View file

@ -29,25 +29,29 @@
* - 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}
* @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
* @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()
* @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')));
$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;
@ -57,31 +61,25 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
$labels = true;
$label_ids = false;
$output = null;
$extra = '';
foreach ($params as $_key => $_val) {
switch ($_key) {
case 'name':
case 'separator':
$$_key = (string) $_val;
$$_key = (string)$_val;
break;
case 'escape':
case 'labels':
case 'label_ids':
$$_key = (bool) $_val;
$$_key = (bool)$_val;
break;
case 'options':
$$_key = (array) $_val;
$$_key = (array)$_val;
break;
case 'values':
case 'output':
$$_key = array_values((array) $_val);
$$_key = array_values((array)$_val);
break;
case 'checked':
case 'selected':
if (is_array($_val)) {
@ -89,57 +87,61 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
foreach ($_val as $_sel) {
if (is_object($_sel)) {
if (method_exists($_sel, '__toString')) {
$_sel = smarty_function_escape_special_chars((string) $_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);
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);
$_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());
$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);
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);
$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;
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);
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) . '"';
@ -149,34 +151,49 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
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);
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);
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
@ -190,59 +207,69 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
*
* @return string
*/
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels,
$label_ids, $escape = true)
{
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();
$value = (string)$value->__toString();
} else {
trigger_error('html_options: value is an object of class \'' . get_class($value) .
'\' without __toString() method', E_USER_NOTICE);
trigger_error(
'html_options: value is an object of class \'' . get_class($value) .
'\' without __toString() method',
E_USER_NOTICE
);
return '';
}
} else {
$value = (string) $value;
$value = (string)$value;
}
if (is_object($output)) {
if (method_exists($output, '__toString')) {
$output = (string) $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);
trigger_error(
'html_options: output is an object of class \'' . get_class($output) .
'\' without __toString() method',
E_USER_NOTICE
);
return '';
}
} else {
$output = (string) $output;
$output = (string)$output;
}
if ($labels) {
if ($label_ids) {
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_',
$name . '_' . $value));
$_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"';
@ -250,13 +277,10 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
} elseif ($value === $selected) {
$_output .= ' checked="checked"';
}
$_output .= $extra . ' />' . $output;
if ($labels) {
$_output .= '</label>';
}
$_output .= $separator;
return $_output;
}

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {html_image} function plugin
* Type: function
@ -22,7 +21,6 @@
* - 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>
@ -38,9 +36,14 @@
*/
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')));
$template->_checkPlugins(
array(
array(
'function' => 'smarty_function_escape_special_chars',
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
)
)
);
$alt = '';
$file = '';
$height = '';
@ -60,53 +63,50 @@ function smarty_function_html_image($params, Smarty_Internal_Template $template)
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);
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);
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, …)
@ -120,25 +120,20 @@ function smarty_function_html_image($params, Smarty_Internal_Template $template)
}
}
}
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 ];
}
@ -146,7 +141,6 @@ function smarty_function_html_image($params, Smarty_Internal_Template $template)
$height = $_image_data[ 1 ];
}
}
if (isset($params[ 'dpi' ])) {
if (strstr($_SERVER[ 'HTTP_USER_AGENT' ], 'Mac')) {
// FIXME: (rodneyrehm) wrong dpi assumption
@ -159,7 +153,6 @@ function smarty_function_html_image($params, Smarty_Internal_Template $template)
$width = round($width * $_resize);
$height = round($height * $_resize);
}
return $prefix . '<img src="' . $path_prefix . $file . '" alt="' . $alt . '" width="' . $width . '" height="' .
$height . '"' . $extra . ' />' . $suffix;
}

View file

@ -21,25 +21,29 @@
* - 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}
* @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>
* @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()
* @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')));
$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;
@ -47,74 +51,73 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
$output = null;
$id = null;
$class = null;
$extra = '';
foreach ($params as $_key => $_val) {
switch ($_key) {
case 'name':
case 'class':
case 'id':
$$_key = (string) $_val;
$$_key = (string)$_val;
break;
case 'options':
$options = (array) $_val;
$options = (array)$_val;
break;
case 'values':
case 'output':
$$_key = array_values((array) $_val);
$$_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());
$_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);
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);
$_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());
$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);
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);
$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);
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) . '"';
@ -124,16 +127,12 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
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);
@ -144,7 +143,6 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
$_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 . '"' : '';
@ -152,9 +150,9 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
'<select name="' . $name . '"' . $_html_class . $_html_id . $extra . '>' . "\n" . $_html_result .
'</select>' . "\n";
}
return $_html_result;
}
/**
* @param $key
* @param $value
@ -181,28 +179,36 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c
$_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());
$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);
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);
$value = smarty_function_escape_special_chars((string)$value);
}
$_html_result .= $_html_class . $_html_id . '>' . $value . '</option>' . "\n";
$idx ++;
$idx++;
} else {
$_idx = 0;
$_html_result =
smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id . '-' . $idx) : null,
$class, $_idx);
$idx ++;
smarty_function_html_options_optgroup(
$key,
$value,
$selected,
!empty($id) ? ($id . '-' . $idx) : null,
$class,
$_idx
);
$idx++;
}
return $_html_result;
}
/**
* @param $key
* @param $values
@ -220,6 +226,5 @@ function smarty_function_html_options_optgroup($key, $values, $selected, $id, $c
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected, $id, $class, $idx);
}
$optgroup_html .= "</optgroup>\n";
return $optgroup_html;
}

View file

@ -29,7 +29,6 @@
* {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>
@ -45,9 +44,14 @@
*/
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')));
$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;
@ -58,73 +62,69 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
$label_ids = false;
$output = null;
$extra = '';
foreach ($params as $_key => $_val) {
switch ($_key) {
case 'name':
case 'separator':
$$_key = (string) $_val;
$$_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());
$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);
trigger_error(
'html_radios: selected attribute is an object of class \'' . get_class($_val) .
'\' without __toString() method',
E_USER_NOTICE
);
}
} else {
$selected = (string) $_val;
$selected = (string)$_val;
}
break;
case 'escape':
case 'labels':
case 'label_ids':
$$_key = (bool) $_val;
$$_key = (bool)$_val;
break;
case 'options':
$$_key = (array) $_val;
$$_key = (array)$_val;
break;
case 'values':
case 'output':
$$_key = array_values((array) $_val);
$$_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;
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);
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) . '"';
@ -134,36 +134,50 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
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);
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);
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
@ -177,69 +191,76 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
*
* @return string
*/
function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids,
$escape)
{
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();
$value = (string)$value->__toString();
} else {
trigger_error('html_options: value is an object of class \'' . get_class($value) .
'\' without __toString() method', E_USER_NOTICE);
trigger_error(
'html_options: value is an object of class \'' . get_class($value) .
'\' without __toString() method',
E_USER_NOTICE
);
return '';
}
} else {
$value = (string) $value;
$value = (string)$value;
}
if (is_object($output)) {
if (method_exists($output, '__toString')) {
$output = (string) $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);
trigger_error(
'html_options: output is an object of class \'' . get_class($output) .
'\' without __toString() method',
E_USER_NOTICE
);
return '';
}
} else {
$output = (string) $output;
$output = (string)$output;
}
if ($labels) {
if ($label_ids) {
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_',
$name . '_' . $value));
$_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;
}

View file

@ -28,13 +28,12 @@
* - 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}
* @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
* @version 2.0
* @author Andrei Zmievski
* @author Monte Ohrt <monte at ohrt dot com>
* @author Rodney Rehm
*
* @param array $params parameters
*
@ -45,19 +44,24 @@
*/
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')));
$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 ++) {
for ($i = 1; $i <= 12; $i++) {
$_month_timestamps[ $i ] = mktime(0, 0, 0, $i, 1, 2000);
}
}
/* Default values. */
$prefix = 'Date_';
$start_year = null;
@ -106,17 +110,21 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$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')));
$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;
@ -124,7 +132,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
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':
@ -151,17 +158,15 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
case 'month_id':
case 'day_id':
case 'year_id':
$$_key = (string) $_value;
$$_key = (string)$_value;
break;
case 'display_days':
case 'display_months':
case 'display_years':
case 'year_as_text':
case 'reverse_years':
$$_key = (bool) $_value;
$$_key = (bool)$_value;
break;
default:
if (!is_array($_value)) {
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
@ -171,15 +176,16 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
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) {
foreach (array(
'Y' => 'Year',
'm' => 'Month',
'd' => 'Day'
) as $_elementKey => $_elementName) {
$_variableName = '_' . strtolower($_elementName);
$$_variableName =
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
@ -187,9 +193,11 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
}
} elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Year' ])) {
// $_REQUEST given
foreach (array('Y' => 'Year',
'm' => 'Month',
'd' => 'Day') as $_elementKey => $_elementName) {
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);
@ -207,31 +215,30 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
} 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) {
foreach (array(
'start',
'end'
) as $key) {
$key .= '_year';
$t = $$key;
if ($t === null) {
$$key = (int) $_current_year;
$$key = (int)$_current_year;
} elseif ($t[ 0 ] === '+') {
$$key = (int) ($_current_year + (int) trim(substr($t, 1)));
$$key = (int)($_current_year + (int)trim(substr($t, 1)));
} elseif ($t[ 0 ] === '-') {
$$key = (int) ($_current_year - (int) trim(substr($t, 1)));
$$key = (int)($_current_year - (int)trim(substr($t, 1)));
} else {
$$key = (int) $$key;
$$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 = '';
@ -242,7 +249,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
if ($year_extra) {
$_extra .= ' ' . $year_extra;
}
if ($year_as_text) {
$_html_years =
'<input type="text" name="' . $_name . '" value="' . $_year . '" size="4" maxlength="4"' . $_extra .
@ -250,31 +256,29 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
} 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)) . '"';
$_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;
$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 = '';
@ -285,25 +289,24 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
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)) . '"';
$_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 ++) {
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 ]));
@ -311,10 +314,8 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$_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 = '';
@ -325,37 +326,34 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
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)) . '"';
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 ++) {
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 ++) {
for ($i = 0; $i <= 2; $i++) {
switch ($field_order[ $i ]) {
case 'Y':
case 'y':
@ -366,7 +364,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$_html .= $_html_years;
}
break;
case 'm':
case 'M':
if (isset($_html_months)) {
@ -376,7 +373,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$_html .= $_html_months;
}
break;
case 'd':
case 'D':
if (isset($_html_days)) {
@ -388,6 +384,5 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
break;
}
}
return $_html;
}

View file

@ -11,130 +11,124 @@
* 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}
* @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>
* @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()
* @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')));
$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')));
$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;
$$_key = (string)$_value;
break;
case 'display_hours':
case 'display_minutes':
case 'display_seconds':
case 'display_meridian':
case 'use_24_hours':
$$_key = (bool) $_value;
$$_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;
$$_key = (int)$_value;
break;
default:
if (!is_array($_value)) {
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
@ -144,13 +138,14 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
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) {
foreach (array(
'H' => 'Hour',
'i' => 'Minute',
's' => 'Second'
) as $_elementKey => $_elementName) {
$_variableName = '_' . strtolower($_elementName);
$$_variableName =
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
@ -163,9 +158,11 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
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) {
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);
@ -187,7 +184,6 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
} else {
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
}
// generate hour <select>
if ($display_hours) {
$_html_hours = '';
@ -199,42 +195,37 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
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)) . '"';
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 ++) {
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 = '';
@ -246,24 +237,23 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
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)) . '"';
$_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);
@ -272,10 +262,8 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$_html_minutes .= '<option value="' . $_value . '"' . ($selected === $i ? ' selected="selected"' : '') .
'>' . $_text . '</option>' . $option_separator;
}
$_html_minutes .= '</select>';
}
// generate second <select>
if ($display_seconds) {
$_html_seconds = '';
@ -287,24 +275,23 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
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)) . '"';
$_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);
@ -313,10 +300,8 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$_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 = '';
@ -328,36 +313,36 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
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)) . '"';
$_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) {
foreach (array(
'_html_hours',
'_html_minutes',
'_html_seconds',
'_html_meridian'
) as $k) {
if (isset($$k)) {
if ($_html) {
$_html .= $field_separator;
@ -365,6 +350,5 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$_html .= $$k;
}
}
return $_html;
}

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {html_table} function plugin
* Type: function
@ -35,12 +34,11 @@
* {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}
* @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
@ -61,19 +59,15 @@ function smarty_function_html_table($params)
$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;
$$_key = (array)$_value;
break;
case 'cols':
if (is_array($_value) && !empty($_value)) {
$cols = $_value;
@ -82,25 +76,22 @@ function smarty_function_html_table($params)
$cols = explode(',', $_value);
$cols_count = count($cols);
} elseif (!empty($_value)) {
$cols_count = (int) $_value;
$cols_count = (int)$_value;
} else {
$cols_count = $cols;
}
break;
case 'rows':
$$_key = (int) $_value;
$$_key = (int)$_value;
break;
case 'table_attr':
case 'trailpad':
case 'hdir':
case 'vdir':
case 'inner':
case 'caption':
$$_key = (string) $_value;
$$_key = (string)$_value;
break;
case 'tr_attr':
case 'td_attr':
case 'th_attr':
@ -108,7 +99,6 @@ function smarty_function_html_table($params)
break;
}
}
$loop_count = count($loop);
if (empty($params[ 'rows' ])) {
/* no rows specified */
@ -119,37 +109,30 @@ function smarty_function_html_table($params)
$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 ++) {
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 ++) {
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 ++) {
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 {
@ -160,9 +143,9 @@ function smarty_function_html_table($params)
}
$output .= "</tbody>\n";
$output .= "</table>\n";
return $output;
}
/**
* @param $name
* @param $var
@ -177,6 +160,5 @@ function smarty_function_html_table_cycle($name, $var, $no)
} else {
$ret = $var[ $no % count($var) ];
}
return ($ret) ? ' ' . $ret : '';
}

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {mailto} function plugin
* Type: function
@ -37,12 +36,11 @@
* {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}
* @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)
* @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
*
@ -53,15 +51,12 @@ 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.
@ -77,61 +72,52 @@ function smarty_function_mailto($params)
$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);
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 ++) {
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 ++) {
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 ++) {
for ($x = 0, $_length = strlen($address); $x < $_length; $x++) {
if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[ $x ])) {
$address_encode .= '%' . bin2hex($address[ $x ]);
} else {
@ -139,12 +125,10 @@ function smarty_function_mailto($params)
}
}
$text_encode = '';
for ($x = 0, $_length = strlen($text); $x < $_length; $x ++) {
for ($x = 0, $_length = strlen($text); $x < $_length; $x++) {
$text_encode .= '&#x' . bin2hex($text[ $x ]) . ';';
}
$mailto = "&#109;&#97;&#105;&#108;&#116;&#111;&#58;";
return '<a href="' . $mailto . $address_encode . '" ' . $extra . '>' . $text_encode . '</a>';
} else {
// no encoding

View file

@ -6,16 +6,15 @@
* @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}
* @link http://www.smarty.net/manual/en/language.function.math.php {math}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author Monte Ohrt <monte at ohrt dot com>
*
* @param array $params parameters
* @param Smarty_Internal_Template $template template object
@ -25,66 +24,71 @@
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);
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);
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);
@ -92,7 +96,6 @@ function smarty_function_math($params, $template)
}
$smarty_math_result = null;
eval("\$smarty_math_result = " . $equation . ";");
if (empty($params[ 'format' ])) {
if (empty($params[ 'assign' ])) {
return $smarty_math_result;

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifier
*/
/**
* Smarty capitalize modifier plugin
* Type: modifier
@ -29,50 +28,75 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
$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);
$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)) {
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 ]));
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);
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);
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)) {
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);
$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()
@ -89,6 +113,7 @@ function smarty_mod_cap_mbconvert_cb($matches)
{
return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 2 ]), MB_CASE_UPPER, Smarty::$_CHARSET);
}
/**
* @param $matches
*
@ -98,6 +123,7 @@ function smarty_mod_cap_mbconvert2_cb($matches)
{
return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 3 ]), MB_CASE_UPPER, Smarty::$_CHARSET);
}
/**
* @param $matches
*
@ -107,6 +133,7 @@ function smarty_mod_cap_ucfirst_cb($matches)
{
return stripslashes($matches[ 1 ]) . ucfirst(stripslashes($matches[ 2 ]));
}
/**
* @param $matches
*

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifier
*/
/**
* Smarty date_format modifier plugin
* Type: modifier
@ -38,7 +37,7 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
static $is_loaded = false;
if (!$is_loaded) {
if (!is_callable('smarty_make_timestamp')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
include_once SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php';
}
$is_loaded = true;
}
@ -51,20 +50,24 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
}
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');
$_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));
@ -75,7 +78,6 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
}
$format = str_replace($_win_from, $_win_to, $format);
}
return strftime($format, $timestamp);
} else {
return date($format, $timestamp);

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage Debug
*/
/**
* Smarty debug_print_var modifier plugin
* Type: modifier
@ -26,7 +25,7 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
{
$_replace = array("\n" => '\n', "\r" => '\r', "\t" => '\t');
switch (gettype($var)) {
case 'array' :
case 'array':
$results = '<b>Array (' . count($var) . ')</b>';
if ($depth === $max) {
break;
@ -34,12 +33,11 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
foreach ($var as $curr_key => $curr_val) {
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b>' . strtr($curr_key, $_replace) .
'</b> =&gt; ' .
smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects);
$depth --;
smarty_modifier_debug_print_var($curr_val, $max, $length, ++$depth, $objects);
$depth--;
}
break;
case 'object' :
case 'object':
$object_vars = get_object_vars($var);
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
if (in_array($var, $objects)) {
@ -52,14 +50,13 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
$objects[] = $var;
foreach ($object_vars as $curr_key => $curr_val) {
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b> -&gt;' . strtr($curr_key, $_replace) .
'</b> = ' . smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects);
$depth --;
'</b> = ' . smarty_modifier_debug_print_var($curr_val, $max, $length, ++$depth, $objects);
$depth--;
}
break;
case 'boolean' :
case 'NULL' :
case 'resource' :
case 'boolean':
case 'NULL':
case 'resource':
if (true === $var) {
$results = 'true';
} elseif (false === $var) {
@ -67,17 +64,15 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
} elseif (null === $var) {
$results = 'null';
} else {
$results = htmlspecialchars((string) $var);
$results = htmlspecialchars((string)$var);
}
$results = '<i>' . $results . '</i>';
break;
case 'integer' :
case 'float' :
$results = htmlspecialchars((string) $var);
case 'integer':
case 'float':
$results = htmlspecialchars((string)$var);
break;
case 'string' :
case 'string':
$results = strtr($var, $_replace);
if (Smarty::$_MBSTRING) {
if (mb_strlen($var, Smarty::$_CHARSET) > $length) {
@ -88,13 +83,11 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
$results = substr($var, 0, $length - 3) . '...';
}
}
$results = htmlspecialchars('"' . $results . '"', ENT_QUOTES, Smarty::$_CHARSET);
break;
case 'unknown type' :
default :
$results = strtr((string) $var, $_replace);
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) . '...';
@ -104,9 +97,7 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
$results = substr($results, 0, $length - 3) . '...';
}
}
$results = htmlspecialchars($results, ENT_QUOTES, Smarty::$_CHARSET);
}
return $results;
}

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifier
*/
/**
* Smarty escape modifier plugin
* Type: modifier
@ -30,11 +29,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
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) {
@ -48,14 +45,21 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
// 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);
$string = str_replace(
array(
'%%%SMARTY_START%%%',
'%%%SMARTY_END%%%'
),
array(
'&',
';'
),
$string
);
return $string;
}
}
// no break
case 'htmlall':
if (Smarty::$_MBSTRING) {
// mb_convert_encoding ignores htmlspecialchars()
@ -71,18 +75,23 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
$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);
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);
@ -92,41 +101,43 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
} 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);
$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 ++) {
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')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php';
}
$is_loaded_1 = true;
}
@ -134,23 +145,20 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
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 ++) {
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')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php';
}
$is_loaded_1 = true;
}
@ -158,50 +166,66 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
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 ++) {
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',
'</' => '<\/'));
return strtr(
$string,
array(
'\\' => '\\\\',
"'" => "\\'",
'"' => '\\"',
"\r" => '\\r',
"\n" => '\\n',
'</' => '<\/'
)
);
case 'mail':
if (Smarty::$_MBSTRING) {
if (!$is_loaded_2) {
if (!is_callable('smarty_mb_str_replace')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php';
}
$is_loaded_2 = true;
}
return smarty_mb_str_replace(array('@',
'.'), array(' [AT] ',
' [DOT] '), $string);
return smarty_mb_str_replace(
array(
'@',
'.'
),
array(
' [AT] ',
' [DOT] '
),
$string
);
}
// no MBString fallback
return str_replace(array('@',
'.'), array(' [AT] ',
' [DOT] '), $string);
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')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php';
}
$is_loaded_1 = true;
}
@ -212,12 +236,10 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
$return .= chr($unicode);
}
}
return $return;
}
$_length = strlen($string);
for ($_i = 0; $_i < $_length; $_i ++) {
for ($_i = 0; $_i < $_length; $_i++) {
$_ord = ord(substr($string, $_i, 1));
// non-standard char, escape it
if ($_ord >= 126) {
@ -226,9 +248,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
$return .= substr($string, $_i, 1);
}
}
return $return;
default:
return $string;
}

View file

@ -11,13 +11,12 @@
* 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
* @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
@ -30,30 +29,28 @@ function smarty_modifier_mb_wordwrap($str, $width = 75, $break = "\n", $cut = fa
$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);
$_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)) {
@ -61,7 +58,7 @@ function smarty_modifier_mb_wordwrap($str, $width = 75, $break = "\n", $cut = fa
}
$length = $token_length;
}
} else if ($token === "\n") {
} elseif ($token === "\n") {
// hard break must reset counters
$length = 0;
}
@ -70,6 +67,5 @@ function smarty_modifier_mb_wordwrap($str, $width = 75, $break = "\n", $cut = fa
$t .= $token;
}
}
return $t;
}

View file

@ -5,16 +5,15 @@
* @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
* @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>
* @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string input string
* @param string|array $search regular expression(s) to search for
@ -23,7 +22,7 @@
*
* @return string
*/
function smarty_modifier_regex_replace($string, $search, $replace, $limit = - 1)
function smarty_modifier_regex_replace($string, $search, $replace, $limit = -1)
{
if (is_array($search)) {
foreach ($search as $idx => $s) {
@ -32,7 +31,6 @@ function smarty_modifier_regex_replace($string, $search, $replace, $limit = - 1)
} else {
$search = _smarty_regex_replace_check($search);
}
return preg_replace($search, $replace, $string, $limit);
}
@ -51,8 +49,7 @@ function _smarty_regex_replace_check($search)
}
// 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 ]);
$search = substr($search, 0, -strlen($match[ 1 ])) . preg_replace('![e\s]+!', '', $match[ 1 ]);
}
return $search;
}

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifier
*/
/**
* Smarty replace modifier plugin
* Type: modifier
@ -28,12 +27,11 @@ function smarty_modifier_replace($string, $search, $replace)
if (Smarty::$_MBSTRING) {
if (!$is_loaded) {
if (!is_callable('smarty_mb_str_replace')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php';
}
$is_loaded = true;
}
return smarty_mb_str_replace($search, $replace, $string);
return smarty_mb_str_replace($search, $replace, $string);
}
return str_replace($search, $replace, $string);
}

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifier
*/
/**
* Smarty spacify modifier plugin
* Type: modifier
@ -23,5 +22,5 @@
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));
return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY));
}

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifier
*/
/**
* Smarty truncate modifier plugin
* Type: modifier
@ -30,25 +29,24 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
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));
$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);
mb_substr($string, -$length / 2, $length, Smarty::$_CHARSET);
}
return $string;
}
// no MBString fallback
if (isset($string[ $length ])) {
$length -= min($length, strlen($etc));
@ -58,9 +56,7 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
if (!$middle) {
return substr($string, 0, $length) . $etc;
}
return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2);
return substr($string, 0, $length / 2) . $etc . substr($string, -$length / 2);
}
return $string;
}

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty cat modifier plugin
* Type: modifier
@ -15,9 +14,9 @@
* Input: string to catenate
* Example: {$var|cat:"foo"}
*
* @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
* @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
* (Smarty online manual)
* @author Uwe Tews
* @author Uwe Tews
*
* @param array $params parameters
*

View file

@ -5,14 +5,14 @@
* @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)
* @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online
* manual)
* @author Uwe Tews
*
* @param array $params parameters

View file

@ -5,16 +5,15 @@
* @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
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
* count_paragraphs (Smarty online manual)
* @author Uwe Tews
* @author Uwe Tews
*
* @param array $params parameters
*

View file

@ -5,16 +5,15 @@
* @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
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
* count_sentences (Smarty online manual)
* @author Uwe Tews
* @author Uwe Tews
*
* @param array $params parameters
*

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty count_words modifier plugin
* Type: modifier

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty default modifier plugin
* Type: modifier
@ -25,11 +24,9 @@ function smarty_modifiercompiler_default($params)
if (!isset($params[ 1 ])) {
$params[ 1 ] = "''";
}
array_shift($params);
foreach ($params as $param) {
$output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)';
}
return $output;
}

View file

@ -14,8 +14,8 @@
* @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
* @param array $params parameters
* @param Smarty_Internal_TemplateCompilerBase $compiler
*
* @return string with compiled code
* @throws \SmartyException
@ -24,21 +24,24 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
{
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')));
$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) {
@ -49,7 +52,7 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
} else {
// fall back to modifier.escape.php
}
// no break
case 'htmlall':
if (Smarty::$_MBSTRING) {
if ($_double_encode) {
@ -65,7 +68,6 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
// fall back to modifier.escape.php
}
}
// no MBString fallback
if ($_double_encode) {
// php >=5.2.3 - go native
@ -77,27 +79,23 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
} 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 ] .
return 'strtr(' .
$params[ 0 ] .
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
}
}
catch (SmartyException $e) {
} 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' ] =
@ -110,6 +108,5 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
$compiler->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'function' ] =
'smarty_modifier_escape';
}
return 'smarty_modifier_escape(' . join(', ', $params) . ')';
}

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty from_charset modifier plugin
* Type: modifier
@ -24,10 +23,8 @@ function smarty_modifiercompiler_from_charset($params)
// 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 ] . ')';
}

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty indent modifier plugin
* Type: modifier
@ -19,7 +18,6 @@
*
* @return string with compiled code
*/
function smarty_modifiercompiler_indent($params)
{
if (!isset($params[ 1 ])) {
@ -28,6 +26,5 @@ function smarty_modifiercompiler_indent($params)
if (!isset($params[ 2 ])) {
$params[ 2 ] = "' '";
}
return 'preg_replace(\'!^!m\',str_repeat(' . $params[ 2 ] . ',' . $params[ 1 ] . '),' . $params[ 0 ] . ')';
}

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty lower modifier plugin
* Type: modifier
@ -20,7 +19,6 @@
*
* @return string with compiled code
*/
function smarty_modifiercompiler_lower($params)
{
if (Smarty::$_MBSTRING) {

View file

@ -5,14 +5,13 @@
* @package Smarty
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty noprint modifier plugin
* Type: modifier
* Name: noprint
* Purpose: return an empty string
*
* @author Uwe Tews
* @author Uwe Tews
* @return string with compiled code
*/
function smarty_modifiercompiler_noprint()

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty string_format modifier plugin
* Type: modifier

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty strip modifier plugin
* Type: modifier
@ -22,12 +21,10 @@
*
* @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]})";
}

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty strip_tags modifier plugin
* Type: modifier

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty to_charset modifier plugin
* Type: modifier
@ -24,10 +23,8 @@ function smarty_modifiercompiler_to_charset($params)
// 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) . '")';
}

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty unescape modifier plugin
* Type: modifier
@ -28,22 +27,17 @@ function smarty_modifiercompiler_unescape($params)
} 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 ];
}

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty upper modifier plugin
* Type: modifier

View file

@ -33,7 +33,7 @@ function smarty_modifiercompiler_wordwrap($params, Smarty_Internal_TemplateCompi
}
$function = 'wordwrap';
if (Smarty::$_MBSTRING) {
$function = $compiler->getPlugin('mb_wordwrap','modifier');
$function = $compiler->getPlugin('mb_wordwrap', 'modifier');
}
return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')';
}

View file

@ -5,85 +5,85 @@
* @package Smarty
* @subpackage PluginsFilter
*/
/**
* Smarty trimwhitespace outputfilter plugin
* Trim unnecessary whitespace from HTML markup.
*
* @author Rodney Rehm
* @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!
* @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)) {
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 ++;
$_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)) {
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 ++;
$_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',
'#(: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' => '>',);
'#^\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 ++;
$_store++;
}
}
return $source;
}

View file

@ -5,16 +5,15 @@
* @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>
* @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string text that should by escaped
* @param string $string text that should by escaped
*
* @return string
*/
@ -29,6 +28,5 @@ function smarty_function_escape_special_chars($string)
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
}
}
return $string;
}

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsShared
*/
/**
* evaluate compiler parameter
*
@ -25,12 +24,12 @@ function smarty_literal_compiler_param($params, $index, $default = null)
}
// 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');
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;
}

View file

@ -5,12 +5,11 @@
* @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>
* @author Monte Ohrt <monte at ohrt dot com>
*
* @param DateTime|int|string $string date object, timestamp or string that can be converted using strtotime()
*
@ -21,25 +20,30 @@ function smarty_make_timestamp($string)
if (empty($string)) {
// use "now":
return time();
} elseif ($string instanceof DateTime ||
(interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface)
} elseif ($string instanceof DateTime
|| (interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface)
) {
return (int) $string->format('U'); // PHP 5.2 BC
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));
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;
return (int)$string;
} else {
// strtotime should handle it
$time = strtotime($string);
if ($time === - 1 || $time === false) {
if ($time === -1 || $time === false) {
// strtotime() was not able to parse $string, use "now":
return time();
}
return $time;
}
}

View file

@ -9,10 +9,10 @@ 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
* @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
@ -28,7 +28,7 @@ if (!function_exists('smarty_mb_str_replace')) {
$string = smarty_mb_str_replace($search, $replace, $string, $c);
$count += $c;
}
} else if (is_array($search)) {
} elseif (is_array($search)) {
if (!is_array($replace)) {
foreach ($search as &$string) {
$subject = smarty_mb_str_replace($string, $replace, $subject, $c);

View file

@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsShared
*/
/**
* convert characters to their decimal unicode equivalents
*
@ -24,7 +23,6 @@ function smarty_mb_to_unicode($string, $encoding = null)
} else {
$expanded = mb_convert_encoding($string, 'UTF-32BE');
}
return unpack('N*', $expanded);
}
@ -45,10 +43,9 @@ function smarty_mb_from_unicode($unicode, $encoding = null)
if (!$encoding) {
$encoding = mb_internal_encoding();
}
foreach ((array) $unicode as $utf32be) {
foreach ((array)$unicode as $utf32be) {
$character = pack('N*', $utf32be);
$t .= mb_convert_encoding($character, $encoding, 'UTF-32BE');
}
return $t;
}

Some files were not shown because too many files have changed in this diff Show more