=====Source: show.php===== author: KlenWell %%(php) to template; * @todo replace $_REQUEST with either $_GET or $_POST (or both if really * necessary) - #312 */ // *** 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'] = ''; // *** 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]) ) { $_SESSION['show_comments'][$tag] = ($this->UserWantsComments() ? '1' : '0'); } // GET setting takes precedence if ( isset($_GET['show_comments']) ) #312 { if ( $_GET['show_comments'] == 0 ) { $_SESSION['show_comments'][$tag] = 0; } elseif ( $_GET['show_comments'] == 1 ) { $_SESSION['show_comments'][$tag] = 1; } } if ($_SESSION['show_comments'][$tag]) { $_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; } // *** 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; } // Generic if ( $_SHOW['no_access'] ) { $_HTML['no_access'] = <<You aren't allowed to read this page.

HTML; } // Page does not exist yet if ( $_SHOW['not_exists'] ) { $_HTML['not_exists'] = <<This page doesn't exist yet. Maybe you want to create it?

HTML; } // Revision Info if ( $_SHOW['revision_info'] ) { $href = $this->Href(); $alabel = $this->GetPageTag(); $ptime = $this->page['time']; $_HTML['revision_info'] = << This is an old revision of {$alabel} from {$ptime} HTML; } // Page Body if ( $_SHOW['page_body'] ) { $_HTML['page_body'] = $this->Format($this->page['body'], 'wakka'); $_HTML['page_close_div'] = "\n"; } // Revision Edit Form if ( $_SHOW['revision_edit_form'] ) { $form_start = $this->FormOpen('edit'); $lid = $latest['id']; $hvalue = $this->htmlspecialchars_ent($this->page['body']); $form_close = $this->FormClose(); $_HTML['revision_edit_form'] = << $form_start $form_close HTML; } // Comments Header and Form if ( $_SHOW['comment_form'] ) { $href = $this->Href('', '', 'show_comments=0'); $_HTML['comments_header'] = <<  Comments [Hide comments/form] HTML; $form_start = $this->FormOpen('addcomment'); $form_close = $this->FormClose(); $_HTML['comment_form'] = << $form_start $form_close HTML; } // comments themselves if ( $_SHOW['comments'] ) { $current_user = $this->GetUserName(); $comment_stack = ''; foreach ($comments as $comment) { $comment_stack .= '
'."\n"; $comment_stack .= ''.$comment['comment']."\n"; $comment_stack .= "\t".'
'."\n-- "; $comment_stack .= ( $this->LoadUser($comment['user']) ) ? $this->Format($comment['user']) : $comment['user']; $comment_stack .= ' ('.$comment['time'].')'."\n"; // does comment get delete form? if ($this->UserIsOwner() || $current_user == $comment['user'] || ($this->config['anony_delete_own_comments'] && $current_user == $comment['user']) ) { $comment_stack .= $this->FormOpen("delcomment"); $comment_stack .= ''; $comment_stack .= ''; $comment_stack .= $this->FormClose(); } $comment_stack .= "\n\t".'
'."\n"; $comment_stack .= '
'."\n"; } $_HTML['comments'] = $comment_stack; } // hidden comments if ( $_SHOW['hidden_comments'] ) { switch (count($comments)) { case 0: $comment_count = '

There are no comments on this page. '; $showcomments_text = 'Add comment'; break; case 1: $comment_count = '

There is one comment on this page. '; $showcomments_text = 'Display comment'; break; default: $comment_count = '

There are '.count($comments).' comments on this page. '; $showcomments_text = 'Display comments'; } $href = $this->Href('', '', 'show_comments=1#comments'); $_HTML['hidden_comments'] = << $comment_count [$showcomments_text]

HTML; } // Page Close if ( $_SHOW['page_close'] ) { $_HTML['page_close'] = << HTML; } // End Viewer Blocks // *** TEMPLATE: stitch it all together $_HTML['page'] = << %%