mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-29 06:38:52 +00:00
New template system. Lots of merging conflicts, so let nate know if he broke stuff.
git-svn-id: file:///svn/phpbb/trunk@105 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
b1ce902c02
commit
40f1f172a8
12 changed files with 476 additions and 438 deletions
|
@ -30,7 +30,7 @@ $user_ip = ($HTTP_X_FORWARDED_FOR) ? $HTTP_X_FORWARDED_FOR : $REMOTE_ADDR;
|
||||||
|
|
||||||
// Setup what template to use. Currently just use default
|
// Setup what template to use. Currently just use default
|
||||||
include('includes/template.inc');
|
include('includes/template.inc');
|
||||||
$template = new Template("./templates/Default", "remove");
|
$template = new Template("./templates/Default");
|
||||||
|
|
||||||
include('functions/error.'.$phpEx);
|
include('functions/error.'.$phpEx);
|
||||||
include('functions/sessions.'.$phpEx);
|
include('functions/sessions.'.$phpEx);
|
||||||
|
|
|
@ -29,16 +29,16 @@ $session_cookie_time = 3600;
|
||||||
// DB connection config
|
// DB connection config
|
||||||
$dbms = "mysql";
|
$dbms = "mysql";
|
||||||
$dbhost = "localhost";
|
$dbhost = "localhost";
|
||||||
$dbname = "";
|
$dbname = "phpbb2";
|
||||||
$dbuser = "";
|
$dbuser = "phpbb2";
|
||||||
$dbpasswd = "";
|
$dbpasswd = "bbphp2bb";
|
||||||
|
|
||||||
// Date format (needs to go into DB)
|
// Date format (needs to go into DB)
|
||||||
$date_format = "M d Y h:i:s a"; // American datesformat
|
$date_format = "M d Y h:i:s a"; // American datesformat
|
||||||
//$date_format = "d-m-Y H:i:s"; // European datesformat
|
//$date_format = "d-m-Y H:i:s"; // European datesformat
|
||||||
|
|
||||||
// DB table prefix
|
// DB table prefix
|
||||||
$table_prefix = "phpbb_";
|
$table_prefix = "";
|
||||||
|
|
||||||
$url_images = "images";
|
$url_images = "images";
|
||||||
$image_quote = "$url_images/quote.gif";
|
$image_quote = "$url_images/quote.gif";
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
// Parse and show the overall header.
|
// Parse and show the overall header.
|
||||||
$template->set_file(array("overall_header" => "overall_header.tpl",
|
$template->set_filenames(array("overall_header" => "overall_header.tpl",
|
||||||
"overall_footer" => "overall_footer.tpl"));
|
"overall_footer" => "overall_footer.tpl"));
|
||||||
|
|
||||||
if($user_logged_in)
|
if($user_logged_in)
|
||||||
|
@ -35,7 +35,7 @@ else
|
||||||
$logged_in_status = "You are not logged in.";
|
$logged_in_status = "You are not logged in.";
|
||||||
}
|
}
|
||||||
|
|
||||||
$template->set_var(array("SITENAME" => $sitename,
|
$template->assign_vars(array("SITENAME" => $sitename,
|
||||||
"PHPEX" => $phpEx,
|
"PHPEX" => $phpEx,
|
||||||
"PAGE_TITLE" => $page_title,
|
"PAGE_TITLE" => $page_title,
|
||||||
"LOGIN_STATUS" => $logged_in_status,
|
"LOGIN_STATUS" => $logged_in_status,
|
||||||
|
@ -67,67 +67,69 @@ $template->set_var(array("SITENAME" => $sitename,
|
||||||
"L_NONEWPOSTS" => $l_nonewposts,
|
"L_NONEWPOSTS" => $l_nonewposts,
|
||||||
"L_NEWPOSTS" => $l_newposts));
|
"L_NEWPOSTS" => $l_newposts));
|
||||||
|
|
||||||
$template->pparse("output", "overall_header");
|
$template->pparse("overall_header");
|
||||||
|
|
||||||
// Do a switch on page type, this way we only load the templates that we need at the time
|
// Do a switch on page type, this way we only load the templates that we need at the time
|
||||||
switch($pagetype)
|
switch($pagetype)
|
||||||
{
|
{
|
||||||
case 'index':
|
case 'index':
|
||||||
$template->set_file(array("header" => "index_header.tpl",
|
$template->set_filenames(array("header" => "index_header.tpl",
|
||||||
"body" => "index_body.tpl",
|
"body" => "index_body.tpl",
|
||||||
"footer" => "index_footer.tpl"));
|
"footer" => "index_footer.tpl"));
|
||||||
|
|
||||||
$template->set_var(array("TOTAL_POSTS" => $total_posts,
|
$template->assign_vars(array("TOTAL_POSTS" => $total_posts,
|
||||||
"TOTAL_USERS" => $total_users,
|
"TOTAL_USERS" => $total_users,
|
||||||
"NEWEST_USER" => $newest_user,
|
"NEWEST_USER" => $newest_user,
|
||||||
"NEWEST_UID" => $newest_uid,
|
"NEWEST_UID" => $newest_uid,
|
||||||
"USERS_BROWSING" => $users_browsing));
|
"USERS_BROWSING" => $users_browsing));
|
||||||
|
|
||||||
$template->pparse("output", "header");
|
$template->pparse("header");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'viewforum':
|
case 'viewforum':
|
||||||
$template->set_file(array("header" => "viewforum_header.tpl",
|
$template->set_filenames(array("header" => "viewforum_header.tpl",
|
||||||
"body" => "viewforum_body.tpl",
|
"body" => "viewforum_body.tpl",
|
||||||
"jumpbox" => "jumpbox.tpl",
|
"jumpbox" => "jumpbox.tpl",
|
||||||
"footer" => "viewforum_footer.tpl"));
|
"footer" => "viewforum_footer.tpl"));
|
||||||
|
|
||||||
$jumpbox = make_jumpbox($db);
|
$jumpbox = make_jumpbox($db);
|
||||||
$template->set_var(array("JUMPBOX_LIST" => $jumpbox,
|
$template->assign_vars(array("JUMPBOX_LIST" => $jumpbox,
|
||||||
"JUMPBOX_ACTION" => "viewforum.".$phpEx,
|
"JUMPBOX_ACTION" => "viewforum.".$phpEx,
|
||||||
"SELECT_NAME" => "forum_id"));
|
"SELECT_NAME" => "forum_id"));
|
||||||
$template->parse("JUMPBOX","jumpbox");
|
|
||||||
|
|
||||||
$template->set_var(array("FORUM_ID" => $forum_id,
|
$template->assign_var_from_handle("JUMPBOX", "jumpbox");
|
||||||
|
|
||||||
|
$template->assign_vars(array("FORUM_ID" => $forum_id,
|
||||||
"FORUM_NAME" => $forum_name,
|
"FORUM_NAME" => $forum_name,
|
||||||
"MODERATORS" => $forum_moderators));
|
"MODERATORS" => $forum_moderators));
|
||||||
|
|
||||||
$template->pparse("output", "header");
|
$template->pparse("header");
|
||||||
break;
|
break;
|
||||||
case 'viewtopic':
|
case 'viewtopic':
|
||||||
$template->set_file(array("header" => "viewtopic_header.tpl",
|
$template->set_filenames(array("header" => "viewtopic_header.tpl",
|
||||||
"body" => "viewtopic_body.tpl",
|
"body" => "viewtopic_body.tpl",
|
||||||
"jumpbox" => "jumpbox.tpl",
|
"jumpbox" => "jumpbox.tpl",
|
||||||
"footer" => "viewtopic_footer.tpl"));
|
"footer" => "viewtopic_footer.tpl"));
|
||||||
$jumpbox = make_jumpbox($db);
|
$jumpbox = make_jumpbox($db);
|
||||||
$template->set_var(array("JUMPBOX_LIST" => $jumpbox,
|
$template->assign_vars(array("JUMPBOX_LIST" => $jumpbox,
|
||||||
"JUMPBOX_ACTION" => "viewforum.".$phpEx,
|
"JUMPBOX_ACTION" => "viewforum.".$phpEx,
|
||||||
"SELECT_NAME" => "forum_id"));
|
"SELECT_NAME" => "forum_id"));
|
||||||
$template->parse("JUMPBOX","jumpbox");
|
|
||||||
|
|
||||||
$template->set_var(array("FORUM_ID" => $forum_id,
|
$template->assign_var_from_handle("JUMPBOX", "jumpbox");
|
||||||
|
|
||||||
|
$template->assign_vars(array("FORUM_ID" => $forum_id,
|
||||||
"FORUM_NAME" => $forum_name,
|
"FORUM_NAME" => $forum_name,
|
||||||
"TOPIC_ID" => $topic_id,
|
"TOPIC_ID" => $topic_id,
|
||||||
"TOPIC_TITLE" => $topic_title));
|
"TOPIC_TITLE" => $topic_title));
|
||||||
$template->pparse("output", "header");
|
$template->pparse("header");
|
||||||
break;
|
break;
|
||||||
case 'newtopic':
|
case 'newtopic':
|
||||||
$template->set_file(array("header" => "newtopic_header.tpl",
|
$template->set_filenames(array("header" => "newtopic_header.tpl",
|
||||||
"body" => "posting_body.tpl"));
|
"body" => "posting_body.tpl"));
|
||||||
$template->set_var(array("FORUM_ID" => $forum_id,
|
$template->assign_vars(array("FORUM_ID" => $forum_id,
|
||||||
"FORUM_NAME" => $forum_name,
|
"FORUM_NAME" => $forum_name,
|
||||||
"L_POSTNEWIN" => $l_postnewin));
|
"L_POSTNEWIN" => $l_postnewin));
|
||||||
$template->pparse("output", "header");
|
$template->pparse("header");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,17 +26,17 @@
|
||||||
switch($pagetype)
|
switch($pagetype)
|
||||||
{
|
{
|
||||||
case 'index':
|
case 'index':
|
||||||
$template->pparse("output", "footer");
|
$template->pparse("footer");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'viewforum':
|
case 'viewforum':
|
||||||
|
|
||||||
$template->set_var(array("PHPEX" => $phpEx,
|
$template->assign_vars(array("PHPEX" => $phpEx,
|
||||||
"FORUM_ID" => $forum_id));
|
"FORUM_ID" => $forum_id));
|
||||||
$template->pparse("output", "footer");
|
$template->pparse("footer");
|
||||||
break;
|
break;
|
||||||
case 'viewtopic':
|
case 'viewtopic':
|
||||||
$template->pparse("output", "footer");
|
$template->pparse("footer");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,9 +45,9 @@ if($user_logged_in)
|
||||||
{
|
{
|
||||||
$admin_link = "<a href=\"admin/index.php\">Administration Panel</a>";
|
$admin_link = "<a href=\"admin/index.php\">Administration Panel</a>";
|
||||||
}
|
}
|
||||||
$template->set_var(array("PHPBB_VERSION" => "2.0-alpha",
|
$template->assign_vars(array("PHPBB_VERSION" => "2.0-alpha",
|
||||||
"ADMIN_LINK" => $admin_link));
|
"ADMIN_LINK" => $admin_link));
|
||||||
$template->pparse("output", "overall_footer");
|
$template->pparse("overall_footer");
|
||||||
|
|
||||||
// Close our DB connection.
|
// Close our DB connection.
|
||||||
$db->sql_close();
|
$db->sql_close();
|
||||||
|
|
|
@ -1,375 +1,427 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
|
||||||
* Session Management for PHP3
|
// (insert phpBB file header here)
|
||||||
*
|
|
||||||
* (C) Copyright 1999-2000 NetUSE GmbH
|
|
||||||
* Kristian Koehntopp
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
* This code was NOT written by the phpBB group. It is part of the PHPLib
|
|
||||||
* package written by NetUSE GmbH and Kristian Koehntopp.
|
|
||||||
* This code is released under the GNU General Public Licence and used in
|
|
||||||
* accordance with said licence.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some methods modified by Nathan Codding of the phpBB group for
|
* Template class. By Nathan Codding of the phpBB group.
|
||||||
* better performance - replacing preg_replace() with str_replace()
|
* The interface was originally inspired by PHPLib templates,
|
||||||
* where possible.
|
* and the template file formats are quite similar.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// global variable that holds all the data we'll be substituting into
|
||||||
|
// the compiled templates.
|
||||||
|
|
||||||
|
// This will end up being a multi-dimensional array like this:
|
||||||
|
// $_tpldata[block.][iteration#][child.][iteration#][child2.][iteration#][variablename] == value
|
||||||
|
// if it's a root-level variable, it'll be like this:
|
||||||
|
// $_tpldata[.][0][varname] == value
|
||||||
|
|
||||||
|
if (!isset($_tpldata))
|
||||||
|
{
|
||||||
|
$_tpldata = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Template {
|
class Template {
|
||||||
var $classname = "Template";
|
var $classname = "Template";
|
||||||
|
|
||||||
/* if set, echo assignments */
|
// Hash of filenames for each template handle.
|
||||||
var $debug = false;
|
var $files = array();
|
||||||
|
|
||||||
/* $file[handle] = "filename"; */
|
// Root template directory.
|
||||||
var $file = array();
|
|
||||||
|
|
||||||
/* relative filenames are relative to this pathname */
|
|
||||||
var $root = "";
|
var $root = "";
|
||||||
|
|
||||||
/* $varkeys[key] = "key"; $varvals[key] = "value"; */
|
// this will hash handle names to the compiled code for that handle.
|
||||||
var $varkeys = array();
|
var $compiled_code = array();
|
||||||
var $varvals = array();
|
|
||||||
|
|
||||||
/* "remove" => remove undefined variables
|
// This will hold the uncompiled code for that handle.
|
||||||
* "comment" => replace undefined variables with comments
|
var $uncompiled_code = array();
|
||||||
* "keep" => keep undefined variables
|
|
||||||
|
/**
|
||||||
|
* Constructor. Simply sets the root dir.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
var $unknowns = "remove";
|
function Template($root = ".")
|
||||||
|
{
|
||||||
/* "yes" => halt, "report" => report error, continue, "no" => ignore error quietly */
|
$this->set_rootdir($root);
|
||||||
var $halt_on_error = "yes";
|
|
||||||
|
|
||||||
/* last error message is retained here */
|
|
||||||
var $last_error = "";
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************/
|
|
||||||
/* public: Constructor.
|
|
||||||
* root: template directory.
|
|
||||||
* unknowns: how to handle unknown variables.
|
|
||||||
*/
|
|
||||||
function Template($root = ".", $unknowns = "remove") {
|
|
||||||
$this->set_root($root);
|
|
||||||
$this->set_unknowns($unknowns);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public: setroot(pathname $root)
|
/**
|
||||||
* root: new template directory.
|
* Sets the template root directory for this Template object.
|
||||||
*/
|
*/
|
||||||
function set_root($root) {
|
function set_rootdir($dir)
|
||||||
if (!is_dir($root)) {
|
{
|
||||||
$this->halt("set_root: $root is not a directory.");
|
if (!is_dir($dir))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->root = $root;
|
$this->root = $dir;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public: set_unknowns(enum $unknowns)
|
/**
|
||||||
* unknowns: "remove", "comment", "keep"
|
* Sets the template filenames for handles. $filename_array
|
||||||
*
|
* should be a hash of handle => filename pairs.
|
||||||
*/
|
*/
|
||||||
function set_unknowns($unknowns = "keep") {
|
function set_filenames($filename_array)
|
||||||
$this->unknowns = $unknowns;
|
{
|
||||||
}
|
if (!is_array($filename_array))
|
||||||
|
{
|
||||||
/* public: set_file(array $filelist)
|
|
||||||
* filelist: array of handle, filename pairs.
|
|
||||||
*
|
|
||||||
* public: set_file(string $handle, string $filename)
|
|
||||||
* handle: handle for a filename,
|
|
||||||
* filename: name of template file
|
|
||||||
*/
|
|
||||||
function set_file($handle, $filename = "") {
|
|
||||||
if (!is_array($handle)) {
|
|
||||||
if ($filename == "") {
|
|
||||||
$this->halt("set_file: For handle $handle filename is empty.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$this->file[$handle] = $this->filename($filename);
|
|
||||||
} else {
|
|
||||||
reset($handle);
|
|
||||||
while(list($h, $f) = each($handle)) {
|
|
||||||
$this->file[$h] = $this->filename($f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* public: set_block(string $parent, string $handle, string $name = "")
|
|
||||||
* extract the template $handle from $parent,
|
|
||||||
* place variable {$name} instead.
|
|
||||||
*/
|
|
||||||
function set_block($parent, $handle, $name = "") {
|
|
||||||
if (!$this->loadfile($parent)) {
|
|
||||||
$this->halt("subst: unable to load $parent.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ($name == "")
|
|
||||||
$name = $handle;
|
|
||||||
|
|
||||||
$str = $this->get_var($parent);
|
|
||||||
$reg = "/<!--\s+BEGIN $handle\s+-->(.*?)\n\s*<!--\s+END $handle\s+-->/sm";
|
|
||||||
preg_match($reg, $str, $m);
|
|
||||||
$str = preg_replace($reg, "{" . "$name}", $str);
|
|
||||||
$this->set_var($handle, $m[1]);
|
|
||||||
$this->set_var($parent, $str);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* public: set_var(array $values)
|
|
||||||
* values: array of variable name, value pairs.
|
|
||||||
*
|
|
||||||
* public: set_var(string $varname, string $value)
|
|
||||||
* varname: name of a variable that is to be defined
|
|
||||||
* value: value of that variable
|
|
||||||
*/
|
|
||||||
function set_var($varname, $value = "") {
|
|
||||||
if (!is_array($varname)) {
|
|
||||||
if (!empty($varname))
|
|
||||||
if ($this->debug) print "scalar: set *$varname* to *$value*<br>\n";
|
|
||||||
$this->varkeys[$varname] = '{' . $varname . '}';
|
|
||||||
$this->varvals[$varname] = $value;
|
|
||||||
} else {
|
|
||||||
reset($varname);
|
|
||||||
while(list($k, $v) = each($varname)) {
|
|
||||||
if (!empty($k))
|
|
||||||
if ($this->debug) print "array: set *$k* to *$v*<br>\n";
|
|
||||||
$this->varkeys[$k] = '{' . $k . '}';
|
|
||||||
$this->varvals[$k] = $v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* public: subst(string $handle)
|
|
||||||
* handle: handle of template where variables are to be substituted.
|
|
||||||
*/
|
|
||||||
function subst($handle) {
|
|
||||||
if (!$this->loadfile($handle)) {
|
|
||||||
$this->halt("subst: unable to load $handle.");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$str = $this->get_var($handle);
|
reset($filename_array);
|
||||||
// This will break if $str is an array... Not sure if that ever
|
while(list($handle, $filename) = each($filename_array))
|
||||||
// actually happens, so we'll use this check for a while.
|
|
||||||
if (is_array($str)) die ("str is an array.");
|
|
||||||
|
|
||||||
reset($this->varkeys);
|
|
||||||
while (list($k, $v) = each ($this->varkeys))
|
|
||||||
{
|
{
|
||||||
$str = str_replace($this->varkeys[$k], $this->varvals[$k], $str);
|
$this->files[$handle] = $this->make_filename($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $str;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public: psubst(string $handle)
|
|
||||||
* handle: handle of template where variables are to be substituted.
|
/**
|
||||||
|
* Load the file for the handle, compile the file,
|
||||||
|
* and run the compiled code. This will print out
|
||||||
|
* the results of executing the template.
|
||||||
*/
|
*/
|
||||||
function psubst($handle) {
|
function pparse($handle)
|
||||||
print $this->subst($handle);
|
{
|
||||||
|
global $_tpldata;
|
||||||
|
|
||||||
return false;
|
if (!$this->loadfile($handle))
|
||||||
|
{
|
||||||
|
die("Template->pparse(): Couldn't load template file for handle $handle");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public: parse(string $target, string $handle, boolean append)
|
// actually compile the template now.
|
||||||
* public: parse(string $target, array $handle, boolean append)
|
if (!isset($this->compiled_code[$handle]) || empty($this->compiled_code[$handle]))
|
||||||
* target: handle of variable to generate
|
{
|
||||||
* handle: handle of template to substitute
|
// Actually compile the code now.
|
||||||
* append: append to target handle
|
$this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run the compiled code.
|
||||||
|
eval($this->compiled_code[$handle]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inserts the uncompiled code for $handle as the
|
||||||
|
* value of $varname in the root-level. This can be used
|
||||||
|
* to effectively include a template in the middle of another
|
||||||
|
* template.
|
||||||
|
* Note that all desired assignments to the variables in $handle should be done
|
||||||
|
* BEFORE calling this function.
|
||||||
*/
|
*/
|
||||||
function parse($target, $handle, $append = false)
|
function assign_var_from_handle($varname, $handle)
|
||||||
{
|
{
|
||||||
if (!is_array($handle))
|
global $_tpldata;
|
||||||
|
if (!$this->loadfile($handle))
|
||||||
{
|
{
|
||||||
$str = $this->subst($handle);
|
die("Template->assign_var_from_handle(): Couldn't load template file for handle $handle");
|
||||||
if ($append)
|
}
|
||||||
|
|
||||||
|
// Compile it, with the "no echo statements" option on.
|
||||||
|
$code = $this->compile($this->uncompiled_code[$handle], true);
|
||||||
|
// turn it into a variable assignment.
|
||||||
|
$code = '$_str = \'' . $code . '\';';
|
||||||
|
|
||||||
|
// evaluate the variable assignment.
|
||||||
|
eval($code);
|
||||||
|
|
||||||
|
// assign the value of the generated variable to the given varname.
|
||||||
|
$this->assign_var($varname, $_str);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Block-level variable assignment. Adds a new block iteration with the given
|
||||||
|
* variable assignments. Note that this should only be called once per block
|
||||||
|
* iteration.
|
||||||
|
*/
|
||||||
|
function assign_block_vars($blockname, $vararray)
|
||||||
{
|
{
|
||||||
$this->set_var($target, $this->get_var($target) . $str);
|
global $_tpldata;
|
||||||
|
|
||||||
|
if (strstr($blockname, '.'))
|
||||||
|
{
|
||||||
|
// Nested block.
|
||||||
|
$blocks = explode('.', $blockname);
|
||||||
|
$blockcount = sizeof($blocks) - 1;
|
||||||
|
$str = '$_tpldata';
|
||||||
|
for ($i = 0; $i < $blockcount; $i++)
|
||||||
|
{
|
||||||
|
$str .= '[\'' . $blocks[$i] . '.\']';
|
||||||
|
eval('$lastiteration = sizeof(' . $str . ') - 1;');
|
||||||
|
$str .= '[' . $lastiteration . ']';
|
||||||
|
}
|
||||||
|
// Now we add the block that we're actually assigning to.
|
||||||
|
// We're adding a new iteration to this block with the given
|
||||||
|
// variable assignments.
|
||||||
|
$str .= '[\'' . $blocks[$blockcount] . '.\'][] = $vararray;';
|
||||||
|
|
||||||
|
// Now we evaluate this assignment we've built up.
|
||||||
|
eval($str);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->set_var($target, $str);
|
// Top-level block.
|
||||||
|
// Add a new iteration to this block with the variable assignments
|
||||||
|
// we were given.
|
||||||
|
$_tpldata[$blockname . '.'][] = $vararray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
/**
|
||||||
|
* Root-level variable assignment. Adds to current assignments, overriding
|
||||||
|
* any existing variable assignment with the same name.
|
||||||
|
*/
|
||||||
|
function assign_vars($vararray)
|
||||||
{
|
{
|
||||||
reset($handle);
|
global $_tpldata;
|
||||||
while(list($i, $h) = each($handle))
|
|
||||||
|
reset ($vararray);
|
||||||
|
while (list($key, $val) = each($vararray))
|
||||||
{
|
{
|
||||||
$str = $this->subst($h);
|
$_tpldata['.'][0][$key] = $val;
|
||||||
$this->set_var($target, $str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $str;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function pparse($target, $handle, $append = false) {
|
/**
|
||||||
print $this->parse($target, $handle, $append);
|
* Root-level variable assignment. Adds to current assignments, overriding
|
||||||
return false;
|
* any existing variable assignment with the same name.
|
||||||
}
|
|
||||||
|
|
||||||
/* public: get_vars()
|
|
||||||
*/
|
*/
|
||||||
function get_vars() {
|
function assign_var($varname, $varval)
|
||||||
reset($this->varkeys);
|
{
|
||||||
while(list($k, $v) = each($this->varkeys)) {
|
global $_tpldata;
|
||||||
$result[$k] = $this->varvals[$k];
|
|
||||||
|
$_tpldata['.'][0][$varname] = $varval;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* public: get_var(string varname)
|
/**
|
||||||
* varname: name of variable.
|
* Generates a full path+filename for the given filename, which can either
|
||||||
*
|
* be an absolute name, or a name relative to the rootdir for this Template
|
||||||
* public: get_var(array varname)
|
* object.
|
||||||
* varname: array of variable names
|
|
||||||
*/
|
*/
|
||||||
function get_var($varname) {
|
function make_filename($filename)
|
||||||
if (!is_array($varname)) {
|
{
|
||||||
return $this->varvals[$varname];
|
// Check if it's an absolute or relative path.
|
||||||
} else {
|
if (substr($filename, 0, 1) != '/')
|
||||||
reset($varname);
|
{
|
||||||
while(list($k, $v) = each($varname)) {
|
$filename = $this->root . '/' . $filename;
|
||||||
$result[$k] = $this->varvals[$k];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* public: get_undefined($handle)
|
|
||||||
* handle: handle of a template.
|
|
||||||
*/
|
|
||||||
function get_undefined($handle) {
|
|
||||||
if (!$this->loadfile($handle)) {
|
|
||||||
$this->halt("get_undefined: unable to load $handle.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
preg_match_all("/\{([^}]+)\}/", $this->get_var($handle), $m);
|
|
||||||
$m = $m[1];
|
|
||||||
if (!is_array($m))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
reset($m);
|
|
||||||
while(list($k, $v) = each($m)) {
|
|
||||||
if (!isset($this->varkeys[$v]))
|
|
||||||
$result[$v] = $v;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($result))
|
|
||||||
return $result;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* public: finish(string $str)
|
|
||||||
* str: string to finish.
|
|
||||||
*/
|
|
||||||
function finish($str) {
|
|
||||||
switch ($this->unknowns) {
|
|
||||||
case "keep":
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "remove":
|
|
||||||
$str = preg_replace('/{[^ \t\r\n}]+}/', "", $str);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "comment":
|
|
||||||
$str = preg_replace('/{([^ \t\r\n}]+)}/', "<!-- Template $handle: Variable \\1 undefined -->", $str);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $str;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* public: p(string $varname)
|
|
||||||
* varname: name of variable to print.
|
|
||||||
*/
|
|
||||||
function p($varname) {
|
|
||||||
print $this->finish($this->get_var($varname));
|
|
||||||
}
|
|
||||||
|
|
||||||
function get($varname) {
|
|
||||||
return $this->finish($this->get_var($varname));
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************/
|
|
||||||
/* private: filename($filename)
|
|
||||||
* filename: name to be completed.
|
|
||||||
*/
|
|
||||||
function filename($filename) {
|
|
||||||
if (substr($filename, 0, 1) != "/") {
|
|
||||||
$filename = $this->root."/".$filename;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($filename))
|
if (!file_exists($filename))
|
||||||
$this->halt("filename: file $filename does not exist.");
|
{
|
||||||
|
die("Template->make_filename(): Error - file $filename does not exist");
|
||||||
|
}
|
||||||
|
|
||||||
return $filename;
|
return $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* private: varname($varname)
|
|
||||||
* varname: name of a replacement variable to be protected.
|
|
||||||
*/
|
|
||||||
function varname($varname) {
|
|
||||||
return preg_quote("{".$varname."}");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
/* private: loadfile(string $handle)
|
* If not already done, load the file for the given handle and populate
|
||||||
* handle: load file defined by handle, if it is not loaded yet.
|
* the uncompiled_code[] hash with its code. Do not compile.
|
||||||
*/
|
*/
|
||||||
function loadfile($handle) {
|
function loadfile($handle)
|
||||||
if (isset($this->varkeys[$handle]) and !empty($this->varvals[$handle]))
|
{
|
||||||
|
global $_tpldata;
|
||||||
|
|
||||||
|
// If the file for this handle is already loaded and compiled, do nothing.
|
||||||
|
if (isset($this->uncompiled_code[$handle]) && !empty($this->uncompiled_code[$handle]))
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!isset($this->file[$handle])) {
|
|
||||||
$this->halt("loadfile: $handle is not a valid handle.");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
$filename = $this->file[$handle];
|
|
||||||
|
// If we don't have a file assigned to this handle, die.
|
||||||
|
if (!isset($this->files[$handle]))
|
||||||
|
{
|
||||||
|
die("Template->loadfile(): No file specified for handle $handle");
|
||||||
|
}
|
||||||
|
|
||||||
|
$filename = $this->files[$handle];
|
||||||
|
|
||||||
$str = implode("", @file($filename));
|
$str = implode("", @file($filename));
|
||||||
if (empty($str)) {
|
if (empty($str))
|
||||||
$this->halt("loadfile: While loading $handle, $filename does not exist or is empty.");
|
{
|
||||||
return false;
|
die("Template->loadfile(): File $filename for handle $handle is empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->set_var($handle, $str);
|
$this->uncompiled_code[$handle] = $str;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************/
|
|
||||||
/* public: halt(string $msg)
|
|
||||||
* msg: error message to show.
|
/**
|
||||||
|
* Compiles the given string of code, and returns
|
||||||
|
* the result in a string.
|
||||||
|
* If "do_not_echo" is true, the returned code will not be directly
|
||||||
|
* executable, but can be used as part of a variable assignment
|
||||||
|
* for use in assign_code_from_handle().
|
||||||
*/
|
*/
|
||||||
function halt($msg) {
|
function compile($code, $do_not_echo = false)
|
||||||
$this->last_error = $msg;
|
{
|
||||||
|
global $_tpldata;
|
||||||
|
|
||||||
if ($this->halt_on_error != "no")
|
// replace \ with \\ and then ' with \'.
|
||||||
$this->haltmsg($msg);
|
$code = str_replace('\\', '\\\\', $code);
|
||||||
|
$code = str_replace('\'', '\\\'', $code);
|
||||||
|
|
||||||
if ($this->halt_on_error == "yes")
|
// change template varrefs into PHP varrefs
|
||||||
die("<b>Halted.</b>");
|
|
||||||
|
|
||||||
return false;
|
// This one will handle varrefs WITH namespaces
|
||||||
|
$varrefs = array();
|
||||||
|
preg_match_all('#\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}#is', $code, $varrefs);
|
||||||
|
$varcount = sizeof($varrefs[1]);
|
||||||
|
for ($i = 0; $i < $varcount; $i++)
|
||||||
|
{
|
||||||
|
$namespace = $varrefs[1][$i];
|
||||||
|
$varname = $varrefs[3][$i];
|
||||||
|
$new = $this->generate_block_varref($namespace, $varname);
|
||||||
|
|
||||||
|
$code = str_replace($varrefs[0][$i], $new, $code);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public, override: haltmsg($msg)
|
// This will handle the remaining root-level varrefs
|
||||||
* msg: error message to show.
|
$code = preg_replace('#\{([a-z0-9\-_]*?)\}#is', '\' . $_tpldata[\'.\'][0][\'\1\'] . \'', $code);
|
||||||
*/
|
|
||||||
function haltmsg($msg) {
|
// Break it up into lines.
|
||||||
printf("<b>Template Error:</b> %s<br>\n", $msg);
|
$code_lines = explode("\n", $code);
|
||||||
|
|
||||||
|
$block_nesting_level = 0;
|
||||||
|
$block_names = array();
|
||||||
|
$block_names[0] = ".";
|
||||||
|
|
||||||
|
// Second: prepend echo ', append ' . "\n"; to each line.
|
||||||
|
$line_count = sizeof($code_lines);
|
||||||
|
for ($i = 0; $i < $line_count; $i++)
|
||||||
|
{
|
||||||
|
$code_lines[$i] = chop($code_lines[$i]);
|
||||||
|
if (preg_match('#<!-- BEGIN (.*?) -->#', $code_lines[$i], $m))
|
||||||
|
{
|
||||||
|
// We have the start of a block.
|
||||||
|
$block_nesting_level++;
|
||||||
|
$block_names[$block_nesting_level] = $m[1];
|
||||||
|
|
||||||
|
if ($block_nesting_level < 2)
|
||||||
|
{
|
||||||
|
// Block is not nested.
|
||||||
|
$code_lines[$i] = '$_' . $m[1] . '_count = sizeof($_tpldata[\'' . $m[1] . '.\']);';
|
||||||
|
$code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)';
|
||||||
|
$code_lines[$i] .= "\n" . '{';
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// This block is nested.
|
||||||
|
|
||||||
|
// Generate a namespace string for this block.
|
||||||
|
$namespace = implode('.', $block_names);
|
||||||
|
// strip leading period from root level..
|
||||||
|
$namespace = substr($namespace, 2);
|
||||||
|
// Get a reference to the data array for this block that depends on the
|
||||||
|
// current indices of all parent blocks.
|
||||||
|
$varref = $this->generate_block_data_ref($namespace, false);
|
||||||
|
// Create the for loop code to iterate over this block.
|
||||||
|
$code_lines[$i] = '$_' . $m[1] . '_count = sizeof(' . $varref . ');';
|
||||||
|
$code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)';
|
||||||
|
$code_lines[$i] .= "\n" . '{';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $m))
|
||||||
|
{
|
||||||
|
// We have the end of a block.
|
||||||
|
unset($block_names[$block_nesting_level]);
|
||||||
|
$block_nesting_level--;
|
||||||
|
$code_lines[$i] = '} // END ' . $m[1];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// We have an ordinary line of code.
|
||||||
|
if (!$do_not_echo)
|
||||||
|
{
|
||||||
|
$code_lines[$i] = 'echo \'' . $code_lines[$i] . '\' . "\\n";';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bring it back into a single string of lines of code.
|
||||||
|
$code = implode("\n", $code_lines);
|
||||||
|
|
||||||
|
return $code ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a reference to the given variable inside the given (possibly nested)
|
||||||
|
* block namespace. This is a string of the form:
|
||||||
|
* ' . $_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . '
|
||||||
|
* It's ready to be inserted into an "echo" line in one of the templates.
|
||||||
|
* NOTE: expects a trailing "." on the namespace.
|
||||||
|
*/
|
||||||
|
function generate_block_varref($namespace, $varname)
|
||||||
|
{
|
||||||
|
// Strip the trailing period.
|
||||||
|
$namespace = substr($namespace, 0, strlen($namespace) - 1);
|
||||||
|
|
||||||
|
// Get a reference to the data block for this namespace.
|
||||||
|
$varref = $this->generate_block_data_ref($namespace, true);
|
||||||
|
// Prepend the necessary code to stick this in an echo line.
|
||||||
|
$varref = '\' . ' . $varref;
|
||||||
|
// Append the variable reference.
|
||||||
|
$varref .= '[\'' . $varname . '\'] . \'';
|
||||||
|
|
||||||
|
return $varref;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a reference to the array of data values for the given
|
||||||
|
* (possibly nested) block namespace. This is a string of the form:
|
||||||
|
* $_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN']
|
||||||
|
*
|
||||||
|
* If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above.
|
||||||
|
* NOTE: does not expect a trailing "." on the blockname.
|
||||||
|
*/
|
||||||
|
function generate_block_data_ref($blockname, $include_last_iterator)
|
||||||
|
{
|
||||||
|
// Get an array of the blocks involved.
|
||||||
|
$blocks = explode(".", $blockname);
|
||||||
|
$blockcount = sizeof($blocks) - 1;
|
||||||
|
$varref = '$_tpldata';
|
||||||
|
// Build up the string with everything but the last child.
|
||||||
|
for ($i = 0; $i < $blockcount; $i++)
|
||||||
|
{
|
||||||
|
$varref .= '[\'' . $blocks[$i] . '.\'][$_' . $blocks[$i] . '_i]';
|
||||||
|
}
|
||||||
|
// Add the block reference for the last child.
|
||||||
|
$varref .= '[\'' . $blocks[$blockcount] . '.\']';
|
||||||
|
// Add the iterator for the last child if requried.
|
||||||
|
if ($include_last_iterator)
|
||||||
|
{
|
||||||
|
$varref .= '[$_' . $blocks[$blockcount] . '_i]';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $varref;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -41,9 +41,6 @@ if(empty($viewcat))
|
||||||
|
|
||||||
include('includes/page_header.'.$phpEx);
|
include('includes/page_header.'.$phpEx);
|
||||||
|
|
||||||
$template->set_block("body", "catrow", "cats");
|
|
||||||
$template->set_block("catrow", "forumrow", "forums");
|
|
||||||
|
|
||||||
$sql = "SELECT c.*
|
$sql = "SELECT c.*
|
||||||
FROM ".CATEGORIES_TABLE." c, ".FORUMS_TABLE." f
|
FROM ".CATEGORIES_TABLE." c, ".FORUMS_TABLE." f
|
||||||
WHERE f.cat_id=c.cat_id
|
WHERE f.cat_id=c.cat_id
|
||||||
|
@ -99,12 +96,10 @@ if($total_categories)
|
||||||
|
|
||||||
for($i = 0; $i < $total_categories; $i++)
|
for($i = 0; $i < $total_categories; $i++)
|
||||||
{
|
{
|
||||||
$template->set_var(array("CAT_ID" => $category_rows[$i]["cat_id"],
|
$template->assign_block_vars("catrow", array("CAT_ID" => $category_rows[$i]["cat_id"],
|
||||||
"PHP_SELF" => $PHP_SELF,
|
"PHP_SELF" => $PHP_SELF,
|
||||||
"CAT_DESC" => stripslashes($category_rows[$i]["cat_title"])));
|
"CAT_DESC" => stripslashes($category_rows[$i]["cat_title"])));
|
||||||
$template->parse("cats", "catrow", true);
|
|
||||||
|
|
||||||
$created_line = false;
|
|
||||||
for($j = 0; $j < $total_forums; $j++)
|
for($j = 0; $j < $total_forums; $j++)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -152,7 +147,7 @@ if($total_categories)
|
||||||
$moderators_links .= "<a href=\"profile.$phpEx?mode=viewprofile&user_id=".$forum_mods["forum_".$forum_rows[$j]["forum_id"]."_id"][$mods]."\">".$forum_mods["forum_".$forum_rows[$j]["forum_id"]."_name"][$mods]."</a>";
|
$moderators_links .= "<a href=\"profile.$phpEx?mode=viewprofile&user_id=".$forum_mods["forum_".$forum_rows[$j]["forum_id"]."_id"][$mods]."\">".$forum_mods["forum_".$forum_rows[$j]["forum_id"]."_name"][$mods]."</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$template->set_var(array("FOLDER" => $folder_image,
|
$template->assign_block_vars("catrow.forumrow", array("FOLDER" => $folder_image,
|
||||||
"FORUM_NAME" => stripslashes($forum_rows[$j]["forum_name"]),
|
"FORUM_NAME" => stripslashes($forum_rows[$j]["forum_name"]),
|
||||||
"FORUM_ID" => $forum_rows[$j]["forum_id"],
|
"FORUM_ID" => $forum_rows[$j]["forum_id"],
|
||||||
"FORUM_DESC" => stripslashes($forum_rows[$j]["forum_desc"]),
|
"FORUM_DESC" => stripslashes($forum_rows[$j]["forum_desc"]),
|
||||||
|
@ -163,16 +158,8 @@ if($total_categories)
|
||||||
"LAST_POST" => $last_post,
|
"LAST_POST" => $last_post,
|
||||||
"MODERATORS" => $moderators_links));
|
"MODERATORS" => $moderators_links));
|
||||||
|
|
||||||
$template->parse("forums", "forumrow", true);
|
|
||||||
|
|
||||||
$created_line = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($created_line)
|
|
||||||
{
|
|
||||||
$template->parse("cats", "forums", true);
|
|
||||||
$template->set_var("forums", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
} // for ... categories
|
} // for ... categories
|
||||||
|
|
||||||
|
@ -181,7 +168,7 @@ else
|
||||||
{
|
{
|
||||||
error_die($db, GENERAL_ERROR, "There are no Categories or Foums on this board.");
|
error_die($db, GENERAL_ERROR, "There are no Categories or Foums on this board.");
|
||||||
}
|
}
|
||||||
$template->pparse("output", "body");
|
$template->pparse("body");
|
||||||
|
|
||||||
include('includes/page_tail.'.$phpEx);
|
include('includes/page_tail.'.$phpEx);
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -143,7 +143,7 @@ else
|
||||||
$notify_toggle .= "> $l_notify";
|
$notify_toggle .= "> $l_notify";
|
||||||
|
|
||||||
|
|
||||||
$template->set_var(array("L_ABOUTPOST" => $l_aboutpost,
|
$template->assign_vars(array("L_ABOUTPOST" => $l_aboutpost,
|
||||||
"L_SUBJECT" => $l_subject,
|
"L_SUBJECT" => $l_subject,
|
||||||
"L_MESSAGEBODY" => $l_body,
|
"L_MESSAGEBODY" => $l_body,
|
||||||
"L_OPTIONS" => $l_options,
|
"L_OPTIONS" => $l_options,
|
||||||
|
@ -163,7 +163,7 @@ else
|
||||||
"NOTIFY_TOGGLE" => $notify_toggle,
|
"NOTIFY_TOGGLE" => $notify_toggle,
|
||||||
"BBCODE_TOGGLE" => $bbcode_toggle,
|
"BBCODE_TOGGLE" => $bbcode_toggle,
|
||||||
"BBCODE_STATUS" => $bbcode_status));
|
"BBCODE_STATUS" => $bbcode_status));
|
||||||
$template->pparse("output", "body");
|
$template->pparse("body");
|
||||||
include('includes/page_tail.'.$phpEx);
|
include('includes/page_tail.'.$phpEx);
|
||||||
break;
|
break;
|
||||||
case 'reply':
|
case 'reply':
|
||||||
|
|
|
@ -14,16 +14,16 @@
|
||||||
</tr>
|
</tr>
|
||||||
<!-- BEGIN catrow -->
|
<!-- BEGIN catrow -->
|
||||||
<tr class="catheader">
|
<tr class="catheader">
|
||||||
<td colspan="6"><a href="{PHP_SELF}?viewcat={CAT_ID}">{CAT_DESC}</a></td>
|
<td colspan="6"><a href="{catrow.PHP_SELF}?viewcat={catrow.CAT_ID}">{catrow.CAT_DESC}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- BEGIN forumrow -->
|
<!-- BEGIN forumrow -->
|
||||||
<tr bgcolor="{ROW_COLOR}" class="tablebody">
|
<tr bgcolor="{catrow.forumrow.ROW_COLOR}" class="tablebody">
|
||||||
<td width="5%" align="center" valign="middle">{FOLDER}</td>
|
<td width="5%" align="center" valign="middle">{catrow.forumrow.FOLDER}</td>
|
||||||
<td><a href="viewforum.{PHPEX}?forum_id={FORUM_ID}&{POSTS}">{FORUM_NAME}</a><br>{FORUM_DESC}</td>
|
<td><a href="viewforum.{PHPEX}?forum_id={catrow.forumrow.FORUM_ID}&{catrow.forumrow.POSTS}">{catrow.forumrow.FORUM_NAME}</a><br>{catrow.forumrow.FORUM_DESC}</td>
|
||||||
<td width="5%" align="center" valign="middle">{TOPICS}</td>
|
<td width="5%" align="center" valign="middle">{catrow.forumrow.TOPICS}</td>
|
||||||
<td width="5%" align="center" valign="middle">{POSTS}</td>
|
<td width="5%" align="center" valign="middle">{catrow.forumrow.POSTS}</td>
|
||||||
<td width="15%" align="center" valign="middle">{LAST_POST}</td>
|
<td width="15%" align="center" valign="middle">{catrow.forumrow.LAST_POST}</td>
|
||||||
<td width="5%" align="center" valign="middle">{MODERATORS}</td>
|
<td width="5%" align="center" valign="middle">{catrow.forumrow.MODERATORS}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- END forumrow -->
|
<!-- END forumrow -->
|
||||||
<!-- END catrow -->
|
<!-- END catrow -->
|
||||||
|
|
|
@ -14,12 +14,12 @@
|
||||||
</tr>
|
</tr>
|
||||||
<!-- BEGIN topicrow -->
|
<!-- BEGIN topicrow -->
|
||||||
<tr bgcolor="#DDDDDD" class="tablebody">
|
<tr bgcolor="#DDDDDD" class="tablebody">
|
||||||
<td width="5%" align="center" valign="middle">{FOLDER}</td>
|
<td width="5%" align="center" valign="middle">{topicrow.FOLDER}</td>
|
||||||
<td><a href="viewtopic.{PHPEX}?{POST_TOPIC_URL}={TOPIC_ID}&{REPLIES}">{TOPIC_TITLE}</a>{GOTO_PAGE}</td>
|
<td><a href="viewtopic.{PHPEX}?{topicrow.POST_TOPIC_URL}={topicrow.TOPIC_ID}&{topicrow.REPLIES}">{topicrow.TOPIC_TITLE}</a>{topicrow.GOTO_PAGE}</td>
|
||||||
<td width="5%" align="center" valign="middle">{REPLIES}</td>
|
<td width="5%" align="center" valign="middle">{topicrow.REPLIES}</td>
|
||||||
<td width="10%" align="center" valign="middle">{TOPIC_POSTER}</td>
|
<td width="10%" align="center" valign="middle">{topicrow.TOPIC_POSTER}</td>
|
||||||
<td width="5%" align="center" valign="middle">{VIEWS}</td>
|
<td width="5%" align="center" valign="middle">{topicrow.VIEWS}</td>
|
||||||
<td width="15%" align="center" valign="middle">{LAST_POST}</td>
|
<td width="15%" align="center" valign="middle">{topicrow.LAST_POST}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- END topicrow -->
|
<!-- END topicrow -->
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -26,19 +26,19 @@
|
||||||
<td>{TOPIC_TITLE}</td>
|
<td>{TOPIC_TITLE}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- BEGIN postrow -->
|
<!-- BEGIN postrow -->
|
||||||
<tr bgcolor="{ROW_COLOR}" class="tablebody">
|
<tr bgcolor="{postrow.ROW_COLOR}" class="tablebody">
|
||||||
<td width="15%" align="left" valign="top">
|
<td width="15%" align="left" valign="top">
|
||||||
<font style="{font-size: 10pt; font-weight: bold;}">{POSTER_NAME}</font><br>
|
<font style="{font-size: 10pt; font-weight: bold;}">{postrow.POSTER_NAME}</font><br>
|
||||||
{POSTER_RANK}<br>
|
{postrow.POSTER_RANK}<br>
|
||||||
{RANK_IMAGE}<br>
|
{postrow.RANK_IMAGE}<br>
|
||||||
<br>
|
<br>
|
||||||
<font style="{font-size: 8pt;}">
|
<font style="{font-size: 8pt;}">
|
||||||
{L_JOINED}: {POSTER_JOINED}<br>{L_POSTS}: {POSTER_POSTS}<br>{POSTER_FROM}</font>
|
{postrow.L_JOINED}: {postrow.POSTER_JOINED}<br>{L_POSTS}: {postrow.POSTER_POSTS}<br>{postrow.POSTER_FROM}</font>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<img src="images/posticon.gif"><font style="{font-size: 8pt;}">{L_POSTED}: {POST_DATE}</font><hr>
|
<img src="images/posticon.gif"><font style="{font-size: 8pt;}">{postrow.L_POSTED}: {postrow.POST_DATE}</font><hr>
|
||||||
{MESSAGE}<hr>
|
{postrow.MESSAGE}<hr>
|
||||||
{PROFILE_IMG} {EMAIL_IMG} {WWW_IMG} {ICQ_STATUS_IMG} {ICQ_ADD_IMG} {AIM_IMG} {YIM_IMG} {MSN_IMG} <img src="images/div.gif"> {EDIT_IMG} {QUOTE_IMG} {PMSG_IMG} <img src="images/div.gif"> {IP_IMG} {DELPOST_IMG}
|
{postrow.PROFILE_IMG} {postrow.EMAIL_IMG} {postrow.WWW_IMG} {postrow.ICQ_STATUS_IMG} {postrow.ICQ_ADD_IMG} {postrow.AIM_IMG} {postrow.YIM_IMG} {postrow.MSN_IMG} <img src="images/div.gif"> {postrow.EDIT_IMG} {postrow.QUOTE_IMG} {postrow.PMSG_IMG} <img src="images/div.gif"> {postrow.IP_IMG} {postrow.DELPOST_IMG}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- END postrow -->
|
<!-- END postrow -->
|
||||||
|
|
|
@ -74,7 +74,6 @@ for($x = 0; $x < $db->sql_numrows($result); $x++)
|
||||||
|
|
||||||
include('includes/page_header.'.$phpEx);
|
include('includes/page_header.'.$phpEx);
|
||||||
|
|
||||||
$template->set_block("body", "topicrow", "topics");
|
|
||||||
|
|
||||||
if(!isset($start))
|
if(!isset($start))
|
||||||
{
|
{
|
||||||
|
@ -137,7 +136,7 @@ if($total_topics)
|
||||||
$last_post_time = date($date_format, $topic_rowset[$x]["post_time"]);
|
$last_post_time = date($date_format, $topic_rowset[$x]["post_time"]);
|
||||||
$last_post_user = $topic_rowset[$x]["user2"];
|
$last_post_user = $topic_rowset[$x]["user2"];
|
||||||
$folder_img = "<img src=\"images/folder.gif\">";
|
$folder_img = "<img src=\"images/folder.gif\">";
|
||||||
$template->set_var(array("FORUM_ID" => $forum_id,
|
$template->assign_block_vars("topicrow", array("FORUM_ID" => $forum_id,
|
||||||
"POST_TOPIC_URL" => POST_TOPIC_URL,
|
"POST_TOPIC_URL" => POST_TOPIC_URL,
|
||||||
"TOPIC_ID" => $topic_id,
|
"TOPIC_ID" => $topic_id,
|
||||||
"FOLDER" => $folder_img,
|
"FOLDER" => $folder_img,
|
||||||
|
@ -147,8 +146,8 @@ if($total_topics)
|
||||||
"TOPIC_TITLE" => $topic_title,
|
"TOPIC_TITLE" => $topic_title,
|
||||||
"VIEWS" => $views,
|
"VIEWS" => $views,
|
||||||
"LAST_POST" => $last_post_time . "<br><a href=\"profile.$phpEx?mode=viewprofile?user_id=".$topic_rowset[$x]["id2"]."\">" . $last_post_user ."</a>"));
|
"LAST_POST" => $last_post_time . "<br><a href=\"profile.$phpEx?mode=viewprofile?user_id=".$topic_rowset[$x]["id2"]."\">" . $last_post_user ."</a>"));
|
||||||
$template->parse("topics", "topicrow", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$count = 1;
|
$count = 1;
|
||||||
$next = $start + $topics_per_page;
|
$next = $start + $topics_per_page;
|
||||||
if($topics_count > $topics_per_page)
|
if($topics_count > $topics_per_page)
|
||||||
|
@ -177,8 +176,8 @@ if($total_topics)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$template->set_var(array("PAGINATION" => $pagination));
|
$template->assign_vars(array("PAGINATION" => $pagination));
|
||||||
$template->pparse("output", array("topics", "body"));
|
$template->pparse("body");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -104,8 +104,6 @@ if(!$total_posts = $db->sql_numrows($result))
|
||||||
}
|
}
|
||||||
$postrow = $db->sql_fetchrowset($result);
|
$postrow = $db->sql_fetchrowset($result);
|
||||||
|
|
||||||
$template->set_block("body", "postrow", "posts");
|
|
||||||
|
|
||||||
for($x = 0; $x < $total_posts; $x++)
|
for($x = 0; $x < $total_posts; $x++)
|
||||||
{
|
{
|
||||||
$poster = stripslashes($postrow[$x]["username"]);
|
$poster = stripslashes($postrow[$x]["username"]);
|
||||||
|
@ -169,7 +167,7 @@ for($x = 0; $x < $total_posts; $x++)
|
||||||
|
|
||||||
$message = eregi_replace("\[addsig]$", "<BR>_________________<BR>" . stripslashes($postrow[$x]["user_sig"]), $message);
|
$message = eregi_replace("\[addsig]$", "<BR>_________________<BR>" . stripslashes($postrow[$x]["user_sig"]), $message);
|
||||||
|
|
||||||
$template->set_var(array("TOPIC_TITLE" => $topic_title,
|
$template->assign_block_vars("postrow", array("TOPIC_TITLE" => $topic_title,
|
||||||
"L_POSTED" => $l_posted,
|
"L_POSTED" => $l_posted,
|
||||||
"L_JOINED" => $l_joined,
|
"L_JOINED" => $l_joined,
|
||||||
"POSTER_NAME" => $poster,
|
"POSTER_NAME" => $poster,
|
||||||
|
@ -194,7 +192,6 @@ for($x = 0; $x < $total_posts; $x++)
|
||||||
"PMSG_IMG" => $pmsg_img,
|
"PMSG_IMG" => $pmsg_img,
|
||||||
"IP_IMG" => $ip_img,
|
"IP_IMG" => $ip_img,
|
||||||
"DELPOST_IMG" => $delpost_img));
|
"DELPOST_IMG" => $delpost_img));
|
||||||
$template->parse("posts", "postrow", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($total_replies > $posts_per_page)
|
if($total_replies > $posts_per_page)
|
||||||
|
@ -247,10 +244,11 @@ else
|
||||||
{
|
{
|
||||||
$pages = "1 page";
|
$pages = "1 page";
|
||||||
}
|
}
|
||||||
$template->set_var(array("PAGES" => $pages,
|
|
||||||
|
$template->assign_vars(array("PAGES" => $pages,
|
||||||
"PAGINATION" => $pagination));
|
"PAGINATION" => $pagination));
|
||||||
|
|
||||||
$template->pparse("output", array("posts", "body"));
|
$template->pparse("body");
|
||||||
|
|
||||||
include('includes/page_tail.'.$phpEx);
|
include('includes/page_tail.'.$phpEx);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue