mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 21:57:51 +02:00
Added support for sitelink function parms. Added sitelink functions for Page books and book-chapters.
This commit is contained in:
@@ -557,13 +557,17 @@ class links_admin_form_ui extends e_admin_form_ui
|
|||||||
|
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
$tmp = e107::getAddonConfig('e_sitelink','sitelink');
|
$tmp = e107::getAddonConfig('e_sitelink','sitelink');
|
||||||
|
|
||||||
foreach($tmp as $cat=> $array)
|
foreach($tmp as $cat=> $array)
|
||||||
{
|
{
|
||||||
$func = array();
|
$func = array();
|
||||||
foreach($array as $val)
|
foreach($array as $val)
|
||||||
{
|
{
|
||||||
$newkey = $cat.'::'.$val['function'];
|
$newkey = $cat.'::'.$val['function'];
|
||||||
|
if(vartrue($val['parm']))
|
||||||
|
{
|
||||||
|
$newkey .= "(".$val['parm'].")";
|
||||||
|
}
|
||||||
$func[$newkey] = $tp->toHtml($val['name'],'','TITLE');
|
$func[$newkey] = $tp->toHtml($val['name'],'','TITLE');
|
||||||
}
|
}
|
||||||
$this->linkFunctions[$cat] = $func;
|
$this->linkFunctions[$cat] = $func;
|
||||||
|
@@ -48,11 +48,19 @@ class sitelinks
|
|||||||
$this->eLinkList['head_menu'][] = $row;
|
$this->eLinkList['head_menu'][] = $row;
|
||||||
if(vartrue($row['link_function']))
|
if(vartrue($row['link_function']))
|
||||||
{
|
{
|
||||||
|
$parm = false;
|
||||||
list($path,$method) = explode("::",$row['link_function']);
|
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"))
|
if(file_exists(e_PLUGIN.$path."/e_sitelink.php") && include_once(e_PLUGIN.$path."/e_sitelink.php"))
|
||||||
{
|
{
|
||||||
$class = $path."_sitelink";
|
$class = $path."_sitelink";
|
||||||
$sublinkArray = e107::callMethod($class,$method); //TODO Cache it.
|
$sublinkArray = e107::callMethod($class,$method,$parm); //TODO Cache it.
|
||||||
if(vartrue($sublinkArray))
|
if(vartrue($sublinkArray))
|
||||||
{
|
{
|
||||||
$this->eLinkList['sub_'.$row['link_id']] = $sublinkArray;
|
$this->eLinkList['sub_'.$row['link_id']] = $sublinkArray;
|
||||||
@@ -1458,6 +1466,7 @@ class e_navigation
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for Dynamic Function
|
* Check for Dynamic Function
|
||||||
|
* @example class:method($parm)
|
||||||
*/
|
*/
|
||||||
protected function isDynamic($row)
|
protected function isDynamic($row)
|
||||||
{
|
{
|
||||||
@@ -1467,12 +1476,21 @@ class e_navigation
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(vartrue($row['link_function']))
|
if(vartrue($row['link_function']))
|
||||||
{
|
{
|
||||||
|
$parm = false;
|
||||||
|
|
||||||
list($path,$method) = explode("::",$row['link_function']);
|
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"))
|
if(include_once(e_PLUGIN.$path."/e_sitelink.php"))
|
||||||
{
|
{
|
||||||
$class = $path."_sitelink";
|
$class = $path."_sitelink";
|
||||||
if($sublinkArray = e107::callMethod($class,$method)) //TODO Cache it.
|
if($sublinkArray = e107::callMethod($class,$method,$parm)) //TODO Cache it.
|
||||||
{
|
{
|
||||||
return $sublinkArray;
|
return $sublinkArray;
|
||||||
}
|
}
|
||||||
|
@@ -16,17 +16,76 @@ class page_sitelink // include plugin-folder in the name.
|
|||||||
function config()
|
function config()
|
||||||
{
|
{
|
||||||
$links = array();
|
$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(
|
$links[] = array(
|
||||||
'name' => "All Pages",
|
'name' => "All Pages",
|
||||||
'function' => "pageNav",
|
'function' => "pageNav",
|
||||||
'description' => ""
|
'parm' => "",
|
||||||
|
'description' => "A list of all pages"
|
||||||
);
|
);
|
||||||
|
|
||||||
return $links;
|
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='')
|
function pageNav($parm='')
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user