préparation de la 0.5
This commit is contained in:
parent
6f6f050f0a
commit
2dfde6b61e
278 changed files with 79759 additions and 0 deletions
81
trunk/HTML/Template/Flexy/Compiler/Regex/BodyOnly.php
Normal file
81
trunk/HTML/Template/Flexy/Compiler/Regex/BodyOnly.php
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2003 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 2.02 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/2_02.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Alan Knowles <alan@akbkhome.com>
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* The html Body only filter
|
||||
*
|
||||
* @abstract
|
||||
* a Simple filter to remove the everything thats not in the body!
|
||||
*
|
||||
* @package HTML_Template_Flexy
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
class HTML_Template_Flexy_Compiler_Regex_BodyOnly
|
||||
{
|
||||
|
||||
/**
|
||||
* Standard Set Engine
|
||||
*
|
||||
*
|
||||
* @param object HTML_Template_Flexy the main engine
|
||||
* @access private
|
||||
*/
|
||||
|
||||
function _set_engine(&$engine)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Strip everything before and including the BODY tag
|
||||
*
|
||||
* @param string The template
|
||||
* @access public
|
||||
*/
|
||||
|
||||
function strip_body_head ($input)
|
||||
{
|
||||
if (!preg_match("/^(.*)<body/si", $input)) {
|
||||
return $input;
|
||||
}
|
||||
$input = preg_replace("/^(.*)<body/si", "",$input);
|
||||
$input = preg_replace("/^([^>]*)>/si", "",$input);
|
||||
return $input;
|
||||
}
|
||||
/**
|
||||
* Strip everything after and including the end BODY tag
|
||||
*
|
||||
* @param string The template
|
||||
* @access public
|
||||
*/
|
||||
function strip_body_foot ($input)
|
||||
{
|
||||
if (!preg_match("/<\/body>.*/si", $input)) {
|
||||
return $input;
|
||||
}
|
||||
$input = preg_replace("/<\/body>.*/si", "",$input);
|
||||
return $input;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
57
trunk/HTML/Template/Flexy/Compiler/Regex/Mail.php
Normal file
57
trunk/HTML/Template/Flexy/Compiler/Regex/Mail.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2003 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 2.02 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/2_02.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Alan Knowles <alan@akbkhome.com>
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* The Mail filter template (sorts out cr removal in php)
|
||||
*
|
||||
*
|
||||
* @package HTML_Template_Flexy
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
class HTML_Template_Flexy_Compiler_Regex_Mail {
|
||||
/**
|
||||
* Standard Set Engine
|
||||
*
|
||||
*
|
||||
* @param object HTML_Template_Flexy the main engine
|
||||
* @access private
|
||||
*/
|
||||
function _set_engine(&$engine)
|
||||
{
|
||||
}
|
||||
/*
|
||||
* add an extra cr to the end php tag, so it show correctly in Emails
|
||||
*
|
||||
* @param string The template
|
||||
* @access public
|
||||
*/
|
||||
|
||||
function post_fix_php_cr ($input)
|
||||
{
|
||||
$input = str_replace("?>\n","?>\n\n",$input);
|
||||
return str_replace("?>\r\n","?>\r\n\r\n",$input);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
74
trunk/HTML/Template/Flexy/Compiler/Regex/Math.php
Normal file
74
trunk/HTML/Template/Flexy/Compiler/Regex/Math.php
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2003 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 2.02 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/2_02.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Alan Knowles <alan@akbkhome.com>
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* A Math Filter
|
||||
*
|
||||
* enable simple maths to be done in the template
|
||||
*
|
||||
* TODO: add an {if:t.xxx%2} type syntax..
|
||||
*
|
||||
* @package HTML_Template_Flexy
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
class HTML_Template_Flexy_Compiler_Regex_Math {
|
||||
/*
|
||||
* @var string $start the start tag for the template (escaped for regex)
|
||||
*/
|
||||
var $start = '\{';
|
||||
/*
|
||||
* @var string $stop the stopt tag for the template (escaped for regex)
|
||||
*/
|
||||
var $stop = '\}'; //ending template tag
|
||||
/**
|
||||
* Standard Set Engine
|
||||
*
|
||||
*
|
||||
* @param object HTML_Template_Flexy the main engine
|
||||
* @access private
|
||||
*/
|
||||
function _set_engine(&$engine) {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* allow simple add multiply, divide and subtraction
|
||||
*
|
||||
* eg.
|
||||
* {(12+t.somevar)*2} maps to =(12+$t->somevar)*2
|
||||
*
|
||||
* @param string The template
|
||||
* @access public
|
||||
*/
|
||||
function variables ($input) {
|
||||
$input = preg_replace(
|
||||
"/".$this->start."([0-9\(\)+*\/-]*)([a-z0-9]+)([0-9\(\)+*\/-]*)".$this->stop."/ie",
|
||||
"'<?=\\1($'.str_replace('.','->','\\2').')\\3?>'",
|
||||
$input);
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
59
trunk/HTML/Template/Flexy/Compiler/Regex/Php.php
Normal file
59
trunk/HTML/Template/Flexy/Compiler/Regex/Php.php
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2003 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 2.02 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/2_02.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Alan Knowles <alan@akbkhome.com>
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* Remove PHP tags and replace them with echo '< ? '
|
||||
*
|
||||
* should be the first filter if you use it
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package HTML_Template_Flexy
|
||||
*
|
||||
*/
|
||||
class HTML_Template_Flexy_Compiler_Regex_Php
|
||||
{
|
||||
/**
|
||||
* Standard Set Engine
|
||||
*
|
||||
*
|
||||
* @param object HTML_Template_Flexy the main engine
|
||||
* @access private
|
||||
*/
|
||||
function _set_engine(&$engine)
|
||||
{
|
||||
}
|
||||
/*
|
||||
* replace the php tags
|
||||
*
|
||||
* @param string The template
|
||||
* @access public
|
||||
*/
|
||||
function pre_strip_php ($input)
|
||||
{
|
||||
$input = str_replace("<?","__{<__?}__",$input);
|
||||
$input = str_replace("?>","<?php echo '?'.'>'; ?>",$input);
|
||||
return str_replace("__{<__?}__","<?php echo '<'.'>'; ?>",$input);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
50
trunk/HTML/Template/Flexy/Compiler/Regex/RtfSimpleTags.php
Normal file
50
trunk/HTML/Template/Flexy/Compiler/Regex/RtfSimpleTags.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2003 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 2.02 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/2_02.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Alan Knowles <alan@akbkhome.com>
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* The rtf SimpleTags filter
|
||||
*
|
||||
* really an extension of simple tags with \\\{ and \\\\} as the tag delimiters
|
||||
* can parse an RTF template and generate a file.
|
||||
*
|
||||
* usually best used with callback ouput buffering to reduce memory loads.
|
||||
*
|
||||
* @package HTML_Template_Flexy
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
require_once "HTML/Template/Flexy/Filter/SimpleTags.php";
|
||||
|
||||
class HTML_Template_Flexy_Compiler_Regex_RtfSimpleTags extends HTML_Template_Flexy_Compiler_Regex_simpletags
|
||||
{
|
||||
/*
|
||||
* @var string $start the start tag for the template (escaped for regex)
|
||||
*/
|
||||
var $start = '\\\{';
|
||||
/*
|
||||
* @var string $stop the stopt tag for the template (escaped for regex)
|
||||
*/
|
||||
var $stop= '\\\}';
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
391
trunk/HTML/Template/Flexy/Compiler/Regex/SimpleTags.php
Normal file
391
trunk/HTML/Template/Flexy/Compiler/Regex/SimpleTags.php
Normal file
|
|
@ -0,0 +1,391 @@
|
|||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2003 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 2.02 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/2_02.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Alan Knowles <alan@akbkhome.com>
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* The Standard Tag filter
|
||||
*
|
||||
* @abstract
|
||||
* does all the clever stuff...
|
||||
*
|
||||
* Security Notes:
|
||||
* Templates should not originate from untrusted sources,
|
||||
* - the method(#.....#) could be regarded as insecure.
|
||||
* - there is no attempt to protect your from <script / <?php in templates.
|
||||
*
|
||||
* @package HTML_Template_Flexy
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
class HTML_Template_Flexy_Compiler_Regex_SimpleTags
|
||||
{
|
||||
/*
|
||||
* @var object HTML_Template_Flexy the main engine
|
||||
*/
|
||||
var $engine; // the engine (with options)
|
||||
/*
|
||||
* @var string $start the start tag for the template (escaped for regex)
|
||||
*/
|
||||
var $start = '\{';
|
||||
|
||||
/*
|
||||
* @var string $stop the stopt tag for the template (escaped for regex)
|
||||
*/
|
||||
var $stop = '\}';
|
||||
/*
|
||||
* @var string $error show/hide the PHP error messages on/off in templates
|
||||
*/
|
||||
var $error = "@"; // change to blank to debug errors.
|
||||
/**
|
||||
* Standard Set Engine
|
||||
*
|
||||
*
|
||||
* @param object HTML_Template_Flexy the main engine
|
||||
* @access private
|
||||
*/
|
||||
function _set_engine(&$engine) {
|
||||
$this->engine = &$engine;
|
||||
if ($this->engine->options['debug']) {
|
||||
$this->error = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Standard Variable replacement
|
||||
*
|
||||
*
|
||||
* Maps variables
|
||||
* {i.xyz} maps to <?php echo htmlspecialchars($i->xyz)?>
|
||||
* {i.xyz:h} maps to <?php echo $i->xyz?>
|
||||
* {i.xyz:u} maps to <?php echo urlencode($i->xyz)?>
|
||||
* {i.xyz:ru} maps to <?php echo rawurlencode($i->xyz)?>
|
||||
*
|
||||
* {i.xyz:r} maps to <PRE><?php echo print_r($i->xyz)?></PRE>
|
||||
* {i.xyz:n} maps to <?php echo nl2br(htmlspecialchars($i->xyz))?>
|
||||
*
|
||||
*
|
||||
* @param string $input the template
|
||||
* @return string the result of the filtering
|
||||
* @access public
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function variables ($input) {
|
||||
$input = preg_replace(
|
||||
"/".$this->start."([a-z0-9_.]+)".$this->stop."/ie",
|
||||
"'<?php echo htmlspecialchars(".$this->error."$'.str_replace('.','->','\\1').')?>'",
|
||||
$input);
|
||||
|
||||
|
||||
$input = preg_replace(
|
||||
"/".$this->start."([a-z0-9_.]+):h".$this->stop."/ie",
|
||||
"'<?php echo ".$this->error."$'.str_replace('.','->','\\1').'?>'",
|
||||
$input);
|
||||
|
||||
$input = preg_replace(
|
||||
"/".$this->start."([a-z0-9_.]+):u".$this->stop."/ie",
|
||||
"'<?php echo urlencode(".$this->error."$'.str_replace('.','->','\\1').')?>'",
|
||||
$input);
|
||||
|
||||
$input = preg_replace(
|
||||
"/".$this->start."([a-z0-9_.]+):ru".$this->stop."/ie",
|
||||
"'<?php echo rawurlencode(".$this->error."$'.str_replace('.','->','\\1').')?>'",
|
||||
$input);
|
||||
|
||||
$input = preg_replace(
|
||||
"/".$this->start."([a-z0-9_.]+):r".$this->stop."/ie",
|
||||
"'<PRE><?php echo print_r($'.str_replace('.','->','\\1').')?></PRE>'",
|
||||
$input);
|
||||
|
||||
$input = preg_replace(
|
||||
"/".$this->start."([a-z0-9_.]+):n".$this->stop."/ie",
|
||||
"'<?php echo nl2br(htmlspecialchars(".$this->error."$'.str_replace('.','->','\\1').'))?>'",
|
||||
$input);
|
||||
return $input;
|
||||
|
||||
}
|
||||
/**
|
||||
* Urlencoded Variable replacement
|
||||
*
|
||||
* Often when you use a WYSISYG editor, it replaces { in
|
||||
* the href="{somevar}" with the urlencoded version, this bit fixes it.
|
||||
*
|
||||
* Maps variables
|
||||
* %??i.xyz%?? maps to <?php echo htmlspecialchars($i->xyz)?>
|
||||
* %??i.xyz:h%?? maps to <?php echo $i->xyz?>
|
||||
* %??i.xyz:u%?? maps to <?php echo urlencode($i->xyz)?>
|
||||
* %??i.xyz:ru%?? maps to <?php echo urlencode($i->xyz)?>
|
||||
* THIS IS PROBABLY THE ONE TO USE!
|
||||
*
|
||||
* %??i.xyz:uu%?? maps to <?php echo urlencode(urlencode($i->xyz))?>
|
||||
*
|
||||
*
|
||||
* @param string $input the template
|
||||
* @return string the result of the filtering
|
||||
* @access public
|
||||
*/
|
||||
|
||||
function urlencoded_variables ($input) {
|
||||
$input = preg_replace(
|
||||
"/".urlencode(stripslashes($this->start))."([a-z0-9_.]+)".urlencode(stripslashes($this->stop))."/ie",
|
||||
"'<?php echo htmlspecialchars(".$this->error."$'.str_replace('.','->','\\1').')?>'",
|
||||
$input);
|
||||
|
||||
|
||||
$input = preg_replace(
|
||||
"/".urlencode(stripslashes($this->start))."([a-z0-9_.]+):h".urlencode(stripslashes($this->stop))."/ie",
|
||||
"'<?php echo ".$this->error."$'.str_replace('.','->','\\1').'?>'",
|
||||
$input);
|
||||
|
||||
$input = preg_replace(
|
||||
"/".urlencode(stripslashes($this->start))."([a-z0-9_.]+):u".urlencode(stripslashes($this->stop))."/ie",
|
||||
"'<?php echo urlencode(".$this->error."$'.str_replace('.','->','\\1').')?>'",
|
||||
$input);
|
||||
|
||||
$input = preg_replace(
|
||||
"/".urlencode(stripslashes($this->start))."([a-z0-9_.]+):uu".urlencode(stripslashes($this->stop))."/ie",
|
||||
"'<?php echo urlencode(urlencode(".$this->error."$'.str_replace('.','->','\\1').'))?>'",
|
||||
$input);
|
||||
return $input;
|
||||
}
|
||||
/**
|
||||
* Calling Methods
|
||||
*
|
||||
* This allows you to call methods of your application
|
||||
*
|
||||
* Maps Methods
|
||||
* {t.xxxx_xxxx()} maps to <?php echo htmlspecialchars($t->xxxx_xxxx())?>
|
||||
* {t.xxxx_xxxx():h} maps to <?php echo $t->xxxx_xxxx()?>
|
||||
*
|
||||
* {t.xxxx_xxxx(sssss.dddd)} maps to <?php echo htmlspecialchars($t->xxxx_xxxx($ssss->dddd))?>
|
||||
* {t.xxxx_xxxx(sssss.dddd):h} maps to <?php echo $t->xxxx_xxxx($ssss->dddd)?>
|
||||
* {t.xxxx_xxxx(sssss.dddd):s} maps to <?php highlight_string($t->xxxx_xxxx($ssss->dddd))?>
|
||||
*
|
||||
* {t.xxxx_xxxx(#XXXXX#)} maps to <?php echo htmlspecialchars($t->xxxx_xxxx('XXXXXX'))?>
|
||||
* {t.xxxx_xxxx(#XXXXX#):h} maps to <?php echo $t->xxxx_xxxx('XXXXXX')?>
|
||||
*
|
||||
* {t.xxxx_xxxx(sss.ddd,sss.ddd)} maps to <?php echo htmlspecialchars($t->xxxx_xxxx($sss->ddd,$sss->ddd))?>
|
||||
* {t.xxxx_xxxx(#aaaa#,sss.ddd)} maps to <?php echo htmlspecialchars($t->xxxx_xxxx("aaaa",$sss->ddd))?>
|
||||
* {t.xxxx_xxxx(sss.ddd,#aaaa#)} maps to <?php echo htmlspecialchars($t->xxxx_xxxx($sss->ddd,"aaaa"))?>
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param string $input the template
|
||||
* @return string the result of the filtering
|
||||
* @access public
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function methods($input) {
|
||||
|
||||
/* no vars */
|
||||
$input = preg_replace(
|
||||
"/".$this->start."([a-z0-9_.]+)\(\)".$this->stop."/ie",
|
||||
"'<?php echo htmlspecialchars(".$this->error."$'.str_replace('.','->','\\1').'())?>'",
|
||||
$input);
|
||||
|
||||
$input = preg_replace(
|
||||
"/".$this->start."([a-z0-9_.]+)\(\):h".$this->stop."/ie",
|
||||
"'<?php echo ".$this->error."$'.str_replace('.','->','\\1').'()?>'",
|
||||
$input);
|
||||
/* single vars */
|
||||
$input = preg_replace(
|
||||
"/".$this->start."([a-z0-9_.]+)\(([a-z0-9_.]+)\)".$this->stop."/ie",
|
||||
"'<?php echo htmlspecialchars(".$this->error."$'.str_replace('.','->','\\1').'($' . str_replace('.','->','\\2') . '))?>'",
|
||||
$input);
|
||||
|
||||
$input = preg_replace(
|
||||
"/".$this->start."([a-z0-9_.]+)\(([a-z0-9_.]+)\):h".$this->stop."/ie",
|
||||
"'<?php echo ".$this->error."$'.str_replace('.','->','\\1').'($' . str_replace('.','->','\\2') . ')?>'",
|
||||
$input);
|
||||
$input = preg_replace(
|
||||
"/".$this->start."([a-z0-9_.]+)\(([a-z0-9_.]+)\):s".$this->stop."/ie",
|
||||
"'<?php highlight_string($'.str_replace('.','->','\\1').'($' . str_replace('.','->','\\2') . '));?>'",
|
||||
$input);
|
||||
/* double vars */
|
||||
$input = preg_replace(
|
||||
"/".$this->start."([a-z0-9_.]+)\(([a-z0-9_.]+),([a-z0-9_.]+)\)".$this->stop."/ie",
|
||||
"'<?php echo htmlspecialchars(".$this->error."$'.str_replace('.','->','\\1').'($' . str_replace('.','->','\\2') . ',$' . str_replace('.','->','\\3') . '))?>'",
|
||||
$input);
|
||||
/* double vars:: # #'d ,var */
|
||||
$input = preg_replace(
|
||||
"/".$this->start."([a-z0-9_.]+)\(\#([^\#]+)\#,([a-z0-9_.]+)\)".$this->stop."/ie",
|
||||
"'<?php echo htmlspecialchars(".$this->error."$'.str_replace('.','->','\\1').'(\''. str_replace(\"'\",\"\\\'\",'\\2') . '\',$' . str_replace('.','->','\\3') . '))?>'",
|
||||
$input);
|
||||
/* double vars:: var , # #'d */
|
||||
$input = preg_replace(
|
||||
"/".$this->start."([a-z0-9_.]+)\(([a-z0-9_.]+),\#([^\#]+)\#\)".$this->stop."/ie",
|
||||
"'<?php echo htmlspecialchars(".$this->error."$'.str_replace('.','->','\\1').'($' . str_replace('.','->','\\2') . ',\''. str_replace(\"'\",\"\\\'\",'\\3') . '\'))?>'",
|
||||
$input);
|
||||
|
||||
/*strings or integers */
|
||||
$input = preg_replace(
|
||||
"/".$this->start."([a-z0-9_.]+)\(\#([^\#]+)\#\)".$this->stop."/ie",
|
||||
"'<?php echo htmlspecialchars(\$'.str_replace('.','->','\\1') . '(\''. str_replace(\"'\",\"\\\'\",'\\2') . '\'))?>'",
|
||||
$input);
|
||||
|
||||
$input = preg_replace(
|
||||
"/".$this->start."([a-z0-9_.]+)\(\#([^\#]+)\#\):h".$this->stop."/ie",
|
||||
"'<?php echo ".$this->error."$'.str_replace('.','->','\\1').'(\"' . str_replace(\"'\",\"\\\'\",'\\2') . '\")?>'",
|
||||
$input);
|
||||
|
||||
return $input;
|
||||
}
|
||||
/**
|
||||
* Looping
|
||||
*
|
||||
* This allows you to do loops on variables (eg. nested/ repeated blocks!)
|
||||
*
|
||||
* Maps Methods
|
||||
* {foreach:t.xyz,zzz} maps to <?php if ($i->xyz) foreach ($t->xyz as $zzz) { ?>
|
||||
* {foreach:t.xyz,xxx,zzz} maps to <?php if ($i->xyz) foreach ($t->xyz as $xxx=>$zzz) { ?>
|
||||
* {end:} maps to <?php }?>
|
||||
* {else:} maps to <?php }else{?>
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param string $input the template
|
||||
* @return string the result of the filtering
|
||||
* @access public
|
||||
*/
|
||||
|
||||
|
||||
function looping($input) {
|
||||
|
||||
|
||||
$input = preg_replace(
|
||||
"/".$this->start."foreach:([a-z0-9_.]+),([a-z0-9_.]+)".$this->stop."/ie",
|
||||
"'<?php if (".$this->error."$' . str_replace('.','->','\\1') . ') foreach( $' . str_replace('.','->','\\1') . ' as $' . str_replace('.','->','\\2') . ') { ?>'",
|
||||
$input);
|
||||
$input = preg_replace(
|
||||
"/".$this->start."foreach:([a-z0-9_.]+),([a-z0-9_.]+),([a-z0-9_.]+)".$this->stop."/ie",
|
||||
"'<?php if (".$this->error."$' . str_replace('.','->','\\1') . ') foreach( $' . str_replace('.','->','\\1') . ' as $' . str_replace('.','->','\\2') . '=>$' . str_replace('.','->','\\3') .') { ?>'",
|
||||
$input);
|
||||
|
||||
$input = str_replace(stripslashes($this->start)."else:".stripslashes($this->stop),'<?php }else{?>', $input);
|
||||
$input = str_replace(stripslashes($this->start)."end:".stripslashes($this->stop),'<?php }?>', $input);
|
||||
return $input;
|
||||
}
|
||||
/**
|
||||
* Conditional inclusion
|
||||
*
|
||||
* This allows you to do conditional inclusion (eg. blocks!)
|
||||
*
|
||||
* Maps conditions
|
||||
*
|
||||
* {if:t.xxxx} => <?php if ($t->xxxx) { ?>
|
||||
* {if:t.x_xxx()} => <?php if ($t->x_xxx()) { ?>
|
||||
*
|
||||
* @param string $input the template
|
||||
* @return string the result of the filtering
|
||||
* @access public
|
||||
*/
|
||||
|
||||
function conditionals($input) {
|
||||
|
||||
$input = preg_replace(
|
||||
"/".$this->start."if:([a-z0-9_.]+)".$this->stop."/ie",
|
||||
"'<?php if (".$this->error."$' . str_replace('.','->','\\1') . ') { ?>'",
|
||||
$input);
|
||||
|
||||
$input = preg_replace(
|
||||
"/".$this->start."if:([a-z0-9_.]+)\(\)".$this->stop."/ie",
|
||||
"'<?php if (".$this->error."$' . str_replace('.','->','\\1') . '()) { ?>'",
|
||||
$input);
|
||||
|
||||
return $input;
|
||||
}
|
||||
/**
|
||||
* sub template inclusion
|
||||
*
|
||||
* This allows you to do include other files (either flat or generated templates.).
|
||||
*
|
||||
* {include:t.abcdef} maps to <?php
|
||||
* if($t->abcdef && file_exists($compileDir . "/". $t->abcdef . "en.php"))
|
||||
* include($compileDir . "/". $t->abcdef . ".en.php");
|
||||
* ?>
|
||||
*
|
||||
* include abcdef.en.php (Eg. hard coded compiled template
|
||||
* {include:#abcdef#} => <?php
|
||||
* if(file_exists($compileDir . "/abcdef.en.php"))
|
||||
* include($compileDir . "/abcdef.en.php");
|
||||
* ?>
|
||||
*
|
||||
* include raw
|
||||
* {t_include:#abcdef.html#} => <?php
|
||||
* if(file_exists($templateDir . "/abcdef.html"))
|
||||
* include($compileDir . "/abcdef.html");
|
||||
* ?>
|
||||
* Compile and include
|
||||
* {q_include:#abcdef.html#} => <?php
|
||||
* HTML_Template_Flexy::staticQuickTemplate('abcedef.html',$t);
|
||||
* ?>
|
||||
*
|
||||
*
|
||||
* @param string $input the template
|
||||
* @return string the result of the filtering
|
||||
* @access public
|
||||
*/
|
||||
|
||||
function include_template($input) {
|
||||
|
||||
$input = preg_replace(
|
||||
"/".$this->start."include:([a-z0-9_.]+)".$this->stop."/ie",
|
||||
"'<?php
|
||||
if ((".$this->error."$' . str_replace('.','->','\\1') . ') &&
|
||||
file_exists(\"" . $this->engine->options['compileDir'] .
|
||||
"/\{$' . str_replace('.','->','\\1') . '}.en.php\"))
|
||||
include(\"" . $this->engine->options['compileDir'] .
|
||||
"/\{$' . str_replace('.','->','\\1') . '}.en.php\");?>'",
|
||||
$input);
|
||||
|
||||
$input = preg_replace(
|
||||
"/".$this->start."include:#([a-z0-9_.]+)#".$this->stop."/ie",
|
||||
"'<?php if (file_exists(\"" . $this->engine->options['compileDir'] . "/\\1.en.php\")) include(\"" .
|
||||
$this->engine->options['compileDir'] . "/\\1.en.php\");?>'",
|
||||
$input);
|
||||
|
||||
$input = preg_replace(
|
||||
"/".$this->start."t_include:#([a-z0-9_.]+)#".$this->stop."/ie",
|
||||
"'<?php if (file_exists(\"" . $this->engine->options['templateDir'] .
|
||||
"/\\1\")) include(\"" . $this->engine->options['templateDir'] . "/\\1\");?>'",
|
||||
$input);
|
||||
|
||||
$input = preg_replace(
|
||||
"/".$this->start."q_include:#([a-z0-9_.]+)#".$this->stop."/ie",
|
||||
"'<?php HTML_Template_Flexy::staticQuickTemplate(\"\\1\",\$t); ?>'",
|
||||
$input);
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
58
trunk/HTML/Template/Flexy/Compiler/Regex/Xml.php
Normal file
58
trunk/HTML/Template/Flexy/Compiler/Regex/Xml.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2003 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 2.02 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/2_02.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Alan Knowles <alan@akbkhome.com>
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* Replace XML tags with echo '<' .'?xml';
|
||||
*
|
||||
|
||||
* @package HTML_Template_Flexy
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
class HTML_Template_Flexy_Compiler_Regex_Xml
|
||||
{
|
||||
/**
|
||||
* Standard Set Engine
|
||||
*
|
||||
*
|
||||
* @param object HTML_Template_Flexy the main engine
|
||||
* @access private
|
||||
*/
|
||||
function _set_engine(&$engine)
|
||||
{
|
||||
}
|
||||
/*
|
||||
* replace the xml tags
|
||||
*
|
||||
* @param string The template
|
||||
* @access public
|
||||
*/
|
||||
function pre_replace_xml ($input)
|
||||
{
|
||||
$input = str_replace("?>","<?php echo '?'.'>'; ?>\n",$input);
|
||||
$input = str_replace("<?xml","<?php echo '<'.'?xml'; ?>",$input);
|
||||
return $input;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue