mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 12:48:26 +02:00
Book listing template added.
This commit is contained in:
@@ -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_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_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_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'),
|
'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 $fieldpref = array("page_id","page_title","page_chapter","page_template","page_author","page_class");
|
||||||
|
|
||||||
protected $prefs = array(
|
protected $prefs = array(
|
||||||
'listPages' => array('title'=> CUSLAN_29, 'type'=>'boolean'),
|
'listPages' => array('title'=> CUSLAN_29, 'type'=>'boolean'),
|
||||||
'pageCookieExpire' => array('title'=> CUSLAN_30, 'type'=>'number') //TODO Set default value to 84600
|
'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();
|
protected $books = array();
|
||||||
@@ -496,10 +498,24 @@ class page_admin_ui extends e_admin_ui
|
|||||||
$this->fields['page_template']['writeParms'] = $this->templates;
|
$this->fields['page_template']['writeParms'] = $this->templates;
|
||||||
$this->fields['menu_template']['writeParms'] = e107::getLayouts('', 'menu', 'front', '', true, false);
|
$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 = e107::getDb();
|
||||||
|
|
||||||
|
|
||||||
$sql->gen("SELECT chapter_id,chapter_name,chapter_parent FROM #page_chapters ORDER BY chapter_parent asc, chapter_order");
|
$sql->gen("SELECT chapter_id,chapter_name,chapter_parent FROM #page_chapters ORDER BY chapter_parent asc, chapter_order");
|
||||||
|
|
||||||
|
|
||||||
while($row = $sql->fetch())
|
while($row = $sql->fetch())
|
||||||
{
|
{
|
||||||
$cat = $row['chapter_id'];
|
$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']['item'] = "<li><h4>{CHAPTER_NAME}</h4>{PAGES}";
|
||||||
$CHAPTER_TEMPLATE['default']['listChapters']['end'] = "</ul>";
|
$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']['listChapters']['submenu_end'] = '</ul>';
|
||||||
|
|
||||||
|
|
||||||
|
$CHAPTER_TEMPLATE['nav']['listBooks'] = $CHAPTER_TEMPLATE['nav']['listChapters'];
|
||||||
$CHAPTER_TEMPLATE['nav']['listPages'] = $CHAPTER_TEMPLATE['nav']['listChapters'];
|
$CHAPTER_TEMPLATE['nav']['listPages'] = $CHAPTER_TEMPLATE['nav']['listChapters'];
|
||||||
$CHAPTER_TEMPLATE['nav']['showPage'] = $CHAPTER_TEMPLATE['nav']['listChapters'];
|
$CHAPTER_TEMPLATE['nav']['showPage'] = $CHAPTER_TEMPLATE['nav']['listChapters'];
|
||||||
|
|
||||||
|
@@ -161,6 +161,7 @@
|
|||||||
<core name="post_script">250</core>
|
<core name="post_script">250</core>
|
||||||
<core name="filter_script">1</core>
|
<core name="filter_script">1</core>
|
||||||
<core name="html_abuse">1</core>
|
<core name="html_abuse">1</core>
|
||||||
|
<core name="pageCookieExpire">84600</core>
|
||||||
<core name="predefinedLoginName"></core>
|
<core name="predefinedLoginName"></core>
|
||||||
<core name="profanity_filter">0</core>
|
<core name="profanity_filter">0</core>
|
||||||
<core name="profanity_replace">[censored]</core>
|
<core name="profanity_replace">[censored]</core>
|
||||||
|
@@ -19,7 +19,9 @@ class page_shortcodes extends e_shortcode
|
|||||||
|
|
||||||
$this->request = e107::getRegistry('core/pages/request');
|
$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');
|
$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.
|
function sc_page_navigation($parm='') // TODO when No $parm provided, auto-detect based on URL which book/chapters to display.
|
||||||
{
|
{
|
||||||
// $parm = eHelper::scParams($parm);
|
// $parm = eHelper::scParams($parm);
|
||||||
|
|
||||||
$tmpl = e107::getCoreTemplate('chapter', vartrue($parm['template'],'nav'), true, true); // always merge
|
$tmpl = e107::getCoreTemplate('chapter', vartrue($parm['template'],'nav'), true, true); // always merge
|
||||||
|
|
||||||
$template = $tmpl['showPage'];
|
$template = $tmpl['showPage'];
|
||||||
@@ -44,6 +46,15 @@ class page_shortcodes extends e_shortcode
|
|||||||
{
|
{
|
||||||
switch ($request['action'])
|
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':
|
case 'listChapters':
|
||||||
$parm['cbook'] = $request['id'];
|
$parm['cbook'] = $request['id'];
|
||||||
$template = $tmpl['listChapters'];
|
$template = $tmpl['listChapters'];
|
||||||
@@ -52,6 +63,7 @@ class page_shortcodes extends e_shortcode
|
|||||||
case 'listPages':
|
case 'listPages':
|
||||||
$parm['cchapter'] = $request['id'];
|
$parm['cchapter'] = $request['id'];
|
||||||
$template = $tmpl['listPages'];
|
$template = $tmpl['listPages'];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'showPage':
|
case 'showPage':
|
||||||
@@ -69,7 +81,7 @@ class page_shortcodes extends e_shortcode
|
|||||||
$parm = '';
|
$parm = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$links = e107::getAddon('page', 'e_sitelink');
|
$links = e107::getAddon('page', 'e_sitelink');
|
||||||
|
|
||||||
$data = $links->pageNav($parm);
|
$data = $links->pageNav($parm);
|
||||||
|
@@ -122,12 +122,14 @@ class page_sitelink // include plugin-folder in the name.
|
|||||||
$title = false;
|
$title = false;
|
||||||
if(vartrue($options['book']))
|
if(vartrue($options['book']))
|
||||||
{
|
{
|
||||||
|
|
||||||
// XXX discuss the idea here
|
// XXX discuss the idea here
|
||||||
//$filter = "chapter_id > ".intval($options['book']);
|
//$filter = "chapter_id > ".intval($options['book']);
|
||||||
$filter = "chapter_parent = ".intval($options['book']);
|
$filter = "chapter_parent = ".intval($options['book']);
|
||||||
$parent = intval($options['book']);
|
$parent = intval($options['book']);
|
||||||
$title = $sql->retrieve('page_chapters', 'chapter_name', 'chapter_id='.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;
|
if(!$title) return $ret;
|
||||||
return array('title' => $title, 'body' => $ret);
|
return array('title' => $title, 'body' => $ret);
|
||||||
}
|
}
|
||||||
|
@@ -20,14 +20,21 @@
|
|||||||
$CHAPTER_TEMPLATE['docs']['listPages']['end'] = '';
|
$CHAPTER_TEMPLATE['docs']['listPages']['end'] = '';
|
||||||
|
|
||||||
|
|
||||||
$CHAPTER_TEMPLATE['docs']['listChapters']['start'] = '<section id="{CPAGEANCHOR}">';
|
$CHAPTER_TEMPLATE['docs']['listChapters']['start'] = '';
|
||||||
$CHAPTER_TEMPLATE['docs']['listChapters']['item'] = "<a href='{CHAPTER_URL}'><h1>{CHAPTER_NAME}</h1></a>
|
$CHAPTER_TEMPLATE['docs']['listChapters']['item'] = "<section id='{CHAPTER_ANCHOR}'><a href='{CHAPTER_URL}'><h1>{CHAPTER_NAME}</h1></a>
|
||||||
{CHAPTER_DESCRIPTION}
|
{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,16 +44,17 @@
|
|||||||
$CHAPTER_TEMPLATE['navdocs']['listChapters']['start'] = '<ul class="nav nav-list bs-docs-sidenav">';
|
$CHAPTER_TEMPLATE['navdocs']['listChapters']['start'] = '<ul class="nav nav-list bs-docs-sidenav">';
|
||||||
|
|
||||||
$CHAPTER_TEMPLATE['navdocs']['listChapters']['item'] = '
|
$CHAPTER_TEMPLATE['navdocs']['listChapters']['item'] = '
|
||||||
<li>
|
<li class="{LINK_ACTIVE}">
|
||||||
<a role="button" href="{LINK_ANCHOR}" ><i class="icon-chevron-right"></i>
|
<a role="button" href="{LINK_ANCHOR}" ><i class="icon-chevron-right"></i>
|
||||||
{LINK_NAME}
|
{LINK_NAME}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
';
|
';
|
||||||
|
|
||||||
|
// These templates are the same as above, so we just give them the same value.
|
||||||
$CHAPTER_TEMPLATE['navdocs']['listPages'] = $CHAPTER_TEMPLATE['navdocs']['listChapters'];
|
$CHAPTER_TEMPLATE['navdocs']['listBooks'] = $CHAPTER_TEMPLATE['navdocs']['listChapters'];
|
||||||
$CHAPTER_TEMPLATE['navdocs']['showPage'] = $CHAPTER_TEMPLATE['navdocs']['listChapters'];
|
$CHAPTER_TEMPLATE['navdocs']['listPages'] = $CHAPTER_TEMPLATE['navdocs']['listChapters'];
|
||||||
|
$CHAPTER_TEMPLATE['navdocs']['showPage'] = $CHAPTER_TEMPLATE['navdocs']['listChapters'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
67
page.php
67
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()
|
function listBooks()
|
||||||
{
|
{
|
||||||
$sql = e107::getDb('sql2');
|
$sql = e107::getDb('sql2');
|
||||||
$tp = e107::getParser();
|
$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())
|
while($row = $sql->fetch())
|
||||||
{
|
{
|
||||||
$text .= "<h3 class='page-book-list'>".$tp->toHtml($row['chapter_name'])."</h3>"; // Book Title.
|
$var = array(
|
||||||
$text .= $this->listChapters($row['chapter_id']);
|
'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 .= "<h3>Other Articles</h3>"; // Book Title.
|
if(e107::getPref('listPages',false))
|
||||||
$text .= $this->listPages(0); // Pages unassigned to Book/Chapters.
|
{
|
||||||
e107::getRender()->tablerender("Articles", $text,"cpage_list");
|
$text .= "<h3>Other Articles</h3>"; // 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');
|
$sql = e107::getDb('chap');
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
$frm = e107::getForm();
|
||||||
|
|
||||||
// retrieve the template to use for this book
|
// retrieve the template to use for this book
|
||||||
if(!$layout = $sql->retrieve('page_chapters','chapter_template','chapter_id = '.intval($book).' LIMIT 1'))
|
if(!$layout = $sql->retrieve('page_chapters','chapter_template','chapter_id = '.intval($book).' LIMIT 1'))
|
||||||
@@ -214,6 +254,7 @@ class pageClass
|
|||||||
{
|
{
|
||||||
$var = array(
|
$var = array(
|
||||||
'CHAPTER_NAME' => $tp->toHtml($row['chapter_name']),
|
'CHAPTER_NAME' => $tp->toHtml($row['chapter_name']),
|
||||||
|
'CHAPTER_ANCHOR' => $frm->name2id($row['chapter_name']),
|
||||||
'CHAPTER_DESCRIPTION' => $tp->toHtml($row['chapter_meta_description'],true,'BODY'),
|
'CHAPTER_DESCRIPTION' => $tp->toHtml($row['chapter_meta_description'],true,'BODY'),
|
||||||
'PAGES' => $this->listPages(intval($row['chapter_id'])),
|
'PAGES' => $this->listPages(intval($row['chapter_id'])),
|
||||||
'CHAPTER_URL' => e_BASE."page.php?ch=".intval($row['chapter_id']) // FIXME SEF-URL
|
'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
|
// $tmpl = e107::getCoreTemplate('chapter','docs', true, true); // always merge
|
||||||
$template = $tmpl['listPages'];
|
$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 "))
|
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();
|
return e107::getMessage()->addInfo(LAN_PAGE_2)->render();
|
||||||
@@ -299,7 +330,7 @@ class pageClass
|
|||||||
// $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");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user