From b19d383e0ddb3fc4933c8381b559baffeb8fce9c Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 16 Jun 2014 18:21:51 -0700 Subject: [PATCH] Fixed: {CPAGEMENU} could return the incorrect Menu under some conditions. --- e107_admin/cpage.php | 9 ++++--- .../shortcodes/batch/page_shortcodes.php | 4 +-- page.php | 27 +++++++++++++------ 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/e107_admin/cpage.php b/e107_admin/cpage.php index 8e9e72f9c..d3d39a35c 100644 --- a/e107_admin/cpage.php +++ b/e107_admin/cpage.php @@ -529,20 +529,23 @@ class page_admin_ui extends e_admin_ui 'menu_image' => array('title' =>"Menu Image/Video", 'type' => 'image', 'width' => '110px', 'thclass' => 'left', 'class' => "left", 'nosort' => false, 'readParms'=>'thumb=140&thumb_urlraw=0&thumb_aw=140', 'readonly'=>false), - 'menu_name' => array('title'=> "Menu Name", 'type' => 'text', 'inline'=>true, 'width' => 'auto','nolist'=>false, "help"=>"Will be listed in the Menu-Manager under this name"), - 'menu_template' => array('title'=> "Menu Template", 'type' => 'dropdown', 'width' => 'auto', 'filter' => true, 'batch'=>true, 'inline'=>true, 'writeParms'=>''), + 'menu_name' => array('title'=> "Menu Name", 'type' => 'text', 'inline'=>true, 'width' => '10%','nolist'=>false, "help"=>"Will be listed in the Menu-Manager under this name"), + 'menu_template' => array('title'=> "Menu Template", 'type' => 'dropdown', 'width' => '15%', 'filter' => true, 'batch'=>true, 'inline'=>true, 'writeParms'=>''), // 'page_author' => array('title'=> LAN_AUTHOR, 'tab' => 0, 'type' => 'user', 'data'=>'int','width' => 'auto', 'thclass' => 'left'), 'page_datestamp' => array('title'=> LAN_DATE, 'type' => 'datestamp', 'data'=>'int', 'width' => 'auto','writeParms'=>'auto=1&readonly=1'), 'menu_icon' => array('title'=> LAN_ICON, 'type' => 'icon', 'width' => '80px', 'thclass' => 'center', 'class' => "center", 'nosort' => false, 'readParms'=>'thumb=80&thumb_urlraw=0&thumb_aw=80', 'readonly'=>false), 'menu_title' => array('title'=> "Menu Title", 'forced'=> TRUE, 'type' => 'text', 'inline'=>true, 'width'=>'25%'), + + 'page_chapter' => array('title'=> 'Book/Chapter', 'tab' => 0, 'type' => 'dropdown', 'width' => '20%', 'filter' => true, 'batch'=>true, 'inline'=>true), + 'menu_text' => array('title'=> "Menu Body", 'type' => 'bbarea', 'data'=>'str', 'width' => 'auto', 'readParms' => 'expand=...&truncate=50&bb=1', 'writeParms'=>'media=page'), 'options' => array('title'=> LAN_OPTIONS, 'type' => 'method', 'noselector' => true, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center','readParms'=>'delete=0&deleteClass='.e_UC_NOBODY) ); - $this->fieldpref = array("page_id","menu_name", "menu_title", "menu_text", 'menu_image', 'menu_template', 'menu_icon'); + $this->fieldpref = array("page_id","menu_name", "menu_title", 'menu_image', 'menu_template', 'menu_icon', 'page_chapter'); } diff --git a/e107_core/shortcodes/batch/page_shortcodes.php b/e107_core/shortcodes/batch/page_shortcodes.php index 372019415..99c35efa1 100644 --- a/e107_core/shortcodes/batch/page_shortcodes.php +++ b/e107_core/shortcodes/batch/page_shortcodes.php @@ -173,8 +173,8 @@ class cpage_shortcodes extends e_shortcode function sc_cpagemenu() { - $parm = $this->var['menu_name']; - return e107::getMenu()->renderMenu($parm, false, false, true); + $parm = $this->var['page_id']; + return e107::getMenu()->renderMenu($parm, true, false, true); } diff --git a/page.php b/page.php index 0336148b2..d97b716fb 100644 --- a/page.php +++ b/page.php @@ -41,7 +41,7 @@ elseif(vartrue($_GET['bk'])) // List Chapters within a specific Book require_once(HEADERF); $data = $e107CorePage->listChapters($_GET['bk']); - $ns->tablerender($data['caption'], $data['text'], 'cpage-chapter-list'); // TODO FIXME Caption eg. "book title" + $ns->tablerender($data['caption'], $data['text'], 'cpage-chapter-list'); require_once(FOOTERF); exit; } @@ -109,7 +109,7 @@ class pageClass $this->pageTitles = array(); $this->bullet = ''; } - else // NEW URLS /page.php?id=x // TODO Complete and test. + else // NEW URLS /page.php?id=x { $tmp = explode(".", e_QUERY); $this->pageID = intval($_GET['id']); @@ -246,7 +246,7 @@ class pageClass 'BOOK_ICON' => $this->chapterIcon($row['chapter_icon']), 'BOOK_DESCRIPTION' => $tp->toHtml($row['chapter_meta_description'],true,'BODY'), 'CHAPTERS' => $listChapters['text'], - 'BOOK_URL' => e107::getUrl()->create('page/book/index', $sef,'allow=chapter_id,chapter_sef,book_sef,page_sef') // e_BASE."page.php?bk=".intval($row['chapter_id']) // FIXME SEF-URL + 'BOOK_URL' => e107::getUrl()->create('page/book/index', $sef,'allow=chapter_id,chapter_sef,book_sef,page_sef') ); $text .= $tp->simpleParse($template['item'],$var); @@ -348,7 +348,7 @@ class pageClass 'CHAPTER_ICON' => $this->chapterIcon($row['chapter_icon']), 'CHAPTER_DESCRIPTION' => $tp->toHtml($row['chapter_meta_description'],true,'BODY'), 'PAGES' => $tmp['text'], - 'CHAPTER_URL' => e107::getUrl()->create('page/chapter/index', $row,'allow=chapter_id,chapter_sef,book_sef') // e_BASE."page.php?ch=".intval($row['chapter_id']) // FIXME SEF-URL + 'CHAPTER_URL' => e107::getUrl()->create('page/chapter/index', $row,'allow=chapter_id,chapter_sef,book_sef') ); $text .= $tp->simpleParse($template['item'],$var); @@ -442,9 +442,11 @@ class pageClass // $tmpl = e107::getCoreTemplate('chapter','docs', true, true); // always merge - $template = $tmpl['listPages']; + $template = $tmpl['listPages']; - if(!$count = $sql->select("page", "*", "page_title !='' AND page_chapter=".intval($chapt)." AND page_class IN (".USERCLASS_LIST.") ORDER BY page_order ASC ")) + $pageOnly = ($layout == 'panel') ? '1' : "page_title !='' "; // When in 'panel' mode, allow Menus to be rendered. + + if(!$count = $sql->select("page", "*", $pageOnly." AND page_chapter=".intval($chapt)." AND page_class IN (".USERCLASS_LIST.") ORDER BY page_order ASC ")) { return array('text' => "".(LAN_PAGE_2).""); // $text = ""; @@ -493,6 +495,7 @@ class pageClass function processViewPage() { + if($this->checkCache()) { return; @@ -504,6 +507,9 @@ class pageClass LEFT JOIN #user AS u ON p.page_author = u.user_id WHERE p.page_id=".intval($this->pageID); // REMOVED AND p.page_class IN (".USERCLASS_LIST.") - permission check is done later + + + if(!$sql->gen($query)) { @@ -534,7 +540,7 @@ class pageClass $this->authorized = 'nf'; $this->template = e107::getCoreTemplate('page', 'default'); - // $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') + // $this->batch = e107::getScBatch('page',null,'cpage')->setVars(new e_vars($ret))->setScVar('page', array()); ///Upgraded to setVars() array. (not using '$this->page') $this->batch = e107::getScBatch('page',null,'cpage')->setVars($this->page); @@ -660,6 +666,11 @@ class pageClass { + + + + + if(null !== $this->cacheData) { @@ -744,7 +755,7 @@ class pageClass - public function parsePage() //XXX FIXME Move to page_shortcodes. + public function parsePage() { $tp = e107::getParser(); e107::getBB()->setClass("page");