1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 04:40:44 +02:00

Fixed conflict between page shortcodes and page plugin shortcodes. Book and Chapter listings improved and page_navigation_menu improved.

This commit is contained in:
Cameron
2013-02-01 18:00:53 -08:00
parent 2b05530a62
commit 405f488f31
6 changed files with 78 additions and 42 deletions

View File

@@ -331,7 +331,7 @@ class page_admin_ui extends e_admin_ui
$sql = e107::getDb(); $sql = e107::getDb();
$sql->db_Select_gen("SELECT chapter_id,chapter_name,chapter_parent FROM #page_chapters ORDER BY chapter_parent asc"); $sql->db_Select_gen("SELECT chapter_id,chapter_name,chapter_parent FROM #page_chapters ORDER BY chapter_parent asc, chapter_order");
while($row = $sql->db_Fetch()) while($row = $sql->db_Fetch())
{ {
$cat = $row['chapter_id']; $cat = $row['chapter_id'];
@@ -346,7 +346,7 @@ class page_admin_ui extends e_admin_ui
$this->cats[$cat] = $this->books[$book] . " : ".$row['chapter_name']; $this->cats[$cat] = $this->books[$book] . " : ".$row['chapter_name'];
} }
} }
asort($this->cats); // asort($this->cats);
$this->fields['page_chapter']['writeParms'] = $this->cats; $this->fields['page_chapter']['writeParms'] = $this->cats;

View File

@@ -15,10 +15,11 @@ if (!defined('e107_INIT')) { exit; }
* *
* Shortcodes for custom page display * Shortcodes for custom page display
*/ */
class page_shortcodes extends e_shortcode class cpage_shortcodes extends e_shortcode
{ {
// var $var; // parsed DB values
function sc_cpagetitle() function sc_cpagetitle($parm='')
{ {
return e107::getParser()->toHTML($this->getParserVars()->title, true, 'TITLE'); return e107::getParser()->toHTML($this->getParserVars()->title, true, 'TITLE');
} }
@@ -30,7 +31,7 @@ class page_shortcodes extends e_shortcode
} }
function sc_cpagebody() function sc_cpagebody($parm='')
{ {
// already parsed // already parsed
return $this->getParserVars()->text; return $this->getParserVars()->text;

View File

@@ -110,7 +110,7 @@ $sc_style['CPAGENAV|default']['post'] = '</div>';
$PAGE_TEMPLATE['nav']['caption'] = "Articles"; $PAGE_TEMPLATE['nav']['caption'] = "Articles";
$PAGE_TEMPLATE['nav']['start'] = '<ul>'; $PAGE_TEMPLATE['nav']['start'] = '<ul class="page-nav">';
// Main Link // Main Link
$PAGE_TEMPLATE['nav']['item'] = ' $PAGE_TEMPLATE['nav']['item'] = '
@@ -161,7 +161,7 @@ $sc_style['CPAGENAV|default']['post'] = '</div>';
$PAGE_TEMPLATE['nav']['end'] = '</ul>'; $PAGE_TEMPLATE['nav']['end'] = '</ul>';
$PAGE_TEMPLATE['nav']['submenu_start'] = '<ul id="{LINK_PARENT}" role="menu" >'; $PAGE_TEMPLATE['nav']['submenu_start'] = '<ul class="page-nav" id="{LINK_PARENT}" role="menu" >';
$PAGE_TEMPLATE['nav']['submenu_item'] = ' $PAGE_TEMPLATE['nav']['submenu_item'] = '

View File

@@ -27,6 +27,4 @@ class page_shortcodes extends e_shortcode
} }
} }
?> ?>

View File

@@ -52,7 +52,9 @@ class page_sitelinks // include plugin-folder in the name.
$sublinks[$pid][] = array( $sublinks[$pid][] = array(
'link_id' => $row['page_id'], 'link_id' => $row['page_id'],
'link_name' => $row['page_title'], 'link_name' => $row['page_title'],
'link_url' => vartrue($row['page_sef'],'page.php?'.$row['page_id']), // 'link_url' => vartrue($row['page_sef'],'page.php?id='.$row['page_id']),
'link_url' => 'page.php?id='.$row['page_id'],
// 'link_url' => e107::getUrl()->create('page/view', $row, 'allow=page_id,page_sef'), //XXX FIXME - bad links created.
'link_description' => '', 'link_description' => '',
'link_button' => '', 'link_button' => '',
'link_category' => '', 'link_category' => '',
@@ -86,7 +88,10 @@ class page_sitelinks // include plugin-folder in the name.
$arr[] = array( $arr[] = array(
'link_id' => $row['chapter_id'], 'link_id' => $row['chapter_id'],
'link_name' => $row['chapter_name'], 'link_name' => $row['chapter_name'],
'link_url' => vartrue($row['chapter_sef'],'#'), //TODO SEFURLS using chapter_sef.
'link_url' => ($row['chapter_parent'] == 0) ? 'page.php?bk='.$row['chapter_id'] : 'page.php?ch='.$row['chapter_id'],
// 'link_url' => vartrue($row['chapter_sef'],'#'),
'link_description' => '', 'link_description' => '',
'link_button' => '', 'link_button' => '',
'link_category' => '', 'link_category' => '',

View File

@@ -30,6 +30,23 @@ if(!e_QUERY)
exit; exit;
} }
} }
elseif(vartrue($_GET['bk'])) // List Chapters within a specific Book
{
require_once(HEADERF);
$text = $e107CorePage->listChapters($_GET['bk']);
$ns->tablerender('', $text, 'page-book-list'); // TODO FIXME Caption eg. "book title"
require_once(FOOTERF);
exit;
}
elseif(vartrue($_GET['ch'])) // List Pages within a specific Chapter
{
require_once(HEADERF);
$text = $e107CorePage->listPages($_GET['ch']);
$ns->tablerender('', $text, 'page-chapter-list'); // TODO FIXME Caption eg. "book title"
require_once(FOOTERF);
exit;
}
else else
{ {
@@ -68,12 +85,22 @@ class pageClass
function __construct($debug=FALSE) function __construct($debug=FALSE)
{ {
/* constructor */ /* constructor */
if(!vartrue($_GET['id'])) // legacy URLs /page.php?x
{
$tmp = explode(".", e_QUERY); $tmp = explode(".", e_QUERY);
$this->pageID = intval($tmp[0]); $this->pageID = intval($tmp[0]);
$this->pageSelected = (isset($tmp[1]) ? intval($tmp[1]) : 0); $this->pageSelected = (isset($tmp[1]) ? intval($tmp[1]) : 0);
$this->pageTitles = array(); $this->pageTitles = array();
$this->bullet = ''; $this->bullet = '';
}
else // NEW URLS /page.php?id=x // TODO Complete and test.
{
$tmp = explode(".", e_QUERY);
$this->pageID = intval($_GET['id']);
$this->pageSelected = (isset($tmp[1]) ? intval($tmp[1]) : 0); // Not sure what this is?
$this->pageTitles = array();
$this->bullet = ''; // deprecated - use CSS instead.
}
// TODO nq_ (no query) cache string // TODO nq_ (no query) cache string
$this->cacheString = 'page_'.$this->pageID.'_'.$this->pageSelected; $this->cacheString = 'page_'.$this->pageID.'_'.$this->pageSelected;
@@ -115,14 +142,14 @@ class pageClass
{ {
while($row = $sql->db_Fetch()) while($row = $sql->db_Fetch())
{ {
$text .= "<h2>".$tp->toHtml($row['chapter_name'])."</h2>"; // Book Title. $text .= "<h3 class='page-book-list'>".$tp->toHtml($row['chapter_name'])."</h3>"; // Book Title.
$text .= $this->listChapters($row['chapter_id']); $text .= $this->listChapters($row['chapter_id']);
} }
} }
$text .= "<h1>Other Pages</h1>"; // Book Title. $text .= "<h3>Other Articles</h3>"; // Book Title.
$text .= $this->listPages(0); // Pages unassigned to Book/Chapters. $text .= $this->listPages(0); // Pages unassigned to Book/Chapters.
e107::getRender()->tablerender(LAN_PAGE_11, $text,"cpage_list"); e107::getRender()->tablerender("Articles", $text,"cpage_list");
} }
@@ -131,16 +158,20 @@ class pageClass
//XXX - May be better to compile into assoc 'tree' array first. ie. books/chapters/pages. //XXX - May be better to compile into assoc 'tree' array first. ie. books/chapters/pages.
function listChapters($book=1) function listChapters($book=1)
{ {
$sql = e107::getDb(); $sql = e107::getDb('chap');
$tp = e107::getParser(); $tp = e107::getParser();
if($sql->db_Select("page_chapters", "*", "chapter_parent = ".intval($book)." ORDER BY chapter_order ASC ")) if($sql->db_Select("page_chapters", "*", "chapter_parent = ".intval($book)." ORDER BY chapter_order ASC "))
{ {
$text .= "<ul class='page-chapters-list'>";
while($row = $sql->db_Fetch()) while($row = $sql->db_Fetch())
{ {
$text .= "<h3>".$tp->toHtml($row['chapter_name'])."</h3>"; // Chapter Title. $text .= "<li>";
$text .= "<h4>".$tp->toHtml($row['chapter_name'])."</h4>"; // Chapter Title.
$text .= $this->listPages(intval($row['chapter_id'])); $text .= $this->listPages(intval($row['chapter_id']));
$text .= "</li>";
} }
$text .= "</ul>";
} }
return $text; return $text;
@@ -151,7 +182,7 @@ class pageClass
// TODO template for page list // TODO template for page list
function listPages($chapt=0) function listPages($chapt=0)
{ {
$sql = e107::getDb(); $sql = e107::getDb('pg');
$tp = e107::getParser(); $tp = e107::getParser();
if(!e107::getPref('listPages', false)) if(!e107::getPref('listPages', false))
@@ -160,19 +191,20 @@ class pageClass
} }
else else
{ {
if(!$sql->db_Select("page", "*", "page_theme='' AND page_chapter=".$chapt." AND page_class IN (".USERCLASS_LIST.") ORDER BY page_order ASC ")) if(!$sql->db_Select("page", "*", "page_theme='' AND page_chapter=".intval($chapt)." AND page_class IN (".USERCLASS_LIST.") ORDER BY page_order ASC "))
{ {
$text = LAN_PAGE_2; $text = LAN_PAGE_2;
} }
else else
{ {
$text .= "<ul class='page-pages-list'>";
$pageArray = $sql->db_getList(); $pageArray = $sql->db_getList();
foreach($pageArray as $page) foreach($pageArray as $page)
{ {
$url = e107::getUrl()->create('page/view', $page, 'allow=page_id,page_sef'); $url = e107::getUrl()->create('page/view', $page, 'allow=page_id,page_sef');
$text .= $this->bullet." <a href='".$url."'>".$tp->toHtml($page['page_title'])."</a><br />"; //XXX Better to use <ul> and <li> ?? $text .= "<li><a href='".$url."'>".$tp->toHtml($page['page_title'])."</a></li>";
} }
$text .= "</ul>";
// $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");
} }
@@ -207,7 +239,7 @@ class pageClass
$ret['cachecontrol'] = false; $ret['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')->setVars(new e_vars($ret))->setScVar('page', array()); $this->batch = e107::getScBatch('page',null,'cpage')->setVars(new e_vars($ret))->setScVar('page', array());
define("e_PAGETITLE", $ret['title']); define("e_PAGETITLE", $ret['title']);
return; return;
@@ -218,7 +250,7 @@ class pageClass
$this->template = e107::getCoreTemplate('page', vartrue($this->page['page_template'], 'default')); $this->template = e107::getCoreTemplate('page', vartrue($this->page['page_template'], 'default'));
if(empty($this->template)) $this->template = e107::getCoreTemplate('page', 'default'); if(empty($this->template)) $this->template = e107::getCoreTemplate('page', 'default');
$this->batch = e107::getScBatch('page'); $this->batch = e107::getScBatch('page',null,'cpage');
$this->pageText = $this->page['page_text']; $this->pageText = $this->page['page_text'];
@@ -286,7 +318,7 @@ class pageClass
if($this->cacheData['COMMENT_FLAG']) if($this->cacheData['COMMENT_FLAG'])
{ {
$vars = new e_vars(array('comments' => $this->pageComment(true))); $vars = new e_vars(array('comments' => $this->pageComment(true)));
$comments = e107::getScBatch('page')->setVars($vars)->cpagecomments(); $comments = e107::getScBatch('page',null,'cpage')->setVars($vars)->cpagecomments();
} }
define('e_PAGETITLE', eHelper::formatMetaTitle($this->cacheData['TITLE'])); define('e_PAGETITLE', eHelper::formatMetaTitle($this->cacheData['TITLE']));
define('META_DESCRIPTION', $this->cacheData['META_DSCR']); define('META_DESCRIPTION', $this->cacheData['META_DSCR']);