diff --git a/e107_admin/cpage.php b/e107_admin/cpage.php index a69858974..f9d298897 100644 --- a/e107_admin/cpage.php +++ b/e107_admin/cpage.php @@ -128,11 +128,14 @@ class page_chapters_ui extends e_admin_ui 'chapter_icon' => array('title'=> LAN_ICON, 'type' => 'icon', 'data' => 'str', 'width' => '100px', 'thclass' => 'center', 'class'=>'center', 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60','readonly'=>FALSE, 'batch' => FALSE, 'filter'=>FALSE), 'chapter_parent' => array('title'=> "Book", 'type' => 'dropdown', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE, 'filter'=>true), 'chapter_name' => array('title'=> "Book or Chapter Title", 'type' => 'method', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE), + 'chapter_template' => array('title'=> LAN_TEMPLATE, 'type' => 'dropdown', 'width' => 'auto','filter' => true, 'batch'=>true, 'inline'=>true, 'writeParms'=>''), + 'chapter_meta_description' => array('title'=> LAN_DESCRIPTION, 'type' => 'textarea', 'width' => 'auto', 'thclass' => 'left','readParms' => 'expand=...&truncate=150&bb=1', 'readonly'=>FALSE), 'chapter_meta_keywords' => array('title'=> "Meta Keywords", 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE), 'chapter_sef' => array('title'=> "SEF Url String", 'type' => 'text', 'width' => 'auto', 'readonly'=>FALSE), // Display name 'chapter_manager' => array('title'=> "Can be edited by", 'type' => 'userclass', 'width' => 'auto', 'data' => 'int','batch'=>TRUE, 'filter'=>TRUE), 'chapter_order' => array('title'=> LAN_ORDER, 'type' => 'text', 'width' => 'auto', 'thclass' => 'right', 'class'=> 'right' ), + 'options' => array('title'=> LAN_OPTIONS, 'type' => 'method', 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'left last', 'class' => 'left', 'readParms'=>'sort=1') ); @@ -153,9 +156,23 @@ class page_chapters_ui extends e_admin_ui $this->books[$bk] = $row['chapter_name']; } - asort($this->books); + asort($this->books); $this->fields['chapter_parent']['writeParms'] = $this->books; + + + $tmp = e107::getLayouts('', 'chapter', 'front', '', true, false); + $tmpl = array(); + foreach($tmp as $key=>$val) + { + if(substr($key,0,3) != 'nav') + { + $tmpl[$key] = $val; + } + } + + $this->fields['chapter_template']['writeParms'] = $tmpl; // e107::getLayouts('', 'chapter', 'front', '', true, false); // e107::getLayouts('', 'page', 'books', 'front', true, false); + } diff --git a/e107_core/sql/core_sql.php b/e107_core/sql/core_sql.php index c6f69bdd5..16afa23f0 100644 --- a/e107_core/sql/core_sql.php +++ b/e107_core/sql/core_sql.php @@ -410,6 +410,7 @@ CREATE TABLE page_chapters ( chapter_manager tinyint(3) unsigned NOT NULL default '254', chapter_icon varchar(250) NOT NULL default '', chapter_order tinyint(3) unsigned NOT NULL default '0', + chapter_template varchar(50) NOT NULL default '', PRIMARY KEY (chapter_id), KEY chapter_order (chapter_order) ) ENGINE=MyISAM; diff --git a/e107_core/templates/chapter_template.php b/e107_core/templates/chapter_template.php new file mode 100644 index 000000000..a7971bb8d --- /dev/null +++ b/e107_core/templates/chapter_template.php @@ -0,0 +1,105 @@ +"; +$CHAPTER_TEMPLATE['default']['listPages']['item'] = "
  • {CPAGETITLE}
  • "; +$CHAPTER_TEMPLATE['default']['listPages']['end'] = ""; + +$CHAPTER_TEMPLATE['default']['listChapters']['start'] = ""; + + + + + +$CHAPTER_TEMPLATE['nav']['listChapters']['caption'] = "Articles"; + +$CHAPTER_TEMPLATE['nav']['listChapters']['start'] = ''; + + +$CHAPTER_TEMPLATE['nav']['listChapters']['submenu_start'] = ''; + + +$CHAPTER_TEMPLATE['nav']['listPages'] = $CHAPTER_TEMPLATE['nav']['listChapters']; +$CHAPTER_TEMPLATE['nav']['showPage'] = $CHAPTER_TEMPLATE['nav']['listChapters']; + +?> \ No newline at end of file diff --git a/e107_core/templates/page_template.php b/e107_core/templates/page_template.php index 67b3cce9a..3a27e60ba 100644 --- a/e107_core/templates/page_template.php +++ b/e107_core/templates/page_template.php @@ -96,96 +96,7 @@ $sc_style['CPAGENAV|default']['post'] = ''; - - -/* Used by {PAGE_NAVIGATION} shortcode - uses Sitelink/Navigation Shortcodes eg. {LINK_NAME} */ - - $PAGE_TEMPLATE['nav']['caption'] = "Articles"; - - $PAGE_TEMPLATE['nav']['start'] = ''; - - - $PAGE_TEMPLATE['nav']['submenu_start'] = ''; - - - - $PAGE_TEMPLATE['listPages']['start'] = ""; - - - $PAGE_TEMPLATE['listChapters']['start'] = ""; diff --git a/e107_plugins/page/e_shortcode.php b/e107_plugins/page/e_shortcode.php index 4b4eb1b27..62ee3e626 100644 --- a/e107_plugins/page/e_shortcode.php +++ b/e107_plugins/page/e_shortcode.php @@ -33,8 +33,10 @@ class page_shortcodes extends e_shortcode function sc_page_navigation($parm='') // TODO when No $parm provided, auto-detect based on URL which book/chapters to display. { // $parm = eHelper::scParams($parm); - - $template = e107::getCoreTemplate('page',vartrue($parm['template'],'nav'), true, true); // always merge + + $tmpl = e107::getCoreTemplate('chapter', vartrue($parm['template'],'nav'), true, true); // always merge + + $template = $tmpl['showPage']; $request = $this->request; @@ -44,10 +46,12 @@ class page_shortcodes extends e_shortcode { case 'listChapters': $parm['cbook'] = $request['id']; + $template = $tmpl['listChapters']; break; case 'listPages': $parm['cchapter'] = $request['id']; + $template = $tmpl['listPages']; break; case 'showPage': @@ -67,8 +71,8 @@ class page_shortcodes extends e_shortcode $links = e107::getAddon('page', 'e_sitelink'); - $data = $links->pageNav($parm); + $data = $links->pageNav($parm); if(isset($data['title']) && !vartrue($template['noAutoTitle'])) { diff --git a/e107_plugins/page/e_sitelink.php b/e107_plugins/page/e_sitelink.php index e268a8091..ce17fe955 100644 --- a/e107_plugins/page/e_sitelink.php +++ b/e107_plugins/page/e_sitelink.php @@ -111,6 +111,7 @@ class page_sitelink // include plugin-folder in the name. if(vartrue($options['chapter'])) { //$filter = "chapter_id > ".intval($options['chapter']); + $title = $sql->retrieve('page_chapters', 'chapter_name', 'chapter_id='.intval($options['chapter'])); $outArray = array(); if(!$title) return e107::getNav()->compile($_pdata, $outArray, $options['chapter']); @@ -121,6 +122,7 @@ class page_sitelink // include plugin-folder in the name. $title = false; if(vartrue($options['book'])) { + // XXX discuss the idea here //$filter = "chapter_id > ".intval($options['book']); $filter = "chapter_parent = ".intval($options['book']); @@ -132,6 +134,7 @@ class page_sitelink // include plugin-folder in the name. $books = $sql->retrieve("SELECT * FROM #page_chapters WHERE ".$filter." ORDER BY chapter_order ASC" , true); foreach($books as $row) { + $arr[] = array( 'link_id' => $row['chapter_id'], 'link_name' => $row['chapter_name'], @@ -146,11 +149,12 @@ class page_sitelink // include plugin-folder in the name. 'link_parent' => $row['chapter_parent'], 'link_open' => '', 'link_class' => 0, - 'link_sub' => varset($sublinks[$row['chapter_id']]), + 'link_sub' => (!vartrue($options['book']) && !vartrue($options['auto'])) ? varset($sublinks[$row['chapter_id']]) : '', //XXX always test with docs template in bootstrap before changing. 'link_active' => $row['chapter_parent'] == 0 ? $options['cbook'] && $options['cbook'] == $row['chapter_id'] : $options['cchapter'] && $options['cchapter'] == $row['chapter_id'], ); } + $outArray = array(); $parent = vartrue($options['book']) ? $options['book'] : 0; $ret = e107::getNav()->compile($arr, $outArray, $parent); diff --git a/e107_plugins/page/page_navigation_menu.php b/e107_plugins/page/page_navigation_menu.php index 7aa056baa..0c81fedc5 100644 --- a/e107_plugins/page/page_navigation_menu.php +++ b/e107_plugins/page/page_navigation_menu.php @@ -15,7 +15,9 @@ if (!defined('e107_INIT')) { exit; } $parm = eHelper::scParams($parm); -$template = e107::getCoreTemplate('page','nav',false,true); // always merge +$tmpl = e107::getCoreTemplate('chapter','nav',false,true); // always merge + +$template = $tmpl['showPage']; $request = e107::getRegistry('core/pages/request'); if($request && is_array($request)) @@ -24,10 +26,12 @@ if($request && is_array($request)) { case 'listChapters': $parm['cbook'] = $request['id']; + $template = $tmpl['listChapters']; break; case 'listPages': $parm['cchapter'] = $request['id']; + $template = $tmpl['listPages']; break; case 'showPage': diff --git a/e107_themes/bootstrap/templates/chapter_template.php b/e107_themes/bootstrap/templates/chapter_template.php new file mode 100644 index 000000000..b12e468e9 --- /dev/null +++ b/e107_themes/bootstrap/templates/chapter_template.php @@ -0,0 +1,55 @@ + + + {CPAGEBODY} + + '; + $CHAPTER_TEMPLATE['docs']['listPages']['end'] = ''; + + + $CHAPTER_TEMPLATE['docs']['listChapters']['start'] = '
    '; + $CHAPTER_TEMPLATE['docs']['listChapters']['item'] = "

    {CHAPTER_NAME}

    + {CHAPTER_DESCRIPTION} + "; + $CHAPTER_TEMPLATE['docs']['listChapters']['end'] = "
    "; + + + + + + + + $CHAPTER_TEMPLATE['navdocs']['listChapters']['caption'] = " "; + + $CHAPTER_TEMPLATE['navdocs']['listChapters']['start'] = ' - */ - $PAGE_TEMPLATE['navdoc']['caption'] = " "; - - $PAGE_TEMPLATE['navdoc']['start'] = ''; - - - $PAGE_TEMPLATE['navdoc']['submenu_start'] = ''; - $PAGE_TEMPLATE['navdoc']['submenu_item'] = ''; - $PAGE_TEMPLATE['navdoc']['submenu_loweritem'] = ''; - $PAGE_TEMPLATE['navdoc']['submenu_loweritem_active'] = ''; - $PAGE_TEMPLATE['navdoc']['submenu_item_active'] = ''; - $PAGE_TEMPLATE['navdoc']['submenu_end'] = ''; - - - - $PAGE_TEMPLATE['listPages']['start'] = ''; - $PAGE_TEMPLATE['listPages']['item'] = ' -
    - - {CPAGEBODY} -
    - '; - $PAGE_TEMPLATE['listPages']['end'] = ''; - - - $PAGE_TEMPLATE['listChapters']['start'] = '
    '; - $PAGE_TEMPLATE['listChapters']['item'] = "

    {CHAPTER_NAME}

    - {CHAPTER_DESCRIPTION} - "; - $PAGE_TEMPLATE['listChapters']['end'] = "
    "; + * 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) + * +*/ + + diff --git a/e107_themes/bootstrap/theme.php b/e107_themes/bootstrap/theme.php index 8c9e26811..c7023d22d 100644 --- a/e107_themes/bootstrap/theme.php +++ b/e107_themes/bootstrap/theme.php @@ -430,7 +430,7 @@ $HEADER['docs'] = << {SETSTYLE=navdoc} - {PAGE_NAVIGATION: template=navdoc&auto=1} + {PAGE_NAVIGATION: template=navdocs&auto=1} {SETSTYLE=doc} diff --git a/page.php b/page.php index f5767b98d..c9abdc950 100644 --- a/page.php +++ b/page.php @@ -171,9 +171,9 @@ class pageClass $sql = e107::getDb('sql2'); $tp = e107::getParser(); - if($sql->db_Select("page_chapters", "*", "chapter_parent ='0' ORDER BY chapter_order ASC ")) + if($sql->select("page_chapters", "*", "chapter_parent ='0' ORDER BY chapter_order ASC ")) { - while($row = $sql->db_Fetch()) + while($row = $sql->fetch()) { $text .= "

    ".$tp->toHtml($row['chapter_name'])."

    "; // Book Title. $text .= $this->listChapters($row['chapter_id']); @@ -186,20 +186,31 @@ class pageClass } - - - //XXX - May be better to compile into assoc 'tree' array first. ie. books/chapters/pages. + /** + * Parse the Book/Chapter "listChapters' template + */ function listChapters($book=1) { $sql = e107::getDb('chap'); $tp = e107::getParser(); - $template = e107::getCoreTemplate('page','listChapters', true, true); // always merge - - if($sql->db_Select("page_chapters", "*", "chapter_parent = ".intval($book)." ORDER BY chapter_order ASC ")) + // retrieve the template to use for this book + if(!$layout = $sql->retrieve('page_chapters','chapter_template','chapter_id = '.intval($book).' LIMIT 1')) { - $text .= $template['start']; // ""; + + $text .= $template['end']; + + } + else + { + $text = e107::getMessage()->addInfo("There are no chapters in this book")->render(); } return $text; } - + function listPages($chapt=0) { $sql = e107::getDb('pg'); $tp = e107::getParser(); $this->batch = e107::getScBatch('page',null,'cpage'); - $template = e107::getCoreTemplate('page','listPages',true,true); // always merge + + // retrieve the template to use for this chapter. + if(!$layout = $sql->retrieve('page_chapters','chapter_template','chapter_id = '.intval($chapt).' LIMIT 1')) + { + $layout = 'default'; + } + + $tml = e107::getCoreTemplate('chapter','', true, true); // always merge + $tmpl = varset($tml[$layout]); + + + // $tmpl = e107::getCoreTemplate('chapter','docs', true, true); // always merge + $template = $tmpl['listPages']; + + if(!e107::getPref('listPages', false)) { @@ -239,10 +266,10 @@ class pageClass } else { - if(!$count = $sql->db_Select("page", "*", "page_title !='' AND page_chapter=".intval($chapt)." AND page_class IN (".USERCLASS_LIST.") ORDER BY page_order ASC ")) + if(!$count = $sql->select("page", "*", "page_title !='' AND page_chapter=".intval($chapt)." AND page_class IN (".USERCLASS_LIST.") ORDER BY page_order ASC ")) { - - $text = ""; + return e107::getMessage()->addInfo(LAN_PAGE_2)->render(); + // $text = ""; } else {