Removing unused libs
This commit is contained in:
11
gulliver/thirdparty/Haanga/.travis.yml
vendored
11
gulliver/thirdparty/Haanga/.travis.yml
vendored
@@ -1,11 +0,0 @@
|
||||
language: php
|
||||
script: cd tests/; phpunit TestSuite.php
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
|
||||
before_script:
|
||||
- curl -s http://getcomposer.org/installer | php
|
||||
- php composer.phar install
|
||||
|
||||
30
gulliver/thirdparty/Haanga/LICENSE
vendored
30
gulliver/thirdparty/Haanga/LICENSE
vendored
@@ -1,30 +0,0 @@
|
||||
Copyright (c) 2011, César D. Rodas <crodas@php.net> and Menéame Comunicacions S.L.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. 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.
|
||||
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
This product includes software developed by César D. Rodas.
|
||||
|
||||
4. Neither the name of the Menéame Comunicacions S.L. nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY MENÉAME COMUNICACIONS S.L. ''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 CÉSAR D. RODAS 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
|
||||
17
gulliver/thirdparty/Haanga/Makefile
vendored
17
gulliver/thirdparty/Haanga/Makefile
vendored
@@ -1,17 +0,0 @@
|
||||
all: build test
|
||||
|
||||
build:
|
||||
#plex lib/Haanga/Compiler/Lexer.lex
|
||||
phplemon lib/Haanga/Compiler/Parser.y
|
||||
|
||||
|
||||
test:
|
||||
cd tests; ~/bin/php-5.2/bin/php /usr/bin/phpunit --colors --verbose TestSuite.php
|
||||
cd tests; php /usr/bin/phpunit --coverage-html coverage/ --colors --verbose TestSuite.php
|
||||
|
||||
test-fast:
|
||||
cd tests; php /usr/bin/phpunit --stop-on-failure --colors --verbose TestSuite.php
|
||||
|
||||
|
||||
edit:
|
||||
vim lib/Haanga/Compiler/Parser.y lib/Haanga/Compiler/Tokenizer.php -O
|
||||
3
gulliver/thirdparty/Haanga/README
vendored
3
gulliver/thirdparty/Haanga/README
vendored
@@ -1,3 +0,0 @@
|
||||
This project was created* and sponsored by Menéame (http://meneame.net/)
|
||||
|
||||
[*] http://twitter.com/gallir/status/16256084676
|
||||
11
gulliver/thirdparty/Haanga/contrib/dummy.php
vendored
11
gulliver/thirdparty/Haanga/contrib/dummy.php
vendored
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
Class Haanga_Extension_Tag_Dummy
|
||||
{
|
||||
public $is_block = TRUE;
|
||||
|
||||
static function main($html)
|
||||
{
|
||||
return strtolower($html);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Tag_MeneamePagination
|
||||
{
|
||||
public $is_block = FALSE;
|
||||
|
||||
static function generator($cmp, $args, $redirected)
|
||||
{
|
||||
if (count($args) != 3 && count($args) != 4) {
|
||||
throw new Haanga_CompilerException("Memeame_Pagination requires 3 or 4 parameters");
|
||||
}
|
||||
|
||||
if (count($args) == 3) {
|
||||
$args[3] = 5;
|
||||
}
|
||||
|
||||
$current = hvar('mnm_current');
|
||||
$total = hvar('mnm_total');
|
||||
$start = hvar('mnm_start');
|
||||
$end = hvar('mnm_end');
|
||||
$prev = hvar('mnm_prev');
|
||||
$next = hvar('mnm_next');
|
||||
$pages = 'mnm_pages';
|
||||
|
||||
$code = hcode();
|
||||
|
||||
$code->decl($current, $args[0]);
|
||||
$code->decl($total, hexec('ceil', hexpr($args[2], '/', $args[1])) );
|
||||
$code->decl($start, hexec('max', hexpr($current, '-', hexec('intval', hexpr($args[3],'/', 2))), 1));
|
||||
$code->decl($end, hexpr($start, '+', $args[3], '-', 1));
|
||||
$code->decl($prev, hexpr_cond( hexpr(1, '==', $current), FALSE, hexpr($current, '-', 1)) );
|
||||
$code->decl($next, hexpr_cond( hexpr($args[2], '<', 0, '||', $current, '<', $total), hexpr($current, '+', 1), FALSE));
|
||||
$code->decl('mnm_pages', hexec('range', $start, hexpr_cond(hexpr($end,'<', $total), $end, $total)));
|
||||
|
||||
$cmp->set_safe($current);
|
||||
$cmp->set_safe($total);
|
||||
$cmp->set_safe($prev);
|
||||
$cmp->set_safe($next);
|
||||
$cmp->set_safe($pages);
|
||||
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
}
|
||||
8
gulliver/thirdparty/Haanga/haanga-cli.php
vendored
8
gulliver/thirdparty/Haanga/haanga-cli.php
vendored
@@ -1,8 +0,0 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__)."/lib/Haanga.php";
|
||||
|
||||
Haanga::registerAutoload();
|
||||
|
||||
Haanga_Compiler::main_cli();
|
||||
427
gulliver/thirdparty/Haanga/lib/Haanga.php
vendored
427
gulliver/thirdparty/Haanga/lib/Haanga.php
vendored
File diff suppressed because it is too large
Load Diff
545
gulliver/thirdparty/Haanga/lib/Haanga/AST.php
vendored
545
gulliver/thirdparty/Haanga/lib/Haanga/AST.php
vendored
File diff suppressed because it is too large
Load Diff
1529
gulliver/thirdparty/Haanga/lib/Haanga/Compiler.php
vendored
1529
gulliver/thirdparty/Haanga/lib/Haanga/Compiler.php
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Copyright (c) 2010 César Rodas and Menéame Comunicacions S.L. |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions are met: |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| |
|
||||
| 2. 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. |
|
||||
| |
|
||||
| 3. All advertising materials mentioning features or use of this software |
|
||||
| must display the following acknowledgement: |
|
||||
| This product includes software developed by César D. Rodas. |
|
||||
| |
|
||||
| 4. Neither the name of the César D. Rodas nor the |
|
||||
| names of its contributors may be used to endorse or promote products |
|
||||
| derived from this software without specific prior written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY CÉSAR D. RODAS ''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 CÉSAR D. RODAS 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 |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Authors: César Rodas <crodas@php.net> |
|
||||
+---------------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
// Exception Class {{{
|
||||
/**
|
||||
* Exception class
|
||||
*
|
||||
*/
|
||||
class Haanga_Compiler_Exception extends Exception
|
||||
{
|
||||
}
|
||||
// }}}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,136 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Copyright (c) 2010 César Rodas and Menéame Comunicacions S.L. |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions are met: |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| |
|
||||
| 2. 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. |
|
||||
| |
|
||||
| 3. All advertising materials mentioning features or use of this software |
|
||||
| must display the following acknowledgement: |
|
||||
| This product includes software developed by César D. Rodas. |
|
||||
| |
|
||||
| 4. Neither the name of the César D. Rodas nor the |
|
||||
| names of its contributors may be used to endorse or promote products |
|
||||
| derived from this software without specific prior written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY CÉSAR D. RODAS ''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 CÉSAR D. RODAS 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 |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Authors: César Rodas <crodas@php.net> |
|
||||
+---------------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
* Runtime compiler
|
||||
*
|
||||
*/
|
||||
final class Haanga_Compiler_Runtime extends Haanga_Compiler
|
||||
{
|
||||
|
||||
// get_function_name($name=NULL) {{{
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
function get_function_name($name)
|
||||
{
|
||||
return "haanga_".sha1($name);
|
||||
}
|
||||
// }}}
|
||||
|
||||
// set_template_name($path) {{{
|
||||
function set_template_name($path)
|
||||
{
|
||||
return $path;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// Override {% include %} {{{
|
||||
protected function generate_op_include($details, &$body)
|
||||
{
|
||||
$this->do_print($body,
|
||||
hexec('Haanga::Load', $details[0], $this->getScopeVariable(),
|
||||
TRUE,
|
||||
hvar('blocks'))
|
||||
);
|
||||
}
|
||||
// }}}
|
||||
|
||||
// {% base "" %} {{{
|
||||
function expr_call_base_template()
|
||||
{
|
||||
return hexec('Haanga::Load', $this->subtemplate,
|
||||
$this->getScopeVariable(), TRUE, hvar('blocks'));
|
||||
}
|
||||
// }}}
|
||||
|
||||
// get_base_template($base) {{{
|
||||
function get_base_template($base)
|
||||
{
|
||||
$this->subtemplate = $base;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// Override get_Custom_tag {{{
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
function get_custom_tag($name)
|
||||
{
|
||||
static $tag = NULL;
|
||||
if (!$tag) $tag = Haanga_Extension::getInstance('Tag');
|
||||
$loaded = &$this->tags;
|
||||
|
||||
if (!isset($loaded[$name])) {
|
||||
$this->prepend_op->comment("Load tag {$name} definition");
|
||||
$this->prepend_op->do_exec('require_once', $tag->getFilePath($name, FALSE));
|
||||
$loaded[$name] = TRUE;
|
||||
}
|
||||
|
||||
return $tag->getClassName($name)."::main";
|
||||
}
|
||||
// }}}
|
||||
|
||||
// Override get_custom_filter {{{
|
||||
function get_custom_filter($name)
|
||||
{
|
||||
static $filter = NULL;
|
||||
if (!$filter) $filter=Haanga_Extension::getInstance('Filter');
|
||||
$loaded = &$this->filters;
|
||||
|
||||
if (!isset($loaded[$name])) {
|
||||
$this->prepend_op->comment("Load filter {$name} definition");
|
||||
$this->prepend_op->do_exec('require_once', $filter->getFilePath($name, FALSE));
|
||||
$loaded[$name] = TRUE;
|
||||
}
|
||||
|
||||
return $filter->getClassName($name)."::main";
|
||||
}
|
||||
// }}}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Copyright (c) 2010 César Rodas and Menéame Comunicacions S.L. |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions are met: |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| |
|
||||
| 2. 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. |
|
||||
| |
|
||||
| 3. All advertising materials mentioning features or use of this software |
|
||||
| must display the following acknowledgement: |
|
||||
| This product includes software developed by César D. Rodas. |
|
||||
| |
|
||||
| 4. Neither the name of the César D. Rodas nor the |
|
||||
| names of its contributors may be used to endorse or promote products |
|
||||
| derived from this software without specific prior written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY CÉSAR D. RODAS ''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 CÉSAR D. RODAS 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 |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Authors: César Rodas <crodas@php.net> |
|
||||
+---------------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
// Haanga_Exception {{{
|
||||
/**
|
||||
* General exception class. It is thrown
|
||||
* when something is not configured properly
|
||||
*
|
||||
*/
|
||||
class Haanga_Exception extends Exception
|
||||
{
|
||||
}
|
||||
// }}}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
|
||||
183
gulliver/thirdparty/Haanga/lib/Haanga/Extension.php
vendored
183
gulliver/thirdparty/Haanga/lib/Haanga/Extension.php
vendored
@@ -1,183 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Copyright (c) 2010 César Rodas and Menéame Comunicacions S.L. |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions are met: |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| |
|
||||
| 2. 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. |
|
||||
| |
|
||||
| 3. All advertising materials mentioning features or use of this software |
|
||||
| must display the following acknowledgement: |
|
||||
| This product includes software developed by César D. Rodas. |
|
||||
| |
|
||||
| 4. Neither the name of the César D. Rodas nor the |
|
||||
| names of its contributors may be used to endorse or promote products |
|
||||
| derived from this software without specific prior written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY CÉSAR D. RODAS ''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 CÉSAR D. RODAS 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 |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Authors: César Rodas <crodas@php.net> |
|
||||
+---------------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
Abstract Class Haanga_Extension
|
||||
{
|
||||
private static $_instances;
|
||||
|
||||
final private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
final static function getInstance($name)
|
||||
{
|
||||
$name = 'Haanga_Extension_'.$name;
|
||||
if (!class_exists($name)) {
|
||||
throw new Haanga_Compiler_Exception("{$name} is not a class");
|
||||
}
|
||||
if (!is_subclass_of($name, __CLASS__)) {
|
||||
throw new Haanga_Compiler_Exception("{$name} is not a sub-class of ".__CLASS__);
|
||||
}
|
||||
|
||||
if (!isset(self::$_instances[$name])) {
|
||||
self::$_instances[$name] = new $name;
|
||||
}
|
||||
return self::$_instances[$name];
|
||||
}
|
||||
|
||||
abstract function isValid($name);
|
||||
abstract function getClassName($name);
|
||||
|
||||
final function getFilePath($name, $rel=TRUE, $pref=NULL)
|
||||
{
|
||||
try {
|
||||
$reflection = new ReflectionClass($this->getClassName($name));
|
||||
$file = $reflection->getFileName();
|
||||
} catch (Exception $e) {
|
||||
$file = "";
|
||||
}
|
||||
return $file;
|
||||
}
|
||||
|
||||
final public function getFunctionAlias($name)
|
||||
{
|
||||
if (!$this->isValid($name)) {
|
||||
return NULL;
|
||||
}
|
||||
$zclass = $this->getClassName($name);
|
||||
$properties = get_class_vars($zclass);
|
||||
if (isset($properties['php_alias'])) {
|
||||
return $properties['php_alias'];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
final public function isSafe($name)
|
||||
{
|
||||
if (!$this->isValid($name)) {
|
||||
return NULL;
|
||||
}
|
||||
$zclass = $this->getClassName($name);
|
||||
$properties = get_class_vars($zclass);
|
||||
return isset($properties['is_safe']) ? $properties['is_safe'] : FALSE;
|
||||
}
|
||||
|
||||
// generator(string $name, Haanga_Compiler $compiler, Array $args) {{{
|
||||
/**
|
||||
* Executer the generator method of the extension. If
|
||||
* the extension doesn't has any generator method, an empty
|
||||
* will be returned.
|
||||
*
|
||||
* @param string $name extension name
|
||||
* @param Haanga_Compiler Compiler object
|
||||
* @param array Arrays
|
||||
* @param mixed Extra param
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function generator($name, Haanga_Compiler $compiler, $args, $extra=NULL)
|
||||
{
|
||||
if (!$this->hasGenerator($name)) {
|
||||
return array();
|
||||
}
|
||||
$zclass = $this->getClassName($name);
|
||||
return call_user_func(array($zclass, 'generator'), $compiler, $args, $extra);
|
||||
}
|
||||
// }}}
|
||||
|
||||
// hasGenerator(string $name) {{{
|
||||
/**
|
||||
* Return TRUE if the extension has a
|
||||
* generator method
|
||||
*
|
||||
* @param string $name Extension name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function hasGenerator($name)
|
||||
{
|
||||
if (!$this->isValid($name)) {
|
||||
return NULL;
|
||||
}
|
||||
$zclass = $this->getClassName($name);
|
||||
return is_callable(array($zclass, 'generator'));
|
||||
}
|
||||
// }}}
|
||||
|
||||
// getFunctionBody(string $name, string $name) {{{
|
||||
/**
|
||||
* Return the body function of the custom extension main method.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getFunctionBody($tag_name, $name)
|
||||
{
|
||||
if (!$this->isValid($tag_name)) {
|
||||
return NULL;
|
||||
}
|
||||
$zclass = $this->getClassName($tag_name);
|
||||
if (!is_callable(array($zclass, 'main'))) {
|
||||
throw new Haanga_Compiler_Exception("{$name}: missing main method in {$zclass} class");
|
||||
}
|
||||
|
||||
$reflection = new ReflectionMethod($zclass, 'main');
|
||||
$content = file($this->getFilePath($tag_name));
|
||||
|
||||
$start = $reflection->getStartLine()-1;
|
||||
$end = $reflection->getEndLine();
|
||||
$content = array_slice($content, $start, $end-$start);
|
||||
|
||||
$content[0] = str_replace("main", $name, $content[0]);
|
||||
|
||||
|
||||
return "if (!function_exists('{$name}')) {\n".implode("", $content)."}";
|
||||
}
|
||||
// }}}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,79 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Copyright (c) 2010 César Rodas and Menéame Comunicacions S.L. |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Redistribution and use in source and binary forms, with or without |
|
||||
| modification, are permitted provided that the following conditions are met: |
|
||||
| 1. Redistributions of source code must retain the above copyright |
|
||||
| notice, this list of conditions and the following disclaimer. |
|
||||
| |
|
||||
| 2. 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. |
|
||||
| |
|
||||
| 3. All advertising materials mentioning features or use of this software |
|
||||
| must display the following acknowledgement: |
|
||||
| This product includes software developed by César D. Rodas. |
|
||||
| |
|
||||
| 4. Neither the name of the César D. Rodas nor the |
|
||||
| names of its contributors may be used to endorse or promote products |
|
||||
| derived from this software without specific prior written permission. |
|
||||
| |
|
||||
| THIS SOFTWARE IS PROVIDED BY CÉSAR D. RODAS ''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 CÉSAR D. RODAS 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 |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| Authors: César Rodas <crodas@php.net> |
|
||||
+---------------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
class Haanga_Extension_Filter extends Haanga_Extension
|
||||
{
|
||||
/**
|
||||
* isValid
|
||||
*
|
||||
*
|
||||
*/
|
||||
final function isValid($filter)
|
||||
{
|
||||
static $cache = array();
|
||||
$filter = strtolower($filter);
|
||||
|
||||
if (!isset($cache[$filter])) {
|
||||
$class_name = $this->getClassName($filter);
|
||||
if (class_exists($class_name)) {
|
||||
$cache[$filter] = TRUE;
|
||||
} else {
|
||||
$cache[$filter] = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return $cache[$filter];
|
||||
}
|
||||
|
||||
final function getClassName($filter)
|
||||
{
|
||||
$filter = str_replace("_", "", ucfirst($filter));
|
||||
return "Haanga_Extension_Filter_{$filter}";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Capfirst
|
||||
{
|
||||
public $php_alias = "ucfirst";
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Count
|
||||
{
|
||||
public $php_alias = "count";
|
||||
public $is_safe = TRUE; /* a number if safe */
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
Class Haanga_Extension_Filter_Cut
|
||||
{
|
||||
|
||||
/**
|
||||
* We implement "cut" filter at compilation time, to
|
||||
* avoid senseless includes for simple things.
|
||||
*
|
||||
* We can also define an "php_alias" that will simple
|
||||
* call this function (therefore it must exists at
|
||||
* rendering time).
|
||||
*
|
||||
* Also a Main() static method could be declared, this will
|
||||
* included at runtime or copied as a function if the CLI is used (more
|
||||
* or less django style).
|
||||
*
|
||||
*/
|
||||
static function generator($compiler, $args)
|
||||
{
|
||||
return hexec('str_replace', $args[1], "", $args[0]);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Date
|
||||
{
|
||||
static function generator($compiler, $args)
|
||||
{
|
||||
return hexec('date', $args[1], $args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Default
|
||||
{
|
||||
static function generator($compiler, $args)
|
||||
{
|
||||
return hexpr_cond(hexpr(hexec('empty', $args[0]), '==', TRUE), $args[1], $args[0]);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Dictsort
|
||||
{
|
||||
/**
|
||||
* Sorted a nested array by '$sort_by'
|
||||
* property on each sub-array. This
|
||||
* filter is included at rendering time, if you want
|
||||
* to see the generated version see tags/dictsort.php
|
||||
*/
|
||||
static function main($array, $sort_by)
|
||||
{
|
||||
$field = array();
|
||||
foreach ($array as $key => $item) {
|
||||
$field[$key] = $item[$sort_by];
|
||||
}
|
||||
array_multisort($field, SORT_REGULAR, $array);
|
||||
return $array;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Empty
|
||||
{
|
||||
public $php_alias = 'empty';
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Escape
|
||||
{
|
||||
public $php_alias = "htmlspecialchars";
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Exists
|
||||
{
|
||||
public $php_alias = 'isset';
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_Hostname
|
||||
{
|
||||
static function generator($cmp, $args)
|
||||
{
|
||||
return hexec('parse_url', $args[0], hconst('PHP_URL_HOST'));
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_intval
|
||||
{
|
||||
public $php_alias = 'intval';
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Haanga_Extension_Filter_IsArray
|
||||
{
|
||||
public $php_alias = "is_array";
|
||||
public $is_safe = TRUE; /* boolean if safe */
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user