diff --git a/e107_admin/links.php b/e107_admin/links.php index 9cb4e39c4..95528d34f 100644 --- a/e107_admin/links.php +++ b/e107_admin/links.php @@ -557,13 +557,17 @@ class links_admin_form_ui extends e_admin_form_ui $tp = e107::getParser(); $tmp = e107::getAddonConfig('e_sitelink','sitelink'); - + foreach($tmp as $cat=> $array) { $func = array(); foreach($array as $val) { $newkey = $cat.'::'.$val['function']; + if(vartrue($val['parm'])) + { + $newkey .= "(".$val['parm'].")"; + } $func[$newkey] = $tp->toHtml($val['name'],'','TITLE'); } $this->linkFunctions[$cat] = $func; diff --git a/e107_handlers/sitelinks_class.php b/e107_handlers/sitelinks_class.php index 77274450b..52f834bfe 100644 --- a/e107_handlers/sitelinks_class.php +++ b/e107_handlers/sitelinks_class.php @@ -48,11 +48,19 @@ class sitelinks $this->eLinkList['head_menu'][] = $row; if(vartrue($row['link_function'])) { + $parm = false; list($path,$method) = explode("::",$row['link_function']); + + if(strpos($method,"(")) + { + list($method,$prm) = explode("(",$method); + $parm = rtrim($prm,")"); + } + if(file_exists(e_PLUGIN.$path."/e_sitelink.php") && include_once(e_PLUGIN.$path."/e_sitelink.php")) { $class = $path."_sitelink"; - $sublinkArray = e107::callMethod($class,$method); //TODO Cache it. + $sublinkArray = e107::callMethod($class,$method,$parm); //TODO Cache it. if(vartrue($sublinkArray)) { $this->eLinkList['sub_'.$row['link_id']] = $sublinkArray; @@ -1458,6 +1466,7 @@ class e_navigation /** * Check for Dynamic Function + * @example class:method($parm) */ protected function isDynamic($row) { @@ -1467,12 +1476,21 @@ class e_navigation } if(vartrue($row['link_function'])) - { + { + $parm = false; + list($path,$method) = explode("::",$row['link_function']); + + if(strpos($method,"(")) + { + list($method,$prm) = explode("(",$method); + $parm = rtrim($prm,")"); + } + if(include_once(e_PLUGIN.$path."/e_sitelink.php")) { $class = $path."_sitelink"; - if($sublinkArray = e107::callMethod($class,$method)) //TODO Cache it. + if($sublinkArray = e107::callMethod($class,$method,$parm)) //TODO Cache it. { return $sublinkArray; } diff --git a/e107_plugins/page/e_sitelink.php b/e107_plugins/page/e_sitelink.php index 77deec67b..1ee6946ee 100644 --- a/e107_plugins/page/e_sitelink.php +++ b/e107_plugins/page/e_sitelink.php @@ -16,17 +16,76 @@ class page_sitelink // include plugin-folder in the name. function config() { $links = array(); + $sql = e107::getDb(); + + $links[] = array( + 'name' => "All Books", + 'function' => "bookNav", + 'description' => "A list of all books" + ); + + $books = $sql->retrieve("SELECT * FROM #page_chapters WHERE chapter_parent =0 ORDER BY chapter_order ASC" , true); + + foreach($books as $row) + { + $links[] = array( + 'name' => "All Chapters from ".$row['chapter_name'], + 'function' => "chapterNav", + 'parm' => $row['chapter_id'], + 'description' => "A list of all chapters from the book ".$row['chapter_name'] + ); + } $links[] = array( 'name' => "All Pages", 'function' => "pageNav", - 'description' => "" + 'parm' => "", + 'description' => "A list of all pages" ); return $links; } + /** + * Return a tree of all books and their chapters. + */ + public function bookNav($book) + { + return $this->pageNav('book=0'); + } + /** + * Return a list of all chapters from a sepcific book. + */ + public function chapterNav($book) + { + $sql = e107::getDb(); + $tp = e107::getParser(); + + if($sql->select("page_chapters", "*", "chapter_parent = ".intval($book)." ORDER BY chapter_order ASC ")) + { + $sublinks = array(); + + while($row = $sql->fetch()) + { + $sublinks[] = array( + 'link_name' => $tp->toHtml($row['chapter_name'],'','TITLE'), + 'link_url' => 'page.php?ch='.$row['chapter_id'], //TODO FIXME chapter_sef support + 'link_description' => '', + 'link_button' => '', + 'link_category' => '', + 'link_order' => '', + 'link_parent' => $row['chapter_parent'], + 'link_open' => '', + 'link_class' => 0 + ); + + } + + return $sublinks; + + } + } function pageNav($parm='') {