diff --git a/e107_core/shortcodes/single/navigation.php b/e107_core/shortcodes/single/navigation.php new file mode 100644 index 000000000..1160897b0 --- /dev/null +++ b/e107_core/shortcodes/single/navigation.php @@ -0,0 +1,7 @@ +frontend(); +} + \ No newline at end of file diff --git a/e107_core/templates/navigation_template.php b/e107_core/templates/navigation_template.php new file mode 100644 index 000000000..f1b3a9a62 --- /dev/null +++ b/e107_core/templates/navigation_template.php @@ -0,0 +1,77 @@ +'; + +// Main Link +$NAVIGATION_TEMPLATE['ITEM'] = ' + +'; + +// Main Link which has a sub menu. +$NAVIGATION_TEMPLATE['ITEM_SUBMENU'] = ' + +'; + +$NAVIGATION_TEMPLATE['ITEM_SUBMENU_ACTIVE'] = ' + +'; + +$NAVIGATION_TEMPLATE['ITEM_ACTIVE'] = ' + +'; + +$NAVIGATION_TEMPLATE['END'] = ''; + + +$NAVIGATION_TEMPLATE['SUBMENU_START'] = ' + '; + + + +?> \ No newline at end of file diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 1e288f9ed..f322956ec 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -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; } /** diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index ec6ae9c69..72158c7ec 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -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); diff --git a/e107_handlers/sitelinks_class.php b/e107_handlers/sitelinks_class.php index 2df0bf19f..dd0a86149 100644 --- a/e107_handlers/sitelinks_class.php +++ b/e107_handlers/sitelinks_class.php @@ -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; + } +} + + + + + + + + + + + ?> \ No newline at end of file diff --git a/e107_themes/bootstrap/theme.php b/e107_themes/bootstrap/theme.php index ab0225570..b734873e3 100644 --- a/e107_themes/bootstrap/theme.php +++ b/e107_themes/bootstrap/theme.php @@ -92,20 +92,24 @@ function tablestyle($caption, $text, $mod) } $HEADER['default'] = ' -
-
- -
-
+