mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 20:58:30 +01:00
Legacy sitelinks fix for PHP 7.1
This commit is contained in:
parent
d9a6d1de07
commit
c82d00e06c
@ -11,11 +11,22 @@
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_sitelinks.php');
|
||||
|
||||
|
||||
/**
|
||||
* Legacy Navigation class.
|
||||
* Class sitelinks
|
||||
*/
|
||||
class sitelinks
|
||||
{
|
||||
var $eLinkList = array();
|
||||
var $sefList = array();
|
||||
|
||||
const LINK_DISPLAY_FLAT = 1;
|
||||
const LINK_DISPLAY_MENU = 2;
|
||||
const LINK_DISPLAY_OTHER = 3;
|
||||
const LINK_DISPLAY_SLIDER = 4;
|
||||
|
||||
|
||||
function getlinks($cat=1)
|
||||
{
|
||||
|
||||
@ -73,19 +84,24 @@ class sitelinks
|
||||
return $this->eLinkList;
|
||||
}
|
||||
|
||||
function get($cat=1, $style='', $css_class = false)
|
||||
function get($cat = 1, $style = null, $css_class = false)
|
||||
{
|
||||
global $pref, $ns, $e107cache, $linkstyle;
|
||||
$ns = e107::getRender();
|
||||
$pref = e107::getPref();
|
||||
$e107cache = e107::getCache();
|
||||
|
||||
$usecache = ((trim(defset('LINKSTART_HILITE')) != "" || trim(defset('LINKCLASS_HILITE')) != "") ? false : true);
|
||||
if ($usecache && !strpos(e_SELF, e_ADMIN) && ($data = $e107cache->retrieve('sitelinks_'.$cat.md5($linkstyle.e_PAGE.e_QUERY))))
|
||||
|
||||
if($usecache && !strpos(e_SELF, e_ADMIN) && ($data = $e107cache->retrieve('sitelinks_' . $cat . md5($linkstyle . e_PAGE . e_QUERY))))
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
|
||||
if (LINKDISPLAY == 4)
|
||||
if(LINKDISPLAY == self::LINK_DISPLAY_SLIDER)
|
||||
{
|
||||
require_once(e_PLUGIN.'ypslide_menu/ypslide_menu.php');
|
||||
return;
|
||||
require_once(e_PLUGIN . 'ypslide_menu/ypslide_menu.php');
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->getlinks($cat);
|
||||
@ -102,10 +118,14 @@ class sitelinks
|
||||
// -----------------------------
|
||||
|
||||
// where did link alignment go?
|
||||
if (!defined('LINKALIGN')) { define('LINKALIGN', ''); }
|
||||
|
||||
if(!$style)
|
||||
if(!defined('LINKALIGN'))
|
||||
{
|
||||
define('LINKALIGN', '');
|
||||
}
|
||||
|
||||
if(empty($style))
|
||||
{
|
||||
$style = array();
|
||||
$style['prelink'] = defined('PRELINK') ? PRELINK : '';
|
||||
$style['postlink'] = defined('POSTLINK') ? POSTLINK : '';
|
||||
$style['linkclass'] = defined('LINKCLASS') ? LINKCLASS : "";
|
||||
@ -123,9 +143,9 @@ class sitelinks
|
||||
// Sublink styles.- replacing the tree-menu.
|
||||
if(isset($style['sublinkdisplay']) || isset($style['subindent']) || isset($style['sublinkclass']) || isset($style['sublinkstart']) || isset($style['sublinkend']) || isset($style['subpostlink']))
|
||||
{
|
||||
foreach($style as $key=>$val)
|
||||
foreach($style as $key => $val)
|
||||
{
|
||||
$aSubStyle[$key] = vartrue($style["sub".$key]) ? $style["sub".$key] : $style[$key];
|
||||
$aSubStyle[$key] = vartrue($style["sub" . $key]) ? $style["sub" . $key] : $style[$key];
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -133,89 +153,105 @@ class sitelinks
|
||||
$style['subindent'] = " ";
|
||||
$aSubStyle = $style;
|
||||
}
|
||||
$text = "\n\n\n<!-- Sitelinks ($cat) -->\n\n\n".$style['prelink'];
|
||||
|
||||
$text = "\n\n\n<!-- Sitelinks ($cat) -->\n\n\n" . $style['prelink'];
|
||||
|
||||
// php warnings
|
||||
if(!vartrue($this->eLinkList['head_menu']))
|
||||
{
|
||||
$this->eLinkList['head_menu'] = array();
|
||||
}
|
||||
|
||||
$render_link = array();
|
||||
|
||||
if ($style['linkdisplay'] != 3)
|
||||
if($style['linkdisplay'] != self::LINK_DISPLAY_OTHER)
|
||||
{
|
||||
foreach ($this->eLinkList['head_menu'] as $key => $link)
|
||||
|
||||
foreach($this->eLinkList['head_menu'] as $key => $link)
|
||||
{
|
||||
$main_linkid = "sub_".$link['link_id'];
|
||||
$link['link_expand'] = ((isset($pref['sitelinks_expandsub']) && $pref['sitelinks_expandsub']) && !vartrue($style['linkmainonly']) && !defined("LINKSRENDERONLYMAIN") && isset($this->eLinkList[$main_linkid]) && is_array($this->eLinkList[$main_linkid])) ? TRUE : FALSE;
|
||||
$render_link[$key] = $this->makeLink($link,'', $style, $css_class);
|
||||
$main_linkid = "sub_" . $link['link_id'];
|
||||
$link['link_expand'] = ((isset($pref['sitelinks_expandsub']) && $pref['sitelinks_expandsub']) && !empty($style['linkmainonly']) && !defined("LINKSRENDERONLYMAIN") && isset($this->eLinkList[$main_linkid]) && is_array($this->eLinkList[$main_linkid])) ? true : false;
|
||||
$render_link[$key] = $this->makeLink($link, '', $style, $css_class);
|
||||
|
||||
if(!defined("LINKSRENDERONLYMAIN") && !isset($style['linkmainonly'])) /* if this is defined in theme.php only main links will be rendered */
|
||||
{
|
||||
$render_link[$key] .= $this->subLink($main_linkid,$aSubStyle,$css_class);
|
||||
$render_link[$key] .= $this->subLink($main_linkid, $aSubStyle, $css_class);
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($style['linkseparator']))
|
||||
if(!isset($style['linkseparator']))
|
||||
{
|
||||
$text .= implode($style['linkseparator'], $render_link);
|
||||
$style['linkseparator'] = '';
|
||||
}
|
||||
|
||||
$text .= implode($style['linkseparator'], $render_link);
|
||||
|
||||
|
||||
$text .= $style['postlink'];
|
||||
if ($style['linkdisplay'] == 2)
|
||||
|
||||
if($style['linkdisplay'] == self::LINK_DISPLAY_MENU)
|
||||
{
|
||||
$text = $ns->tablerender(LAN_SITELINKS_183, $text, 'sitelinks', TRUE);
|
||||
$text = $ns->tablerender(LAN_SITELINKS_183, $text, 'sitelinks', true);
|
||||
}
|
||||
}
|
||||
else
|
||||
else // link_DISPLAY_3
|
||||
{
|
||||
foreach($this->eLinkList['head_menu'] as $link)
|
||||
{
|
||||
if (!count($this->eLinkList['sub_'.$link['link_id']]))
|
||||
if(!count($this->eLinkList['sub_' . $link['link_id']]))
|
||||
{
|
||||
$text .= $this->makeLink($link,'', $style, $css_class);
|
||||
$text .= $this->makeLink($link, '', $style, $css_class);
|
||||
}
|
||||
$text .= $style['postlink'];
|
||||
}
|
||||
$text = $ns->tablerender(LAN_SITELINKS_183, $text, 'sitelinks_main', TRUE);
|
||||
|
||||
$text = $ns->tablerender(LAN_SITELINKS_183, $text, 'sitelinks_main', true);
|
||||
|
||||
foreach(array_keys($this->eLinkList) as $k)
|
||||
{
|
||||
$mnu = $style['prelink'];
|
||||
foreach($this->eLinkList[$k] as $link)
|
||||
{
|
||||
if ($k != 'head_menu')
|
||||
if($k != 'head_menu')
|
||||
{
|
||||
$mnu .= $this->makeLink($link, TRUE, $style, $css_class);
|
||||
$mnu .= $this->makeLink($link, true, $style, $css_class);
|
||||
}
|
||||
}
|
||||
$mnu .= $style['postlink'];
|
||||
$text .= $ns->tablerender($k, $mnu, 'sitelinks_sub', TRUE);
|
||||
$text .= $ns->tablerender($k, $mnu, 'sitelinks_sub', true);
|
||||
}
|
||||
}
|
||||
|
||||
$text .= "\n\n\n<!-- end Site Links -->\n\n\n";
|
||||
|
||||
|
||||
|
||||
if($usecache)
|
||||
{
|
||||
$e107cache->set('sitelinks_'.$cat.md5($linkstyle.e_PAGE.e_QUERY), $text);
|
||||
$e107cache->set('sitelinks_' . $cat . md5($linkstyle . e_PAGE . e_QUERY), $text);
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage Sublink Rendering
|
||||
* @param object $main_linkid
|
||||
* @param object $aSubStyle
|
||||
* @param object $css_class
|
||||
* @param string $main_linkid
|
||||
* @param string $aSubStyle
|
||||
* @param string $css_class
|
||||
* @param object $level [optional]
|
||||
* @return
|
||||
*/
|
||||
function subLink($main_linkid,$aSubStyle,$css_class='',$level=0)
|
||||
{
|
||||
global $pref;
|
||||
|
||||
if(!isset($this->eLinkList[$main_linkid]) || !is_array($this->eLinkList[$main_linkid]))
|
||||
{
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
$sub['link_expand'] = ((isset($pref['sitelinks_expandsub']) && $pref['sitelinks_expandsub']) && !vartrue($style['linkmainonly']) && !defined("LINKSRENDERONLYMAIN") && isset($this->eLinkList[$main_linkid]) && is_array($this->eLinkList[$main_linkid])) ? TRUE : FALSE;
|
||||
|
||||
$sub['link_expand'] = ((isset($pref['sitelinks_expandsub']) && $pref['sitelinks_expandsub']) && empty($style['linkmainonly']) && !defined("LINKSRENDERONLYMAIN") && isset($this->eLinkList[$main_linkid]) && is_array($this->eLinkList[$main_linkid])) ? TRUE : FALSE;
|
||||
|
||||
foreach($this->eLinkList[$main_linkid] as $val) // check that something in the submenu is actually selected.
|
||||
{
|
||||
@ -232,15 +268,17 @@ class sitelinks
|
||||
|
||||
$text = "";
|
||||
$text .= "\n\n<div id='{$main_linkid}' style='display:$substyle' class='d_sublink'>\n";
|
||||
|
||||
foreach ($this->eLinkList[$main_linkid] as $sub)
|
||||
{
|
||||
$id = "sub_".$sub['link_id'];
|
||||
$sub['link_expand'] = ((isset($pref['sitelinks_expandsub']) && $pref['sitelinks_expandsub']) && !vartrue($style['linkmainonly']) && !defined("LINKSRENDERONLYMAIN") && isset($this->eLinkList[$id]) && is_array($this->eLinkList[$id])) ? TRUE : FALSE;
|
||||
$id = (!empty($sub['link_id'])) ? "sub_".$sub['link_id'] : 'sub_0';
|
||||
$sub['link_expand'] = ((isset($pref['sitelinks_expandsub']) && $pref['sitelinks_expandsub']) && empty($style['linkmainonly']) && !defined("LINKSRENDERONLYMAIN") && isset($this->eLinkList[$id]) && is_array($this->eLinkList[$id])) ? TRUE : FALSE;
|
||||
$class = "sublink-level-".($level+1);
|
||||
$class .= ($css_class) ? " ".$css_class : "";
|
||||
$text .= $this->makeLink($sub, TRUE, $aSubStyle,$class );
|
||||
$text .= $this->subLink($id,$aSubStyle,$css_class,($level+1));
|
||||
}
|
||||
|
||||
$text .= "\n</div>\n\n";
|
||||
return $text;
|
||||
}
|
||||
@ -271,7 +309,7 @@ class sitelinks
|
||||
$tmp = explode('.', $linkInfo['link_name'], 3);
|
||||
$linkInfo['link_name'] = $tmp[2];
|
||||
}
|
||||
$indent = ($style['linkdisplay'] != 3) ? ($style['subindent']) : "";
|
||||
$indent = ($style['linkdisplay'] != self::LINK_DISPLAY_OTHER && !empty($style['subindent'])) ? ($style['subindent']) : "";
|
||||
}
|
||||
|
||||
// Convert any {e_XXX} to absolute URLs (relative ones sometimes get broken by adding e_HTTP at the front)
|
||||
@ -394,6 +432,7 @@ e107::getDebug()->log($linkInfo['link_url']);
|
||||
$replace[1] = $tp -> toHTML($linkInfo['link_description'], true);
|
||||
|
||||
$text = preg_replace($search, $replace, $SITELINKSTYLE);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
@ -512,9 +551,9 @@ e107::getDebug()->log($linkInfo['link_url']);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
elseif (!e_QUERY && e_PAGE == "news.php")
|
||||
elseif (!e_QUERY && defset('e_PAGE') === "news.php")
|
||||
{
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user