mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
{MENU} shortcode fixed for BC and added new ability to call a Page/Menu directly.
eg. {MENU|feature-1} called from within a template would render the menu called 'feature-1' found in the Pages/Menus area of admin.
This commit is contained in:
@@ -349,12 +349,13 @@ class page_admin_ui extends e_admin_ui
|
||||
'page_order' => array('title'=> LAN_ORDER, 'tab' => 1, 'type' => 'number', 'width' => 'auto', 'inline'=>true),
|
||||
|
||||
// Menu Tab XXX 'page_theme' is 'menu_name' - not caption.
|
||||
'page_theme' => array('title'=> "Menu Name", 'tab' => 2, 'type' => 'text', 'width' => 'auto','nolist'=>true, "help"=>"Will be listed in the Menu-Manager under this name or may be called using {MENU=name} in your theme."),
|
||||
'page_theme' => array('title'=> "Menu Name", 'tab' => 2, 'type' => 'text', 'width' => 'auto','nolist'=>true, "help"=>"Will be listed in the Menu-Manager under this name or may be called using {MENU|name} in your theme."),
|
||||
'menu_title' => array('title'=> "Menu Title", 'nolist'=>true, 'tab' => 2, 'type' => 'text', 'inline'=>true, 'width'=>'25%', "help"=>"Caption displayed on the menu item."),
|
||||
'menu_text' => array('title'=> "Menu Body", 'nolist'=>true, 'tab' => 2, 'type' => 'bbarea', 'data'=>'str', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1', 'writeParms'=>'media=page' ),
|
||||
'menu_image' => array('title' =>"Menu Image", 'nolist'=>true, 'tab' => 2, 'type' => 'image', 'width' => '110px', 'thclass' => 'center', 'class' => "center", 'nosort' => false, 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60','readonly'=>false),
|
||||
'menu_template' => array('title'=> "Menu Template", 'nolist'=>true, 'tab' => 2, 'type' => 'dropdown', 'width' => 'auto','filter' => true, 'batch'=>true, 'inline'=>true, 'writeParms'=>''),
|
||||
|
||||
'menu_image' => array('title' =>"Menu Image", 'nolist'=>true, 'tab' => 2, 'type' => 'image', 'width' => '110px', 'thclass' => 'center', 'class' => "center", 'nosort' => false, 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60','readonly'=>false),
|
||||
|
||||
|
||||
|
||||
// 'page_ip_restrict' => array('title'=> LXXAN_USER_07, 'type' => 'text', 'width' => 'auto'), // Avatar
|
||||
@@ -390,13 +391,13 @@ class page_admin_ui extends e_admin_ui
|
||||
'menu_image' => array('title' =>"Menu Image", 'type' => 'image', 'width' => '110px', 'thclass' => 'left', 'class' => "left", 'nosort' => false, 'readParms'=>'thumb=80&thumb_urlraw=0&thumb_aw=80','readonly'=>false),
|
||||
|
||||
'page_theme' => array('title'=> "Menu Name", 'type' => 'text', 'width' => 'auto','nolist'=>true, "help"=>"Will be listed in the Menu-Manager under this name"),
|
||||
'menu_template' => array('title'=> "Menu Template", '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_datestamp' => array('title'=> LAN_DATE, 'type' => 'datestamp', 'data'=>'int', 'width' => 'auto','writeParms'=>'auto=1&readonly=1'),
|
||||
|
||||
'menu_title' => array('title'=> "Menu Title", 'forced'=> TRUE, 'type' => 'text', 'inline'=>true, 'width'=>'25%'),
|
||||
'menu_text' => array('title'=> "Menu Body", 'type' => 'bbarea', 'data'=>'str', 'width' => 'auto', 'readParms' => 'expand=...&truncate=50&bb=1', 'writeParms'=>'media=page'),
|
||||
'menu_template' => array('title'=> "Menu Template", 'type' => 'dropdown', 'width' => 'auto', 'filter' => true, 'batch'=>true, 'inline'=>true, 'writeParms'=>''),
|
||||
|
||||
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'noselector' => true, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center','readParms'=>'deleteClass=252')
|
||||
);
|
||||
|
@@ -168,7 +168,7 @@ class cpage_shortcodes extends e_shortcode
|
||||
return '<a class="cpage" href="'.$url.'">'.$this->sc_cpagetitle().'</a>';
|
||||
}
|
||||
|
||||
function sc_cpagebutton($parm)
|
||||
function sc_cpagebutton($parm,$options)
|
||||
{
|
||||
$url = $this->sc_cpageurl();
|
||||
|
||||
@@ -176,13 +176,23 @@ class cpage_shortcodes extends e_shortcode
|
||||
{
|
||||
return $url;
|
||||
}
|
||||
return '<a class="cpage btn btn-small" href="'.$url.'">Read More..</a>';
|
||||
|
||||
parse_str($options,$options);
|
||||
|
||||
$text = vartrue($options['text'], "Read more..");
|
||||
$size = vartrue($options['size'], "");
|
||||
$inc = ($size) ? " btn-".$size : "";
|
||||
|
||||
return '<a class="cpage btn'.$inc.'" href="'.$url.'">'.$text.'</a>';
|
||||
}
|
||||
|
||||
|
||||
function sc_cmenutitle($parm='')
|
||||
{
|
||||
return e107::getParser()->toHTML($this->getParserVars()->menu_title, true, 'TITLE');
|
||||
$tp = e107::getParser();
|
||||
$title = $tp->glyph($this->page['menu_title']); // (preg_replace('/i_([\w]*)/',"<i class='i_$1'></i>",$this->page['menu_title']);
|
||||
|
||||
return $tp->toHTML($title, true, 'TITLE');
|
||||
}
|
||||
|
||||
|
||||
@@ -197,6 +207,11 @@ class cpage_shortcodes extends e_shortcode
|
||||
{
|
||||
// print_a($this);
|
||||
$img = e107::getParser()->thumbUrl($this->page['menu_image']);
|
||||
if($parm == 'url')
|
||||
{
|
||||
return $img;
|
||||
}
|
||||
|
||||
return "<img src='".$img."' alt='' />";
|
||||
}
|
||||
|
||||
|
@@ -1,9 +1,33 @@
|
||||
<?php
|
||||
/* $Id$ */
|
||||
|
||||
function menu_shortcode($parm)
|
||||
if(!defined('e107_INIT'))
|
||||
{
|
||||
return e107::getMenu()->renderArea($parm);
|
||||
exit();
|
||||
}
|
||||
|
||||
function menu_shortcode($parm, $mode='')
|
||||
{
|
||||
list($path,$echo) = explode(':', $parm);
|
||||
|
||||
if($mode) // New in v2.x. eg. {MENU|feature-1} Renders a menu called 'feature-1' as found in the e107_page table See admin Pages/Menus .
|
||||
{
|
||||
return e107::getMenu()->renderMenu($mode, false);
|
||||
}
|
||||
|
||||
if(is_numeric($path)) // eg. {MENU=1} - renders area 1 as found in the e107_menu db table.
|
||||
{
|
||||
return e107::getMenu()->renderArea($parm);
|
||||
}
|
||||
else // eg. {MENU=contact} for e107_plugins/contact/contact_menu.php OR {MENU=contact/other} for e107_plugins/contact/other_menu.php
|
||||
{
|
||||
list($plugin,$menu) = explode("/",$path,2);
|
||||
|
||||
if($menu == '')
|
||||
{
|
||||
$menu = $plugin;
|
||||
}
|
||||
|
||||
return e107::getMenu()->renderMenu($plugin,$menu."_menu");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -222,6 +222,7 @@ class e_menu
|
||||
{
|
||||
ob_start();
|
||||
}
|
||||
|
||||
e107::getRender()->eMenuArea = $tmp[0];
|
||||
foreach($this->eMenuActive[$tmp[0]] as $row)
|
||||
{
|
||||
@@ -246,12 +247,19 @@ class e_menu
|
||||
* @param boolean $return
|
||||
* return string if required
|
||||
*/
|
||||
public function renderMenu($mpath, $mname, $parm = '', $return = false)
|
||||
public function renderMenu($mpath, $mname='', $parm = '', $return = false)
|
||||
{
|
||||
global $sql; // required at the moment.
|
||||
global $ns, $tp, $sc_style, $e107_debug;
|
||||
// global $sql; // required at the moment.
|
||||
global $sc_style, $e107_debug;
|
||||
|
||||
|
||||
$e107 = e107::getInstance();
|
||||
|
||||
$sql = e107::getDb();
|
||||
$ns = e107::getRender();
|
||||
$tp = e107::getParser();
|
||||
|
||||
|
||||
if($return)
|
||||
{
|
||||
ob_start();
|
||||
@@ -263,12 +271,14 @@ class e_menu
|
||||
}
|
||||
e107::getDB()->db_Mark_Time($mname);
|
||||
|
||||
if(is_numeric($mpath)) // Custom Page/Menu
|
||||
if(is_numeric($mpath) || ($mname === false)) // Custom Page/Menu
|
||||
{
|
||||
$sql->select("page", "*", "page_id=".intval($mpath)." ");
|
||||
$query = ($mname === false) ? "page_theme = '".$mpath."' " : "page_id=".intval($mpath)." "; // load by ID or load by menu-name (page_theme)
|
||||
|
||||
$sql->select("page", "*", $query);
|
||||
$page = $sql->fetch();
|
||||
|
||||
$caption = $e107->tp->toHTML($page['page_title'], true, 'parse_sc, constants');
|
||||
$caption = $tp->toHTML($page['page_title'], true, 'parse_sc, constants');
|
||||
|
||||
if(vartrue($page['menu_template'])) // New v2.x templates. see core/menu_template.php
|
||||
{
|
||||
@@ -280,14 +290,18 @@ class e_menu
|
||||
$text = $tp->parseTemplate($template['body'], true, $page_shortcodes);
|
||||
// echo "TEMPLATE= ($mpath)".$page['menu_template'];
|
||||
|
||||
// e107::getRender()->tablerender($caption, $text);
|
||||
echo $text;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$text = $e107->tp->toHTML($page['page_text'], true, 'parse_sc, constants');
|
||||
e107::getRender()->tablerender($caption, $text);
|
||||
}
|
||||
|
||||
e107::getRender()->tablerender($caption, $text);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
@@ -302,13 +316,9 @@ class e_menu
|
||||
//{
|
||||
// $mpath .= '/';
|
||||
//}
|
||||
|
||||
$mpath = trim($mpath, '/').'/'; // faster...
|
||||
$e107_debug ? include(e_PLUGIN.$mpath.$mname.'.php') : @include(e_PLUGIN.$mpath.$mname.'.php');
|
||||
|
||||
/*if(file_exists(e_PLUGIN.$mpath."/".$mname.".php"))
|
||||
{
|
||||
include_once (e_PLUGIN.$mpath."/".$mname.".php");
|
||||
}*/
|
||||
}
|
||||
e107::getDB()->db_Mark_Time("(After ".$mname.")");
|
||||
if($error_handler->debug==true)
|
||||
|
Reference in New Issue
Block a user