Source: show.php
last updated: 5 Aug 2007author: KlenWell
note: the code has not yet been tested (I need to upgrade to the latest version before I'll be able to test it)
<?php
/**
* show.php refactored to controller model
*
* This is based on revision #637 (http://wush.net/trac/wikka/changeset/637)
*
* For more info, see http://wikkawiki.org/KlenWell
*
*
* @package Handlers
* @subpackage Page
* @version $Id$
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @filesource
*
* @uses Config::$anony_delete_own_comments
* @uses Config::$hide_comments
* @uses Wakka::Format()
* @uses Wakka::FormClose()
* @uses Wakka::FormOpen()
* @uses Wakka::GetConfigValue()
* @uses Wakka::GetPageTag()
* @uses Wakka::GetUser()
* @uses Wakka::GetUserName()
* @uses Wakka::HasAccess()
* @uses Wakka::Href()
* @uses Wakka::htmlspecialchars_ent()
* @uses Wakka::LoadComments()
* @uses Wakka::LoadPage()
* @uses Wakka::LoadUser()
* @uses Wakka::UserIsOwner()
*/
// *** Show Flags for Controller
$_SHOW['page_start'] = 0;
$_SHOW['no_access'] = 0;
$_SHOW['not_exists'] = 0;
$_SHOW['page_body'] = 0;
$_SHOW['revision_info'] = 0;
$_SHOW['revision_edit_form'] = 0;
$_SHOW['comments'] = 0;
$_SHOW['hidden_comments'] = 0;
$_SHOW['no_comments'] = 0;
$_SHOW['comment_form'] = 0;
$_SHOW['page_close'] = 0;
// *** HTML Blocks
$_HTML['page'] = '';
$_HTML['page_start'] = '';
$_HTML['no_access'] = '';
$_HTML['not_exists'] = '';
$_HTML['revision_info'] = '';
$_HTML['page_body'] = '';
$_HTML['revision_edit_form'] = '';
$_HTML['page_close_div'] = '';
$_HTML['comments_header'] = '';
$_HTML['comments'] = '';
$_HTML['comment_form'] = '';
$_HTML['hidden_comments'] = '';
$_HTML['page_close'] = '';
// *** displayComments function
function displayComments(&$obj, &$comments, $tag)
{
$current_user = $obj->GetUserName();
$is_owner = $obj->UserIsOwner();
$prev_level = null;
$threaded = 0;
if ($_SESSION['show_comments'][$tag] == COMMENT_ORDER_THREADED)
{
$threaded = 1;
}
?>
<div class="commentscontainer">
<?php
foreach ($comments as $comment)
{
# Handle legacy or non-threaded comments
if (!isset($comment['level']) || !$threaded)
{
$comment['level'] = 0;
}
# Keep track of closing <div> tags to effect nesting
if (isset($prev_level) && ($comment['level'] <= $prev_level))
{
for ($i=0; $i<$prev_level-$comment['level']+1; ++$i)
{
echo '</div><!--closing comment level '.$i.'-->'."\n";
}
}
# Alternate light/dark comment styles per level
$comment_class = '';
if ($comment['level'] % 2 == 1)
{
$comment_class = "comment-layout-1";
}
else
{
$comment_class = "comment-layout-2";
}
if ($comment['status'] == 'deleted') {
?>
<div class="<?php echo $comment_class ?>">
<div class="commentdeleted"><?php echo COMMENT_DELETED_LABEL ?></div>
<?php
}
else
{
# Some stats
$comment_author = $obj->FormatUser($comment['user']);
//$comment_author = $obj->LoadUser($comment['user'])? $obj->Format($comment['user']) : $comment['user'];
$comment_ts = sprintf(COMMENT_TIME_CAPTION,$comment['time']);
?>
<div id="comment_<?php echo $comment['id'] ?>" class="<?php echo $comment_class ?>" >
<div class="commentheader">
<div class="commentauthor"><?php echo COMMENT_BY_LABEL.$comment_author ?></div>
<div class="commentinfo"><?php echo $comment_ts ?></div>
</div>
<div class="commentbody">
<?php echo $comment['comment'] ?>
</div>
<?php
if ($obj->HasAccess('comment_post'))
{
echo '<div class="commentaction">';
echo $obj->FormOpen("processcomment");
?>
<input type="hidden" name="comment_id" value="<?php echo $comment['id'] ?>" />
<?php
?>
<input type="submit" name="submit" value="<?php echo COMMENT_REPLY_BUTTON ?>" />
<?php
$user = $obj->GetUser();
if (isset($user))
{
$name = $user['name'];
}
if ($is_owner || $name == $comment['user'] || ($obj->config['anony_delete_own_comments'] && $current_user == $comment['user']))
{
?>
<input type="submit" name="submit" value="<?php echo COMMENT_DELETE_BUTTON ?>" />
<?php
}
echo $obj->FormClose();
echo "</div>";
}
}
$prev_level = $comment['level'];
}
for ($i=0; $i<$prev_level+1; ++$i)
{
print '</div><!--closing comment level (end)-->'."\n";
}
?>
</div>
<?php
}
// *** Controller
// Default Shows
$_SHOW['page_start'] = 1;
$_SHOW['page_close'] = 1;
// Has Page Access
if (!$this->HasAccess('read'))
{
$_SHOW['no_access'] = 1;
}
// Page Exists
if ( !$this->page )
{
$_SHOW['not_exists'] = 1;
}
else
{
$_SHOW['page_body'] = 1;
}
// As Revision
if ($this->page['latest'] == 'N')
{
$_SHOW['revision_info'] = 1;
}
// Revision w/ write access
if ( ($this->page['latest'] == 'N' && $this->HasAccess('write')) && ($latest = $this->LoadPage($this->tag)) )
{
$_SHOW['revision_edit_form'] = 1;
}
// Show Comment Form
if ( $this->GetConfigValue('hide_comments') != 1 )
{
// get page tag
$tag = $this->GetPageTag();
// session settings?
if ( !isset($_SESSION['show_comments'][$tag]) && $this->UserWantsComments($tag) !== FALSE )
{
$_SESSION['show_comments'][$tag] = $this->UserWantsComments($tag);
}
// GET setting takes precedence
if ( isset($_GET['show_comments']) ) #312
{
switch($_GET['show_comments'])
{
case COMMENT_NO_DISPLAY:
$_SESSION['show_comments'][$tag] = COMMENT_NO_DISPLAY;
break;
case COMMENT_ORDER_DATE_ASC:
$_SESSION['show_comments'][$tag] = COMMENT_ORDER_DATE_ASC;
break;
case COMMENT_ORDER_DATE_DESC:
$_SESSION['show_comments'][$tag] = COMMENT_ORDER_DATE_DESC;
break;
case COMMENT_ORDER_THREADED:
$_SESSION['show_comments'][$tag] = COMMENT_ORDER_THREADED;
break;
}
}
if ( isset($_SESSION['show_comments'][$tag]) && ($_SESSION['show_comments'][$tag] != COMMENT_NO_DISPLAY) )
{
$_SHOW['comment_form'] = 1;
}
else
{
$_SHOW['hidden_comments'] = 1;
}
}
// Show Comments?
$comments = $this->LoadComments($this->tag);
if ( $_SESSION['show_comments'][$tag] && $comments )
{
$_SHOW['comments'] = 1;
}
// Comment Post?
if ( $this->HasAccess('comment_post') )
{
$_SHOW['comment_post'] = 1;
}
// *** Viewer Blocks
// Page Start
if ( $_SHOW['page_start'] )
{
$_js = ( ($user = $this->GetUser()) && ($user['doubleclickedit'] == 'N') || !$this->HasAccess('write') ) ? '' : 'ondblclick="document.location=\''.$this->Href('edit').'\';" ';
$_HTML['page_start'] = <<<HTML
<!--starting page content-->
<div class="page" {$_js }>
HTML;
}
// Generic
if ( $_SHOW['no_access'] )
{
$inner = '<p><em class="error">'.WIKKA_ERROR_ACL_READ.'</em></p>';
$_HTML['no_access'] = <<<HTML
$inner
</div>
<!--closing page content-->
HTML;
}
// Page does not exist yet
if ( $_SHOW['not_exists'] )
{
$createlink = '<a href="'.$this->Href('edit').'">'.WIKKA_PAGE_CREATE_LINK_DESC.'</a>';
$inner = '<p>'.sprintf(SHOW_ASK_CREATE_PAGE_CAPTION,$createlink).'</p>';
$_HTML['not_exists'] = <<<HTML
$inner
</div>
<!--closing page content-->
HTML;
}
// Revision Info
if ( $_SHOW['revision_info'] )
{
$pagelink = '<a href="'.$this->Href().'">'.$this->tag.'</a>';
$inner = '<div class="revisioninfo">'.sprintf(SHOW_OLD_REVISION_CAPTION,$pagelink,$this->Link($this->tag, 'revisions', $this->page['time']));
$_HTML['revision_info'] = <<<HTML
$inner
</div>
HTML;
}
// Page Body
if ( $_SHOW['page_body'] )
{
$_HTML['page_body'] = $this->Format($this->page['body'], 'wakka', 'page');
$_HTML['page_close_div'] = "\n".'</div><!--closing page content-->'."\n\n";
}
// Revision Edit Form
if ( $_SHOW['revision_edit_form'] )
{
$form_start = $this->FormOpen('edit');
$lid = $latest['id'];
$hvalue = $this->htmlspecialchars_ent($this->page['body']);
$svalue = SHOW_RE_EDIT_BUTTON;
$form_close = $this->FormClose();
$_HTML['revision_edit_form'] = <<<HTML
<br />
$form_start
<input type="hidden" name="previous" value="$lid" />
<input type="hidden" name="body" value="$hvalue" />
<input type="submit" value="$svalue" />
$form_close
HTML;
}
// Comments Header and Form
if ( $_SHOW['comment_form'] )
{
$href = $this->Href('', '', 'show_comments=0');
$_HTML['comments_header'] = <<<HTML
<div class="commentsheader">
<span id="comments"> </span>Comments [<a href="$href">Hide comments/form</a>]
</div>
HTML;
$form_start = $this->FormOpen('addcomment');
$form_close = $this->FormClose();
$_HTML['comment_form'] = <<<HTML
<div class="commentform">
$form_start
<label for="commentbox">Add a comment to this page:<br />
<textarea id="commentbox" name="body" rows="6" cols="78"></textarea><br />
<input type="submit" value="Add Comment" accesskey="s" />
</label>
$form_close
</div>
HTML;
}
// comments themselves
if ( $_SHOW['comments'] )
{
$comment_stack = '';
$current_user = $this->GetUserName();
$display_mode = $_SESSION['show_comments'][$tag];
// icons
$sort_desc_icon_url = StaticHref('images/icons/sort_desc.gif');
$sort_ascc_icon_url = StaticHref('images/icons/sort_asc.gif');
$sort_comment_icon_url = StaticHref('images/icons/comment.gif');
// comments header
$inner = '<a href="' . $this->Href('', '', 'show_comments='.COMMENT_ORDER_DATE_DESC.'#comments') . '"><img class="'.($display_mode==COMMENT_ORDER_DATE_DESC ? "icon_on" : "icon").'" alt="flat" title="Flat (newest first)" src="'.$sort_desc_icon_url.'" /></a>';
$inner .= '<a href="' . $this->Href('', '', 'show_comments='.COMMENT_ORDER_DATE_ASC.'#comments') . '"><img class="'.($display_mode==COMMENT_ORDER_DATE_ASC ? "icon_on" : "icon").'" alt="flat" title="Flat (oldest first)" src="'.$sort_asc_icon_url.'" /></a>';
$inner .= '<a href="' . $this->Href('', '', 'show_comments='.COMMENT_ORDER_THREADED.'#comments') . '"><img class="'.($display_mode==COMMENT_ORDER_THREADED ? "icon_on" : "icon").'" alt="threaded" title="Threaded" src="'.$sort_comment_icon_url.'" /></a>';
$inner2 = COMMENTS_CAPTION;
$inner3 = '[<a href="' . $this->Href('', '', 'show_comments='.COMMENT_NO_DISPLAY) . '">' . HIDE_COMMENTS_LINK_DESC . '</a>]';
// comment post
if ( $_SHOW['comment_post'] )
{
$form1 = $this->FormOpen('processcomment');
$svalue = COMMENT_NEW_BUTTON;
$form2 = $this->FormClose();
$_HTML['comment_post'] = <<<HTML
$form1
<input type="submit" name="submit" value="$svalue" />
$form2
HTML;
}
$_HTML['comments_header'] = <<<HTML
<!--starting comments header (show)-->
<div class="commentsheader">
<div id="commentsnav">
$inner
</div>
<!-- closing commentsnav div -->
$inner2
$inner3
{$_HTML['comment_post']}
</div>
<!--closing commentsheader (show)-->
HTML;
// a very ugly hack
if ( $comments )
{
ob_start();
displayComments($this, $comments, $tag);
$_HTML['comments'] = ob_get_flush();
#echo "<pre>{$_HTML['comments']}</pre>"; # debug
}
}
// hidden comments
if ( $_SHOW['hidden_comments'] )
{
$showcomments_text = '';
$commentCount = $this->CountComments($this->tag);
switch ( $commentCount )
{
case 0:
$comments_message = STATUS_NO_COMMENTS.' ';
if ($this->HasAccess('comment_post'))
{
$showcomments_text = $this->FormOpen("processcomment");
$showcomments_text .= '<input type="submit" name="submit" value="'.COMMENT_NEW_BUTTON.'" />';
$showcomments_text .= $this->FormClose();
}
break;
case 1:
$comments_message = STATUS_ONE_COMMENT.' ';
$showcomments_text = '[<a href="'.$this->Href('', '', 'show_comments=1#comments').'">'.DISPLAY_COMMENT_LINK_DESC.'</a>]';
break;
default:
$comments_message = sprintf(STATUS_SOME_COMMENTS, $commentCount).' ';
$comment_ordering = NULL;
if (isset($user['default_comment_display']))
{
$comment_ordering = $user['default_comment_display'];
}
elseif (NULL !== $this->GetConfigValue('default_comment_display'))
{
$comment_ordering = $this->GetConfigValue('default_comment_display');
}
else
{
$comment_ordering = COMMENT_ORDER_DATE_ASC;
}
$showcomments_text = '[<a href="'.$this->Href('', '', 'show_comments='.$comment_ordering.'#comments').'">'.DISPLAY_COMMENTS_LABEL.'</a>]';
}
$_HTML['hidden_comments'] = <<<HTML
<!--starting comments header (hide)-->
<div class="commentsheader">
$comments_message
$showcomments_text
</div>
<!--closing comments block-->
HTML;
}
// Page Close
if ( $_SHOW['page_close'] )
{
$_HTML['page_close'] = <<<HTML
</div>
<!--closing page content-->
HTML;
}
// End Viewer Blocks
// *** TEMPLATE: stitch it all together
require_once('show.tpl.php');
echo $_HTML['page'];
?>
/**
* show.php refactored to controller model
*
* This is based on revision #637 (http://wush.net/trac/wikka/changeset/637)
*
* For more info, see http://wikkawiki.org/KlenWell
*
*
* @package Handlers
* @subpackage Page
* @version $Id$
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @filesource
*
* @uses Config::$anony_delete_own_comments
* @uses Config::$hide_comments
* @uses Wakka::Format()
* @uses Wakka::FormClose()
* @uses Wakka::FormOpen()
* @uses Wakka::GetConfigValue()
* @uses Wakka::GetPageTag()
* @uses Wakka::GetUser()
* @uses Wakka::GetUserName()
* @uses Wakka::HasAccess()
* @uses Wakka::Href()
* @uses Wakka::htmlspecialchars_ent()
* @uses Wakka::LoadComments()
* @uses Wakka::LoadPage()
* @uses Wakka::LoadUser()
* @uses Wakka::UserIsOwner()
*/
// *** Show Flags for Controller
$_SHOW['page_start'] = 0;
$_SHOW['no_access'] = 0;
$_SHOW['not_exists'] = 0;
$_SHOW['page_body'] = 0;
$_SHOW['revision_info'] = 0;
$_SHOW['revision_edit_form'] = 0;
$_SHOW['comments'] = 0;
$_SHOW['hidden_comments'] = 0;
$_SHOW['no_comments'] = 0;
$_SHOW['comment_form'] = 0;
$_SHOW['page_close'] = 0;
// *** HTML Blocks
$_HTML['page'] = '';
$_HTML['page_start'] = '';
$_HTML['no_access'] = '';
$_HTML['not_exists'] = '';
$_HTML['revision_info'] = '';
$_HTML['page_body'] = '';
$_HTML['revision_edit_form'] = '';
$_HTML['page_close_div'] = '';
$_HTML['comments_header'] = '';
$_HTML['comments'] = '';
$_HTML['comment_form'] = '';
$_HTML['hidden_comments'] = '';
$_HTML['page_close'] = '';
// *** displayComments function
function displayComments(&$obj, &$comments, $tag)
{
$current_user = $obj->GetUserName();
$is_owner = $obj->UserIsOwner();
$prev_level = null;
$threaded = 0;
if ($_SESSION['show_comments'][$tag] == COMMENT_ORDER_THREADED)
{
$threaded = 1;
}
?>
<div class="commentscontainer">
<?php
foreach ($comments as $comment)
{
# Handle legacy or non-threaded comments
if (!isset($comment['level']) || !$threaded)
{
$comment['level'] = 0;
}
# Keep track of closing <div> tags to effect nesting
if (isset($prev_level) && ($comment['level'] <= $prev_level))
{
for ($i=0; $i<$prev_level-$comment['level']+1; ++$i)
{
echo '</div><!--closing comment level '.$i.'-->'."\n";
}
}
# Alternate light/dark comment styles per level
$comment_class = '';
if ($comment['level'] % 2 == 1)
{
$comment_class = "comment-layout-1";
}
else
{
$comment_class = "comment-layout-2";
}
if ($comment['status'] == 'deleted') {
?>
<div class="<?php echo $comment_class ?>">
<div class="commentdeleted"><?php echo COMMENT_DELETED_LABEL ?></div>
<?php
}
else
{
# Some stats
$comment_author = $obj->FormatUser($comment['user']);
//$comment_author = $obj->LoadUser($comment['user'])? $obj->Format($comment['user']) : $comment['user'];
$comment_ts = sprintf(COMMENT_TIME_CAPTION,$comment['time']);
?>
<div id="comment_<?php echo $comment['id'] ?>" class="<?php echo $comment_class ?>" >
<div class="commentheader">
<div class="commentauthor"><?php echo COMMENT_BY_LABEL.$comment_author ?></div>
<div class="commentinfo"><?php echo $comment_ts ?></div>
</div>
<div class="commentbody">
<?php echo $comment['comment'] ?>
</div>
<?php
if ($obj->HasAccess('comment_post'))
{
echo '<div class="commentaction">';
echo $obj->FormOpen("processcomment");
?>
<input type="hidden" name="comment_id" value="<?php echo $comment['id'] ?>" />
<?php
?>
<input type="submit" name="submit" value="<?php echo COMMENT_REPLY_BUTTON ?>" />
<?php
$user = $obj->GetUser();
if (isset($user))
{
$name = $user['name'];
}
if ($is_owner || $name == $comment['user'] || ($obj->config['anony_delete_own_comments'] && $current_user == $comment['user']))
{
?>
<input type="submit" name="submit" value="<?php echo COMMENT_DELETE_BUTTON ?>" />
<?php
}
echo $obj->FormClose();
echo "</div>";
}
}
$prev_level = $comment['level'];
}
for ($i=0; $i<$prev_level+1; ++$i)
{
print '</div><!--closing comment level (end)-->'."\n";
}
?>
</div>
<?php
}
// *** Controller
// Default Shows
$_SHOW['page_start'] = 1;
$_SHOW['page_close'] = 1;
// Has Page Access
if (!$this->HasAccess('read'))
{
$_SHOW['no_access'] = 1;
}
// Page Exists
if ( !$this->page )
{
$_SHOW['not_exists'] = 1;
}
else
{
$_SHOW['page_body'] = 1;
}
// As Revision
if ($this->page['latest'] == 'N')
{
$_SHOW['revision_info'] = 1;
}
// Revision w/ write access
if ( ($this->page['latest'] == 'N' && $this->HasAccess('write')) && ($latest = $this->LoadPage($this->tag)) )
{
$_SHOW['revision_edit_form'] = 1;
}
// Show Comment Form
if ( $this->GetConfigValue('hide_comments') != 1 )
{
// get page tag
$tag = $this->GetPageTag();
// session settings?
if ( !isset($_SESSION['show_comments'][$tag]) && $this->UserWantsComments($tag) !== FALSE )
{
$_SESSION['show_comments'][$tag] = $this->UserWantsComments($tag);
}
// GET setting takes precedence
if ( isset($_GET['show_comments']) ) #312
{
switch($_GET['show_comments'])
{
case COMMENT_NO_DISPLAY:
$_SESSION['show_comments'][$tag] = COMMENT_NO_DISPLAY;
break;
case COMMENT_ORDER_DATE_ASC:
$_SESSION['show_comments'][$tag] = COMMENT_ORDER_DATE_ASC;
break;
case COMMENT_ORDER_DATE_DESC:
$_SESSION['show_comments'][$tag] = COMMENT_ORDER_DATE_DESC;
break;
case COMMENT_ORDER_THREADED:
$_SESSION['show_comments'][$tag] = COMMENT_ORDER_THREADED;
break;
}
}
if ( isset($_SESSION['show_comments'][$tag]) && ($_SESSION['show_comments'][$tag] != COMMENT_NO_DISPLAY) )
{
$_SHOW['comment_form'] = 1;
}
else
{
$_SHOW['hidden_comments'] = 1;
}
}
// Show Comments?
$comments = $this->LoadComments($this->tag);
if ( $_SESSION['show_comments'][$tag] && $comments )
{
$_SHOW['comments'] = 1;
}
// Comment Post?
if ( $this->HasAccess('comment_post') )
{
$_SHOW['comment_post'] = 1;
}
// *** Viewer Blocks
// Page Start
if ( $_SHOW['page_start'] )
{
$_js = ( ($user = $this->GetUser()) && ($user['doubleclickedit'] == 'N') || !$this->HasAccess('write') ) ? '' : 'ondblclick="document.location=\''.$this->Href('edit').'\';" ';
$_HTML['page_start'] = <<<HTML
<!--starting page content-->
<div class="page" {$_js }>
HTML;
}
// Generic
if ( $_SHOW['no_access'] )
{
$inner = '<p><em class="error">'.WIKKA_ERROR_ACL_READ.'</em></p>';
$_HTML['no_access'] = <<<HTML
$inner
</div>
<!--closing page content-->
HTML;
}
// Page does not exist yet
if ( $_SHOW['not_exists'] )
{
$createlink = '<a href="'.$this->Href('edit').'">'.WIKKA_PAGE_CREATE_LINK_DESC.'</a>';
$inner = '<p>'.sprintf(SHOW_ASK_CREATE_PAGE_CAPTION,$createlink).'</p>';
$_HTML['not_exists'] = <<<HTML
$inner
</div>
<!--closing page content-->
HTML;
}
// Revision Info
if ( $_SHOW['revision_info'] )
{
$pagelink = '<a href="'.$this->Href().'">'.$this->tag.'</a>';
$inner = '<div class="revisioninfo">'.sprintf(SHOW_OLD_REVISION_CAPTION,$pagelink,$this->Link($this->tag, 'revisions', $this->page['time']));
$_HTML['revision_info'] = <<<HTML
$inner
</div>
HTML;
}
// Page Body
if ( $_SHOW['page_body'] )
{
$_HTML['page_body'] = $this->Format($this->page['body'], 'wakka', 'page');
$_HTML['page_close_div'] = "\n".'</div><!--closing page content-->'."\n\n";
}
// Revision Edit Form
if ( $_SHOW['revision_edit_form'] )
{
$form_start = $this->FormOpen('edit');
$lid = $latest['id'];
$hvalue = $this->htmlspecialchars_ent($this->page['body']);
$svalue = SHOW_RE_EDIT_BUTTON;
$form_close = $this->FormClose();
$_HTML['revision_edit_form'] = <<<HTML
<br />
$form_start
<input type="hidden" name="previous" value="$lid" />
<input type="hidden" name="body" value="$hvalue" />
<input type="submit" value="$svalue" />
$form_close
HTML;
}
// Comments Header and Form
if ( $_SHOW['comment_form'] )
{
$href = $this->Href('', '', 'show_comments=0');
$_HTML['comments_header'] = <<<HTML
<div class="commentsheader">
<span id="comments"> </span>Comments [<a href="$href">Hide comments/form</a>]
</div>
HTML;
$form_start = $this->FormOpen('addcomment');
$form_close = $this->FormClose();
$_HTML['comment_form'] = <<<HTML
<div class="commentform">
$form_start
<label for="commentbox">Add a comment to this page:<br />
<textarea id="commentbox" name="body" rows="6" cols="78"></textarea><br />
<input type="submit" value="Add Comment" accesskey="s" />
</label>
$form_close
</div>
HTML;
}
// comments themselves
if ( $_SHOW['comments'] )
{
$comment_stack = '';
$current_user = $this->GetUserName();
$display_mode = $_SESSION['show_comments'][$tag];
// icons
$sort_desc_icon_url = StaticHref('images/icons/sort_desc.gif');
$sort_ascc_icon_url = StaticHref('images/icons/sort_asc.gif');
$sort_comment_icon_url = StaticHref('images/icons/comment.gif');
// comments header
$inner = '<a href="' . $this->Href('', '', 'show_comments='.COMMENT_ORDER_DATE_DESC.'#comments') . '"><img class="'.($display_mode==COMMENT_ORDER_DATE_DESC ? "icon_on" : "icon").'" alt="flat" title="Flat (newest first)" src="'.$sort_desc_icon_url.'" /></a>';
$inner .= '<a href="' . $this->Href('', '', 'show_comments='.COMMENT_ORDER_DATE_ASC.'#comments') . '"><img class="'.($display_mode==COMMENT_ORDER_DATE_ASC ? "icon_on" : "icon").'" alt="flat" title="Flat (oldest first)" src="'.$sort_asc_icon_url.'" /></a>';
$inner .= '<a href="' . $this->Href('', '', 'show_comments='.COMMENT_ORDER_THREADED.'#comments') . '"><img class="'.($display_mode==COMMENT_ORDER_THREADED ? "icon_on" : "icon").'" alt="threaded" title="Threaded" src="'.$sort_comment_icon_url.'" /></a>';
$inner2 = COMMENTS_CAPTION;
$inner3 = '[<a href="' . $this->Href('', '', 'show_comments='.COMMENT_NO_DISPLAY) . '">' . HIDE_COMMENTS_LINK_DESC . '</a>]';
// comment post
if ( $_SHOW['comment_post'] )
{
$form1 = $this->FormOpen('processcomment');
$svalue = COMMENT_NEW_BUTTON;
$form2 = $this->FormClose();
$_HTML['comment_post'] = <<<HTML
$form1
<input type="submit" name="submit" value="$svalue" />
$form2
HTML;
}
$_HTML['comments_header'] = <<<HTML
<!--starting comments header (show)-->
<div class="commentsheader">
<div id="commentsnav">
$inner
</div>
<!-- closing commentsnav div -->
$inner2
$inner3
{$_HTML['comment_post']}
</div>
<!--closing commentsheader (show)-->
HTML;
// a very ugly hack
if ( $comments )
{
ob_start();
displayComments($this, $comments, $tag);
$_HTML['comments'] = ob_get_flush();
#echo "<pre>{$_HTML['comments']}</pre>"; # debug
}
}
// hidden comments
if ( $_SHOW['hidden_comments'] )
{
$showcomments_text = '';
$commentCount = $this->CountComments($this->tag);
switch ( $commentCount )
{
case 0:
$comments_message = STATUS_NO_COMMENTS.' ';
if ($this->HasAccess('comment_post'))
{
$showcomments_text = $this->FormOpen("processcomment");
$showcomments_text .= '<input type="submit" name="submit" value="'.COMMENT_NEW_BUTTON.'" />';
$showcomments_text .= $this->FormClose();
}
break;
case 1:
$comments_message = STATUS_ONE_COMMENT.' ';
$showcomments_text = '[<a href="'.$this->Href('', '', 'show_comments=1#comments').'">'.DISPLAY_COMMENT_LINK_DESC.'</a>]';
break;
default:
$comments_message = sprintf(STATUS_SOME_COMMENTS, $commentCount).' ';
$comment_ordering = NULL;
if (isset($user['default_comment_display']))
{
$comment_ordering = $user['default_comment_display'];
}
elseif (NULL !== $this->GetConfigValue('default_comment_display'))
{
$comment_ordering = $this->GetConfigValue('default_comment_display');
}
else
{
$comment_ordering = COMMENT_ORDER_DATE_ASC;
}
$showcomments_text = '[<a href="'.$this->Href('', '', 'show_comments='.$comment_ordering.'#comments').'">'.DISPLAY_COMMENTS_LABEL.'</a>]';
}
$_HTML['hidden_comments'] = <<<HTML
<!--starting comments header (hide)-->
<div class="commentsheader">
$comments_message
$showcomments_text
</div>
<!--closing comments block-->
HTML;
}
// Page Close
if ( $_SHOW['page_close'] )
{
$_HTML['page_close'] = <<<HTML
</div>
<!--closing page content-->
HTML;
}
// End Viewer Blocks
// *** TEMPLATE: stitch it all together
require_once('show.tpl.php');
echo $_HTML['page'];
?>
source: show.tpl.php
<?php
/* wikka page template
don't remove any of the $_HTML array elements below, but feel free to move them
around and add wrapper classes as you see fit
Full List of $_HTML elements from show.php in template:
{$_HTML['page_start']}
{$_HTML['no_access']}
{$_HTML['not_exists']}
{$_HTML['revision_info']}
{$_HTML['page_body']}
{$_HTML['revision_edit_form']}
{$_HTML['page_close_div']}
{$_HTML['comments_header']}
{$_HTML['comments']}
{$_HTML['comment_form']}
{$_HTML['hidden_comments']}
{$_HTML['page_close']}
*/
$_HTML['page'] = <<<HTML
{$_HTML['page_start']}
{$_HTML['no_access']}
{$_HTML['not_exists']}
{$_HTML['revision_info']}
{$_HTML['page_body']}
{$_HTML['revision_edit_form']}
<div id="comment_stack">
{$_HTML['comments_header']}
{$_HTML['comments']}
{$_HTML['comment_form']}
{$_HTML['hidden_comments']}
</div>
{$_HTML['page_close_div']}
{$_HTML['page_close']}
HTML;
?>
/* wikka page template
don't remove any of the $_HTML array elements below, but feel free to move them
around and add wrapper classes as you see fit
Full List of $_HTML elements from show.php in template:
{$_HTML['page_start']}
{$_HTML['no_access']}
{$_HTML['not_exists']}
{$_HTML['revision_info']}
{$_HTML['page_body']}
{$_HTML['revision_edit_form']}
{$_HTML['page_close_div']}
{$_HTML['comments_header']}
{$_HTML['comments']}
{$_HTML['comment_form']}
{$_HTML['hidden_comments']}
{$_HTML['page_close']}
*/
$_HTML['page'] = <<<HTML
{$_HTML['page_start']}
{$_HTML['no_access']}
{$_HTML['not_exists']}
{$_HTML['revision_info']}
{$_HTML['page_body']}
{$_HTML['revision_edit_form']}
<div id="comment_stack">
{$_HTML['comments_header']}
{$_HTML['comments']}
{$_HTML['comment_form']}
{$_HTML['hidden_comments']}
</div>
{$_HTML['page_close_div']}
{$_HTML['page_close']}
HTML;
?>