|
From: <ru...@us...> - 2010-06-10 07:11:02
|
Revision: 7517
http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7517&view=rev
Author: rurban
Date: 2010-06-10 07:10:56 +0000 (Thu, 10 Jun 2010)
Log Message:
-----------
linebreak
Modified Paths:
--------------
trunk/lib/Template.php
Modified: trunk/lib/Template.php
===================================================================
--- trunk/lib/Template.php 2010-06-10 06:53:11 UTC (rev 7516)
+++ trunk/lib/Template.php 2010-06-10 07:10:56 UTC (rev 7517)
@@ -197,7 +197,8 @@
; //return $error;
}
elseif (strstr($error->errfile, "In template '")) { // merge
- $error->errfile = preg_replace("/'(\w+)'\)$/", "'\\1' < '$this->_name')", $error->errfile);
+ $error->errfile = preg_replace("/'(\w+)'\)$/", "'\\1' < '$this->_name')",
+ $error->errfile);
}
else {
$error->errfile .= " (In template '$this->_name')";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <var...@us...> - 2010-07-02 08:24:34
|
Revision: 7592
http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7592&view=rev
Author: vargenau
Date: 2010-07-02 08:24:28 +0000 (Fri, 02 Jul 2010)
Log Message:
-----------
Add rule for <?php echo
Modified Paths:
--------------
trunk/lib/Template.php
Modified: trunk/lib/Template.php
===================================================================
--- trunk/lib/Template.php 2010-07-02 08:05:07 UTC (rev 7591)
+++ trunk/lib/Template.php 2010-07-02 08:24:28 UTC (rev 7592)
@@ -61,6 +61,10 @@
$orig[] = '/<\?=(.*?)\?>/s';
$repl[] = '<?php $this->_print(\1);?>';
+ // Convert < ?php echo expr ? > to < ?php $this->_print(expr); ? >
+ $orig[] = '/<\?php echo (.*?)\?>/s';
+ $repl[] = '<?php $this->_print(\1);?>';
+
return preg_replace($orig, $repl, $template);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <var...@us...> - 2014-06-05 16:02:32
|
Revision: 8875
http://sourceforge.net/p/phpwiki/code/8875
Author: vargenau
Date: 2014-06-05 16:02:24 +0000 (Thu, 05 Jun 2014)
Log Message:
-----------
Update PHP Doc
Modified Paths:
--------------
trunk/lib/Template.php
Modified: trunk/lib/Template.php
===================================================================
--- trunk/lib/Template.php 2014-06-04 16:39:11 UTC (rev 8874)
+++ trunk/lib/Template.php 2014-06-05 16:02:24 UTC (rev 8875)
@@ -117,14 +117,11 @@
* Substitute HTML replacement text for tokens in template.
*
* Constructs a new WikiTemplate based upon the named template.
- *
* @access public
- *
- * @param $token string Name of token to substitute for.
- *
- * @param $replacement string Replacement HTML text.
+ * @param string $varname Name of token to substitute for.
+ * @param string $value Replacement HTML text.
*/
- function replace($varname, $value)
+ public function replace($varname, $value)
{
$this->_locals[$varname] = $value;
}
@@ -246,14 +243,14 @@
* Make and expand the top-level template.
*
*
- * @param $content mixed html content to put into the page
- * @param $title string page title
- * @param $page_revision object A WikiDB_PageRevision object or false
- * @param $args hash Extract args for top-level template
+ * @param mixed $content html content to put into the page
+ * @param string $title page title
+ * @param object|bool $page_revision A WikiDB_PageRevision object or false
+ * @param array $args hash Extract args for top-level template
*
* @return string HTML expansion of template.
*/
-function GeneratePage($content, $title, $page_revision = false, $args = false)
+function GeneratePage($content, $title, $page_revision = false, $args = array())
{
global $request;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <var...@us...> - 2014-06-05 16:23:30
|
Revision: 8876
http://sourceforge.net/p/phpwiki/code/8876
Author: vargenau
Date: 2014-06-05 16:23:23 +0000 (Thu, 05 Jun 2014)
Log Message:
-----------
Fix types
Modified Paths:
--------------
trunk/lib/Template.php
Modified: trunk/lib/Template.php
===================================================================
--- trunk/lib/Template.php 2014-06-05 16:02:24 UTC (rev 8875)
+++ trunk/lib/Template.php 2014-06-05 16:23:23 UTC (rev 8876)
@@ -9,7 +9,7 @@
/**
* name optionally of form "theme/template" to include parent templates in children
*/
- function Template($name, &$request, $args = false)
+ function Template($name, &$request, $args = array())
{
global $WikiTheme;
@@ -227,7 +227,7 @@
* new Template(...)
* </pre>
*/
-function Template($name, $args = false)
+function Template($name, $args = array())
{
global $request;
return new Template($name, $request, $args);
@@ -271,7 +271,7 @@
* For dumping pages as html to a file.
* Used for action=dumphtml,action=ziphtml,format=pdf,format=xml
*/
-function GeneratePageasXML($content, $title, $page_revision = false, $args = false)
+function GeneratePageasXML($content, $title, $page_revision = false, $args = array())
{
global $request;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <var...@us...> - 2014-06-05 16:33:27
|
Revision: 8877
http://sourceforge.net/p/phpwiki/code/8877
Author: vargenau
Date: 2014-06-05 16:33:24 +0000 (Thu, 05 Jun 2014)
Log Message:
-----------
Add methods visibility
Modified Paths:
--------------
trunk/lib/Template.php
Modified: trunk/lib/Template.php
===================================================================
--- trunk/lib/Template.php 2014-06-05 16:23:23 UTC (rev 8876)
+++ trunk/lib/Template.php 2014-06-05 16:33:24 UTC (rev 8877)
@@ -49,7 +49,7 @@
$this->_locals = array();
}
- function _munge_input($template)
+ private function _munge_input($template)
{
// Convert < ?plugin expr ? > to < ?php $this->_printPluginPI("expr"); ? >
@@ -67,7 +67,7 @@
return preg_replace($orig, $repl, $template);
}
- function _mungePlugin($pi)
+ private function _mungePlugin($pi)
{
// HACK ALERT: PHP's preg_replace, with the /e option seems to
// escape both single and double quotes with backslashes.
@@ -78,7 +78,7 @@
"'" . str_replace("'", "\'", $pi) . "'");
}
- function _printPlugin($pi)
+ private function _printPlugin($pi)
{
include_once 'lib/WikiPlugin.php';
static $loader;
@@ -89,7 +89,7 @@
$this->_print($loader->expandPI($pi, $this->_request, $this, $this->_basepage));
}
- function _print($val)
+ private function _print($val)
{
if (isa($val, 'Template')) {
$this->_expandSubtemplate($val);
@@ -98,7 +98,7 @@
}
}
- function _expandSubtemplate(&$template)
+ private function _expandSubtemplate(&$template)
{
// FIXME: big hack!
//if (!$template->_request)
@@ -126,7 +126,7 @@
$this->_locals[$varname] = $value;
}
- function printExpansion($defaults = false)
+ public function printExpansion($defaults = false)
{
if (!is_array($defaults)) // HTML object or template object
$defaults = array('CONTENT' => $defaults);
@@ -158,7 +158,7 @@
// Find a way to do template expansion less memory intensive and faster.
// 1.3.4 needed no memory at all for dumphtml, now it needs +15MB.
// Smarty? As before?
- function getExpansion($defaults = false)
+ public function getExpansion($defaults = false)
{
ob_start();
$this->printExpansion($defaults);
@@ -167,18 +167,18 @@
return $xml;
}
- function printXML()
+ public function printXML()
{
$this->printExpansion();
}
- function asXML()
+ public function asXML()
{
return $this->getExpansion();
}
// Debugging:
- function _dump_template()
+ private function _dump_template()
{
$lines = explode("\n", $this->_munge_input($this->_tmpl));
$pre = HTML::pre();
@@ -188,7 +188,7 @@
$pre->printXML();
}
- function _errorHandler($error)
+ private function _errorHandler($error)
{
//if (!preg_match('/: eval\(\)\'d code$/', $error->errfile))
// return false;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <var...@us...> - 2014-06-06 15:08:37
|
Revision: 8878
http://sourceforge.net/p/phpwiki/code/8878
Author: vargenau
Date: 2014-06-06 15:08:35 +0000 (Fri, 06 Jun 2014)
Log Message:
-----------
_errorHandler is public :-(
Modified Paths:
--------------
trunk/lib/Template.php
Modified: trunk/lib/Template.php
===================================================================
--- trunk/lib/Template.php 2014-06-05 16:33:24 UTC (rev 8877)
+++ trunk/lib/Template.php 2014-06-06 15:08:35 UTC (rev 8878)
@@ -188,7 +188,7 @@
$pre->printXML();
}
- private function _errorHandler($error)
+ public function _errorHandler($error)
{
//if (!preg_match('/: eval\(\)\'d code$/', $error->errfile))
// return false;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <var...@us...> - 2014-06-26 16:55:48
|
Revision: 8942
http://sourceforge.net/p/phpwiki/code/8942
Author: vargenau
Date: 2014-06-26 16:55:40 +0000 (Thu, 26 Jun 2014)
Log Message:
-----------
Avoid PHP 5.5 warning about /e
Modified Paths:
--------------
trunk/lib/Template.php
Modified: trunk/lib/Template.php
===================================================================
--- trunk/lib/Template.php 2014-06-26 10:07:29 UTC (rev 8941)
+++ trunk/lib/Template.php 2014-06-26 16:55:40 UTC (rev 8942)
@@ -64,7 +64,8 @@
$orig[] = '/<\?php echo (.*?)\?>/s';
$repl[] = '<?php $this->_print(\1);?>';
- return preg_replace($orig, $repl, $template);
+ // Avoid PHP 5.5 warning about /e
+ return @preg_replace($orig, $repl, $template);
}
private function _mungePlugin($pi)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <var...@us...> - 2014-12-08 17:14:23
|
Revision: 9432
http://sourceforge.net/p/phpwiki/code/9432
Author: vargenau
Date: 2014-12-08 17:14:15 +0000 (Mon, 08 Dec 2014)
Log Message:
-----------
Type compatibility
Modified Paths:
--------------
trunk/lib/Template.php
Modified: trunk/lib/Template.php
===================================================================
--- trunk/lib/Template.php 2014-12-08 14:31:53 UTC (rev 9431)
+++ trunk/lib/Template.php 2014-12-08 17:14:15 UTC (rev 9432)
@@ -273,7 +273,7 @@
* For dumping pages as html to a file.
* Used for action=dumphtml,action=ziphtml,format=pdf,format=xml
*/
-function GeneratePageasXML($content, $title, $page_revision = false, $args = array())
+function GeneratePageasXML($content, $title, $page_revision = null, $args = array())
{
global $request;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <var...@us...> - 2016-07-11 12:55:54
|
Revision: 9872
http://sourceforge.net/p/phpwiki/code/9872
Author: vargenau
Date: 2016-07-11 12:55:52 +0000 (Mon, 11 Jul 2016)
Log Message:
-----------
Template: use __construct
Modified Paths:
--------------
trunk/lib/Template.php
Modified: trunk/lib/Template.php
===================================================================
--- trunk/lib/Template.php 2016-07-10 16:57:34 UTC (rev 9871)
+++ trunk/lib/Template.php 2016-07-11 12:55:52 UTC (rev 9872)
@@ -13,7 +13,7 @@
* @param WikiRequest $request
* @param array $args
*/
- function Template($name, &$request, $args = array())
+ function __construct($name, &$request, $args = array())
{
global $WikiTheme;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <var...@us...> - 2022-01-13 16:08:31
|
Revision: 10895
http://sourceforge.net/p/phpwiki/code/10895
Author: vargenau
Date: 2022-01-13 16:08:30 +0000 (Thu, 13 Jan 2022)
Log Message:
-----------
check arguments for array_merge
Modified Paths:
--------------
trunk/lib/Template.php
Modified: trunk/lib/Template.php
===================================================================
--- trunk/lib/Template.php 2022-01-13 15:16:42 UTC (rev 10894)
+++ trunk/lib/Template.php 2022-01-13 16:08:30 UTC (rev 10895)
@@ -144,7 +144,11 @@
{
if (!is_array($defaults)) // HTML object or template object
$defaults = array('CONTENT' => $defaults);
- $this->_vars = array_merge($defaults, $this->_locals);
+ if (is_array($this->_locals)) {
+ $this->_vars = array_merge($defaults, $this->_locals);
+ } else {
+ $this->_vars = $defaults;
+ }
extract($this->_vars);
global $request;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <var...@us...> - 2022-02-01 08:45:46
|
Revision: 10965
http://sourceforge.net/p/phpwiki/code/10965
Author: vargenau
Date: 2022-02-01 08:45:44 +0000 (Tue, 01 Feb 2022)
Log Message:
-----------
Avoid fatal error when errline=?
Modified Paths:
--------------
trunk/lib/Template.php
Modified: trunk/lib/Template.php
===================================================================
--- trunk/lib/Template.php 2022-01-31 18:50:36 UTC (rev 10964)
+++ trunk/lib/Template.php 2022-02-01 08:45:44 UTC (rev 10965)
@@ -212,18 +212,12 @@
} else {
$error->errfile .= " (In template '$this->_name')";
}
-
- if (!empty($this->_tmpl)) {
- $lines = explode("\n", $this->_tmpl);
- if (isset($lines[$error->errline - 1]))
- $error->errstr .= ":\n\t" . $lines[$error->errline - 1];
- }
return $error;
}
}
/**
- * Get a templates
+ * Get a template
*
* This is a convenience function and is equivalent to:
* <pre>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <var...@us...> - 2016-10-13 12:56:40
|
Revision: 9962
http://sourceforge.net/p/phpwiki/code/9962
Author: vargenau
Date: 2016-10-13 12:56:38 +0000 (Thu, 13 Oct 2016)
Log Message:
-----------
Do not use preg_replace with /e to be compatible with PHP 7
Modified Paths:
--------------
trunk/lib/Template.php
Modified: trunk/lib/Template.php
===================================================================
--- trunk/lib/Template.php 2016-10-13 12:55:27 UTC (rev 9961)
+++ trunk/lib/Template.php 2016-10-13 12:56:38 UTC (rev 9962)
@@ -79,41 +79,21 @@
private function _munge_input($template)
{
+ // Convert < ?plugin expr ? > to < ?php $this->_printPlugin("expr"); ? >
+ $orig[] = '/<\?plugin.*?\?>/s';
+ $repl[] = "<?php \$this->_printPlugin('\\0'); ?>";
- // Convert < ?plugin expr ? > to < ?php $this->_printPluginPI("expr"); ? >
- $orig[] = '/<\?plugin.*?\?>/se';
- $repl[] = "\$this->_mungePlugin('\\0')";
+ // Convert <<expr>> to < ?php $this->_printPlugin("expr"); ? >
+ $orig[] = '/<<(.*?)>>/s';
+ $repl[] = "<?php \$this->_printPlugin('<?plugin \\1 ?>'); ?>";
- // Convert <<expr>> to < ?php $this->_printPluginPI("expr"); ? >
- $orig[] = '/<<.*?>>/se';
- $repl[] = "\$this->_mungePlugin('\\0')";
-
- // Convert < ?= expr ? > to < ?php $this->_print(expr); ? >
- $orig[] = '/<\?=(.*?)\?>/s';
- $repl[] = '<?php $this->_print(\1);?>';
-
// Convert < ?php echo expr ? > to < ?php $this->_print(expr); ? >
$orig[] = '/<\?php echo (.*?)\?>/s';
$repl[] = '<?php $this->_print(\1);?>';
- // Avoid PHP 5.5 warning about /e
- return @preg_replace($orig, $repl, $template);
+ return preg_replace($orig, $repl, $template);
}
- private function _mungePlugin($pi)
- {
- $pi = preg_replace('/^<</', '<?plugin ', $pi);
- $pi = preg_replace('/>>$/', ' ?>', $pi);
-
- // HACK ALERT: PHP's preg_replace, with the /e option seems to
- // escape both single and double quotes with backslashes.
- // So we need to unescape the double quotes here...
-
- $pi = preg_replace('/(?!<\\\\)\\\\"/x', '"', $pi);
- return sprintf('<?php $this->_printPlugin(%s); ?>',
- "'" . str_replace("'", "\'", $pi) . "'");
- }
-
private function _printPlugin($pi)
{
include_once 'lib/WikiPlugin.php';
@@ -136,9 +116,6 @@
private function _expandSubtemplate(&$template)
{
- // FIXME: big hack!
- //if (!$template->_request)
- // $template->_request = &$this->_request;
if (DEBUG) {
echo "<!-- Begin $template->_name -->\n";
}
@@ -178,7 +155,6 @@
$revision = false;
global $WikiTheme;
- //$this->_dump_template();
$SEP = $WikiTheme->getButtonSeparator();
global $ErrorManager;
@@ -212,22 +188,8 @@
return $this->getExpansion();
}
- // Debugging:
- private function _dump_template()
- {
- $lines = explode("\n", $this->_munge_input($this->_tmpl));
- $pre = HTML::pre();
- $n = 1;
- foreach ($lines as $line)
- $pre->pushContent(fmt("%4d %s\n", $n++, $line));
- $pre->printXML();
- }
-
public function _errorHandler($error)
{
- //if (!preg_match('/: eval\(\)\'d code$/', $error->errfile))
- // return false;
-
if (preg_match('/: eval\(\)\'d code$/', $error->errfile)) {
$error->errfile = "In template '$this->_name'";
// Hack alert: Ignore 'undefined variable' messages for variables
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <var...@us...> - 2022-01-01 13:06:09
|
Revision: 10803
http://sourceforge.net/p/phpwiki/code/10803
Author: vargenau
Date: 2022-01-01 13:06:07 +0000 (Sat, 01 Jan 2022)
Log Message:
-----------
Add {}
Modified Paths:
--------------
trunk/lib/Template.php
Modified: trunk/lib/Template.php
===================================================================
--- trunk/lib/Template.php 2021-12-30 09:44:07 UTC (rev 10802)
+++ trunk/lib/Template.php 2022-01-01 13:06:07 UTC (rev 10803)
@@ -70,11 +70,13 @@
$this->_tmpl = fread($fp, filesize($file));
if ($fp) fclose($fp);
//$userid = $request->_user->_userid;
- if (is_array($args))
+ if (is_array($args)) {
$this->_locals = $args;
- elseif ($args)
- $this->_locals = array('CONTENT' => $args); else
+ } elseif ($args) {
+ $this->_locals = array('CONTENT' => $args);
+ } else {
$this->_locals = array();
+ }
}
private function _munge_input($template)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|