Deprecated: Assigning the return value of new by reference is deprecated in /home/bluestat/public_html/source/index.php on line 477
Kalens - Blob - ViewGit - Blue Static
<?php
/*=====================================================================*\
|| ###################################################################
|| # Kalens [#]version[#]
|| # Copyright ©2002-[#]year[#] Iris Studios, Inc.
|| #
|| # This program is free software; you can redistribute it and/or modify
|| # it under the terms of the GNU General Public License as published by
|| # the Free Software Foundation; version [#]gpl[#] of the License.
|| #
|| # This program is distributed in the hope that it will be useful, but
|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|| # more details.
|| #
|| # You should have received a copy of the GNU General Public License along
|| # with this program; if not, write to the Free Software Foundation, Inc.,
|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|| ###################################################################
\*=====================================================================*/


chdir('./../admin/');

require_once('./global.php');

$print->page_start('Template Variable Usage');

// ###################################################################

$templates = $db->query("SELECT * FROM template WHERE styleid = -1 ORDER BY templatename ASC");
while ($template = $db->fetch_array($templates))
{
	$templateusage["$template[templateid]"] = $template['templatename'];
}

$select = '<select name="templateid">';
foreach ($templateusage AS $templateid => $templatename)
{
	$select .= "\n\t<option value=\"$templateid\"" . ($_REQUEST['templateid'] == $templateid ? ' selected="selected"' : '') . ">$templatename</option>";
}
$select .= '</select>';

echo "<form name=\"tplselect\" action=\"template_var_usage.php\" method=\"get\"><p align=\"center\">$select <input type=\"submit\" name=\"go\" value=\"Select\" /></p></form>";

// ###################################################################

if ($_REQUEST['templateid'])
{
	$print->table_start();

	$tpl = $db->query_first("SELECT * FROM template WHERE templateid = " . intval($_REQUEST['templateid']));

	$print->table_head("Template: $tpl[templatename]; Style: Master; Id: $tpl[templateid]");

	$tpl['template'] = htmlspecialchars($tpl['template']);

	// convert tabs
	$tpl['template'] = str_replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;', $tpl['template']);

	// handle lang sprints
	preg_match_all('#&lt;lang(.*?)&lt;/lang&gt;#', $tpl['template'], $matches);
	foreach ((array)$matches[0] AS $match)
	{
		$tpl['template'] = str_replace($match, '<span style="color:green; background:#EEEEEE">' . $match . '</span>', $tpl['template']);
	}

	// handle variables
	preg_match_all('#\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff\'\[\]"]*#', $tpl['template'], $matches);
	foreach ((array)$matches[0] AS $match)
	{
		$tpl['template'] = str_replace($match, '<span style="color:red; background:#EEEEEE">' . $match . '</span>', $tpl['template']);
		$varlist['PHP Variables'][] = $match;
	}

	// language objects
	preg_match_all('#\{@(&quot;|")(\w+?)\1\}#is', $tpl['template'], $matches);
	foreach ((array)$matches[0] AS $id => $match)
	{
		$tpl['template'] = str_replace($match, '<span style="color:blue; background:#EEEEEE">' . $match . '</span>', $tpl['template']);
		$varlist['Language Objects'][] = '<strong>' . $matches[2]["$id"] . '</strong>';
	}

	//$tpl['template'] = preg_replace('#&lt;lang(.*?)&lt;/lang&gt;#', '<span style="color:green; background:#EEEEEE">&lt;lang\\1&lt;/lang&gt;</span>', $tpl['template']);
	//$tpl['template'] = preg_replace('#\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff\[\]]*)#', '<span style="color:red; background:#EEEEEE">$\\1</span>', $tpl['template']);
	//$tpl['template'] = preg_replace('#\{lang\.(\w+?)\}#is', '<span style="color:blue; background:#EEEEEE">{lang.\\1}</span>', $tpl['template']);


	$print->row_span('<div style="width:100%; height:100%; background:white; color:#000000; font-family:courier; border:1px solid">' . nl2br($tpl['template']) . '</div>');

	$print->table_head('Match List');

	foreach ((array)$varlist AS $type => $matchlist)
	{
		$print->row_span($type, 'thead');
		foreach ((array)$matchlist AS $variable)
		{
			$print->row_span($variable);
		}
	}

	$print->table_end();
}

$print->page_end();

/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>