mirror of
https://github.com/e107inc/e107.git
synced 2025-07-30 03:10:50 +02:00
Start of front-end navigation template. Shortcode handler fix to prevent reloading of existing classes. Bootstrap front-end theme updated.
This commit is contained in:
7
e107_core/shortcodes/single/navigation.php
Normal file
7
e107_core/shortcodes/single/navigation.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
function navigation_shortcode($parm='')
|
||||
{
|
||||
return e107::getNav()->frontend();
|
||||
}
|
||||
|
77
e107_core/templates/navigation_template.php
Normal file
77
e107_core/templates/navigation_template.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2012 e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id: e_shortcode.php 12438 2011-12-05 15:12:56Z secretr $
|
||||
*
|
||||
* Gallery Template
|
||||
*/
|
||||
|
||||
|
||||
|
||||
$NAVIGATION_TEMPLATE['START'] = '<ul class="nav nav-pills">';
|
||||
|
||||
// Main Link
|
||||
$NAVIGATION_TEMPLATE['ITEM'] = '
|
||||
<li class="dropdown">
|
||||
<a class="dropdown-toggle" role="button" href="{LINK_URL}" >
|
||||
{LINK_NAME}
|
||||
</a>
|
||||
</li>
|
||||
';
|
||||
|
||||
// Main Link which has a sub menu.
|
||||
$NAVIGATION_TEMPLATE['ITEM_SUBMENU'] = '
|
||||
<li class="dropdown">
|
||||
<a class="dropdown-toggle" role="button" data-toggle="dropdown" data-target="#" href="{LINK_URL}" >
|
||||
{LINK_NAME}
|
||||
<b class="caret"></b>
|
||||
</a>
|
||||
{LINK_SUB}
|
||||
</li>
|
||||
';
|
||||
|
||||
$NAVIGATION_TEMPLATE['ITEM_SUBMENU_ACTIVE'] = '
|
||||
<li class="dropdown">
|
||||
<a class="dropdown-toggle" role="button" data-toggle="dropdown" data-target="#" href="{LINK_URL}">
|
||||
{LINK_IMAGE} {LINK_NAME}
|
||||
<b class="caret"></b>
|
||||
</a>
|
||||
{LINK_SUB}
|
||||
</li>
|
||||
';
|
||||
|
||||
$NAVIGATION_TEMPLATE['ITEM_ACTIVE'] = '
|
||||
<li class="dropdown">
|
||||
<a class="dropdown-toggle" role="button" data-toggle="dropdown" data-target="#" href="{LINK_URL}">
|
||||
{LINK_IMAGE} {LINK_NAME}
|
||||
</a>
|
||||
</li>
|
||||
';
|
||||
|
||||
$NAVIGATION_TEMPLATE['END'] = '</ul>';
|
||||
|
||||
|
||||
$NAVIGATION_TEMPLATE['SUBMENU_START'] = '
|
||||
<ul class="dropdown-menu" role="menu" >
|
||||
';
|
||||
|
||||
|
||||
$NAVIGATION_TEMPLATE['SUBMENU_ITEM'] = '
|
||||
<li role="menuitem" >
|
||||
<a href="{LINK_URL}">{LINK_IMAGE}{LINK_NAME}</a>
|
||||
</li>
|
||||
';
|
||||
|
||||
|
||||
|
||||
$NAVIGATION_TEMPLATE['SUBMENU_ITEM_ACTIVE'] = '
|
||||
<li role="menuitem" class="active">
|
||||
<a href="{LINK_URL}">{LINK_IMAGE}{LINK_NAME}</a>
|
||||
</li>
|
||||
';
|
||||
|
||||
$NAVIGATION_TEMPLATE['SUBMENU_END'] = '</ul>';
|
||||
|
||||
|
||||
|
||||
?>
|
@@ -1744,10 +1744,20 @@ class e107
|
||||
public static function coreTemplatePath($id, $override = true)
|
||||
{
|
||||
$id = str_replace('..', '', $id); //simple security, '/' is allowed
|
||||
$override_path = $override ? self::getThemeInfo($override, 'rel').'templates/'.$id.'_template.php' : null;
|
||||
$default_path = e_THEME.'templates/'.$id.'_template.php';
|
||||
$override_path = $override ? self::getThemeInfo($override, 'rel').'templates/'.$id.'_template.php' : null;
|
||||
$legacy_path = e_THEME.'templates/'.$id.'_template.php';
|
||||
$core_path = e_CORE.'templates/'.$id.'_template.php';
|
||||
|
||||
if($override_path && is_readable($override_path))
|
||||
{
|
||||
return $override_path;
|
||||
}
|
||||
elseif(is_readable($legacy_path))
|
||||
{
|
||||
return $legacy_path;
|
||||
}
|
||||
|
||||
return ($override_path && is_readable($override_path) ? $override_path : $default_path);
|
||||
return $core_path;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -299,6 +299,13 @@ class e_parse_shortcode
|
||||
$path = $pathBC;
|
||||
}
|
||||
|
||||
// If it already exists - don't include it again.
|
||||
if (class_exists($className, false)) // don't allow __autoload()
|
||||
{
|
||||
$this->registerClassMethods($className, $path);
|
||||
return $this->scClasses[$className];
|
||||
}
|
||||
|
||||
if (is_readable($path))
|
||||
{
|
||||
require_once($path);
|
||||
|
@@ -1175,23 +1175,143 @@ class e_navigation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function frontend() //TODO equivalent for front-end sitelinks etc.
|
||||
{
|
||||
/**
|
||||
* Return a clean array structure for all links.
|
||||
*/
|
||||
function getData($cat=1)
|
||||
{
|
||||
$sql = e107::getDb('sqlSiteLinks');
|
||||
$ins = ($cat > 0) ? "link_category = ".intval($cat)." AND " : "";
|
||||
$query = "SELECT * FROM #links WHERE ".$ins." link_class IN (".USERCLASS_LIST.") ORDER BY link_order ASC";
|
||||
|
||||
$ret = array();
|
||||
|
||||
if($sql->db_Select_gen($query))
|
||||
{
|
||||
while ($row = $sql->db_Fetch())
|
||||
{
|
||||
|
||||
if (isset($row['link_parent']) && $row['link_parent'] != 0)
|
||||
{
|
||||
$id = $row['link_parent'];
|
||||
$ret[$id]['link_sub'][] = $row;
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = $row['link_id'];
|
||||
$ret[$id] = $row;
|
||||
}
|
||||
|
||||
if(vartrue($row['link_function']))
|
||||
{
|
||||
list($path,$method) = explode("::",$row['link_function']);
|
||||
if(include_once(e_PLUGIN.$path."/e_sitelink.php"))
|
||||
{
|
||||
$class = $path."_sitelinks";
|
||||
$sublinkArray = e107::callMethod($class,$method); //TODO Cache it.
|
||||
if(vartrue($sublinkArray))
|
||||
{
|
||||
$ret[$id]['link_sub'] = $sublinkArray;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Render the Front-end Links.
|
||||
function frontend($cat=1)
|
||||
{
|
||||
$links = $this->getData($cat);
|
||||
$sc = e107::getScBatch('navigation');
|
||||
$template = e107::getCoreTemplate('navigation');
|
||||
$sc->template = $template; // parse the template to the shortcodes. (sub menus)
|
||||
|
||||
$text = $template['START'];
|
||||
|
||||
foreach($links as $lnk)
|
||||
{
|
||||
$sc->setVars($lnk);
|
||||
$item = varset($lnk['link_sub']) ? $template['ITEM_SUBMENU'] : $template['ITEM'];
|
||||
$text .= e107::getParser()->parseTemplate($item,TRUE);
|
||||
}
|
||||
|
||||
$text .= $template['END'];
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO - 'active links', SEF etc.
|
||||
class navigation_shortcodes extends e_shortcode
|
||||
{
|
||||
|
||||
var $template;
|
||||
|
||||
function sc_link_name($parm='')
|
||||
{
|
||||
return e107::getParser()->toHtml($this->var['link_name'],false,'TITLE');
|
||||
}
|
||||
|
||||
function sc_link_url($parm='')
|
||||
{
|
||||
return e107::getParser()->replaceConstants($this->var['link_url']);
|
||||
}
|
||||
|
||||
function sc_link_image($parm='')
|
||||
{
|
||||
return e107::getParser()->replaceConstants($this->var['link_image']);
|
||||
}
|
||||
|
||||
|
||||
function sc_link_description($parm='')
|
||||
{
|
||||
return e107::getParser()->toAttribute($this->var['link_description']);
|
||||
}
|
||||
|
||||
function sc_link_sub($parm='')
|
||||
{
|
||||
if(!varset($this->var['link_sub']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$text = $this->template['SUBMENU_START'];
|
||||
|
||||
foreach($this->var['link_sub'] as $val)
|
||||
{
|
||||
$this->setVars($val);
|
||||
$text .= e107::getParser()->parseTemplate($this->template['SUBMENU_ITEM'],TRUE);
|
||||
}
|
||||
|
||||
$text .= $this->template['SUBMENU_END'];
|
||||
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
@@ -92,20 +92,24 @@ function tablestyle($caption, $text, $mod)
|
||||
}
|
||||
|
||||
$HEADER['default'] = '
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="navbar navbar-inverse navbar-fixed-top site-header">
|
||||
<div class="navbar-inner">
|
||||
<div class="span9">
|
||||
<div class="site-logo pull-left thumbnails"><a class="logolink" href="'.SITEURL.' title="">{LOGO}</a></div><div class="dropdown nav navbar-text pull-left">{SITELINKS}</div>
|
||||
</div>
|
||||
<div class="span3">
|
||||
<div class="pull-right">'.$c_login.'</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</a>
|
||||
<a class="brand" href="'.SITEURL.'">{SITENAME}</a>
|
||||
<div class="nav-collapse collapse">
|
||||
<p class="navbar-text pull-right">
|
||||
Logged in as <a href="#" class="navbar-link">'.USERNAME.'</a>
|
||||
</p>
|
||||
{NAVIGATION}
|
||||
</div><!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span2">
|
||||
|
Reference in New Issue
Block a user