mirror of
https://github.com/e107inc/e107.git
synced 2025-08-12 09:34:54 +02:00
The {CHAPTER_MENUS} shortcode now accepts the 'template' parameter. Additional Custom Menu shortcodes/aliases added:
{CMENU_TAB_ACTIVE} {CMENU_BUTTON_TEXT} {CMENU_BUTTON_URL}
This commit is contained in:
@@ -344,23 +344,43 @@ class cpage_shortcodes extends e_shortcode
|
|||||||
{
|
{
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
|
||||||
|
if($parm == 'url')
|
||||||
|
{
|
||||||
|
$img = ($tp->isVideo($this->var['menu_image'])) ? $tp->toVideo($this->var['menu_image'], array('thumb'=>'src')) : $tp->thumbUrl($this->var['menu_image']);
|
||||||
|
return $img;
|
||||||
|
}
|
||||||
|
|
||||||
if($video = $tp->toVideo($this->var['menu_image']))
|
if($video = $tp->toVideo($this->var['menu_image']))
|
||||||
{
|
{
|
||||||
return $video;
|
return $video;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($parm == 'url')
|
|
||||||
{
|
|
||||||
$img = $tp->thumbUrl($this->var['menu_image']);
|
|
||||||
return $img;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $tp->toImage($this->var['menu_image'], $parm);
|
return $tp->toImage($this->var['menu_image'], $parm);
|
||||||
|
|
||||||
//return "<img class='".$class."' src='".$img."' alt='' ".$dimensions." />";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function sc_cmenu_tab_active($parm=null)
|
||||||
|
{
|
||||||
|
if(!empty($this->var['cmenu_tab_active']))
|
||||||
|
{
|
||||||
|
return 'active';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sc_cmenu_button_text($parm=null)
|
||||||
|
{
|
||||||
|
return (empty($this->var['menu_button_text'])) ? LAN_READ_MORE : $this->var['menu_button_text'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function sc_cmenu_button_url($parm=null)
|
||||||
|
{
|
||||||
|
return $this->sc_cmenuurl($parm);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function sc_cmenuicon($parm='')
|
function sc_cmenuicon($parm='')
|
||||||
{
|
{
|
||||||
if($parm === 'css')
|
if($parm === 'css')
|
||||||
|
@@ -133,14 +133,25 @@ class page_shortcodes extends e_shortcode
|
|||||||
* Render All visible Menus from a specific chapter.
|
* Render All visible Menus from a specific chapter.
|
||||||
* @param null $parm
|
* @param null $parm
|
||||||
* @example {CHAPTER_MENUS: name=chapter-sef-url}
|
* @example {CHAPTER_MENUS: name=chapter-sef-url}
|
||||||
|
* @example {CHAPTER_MENUS: name=chapter-sef-url&template=xxxxx}
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function sc_chapter_menus($parm=null)
|
function sc_chapter_menus($parm=null)
|
||||||
{
|
{
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
$query = "SELECT * FROM #page AS p LEFT JOIN #page_chapters as ch ON p.page_chapter=ch.chapter_id WHERE ch.chapter_visibility IN (" . USERCLASS_LIST . ") AND p.menu_class IN (" . USERCLASS_LIST . ") AND ch.chapter_sef = '" . $tp->filter($parm['name'],'str') . "' ORDER BY p.page_order ASC ";
|
|
||||||
|
|
||||||
$text = '';
|
$text = '';
|
||||||
|
$start = '';
|
||||||
|
|
||||||
|
$sef = $tp->filter($parm['name'],'str');
|
||||||
|
|
||||||
|
$registry = 'e_shortcode/sc_chapter_menus/'.$sef;
|
||||||
|
|
||||||
|
if(!$pageArray = e107::getRegistry($registry))
|
||||||
|
{
|
||||||
|
$query = "SELECT * FROM #page AS p LEFT JOIN #page_chapters as ch ON p.page_chapter=ch.chapter_id WHERE ch.chapter_visibility IN (" . USERCLASS_LIST . ") AND p.menu_class IN (" . USERCLASS_LIST . ") AND ch.chapter_sef = '" . $sef . "' ORDER BY p.page_order ASC ";
|
||||||
|
|
||||||
|
e107::getDebug()->log("Loading page Chapters");
|
||||||
|
|
||||||
if(!$pageArray = e107::getDb()->retrieve($query, true))
|
if(!$pageArray = e107::getDb()->retrieve($query, true))
|
||||||
{
|
{
|
||||||
@@ -148,25 +159,57 @@ class page_shortcodes extends e_shortcode
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e107::setRegistry($registry, $pageArray);
|
||||||
|
}
|
||||||
|
|
||||||
$template = e107::getCoreTemplate('menu',null,true,true);
|
$template = e107::getCoreTemplate('menu',null,true,true);
|
||||||
|
|
||||||
$sc = e107::getScBatch('page', null, 'cpage');
|
$sc = e107::getScBatch('page', null, 'cpage');
|
||||||
$sc->setVars($pageArray[0]);
|
$sc->setVars($pageArray[0]);
|
||||||
$tpl = varset($pageArray[0]['menu_template'],'default'); // use start template from first row.
|
$tpl = varset($pageArray[0]['menu_template'],'default'); // use start template from first row.
|
||||||
|
|
||||||
$start = $tp->parseTemplate($template[$tpl]['start'],true,$sc);
|
if(!empty($parm['template']))
|
||||||
|
|
||||||
foreach($pageArray as $row)
|
|
||||||
{
|
{
|
||||||
$tpl = varset($row['menu_template'],'default');
|
|
||||||
$sc->setVars($row);
|
|
||||||
|
|
||||||
$text .= $tp->parseTemplate($template[$tpl]['body'],true,$sc);
|
$tpl = $parm['template'];
|
||||||
|
$start .= "<!-- CHAPTER_MENUS Start Template: ". $tpl." -->";
|
||||||
|
|
||||||
|
if(empty($template[$tpl]))
|
||||||
|
{
|
||||||
|
e107::getDebug()->log('{CHAPTER_MENUS: '.http_build_query($parm).'} has an empty template.');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$active = varset($parm['active'],1);
|
||||||
|
|
||||||
|
$start .= $tp->parseTemplate($template[$tpl]['start'],true,$sc);
|
||||||
|
|
||||||
|
$c=1;
|
||||||
|
foreach($pageArray as $row)
|
||||||
|
{
|
||||||
|
$row['cmenu_tab_active'] = ($c === $active) ? true : false;
|
||||||
|
|
||||||
|
if(empty($parm['template']))
|
||||||
|
{
|
||||||
|
$tpl = varset($row['menu_template'],'default');
|
||||||
|
}
|
||||||
|
|
||||||
|
$sc->setVars($row);
|
||||||
|
|
||||||
|
$text .= $tp->parseTemplate($template[$tpl]['body'],true,$sc);
|
||||||
|
$c++;
|
||||||
|
}
|
||||||
|
|
||||||
$end = $tp->parseTemplate($template[$tpl]['end'],true,$sc);
|
$end = $tp->parseTemplate($template[$tpl]['end'],true,$sc);
|
||||||
|
|
||||||
|
$end .= "<!-- ".http_build_query($parm)." -->";
|
||||||
|
|
||||||
|
if(!empty($parm['template']))
|
||||||
|
{
|
||||||
|
$end .= "<!-- CHAPTER_MENUS end template: ". $parm['template']." -->";
|
||||||
|
}
|
||||||
|
|
||||||
if(!empty($text))
|
if(!empty($text))
|
||||||
{
|
{
|
||||||
return $start . $text . $end;
|
return $start . $text . $end;
|
||||||
|
Reference in New Issue
Block a user