|
From: Hinrich D. <hd...@us...> - 2002-06-09 22:46:59
|
Update of /cvsroot/post-nuke/postnuke_official/html/includes
In directory usw-pr-cvs1:/tmp/cvs-serv7328
Modified Files:
pnTemplate.php
Log Message:
- dummy cvs sync
Index: pnTemplate.php
===================================================================
RCS file: /cvsroot/post-nuke/postnuke_official/html/includes/pnTemplate.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pnTemplate.php 26 May 2002 21:46:01 -0000 1.1
--- pnTemplate.php 9 Jun 2002 22:46:56 -0000 1.2
***************
*** 107,114 ****
// handle logic separately, it's a special case
! $search = '!<pn:logic\s+(.*?)>!se';
! $replace = 'pnTemplateLogic(\'$1\');';
$page = preg_replace($search, $replace, $page);
! $page = str_replace('</pn:logic>', '<?php } ?>', $page);
// handle sec separately, it's another special case
--- 107,114 ----
// handle logic separately, it's a special case
! $search = '!<pn:(logic|loop)\s+(.*?)>!se';
! $replace = 'pnTemplate$1(\'$2\');';
$page = preg_replace($search, $replace, $page);
! $page = str_replace(array('</pn:logic>', '</pn:loop>'), '<?php } ?>', $page);
// handle sec separately, it's another special case
***************
*** 155,171 ****
}
! if (!isset($id)) {
pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNKNOWN',
! new SystemException(__FILE__.'('.__LINE__.'): Missing \'id\' attribute in <pn:var> tag.'));
return;
}
if (isset($scope)) {
if (!strcasecmp($scope, 'config')) {
! return '<?php echo pnConfigGetVar(\'' . $id . '\'); ?>';
}
}
! return '<?php echo $'.$id.'; ?>';
}
--- 155,175 ----
}
! if (!isset($name)) {
pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNKNOWN',
! new SystemException(__FILE__.'('.__LINE__.'): Missing \'name\' attribute in <pn:var> tag.'));
return;
}
+ // convert foo.bar.baz to foo['bar']['baz']
+ // if (strchr($name, '.'))
+ $name = convert_array_style($name);
+
if (isset($scope)) {
if (!strcasecmp($scope, 'config')) {
! return '<?php echo pnConfigGetVar(\'' . $name . '\'); ?>';
}
}
! return '<?php echo $'.$name.'; ?>';
}
***************
*** 255,258 ****
--- 259,294 ----
/**
+ * replace <pn:loop> tags with PHP code
+ *
+ * @param args the attributes section of the <pn:loop> tag
+ * @return The PHP code to substitute in
+ * @access private
+ */
+ function pnTemplateLoop($args)
+ {
+ $args = stripslashes($args);
+ // Break out args into name="value" pairs
+ preg_match_all('!\s*(\S*)\s*=\s*"(.*?[^\\\])"!s', $args, $fargs);
+
+ // Set values in local namespace
+ for ($i = 0; $i < count($fargs[1]); $i++) {
+ $var = $fargs[1][$i];
+ $$var = stripslashes($fargs[2][$i]);
+ }
+
+ if (!isset($name)) {
+ pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNKNOWN',
+ new SystemException(__FILE__.'('.__LINE__.'): Missing \'name\' attribute in <pn:loop> tag.'));
+ return;
+ }
+
+ if (isset($key)) {
+ return "<?php \$_pass = 0; foreach ($$name as \$_item) { extract(\$_item, EXTR_OVERWRITE); \$_pass++; $$key = \$_pass; ?>";
+ }
+
+ return "<?php foreach ($$name as \$_item) { extract(\$_item, EXTR_OVERWRITE); ?>";
+ }
+
+ /**
* replace <pn:error> tags with PHP code
*
***************
*** 348,352 ****
*/
! if (!isset($id) || trim($id) == '') {
//return 'Error: block ID not specified';
}
--- 384,388 ----
*/
! if (!isset($name) || trim($name) == '') {
//return 'Error: block ID not specified';
}
***************
*** 373,377 ****
return "<?php echo pnBlockShow('$module',
! '$id',
array('title' => '".addslashes($title)."',
'content' => '$content',
--- 409,413 ----
return "<?php echo pnBlockShow('$module',
! '$name',
array('title' => '".addslashes($title)."',
'content' => '$content',
***************
*** 441,444 ****
--- 477,486 ----
$template_file = "modules/$module/templates/$type-$func.pnd";
+ $template_sourcefile = "modules/$module/templates/$type-$func.pnt";
+
+ if (isset($regenerate) && file_exists($template_sourcefile)) {
+ pnTemplateCompile($template_sourcefile, $template_file);
+ }
+
if (!file_exists($template_file)) {
pnExceptionSet(PN_SYSTEM_EXCEPTION, 'UNKNOWN',
***************
*** 473,476 ****
--- 515,530 ----
}
+ function convert_array_style($var)
+ {
+ $var = explode('.', $var);
+ $new_var = $var[0];
+
+ for ($i = 1; $i < count($var); $i++) {
+ $new_var .= '[\''.$var[$i].'\']';
+ }
+
+ return $new_var;
+ }
+
function themesidebox($title, $content, $blockinfo = array())
{
***************
*** 503,542 ****
}
- include $template_file;
- }
-
- function themeindex ($_deprecated, $_deprecated, $_deprecated, $_deprecated, $_deprecated, $_deprecated, $_deprecated, $_deprecated, $_deprecated, $_deprecated, $_deprecated, $_deprecated, $info, $links, $preformat) {
- global $thename, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $sepcolor;
- $anonymous = pnConfigGetVar('anonymous');
- $tipath = pnConfigGetVar('tipath');
-
- global $regenerate;
- $theme = pnUserGetTheme();
-
- if (isset($blockinfo['template'])) {
- $template = $blockinfo['template'];
- } else {
- $template = 'default';
- }
- $template = 'default';
- // Load page
- $template_file = "templates/$theme/modules/News/$template.pnc";
- if (!file_exists($template_file) || isset($regenerate) && $regenerate == true) {
- $template_sourcefile = "templates/$theme/modules/News/$template.pnt";
- if (!file_exists($template_sourcefile)) {
- if ($template != 'default') {
- $blockinfo['template'] = 'default';
- //return ($title, $content, $blockinfo);
- }
- echo "Could not locate block template '$template'";
- exit;
- }
-
- if (!pnTemplateCompile($template_sourcefile, $template_file)) {
- echo 'Error compiling template';
- exit;
- }
- }
-
include $template_file;
}
--- 557,560 ----
|