pax_global_header 0000666 0000000 0000000 00000000064 13306571373 0014522 g ustar 00root root 0000000 0000000 52 comment=edee683bf242f40cc75bee46a78759f6c1589dca
raintpl3-3.1.1/ 0000775 0000000 0000000 00000000000 13306571373 0013260 5 ustar 00root root 0000000 0000000 raintpl3-3.1.1/.gitignore 0000664 0000000 0000000 00000000052 13306571373 0015245 0 ustar 00root root 0000000 0000000 .DS_Store
nbproject
vendor/*
test/cache/*
raintpl3-3.1.1/.travis.yml 0000664 0000000 0000000 00000000064 13306571373 0015371 0 ustar 00root root 0000000 0000000 language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
raintpl3-3.1.1/README.md 0000664 0000000 0000000 00000004217 13306571373 0014543 0 ustar 00root root 0000000 0000000 RainTPL 3
=========
By Federico Ulfo and a lot [awesome contributors](https://github.com/rainphp/raintpl3/network)!
[RainTPL](http://raintpl.com) is an easy template engine for PHP that enables designers and developers to work better together, it loads HTML template to separate the presentation from the logic.
Features
--------
* Easy for designers, only 10 tags, *{$variable}*, *{#constant#}*, *{include}*, *{loop}*, *{if}*, *{* comment *}*, *{noparse}*, *{function}*
* Easy for developers, 5 methods to load and draw templates.
* Powerful, modifier and operation with variables
* Extensible, load plugins and register new tags
* Secure, sandbox with blacklist.
Installation / Usage
--------------------
1. Install composer https://github.com/composer/composer
2. Create a composer.json inside your application folder:
``` json
{
"require": {
"rain/raintpl": ">=3.0.0"
}
}
```
3. Run the following code
``` sh
$ php composer.phar install
```
4. Run one example of RainTPL with your browser: ```http://localhost/raintpl3/example.php```
Documentation
-------------
The [documentation](https://github.com/rainphp/raintpl3/wiki/Documentation) of RainTPL is divided in [documentation for web designers](https://github.com/rainphp/raintpl3/wiki/Documentation-for-web-designers) and [documentation for PHP developers](https://github.com/rainphp/raintpl3/wiki/Documentation-for-PHP-developers).
Licence
-------
RainTPL 3, like its antecessor Rain.TPL version 2, is, as of 2018-06-07, published under the MIT Licence.
The above applies to RainTPL 3 itself, not the entire content of this repository. Some of the `example-*.php` files and the content below `templates/` in this repository are copies of external code under various licences, such as:
* Twitter Bootstrap, under the Apache v2 licence
* LESS - Leaner CSS, under the Apache v2 licence
Note that not all external content comes with full source code, it’s usually just a copy of (possibly minified or otherwise modified) parts of their distribution. The example files may be used as starting points without limitation except the licences on the external content.
raintpl3-3.1.1/cache/ 0000775 0000000 0000000 00000000000 13306571373 0014323 5 ustar 00root root 0000000 0000000 raintpl3-3.1.1/cache/.gitignore 0000664 0000000 0000000 00000000002 13306571373 0016303 0 ustar 00root root 0000000 0000000 *
raintpl3-3.1.1/composer.json 0000664 0000000 0000000 00000001103 13306571373 0015775 0 ustar 00root root 0000000 0000000 {
"name": "rain/raintpl",
"type": "library",
"description": "easy and fast template engine",
"homepage":"http://raintpl.com",
"license": "MIT",
"authors": [
{
"name": "Federico Ulfo",
"email": "rainelemental@gmail.com"
},
{
"name": "Rain Community"
}
],
"require": {
"php": ">=5.3"
},
"require-dev": {
"phpunit/phpunit": "4.4.*"
},
"minimum-stability": "dev",
"autoload": {
"psr-0": {
"Rain": "library/"
}
}
}
raintpl3-3.1.1/composer.lock 0000664 0000000 0000000 00000066764 13306571373 0016004 0 ustar 00root root 0000000 0000000 {
"_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": "63b9b594c97e46614b14e16b1b4527c4",
"packages": [],
"packages-dev": [
{
"name": "doctrine/instantiator",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "40efa2d8c9e2948b29fdf5d782babaacb08d0c86"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/40efa2d8c9e2948b29fdf5d782babaacb08d0c86",
"reference": "40efa2d8c9e2948b29fdf5d782babaacb08d0c86",
"shasum": ""
},
"require": {
"php": ">=5.3,<8.0-DEV"
},
"require-dev": {
"athletic/athletic": "~0.1.8",
"ext-pdo": "*",
"ext-phar": "*",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com",
"homepage": "http://ocramius.github.com/"
}
],
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
"homepage": "https://github.com/doctrine/instantiator",
"keywords": [
"constructor",
"instantiate"
],
"time": "2014-12-12 16:47:07"
},
{
"name": "phpunit/php-code-coverage",
"version": "2.0.x-dev",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "0e7d2eec5554f869fa7a4ec2d21e4b37af943ea5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/0e7d2eec5554f869fa7a4ec2d21e4b37af943ea5",
"reference": "0e7d2eec5554f869fa7a4ec2d21e4b37af943ea5",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"phpunit/php-file-iterator": "~1.3",
"phpunit/php-text-template": "~1.2",
"phpunit/php-token-stream": "~1.3",
"sebastian/environment": "~1.0",
"sebastian/version": "~1.0"
},
"require-dev": {
"ext-xdebug": ">=2.1.4",
"phpunit/phpunit": "~4.1"
},
"suggest": {
"ext-dom": "*",
"ext-xdebug": ">=2.2.1",
"ext-xmlwriter": "*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"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-12-03 06:41:44"
},
{
"name": "phpunit/php-file-iterator",
"version": "1.3.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "acd690379117b042d1c8af1fafd61bde001bf6bb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb",
"reference": "acd690379117b042d1c8af1fafd61bde001bf6bb",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"autoload": {
"classmap": [
"File/"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
""
],
"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": "2013-10-10 15:34:57"
},
{
"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": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "f8d5d08c56de5cfd592b3340424a81733259a876"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/f8d5d08c56de5cfd592b3340424a81733259a876",
"reference": "f8d5d08c56de5cfd592b3340424a81733259a876",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Wrapper around PHP's tokenizer extension.",
"homepage": "https://github.com/sebastianbergmann/php-token-stream/",
"keywords": [
"tokenizer"
],
"time": "2014-08-31 06:12:13"
},
{
"name": "phpunit/phpunit",
"version": "4.4.x-dev",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "b43c27aa18e1e20c9f7013362918cf3d8898e5f6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b43c27aa18e1e20c9f7013362918cf3d8898e5f6",
"reference": "b43c27aa18e1e20c9f7013362918cf3d8898e5f6",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-json": "*",
"ext-pcre": "*",
"ext-reflection": "*",
"ext-spl": "*",
"php": ">=5.3.3",
"phpunit/php-code-coverage": "~2.0",
"phpunit/php-file-iterator": "~1.3.2",
"phpunit/php-text-template": "~1.2",
"phpunit/php-timer": "~1.0.2",
"phpunit/phpunit-mock-objects": "~2.3",
"sebastian/comparator": "~1.0",
"sebastian/diff": "~1.1",
"sebastian/environment": "~1.1",
"sebastian/exporter": "~1.0",
"sebastian/global-state": "~1.0",
"sebastian/version": "~1.0",
"symfony/yaml": "~2.0"
},
"suggest": {
"phpunit/php-invoker": "~1.1"
},
"bin": [
"phpunit"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.4.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "The PHP Unit Testing framework.",
"homepage": "https://phpunit.de/",
"keywords": [
"phpunit",
"testing",
"xunit"
],
"time": "2014-12-22 16:18:53"
},
{
"name": "phpunit/phpunit-mock-objects",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "96c5b81f9842f38fe6c73ad0020306cc4862a9e3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/96c5b81f9842f38fe6c73ad0020306cc4862a9e3",
"reference": "96c5b81f9842f38fe6c73ad0020306cc4862a9e3",
"shasum": ""
},
"require": {
"doctrine/instantiator": "~1.0,>=1.0.2",
"php": ">=5.3.3",
"phpunit/php-text-template": "~1.2"
},
"require-dev": {
"phpunit/phpunit": "4.4.*@dev"
},
"suggest": {
"ext-soap": "*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.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": "Mock Object library for PHPUnit",
"homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
"keywords": [
"mock",
"xunit"
],
"time": "2014-10-04 10:04:20"
},
{
"name": "sebastian/comparator",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "4c7f82f0599413ed5521e464071ee8460c96ce89"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/4c7f82f0599413ed5521e464071ee8460c96ce89",
"reference": "4c7f82f0599413ed5521e464071ee8460c96ce89",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"sebastian/diff": "~1.1",
"sebastian/exporter": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Volker Dusch",
"email": "github@wallbash.com"
},
{
"name": "Bernhard Schussek",
"email": "bschussek@2bepublished.at"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Provides the functionality to compare PHP values for equality",
"homepage": "http://www.github.com/sebastianbergmann/comparator",
"keywords": [
"comparator",
"compare",
"equality"
],
"time": "2014-12-04 15:00:21"
},
{
"name": "sebastian/diff",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
"reference": "f38057b48125c2b421361da224a8aa800d70aeca"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/f38057b48125c2b421361da224a8aa800d70aeca",
"reference": "f38057b48125c2b421361da224a8aa800d70aeca",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Kore Nordmann",
"email": "mail@kore-nordmann.de"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Diff implementation",
"homepage": "http://www.github.com/sebastianbergmann/diff",
"keywords": [
"diff"
],
"time": "2014-11-22 06:25:40"
},
{
"name": "sebastian/environment",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
"reference": "a4420fdad8ef5e525cdeb66adbb5ed9e873e6128"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/a4420fdad8ef5e525cdeb66adbb5ed9e873e6128",
"reference": "a4420fdad8ef5e525cdeb66adbb5ed9e873e6128",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Provides functionality to handle HHVM/PHP environments",
"homepage": "http://www.github.com/sebastianbergmann/environment",
"keywords": [
"Xdebug",
"environment",
"hhvm"
],
"time": "2014-12-15 10:20:32"
},
{
"name": "sebastian/exporter",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c7d59948d6e82818e1bdff7cadb6c34710eb7dc0",
"reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Volker Dusch",
"email": "github@wallbash.com"
},
{
"name": "Bernhard Schussek",
"email": "bschussek@2bepublished.at"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Adam Harvey",
"email": "aharvey@php.net"
}
],
"description": "Provides the functionality to export PHP variables for visualization",
"homepage": "http://www.github.com/sebastianbergmann/exporter",
"keywords": [
"export",
"exporter"
],
"time": "2014-09-10 00:51:36"
},
{
"name": "sebastian/global-state",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "231d48620efde984fd077ee92916099a3ece9a59"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/231d48620efde984fd077ee92916099a3ece9a59",
"reference": "231d48620efde984fd077ee92916099a3ece9a59",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.2"
},
"suggest": {
"ext-uopz": "*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Snapshotting of global state",
"homepage": "http://www.github.com/sebastianbergmann/global-state",
"keywords": [
"global state"
],
"time": "2014-10-06 09:49:11"
},
{
"name": "sebastian/version",
"version": "1.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/version.git",
"reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/version/zipball/b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43",
"reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43",
"shasum": ""
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
"time": "2014-03-07 15:35:33"
},
{
"name": "symfony/yaml",
"version": "2.7.x-dev",
"target-dir": "Symfony/Component/Yaml",
"source": {
"type": "git",
"url": "https://github.com/symfony/Yaml.git",
"reference": "b9c19ce1bd9a51d3f42665973088f2e2b82db240"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/b9c19ce1bd9a51d3f42665973088f2e2b82db240",
"reference": "b9c19ce1bd9a51d3f42665973088f2e2b82db240",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.7-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": "2014-12-09 17:32:32"
}
],
"aliases": [],
"minimum-stability": "dev",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=5.3"
},
"platform-dev": []
}
raintpl3-3.1.1/example-all.php 0000664 0000000 0000000 00000004525 13306571373 0016200 0 ustar 00root root 0000000 0000000 null,
"tpl_dir" => "templates/test/",
"cache_dir" => "cache/",
"remove_comments" => true,
"debug" => true, // set to false to improve the speed
);
Tpl::configure( $config );
// Add PathReplace plugin (necessary to load the CSS with path replace)
Tpl::registerPlugin( new Tpl\Plugin\PathReplace() );
// set variables
$var = array(
"variable" => "Hello World!",
"bad_variable" => "",
"safe_variable" => "",
"version" => "3.0 Alpha",
"menu" => array(
array("name" => "Home", "link" => "index.php", "selected" => true ),
array("name" => "FAQ", "link" => "index.php/FAQ/", "selected" => null ),
array("name" => "Documentation", "link" => "index.php/doc/", "selected" => null )
),
"week" => array( "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ),
"user" => (object) array("name"=>"Rain", "citizen" => "Earth", "race" => "Human" ),
"numbers" => array( 3, 2, 1 ),
"bad_text" => 'Hey this is a malicious XSS ',
"table" => array( array( "Apple", "1996" ), array( "PC", "1997" ) ),
"title" => "Rain TPL 3 - Easy and Fast template engine",
"copyright" => "Copyright 2006 - 2012 Rain TPL
Project By Rain Team",
);
// add a tag
Tpl::registerTag( "({@.*?@})", // preg split
"{@(.*?)@}", // preg match
function( $params ){ // function called by the tag
$value = $params[1][0];
return "Translate: $value";
}
);
// add a tag
Tpl::registerTag( "({%.*?%})", // preg split
"{%(.*?)(?:\|(.*?))%}", // preg match
function( $params ){ // function called by the tag
$value = $params[1][0];
$value2 = $params[2][0];
return "Translate: $value in $value2";
}
);
// draw
$tpl = new Tpl;
$tpl->assign( $var );
echo $tpl->draw( "test" );
class Test{
static public function method( $variable ){
echo "Hi I am a static method, and this is the parameter passed to me: $variable!";
}
}
// end raintpl3-3.1.1/example-bootstrap.php 0000664 0000000 0000000 00000003201 13306571373 0017433 0 ustar 00root root 0000000 0000000 null,
"tpl_dir" => "templates/",
"cache_dir" => "cache/",
"debug" => true // set to false to improve the speed
);
Tpl::configure( $config );
// Add PathReplace plugin
Tpl::registerPlugin( new Tpl\Plugin\PathReplace() );
// set variables
$var = array(
"variable" => "Hello World!",
"version" => "3.0 Alpha",
"menu" => array(
array("name" => "Home", "link" => "index.php", "selected" => true ),
array("name" => "FAQ", "link" => "index.php/FAQ/", "selected" => null ),
array("name" => "Documentation", "link" => "index.php/doc/", "selected" => null )
),
"week" => array( "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ),
"user" => (object) array("name"=>"Rain", "citizen" => "Earth", "race" => "Human" ),
"numbers" => array( 3, 2, 1 ),
"bad_text" => 'Hey this is a malicious XSS ',
"table" => array( array( "Apple", "1996" ), array( "PC", "1997" ) ),
"title" => "Rain TPL 3 - Easy and Fast template engine",
"copyright" => "Copyright 2006 - 2012 Rain TPL
Project By Rain Team",
);
// add a function
Tpl::registerTag( "({@.*?@})", // preg split
"{@(.*?)@}", // preg match
function( $params ){ // function called by the tag
$value = $params[0];
return "Translate: $value";
}
);
// draw
$tpl = new Tpl;
$tpl->assign( $var );
echo $tpl->draw( "bootstrap/hero" );
// end raintpl3-3.1.1/example-draw-string.php 0000664 0000000 0000000 00000010437 13306571373 0017670 0 ustar 00root root 0000000 0000000 null,
"tpl_dir" => "templates/test/",
"cache_dir" => "cache/",
"debug" => true // set to false to improve the speed
);
Tpl::configure( $config );
// Add PathReplace plugin
Tpl::registerPlugin( new Tpl\Plugin\PathReplace() );
// set variables
$var = array(
"variable" => "Hello World!",
"version" => "3.0 Alpha",
"menu" => array(
array("name" => "Home", "link" => "index.php", "selected" => true ),
array("name" => "FAQ", "link" => "index.php/FAQ/", "selected" => null ),
array("name" => "Documentation", "link" => "index.php/doc/", "selected" => null )
),
"week" => array( "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ),
"user" => (object) array("name"=>"Rain", "citizen" => "Earth", "race" => "Human" ),
"numbers" => array( 3, 2, 1 ),
"bad_text" => "Hey this is a malicious XSS ",
"table" => array( array( "Apple", "1996" ), array( "PC", "1997" ) ),
"title" => "Rain TPL 3 - Easy and Fast template engine",
"copyright" => "Copyright 2006 - 2012 Rain TPL
Project By Rain Team",
);
// add a tag
Tpl::registerTag( "({@.*?@})", // preg split
"{@(.*?)@}", // preg match
function( $params ){ // function called by the tag
$value = $params[1][0];
return "Translate: $value";
}
);
// add a tag
Tpl::registerTag( "({%.*?%})", // preg split
"{%(.*?)(?:\|(.*?))%}", // preg match
function( $params ){ // function called by the tag
$value = $params[1][0];
$value2 = $params[2][0];
return "Translate: $value in $value2";
}
);
$string = file_get_contents( "templates/test/test.html");
class Test{
static public function method( $variable ){
echo "Hi I am a static method, and this is the parameter passed to me: $variable!";
}
}
// draw
$tpl = new Tpl;
$tpl->assign( $var );
echo $tpl->drawString( $string );
// -- end
//-------------------------------------------------------------
//
// BENCHMARK/DEBUG FUNCTIONS
//
//-------------------------------------------------------------
echo "
---------
";
echo memoryUsage();
echo "
";
echo timer();
/**
* Useful for debug, print the variable $mixed and die
*/
function dump( $mixed, $exit = 1 ){
echo "
dump \n---------------------- \n\n" . print_r( $mixed, true ) . "\n----------------------"; if( $exit ) exit; } /** * Save the memory used at this point */ function memoryUsageStart( $memName = "execution_time" ){ return $GLOBALS['memoryCounter'][$memName] = memory_get_usage(); } /** * Get the memory used */ function memoryUsage( $memName = "execution_time", $byteFormat = true ){ $totMem = memory_get_usage() - $GLOBALS['memoryCounter'][ $memName ]; return $byteFormat ? byteFormat($totMem) : $totMem; } //------------------------------------------------------------- // // TIME FUNCTIONS // //------------------------------------------------------------- /** * Start the timer */ function timerStart( $timeName = "execution_time" ){ $stimer = explode( ' ', microtime( ) ); $GLOBALS['timeCounter'][$timeName] = $stimer[ 1 ] + $stimer[ 0 ]; } /** * Get the time passed */ function timer( $timeName = "execution_time", $precision = 10 ){ $etimer = explode( ' ', microtime( ) ); $timeElapsed = $etimer[ 1 ] + $etimer[ 0 ] - $GLOBALS['timeCounter'][ $timeName ]; return substr( $timeElapsed, 0, $precision ); } /** * Convert byte to more readable format, like "1 KB" instead of "1024". * cut_zero, remove the 0 after comma ex: 10,00 => 10 14,30 => 14,3 */ function byteFormat( $size ){ if( $size > 0 ){ $unim = array("B","KB","MB","GB","TB","PB"); for( $i=0; $size >= 1024; $i++ ) $size = $size / 1024; return number_format($size,$i?2:0, ',', '.' )." ".$unim[$i]; } } // end raintpl3-3.1.1/example-extend-class.php 0000664 0000000 0000000 00000002522 13306571373 0020015 0 ustar 00root root 0000000 0000000 var[$key] : $this->var; } // set function function __set( $key, $value ){ $this->var[$key] = $value; } } // conf $config = array( "base_url" => null, "tpl_dir" => "templates/raintpl3/", "cache_dir" => "cache/", "debug" => true, // set to false to improve the speed "charset" => "iso-8859-1", ); //use Rain; MyRainTPL::configure( $config ); // Add PathReplace plugin MyRainTPL::registerPlugin( new Tpl\Plugin\PathReplace() ); global $global_variable; $global_variable = "I'm Global"; // draw $tpl = new MyRainTPL; $tpl->variable = "Hello World"; $tpl->version = "3.0 Alpha"; $tpl->menu = array( array("name" => "Home", "link" => "index.php", "selected" => true ), array("name" => "FAQ", "link" => "index.php/FAQ/", "selected" => null ), array("name" => "Documentation", "link" => "index.php/doc/", "selected" => null ) ); $tpl->title = "Rain TPL 3 - Easy and Fast template engine"; $tpl->copyright = "Copyright 2006 - 2012 Rain TPL
Project By Rain Team"; $tpl->draw( 'page' ); raintpl3-3.1.1/example-multiple-template-directories.php 0000664 0000000 0000000 00000001113 13306571373 0023374 0 ustar 00root root 0000000 0000000 array( "templates/multiple-template-directories/newimplement/", "templates/multiple-template-directories/base/" ), "cache_dir" => "cache/", "debug" => true, // set to false to improve the speed ); Tpl::configure($config); // Add PathReplace plugin (necessary to load the CSS with path replace) Tpl::registerPlugin(new Tpl\Plugin\PathReplace()); // create the Tpl object $tpl = new Tpl; $tpl->draw("subfolder/index"); ?> raintpl3-3.1.1/example-nested-loop.php 0000664 0000000 0000000 00000003214 13306571373 0017653 0 ustar 00root root 0000000 0000000 null, "tpl_dir" => "templates/nested_loop/", "cache_dir" => "cache/", "debug" => true // set to false to improve the speed ); Tpl::configure( $config ); // Add PathReplace plugin Tpl::registerPlugin( new Tpl\Plugin\PathReplace() ); $user = array( array( 'name' => 'Jupiter', 'color' => 'yellow', 'orders' => array( array('order_id' => '123', 'order_name' => 'o1d'), array('order_id' => '1sn24', 'order_name' => 'o2d') ) ), array( 'name' => 'Mars', 'color' => 'red', 'orders' => array( array('order_id' => '3rf22', 'order_name' => '¶©µ¥Aj') ) ), array( 'name' => 'Empty', 'color' => 'blue', 'orders' => array( ) ), array( 'name' => 'Earth', 'color' => 'blue', 'orders' => array( array('order_id' => '2315', 'order_name' => '¶©µ¥15'), array('order_id' => 'rf2123', 'order_name' => '¶©µ¥215'), array('order_id' => '0231', 'order_name' => '¶©µ¥315'), array('order_id' => 'sn09-0fsd', 'order_name' => '¶©µ¥45415') ) ) ); // draw $tpl = new Tpl; $tpl->assign( "user", $user ); echo $tpl->draw( "test" ); class Test{ static public function method( $variable ){ echo "Hi I am a static method, and this is the parameter passed to me: $variable!"; } } // end raintpl3-3.1.1/example-plugin-compress.php 0000664 0000000 0000000 00000003201 13306571373 0020545 0 ustar 00root root 0000000 0000000 null, "tpl_dir" => "templates/compress/", "cache_dir" => "cache/", "debug" => true // set to false to improve the speed ); Tpl::configure( $config ); Tpl::registerPlugin( new Tpl\Plugin\PathReplace ); $compress = new Tpl\Plugin\Compress; $compress->configure('css', array('status'=>true)); $compress->configure('html', array('status'=>true)); $compress->configure('javascript', array('status'=>true, 'position' => 'bottom')); Tpl::registerPlugin($compress); global $global_variable; $global_variable = "I'm Global"; // set variables $var = array( "variable" => "Hello", "version" => "3.0 Alpha", "menu" => array( array("name" => "Home", "link" => "index.php", "selected" => true ), array("name" => "FAQ", "link" => "index.php/FAQ/", "selected" => null ), array("name" => "Documentation", "link" => "index.php/doc/", "selected" => null ) ), "week" => array( "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ), "title" => "Rain TPL 3 - Easy and Fast template engine", "user" => array( array("name" => "Fede", "color" => "blue" ), array("name" => "Laura", "color" => "red" ), array("name" => "Who", "color" => "yellow" ), ), "empty_array" => array(), "copyright" => "Copyright 2006 - 2012 Rain TPL
Project By Rain Team", ); // draw $tpl = new Tpl; $tpl->assign( $var ); $tpl->draw( "test_compress" ); raintpl3-3.1.1/example-plugin-img-resize.php 0000664 0000000 0000000 00000003332 13306571373 0020772 0 ustar 00root root 0000000 0000000 null, "tpl_dir" => "templates/image_resize/", "cache_dir" => "cache/", "debug" => true // set to false to improve the speed ); Tpl::configure( $config ); // Add PathReplace plugin (necessary to load the CSS with path replace) Tpl::registerPlugin( new Tpl\Plugin\PathReplace() ); $plugin_options = array( 'quality' => 100, 'crop' => true ); Tpl::registerPlugin( new Tpl\Plugin\ImageResize( $plugin_options ) ); global $global_variable; $global_variable = "I'm Global"; // set variables $var = array( "variable" => "Hello", "version" => "3.0 Alpha", "menu" => array( array("name" => "Home", "link" => "index.php", "selected" => true ), array("name" => "FAQ", "link" => "index.php/FAQ/", "selected" => null ), array("name" => "Documentation", "link" => "index.php/doc/", "selected" => null ) ), "week" => array( "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ), "title" => "Rain TPL 3 - Easy and Fast template engine", "user" => array( array("name" => "Fede", "color" => "blue" ), array("name" => "Sheska", "color" => "red" ), array("name" => "Who", "color" => "yellow" ), ), "empty_array" => array(), "copyright" => "Copyright 2006 - 2012 Rain TPL
Project By Rain Team", ); $test = function( $params ){ $value = $params[0]; return "Translate: $value"; }; // add a function Tpl::registerTag( "({@.*?@})", "{@(.*?)@}", $test ); // draw $tpl = new Tpl; $tpl->assign( $var ); $tpl->draw( "page" ); // end raintpl3-3.1.1/example-simple.php 0000664 0000000 0000000 00000001350 13306571373 0016712 0 ustar 00root root 0000000 0000000 "templates/simple/", "cache_dir" => "cache/", "debug" => true, // set to false to improve the speed ); Tpl::configure( $config ); // Add PathReplace plugin (necessary to load the CSS with path replace) Tpl::registerPlugin( new Tpl\Plugin\PathReplace() ); // create the Tpl object $tpl = new Tpl; // assign a variable $tpl->assign( "name", "Obi Wan Kenoby" ); // assign an array $tpl->assign( "week", array( "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ) ); // draw the template $tpl->draw( "simple_template" ); ?> raintpl3-3.1.1/example-webpage-new.php 0000664 0000000 0000000 00000003102 13306571373 0017617 0 ustar 00root root 0000000 0000000 null, "tpl_dir" => "templates/raintpl3/", "cache_dir" => "cache/", "debug" => true // set to false to improve the speed ); //use Rain; Tpl::configure( $config ); // Add PathReplace plugin Tpl::registerPlugin( new Rain\Tpl\Plugin\PathReplace() ); global $global_variable; $global_variable = "I'm Global"; // set variables $var = array( "variable" => "Hello", "version" => "3.0 Alpha", "menu" => array( array("name" => "Home", "link" => "index.php", "selected" => true ), array("name" => "FAQ", "link" => "index.php/FAQ/", "selected" => null ), array("name" => "Documentation", "link" => "index.php/doc/", "selected" => null ) ), "week" => array( "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ), "title" => "Rain TPL 3 - Easy and Fast template engine", "user" => array( array("name" => "Fede", "color" => "blue" ), array("name" => "Sheska", "color" => "red" ), array("name" => "Who", "color" => "yellow" ), ), "empty_array" => array(), "copyright" => "Copyright 2006 - 2012 Rain TPL
Project By Rain Team", ); $test = function( $params ){ $value = $params[0]; return "Translate: $value"; }; // add a function Tpl::registerTag( "({@.*?@})", "{@(.*?)@}", $test ); // draw $tpl = new Tpl; $tpl->assign( $var ); echo $tpl->draw( "page" ); // end raintpl3-3.1.1/example-webpage.php 0000664 0000000 0000000 00000003036 13306571373 0017036 0 ustar 00root root 0000000 0000000 null, "tpl_dir" => "templates/raintpl2/", "cache_dir" => "cache/", "debug" => true // set to false to improve the speed ); Tpl::configure( $config ); // Add PathReplace plugin Tpl::registerPlugin( new Tpl\Plugin\PathReplace() ); global $global_variable; $global_variable = "I'm Global"; // set variables $var = array( "variable" => "Hello", "version" => "3.0 Alpha", "menu" => array( array("name" => "Home", "link" => "index.php", "selected" => true ), array("name" => "FAQ", "link" => "index.php/FAQ/", "selected" => null ), array("name" => "Documentation", "link" => "index.php/doc/", "selected" => null ) ), "week" => array( "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ), "title" => "Rain TPL 3 - Easy and Fast template engine", "user" => array( array("name" => "Fede", "color" => "blue" ), array("name" => "Sheska", "color" => "red" ), array("name" => "Who", "color" => "yellow" ), ), "empty_array" => array(), "copyright" => "Copyright 2006 - 2012 Rain TPL
Project By Rain Team", ); function test( $params ){ $value = $params[0]; return "Translate: $value"; }; // add a function Tpl::registerTag( "({@.*?@})", "{@(.*?)@}", "test" ); // draw $tpl = new Tpl; $tpl->assign( $var ); echo $tpl->draw( "page" ); raintpl3-3.1.1/library/ 0000775 0000000 0000000 00000000000 13306571373 0014724 5 ustar 00root root 0000000 0000000 raintpl3-3.1.1/library/Rain/ 0000775 0000000 0000000 00000000000 13306571373 0015615 5 ustar 00root root 0000000 0000000 raintpl3-3.1.1/library/Rain/Tpl.php 0000664 0000000 0000000 00000027146 13306571373 0017077 0 ustar 00root root 0000000 0000000 array(), 'charset' => 'UTF-8', 'debug' => false, 'tpl_dir' => 'templates/', 'cache_dir' => 'cache/', 'tpl_ext' => 'html', 'base_url' => '', 'php_enabled' => false, 'auto_escape' => true, 'sandbox' => true, 'remove_comments' => false, 'registered_tags' => array(), ); // tags registered by the developers protected static $registered_tags = array(); /** * Draw the template * * @param string $templateFilePath: name of the template file * @param bool $toString: if the method should return a string * or echo the output * * @return void, string: depending of the $toString */ public function draw($templateFilePath, $toString = FALSE) { extract($this->var); // Merge local and static configurations $this->config = $this->objectConf + static::$conf; ob_start(); require $this->checkTemplate($templateFilePath); $html = ob_get_clean(); // Execute plugins, before_parse $context = $this->getPlugins()->createContext(array( 'code' => $html, 'conf' => $this->config, )); $this->getPlugins()->run('afterDraw', $context); $html = $context->code; if ($toString) return $html; else echo $html; } /** * Draw a string * * @param string $string: string in RainTpl format * @param bool $toString: if the param * * @return void, string: depending of the $toString */ public function drawString($string, $toString = false) { extract($this->var); // Merge local and static configurations $this->config = $this->objectConf + static::$conf; ob_start(); require $this->checkString($string); $html = ob_get_clean(); // Execute plugins, before_parse $context = $this->getPlugins()->createContext(array( 'code' => $html, 'conf' => $this->config, )); $this->getPlugins()->run('afterDraw', $context); $html = $context->code; if ($toString) return $html; else echo $html; } /** * Object specific configuration * * @param string, array $setting: name of the setting to configure * or associative array type 'setting' => 'value' * @param mixed $value: value of the setting to configure * @return \Rain\Tpl $this */ public function objectConfigure($setting, $value = null) { if (is_array($setting)) foreach ($setting as $key => $value) $this->objectConfigure($key, $value); else if (isset(static::$conf[$setting])) { // add ending slash if missing if ($setting == "tpl_dir" || $setting == "cache_dir") { $value = self::addTrailingSlash($value); } $this->objectConf[$setting] = $value; } return $this; } /** * Global configurations * * @param string, array $setting: name of the setting to configure * or associative array type 'setting' => 'value' * @param mixed $value: value of the setting to configure */ public static function configure($setting, $value = null) { if (is_array($setting)) foreach ($setting as $key => $value) static::configure($key, $value); else if (isset(static::$conf[$setting])) { // add ending slash if missing if ($setting == "tpl_dir" || $setting == "cache_dir") { $value = self::addTrailingSlash($value); } static::$conf[$setting] = $value; static::$conf['checksum'][$setting] = $value; // take trace of all config } } /** * Assign variable * eg. $t->assign('name','mickey'); * * @param mixed $variable Name of template variable or associative array name/value * @param mixed $value value assigned to this variable. Not set if variable_name is an associative array * * @return \Rain\Tpl $this */ public function assign($variable, $value = null) { if (is_array($variable)) $this->var = $variable + $this->var; else $this->var[$variable] = $value; return $this; } /** * Clean the expired files from cache * @param type $expireTime Set the expiration time */ public static function clean($expireTime = 2592000) { $files = glob(static::$conf['cache_dir'] . "*.rtpl.php"); $time = time() - $expireTime; foreach ($files as $file) if ($time > filemtime($file) ) unlink($file); } /** * Allows the developer to register a tag. * * @param string $tag nombre del tag * @param regexp $parse regular expression to parse the tag * @param anonymous function $function: action to do when the tag is parsed */ public static function registerTag($tag, $parse, $function) { static::$registered_tags[$tag] = array("parse" => $parse, "function" => $function); } /** * Registers a plugin globally. * * @param \Rain\Tpl\IPlugin $plugin * @param string $name name can be used to distinguish plugins of same class. */ public static function registerPlugin(Tpl\IPlugin $plugin, $name = '') { $name = (string)$name ?: \get_class($plugin); static::getPlugins()->addPlugin($name, $plugin); } /** * Removes registered plugin from stack. * * @param string $name */ public static function removePlugin($name) { static::getPlugins()->removePlugin($name); } /** * Returns plugin container. * * @return \Rain\Tpl\PluginContainer */ protected static function getPlugins() { return static::$plugins ?: static::$plugins = new Tpl\PluginContainer(); } /** * Check if the template exist and compile it if necessary * * @param string $template: name of the file of the template * * @throw \Rain\Tpl\NotFoundException the file doesn't exists * @return string: full filepath that php must use to include */ protected function checkTemplate($template) { // set filename $templateName = basename($template); $templateBasedir = strpos($template, '/') !== false ? dirname($template) . '/' : null; $templateDirectory = null; $templateFilepath = null; $parsedTemplateFilepath = null; // Make directories to array for multiple template directory $templateDirectories = $this->config['tpl_dir']; if (!is_array($templateDirectories)) { $templateDirectories = array($templateDirectories); } $isFileNotExist = true; // absolute path if ($template[0] == '/') { $templateDirectory = $templateBasedir; $templateFilepath = $templateDirectory . $templateName . '.' . $this->config['tpl_ext']; $parsedTemplateFilepath = $this->config['cache_dir'] . $templateName . "." . md5($templateDirectory . serialize($this->config['checksum'])) . '.rtpl.php'; // For check templates are exists if (file_exists($templateFilepath)) { $isFileNotExist = false; } } else { foreach($templateDirectories as $templateDirectory) { $templateDirectory .= $templateBasedir; $templateFilepath = $templateDirectory . $templateName . '.' . $this->config['tpl_ext']; $parsedTemplateFilepath = $this->config['cache_dir'] . $templateName . "." . md5($templateDirectory . serialize($this->config['checksum'])) . '.rtpl.php'; // For check templates are exists if (file_exists($templateFilepath)) { $isFileNotExist = false; break; } } } // if the template doesn't exsist throw an error if ($isFileNotExist === true) { $e = new Tpl\NotFoundException('Template ' . $templateName . ' not found!'); throw $e->templateFile($templateFilepath); } // Compile the template if the original has been updated if ($this->config['debug'] || !file_exists($parsedTemplateFilepath) || ( filemtime($parsedTemplateFilepath) < filemtime($templateFilepath) )) { $parser = new Tpl\Parser($this->config, static::$plugins, static::$registered_tags); $parser->compileFile($templateName, $templateBasedir, $templateDirectory, $templateFilepath, $parsedTemplateFilepath); } return $parsedTemplateFilepath; } /** * Compile a string if necessary * * @param string $string: RainTpl template string to compile * * @return string: full filepath that php must use to include */ protected function checkString($string) { // set filename $templateName = md5($string . implode($this->config['checksum'])); $parsedTemplateFilepath = $this->config['cache_dir'] . $templateName . '.s.rtpl.php'; $templateFilepath = ''; $templateBasedir = ''; // Compile the template if the original has been updated if ($this->config['debug'] || !file_exists($parsedTemplateFilepath)) { $parser = new Tpl\Parser($this->config, static::$plugins, static::$registered_tags); $parser->compileString($templateName, $templateBasedir, $templateFilepath, $parsedTemplateFilepath, $string); } return $parsedTemplateFilepath; } private static function addTrailingSlash($folder) { if (is_array($folder)) { foreach($folder as &$f) { $f = self::addTrailingSlash($f); } } elseif ( strlen($folder) > 0 && $folder[0] != '/' ) { $folder = $folder . "/"; } return $folder; } } raintpl3-3.1.1/library/Rain/Tpl/ 0000775 0000000 0000000 00000000000 13306571373 0016354 5 ustar 00root root 0000000 0000000 raintpl3-3.1.1/library/Rain/Tpl/Exception.php 0000664 0000000 0000000 00000003320 13306571373 0021021 0 ustar 00root root 0000000 0000000 templateFile; $this->templateFile = (string) $templateFile; return $this; } } // -- end raintpl3-3.1.1/library/Rain/Tpl/IPlugin.php 0000664 0000000 0000000 00000004204 13306571373 0020434 0 ustar 00root root 0000000 0000000 * public function declare_hooks() { * return array('before_parse', 'after_parse' => 'custom_method'); * } * * * Template will then call the registered method with a context object as parameter. * Context object implements \ArrayAccess. * It's properties depends on hook api. * * Method can modify some properties. No return value is expected. */ interface IPlugin { /** * Returns a list of hooks that are implemented by the plugin. * This should be an array containing: * - a key/value pair where key is hook name and value is implementing method, * - a value only when hook has same name as method. */ public function declareHooks(); /** * Sets plugin options. * * @var array */ public function setOptions($options); } raintpl3-3.1.1/library/Rain/Tpl/NotFoundException.php 0000664 0000000 0000000 00000002452 13306571373 0022503 0 ustar 00root root 0000000 0000000 array( '({loop.*?})', '/{loop="(?\${0,1}[^"]*)"(?: as (? \$.*?)(?: => (? \$.*?)){0,1}){0,1}}/' ), 'loop_close' => array('({\/loop})', '/{\/loop}/'), 'loop_break' => array('({break})', '/{break}/'), 'loop_continue' => array('({continue})', '/{continue}/'), 'if' => array('({if.*?})', '/{if="([^"]*)"}/'), 'elseif' => array('({elseif.*?})', '/{elseif="([^"]*)"}/'), 'else' => array('({else})', '/{else}/'), 'if_close' => array('({\/if})', '/{\/if}/'), 'autoescape' => array('({autoescape.*?})', '/{autoescape="([^"]*)"}/'), 'autoescape_close' => array('({\/autoescape})', '/{\/autoescape}/'), 'noparse' => array('({noparse})', '/{noparse}/'), 'noparse_close' => array('({\/noparse})', '/{\/noparse}/'), 'ignore' => array('({ignore}|{\*)', '/{ignore}|{\*/'), 'ignore_close' => array('({\/ignore}|\*})', '/{\/ignore}|\*}/'), 'include' => array('({include.*?})', '/{include="([^"]*)"}/'), 'function' => array( '({function.*?})', '/{function="([a-zA-Z_][a-zA-Z_0-9\:]*)(\(.*\)){0,1}"}/' ), 'ternary' => array('({.[^{?]*?\?.*?\:.*?})', '/{(.[^{?]*?)\?(.*?)\:(.*?)}/'), 'variable' => array('({\$.*?})', '/{(\$.*?)}/'), 'constant' => array('({#.*?})', '/{#(.*?)#{0,1}}/'), ); // black list of functions and variables protected static $black_list = array( 'exec', 'shell_exec', 'pcntl_exec', 'passthru', 'proc_open', 'system', 'posix_kill', 'posix_setsid', 'pcntl_fork', 'posix_uname', 'php_uname', 'phpinfo', 'popen', 'file_get_contents', 'file_put_contents', 'rmdir', 'mkdir', 'unlink', 'highlight_contents', 'symlink', 'apache_child_terminate', 'apache_setenv', 'define_syslog_variables', 'escapeshellarg', 'escapeshellcmd', 'eval', 'fp', 'fput', 'ftp_connect', 'ftp_exec', 'ftp_get', 'ftp_login', 'ftp_nb_fput', 'ftp_put', 'ftp_raw', 'ftp_rawlist', 'highlight_file', 'ini_alter', 'ini_get_all', 'ini_restore', 'inject_code', 'mysql_pconnect', 'openlog', 'passthru', 'php_uname', 'phpAds_remoteInfo', 'phpAds_XmlRpc', 'phpAds_xmlrpcDecode', 'phpAds_xmlrpcEncode', 'posix_getpwuid', 'posix_kill', 'posix_mkfifo', 'posix_setpgid', 'posix_setsid', 'posix_setuid', 'posix_uname', 'proc_close', 'proc_get_status', 'proc_nice', 'proc_open', 'proc_terminate', 'syslog', 'xmlrpc_entity_decode' ); public function __construct($config, $plugins, $registered_tags) { $this->config = $config; static::$plugins = $plugins; static::$registered_tags = $registered_tags; } /** * Returns plugin container. * * @return \Rain\Tpl\PluginContainer */ protected static function getPlugins() { return static::$plugins ?: static::$plugins = new PluginContainer(); } /** * Compile the file and save it in the cache * * @param string $templateName: name of the template * @param string $templateBaseDir * @param string $templateDirectory * @param string $templateFilepath * @param string $parsedTemplateFilepath: cache file where to save the template */ public function compileFile( $templateName, $templateBasedir, $templateDirectory, $templateFilepath, $parsedTemplateFilepath ) { // open the template $fp = fopen($templateFilepath, "r"); // lock the file if (flock($fp, LOCK_EX)) { // save the filepath in the info $this->templateInfo['template_filepath'] = $templateFilepath; // read the file $this->templateInfo['code'] = $code = fread($fp, filesize($templateFilepath)); // xml substitution $code = preg_replace("/<\?xml(.*?)\?>/s", /**/ "##XML\\1XML##", $code); // disable php tag if (!$this->config['php_enabled']) $code = str_replace(array("", "?>"), array("<?", "?>"), $code); // xml re-substitution $code = preg_replace_callback("/##XML(.*?)XML##/s", function( $match ) { return "'; ?>"; }, $code); $parsedCode = $this->compileTemplate($code, $isString = false, $templateBasedir, $templateDirectory, $templateFilepath); $parsedCode = "" . $parsedCode; // fix the php-eating-newline-after-closing-tag-problem $parsedCode = str_replace("?>\n", "?>\n\n", $parsedCode); // create directories if (!is_dir($this->config['cache_dir'])) mkdir($this->config['cache_dir'], 0755, TRUE); // check if the cache is writable if (!is_writable($this->config['cache_dir'])) throw new Exception('Cache directory ' . $this->config['cache_dir'] . 'doesn\'t have write permission. Set write permission or set RAINTPL_CHECK_TEMPLATE_UPDATE to FALSE. More details on http://www.raintpl.com/Documentation/Documentation-for-PHP-developers/Configuration/'); // write compiled file file_put_contents($parsedTemplateFilepath, $parsedCode); // release the file lock flock($fp, LOCK_UN); } // close the file fclose($fp); } /** * Compile a string and save it in the cache * * @param string $templateName: name of the template * @param string $templateBaseDir * @param string $templateFilepath * @param string $parsedTemplateFilepath: cache file where to save the template * @param string $code: code to compile */ public function compileString($templateName, $templateBasedir, $templateFilepath, $parsedTemplateFilepath, $code) { // open the template $fp = fopen($parsedTemplateFilepath, "w"); // lock the file if (flock($fp, LOCK_SH)) { // xml substitution $code = preg_replace("/<\?xml(.*?)\?>/s", "##XML\\1XML##", $code); // disable php tag if (!$this->config['php_enabled']) $code = str_replace(array("", "?>"), array("<?", "?>"), $code); // xml re-substitution $code = preg_replace_callback("/##XML(.*?)XML##/s", function( $match ) { return "'; ?>"; }, $code); $parsedCode = $this->compileTemplate($code, $isString = true, $templateBasedir, $templateDirectory = null, $templateFilepath); $parsedCode = "" . $parsedCode; // fix the php-eating-newline-after-closing-tag-problem $parsedCode = str_replace("?>\n", "?>\n\n", $parsedCode); // create directories if (!is_dir($this->config['cache_dir'])) mkdir($this->config['cache_dir'], 0755, true); // check if the cache is writable if (!is_writable($this->config['cache_dir'])) throw new Exception('Cache directory ' . $this->config['cache_dir'] . 'doesn\'t have write permission. Set write permission or set RAINTPL_CHECK_TEMPLATE_UPDATE to false. More details on http://www.raintpl.com/Documentation/Documentation-for-PHP-developers/Configuration/'); // write compiled file fwrite($fp, $parsedCode); // release the file lock flock($fp, LOCK_UN); } // close the file fclose($fp); } /** * Compile template * @access protected * * @param string $code: code to compile */ protected function compileTemplate($code, $isString, $templateBasedir, $templateDirectory, $templateFilepath) { // Execute plugins, before_parse $context = $this->getPlugins()->createContext(array( 'code' => $code, 'template_basedir' => $templateBasedir, 'template_filepath' => $templateFilepath, 'conf' => $this->config, )); $this->getPlugins()->run('beforeParse', $context); $code = $context->code; // set tags foreach (static::$tags as $tag => $tagArray) { list( $split, $match ) = $tagArray; $tagSplit[$tag] = $split; $tagMatch[$tag] = $match; } $keys = array_keys(static::$registered_tags); $tagSplit += array_merge($tagSplit, $keys); //Remove comments if ($this->config['remove_comments']) { $code = preg_replace('//Uis', '', $code); } //split the code with the tags regexp $codeSplit = preg_split("/" . implode("|", $tagSplit) . "/", $code, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); //variables initialization $parsedCode = $commentIsOpen = $ignoreIsOpen = NULL; $openIf = $loopLevel = 0; // if the template is not empty if ($codeSplit) //read all parsed code foreach ($codeSplit as $html) { //close ignore tag if (!$commentIsOpen && preg_match($tagMatch['ignore_close'], $html)) $ignoreIsOpen = FALSE; //code between tag ignore id deleted elseif ($ignoreIsOpen) { //ignore the code } //close no parse tag elseif (preg_match($tagMatch['noparse_close'], $html)) $commentIsOpen = FALSE; //code between tag noparse is not compiled elseif ($commentIsOpen) $parsedCode .= $html; //ignore elseif (preg_match($tagMatch['ignore'], $html)) $ignoreIsOpen = TRUE; //noparse elseif (preg_match($tagMatch['noparse'], $html)) $commentIsOpen = TRUE; //include tag elseif (preg_match($tagMatch['include'], $html, $matches)) { //get the folder of the actual template $actualFolder = $templateDirectory; if (is_array($this->config['tpl_dir'])) { foreach($this->config['tpl_dir'] as $tpl) { if (substr($actualFolder, 0, strlen($tpl)) == $tpl) { $actualFolder = substr($actualFolder, strlen($tpl)); } } } elseif (substr($actualFolder, 0, strlen($this->config['tpl_dir'])) == $this->config['tpl_dir']) { $actualFolder = substr($actualFolder, strlen($this->config['tpl_dir'])); } //get the included template if (strpos($matches[1], '$') !== false) { $includeTemplate = "'$actualFolder'." . $this->varReplace($matches[1], $loopLevel); } else { $includeTemplate = $actualFolder . $this->varReplace($matches[1], $loopLevel); } // reduce the path $includeTemplate = Parser::reducePath( $includeTemplate ); if (strpos($matches[1], '$') !== false) { //dynamic include $parsedCode .= 'checkTemplate(' . $includeTemplate . ');?>'; } else { //dynamic include $parsedCode .= 'checkTemplate("' . $includeTemplate . '");?>'; } } //loop elseif (preg_match($tagMatch['loop'], $html, $matches)) { // increase the loop counter $loopLevel++; //replace the variable in the loop $var = $this->varReplace($matches['variable'], $loopLevel - 1, $escape = FALSE); if (preg_match('#\(#', $var)) { $newvar = "\$newvar{$loopLevel}"; $assignNewVar = "$newvar=$var;"; } else { $newvar = $var; $assignNewVar = null; } // check black list $this->blackList($var); //loop variables $counter = "\$counter$loopLevel"; // count iteration if (isset($matches['key']) && isset($matches['value'])) { $key = $matches['key']; $value = $matches['value']; } elseif (isset($matches['key'])) { $key = "\$key$loopLevel"; // key $value = $matches['key']; } else { $key = "\$key$loopLevel"; // key $value = "\$value$loopLevel"; // value } //loop code $parsedCode .= " $value ){ $counter++; ?>"; } //close loop tag elseif (preg_match($tagMatch['loop_close'], $html)) { //iterator $counter = "\$counter$loopLevel"; //decrease the loop counter $loopLevel--; //close loop code $parsedCode .= ""; } //break loop tag elseif (preg_match($tagMatch['loop_break'], $html)) { //close loop code $parsedCode .= ""; } //continue loop tag elseif (preg_match($tagMatch['loop_continue'], $html)) { //close loop code $parsedCode .= ""; } //if elseif (preg_match($tagMatch['if'], $html, $matches)) { //increase open if counter (for intendation) $openIf++; //tag $tag = $matches[0]; //condition attribute $condition = $matches[1]; // check black list $this->blackList($condition); //variable substitution into condition (no delimiter into the condition) $parsedCondition = $this->varReplace($condition, $loopLevel, $escape = FALSE); //if code $parsedCode .= ""; } //elseif elseif (preg_match($tagMatch['elseif'], $html, $matches)) { //tag $tag = $matches[0]; //condition attribute $condition = $matches[1]; // check black list $this->blackList($condition); //variable substitution into condition (no delimiter into the condition) $parsedCondition = $this->varReplace($condition, $loopLevel, $escape = FALSE); //elseif code $parsedCode .= ""; } //else elseif (preg_match($tagMatch['else'], $html)) { //else code $parsedCode .= ''; } //close if tag elseif (preg_match($tagMatch['if_close'], $html)) { //decrease if counter $openIf--; // close if code $parsedCode .= ''; } // autoescape off elseif (preg_match($tagMatch['autoescape'], $html, $matches)) { // get function $mode = $matches[1]; $this->config['auto_escape_old'] = $this->config['auto_escape']; if ($mode == 'off' or $mode == 'false' or $mode == '0' or $mode == null) { $this->config['auto_escape'] = false; } else { $this->config['auto_escape'] = true; } } // autoescape on elseif (preg_match($tagMatch['autoescape_close'], $html, $matches)) { $this->config['auto_escape'] = $this->config['auto_escape_old']; unset($this->config['auto_escape_old']); } // function elseif (preg_match($tagMatch['function'], $html, $matches)) { // get function $function = $matches[1]; // var replace if (isset($matches[2])) $parsedFunction = $function . $this->varReplace($matches[2], $loopLevel, $escape = FALSE, $echo = FALSE); else $parsedFunction = $function . "()"; // check black list $this->blackList($parsedFunction); // function $parsedCode .= ""; } //ternary elseif (preg_match($tagMatch['ternary'], $html, $matches)) { $parsedCode .= "varReplace($matches[1], $loopLevel, $escape = TRUE, $echo = FALSE) . '?' . $this->varReplace($matches[2], $loopLevel, $escape = TRUE, $echo = FALSE) . ':' . $this->varReplace($matches[3], $loopLevel, $escape = TRUE, $echo = FALSE) . ')' . "; ?>"; } //variables elseif (preg_match($tagMatch['variable'], $html, $matches)) { //variables substitution (es. {$title}) $parsedCode .= "varReplace($matches[1], $loopLevel, $escape = TRUE, $echo = TRUE) . "; ?>"; } //constants elseif (preg_match($tagMatch['constant'], $html, $matches)) { $parsedCode .= "conReplace($matches[1], $loopLevel) . "; ?>"; } // registered tags else { $found = FALSE; foreach (static::$registered_tags as $tags => $array) { if (preg_match_all('/' . $array['parse'] . '/', $html, $matches)) { $found = true; $parsedCode .= ""; } } if (!$found){ $parsedCode .= $html; } } } if ($isString) { if ($openIf > 0) { $trace = debug_backtrace(); $caller = array_shift($trace); $e = new SyntaxException("Error! You need to close an {if} tag in the string, loaded by {$caller['file']} at line {$caller['line']}"); throw $e->templateFile($templateFilepath); } if ($loopLevel > 0) { $trace = debug_backtrace(); $caller = array_shift($trace); $e = new SyntaxException("Error! You need to close the {loop} tag in the string, loaded by {$caller['file']} at line {$caller['line']}"); throw $e->templateFile($templateFilepath); } } else { if ($openIf > 0) { $e = new SyntaxException("Error! You need to close an {if} tag in $templateFilepath template"); throw $e->templateFile($templateFilepath); } if ($loopLevel > 0) { $e = new SyntaxException("Error! You need to close the {loop} tag in $templateFilepath template"); throw $e->templateFile($templateFilepath); } } $html = str_replace('?>code = $parsedCode; $this->getPlugins()->run('afterParse', $context); return $context->code; } protected function varReplace($html, $loopLevel = NULL, $escape = TRUE, $echo = FALSE) { // change variable name if loop level if (!empty($loopLevel)) $html = preg_replace(array('/(\$key)\b/', '/(\$value)\b/', '/(\$counter)\b/'), array('${1}' . $loopLevel, '${1}' . $loopLevel, '${1}' . $loopLevel), $html); // if it is a variable if (preg_match_all('/(\$[a-z_A-Z][^\s]*)/', $html, $matches)) { // substitute . and [] with [" "] for ($i = 0; $i < count($matches[1]); $i++) { $rep = preg_replace('/\[(\${0,1}[a-zA-Z_0-9]*)\]/', '["$1"]', $matches[1][$i]); //$rep = preg_replace('/\.(\${0,1}[a-zA-Z_0-9]*)/', '["$1"]', $rep); $rep = preg_replace( '/\.(\${0,1}[a-zA-Z_0-9]*(?![a-zA-Z_0-9]*(\'|\")))/', '["$1"]', $rep ); $html = str_replace($matches[0][$i], $rep, $html); } // update modifier $html = $this->modifierReplace($html); // if does not initialize a value, e.g. {$a = 1} if (!preg_match('/\$.*=.*/', $html)) { // escape character if ($this->config['auto_escape'] && $escape) //$html = "htmlspecialchars( $html )"; $html = "htmlspecialchars( $html, ENT_COMPAT, '" . $this->config['charset'] . "', FALSE )"; // if is an assignment it doesn't add echo if ($echo) $html = "echo " . $html; } } return $html; } protected function conReplace($html) { $html = $this->modifierReplace($html); return $html; } protected function modifierReplace($html) { $this->blackList($html); if (strpos($html,'|') !== false && substr($html,strpos($html,'|')+1,1) != "|") { preg_match('/([\$a-z_A-Z0-9\(\),\[\]"->]+)\|([\$a-z_A-Z0-9\(\):,\[\]"->\s]+)/i', $html,$result); $function_params = $result[1]; $result[2] = str_replace("::", "@double_dot@", $result[2] ); $explode = explode(":",$result[2]); $function = str_replace('@double_dot@', '::', $explode[0]); $params = isset($explode[1]) ? "," . $explode[1] : null; $html = str_replace($result[0],$function . "(" . $function_params . "$params)",$html); if (strpos($html,'|') !== false && substr($html,strpos($html,'|')+1,1) != "|") { $html = $this->modifierReplace($html); } } return $html; } protected function blackList($html) { if (!$this->config['sandbox'] || !static::$black_list) return true; if (empty($this->config['black_list_preg'])) $this->config['black_list_preg'] = '#[\W\s]*' . implode('[\W\s]*|[\W\s]*', static::$black_list) . '[\W\s]*#'; // check if the function is in the black list (or not in white list) if (preg_match($this->config['black_list_preg'], $html, $match)) { // find the line of the error $line = 0; $rows = explode("\n", $this->templateInfo['code']); while (!strpos($rows[$line], $html) && $line + 1 < count($rows)) $line++; // stop the execution of the script $e = new SyntaxException('Syntax ' . $match[0] . ' not allowed in template: ' . $this->templateInfo['template_filepath'] . ' at line ' . $line); throw $e->templateFile($this->templateInfo['template_filepath']) ->tag($match[0]) ->templateLine($line); return false; } } public static function reducePath( $path ){ // reduce the path $path = str_replace( "://", "@not_replace@", $path ); $path = preg_replace( "#(/+)#", "/", $path ); $path = preg_replace( "#(/\./+)#", "/", $path ); $path = str_replace( "@not_replace@", "://", $path ); while( preg_match('#\w+\.\./#', $path) ) { $path = preg_replace('#\w+/\.\./#', '', $path ); } return $path; } } raintpl3-3.1.1/library/Rain/Tpl/Plugin.php 0000664 0000000 0000000 00000005654 13306571373 0020335 0 ustar 00root root 0000000 0000000 setOptions($options); } /** * Returns a list of hooks that are implemented by the plugin. * This should be an array containing: * - a key/value pair where key is hook name and value is implementing method, * - a value only when hook has same name as method. */ public function declareHooks() { return $this->hooks; } /** * Sets plugin options. * * @var array */ public function setOptions($options) { foreach ((array) $options as $key => $val) { $this->setOption($key, $val); } return $this; } /** * Sets plugin option. * * @param string $name * @param mixed $value * @throws \InvalidArgumentException Wrong option name or value * @return Plugin */ public function setOption($name, $value) { $method = 'set' . ucfirst($name); if (!\method_exists($this, $method)) { throw new \InvalidArgumentException('Key "' . $name . '" is not a valid settings option' ); } $this->{$method}($value); return $this; } } raintpl3-3.1.1/library/Rain/Tpl/Plugin/ 0000775 0000000 0000000 00000000000 13306571373 0017612 5 ustar 00root root 0000000 0000000 raintpl3-3.1.1/library/Rain/Tpl/Plugin/Compress.php 0000664 0000000 0000000 00000022403 13306571373 0022117 0 ustar 00root root 0000000 0000000 array('status'=>true), 'css' =>array('status'=>true), 'javascript'=>array('status'=>true, 'position'=>'bottom'), ); /** * Initialize the local configuration */ public function __construct(){ $this->conf = self::$configure; } /** * Function called in the hook afterDraw * @param \ArrayAccess $context */ public function afterDraw(\ArrayAccess $context) { // get the cache directory $this->cache_dir = $context->conf['cache_dir']; $html = $context->code; if( $this->conf['css']['status'] ) $html = $this->compressCSS( $html ); if( $this->conf['javascript']['status'] ) $html = self::compressJavascript( $html ); if( $this->conf['html']['status'] ) $html = $this->compressHTML($html); // save the compressed code $context->code = $html; } /** * Compress the HTML * @param type $html * @return type */ protected function compressHTML($html) { // Set PCRE recursion limit to sane value = STACKSIZE / 500 // ini_set("pcre.recursion_limit", "524"); // 256KB stack. Win32 Apache ini_set("pcre.recursion_limit", "16777"); // 8MB stack. *nix $re = '%# Collapse whitespace everywhere but in blacklisted elements. (?> # Match all whitespans other than single space. [^\S ]\s* # Either one [\t\r\n\f\v] and zero or more ws, | \s{2,} # or two or more consecutive-any-whitespace. ) # Note: The remaining regex consumes no text at all... (?= # Ensure we are not in a blacklist tag. [^<]*+ # Either zero or more non-"<" {normal*} (?: # Begin {(special normal*)*} construct < # or a < starting a non-blacklist tag. (?!/?(?:textarea|pre|script)\b) [^<]*+ # more non-"<" {normal*} )*+ # Finish "unrolling-the-loop" (?: # Begin alternation group. < # Either a blacklist start tag. (?>textarea|pre|script)\b | \z # or end of file. ) # End alternation group. ) # If we made it here, we are not in a blacklist tag. %Six'; $html = preg_replace($re, " ", $html); if ($html === null) exit("PCRE Error! File too big.\n"); return $html; } /** * Compress the CSS * @param type $html * @return type */ protected function compressCSS($html) { // search for all stylesheet if (!preg_match_all("/ /", $html, $matches)) return $html; // return the HTML if doesn't find any // prepare the variables $externalUrl = array(); $css = $cssName = ""; $urlArray = array(); $cssFiles = $matches[1]; $md5Name = ""; foreach( $cssFiles as $file ){ $md5Name .= basename($file); } $cachedFilename = md5($md5Name); $cacheFolder = $this->cache_dir . "compress/css/"; // css cache folder $cachedFilepath = $cacheFolder . $cachedFilename . ".css"; if( !file_exists($cachedFilepath) ){ // read all the CSS found foreach ($cssFiles as $url) { // if a CSS is repeat it takes only the first if (empty($urlArray[$url])) { $urlArray[$url] = 1; // parse the URL $parse = parse_url($url); // read file $stylesheetFile = file_get_contents($url); // optimize image URL if (preg_match_all("/url\({0,1}(.*?)\)/", $stylesheetFile, $matches)) { foreach ($matches[1] as $imageUrl) { $imageUrl = preg_replace("/'|\"/", "", $imageUrl); dirname($url) . "/" . $imageUrl; $real_path = reduce_path("../../../" . dirname($url) . "/" . $imageUrl); $stylesheetFile = str_replace($imageUrl, $real_path, $stylesheetFile); } } // remove the comments $stylesheetFile = preg_replace("!/\*[^*]*\*+([^/][^*]*\*+)*/!", "", $stylesheetFile); // minify the CSS $stylesheetFile = preg_replace("/\n|\r|\t|\s{4}/", "", $stylesheetFile); $css .= "/*---\n CSS compressed in Rain \n {$url} \n---*/\n\n" . $stylesheetFile . "\n"; } } if (!is_dir($cacheFolder)) mkdir($cacheFolder, 0755, $recursive = true); // save the stylesheet file_put_contents($cachedFilepath, $css); } // remove all the old stylesheet from the page $html = preg_replace("/ /", "", $html); // create the tag for the stylesheet $tag = ''; // add the tag to the end of the tag $html = str_replace("", $tag . "\n", $html); // return the stylesheet return $html; } /** * Compress the CSS * @param type $html * @return type */ protected function compressJavascript($html) { $htmlToCheck = preg_replace("", "", $html); // search for javascript preg_match_all("/ /", $htmlToCheck, $matches); $externalUrl = array(); $javascript = ""; $javascriptFiles = $matches[1]; $md5Name = ""; foreach( $javascriptFiles as $file ){ $md5Name .= basename($file); } $cachedFilename = md5($md5Name); $cacheFolder = $this->cache_dir . "compress/js/"; // css cache folder $cachedFilepath = $cacheFolder . $cachedFilename . ".js"; if( !file_exists($cachedFilepath) ){ foreach ($matches[1] as $url) { // if a JS is repeat it takes only the first if (empty($urlArray[$url])) { $urlArray[$url] = $url; // reduce the path $url = \Rain\Tpl\Parser::reducePath( $url ); $javascriptFile = file_get_contents($url); // minify the js $javascriptFile = preg_replace("#/\*.*?\*/#", "", $javascriptFile); $javascriptFile = preg_replace("#\n+|\t+| +#", " ", $javascriptFile); $javascript .= "/*---\n Javascript compressed in Rain \n {$url} \n---*/\n\n" . $javascriptFile . "\n\n"; } } if (!is_dir($cacheFolder)) mkdir($cacheFolder, 0755, $recursive = true); // save the stylesheet file_put_contents($cachedFilepath, $javascript); } $html = preg_replace("/ /", "", $html); $tag = ''; if( $this->conf['javascript']['position'] == 'bottom' ){ $html = preg_replace("/<\/body>/", $tag . "
", $html); } else{ $html = preg_replace("/
/", "
\n".$tag, $html);
}
return $html;
}
public function configure( $setting, $value ){
$this->conf[$setting] = self::$configure[$setting] = $value;
}
public function configureLocal( $setting, $value ){
$this->conf[$setting] = $value;
}
}
raintpl3-3.1.1/library/Rain/Tpl/Plugin/ImageResize.php 0000664 0000000 0000000 00000013304 13306571373 0022530 0 ustar 00root root 0000000 0000000 code;
$template_basedir = $context->template_basedir;
$quality = $this->quality;
$auto_crop = $this->crop;
$conf = $context->conf;
$img_cache_dir = $template_basedir = $conf['cache_dir'];
// get the template base directory
$template_directory = $conf['base_url'] . $conf['tpl_dir'] . $template_basedir;
// reduce the path
$path = preg_replace('/\w+\/\.\.\//', '', $template_directory );
$exp = $sub = array();
$image_resized = false;
// match the images
if( preg_match_all( '/ Vestibulum id ligula porta felis euismod semper. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Etiam porta sem malesuada magna mollis euismod. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus..*?)"))|(\s*(width="(?
code = preg_replace( $exp, $sub, $html );
}
public function setTags($tags) {
$this->tags = (array) $tags;
return $this;
}
}
raintpl3-3.1.1/library/Rain/Tpl/PluginContainer.php 0000664 0000000 0000000 00000010441 13306571373 0022166 0 ustar 00root root 0000000 0000000 plugins[(string) $name])) {
throw new \InvalidArgumentException('Plugin named "' . $name . '" already exists in container');
}
return $this->setPlugin($name, $plugin);
}
/**
* Sets plugin by name. Plugin of same name is replaced when exists.
*
* @param string $name
* @param IPlugin $plugin
* @return PluginContainer
*/
public function setPlugin($name, IPlugin $plugin) {
$this->removePlugin($name);
$this->plugins[(string) $name] = $plugin;
foreach ((array) $plugin->declareHooks() as $hook => $method) {
if (is_int($hook)) {
// numerical key, method has same name as hook
$hook = $method;
}
$callable = array($plugin, $method);
if (!is_callable($callable)) {
throw new \InvalidArgumentException(sprintf(
'Wrong callcable suplied by %s for "%s" hook ',
get_class($plugin), $hook
));
}
$this->hooks[$hook][] = $callable;
}
return $this;
}
public function removePlugin($name) {
$name = (string) $name;
if (!isset($this->plugins[$name])) {
return;
}
$plugin = $this->plugins[$name];
unset($this->plugins[$name]);
// remove all registered callables
foreach ($this->hooks as $hook => &$callables) {
foreach ($callables as $i => $callable) {
if ($callable[0] === $plugin) {
unset($callables[$i]);
}
}
}
return $this;
}
/**
* Passes the context object to registered plugins.
*
* @param string $hook_name
* @param \ArrayAccess $context
* @return PluginContainer
*/
public function run($hook_name, \ArrayAccess $context ){
if (!isset($this->hooks[$hook_name])) {
return $this;
}
$context['_hook_name'] = $hook_name;
foreach( $this->hooks[$hook_name] as $callable ){
call_user_func($callable, $context);
}
return $this;
}
/**
* Retuns context object that will be passed to plugins.
*
* @param array $params
* @return \ArrayObject
*/
public function createContext($params = array())
{
return new \ArrayObject((array) $params, \ArrayObject::ARRAY_AS_PROPS);
}
}
raintpl3-3.1.1/library/Rain/Tpl/SyntaxException.php 0000664 0000000 0000000 00000004311 13306571373 0022231 0 ustar 00root root 0000000 0000000 templateLine;
$this->templateLine = (int) $line;
return $this;
}
/**
* Handles the tag which caused an error.
*
* @param string | null $tag
*
* @return \Rain\Tpl_SyntaxException | string | null
*/
public function tag($tag=null){
if(is_null($tag))
return $this->tag;
$this->tag = (string) $tag;
return $this;
}
}
// -- end
raintpl3-3.1.1/library/Rain/autoload.php 0000664 0000000 0000000 00000003604 13306571373 0020141 0 ustar 00root root 0000000 0000000 ";
echo $path;
echo "
";
echo $abs_path;
echo "
";
}
// require the file
require_once $abs_path;
}
} raintpl3-3.1.1/phpunit.xml.dist 0000664 0000000 0000000 00000001214 13306571373 0016431 0 ustar 00root root 0000000 0000000
Hello, world!
Heading
Heading
Heading