mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Legacy sitelinks fix for PHP 7.1
This commit is contained in:
@@ -11,11 +11,22 @@
|
|||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_sitelinks.php');
|
e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_sitelinks.php');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legacy Navigation class.
|
||||||
|
* Class sitelinks
|
||||||
|
*/
|
||||||
class sitelinks
|
class sitelinks
|
||||||
{
|
{
|
||||||
var $eLinkList = array();
|
var $eLinkList = array();
|
||||||
var $sefList = 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)
|
function getlinks($cat=1)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -73,19 +84,24 @@ class sitelinks
|
|||||||
return $this->eLinkList;
|
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;
|
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);
|
$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;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LINKDISPLAY == 4)
|
if(LINKDISPLAY == self::LINK_DISPLAY_SLIDER)
|
||||||
{
|
{
|
||||||
require_once(e_PLUGIN . 'ypslide_menu/ypslide_menu.php');
|
require_once(e_PLUGIN . 'ypslide_menu/ypslide_menu.php');
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getlinks($cat);
|
$this->getlinks($cat);
|
||||||
@@ -102,10 +118,14 @@ class sitelinks
|
|||||||
// -----------------------------
|
// -----------------------------
|
||||||
|
|
||||||
// where did link alignment go?
|
// where did link alignment go?
|
||||||
if (!defined('LINKALIGN')) { define('LINKALIGN', ''); }
|
if(!defined('LINKALIGN'))
|
||||||
|
|
||||||
if(!$style)
|
|
||||||
{
|
{
|
||||||
|
define('LINKALIGN', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(empty($style))
|
||||||
|
{
|
||||||
|
$style = array();
|
||||||
$style['prelink'] = defined('PRELINK') ? PRELINK : '';
|
$style['prelink'] = defined('PRELINK') ? PRELINK : '';
|
||||||
$style['postlink'] = defined('POSTLINK') ? POSTLINK : '';
|
$style['postlink'] = defined('POSTLINK') ? POSTLINK : '';
|
||||||
$style['linkclass'] = defined('LINKCLASS') ? LINKCLASS : "";
|
$style['linkclass'] = defined('LINKCLASS') ? LINKCLASS : "";
|
||||||
@@ -133,6 +153,7 @@ class sitelinks
|
|||||||
$style['subindent'] = " ";
|
$style['subindent'] = " ";
|
||||||
$aSubStyle = $style;
|
$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
|
// php warnings
|
||||||
@@ -140,14 +161,16 @@ class sitelinks
|
|||||||
{
|
{
|
||||||
$this->eLinkList['head_menu'] = array();
|
$this->eLinkList['head_menu'] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$render_link = 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'];
|
$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;
|
$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);
|
$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 */
|
if(!defined("LINKSRENDERONLYMAIN") && !isset($style['linkmainonly'])) /* if this is defined in theme.php only main links will be rendered */
|
||||||
@@ -156,18 +179,22 @@ class sitelinks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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'];
|
$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)
|
foreach($this->eLinkList['head_menu'] as $link)
|
||||||
{
|
{
|
||||||
@@ -177,7 +204,9 @@ class sitelinks
|
|||||||
}
|
}
|
||||||
$text .= $style['postlink'];
|
$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)
|
foreach(array_keys($this->eLinkList) as $k)
|
||||||
{
|
{
|
||||||
$mnu = $style['prelink'];
|
$mnu = $style['prelink'];
|
||||||
@@ -185,37 +214,44 @@ class sitelinks
|
|||||||
{
|
{
|
||||||
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'];
|
$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";
|
$text .= "\n\n\n<!-- end Site Links -->\n\n\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if($usecache)
|
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;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage Sublink Rendering
|
* Manage Sublink Rendering
|
||||||
* @param object $main_linkid
|
* @param string $main_linkid
|
||||||
* @param object $aSubStyle
|
* @param string $aSubStyle
|
||||||
* @param object $css_class
|
* @param string $css_class
|
||||||
* @param object $level [optional]
|
* @param object $level [optional]
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
function subLink($main_linkid,$aSubStyle,$css_class='',$level=0)
|
function subLink($main_linkid,$aSubStyle,$css_class='',$level=0)
|
||||||
{
|
{
|
||||||
global $pref;
|
global $pref;
|
||||||
|
|
||||||
if(!isset($this->eLinkList[$main_linkid]) || !is_array($this->eLinkList[$main_linkid]))
|
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.
|
foreach($this->eLinkList[$main_linkid] as $val) // check that something in the submenu is actually selected.
|
||||||
{
|
{
|
||||||
@@ -232,15 +268,17 @@ class sitelinks
|
|||||||
|
|
||||||
$text = "";
|
$text = "";
|
||||||
$text .= "\n\n<div id='{$main_linkid}' style='display:$substyle' class='d_sublink'>\n";
|
$text .= "\n\n<div id='{$main_linkid}' style='display:$substyle' class='d_sublink'>\n";
|
||||||
|
|
||||||
foreach ($this->eLinkList[$main_linkid] as $sub)
|
foreach ($this->eLinkList[$main_linkid] as $sub)
|
||||||
{
|
{
|
||||||
$id = "sub_".$sub['link_id'];
|
$id = (!empty($sub['link_id'])) ? "sub_".$sub['link_id'] : 'sub_0';
|
||||||
$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;
|
$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 = "sublink-level-".($level+1);
|
||||||
$class .= ($css_class) ? " ".$css_class : "";
|
$class .= ($css_class) ? " ".$css_class : "";
|
||||||
$text .= $this->makeLink($sub, TRUE, $aSubStyle,$class );
|
$text .= $this->makeLink($sub, TRUE, $aSubStyle,$class );
|
||||||
$text .= $this->subLink($id,$aSubStyle,$css_class,($level+1));
|
$text .= $this->subLink($id,$aSubStyle,$css_class,($level+1));
|
||||||
}
|
}
|
||||||
|
|
||||||
$text .= "\n</div>\n\n";
|
$text .= "\n</div>\n\n";
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
@@ -271,7 +309,7 @@ class sitelinks
|
|||||||
$tmp = explode('.', $linkInfo['link_name'], 3);
|
$tmp = explode('.', $linkInfo['link_name'], 3);
|
||||||
$linkInfo['link_name'] = $tmp[2];
|
$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)
|
// 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);
|
$replace[1] = $tp -> toHTML($linkInfo['link_description'], true);
|
||||||
|
|
||||||
$text = preg_replace($search, $replace, $SITELINKSTYLE);
|
$text = preg_replace($search, $replace, $SITELINKSTYLE);
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -512,9 +551,9 @@ e107::getDebug()->log($linkInfo['link_url']);
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif (!e_QUERY && e_PAGE == "news.php")
|
elseif (!e_QUERY && defset('e_PAGE') === "news.php")
|
||||||
{
|
{
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user