mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 20:57:26 +02:00
Book listing template added.
This commit is contained in:
@@ -450,6 +450,8 @@ class page_admin_ui extends e_admin_ui
|
||||
|
||||
protected $prefs = array(
|
||||
'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
|
||||
);
|
||||
|
||||
@@ -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'];
|
||||
|
@@ -20,7 +20,9 @@ $CHAPTER_TEMPLATE['default']['listChapters']['start'] = "<ul class='page-chap
|
||||
$CHAPTER_TEMPLATE['default']['listChapters']['item'] = "<li><h4>{CHAPTER_NAME}</h4>{PAGES}";
|
||||
$CHAPTER_TEMPLATE['default']['listChapters']['end'] = "</ul>";
|
||||
|
||||
|
||||
$CHAPTER_TEMPLATE['default']['listBooks']['start'] = "<ul class='page-chapters-list'>";
|
||||
$CHAPTER_TEMPLATE['default']['listBooks']['item'] = "<li><h3>{BOOK_NAME}</h3>{CHAPTERS}";
|
||||
$CHAPTER_TEMPLATE['default']['listBooks']['end'] = "</ul>";
|
||||
|
||||
|
||||
|
||||
@@ -99,6 +101,7 @@ $CHAPTER_TEMPLATE['nav']['listChapters']['submenu_item_active'] = '
|
||||
$CHAPTER_TEMPLATE['nav']['listChapters']['submenu_end'] = '</ul>';
|
||||
|
||||
|
||||
$CHAPTER_TEMPLATE['nav']['listBooks'] = $CHAPTER_TEMPLATE['nav']['listChapters'];
|
||||
$CHAPTER_TEMPLATE['nav']['listPages'] = $CHAPTER_TEMPLATE['nav']['listChapters'];
|
||||
$CHAPTER_TEMPLATE['nav']['showPage'] = $CHAPTER_TEMPLATE['nav']['listChapters'];
|
||||
|
||||
|
@@ -161,6 +161,7 @@
|
||||
<core name="post_script">250</core>
|
||||
<core name="filter_script">1</core>
|
||||
<core name="html_abuse">1</core>
|
||||
<core name="pageCookieExpire">84600</core>
|
||||
<core name="predefinedLoginName"></core>
|
||||
<core name="profanity_filter">0</core>
|
||||
<core name="profanity_replace">[censored]</core>
|
||||
|
@@ -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');
|
||||
}
|
||||
@@ -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':
|
||||
|
@@ -128,6 +128,8 @@ class page_sitelink // include plugin-folder in the name.
|
||||
$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);
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +158,7 @@ class page_sitelink // include plugin-folder in the name.
|
||||
|
||||
|
||||
$outArray = array();
|
||||
$parent = vartrue($options['book']) ? $options['book'] : 0;
|
||||
$parent = vartrue($options['book']) ? intval($options['book']) : 0;
|
||||
$ret = e107::getNav()->compile($arr, $outArray, $parent);
|
||||
|
||||
if(!$title) return $ret;
|
||||
|
@@ -20,14 +20,21 @@
|
||||
$CHAPTER_TEMPLATE['docs']['listPages']['end'] = '';
|
||||
|
||||
|
||||
$CHAPTER_TEMPLATE['docs']['listChapters']['start'] = '<section id="{CPAGEANCHOR}">';
|
||||
$CHAPTER_TEMPLATE['docs']['listChapters']['item'] = "<a href='{CHAPTER_URL}'><h1>{CHAPTER_NAME}</h1></a>
|
||||
$CHAPTER_TEMPLATE['docs']['listChapters']['start'] = '';
|
||||
$CHAPTER_TEMPLATE['docs']['listChapters']['item'] = "<section id='{CHAPTER_ANCHOR}'><a href='{CHAPTER_URL}'><h1>{CHAPTER_NAME}</h1></a>
|
||||
{CHAPTER_DESCRIPTION}
|
||||
</section>
|
||||
";
|
||||
$CHAPTER_TEMPLATE['docs']['listChapters']['end'] = "</section>";
|
||||
|
||||
$CHAPTER_TEMPLATE['docs']['listChapters']['end'] = '';
|
||||
|
||||
|
||||
$CHAPTER_TEMPLATE['docs']['listBooks']['caption'] = '';
|
||||
$CHAPTER_TEMPLATE['docs']['listBooks']['start'] = '';
|
||||
$CHAPTER_TEMPLATE['docs']['listBooks']['item'] = "<section id='{BOOK_ANCHOR}'><a href='{BOOK_URL}'><h1>{BOOK_NAME}</h1></a>
|
||||
{BOOK_DESCRIPTION}
|
||||
</section>
|
||||
";
|
||||
$CHAPTER_TEMPLATE['docs']['listBooks']['end'] = '';
|
||||
|
||||
|
||||
|
||||
@@ -37,14 +44,15 @@
|
||||
$CHAPTER_TEMPLATE['navdocs']['listChapters']['start'] = '<ul class="nav nav-list bs-docs-sidenav">';
|
||||
|
||||
$CHAPTER_TEMPLATE['navdocs']['listChapters']['item'] = '
|
||||
<li>
|
||||
<li class="{LINK_ACTIVE}">
|
||||
<a role="button" href="{LINK_ANCHOR}" ><i class="icon-chevron-right"></i>
|
||||
{LINK_NAME}
|
||||
</a>
|
||||
</li>
|
||||
';
|
||||
|
||||
|
||||
// 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'];
|
||||
|
||||
|
63
page.php
63
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 .= "<h3 class='page-book-list'>".$tp->toHtml($row['chapter_name'])."</h3>"; // 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);
|
||||
}
|
||||
}
|
||||
|
||||
if(e107::getPref('listPages',false))
|
||||
{
|
||||
$text .= "<h3>Other Articles</h3>"; // Book Title.
|
||||
$text .= $this->listPages(0); // Pages unassigned to Book/Chapters.
|
||||
e107::getRender()->tablerender("Articles", $text,"cpage_list");
|
||||
} //
|
||||
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user