diff --git a/e107_admin/cpage.php b/e107_admin/cpage.php
index e4678d0da..8d9d50982 100644
--- a/e107_admin/cpage.php
+++ b/e107_admin/cpage.php
@@ -414,7 +414,7 @@ class page_admin_ui extends e_admin_ui
'page_chapter' => array('title'=> 'Book/Chapter', 'tab' => 0, 'type' => 'dropdown', 'width' => '20%', 'filter' => true, 'batch'=>true, 'inline'=>true),
'page_template' => array('title'=> LAN_TEMPLATE, 'tab' => 0, 'type' => 'dropdown', 'width' => 'auto','filter' => true, 'batch'=>true, 'inline'=>true, 'writeParms'=>''),
-
+
'page_author' => array('title'=> LAN_AUTHOR, 'tab' => 0, 'type' => 'user', 'data'=>'int','width' => 'auto', 'thclass' => 'left'),
'page_text' => array('title'=> CUSLAN_9, 'tab' => 0, 'type' => 'bbarea', 'data'=>'str', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1', 'writeParms'=>'media=page'),
@@ -449,8 +449,10 @@ class page_admin_ui extends e_admin_ui
protected $fieldpref = array("page_id","page_title","page_chapter","page_template","page_author","page_class");
protected $prefs = array(
- 'listPages' => array('title'=> CUSLAN_29, 'type'=>'boolean'),
- 'pageCookieExpire' => array('title'=> CUSLAN_30, 'type'=>'number') //TODO Set default value to 84600
+ 'listPages' => array('title'=> CUSLAN_29, 'type'=>'boolean'),
+ 'listBooks' => array('title'=> 'List Books/Chapters', 'type'=>'boolean'),
+ 'listBooksTemplate' => array('title'=> 'List Books/Chapters Template', 'type'=>'dropdown'),
+ 'pageCookieExpire' => array('title'=> CUSLAN_30, 'type'=>'number') //TODO Set default value to 84600
);
protected $books = array();
@@ -496,10 +498,24 @@ class page_admin_ui extends e_admin_ui
$this->fields['page_template']['writeParms'] = $this->templates;
$this->fields['menu_template']['writeParms'] = e107::getLayouts('', 'menu', 'front', '', true, false);
+
+ $tmp = e107::getLayouts('', 'chapter', 'front', '', true, false);
+ $tmpl = array();
+ foreach($tmp as $key=>$val)
+ {
+ if(substr($key,0,3) != 'nav')
+ {
+ $tmpl[$key] = $val;
+ }
+ }
+
+
+ $this->prefs['listBooksTemplate']['writeParms'] = $tmpl;
+
$sql = e107::getDb();
+
+
$sql->gen("SELECT chapter_id,chapter_name,chapter_parent FROM #page_chapters ORDER BY chapter_parent asc, chapter_order");
-
-
while($row = $sql->fetch())
{
$cat = $row['chapter_id'];
diff --git a/e107_core/templates/chapter_template.php b/e107_core/templates/chapter_template.php
index a7971bb8d..cacfb2fdb 100644
--- a/e107_core/templates/chapter_template.php
+++ b/e107_core/templates/chapter_template.php
@@ -20,7 +20,9 @@ $CHAPTER_TEMPLATE['default']['listChapters']['start'] = "
{CHAPTER_NAME}
{PAGES}";
$CHAPTER_TEMPLATE['default']['listChapters']['end'] = "
";
-
+$CHAPTER_TEMPLATE['default']['listBooks']['start'] = "";
+$CHAPTER_TEMPLATE['default']['listBooks']['item'] = "{BOOK_NAME}
{CHAPTERS}";
+$CHAPTER_TEMPLATE['default']['listBooks']['end'] = "
";
@@ -99,6 +101,7 @@ $CHAPTER_TEMPLATE['nav']['listChapters']['submenu_item_active'] = '
$CHAPTER_TEMPLATE['nav']['listChapters']['submenu_end'] = '';
+$CHAPTER_TEMPLATE['nav']['listBooks'] = $CHAPTER_TEMPLATE['nav']['listChapters'];
$CHAPTER_TEMPLATE['nav']['listPages'] = $CHAPTER_TEMPLATE['nav']['listChapters'];
$CHAPTER_TEMPLATE['nav']['showPage'] = $CHAPTER_TEMPLATE['nav']['listChapters'];
diff --git a/e107_core/xml/default_install.xml b/e107_core/xml/default_install.xml
index 60a1d53c4..c370201ad 100644
--- a/e107_core/xml/default_install.xml
+++ b/e107_core/xml/default_install.xml
@@ -161,6 +161,7 @@
250
1
1
+ 84600
0
[censored]
diff --git a/e107_plugins/page/e_shortcode.php b/e107_plugins/page/e_shortcode.php
index 62ee3e626..e30922fab 100644
--- a/e107_plugins/page/e_shortcode.php
+++ b/e107_plugins/page/e_shortcode.php
@@ -19,7 +19,9 @@ class page_shortcodes extends e_shortcode
$this->request = e107::getRegistry('core/pages/request');
- if((varset($this->request['action']) == 'listPages' || varset($this->request['action']) == 'listChapters') && vartrue($this->request['id']))
+ $action = varset($this->request['action']);
+
+ if(($action == 'listPages' || $action == 'listChapters') && vartrue($this->request['id']))
{
$this->var = e107::getDb()->retrieve('page_chapters','chapter_name, chapter_meta_description','chapter_id = '.intval($this->request['id']).' LIMIT 1');
}
@@ -33,7 +35,7 @@ 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);
-
+
$tmpl = e107::getCoreTemplate('chapter', vartrue($parm['template'],'nav'), true, true); // always merge
$template = $tmpl['showPage'];
@@ -44,6 +46,15 @@ class page_shortcodes extends e_shortcode
{
switch ($request['action'])
{
+ case 'listBooks':
+ $parm['cbook'] = 'all';
+ $template = $tmpl['listBooks'];
+ if(e107::getPref('listBooks',false) == false) // List Books has been disabled.
+ {
+ return false;
+ }
+ break;
+
case 'listChapters':
$parm['cbook'] = $request['id'];
$template = $tmpl['listChapters'];
@@ -52,6 +63,7 @@ class page_shortcodes extends e_shortcode
case 'listPages':
$parm['cchapter'] = $request['id'];
$template = $tmpl['listPages'];
+
break;
case 'showPage':
@@ -69,7 +81,7 @@ class page_shortcodes extends e_shortcode
$parm = '';
}
-
+
$links = e107::getAddon('page', 'e_sitelink');
$data = $links->pageNav($parm);
diff --git a/e107_plugins/page/e_sitelink.php b/e107_plugins/page/e_sitelink.php
index ce17fe955..77deec67b 100644
--- a/e107_plugins/page/e_sitelink.php
+++ b/e107_plugins/page/e_sitelink.php
@@ -122,12 +122,14 @@ 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']);
$parent = intval($options['book']);
$title = $sql->retrieve('page_chapters', 'chapter_name', 'chapter_id='.intval($options['book']));
+
+ // print_a('parent='.$parent);
}
@@ -154,11 +156,11 @@ class page_sitelink // include plugin-folder in the name.
);
}
-
- $outArray = array();
- $parent = vartrue($options['book']) ? $options['book'] : 0;
- $ret = e107::getNav()->compile($arr, $outArray, $parent);
+ $outArray = array();
+ $parent = vartrue($options['book']) ? intval($options['book']) : 0;
+ $ret = e107::getNav()->compile($arr, $outArray, $parent);
+
if(!$title) return $ret;
return array('title' => $title, 'body' => $ret);
}
diff --git a/e107_themes/bootstrap/templates/chapter_template.php b/e107_themes/bootstrap/templates/chapter_template.php
index b12e468e9..e99dc130a 100644
--- a/e107_themes/bootstrap/templates/chapter_template.php
+++ b/e107_themes/bootstrap/templates/chapter_template.php
@@ -20,14 +20,21 @@
$CHAPTER_TEMPLATE['docs']['listPages']['end'] = '';
- $CHAPTER_TEMPLATE['docs']['listChapters']['start'] = '';
- $CHAPTER_TEMPLATE['docs']['listChapters']['item'] = "{CHAPTER_NAME}
+ $CHAPTER_TEMPLATE['docs']['listChapters']['start'] = '';
+ $CHAPTER_TEMPLATE['docs']['listChapters']['item'] = "
";
- $CHAPTER_TEMPLATE['docs']['listChapters']['end'] = "";
-
+ $CHAPTER_TEMPLATE['docs']['listChapters']['end'] = '';
+ $CHAPTER_TEMPLATE['docs']['listBooks']['caption'] = '';
+ $CHAPTER_TEMPLATE['docs']['listBooks']['start'] = '';
+ $CHAPTER_TEMPLATE['docs']['listBooks']['item'] = "
+ ";
+ $CHAPTER_TEMPLATE['docs']['listBooks']['end'] = '';
@@ -37,16 +44,17 @@
$CHAPTER_TEMPLATE['navdocs']['listChapters']['start'] = '';
$CHAPTER_TEMPLATE['navdocs']['listChapters']['item'] = '
- -
+
-
{LINK_NAME}
';
-
- $CHAPTER_TEMPLATE['navdocs']['listPages'] = $CHAPTER_TEMPLATE['navdocs']['listChapters'];
- $CHAPTER_TEMPLATE['navdocs']['showPage'] = $CHAPTER_TEMPLATE['navdocs']['listChapters'];
+ // These templates are the same as above, so we just give them the same value.
+ $CHAPTER_TEMPLATE['navdocs']['listBooks'] = $CHAPTER_TEMPLATE['navdocs']['listChapters'];
+ $CHAPTER_TEMPLATE['navdocs']['listPages'] = $CHAPTER_TEMPLATE['navdocs']['listChapters'];
+ $CHAPTER_TEMPLATE['navdocs']['showPage'] = $CHAPTER_TEMPLATE['navdocs']['listChapters'];
diff --git a/page.php b/page.php
index c9abdc950..11e59e29f 100644
--- a/page.php
+++ b/page.php
@@ -165,24 +165,63 @@ class pageClass
- //XXX - May be better to compile into assoc 'tree' array first. ie. books/chapters/pages.
+ /**
+ * @todo Check userclasses
+ * @todo sef urls
+ */
function listBooks()
{
$sql = e107::getDb('sql2');
$tp = e107::getParser();
+ $frm = e107::getForm();
- if($sql->select("page_chapters", "*", "chapter_parent ='0' ORDER BY chapter_order ASC "))
+ $text = "";
+
+
+ if(e107::getPref('listBooks',false) && $sql->select("page_chapters", "*", "chapter_parent ='0' ORDER BY chapter_order ASC "))
{
+ $layout = e107::getPref('listBooksTemplate','default');
+ $tml = e107::getCoreTemplate('chapter','', true, true); // always merge
+ $tmpl = varset($tml[$layout]);
+ $template = $tmpl['listBooks'];
+
+ $text = $template['start'];
+
while($row = $sql->fetch())
{
- $text .= "".$tp->toHtml($row['chapter_name'])."
"; // Book Title.
- $text .= $this->listChapters($row['chapter_id']);
+ $var = array(
+ 'BOOK_NAME' => $tp->toHtml($row['chapter_name']),
+ 'BOOK_ANCHOR' => $frm->name2id($row['chapter_name']),
+ 'BOOK_DESCRIPTION' => $tp->toHtml($row['chapter_meta_description'],true,'BODY'),
+ 'CHAPTERS' => $this->listChapters(intval($row['chapter_id'])),
+ 'BOOK_URL' => e_BASE."page.php?bk=".intval($row['chapter_id']) // FIXME SEF-URL
+ );
+
+ $text .= $tp->simpleParse($template['item'],$var);
}
}
- $text .= "Other Articles
"; // Book Title.
- $text .= $this->listPages(0); // Pages unassigned to Book/Chapters.
- e107::getRender()->tablerender("Articles", $text,"cpage_list");
+ if(e107::getPref('listPages',false))
+ {
+ $text .= "Other Articles
"; // Book Title.
+ $text .= $this->listPages(0); // Pages unassigned to Book/Chapters.
+ } //
+
+ if($text)
+ {
+ $caption = varset($template['caption'],"Articles");
+ e107::getRender()->tablerender($caption, $text, "cpage_list");
+ }
+ else
+ {
+ message_handler("MESSAGE", LAN_PAGE_1);
+ require_once(FOOTERF); // prevent message from showing twice and still listing chapters
+ exit;
+ }
+
+
+
+
}
@@ -193,6 +232,7 @@ class pageClass
{
$sql = e107::getDb('chap');
$tp = e107::getParser();
+ $frm = e107::getForm();
// retrieve the template to use for this book
if(!$layout = $sql->retrieve('page_chapters','chapter_template','chapter_id = '.intval($book).' LIMIT 1'))
@@ -214,6 +254,7 @@ class pageClass
{
$var = array(
'CHAPTER_NAME' => $tp->toHtml($row['chapter_name']),
+ 'CHAPTER_ANCHOR' => $frm->name2id($row['chapter_name']),
'CHAPTER_DESCRIPTION' => $tp->toHtml($row['chapter_meta_description'],true,'BODY'),
'PAGES' => $this->listPages(intval($row['chapter_id'])),
'CHAPTER_URL' => e_BASE."page.php?ch=".intval($row['chapter_id']) // FIXME SEF-URL
@@ -256,16 +297,6 @@ class pageClass
// $tmpl = e107::getCoreTemplate('chapter','docs', true, true); // always merge
$template = $tmpl['listPages'];
-
-
- if(!e107::getPref('listPages', false))
- {
- message_handler("MESSAGE", LAN_PAGE_1);
- require_once(FOOTERF); // prevent message from showing twice and still listing chapters
- exit;
- }
- else
- {
if(!$count = $sql->select("page", "*", "page_title !='' AND page_chapter=".intval($chapt)." AND page_class IN (".USERCLASS_LIST.") ORDER BY page_order ASC "))
{
return e107::getMessage()->addInfo(LAN_PAGE_2)->render();
@@ -299,7 +330,7 @@ class pageClass
// $caption = ($title !='')? $title: LAN_PAGE_11;
// e107::getRender()->tablerender($caption, $text,"cpage_list");
}
- }
+
return $text;
}