1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

Fixes #594 - cpage_shortcodes notice. Also resolves long-standing conflict between page.php and other scripts using the same cpage shortcodes. These changes will require much testing. Added new chapter menu. (useful for menus on the Home page that link to chapters)

This commit is contained in:
Cameron
2014-06-13 03:39:41 -07:00
parent c3f986b77c
commit 8bb72d1d4c
6 changed files with 231 additions and 105 deletions

View File

@@ -15,12 +15,15 @@ if (!defined('e107_INIT')) { exit; }
* *
* Shortcodes for custom page display * Shortcodes for custom page display
*/ */
// XXX FIXME All shortcodes should return a value from $this->var.
class cpage_shortcodes extends e_shortcode class cpage_shortcodes extends e_shortcode
{ {
// var $var; // parsed DB values // var $var; // parsed DB values
private $chapterData = array(); private $chapterData = array();
// Works in 'magic' mode, so setting it breaks everything
//public $page = array();
// Grab all book/chapter data. // Grab all book/chapter data.
function __construct() function __construct()
{ {
@@ -34,11 +37,19 @@ class cpage_shortcodes extends e_shortcode
} }
} }
// Return data for a specific chapter-id // Set Chapter. // @see chapter_menu.php
public function setChapter($id)
{
$this->var['page_chapter'] = intval($id);
}
// Return data for a specific chapter-id - XXX @SecretR - without $page defined above, this will return nothing. All $this->var need to be replaced with $this->var
function getChapter() function getChapter()
{ {
$id = $this->page['page_chapter'];
$id = $this->var['page_chapter'];
if(vartrue($this->chapterData[$id]['chapter_id']) && $this->chapterData[$id]['chapter_parent'] > 0) if(vartrue($this->chapterData[$id]['chapter_id']) && $this->chapterData[$id]['chapter_parent'] > 0)
{ {
@@ -49,10 +60,13 @@ class cpage_shortcodes extends e_shortcode
// Return data for a specific book-id // Return data for a specific book-id
function getBook() function getBook($cid='')
{ {
$pid = $this->page['page_chapter']; if(empty($cid))
$cid = $this->chapterData[$pid]['chapter_parent']; {
$pid = $this->var['page_chapter'];
$cid = $this->chapterData[$pid]['chapter_parent'];
}
$row = $this->chapterData[$cid]; $row = $this->chapterData[$cid];
@@ -71,38 +85,38 @@ class cpage_shortcodes extends e_shortcode
function sc_cpagetitle($parm='') function sc_cpagetitle($parm='')
{ {
return e107::getParser()->toHTML($this->getParserVars()->title, true, 'TITLE'); return e107::getParser()->toHTML($this->var['page_title'], true, 'TITLE');
} }
function sc_cpagesubtitle() function sc_cpagesubtitle()
{ {
$subtitle = $this->getParserVars()->sub_title; $subtitle = $this->var['sub_title'];
return $subtitle ? e107::getParser()->toHTML($subtitle, true, 'TITLE') : ''; return $subtitle ? e107::getParser()->toHTML($subtitle, true, 'TITLE') : '';
} }
function sc_cpagebody($parm='') function sc_cpagebody($parm='')
{ {
// already parsed $text = $this->var['page_text'];
return $this->getParserVars()->text; return $text ? e107::getParser()->toHTML($text, true, 'BODY') : '';
} }
function sc_cpageauthor($parm) function sc_cpageauthor($parm)
{ {
$parms = eHelper::scParams($parm); $parms = eHelper::scParams($parm);
$author = ''; $author = '';
$url = e107::getUrl()->create('user/profile/view', array('name' => $this->page['user_name'], 'id' => $this->page['user_id'])); $url = e107::getUrl()->create('user/profile/view', array('name' => $this->var['user_name'], 'id' => $this->var['user_id']));
if(isset($parms['url'])) if(isset($parms['url']))
{ {
return $url; return $url;
} }
if($this->page['page_author']) if($this->var['page_author'])
{ {
// currently this field used as Real Name, no matter what the db name says // currently this field used as Real Name, no matter what the db name says
if($this->page['user_login'] && !isset($parms['user'])) $author = $this->page['user_login']; if($this->var['user_login'] && !isset($parms['user'])) $author = $this->var['user_login'];
elseif($this->page['user_name']) $author = preg_replace('/[^\w\pL\s]+/u', ' ', $this->page['user_name']); elseif($this->var['user_name']) $author = preg_replace('/[^\w\pL\s]+/u', ' ', $this->var['user_name']);
} }
if(empty($author)) return ''; if(empty($author)) return '';
@@ -121,44 +135,50 @@ class cpage_shortcodes extends e_shortcode
{ {
if(empty($parm)) if(empty($parm))
{ {
return e107::getDateConvert()->convert_date($this->page['page_datestamp'], 'long'); return e107::getDateConvert()->convert_date($this->var['page_datestamp'], 'long');
} }
return e107::getDateConvert()->convert_date($this->page['page_datestamp'], $parm); return e107::getDateConvert()->convert_date($this->var['page_datestamp'], $parm);
} }
function sc_cpageid() function sc_cpageid()
{ {
return $this->page['page_id']; return $this->var['page_id'];
} }
function sc_cpageanchor() function sc_cpageanchor()
{ {
$frm = e107::getForm(); return e107::getForm()->name2id($this->var['page_title']);
return $frm->name2id($this->page['page_title']);
} }
// Not a shortcode really, as it shouldn't be cached at all :/ // Not a shortcode really, as it shouldn't be cached at all :/
function cpagecomments() function cpagecomments()
{ {
$com = $this->getParserVars()->comments; $com = $this->var['comments'];
//if($parm && isset($com[$parm])) return $com[$parm]; //if($parm && isset($com[$parm])) return $com[$parm];
return $com['comment'].$com['comment_form']; return $com['comment'].$com['comment_form'];
} }
function sc_cpagenav() function sc_cpagenav()
{ {
return $this->getParserVars()->np; return $this->var['np'];
} }
function sc_cpagerating() function sc_cpagerating()
{ {
return $this->getParserVars()->rating; return $this->var['rating'];
} }
function sc_cpagemessage() function sc_cpagemessage()
{ {
return e107::getMessage()->render(); return e107::getMessage()->render();
} }
function sc_cpagemenu()
{
$parm = $this->var['menu_name'];
return e107::getMenu()->renderMenu($parm, false, false, true);
}
/** /**
* Auto-thumbnailing now allowed. * Auto-thumbnailing now allowed.
@@ -206,9 +226,9 @@ class cpage_shortcodes extends e_shortcode
function sc_cpageimage($parm = '') function sc_cpageimage($parm = '')
{ {
list($num,$size) = explode("|",$parm); list($num,$size) = explode("|",$parm);
if($this->page['page_images']) if($this->var['page_images'])
{ {
$img = explode(",",$this->page['page_images']); $img = explode(",",$this->var['page_images']);
} }
} }
@@ -233,7 +253,7 @@ class cpage_shortcodes extends e_shortcode
return $url; return $url;
} }
if(trim($this->page['page_text']) == '') // Hide the button when there is no page content. (avoids templates with and without buttons) if(trim($this->var['page_text']) == '') // Hide the button when there is no page content. (avoids templates with and without buttons)
{ {
return "<!-- Button Removed: No page text exists! -->"; return "<!-- Button Removed: No page text exists! -->";
} }
@@ -252,27 +272,27 @@ class cpage_shortcodes extends e_shortcode
{ {
$tp = e107::getParser(); $tp = e107::getParser();
// //
return $tp->toHTML($this->page['menu_title'], true, 'TITLE'); return $tp->toHTML($this->var['menu_title'], true, 'TITLE');
} }
function sc_cmenubody($parm='') function sc_cmenubody($parm='')
{ {
// print_a($this); // print_a($this);
return e107::getParser()->toHTML($this->page['menu_text'], true, 'BODY'); return e107::getParser()->toHTML($this->var['menu_text'], true, 'BODY');
} }
function sc_cmenuimage($parm='') function sc_cmenuimage($parm='')
{ {
$tp = e107::getParser(); $tp = e107::getParser();
if($video = $tp->toVideo($this->page['menu_image'])) if($video = $tp->toVideo($this->var['menu_image']))
{ {
return $video; return $video;
} }
$img = $tp->thumbUrl($this->page['menu_image']); $img = $tp->thumbUrl($this->var['menu_image']);
if($parm == 'url') if($parm == 'url')
{ {
return $img; return $img;
@@ -283,19 +303,19 @@ class cpage_shortcodes extends e_shortcode
function sc_cmenuicon($parm='') function sc_cmenuicon($parm='')
{ {
return e107::getParser()->toIcon($this->page['menu_icon'], array('space'=>' ')); return e107::getParser()->toIcon($this->var['menu_icon'], array('space'=>' '));
} }
function sc_cpageurl() function sc_cpageurl()
{ {
$route = ($this->page['page_chapter'] == 0) ? 'page/view/other' : 'page/view'; $route = ($this->var['page_chapter'] == 0) ? 'page/view/other' : 'page/view';
$urldata = $this->page; $urldata = $this->var;
if($this->page['page_chapter'] && $this->chapterData[$this->page['page_chapter']]) if($this->var['page_chapter'] && $this->chapterData[$this->var['page_chapter']])
{ {
$chapter = $this->chapterData[$this->page['page_chapter']]; $chapter = $this->chapterData[$this->var['page_chapter']];
$urldata = array_merge($this->page, $chapter); $urldata = array_merge($this->var, $chapter);
$urldata['book_sef'] = $this->chapterData[$chapter['chapter_parent']]['chapter_sef']; $urldata['book_sef'] = $this->chapterData[$chapter['chapter_parent']]['chapter_sef'];
} }
return e107::getUrl()->create($route, $urldata, array('allow' => 'page_sef,page_title,page_id,chapter_sef,book_sef')); return e107::getUrl()->create($route, $urldata, array('allow' => 'page_sef,page_title,page_id,chapter_sef,book_sef'));
@@ -303,12 +323,12 @@ class cpage_shortcodes extends e_shortcode
function sc_cpagemetadiz() function sc_cpagemetadiz()
{ {
return $this->page['page_metadscr']; return $this->var['page_metadscr'];
} }
function sc_cpagesef() function sc_cpagesef()
{ {
return vartrue($this->page['page_sef'],'page-no-sef'); return vartrue($this->var['page_sef'],'page-no-sef');
} }
// -------------------- Book - specific to the current page. ------------------------- // -------------------- Book - specific to the current page. -------------------------
@@ -352,8 +372,11 @@ class cpage_shortcodes extends e_shortcode
function sc_chapter_name() function sc_chapter_name()
{ {
$tp = e107::getParser(); $tp = e107::getParser();
$row = $this->getChapter(); $row = $this->getChapter();
return $tp->toHtml($row['chapter_name'], false, 'TITLE'); return $tp->toHtml($row['chapter_name'], false, 'TITLE');
} }
@@ -382,6 +405,26 @@ class cpage_shortcodes extends e_shortcode
return $tp->toHtml($row['chapter_meta_description'], true, 'BODY'); return $tp->toHtml($row['chapter_meta_description'], true, 'BODY');
} }
function sc_chapter_url()
{
$tp = e107::getParser();
$row = $this->getChapter();
$brow = $this->getBook($row['chapter_parent']);
$row['book_sef'] = vartrue($brow['chapter_sef'],"no-sef-found"); //$this->getBook();
return e107::getUrl()->create('page/chapter/index', $row,'allow=chapter_id,chapter_sef,book_sef') ;
}
function sc_chapter_button($options)
{
$text = vartrue($options['text'], LAN_READ_MORE);
$size = vartrue($options['size'], "");
$inc = ($size) ? " btn-".$size : "";
return '<a class="cpage btn btn-primary btn-chapter'.$inc.'" href="'.$url.'">'.$text.'</a>';
}
function sc_cpagerelated($array=array()) function sc_cpagerelated($array=array())
@@ -391,11 +434,10 @@ class cpage_shortcodes extends e_shortcode
$array['types'] = 'page,news'; $array['types'] = 'page,news';
} }
return e107::getForm()->renderRelated($array, $this->page['page_metakeys'], array('page'=>$this->page['page_id'])); return e107::getForm()->renderRelated($array, $this->var['page_metakeys'], array('page'=>$this->var['page_id']));
} }
} }

View File

@@ -6,6 +6,7 @@ if(!defined('e107_INIT'))
function menu_shortcode($parm, $mode='') function menu_shortcode($parm, $mode='')
{ {
if(is_array($parm)) //v2.x format allowing for parms. {MENU: path=y&count=x} if(is_array($parm)) //v2.x format allowing for parms. {MENU: path=y&count=x}
{ {
list($plugin,$menu) = explode("/",$parm['path'],2); list($plugin,$menu) = explode("/",$parm['path'],2);

View File

@@ -106,6 +106,15 @@ $CHAPTER_TEMPLATE['nav']['listPages'] = $CHAPTER_TEMPLATE['nav']['listChapters']
$CHAPTER_TEMPLATE['nav']['showPage'] = $CHAPTER_TEMPLATE['nav']['listChapters']; $CHAPTER_TEMPLATE['nav']['showPage'] = $CHAPTER_TEMPLATE['nav']['listChapters'];
// Used by e107_plugins/page/chapter_menu.php
$CHAPTER_TEMPLATE['panel']['listChapters']['start'] = "<div class='chapter-panel-list'>";
$CHAPTER_TEMPLATE['panel']['listChapters']['item'] = "<h1><a href='{CHAPTER_URL}' >{CHAPTER_ICON}</a></h1><br /><p>{CHAPTER_DESCRIPTION}</p>";
$CHAPTER_TEMPLATE['panel']['listChapters']['end'] = "</div>";
$CHAPTER_TEMPLATE['panel']['listPages']['caption'] = "{CHAPTER_NAME}";
$CHAPTER_TEMPLATE['panel']['listPages']['start'] = "<div class='chapter-pages-list'>";
$CHAPTER_TEMPLATE['panel']['listPages']['item'] = "{SETSTYLE=none}<div class='section'><div class='row'>{CPAGEMENU}</div></div>";
$CHAPTER_TEMPLATE['panel']['listPages']['end'] = "</div>";
?> ?>

View File

@@ -432,7 +432,7 @@ class e_menu
{ {
$template = e107::getCoreTemplate('menu',$page['menu_template']); $template = e107::getCoreTemplate('menu',$page['menu_template']);
$page_shortcodes = e107::getScBatch('page',null,'cpage'); $page_shortcodes = e107::getScBatch('page',null,'cpage');
$page_shortcodes->page = $page; $page_shortcodes->setVars($page);
$head = $tp->parseTemplate($template['start'], true); $head = $tp->parseTemplate($template['start'], true);
$foot = $tp->parseTemplate($template['end'], true); $foot = $tp->parseTemplate($template['end'], true);

View File

@@ -0,0 +1,47 @@
<?php
/**
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Purpose: Display a Menu item (panel) for each 'chapter' of a specific book. ie. the chapter-equivalent of {CMENU} .
* @example in theme.php: {MENU: path=page/chapter&book=1} to render all chapters in book 1.
*/
if (!defined('e107_INIT')) { exit; }
$sql = e107::getDb();
$ns = e107::getRender();
$tp = e107::getParser();
$parm = eHelper::scParams($parm);
$template = e107::getCoreTemplate('chapter','panel');
$insert = (vartrue($parm['book'])) ? "AND chapter_parent = ".intval($parm['book']) : '';
//TODO Limits and cache etc.
$data = $sql->retrieve("SELECT * FROM #page_chapters WHERE chapter_visibility IN (".USERCLASS_LIST.") AND chapter_template = 'panel' ".$insert. " LIMIT 24", true);
$sc = e107::getScBatch('page', null, 'cpage');
echo $template['listChapters']['start'];
foreach($data as $row)
{
$sc->setVars($row);
$sc->setChapter($row['chapter_id']);
$title = $tp->toHtml($row['chapter_name'],false,'TITLE'); // Used when tablerender style includes the caption.
$body = $tp->parseTemplate($template['listChapters']['item'], true, $sc);
$ns->tablerender($title, $body, 'chapter-menu'); // check for $mode == 'page-menu' in tablestyle() if you need a simple 'echo' without rendering styles.
}
echo $template['listChapters']['end'];
?>

153
page.php
View File

@@ -93,9 +93,11 @@ class pageClass
public $cacheData = null; /* cache data */ public $cacheData = null; /* cache data */
protected $chapterSef; /* authorized status */ protected $chapterSef; /* authorized status */
protected $chapterParent; protected $chapterParent;
protected $chapterData = array(); protected $chapterData = array();
protected $displayAllMode = false; // set to True when no book/chapter/page has been defined by the url/query.
function __construct($debug=FALSE) function __construct($debug=FALSE)
{ {
/* constructor */ /* constructor */
@@ -146,8 +148,6 @@ class pageClass
foreach($books as $row) foreach($books as $row)
{ {
$id = $row['chapter_id']; $id = $row['chapter_id'];
// $this->chapterSef[$id] = $row['chapter_sef'];
// $this->chapterParent[$id] = $row['chapter_parent'];
$this->chapterData[$id] = $row; $this->chapterData[$id] = $row;
} }
@@ -215,6 +215,8 @@ class pageClass
$tp = e107::getParser(); $tp = e107::getParser();
$frm = e107::getForm(); $frm = e107::getForm();
$this->displayAllMode = true;
$text = ""; $text = "";
@@ -272,6 +274,8 @@ class pageClass
} }
/** /**
* Parse the Book/Chapter "listChapters' template * Parse the Book/Chapter "listChapters' template
*/ */
@@ -287,9 +291,15 @@ class pageClass
$layout = 'default'; $layout = 'default';
} }
if($this->displayAllMode === true)
{
$layout = e107::getPref('listBooksTemplate');
}
$error = array('listChapters' => array('start'=>"Chapter template not found: ".$layout));
$tml = e107::getCoreTemplate('chapter','', true, true); // always merge $tml = e107::getCoreTemplate('chapter','', true, true); // always merge
$tmpl = varset($tml[$layout]); $tmpl = varset($tml[$layout],$error );
$template = $tmpl['listChapters']; $template = $tmpl['listChapters'];
@@ -369,7 +379,15 @@ class pageClass
// retrieve the template to use for this chapter. // retrieve the template to use for this chapter.
$row = $sql->retrieve('page_chapters','chapter_id,chapter_icon,chapter_name,chapter_parent, chapter_meta_description,chapter_template','chapter_id = '.intval($chapt).' LIMIT 1'); $row = $sql->retrieve('page_chapters','chapter_id,chapter_icon,chapter_name,chapter_parent, chapter_meta_description,chapter_template','chapter_id = '.intval($chapt).' LIMIT 1');
$layout = vartrue($row['chapter_template'],'default');
if($this->displayAllMode === true)
{
$layout = e107::getPref('listBooksTemplate');
}
else
{
$layout = vartrue($row['chapter_template'],'default');
}
$bookSef = $this->getSef($row['chapter_parent']); $bookSef = $this->getSef($row['chapter_parent']);
@@ -410,22 +428,24 @@ class pageClass
$page['chapter_sef'] = $this->getSef($page['page_chapter']); // $chapter_sef; $page['chapter_sef'] = $this->getSef($page['page_chapter']); // $chapter_sef;
$page['book_sef'] = $bookSef; $page['book_sef'] = $bookSef;
$this->page = $page; // $this->page = $page;
$this->batch->setVars(new e_vars($data))->setScVar('page', $this->page); $this->batch->setVars($page);
// $this->batch->setVars(new e_vars($data))->setScVar('page', $this->page);
// $url = e107::getUrl()->create('page/view', $page, 'allow=page_id,page_sef,chapter_sef,book_sef'); // $url = e107::getUrl()->create('page/view', $page, 'allow=page_id,page_sef,chapter_sef,book_sef');
// $text .= "<li><a href='".$url."'>".$tp->toHtml($page['page_title'])."</a></li>"; // $text .= "<li><a href='".$url."'>".$tp->toHtml($page['page_title'])."</a></li>";
$text .= e107::getParser()->parseTemplate($template['item'], true, $this->batch); $text .= e107::getParser()->parseTemplate($template['item'], true, $this->batch);
} }
$text .= $tp->simpleParse($template['end'],$var); $text .= $tp->simpleParse($template['end'], $var);
// $caption = ($title !='')? $title: LAN_PAGE_11; // $caption = ($title !='')? $title: LAN_PAGE_11;
// e107::getRender()->tablerender($caption, $text,"cpage_list"); // e107::getRender()->tablerender($caption, $text,"cpage_list");
} }
$caption = $tp->simpleParse($template['caption'],$var); $caption = $tp->simpleParse($template['caption'], $var);
return array('caption'=>$caption, 'text'=> $text); return array('caption'=>$caption, 'text'=> $text);
} }
@@ -446,6 +466,9 @@ class pageClass
if(!$sql->gen($query)) if(!$sql->gen($query))
{ {
/*
$ret['title'] = LAN_PAGE_12; // ***** CHANGED $ret['title'] = LAN_PAGE_12; // ***** CHANGED
$ret['sub_title'] = ''; $ret['sub_title'] = '';
$ret['text'] = LAN_PAGE_3; $ret['text'] = LAN_PAGE_3;
@@ -454,11 +477,30 @@ class pageClass
$ret['np'] = ''; $ret['np'] = '';
$ret['err'] = TRUE; $ret['err'] = TRUE;
$ret['cachecontrol'] = false; $ret['cachecontrol'] = false;
*/
// ---------- New (to replace values above) ----
$this->page['page_title'] = LAN_PAGE_12; // ***** CHANGED
$this->page['sub_title'] = '';
$this->page['page_text'] = LAN_PAGE_3;
$this->page['comments'] = '';
$this->page['rating'] = '';
$this->page['np'] = '';
$this->page['err'] = TRUE;
$this->page['cachecontrol'] = false;
// -------------------------------------
$this->authorized = 'nf'; $this->authorized = 'nf';
$this->template = e107::getCoreTemplate('page', 'default'); $this->template = e107::getCoreTemplate('page', 'default');
$this->batch = e107::getScBatch('page',null,'cpage')->setVars(new e_vars($ret))->setScVar('page', array()); // $this->batch = e107::getScBatch('page',null,'cpage')->setVars(new e_vars($ret))->setScVar('page', array()); ///FIXME Needs upgrading to setVars() array. (not using '$this->page')
define("e_PAGETITLE", $ret['title']); $this->batch = e107::getScBatch('page',null,'cpage')->setVars($this->page);
define("e_PAGETITLE", $this->page['page_title']);
return; return;
} }
@@ -467,6 +509,7 @@ class pageClass
// setting override to true breaks default. // setting override to true breaks default.
$this->template = e107::getCoreTemplate('page', vartrue($this->page['page_template'], 'default'), true, true); $this->template = e107::getCoreTemplate('page', vartrue($this->page['page_template'], 'default'), true, true);
if(!$this->template) if(!$this->template)
{ {
// switch to default // switch to default
@@ -498,7 +541,7 @@ class pageClass
$rating = $this->pageRating($this->page['page_rating_flag']); $rating = $this->pageRating($this->page['page_rating_flag']);
$comments = $this->pageComment($this->page['page_comment_flag']); $comments = $this->pageComment($this->page['page_comment_flag']);
} }
/*
$ret['title'] = $this->page['page_title']; $ret['title'] = $this->page['page_title'];
$ret['sub_title'] = $this->title; $ret['sub_title'] = $this->title;
$ret['text'] = $this->pageToRender; $ret['text'] = $this->pageToRender;
@@ -507,8 +550,23 @@ class pageClass
$ret['comments'] = $comments; $ret['comments'] = $comments;
$ret['err'] = FALSE; $ret['err'] = FALSE;
$ret['cachecontrol'] = (isset($this->page['page_password']) && !$this->page['page_password'] && $this->authorized === true); // Don't cache password protected pages $ret['cachecontrol'] = (isset($this->page['page_password']) && !$this->page['page_password'] && $this->authorized === true); // Don't cache password protected pages
*/
// $this->batch->setVars(new e_vars($ret))->setScVar('page', $this->page); // Removed in favour of $this->var (cross-compatible with menus and other parts of e107 that use the same shortcodes)
// ---- New --- -
$this->page['page_text'] = $this->pageToRender;
$this->page['np'] = $pagenav;
$this->page['rating'] = $rating;
$this->page['comments'] = $comments;
$this->page['err'] = FALSE;
$this->page['cachecontrol'] = (isset($this->page['page_password']) && !$this->page['page_password'] && $this->authorized === true);
// -----------------
$this->batch->setVars($this->page);
$this->batch->setVars(new e_vars($ret))->setScVar('page', $this->page);
define('e_PAGETITLE', eHelper::formatMetaTitle($ret['title'])); define('e_PAGETITLE', eHelper::formatMetaTitle($ret['title']));
if($this->page['page_metadscr']) define('META_DESCRIPTION', eHelper::formatMetaDescription($this->page['page_metadscr'])); if($this->page['page_metadscr']) define('META_DESCRIPTION', eHelper::formatMetaDescription($this->page['page_metadscr']));
@@ -590,7 +648,7 @@ class pageClass
$vars = $this->batch->getParserVars(); $vars = $this->batch->getParserVars();
// reset batch data // reset batch data
$this->batch->setVars(null)->setScVar('page', array()); // $this->batch->setVars(null)->setScVar('page', array());
// copy some data // copy some data
$extend->title = $vars->title; $extend->title = $vars->title;
@@ -628,28 +686,25 @@ class pageClass
public function renderPage($template, $vars = null) public function renderPage($template, $vars = null)
{ {
if(null === $vars) if(null === $vars)
{ {
$ret = e107::getParser()->parseTemplate($template, true, $this->batch); $ret = e107::getParser()->parseTemplate($template, true, $this->batch);
$vars = $this->batch->getParserVars();
} }
else else
{ {
$ret = e107::getParser()->simpleParse($template, $vars); $ret = e107::getParser()->simpleParse($template, $vars);
} }
// if(vartrue($this->template['noTableRender'])) //XXX Deprecated - use tablerender $mode instead. eg. cpage-templatename : echo $text;
// {
// return $ret;
// }
$mode = vartrue($this->template['tableRender'], 'cpage-'.$template); $mode = vartrue($this->template['tableRender'], 'cpage-'.$template);
$title = $vars->title;
return e107::getRender()->tablerender($title, $ret, $mode, true); return e107::getRender()->tablerender($this->page['page_title'], $ret, $mode, true);
} }
public function parsePage()
public function parsePage() //XXX FIXME Move to page_shortcodes.
{ {
$tp = e107::getParser(); $tp = e107::getParser();
e107::getBB()->setClass("page"); e107::getBB()->setClass("page");
@@ -731,6 +786,8 @@ class pageClass
e107::getBB()->clearClass(); e107::getBB()->clearClass();
} }
function pageIndex() function pageIndex()
{ {
// Use always nextprev shortcode (with a special default 'page' tempalte) // Use always nextprev shortcode (with a special default 'page' tempalte)
@@ -755,44 +812,6 @@ class pageClass
if($page_rating_flag) if($page_rating_flag)
{ {
return "<br /><div style='text-align:right'>".e107::getRate()->render("page", $this->pageID,array('label'=>LAN_PAGE_4))."</div>"; return "<br /><div style='text-align:right'>".e107::getRate()->render("page", $this->pageID,array('label'=>LAN_PAGE_4))."</div>";
/*
$rate_text = ''; // Notice removal
require_once(e_HANDLER."rate_class.php");
$rater = new rater;
$rate_text = "<br /><table style='width:100%'><tr><td style='width:50%'>";
if ($ratearray = $rater->getrating("page", $this->pageID))
{
if ($ratearray[2] == "")
{
$ratearray[2] = 0;
}
$rate_text .= "<img src='".e_IMAGE_ABS."rate/box/box".$ratearray[1].".png' alt='' style='vertical-align:middle;' />\n";
$rate_text .= "&nbsp;".$ratearray[1].".".$ratearray[2]." - ".$ratearray[0]."&nbsp;";
$rate_text .= ($ratearray[0] == 1 ? "vote" : "votes");
}
else
{
$rating .= LAN_PAGE_dl_13;
}
$rate_text .= "</td><td style='width:50%; text-align:right'>";
if (!$rater->checkrated("page", $this->pageID) && USER)
{
$rate_text .= $rater->rateselect("&nbsp;&nbsp;&nbsp;&nbsp; <b>".LAN_PAGE_4."</b>", "page", $this->pageID);
}
else if(!USER)
{
$rate_text .= "&nbsp;";
}
else
{
$rate_text .= LAN_PAGE_5;
}
$rate_text .= "</td></tr></table>";
*/
} }
@@ -800,12 +819,14 @@ class pageClass
// return $rate_text; // return $rate_text;
} }
function pageComment($page_comment_flag) function pageComment($page_comment_flag)
{ {
if($page_comment_flag) if($page_comment_flag)
{ {
require_once(e_HANDLER."comment_class.php"); $cobj = e107::getComment();
$cobj = new comment;
if (isset($_POST['commentsubmit'])) if (isset($_POST['commentsubmit']))
{ {
@@ -818,6 +839,8 @@ class pageClass
} }
} }
function pageCheckPerms($page_class, $page_password, $page_title="&nbsp;") function pageCheckPerms($page_class, $page_password, $page_title="&nbsp;")
{ {
global $ns, $tp, $pref, $HEADER, $FOOTER, $sql; // $tp added - also $pref - used by footer global $ns, $tp, $pref, $HEADER, $FOOTER, $sql; // $tp added - also $pref - used by footer
@@ -867,11 +890,15 @@ class pageClass
return false; return false;
} }
function getCookieName() function getCookieName()
{ {
return e_COOKIE.'_page_'.$this->pageID; return e_COOKIE.'_page_'.$this->pageID;
} }
function setPageCookie() function setPageCookie()
{ {
if(!$this->pageID || !vartrue($_POST['page_pw'])) return; if(!$this->pageID || !vartrue($_POST['page_pw'])) return;