2006-12-02 04:36:16 +00:00
< ? php
/*
2009-11-17 10:46:35 +00:00
* e107 website system
*
2017-01-14 16:08:13 +00:00
* Copyright ( C ) 2008 - 2017 e107 Inc ( e107 . org )
2009-11-17 10:46:35 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
*/
2006-12-02 04:36:16 +00:00
if ( ! defined ( 'e107_INIT' )) { exit ; }
2017-01-23 09:41:23 -08:00
e107 :: includeLan ( e_LANGUAGEDIR . e_LANGUAGE . '/lan_sitelinks.php' );
2006-12-02 04:36:16 +00:00
2017-01-28 10:36:26 -08:00
/**
* Legacy Navigation class .
* Class sitelinks
*/
2006-12-02 04:36:16 +00:00
class sitelinks
{
2009-11-23 10:27:43 +00:00
var $eLinkList = array ();
2017-10-05 13:14:50 -07:00
var $eSubLinkLevel = 0 ;
2011-06-17 01:13:05 +00:00
var $sefList = array ();
2006-12-02 04:36:16 +00:00
2017-01-28 10:36:26 -08:00
const LINK_DISPLAY_FLAT = 1 ;
const LINK_DISPLAY_MENU = 2 ;
const LINK_DISPLAY_OTHER = 3 ;
const LINK_DISPLAY_SLIDER = 4 ;
2022-04-04 10:54:24 -07:00
/**
* @ param $cat
* @ return void
*/
2006-12-02 04:36:16 +00:00
function getlinks ( $cat = 1 )
2016-01-31 11:41:29 -08:00
{
2009-11-23 10:27:43 +00:00
$this -> eLinkList = array (); // clear the array in case getlinks is called 2x on the same page.
2009-11-20 05:01:51 +00:00
$sql = e107 :: getDb ( 'sqlSiteLinks' );
2020-12-21 17:46:32 -08:00
$ins = ( $cat > 0 ) ? " link_category = " . ( int ) $cat . " AND " : " " ;
2017-11-01 18:22:12 -07:00
$query = " SELECT * FROM #links WHERE " . $ins . " ((link_class >= 0 AND link_class IN ( " . USERCLASS_LIST . " )) OR (link_class < 0 AND ABS(link_class) NOT IN ( " . USERCLASS_LIST . " )) ) ORDER BY link_order ASC " ;
2015-02-15 16:07:27 -08:00
if ( $sql -> gen ( $query ))
2010-03-16 15:11:07 +00:00
{
2015-02-15 16:07:27 -08:00
while ( $row = $sql -> fetch ())
2006-12-02 04:36:16 +00:00
{
2015-03-31 14:48:07 -07:00
2011-06-17 01:13:05 +00:00
2010-10-30 14:50:30 +00:00
// if (substr($row['link_name'], 0, 8) == 'submenu.'){
// $tmp=explode('.', $row['link_name'], 3);
// $this->eLinkList[$tmp[1]][]=$row;
2009-11-20 05:01:51 +00:00
if ( isset ( $row [ 'link_parent' ]) && $row [ 'link_parent' ] != 0 )
{
2006-12-02 04:36:16 +00:00
$this -> eLinkList [ 'sub_' . $row [ 'link_parent' ]][] = $row ;
2010-03-16 15:11:07 +00:00
2009-11-20 05:01:51 +00:00
}
else
{
2006-12-02 04:36:16 +00:00
$this -> eLinkList [ 'head_menu' ][] = $row ;
2020-12-20 11:50:10 -08:00
if ( ! empty ( $row [ 'link_function' ]))
2010-03-16 15:11:07 +00:00
{
2013-10-28 21:30:24 -07:00
$parm = false ;
2009-11-20 05:01:51 +00:00
list ( $path , $method ) = explode ( " :: " , $row [ 'link_function' ]);
2013-10-28 21:30:24 -07:00
if ( strpos ( $method , " ( " ))
{
list ( $method , $prm ) = explode ( " ( " , $method );
$parm = rtrim ( $prm , " ) " );
}
2012-12-17 13:20:52 -08:00
if ( file_exists ( e_PLUGIN . $path . " /e_sitelink.php " ) && include_once ( e_PLUGIN . $path . " /e_sitelink.php " ))
2009-11-20 05:01:51 +00:00
{
2013-02-26 03:43:52 -08:00
$class = $path . " _sitelink " ;
2013-10-28 21:30:24 -07:00
$sublinkArray = e107 :: callMethod ( $class , $method , $parm ); //TODO Cache it.
2020-12-20 11:50:10 -08:00
if ( ! empty ( $sublinkArray ))
2009-11-20 05:01:51 +00:00
{
$this -> eLinkList [ 'sub_' . $row [ 'link_id' ]] = $sublinkArray ;
}
2010-03-16 15:11:07 +00:00
}
2012-12-17 13:20:52 -08:00
2009-11-20 05:01:51 +00:00
}
2006-12-02 04:36:16 +00:00
}
}
}
2010-03-16 15:11:07 +00:00
2006-12-02 04:36:16 +00:00
}
2010-03-16 15:11:07 +00:00
2022-04-04 10:54:24 -07:00
/**
* @ return array
*/
2009-11-21 11:36:10 +00:00
function getLinkArray ()
{
return $this -> eLinkList ;
}
2010-03-16 15:11:07 +00:00
2022-04-04 10:54:24 -07:00
/**
* @ param $cat
* @ param $style
* @ param $css_class
* @ return string | null
*/
2017-01-28 10:36:26 -08:00
function get ( $cat = 1 , $style = null , $css_class = false )
2006-12-02 04:36:16 +00:00
{
global $pref , $ns , $e107cache , $linkstyle ;
2017-01-28 10:36:26 -08:00
$ns = e107 :: getRender ();
$pref = e107 :: getPref ();
$e107cache = e107 :: getCache ();
2021-01-24 17:00:02 -08:00
$usecache = ( ! ( trim ( defset ( 'LINKSTART_HILITE' )) != " " || trim ( defset ( 'LINKCLASS_HILITE' )) != " " ));
2017-01-28 10:36:26 -08:00
if ( $usecache && ! strpos ( e_SELF , e_ADMIN ) && ( $data = $e107cache -> retrieve ( 'sitelinks_' . $cat . md5 ( $linkstyle . e_PAGE . e_QUERY ))))
2008-05-30 20:57:20 +00:00
{
2017-01-28 10:36:26 -08:00
return $data ;
2006-12-02 04:36:16 +00:00
}
2017-01-28 10:36:26 -08:00
if ( LINKDISPLAY == self :: LINK_DISPLAY_SLIDER )
2010-10-30 14:50:30 +00:00
{
2017-01-28 10:36:26 -08:00
require_once ( e_PLUGIN . 'ypslide_menu/ypslide_menu.php' );
return null ;
2006-12-02 04:36:16 +00:00
}
$this -> getlinks ( $cat );
2017-10-05 13:14:50 -07:00
if ( empty ( $this -> eLinkList )) { return '' ; }
2006-12-02 04:36:16 +00:00
// are these defines used at all ?
2010-10-30 14:50:30 +00:00
if ( ! defined ( 'PRELINKTITLE' ))
{
2006-12-02 04:36:16 +00:00
define ( 'PRELINKTITLE' , '' );
}
2010-10-30 14:50:30 +00:00
if ( ! defined ( 'PRELINKTITLE' ))
{
2006-12-02 04:36:16 +00:00
define ( 'POSTLINKTITLE' , '' );
}
// -----------------------------
// where did link alignment go?
2017-01-28 10:36:26 -08:00
if ( ! defined ( 'LINKALIGN' ))
{
define ( 'LINKALIGN' , '' );
}
2006-12-02 04:36:16 +00:00
2017-01-28 10:36:26 -08:00
if ( empty ( $style ))
2010-10-30 14:50:30 +00:00
{
2017-01-28 10:36:26 -08:00
$style = array ();
2006-12-02 04:36:16 +00:00
$style [ 'prelink' ] = defined ( 'PRELINK' ) ? PRELINK : '' ;
$style [ 'postlink' ] = defined ( 'POSTLINK' ) ? POSTLINK : '' ;
$style [ 'linkclass' ] = defined ( 'LINKCLASS' ) ? LINKCLASS : " " ;
$style [ 'linkclass_hilite' ] = defined ( 'LINKCLASS_HILITE' ) ? LINKCLASS_HILITE : " " ;
$style [ 'linkstart_hilite' ] = defined ( 'LINKSTART_HILITE' ) ? LINKSTART_HILITE : " " ;
$style [ 'linkstart' ] = defined ( 'LINKSTART' ) ? LINKSTART : '' ;
$style [ 'linkdisplay' ] = defined ( 'LINKDISPLAY' ) ? LINKDISPLAY : '' ;
$style [ 'linkend' ] = defined ( 'LINKEND' ) ? LINKEND : '' ;
$style [ 'linkseparator' ] = defined ( 'LINKSEPARATOR' ) ? LINKSEPARATOR : '' ;
2007-06-11 09:26:06 +00:00
$style [ 'sublinkstart' ] = defined ( 'SUBLINKSTART' ) ? SUBLINKSTART : '' ;
$style [ 'sublinkend' ] = defined ( 'SUBLINKEND' ) ? SUBLINKEND : '' ;
$style [ 'sublinkclass' ] = defined ( 'SUBLINKCLASS' ) ? SUBLINKCLASS : '' ;
2006-12-02 04:36:16 +00:00
}
2017-10-05 13:14:50 -07:00
if ( ! varset ( $style [ 'linkseparator' ]))
{
$style [ 'linkseparator' ] = '' ;
}
2010-10-30 14:50:30 +00:00
// Sublink styles.- replacing the tree-menu.
2017-01-28 10:36:26 -08:00
if ( isset ( $style [ 'sublinkdisplay' ]) || isset ( $style [ 'subindent' ]) || isset ( $style [ 'sublinkclass' ]) || isset ( $style [ 'sublinkstart' ]) || isset ( $style [ 'sublinkend' ]) || isset ( $style [ 'subpostlink' ]))
2010-10-30 14:50:30 +00:00
{
2017-01-28 10:36:26 -08:00
foreach ( $style as $key => $val )
2010-10-30 14:50:30 +00:00
{
2017-01-28 10:36:26 -08:00
$aSubStyle [ $key ] = vartrue ( $style [ " sub " . $key ]) ? $style [ " sub " . $key ] : $style [ $key ];
2006-12-02 04:36:16 +00:00
}
2017-01-28 10:36:26 -08:00
}
2010-10-30 14:50:30 +00:00
else
{
$style [ 'subindent' ] = " " ;
$aSubStyle = $style ;
2006-12-02 04:36:16 +00:00
}
2017-01-28 10:36:26 -08:00
$text = " \n \n \n <!-- Sitelinks ( $cat ) --> \n \n \n " . $style [ 'prelink' ];
2006-12-02 04:36:16 +00:00
2010-03-16 15:11:07 +00:00
// php warnings
if ( ! vartrue ( $this -> eLinkList [ 'head_menu' ]))
{
$this -> eLinkList [ 'head_menu' ] = array ();
}
2017-01-28 10:36:26 -08:00
2010-03-16 15:15:32 +00:00
$render_link = array ();
2010-03-16 15:11:07 +00:00
2017-01-28 10:36:26 -08:00
if ( $style [ 'linkdisplay' ] != self :: LINK_DISPLAY_OTHER )
2010-10-30 14:50:30 +00:00
{
2017-01-28 10:36:26 -08:00
foreach ( $this -> eLinkList [ 'head_menu' ] as $key => $link )
2010-10-30 14:50:30 +00:00
{
2017-01-28 10:36:26 -08:00
$main_linkid = " sub_ " . $link [ 'link_id' ];
2021-01-24 17:00:02 -08:00
$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 ]));
2017-01-28 10:36:26 -08:00
$render_link [ $key ] = $this -> makeLink ( $link , '' , $style , $css_class );
2006-12-02 04:36:16 +00:00
2017-01-24 08:46:31 -08:00
if ( ! defined ( " LINKSRENDERONLYMAIN " ) && ! isset ( $style [ 'linkmainonly' ])) /* if this is defined in theme.php only main links will be rendered */
2017-01-28 10:36:26 -08:00
{
$render_link [ $key ] .= $this -> subLink ( $main_linkid , $aSubStyle , $css_class );
}
2006-12-02 04:36:16 +00:00
}
2017-01-24 15:19:40 -08:00
2017-01-28 10:36:26 -08:00
if ( ! isset ( $style [ 'linkseparator' ]))
2017-01-24 08:46:31 -08:00
{
2017-01-28 10:36:26 -08:00
$style [ 'linkseparator' ] = '' ;
2017-01-24 08:46:31 -08:00
}
2017-01-28 10:36:26 -08:00
$text .= implode ( $style [ 'linkseparator' ], $render_link );
2006-12-02 04:36:16 +00:00
$text .= $style [ 'postlink' ];
2017-01-28 10:36:26 -08:00
if ( $style [ 'linkdisplay' ] == self :: LINK_DISPLAY_MENU )
2010-10-30 14:50:30 +00:00
{
2017-01-28 10:36:26 -08:00
$text = $ns -> tablerender ( LAN_SITELINKS_183 , $text , 'sitelinks' , true );
2006-12-02 04:36:16 +00:00
}
}
2017-01-28 10:36:26 -08:00
else // link_DISPLAY_3
2006-12-02 04:36:16 +00:00
{
foreach ( $this -> eLinkList [ 'head_menu' ] as $link )
{
2017-01-28 10:36:26 -08:00
if ( ! count ( $this -> eLinkList [ 'sub_' . $link [ 'link_id' ]]))
2006-12-02 04:36:16 +00:00
{
2017-01-28 10:36:26 -08:00
$text .= $this -> makeLink ( $link , '' , $style , $css_class );
2006-12-02 04:36:16 +00:00
}
$text .= $style [ 'postlink' ];
}
2017-01-28 10:36:26 -08:00
$text = $ns -> tablerender ( LAN_SITELINKS_183 , $text , 'sitelinks_main' , true );
2006-12-02 04:36:16 +00:00
foreach ( array_keys ( $this -> eLinkList ) as $k )
{
$mnu = $style [ 'prelink' ];
foreach ( $this -> eLinkList [ $k ] as $link )
{
2020-12-21 17:46:32 -08:00
if ( $k !== 'head_menu' )
2006-12-02 04:36:16 +00:00
{
2017-01-28 10:36:26 -08:00
$mnu .= $this -> makeLink ( $link , true , $style , $css_class );
2006-12-02 04:36:16 +00:00
}
}
$mnu .= $style [ 'postlink' ];
2017-01-28 10:36:26 -08:00
$text .= $ns -> tablerender ( $k , $mnu , 'sitelinks_sub' , true );
2006-12-02 04:36:16 +00:00
}
}
2017-01-28 10:36:26 -08:00
2009-07-02 20:40:43 +00:00
$text .= " \n \n \n <!-- end Site Links --> \n \n \n " ;
2017-01-28 10:36:26 -08:00
2006-12-02 04:36:16 +00:00
if ( $usecache )
{
2017-01-28 10:36:26 -08:00
$e107cache -> set ( 'sitelinks_' . $cat . md5 ( $linkstyle . e_PAGE . e_QUERY ), $text );
2006-12-02 04:36:16 +00:00
}
2017-01-28 10:36:26 -08:00
return $text ;
2006-12-02 04:36:16 +00:00
}
2022-04-04 10:54:24 -07:00
2010-12-13 09:23:04 +00:00
/**
* Manage Sublink Rendering
2017-01-28 10:36:26 -08:00
* @ param string $main_linkid
2019-04-30 14:01:05 -07:00
* @ param array $aSubStyle
2017-01-28 10:36:26 -08:00
* @ param string $css_class
2022-04-04 10:54:24 -07:00
* @ param int $level [ optional ]
* @ return string | null
2010-12-13 09:23:04 +00:00
*/
2019-04-30 14:01:05 -07:00
function subLink ( $main_linkid , $aSubStyle = array (), $css_class = '' , $level = 0 )
2010-12-13 09:23:04 +00:00
{
global $pref ;
2017-01-28 10:36:26 -08:00
2010-12-13 09:23:04 +00:00
if ( ! isset ( $this -> eLinkList [ $main_linkid ]) || ! is_array ( $this -> eLinkList [ $main_linkid ]))
{
2017-01-28 10:36:26 -08:00
return null ;
2010-12-13 09:23:04 +00:00
}
2017-01-28 10:36:26 -08:00
2021-01-24 17:00:02 -08:00
$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 ]));
2010-12-13 09:23:04 +00:00
foreach ( $this -> eLinkList [ $main_linkid ] as $val ) // check that something in the submenu is actually selected.
{
if ( $this -> hilite ( $val [ 'link_url' ], TRUE ) == TRUE || $sub [ 'link_expand' ] == FALSE )
{
$substyle = " block " ; // previously (non-W3C compliant): compact
break ;
}
else
{
$substyle = " none " ;
}
}
$text = " " ;
$text .= " \n \n <div id=' { $main_linkid } ' style='display: $substyle ' class='d_sublink'> \n " ;
2017-01-28 10:36:26 -08:00
2010-12-13 09:23:04 +00:00
foreach ( $this -> eLinkList [ $main_linkid ] as $sub )
{
2017-01-28 10:36:26 -08:00
$id = ( ! empty ( $sub [ 'link_id' ])) ? " sub_ " . $sub [ 'link_id' ] : 'sub_0' ;
2021-01-24 17:00:02 -08:00
$sub [ 'link_expand' ] = (( isset ( $pref [ 'sitelinks_expandsub' ]) && $pref [ 'sitelinks_expandsub' ]) && empty ( $style [ 'linkmainonly' ]) && ! defined ( " LINKSRENDERONLYMAIN " ) && isset ( $this -> eLinkList [ $id ]) && is_array ( $this -> eLinkList [ $id ]));
2010-12-13 09:23:04 +00:00
$class = " sublink-level- " . ( $level + 1 );
$class .= ( $css_class ) ? " " . $css_class : " " ;
2017-10-05 13:14:50 -07:00
$class .= ( $aSubStyle [ 'sublinkclass' ]) ? " " . $aSubStyle [ 'sublinkclass' ] : " " ; // backwards compatible
2010-12-13 09:23:04 +00:00
$text .= $this -> makeLink ( $sub , TRUE , $aSubStyle , $class );
$text .= $this -> subLink ( $id , $aSubStyle , $css_class ,( $level + 1 ));
}
2017-01-28 10:36:26 -08:00
2010-12-13 09:23:04 +00:00
$text .= " \n </div> \n \n " ;
return $text ;
}
2006-12-02 04:36:16 +00:00
2022-04-04 10:54:24 -07:00
/**
* @ param $linkInfo
* @ param $submenu
* @ param $style
* @ param $css_class
* @ return string
*/
2019-04-30 14:01:05 -07:00
function makeLink ( $linkInfo = array (), $submenu = FALSE , $style = array (), $css_class = false )
2006-12-02 04:36:16 +00:00
{
global $pref , $tp ;
// Start with an empty link
$linkstart = $indent = $linkadd = $screentip = $href = $link_append = '' ;
2007-07-06 22:02:29 +00:00
$highlighted = FALSE ;
2011-06-17 01:13:05 +00:00
2017-10-05 13:14:50 -07:00
if ( ! isset ( $style [ 'linkstart_hilite' ])) // Notice removal
{
$style [ 'linkstart_hilite' ] = " " ;
}
if ( ! isset ( $style [ 'linkclass_hilite' ]))
{
$style [ 'linkclass_hilite' ] = " " ;
}
2020-12-20 11:50:10 -08:00
if ( ! empty ( $linkInfo [ 'link_sefurl' ]) && ! empty ( $linkInfo [ 'link_owner' ]))
2011-06-17 01:13:05 +00:00
{
2015-04-03 13:07:28 -07:00
$linkInfo [ 'link_url' ] = e107 :: url ( $linkInfo [ 'link_owner' ], $linkInfo [ 'link_sefurl' ]) ; // $linkInfo['link_sefurl'];
2011-06-17 01:13:05 +00:00
}
2010-03-16 15:11:07 +00:00
2016-12-10 17:05:12 -08:00
2006-12-02 04:36:16 +00:00
// If submenu: Fix Name, Add Indentation.
2017-10-05 13:14:50 -07:00
if ( $submenu == true )
2010-10-30 14:50:30 +00:00
{
2020-12-20 11:50:10 -08:00
if ( strpos ( $linkInfo [ 'link_name' ], 'submenu.' ) === 0 )
2010-10-30 14:50:30 +00:00
{
2006-12-02 04:36:16 +00:00
$tmp = explode ( '.' , $linkInfo [ 'link_name' ], 3 );
$linkInfo [ 'link_name' ] = $tmp [ 2 ];
}
2017-01-28 10:36:26 -08:00
$indent = ( $style [ 'linkdisplay' ] != self :: LINK_DISPLAY_OTHER && ! empty ( $style [ 'subindent' ])) ? ( $style [ 'subindent' ]) : " " ;
2006-12-02 04:36:16 +00:00
}
2007-05-16 20:24:44 +00:00
// Convert any {e_XXX} to absolute URLs (relative ones sometimes get broken by adding e_HTTP at the front)
$linkInfo [ 'link_url' ] = $tp -> replaceConstants ( $linkInfo [ 'link_url' ], TRUE , TRUE ); // replace {e_xxxx}
2006-12-02 04:36:16 +00:00
2016-12-10 17:05:12 -08:00
if ( strpos ( $linkInfo [ 'link_url' ], " { " ) !== false )
2010-10-30 14:50:30 +00:00
{
2006-12-02 04:36:16 +00:00
$linkInfo [ 'link_url' ] = $tp -> parseTemplate ( $linkInfo [ 'link_url' ], TRUE ); // shortcode in URL support - dynamic urls for multilanguage.
}
2020-12-21 17:46:32 -08:00
elseif ( $linkInfo [ 'link_url' ][ 0 ] !== '/' && strpos ( $linkInfo [ 'link_url' ], 'http' ) !== 0 )
2016-12-10 17:05:12 -08:00
{
$linkInfo [ 'link_url' ] = e_HTTP . ltrim ( $linkInfo [ 'link_url' ], '/' );
}
2006-12-02 04:36:16 +00:00
// By default links are not highlighted.
2014-01-20 06:20:58 -08:00
if ( isset ( $linkInfo [ 'link_expand' ]) && $linkInfo [ 'link_expand' ])
{
// $href = " href=\"javascript:expandit('sub_".$linkInfo['link_id']."')\"";
$css_class .= " e-expandit " ;
}
2006-12-02 04:36:16 +00:00
$linkstart = $style [ 'linkstart' ];
$linkadd = ( $style [ 'linkclass' ]) ? " class=' " . $style [ 'linkclass' ] . " ' " : " " ;
2017-10-05 13:14:50 -07:00
$linkadd = ( $css_class ) ? " class=' " . $style [ 'linkclass' ] . $css_class . " ' " : $linkadd ;
2006-12-02 04:36:16 +00:00
// Check for screentip regardless of URL.
2010-10-30 14:50:30 +00:00
if ( isset ( $pref [ 'linkpage_screentip' ]) && $pref [ 'linkpage_screentip' ] && $linkInfo [ 'link_description' ])
{
2007-01-07 15:59:42 +00:00
$screentip = " title = \" " . $tp -> toHTML ( $linkInfo [ 'link_description' ], " " , " value, emotes_off, defs, no_hook " ) . " \" " ;
2006-12-02 04:36:16 +00:00
}
// Check if its expandable first. It should override its URL.
2007-08-02 20:42:16 +00:00
if ( isset ( $linkInfo [ 'link_expand' ]) && $linkInfo [ 'link_expand' ])
{
2014-01-20 06:20:58 -08:00
// $href = " href=\"javascript:expandit('sub_".$linkInfo['link_id']."')\"";
$href = " href='#sub_ " . $linkInfo [ 'link_id' ] . " ' " ;
2010-03-16 15:11:07 +00:00
}
2007-08-02 20:42:16 +00:00
elseif ( $linkInfo [ 'link_url' ])
{
2006-12-02 04:36:16 +00:00
// Only add the e_BASE if it actually has an URL.
2021-12-02 11:35:12 -08:00
// $linkInfo['link_url'] = (strpos($linkInfo['link_url'], '://') === FALSE && strpos($linkInfo['link_url'], 'mailto:') !== 0 ? $linkInfo['link_url'] : $linkInfo['link_url']);
2006-12-02 04:36:16 +00:00
// Only check if its highlighted if it has an URL
2010-10-30 14:50:30 +00:00
if ( $this -> hilite ( $linkInfo [ 'link_url' ], $style [ 'linkstart_hilite' ]) == TRUE )
{
2007-08-07 19:31:44 +00:00
$linkstart = ( isset ( $style [ 'linkstart_hilite' ])) ? $style [ 'linkstart_hilite' ] : " " ;
$highlighted = TRUE ;
2006-12-02 04:36:16 +00:00
}
2017-01-24 08:46:31 -08:00
if ( $this -> hilite ( varset ( $linkInfo [ 'link_url' ]), ! empty ( $style [ 'linkclass_hilite' ])))
2010-10-30 14:50:30 +00:00
{
2007-08-07 19:31:44 +00:00
$linkadd = ( isset ( $style [ 'linkclass_hilite' ])) ? " class=' " . $style [ 'linkclass_hilite' ] . " ' " : " " ;
2006-12-02 04:36:16 +00:00
$highlighted = TRUE ;
}
2007-08-02 20:42:16 +00:00
if ( $linkInfo [ 'link_open' ] == 4 || $linkInfo [ 'link_open' ] == 5 )
{
2006-12-02 04:36:16 +00:00
$dimen = ( $linkInfo [ 'link_open' ] == 4 ) ? " 600,400 " : " 800,600 " ;
$href = " href= \" javascript:open_window(' " . $linkInfo [ 'link_url' ] . " ', { $dimen } ) \" " ;
2010-03-16 15:11:07 +00:00
}
else
2007-08-02 20:42:16 +00:00
{
2006-12-02 04:36:16 +00:00
$href = " href=' " . $linkInfo [ 'link_url' ] . " ' " ;
}
// Open link in a new window. (equivalent of target='_blank' )
$link_append = ( $linkInfo [ 'link_open' ] == 1 ) ? " rel='external' " : " " ;
}
2017-10-05 13:14:50 -07:00
2006-12-02 04:36:16 +00:00
// Remove default images if its a button and add new image at the start.
2007-08-02 20:42:16 +00:00
if ( $linkInfo [ 'link_button' ])
{
2006-12-02 04:36:16 +00:00
$linkstart = preg_replace ( '/\<img.*\>/si' , '' , $linkstart );
2019-04-30 14:01:05 -07:00
$linkstart .= $tp -> toIcon ( $linkInfo [ 'link_button' ], array ( 'legacy' => " { e_IMAGE}icons/ " ));
2012-07-21 07:30:28 +00:00
2019-04-30 14:01:05 -07:00
/* if ( $linkInfo [ 'link_button' ][ 0 ] == '{' )
2012-07-21 07:30:28 +00:00
{
$linkstart .= " <img src=' " . $tp -> replaceConstants ( $linkInfo [ 'link_button' ], 'abs' ) . " ' alt='' style='vertical-align:middle' /> " ;
}
else
{
2019-04-30 14:01:05 -07:00
$linkstart .= " <img src=' " . e_IMAGE_ABS . " icons/ " . $linkInfo [ 'link_button' ] . " ' alt='' style='vertical-align:middle' /> " ;
} */
2006-12-02 04:36:16 +00:00
}
// mobile phone support.
$accesskey = ( isset ( $style [ 'accesskey' ]) && $style [ 'accesskey' ] == TRUE ) ? " accesskey=' " . $linkInfo [ 'link_order' ] . " ' " : " " ;
$accessdigit = ( isset ( $style [ 'accessdigit' ], $style [ 'accesskey' ]) && $style [ 'accessdigit' ] == TRUE && $style [ 'accesskey' ] == TRUE ) ? $linkInfo [ 'link_order' ] . " . " : " " ;
// If its a link.. make a link
$_link = " " ;
$_link .= $accessdigit ;
2017-01-24 08:46:31 -08:00
if ( ! empty ( $href ) && (( isset ( $style [ 'hilite_nolink' ]) && $highlighted ) != TRUE ))
2010-10-30 14:50:30 +00:00
{
2007-01-07 15:59:42 +00:00
$_link .= " <a " . $linkadd . $screentip . $href . $link_append . $accesskey . " > " . $tp -> toHTML ( $linkInfo [ 'link_name' ], " " , " emotes_off, defs, no_hook " ) . " </a> " ;
2010-10-30 14:50:30 +00:00
}
elseif ( ! empty ( $linkadd ) || ! empty ( $screentip ))
{ // If its not a link, but has a class or screentip do span:
2007-01-07 15:59:42 +00:00
$_link .= " <span " . $linkadd . $screentip . " > " . $tp -> toHTML ( $linkInfo [ 'link_name' ], " " , " emotes_off, defs, no_hook " ) . " </span> " ;
2010-10-30 14:50:30 +00:00
}
else
{ // Else just the name:
2007-01-07 15:59:42 +00:00
$_link .= $tp -> toHTML ( $linkInfo [ 'link_name' ], " " , " emotes_off, defs, no_hook " );
2006-12-02 04:36:16 +00:00
}
$_link = $linkstart . $indent . $_link ;
2017-10-05 13:14:50 -07:00
return $_link . $style [ 'linkend' ] . " \n " ;
2010-03-16 15:11:07 +00:00
2016-12-10 17:05:12 -08:00
2017-10-05 13:14:50 -07:00
/*
2007-06-25 15:00:58 +00:00
$search [ 0 ] = " / \ { LINK \ }(.*?)/si " ;
$replace [ 0 ] = $_link . $style [ 'linkend' ] . " \n " ;
$search [ 1 ] = " / \ { LINK_DESCRIPTION \ }(.*?)/si " ;
2007-06-25 15:06:38 +00:00
$replace [ 1 ] = $tp -> toHTML ( $linkInfo [ 'link_description' ], true );
2007-06-25 15:00:58 +00:00
$text = preg_replace ( $search , $replace , $SITELINKSTYLE );
2017-01-28 10:36:26 -08:00
2017-10-05 13:14:50 -07:00
return $text ; */
2006-12-02 04:36:16 +00:00
}
2010-10-30 14:50:30 +00:00
/**
* Determine whether link highlighting needs to be active
*
* @ param string $link - the full link as stored in the DB
* @ param boolean $enabled - TRUE if the link is enabled
*
* @ return boolean TRUE if link to be highlighted , FALSE if not
*/
function hilite ( $link , $enabled = FALSE )
2006-12-02 04:36:16 +00:00
{
2019-04-30 14:01:05 -07:00
global $PLUGINS_DIRECTORY ;
2010-10-30 14:50:30 +00:00
if ( ! $enabled ){ return FALSE ; }
2006-12-02 04:36:16 +00:00
2019-04-30 14:01:05 -07:00
$tp = e107 :: getParser ();
2010-10-30 14:50:30 +00:00
$link = $tp -> replaceConstants ( $link , '' , TRUE ); // The link saved in the DB
$tmp = explode ( '?' , $link );
$link_qry = ( isset ( $tmp [ 1 ])) ? $tmp [ 1 ] : '' ;
$link_slf = ( isset ( $tmp [ 0 ])) ? $tmp [ 0 ] : '' ;
$link_pge = basename ( $link_slf );
$link_match = ( empty ( $tmp [ 0 ])) ? " " : strpos ( e_SELF , $tmp [ 0 ]); // e_SELF is the actual displayed page
2006-12-02 04:36:16 +00:00
2020-12-21 17:46:32 -08:00
if ( e_MENU === " debug " && getperms ( '0' ))
2007-08-02 20:42:16 +00:00
{
2010-10-30 14:50:30 +00:00
echo " <br />link= " . $link ;
echo " <br />link_q= " . $link_qry ;
echo " <br />url= " . e_PAGE ;
echo " <br />self= " . e_SELF ;
echo " <br />url_query= " . e_QUERY . " <br /> " ;
2006-12-02 04:36:16 +00:00
}
2010-10-30 14:50:30 +00:00
// ----------- highlight overriding - set the link matching in the page itself.
if ( defined ( 'HILITE' ))
{
if ( strpos ( $link , HILITE ))
{
return TRUE ;
}
}
2006-12-02 04:36:16 +00:00
2010-10-30 14:50:30 +00:00
// --------------- highlighting for 'HOME'. ----------------
// See if we're on whatever is set as 'home' page for this user
2007-08-02 20:42:16 +00:00
2010-10-30 14:50:30 +00:00
// Although should be just 'index.php', allow for the possibility that there might be a query part
2019-04-30 14:01:05 -07:00
// global $pref;
$pref = e107 :: pref ();
2010-10-30 14:50:30 +00:00
if (( $link_slf == e_HTTP . " index.php " ) && count ( $pref [ 'frontpage' ]))
{ // Only interested if the displayed page is index.php - see whether its the user's home (front) page
$full_url = 'news.php' ; // Set a default in case
$uc_array = explode ( ',' , USERCLASS_LIST );
foreach ( $pref [ 'frontpage' ] as $fk => $fp )
{
if ( in_array ( $fk , $uc_array ))
{
$full_url = (( strpos ( $fp , 'http' ) === FALSE ) ? SITEURL : '' ) . $fp ;
break ;
}
}
list ( $fp , $fp_q ) = explode ( " ? " , $full_url . " ? " ); // extra '?' ensure the array is filled
2020-12-21 17:46:32 -08:00
if ( e_MENU === " debug " && getperms ( '0' ))
2010-10-30 14:50:30 +00:00
{
echo " \$ fp = " . $fp . " <br /> " ;
echo " \$ fp_q = " . $fp_q . " <br /> " ;
}
$tmp = str_replace ( " ../ " , " " , e_SELF );
if (( strpos ( $fp , $tmp ) !== FALSE ) && ( $fp_q == $link_qry ))
{
return TRUE ;
}
2007-08-02 20:42:16 +00:00
}
2006-12-02 04:36:16 +00:00
2010-10-30 14:50:30 +00:00
// --------------- highlighting for plugins. ----------------
2020-12-20 11:50:10 -08:00
if ( stripos ( $link , $PLUGINS_DIRECTORY ) !== false && stripos ( $link , " custompages " ) === false )
2007-08-02 20:42:16 +00:00
{
2006-12-02 04:36:16 +00:00
if ( $link_qry )
2010-10-30 14:50:30 +00:00
{ // plugin links with queries
2021-01-24 17:00:02 -08:00
return ( strpos ( e_SELF , $link_slf ) && e_QUERY == $link_qry );
2006-12-02 04:36:16 +00:00
}
else
2010-10-30 14:50:30 +00:00
{ // plugin links without queries
2006-12-02 04:36:16 +00:00
$link = str_replace ( " ../ " , " " , $link );
2020-12-20 11:50:10 -08:00
if ( stripos ( dirname ( e_SELF ), dirname ( $link )) !== false )
2007-08-02 20:42:16 +00:00
{
2006-12-02 04:36:16 +00:00
return TRUE ;
}
}
return FALSE ;
}
2010-10-30 14:50:30 +00:00
// --------------- highlight for news items.----------------
// eg. news.php, news.php?list.1 or news.php?cat.2 etc
2020-12-21 17:46:32 -08:00
if ( strpos ( basename ( $link ), " news.php " ) === 0 )
2010-10-30 14:50:30 +00:00
{
if ( strpos ( $link , " news.php? " ) !== FALSE && strpos ( e_SELF , " /news.php " ) !== FALSE )
{
$lnk = explode ( " . " , $link_qry ); // link queries.
$qry = explode ( " . " , e_QUERY ); // current page queries.
2006-12-02 04:36:16 +00:00
2020-12-21 17:46:32 -08:00
if ( $qry [ 0 ] === " item " )
2010-10-30 14:50:30 +00:00
{
2021-01-24 17:00:02 -08:00
return $qry [ 2 ] == $lnk [ 1 ];
2010-10-30 14:50:30 +00:00
}
2006-12-02 04:36:16 +00:00
2020-12-21 17:46:32 -08:00
if ( $qry [ 0 ] === " all " && $lnk [ 0 ] === " all " )
2010-10-30 14:50:30 +00:00
{
return TRUE ;
}
2006-12-02 04:36:16 +00:00
2010-10-30 14:50:30 +00:00
if ( $lnk [ 0 ] == $qry [ 0 ] && $lnk [ 1 ] == $qry [ 1 ])
{
return TRUE ;
}
2007-02-13 23:24:36 +00:00
2020-12-21 17:46:32 -08:00
if ( $qry [ 1 ] === " list " && $lnk [ 0 ] === " list " && $lnk [ 1 ] == $qry [ 2 ])
2010-10-30 14:50:30 +00:00
{
return TRUE ;
}
2006-12-02 04:36:16 +00:00
}
2017-01-28 10:36:26 -08:00
elseif ( ! e_QUERY && defset ( 'e_PAGE' ) === " news.php " )
2007-02-05 05:02:25 +00:00
{
2017-01-28 10:36:26 -08:00
return true ;
2007-02-05 05:02:25 +00:00
}
2006-12-02 04:36:16 +00:00
return FALSE ;
2010-10-30 14:50:30 +00:00
}
2006-12-02 04:36:16 +00:00
2010-10-30 14:50:30 +00:00
// --------------- highlight for Custom Pages.----------------
// eg. page.php?1, or page.php?5.7 [2nd parameter is page # within item]
2006-12-02 04:36:16 +00:00
2009-12-18 20:49:56 +00:00
//echo "Link: {$link}, link query: {$link_qry}, e_SELF: ".e_SELF.", link_slf: {$link_slf}, link_pge: {$link_pge}, e_PAGE: ".e_PAGE."<br />";
2020-12-21 17:46:32 -08:00
if (( $link_slf == e_HTTP . 'page.php' ) && ( e_PAGE === 'page.php' ))
2009-12-18 20:49:56 +00:00
{
list ( $custom , $page ) = explode ( '.' , $link_qry . '.' );
list ( $q_custom , $q_page ) = explode ( '.' , e_QUERY . '.' );
if ( $custom == $q_custom )
{
2006-12-02 04:36:16 +00:00
return TRUE ;
2009-12-18 20:49:56 +00:00
}
else
{
2006-12-02 04:36:16 +00:00
return FALSE ;
}
}
2010-10-30 14:50:30 +00:00
// --------------- highlight default ----------------
2009-12-18 20:49:56 +00:00
if ( strpos ( $link , '?' ) !== FALSE )
{
2006-12-02 04:36:16 +00:00
$thelink = str_replace ( " ../ " , " " , $link );
2010-10-30 14:50:30 +00:00
if ( ! preg_match ( " /all|item|cat|list/ " , e_QUERY ) && ( empty ( $link ) == false ) && ( strpos ( e_SELF , str_replace ( " ../ " , " " , $link )) !== false ))
{
2006-12-02 04:36:16 +00:00
return true ;
}
}
2009-12-18 20:49:56 +00:00
if ( ! preg_match ( " /all|item|cat|list/ " , e_QUERY ) && ( strpos ( e_SELF , str_replace ( " ../ " , " " , $link )) !== false ))
{
2006-12-02 04:36:16 +00:00
return true ;
}
2009-12-18 20:49:56 +00:00
if (( ! $link_qry && ! e_QUERY ) && ( empty ( $link ) == FALSE ) && ( strpos ( e_SELF , $link ) !== FALSE ))
{
2006-12-02 04:36:16 +00:00
return TRUE ;
}
2022-12-10 07:06:47 -08:00
if (( $link_slf == e_SELF && ! $link_qry ) || ( e_QUERY && empty ( $link ) == FALSE && strpos ( e_SELF . " ? " . e_QUERY , $link ) !== FALSE ) )
2009-12-18 20:49:56 +00:00
{
2006-12-02 04:36:16 +00:00
return TRUE ;
}
2010-12-13 09:23:04 +00:00
if ( $link_pge == basename ( $_SERVER [ 'REQUEST_URI' ])) // mod_rewrite support
{
return TRUE ;
}
2006-12-02 04:36:16 +00:00
return FALSE ;
}
2012-12-03 01:40:47 -08:00
}
/**
* Class for handling all navigation links site - wide . ie . admin links , admin - menu links , admin - plugin links , front - end sitelinks etc .
*/
class e_navigation
{
2012-12-14 12:19:13 +02:00
/**
* @ var array Admin link structure
*/
var $admin_cat = array ();
2013-10-24 13:09:43 +03:00
/**
* @ var boolean active check main
*/
public $activeSubFound = false ;
/**
* @ var boolean active check sub
*/
public $activeMainFound = false ;
2012-12-14 12:19:13 +02:00
2013-04-24 17:42:22 -07:00
var $iconArray = array ();
function __construct ()
{
if ( defined ( 'E_32_MAIN' )) // basic check so that it's not loaded on the front-end.
{
2013-04-29 12:56:50 -07:00
$this -> setIconArray ();
}
}
2021-02-03 11:46:32 -08:00
/**
* Guess the admin menu item icon based on the path
* @ param $key
* @ return string
*/
public static function guessMenuIcon ( $key )
{
2021-02-03 11:57:48 -08:00
$tmp = explode ( '/' , $key );
$mode = varset ( $tmp [ 0 ]);
$action = varset ( $tmp [ 1 ]);
2021-02-03 11:46:32 -08:00
switch ( $action )
{
case 'main' :
case 'list' :
$ret = $ret = ( $mode === 'cat' ) ? 'fa-folder.glyph' : 'fa-list.glyph' ;
break ;
case 'options' :
case 'prefs' :
case 'settings' :
case 'config' :
case 'configure' :
$ret = 'fa-cog.glyph' ;
break ;
case 'create' :
$ret = ( $mode === 'cat' ) ? 'fa-folder-plus.glyph' : 'fa-plus.glyph' ;
break ;
case 'tools' :
case 'maint' :
$ret = 'fas-toolbox.glyph' ;
break ;
case 'import' :
case 'upload' :
$ret = 'fa-upload.glyph' ;
break ;
default :
$ret = 'fa-question.glyph' ;
// code to be executed if n is different from all labels;
}
return $ret ;
}
2022-04-04 10:54:24 -07:00
/**
* @ return array
*/
2013-04-29 12:56:50 -07:00
function getIconArray ()
{
return $this -> iconArray ;
}
2022-04-04 10:54:24 -07:00
/**
* @ return void
*/
2013-04-29 12:56:50 -07:00
function setIconArray ()
{
if ( ! defined ( 'E_32_MAIN' ))
{
2021-01-24 10:44:30 -08:00
// e107::getCoreTemplate('admin_icons');
e107 :: loadAdminIcons ();
2013-04-29 12:56:50 -07:00
}
$this -> iconArray = array (
2013-04-24 17:42:22 -07:00
'main' => E_32_MAIN ,
'admin' => E_32_ADMIN ,
'admin_pass' => E_32_ADPASS ,
'banlist' => E_32_BANLIST ,
'cache' => E_32_CACHE ,
'comment' => E_32_COMMENT ,
'credits' => E_32_CREDITS ,
'cron' => E_32_CRON ,
'custom' => E_32_CUST ,
// 'custom_field' => E_32_CUSTOMFIELD,
'database' => E_32_DATAB ,
'docs' => E_32_DOCS ,
//'download' => E_32_DOWNL,
'emoticon' => E_32_EMOTE ,
'filemanage' => E_32_FILE ,
'fileinspector' => E_32_INSPECT ,
'frontpage' => E_32_FRONT ,
'image' => E_32_IMAGES ,
'language' => E_32_LANGUAGE ,
'links' => E_32_LINKS ,
'mail' => E_32_MAIL ,
'maintain' => E_32_MAINTAIN ,
'menus' => E_32_MENUS ,
'meta' => E_32_META ,
'newsfeed' => E_32_NEWSFEED ,
'news' => E_32_NEWS ,
'notify' => E_32_NOTIFY ,
'phpinfo' => E_32_PHP ,
'plug_manage' => E_32_PLUGMANAGER ,
'poll' => E_32_POLLS ,
'prefs' => E_32_PREFS ,
'search' => E_32_SEARCH ,
'syslogs' => E_32_ADMINLOG ,
'theme_manage' => E_32_THEMEMANAGER ,
'upload' => E_32_UPLOADS ,
'eurl' => E_32_EURL ,
'userclass' => E_32_USERCLASS ,
'user_extended' => E_32_USER_EXTENDED ,
'users' => E_32_USER ,
'wmessage' => E_32_WELCOME
2013-04-29 12:56:50 -07:00
);
2013-04-24 17:42:22 -07:00
2013-03-20 23:50:30 -07:00
}
2012-12-14 12:19:13 +02:00
/**
* Structure $this -> _md5cache [ $category ] = md5HASH
* @ var md5 hash used for build unique cache string per category and user classes
*/
protected $_md5cache = array ();
2012-12-03 01:40:47 -08:00
//FIXME array structure - see $this->admin();
2022-04-04 10:54:24 -07:00
/**
* @ return array
*/
2012-12-03 01:40:47 -08:00
function adminCats ()
{
2014-01-22 06:10:44 -08:00
$tp = e107 :: getParser ();
if ( count ( $this -> admin_cat ))
{
return $this -> admin_cat ;
}
2012-12-03 01:40:47 -08:00
$pref = e107 :: getPref ();
2015-06-11 09:40:56 -07:00
$this -> admin_cat [ 'title' ][ 1 ] = LAN_SETTINGS ;
2012-12-14 12:19:13 +02:00
$this -> admin_cat [ 'id' ][ 1 ] = 'setMenu' ;
2017-01-14 16:10:47 -08:00
$this -> admin_cat [ 'img' ][ 1 ] = 'fa-cogs.glyph' ;
2017-02-03 20:18:45 -08:00
$this -> admin_cat [ 'lrg_img' ][ 1 ] = $tp -> toGlyph ( 'e-settings-32' );
2012-12-14 12:19:13 +02:00
$this -> admin_cat [ 'sort' ][ 1 ] = true ;
2014-01-22 06:10:44 -08:00
/*
* i . e - cat_content - 32 { background - position : - 370 px 0 ; width : 32 px ; height : 32 px ; }
i . e - cat_files - 32 { background - position : - 407 px 0 ; width : 32 px ; height : 32 px ; }
i . e - cat_plugins - 32 { background - position : - 444 px 0 ; width : 32 px ; height : 32 px ; }
i . e - cat_settings - 32 { background - position : - 481 px 0 ; width : 32 px ; height : 32 px ; }
i . e - cat_tools - 32 { background - position : - 518 px 0 ; width : 32 px ; height : 32 px ; }
i . e - cat_users - 32 { background - position : - 555 px 0 ; width : 32 px ; height : 32 px ; }
* e - manage - 32
*/
2012-12-03 01:40:47 -08:00
2012-12-14 12:19:13 +02:00
$this -> admin_cat [ 'title' ][ 2 ] = ADLAN_CL_2 ;
$this -> admin_cat [ 'id' ][ 2 ] = 'userMenu' ;
2017-01-14 16:10:47 -08:00
$this -> admin_cat [ 'img' ][ 2 ] = 'fa-users.glyph' ; // $tp->toGlyph('e-cat_users-16');
2014-01-22 06:10:44 -08:00
$this -> admin_cat [ 'lrg_img' ][ 2 ] = $tp -> toGlyph ( 'e-cat_users-32' );
2012-12-14 12:19:13 +02:00
$this -> admin_cat [ 'sort' ][ 2 ] = true ;
2012-12-03 01:40:47 -08:00
2012-12-14 12:19:13 +02:00
$this -> admin_cat [ 'title' ][ 3 ] = ADLAN_CL_3 ;
$this -> admin_cat [ 'id' ][ 3 ] = 'contMenu' ;
2017-11-17 13:10:29 -08:00
$this -> admin_cat [ 'img' ][ 3 ] = 'fa-file-text-o.glyph' ; // $tp->toGlyph('e-cat_content-16');
2014-01-22 06:10:44 -08:00
$this -> admin_cat [ 'lrg_img' ][ 3 ] = $tp -> toGlyph ( 'e-cat_content-32' );
2012-12-14 12:19:13 +02:00
$this -> admin_cat [ 'sort' ][ 3 ] = true ;
2012-12-03 01:40:47 -08:00
2012-12-14 12:19:13 +02:00
$this -> admin_cat [ 'title' ][ 4 ] = ADLAN_CL_6 ;
$this -> admin_cat [ 'id' ][ 4 ] = 'toolMenu' ;
2017-11-17 13:10:29 -08:00
$this -> admin_cat [ 'img' ][ 4 ] = 'fa-wrench.glyph' ; // $tp->toGlyph('e-cat_tools-16');
2014-01-22 06:10:44 -08:00
$this -> admin_cat [ 'lrg_img' ][ 4 ] = $tp -> toGlyph ( 'e-cat_tools-32' );
2012-12-14 12:19:13 +02:00
$this -> admin_cat [ 'sort' ][ 4 ] = true ;
2012-12-03 01:40:47 -08:00
// Manage
2012-12-14 12:19:13 +02:00
$this -> admin_cat [ 'title' ][ 5 ] = LAN_MANAGE ;
$this -> admin_cat [ 'id' ][ 5 ] = 'managMenu' ;
2017-01-14 16:10:47 -08:00
$this -> admin_cat [ 'img' ][ 5 ] = 'fa-desktop.glyph' ; // $tp->toGlyph('e-manage-16');
2014-01-22 06:10:44 -08:00
$this -> admin_cat [ 'lrg_img' ][ 5 ] = $tp -> toGlyph ( 'e-manage-32' );
2012-12-14 12:19:13 +02:00
$this -> admin_cat [ 'sort' ][ 5 ] = TRUE ;
2012-12-03 01:40:47 -08:00
2020-12-20 11:50:10 -08:00
if ( ! empty ( $pref [ 'admin_separate_plugins' ]))
2012-12-03 01:40:47 -08:00
{
2012-12-14 12:19:13 +02:00
$this -> admin_cat [ 'title' ][ 6 ] = ADLAN_CL_7 ;
2014-01-22 06:10:44 -08:00
$this -> admin_cat [ 'id' ][ 6 ] = 'plugMenu' ;
2017-01-14 16:10:47 -08:00
$this -> admin_cat [ 'img' ][ 6 ] = 'fa-puzzle-piece.glyph' ; // $tp->toGlyph('e-cat_plugins-16');
2014-01-22 06:10:44 -08:00
$this -> admin_cat [ 'lrg_img' ][ 6 ] = $tp -> toGlyph ( 'e-cat_plugins-32' );
2012-12-14 12:19:13 +02:00
$this -> admin_cat [ 'sort' ][ 6 ] = false ;
2012-12-03 01:40:47 -08:00
}
else
{
// Misc.
2012-12-14 12:19:13 +02:00
$this -> admin_cat [ 'title' ][ 6 ] = ADLAN_CL_8 ;
$this -> admin_cat [ 'id' ][ 6 ] = 'miscMenu' ;
2020-12-21 17:46:32 -08:00
$this -> admin_cat [ 'img' ][ 6 ] = 'fa-puzzle-piece.glyph' ; // E_16_CAT_MISC;
2014-01-21 07:18:02 -08:00
$this -> admin_cat [ 'lrg_img' ][ 6 ] = '' ; // E_32_CAT_MISC;
2012-12-14 12:19:13 +02:00
$this -> admin_cat [ 'sort' ][ 6 ] = TRUE ;
2012-12-03 01:40:47 -08:00
}
//About menu - No 20 - leave space for user-categories.
2015-07-02 14:15:17 -07:00
$this -> admin_cat [ 'title' ][ 20 ] = LAN_ABOUT ;
2012-12-14 12:19:13 +02:00
$this -> admin_cat [ 'id' ][ 20 ] = 'aboutMenu' ;
2017-01-14 16:10:47 -08:00
$this -> admin_cat [ 'img' ][ 20 ] = 'fa-info-circle.glyph' ; // E_16_CAT_ABOUT;//E_16_NAV_DOCS
2017-02-03 20:18:45 -08:00
$this -> admin_cat [ 'lrg_img' ][ 20 ] = '' ; // $tp->toGlyph('e-cat_about-32'); ; // E_32_CAT_ABOUT;
2012-12-14 12:19:13 +02:00
$this -> admin_cat [ 'sort' ][ 20 ] = false ;
2012-12-03 01:40:47 -08:00
2012-12-14 12:19:13 +02:00
return $this -> admin_cat ;
2012-12-03 01:40:47 -08:00
}
2012-12-03 02:21:51 -08:00
// Previously $array_functions variable.
2022-04-04 10:54:24 -07:00
/**
* @ param $mode
* @ return array | array [] | string
*/
2012-12-03 02:21:51 -08:00
function adminLinks ( $mode = false )
2012-12-03 01:40:47 -08:00
{
2013-02-26 18:57:33 -08:00
2020-12-21 17:46:32 -08:00
if ( $mode === 'plugin' )
2013-02-26 18:57:33 -08:00
{
return $this -> pluginLinks ( E_16_PLUGMANAGER , " array " ) ;
2013-04-29 12:56:50 -07:00
}
2017-02-03 20:18:45 -08:00
2020-12-21 17:46:32 -08:00
if ( $mode === 'plugin2' )
2017-02-03 20:18:45 -08:00
{
return $this -> pluginLinks ( E_16_PLUGMANAGER , " standard " ) ;
}
2013-04-29 12:56:50 -07:00
$this -> setIconArray ();
2020-12-21 17:46:32 -08:00
if ( $mode === 'sub' )
2013-04-29 12:56:50 -07:00
{
2012-12-03 01:40:47 -08:00
//FIXME array structure suitable for e_admin_menu - see shortcodes/admin_navigation.php
/*
* Info about sublinks array structure
*
* key = $array_functions key
* attribute 1 = link
* attribute 2 = title
* attribute 3 = description
* attribute 4 = perms
* attribute 5 = category
* attribute 6 = 16 x 16 image
* attribute 7 = 32 x 32 image
*
*/
$array_sub_functions = array ();
$array_sub_functions [ 17 ][] = array ( e_ADMIN . 'newspost.php' , LAN_MANAGE , ADLAN_3 , 'H' , 3 , E_16_MANAGE , E_32_MANAGE );
$array_sub_functions [ 17 ][] = array ( e_ADMIN . 'newspost.php?create' , LAN_CREATE , ADLAN_2 , 'H' , 3 , E_16_CREATE , E_32_CREATE );
2015-01-30 18:14:06 -08:00
$array_sub_functions [ 17 ][] = array ( e_ADMIN . 'newspost.php?pref' , LAN_PREFS , LAN_PREFS , 'H' , 3 , E_16_SETTINGS , E_32_SETTINGS );
2012-12-03 01:40:47 -08:00
return $array_sub_functions ;
2013-04-29 12:56:50 -07:00
}
2012-12-03 01:40:47 -08:00
//FIXME array structure suitable for e_admin_menu (NOW admin() below) - see shortcodes/admin_navigation.php
//TODO find out where is used $array_functions elsewhere, refactor it
//XXX DO NOT EDIT without first checking perms in user_handler.php !!!!
2012-12-03 04:21:42 -08:00
2012-12-03 01:40:47 -08:00
$array_functions = array (
2014-03-13 00:21:34 +01:00
0 => array ( e_ADMIN_ABS . 'administrator.php' , ADLAN_8 , ADLAN_9 , '3' , 2 , E_16_ADMIN , E_32_ADMIN ),
2015-09-06 11:00:07 -07:00
1 => array ( e_ADMIN_ABS . 'updateadmin.php' , ADLAN_10 , ADLAN_11 , false , 2 , E_16_ADPASS , E_32_ADPASS ),
2014-03-13 00:21:34 +01:00
2 => array ( e_ADMIN_ABS . 'banlist.php' , ADLAN_34 , ADLAN_35 , '4' , 2 , E_16_BANLIST , E_32_BANLIST ),
4 => array ( e_ADMIN_ABS . 'cache.php' , ADLAN_74 , ADLAN_75 , 'C' , 1 , E_16_CACHE , E_32_CACHE ),
5 => array ( e_ADMIN_ABS . 'cpage.php' , ADLAN_42 , ADLAN_43 , '5|J' , 3 , E_16_CUST , E_32_CUST ),
6 => array ( e_ADMIN_ABS . 'db.php' , ADLAN_44 , ADLAN_45 , '0' , 4 , E_16_DATAB , E_32_DATAB ),
2012-12-03 01:40:47 -08:00
// 7 => array(e_ADMIN.'download.php', ADLAN_24, ADLAN_25, 'R', 3, E_16_DOWNL, E_32_DOWNL),
2014-03-13 00:21:34 +01:00
8 => array ( e_ADMIN_ABS . 'emoticon.php' , ADLAN_58 , ADLAN_59 , 'F' , 1 , E_16_EMOTE , E_32_EMOTE ),
2012-12-03 01:40:47 -08:00
// 9 => array(e_ADMIN.'filemanager.php', ADLAN_30, ADLAN_31, '6', 5, E_16_FILE, E_32_FILE), // replaced by media-manager
2014-03-13 00:21:34 +01:00
10 => array ( e_ADMIN_ABS . 'frontpage.php' , ADLAN_60 , ADLAN_61 , 'G' , 1 , E_16_FRONT , E_32_FRONT ),
11 => array ( e_ADMIN_ABS . 'image.php' , LAN_MEDIAMANAGER , LAN_MEDIAMANAGER , 'A' , 5 , E_16_IMAGES , E_32_IMAGES ),
2020-12-27 14:28:19 -08:00
12 => array ( e_ADMIN_ABS . 'links.php' , LAN_NAVIGATION , ADLAN_139 , 'I' , 1 , E_16_LINKS , E_32_LINKS ),
2014-03-13 00:21:34 +01:00
13 => array ( e_ADMIN_ABS . 'wmessage.php' , ADLAN_28 , ADLAN_29 , 'M' , 3 , E_16_WELCOME , E_32_WELCOME ),
14 => array ( e_ADMIN_ABS . 'ugflag.php' , ADLAN_40 , ADLAN_41 , '9' , 4 , E_16_MAINTAIN , E_32_MAINTAIN ),
15 => array ( e_ADMIN_ABS . 'menus.php' , ADLAN_6 , ADLAN_7 , '2' , 5 , E_16_MENUS , E_32_MENUS ),
16 => array ( e_ADMIN_ABS . 'meta.php' , ADLAN_66 , ADLAN_67 , 'T' , 1 , E_16_META , E_32_META ),
2015-06-06 02:33:23 -07:00
17 => array ( e_ADMIN_ABS . 'newspost.php' , ADLAN_0 , ADLAN_1 , 'H|N|7|H0|H1|H2|H3|H4|H5' , 3 , E_16_NEWS , E_32_NEWS ),
2014-03-13 00:21:34 +01:00
18 => array ( e_ADMIN_ABS . 'phpinfo.php' , ADLAN_68 , ADLAN_69 , '0' , 20 , E_16_PHP , E_32_PHP ),
2015-01-30 18:14:06 -08:00
19 => array ( e_ADMIN_ABS . 'prefs.php' , LAN_PREFS , ADLAN_5 , '1' , 1 , E_16_PREFS , E_32_PREFS ),
20 => array ( e_ADMIN_ABS . 'search.php' , LAN_SEARCH , ADLAN_143 , 'X' , 1 , E_16_SEARCH , E_32_SEARCH ),
2014-03-13 00:21:34 +01:00
21 => array ( e_ADMIN_ABS . 'admin_log.php' , ADLAN_155 , ADLAN_156 , 'S' , 4 , E_16_ADMINLOG , E_32_ADMINLOG ),
2019-07-29 12:37:08 -07:00
22 => array ( e_ADMIN_ABS . 'theme.php' , ADLAN_140 , ADLAN_141 , '1|TMP' , 5 , E_16_THEMEMANAGER , E_32_THEMEMANAGER ),
2014-03-13 00:21:34 +01:00
23 => array ( e_ADMIN_ABS . 'upload.php' , ADLAN_72 , ADLAN_73 , 'V' , 3 , E_16_UPLOADS , E_32_UPLOADS ),
24 => array ( e_ADMIN_ABS . 'users.php' , ADLAN_36 , ADLAN_37 , '4|U0|U1|U2|U3' , 2 , E_16_USER , E_32_USER ),
25 => array ( e_ADMIN_ABS . 'userclass2.php' , ADLAN_38 , ADLAN_39 , '4' , 2 , E_16_USERCLASS , E_32_USERCLASS ),
26 => array ( e_ADMIN_ABS . 'language.php' , ADLAN_132 , ADLAN_133 , 'L' , 1 , E_16_LANGUAGE , E_32_LANGUAGE ),
27 => array ( e_ADMIN_ABS . 'mailout.php' , ADLAN_136 , ADLAN_137 , 'W' , 2 , E_16_MAIL , E_32_MAIL ),
28 => array ( e_ADMIN_ABS . 'users_extended.php' , ADLAN_78 , ADLAN_79 , '4' , 2 , E_16_USER_EXTENDED , E_32_USER_EXTENDED ),
29 => array ( e_ADMIN_ABS . 'fileinspector.php' , ADLAN_147 , ADLAN_148 , 'Y' , 4 , E_16_INSPECT , E_32_INSPECT ),
30 => array ( e_ADMIN_ABS . 'notify.php' , ADLAN_149 , ADLAN_150 , 'O' , 4 , E_16_NOTIFY , E_32_NOTIFY ),
31 => array ( e_ADMIN_ABS . 'cron.php' , ADLAN_157 , ADLAN_158 , 'U' , 4 , E_16_CRON , E_32_CRON ),
32 => array ( e_ADMIN_ABS . 'eurl.php' , ADLAN_159 , ADLAN_160 , 'K' , 1 , E_16_EURL , E_32_EURL ),
33 => array ( e_ADMIN_ABS . 'plugin.php' , ADLAN_98 , ADLAN_99 , 'Z' , 5 , E_16_PLUGMANAGER , E_32_PLUGMANAGER ),
2017-12-01 17:00:02 -08:00
34 => array ( e_ADMIN_ABS . 'docs.php' , ADLAN_12 , ADLAN_13 , false , 20 , E_16_DOCS , E_32_DOCS ),
2012-12-03 01:40:47 -08:00
// TODO System Info.
// 35 => array('#TODO', 'System Info', 'System Information', '', 20, '', ''),
2017-12-01 17:00:02 -08:00
36 => array ( e_ADMIN_ABS . 'credits.php' , LAN_CREDITS , LAN_CREDITS , false , 20 , E_16_E107 , E_32_E107 ),
2012-12-03 01:40:47 -08:00
// 37 => array(e_ADMIN.'custom_field.php', ADLAN_161, ADLAN_162, 'U', 4, E_16_CUSTOMFIELD, E_32_CUSTOMFIELD),
2016-06-20 11:12:25 +02:00
38 => array ( e_ADMIN_ABS . 'comment.php' , LAN_COMMENTMAN , LAN_COMMENTMAN , 'B' , 5 , E_16_COMMENT , E_32_COMMENT ),
2017-12-01 17:00:02 -08:00
);
2020-12-21 17:46:32 -08:00
if ( $mode === 'legacy' )
2013-02-26 18:57:33 -08:00
{
return $array_functions ; // Old BC format.
}
$newarray = asortbyindex ( $array_functions , 1 );
$array_functions_assoc = $this -> convert_core_icons ( $newarray );
2017-12-01 17:00:02 -08:00
2013-02-26 18:57:33 -08:00
2020-12-21 17:46:32 -08:00
if ( $mode === 'core' ) // Core links only.
2013-02-26 18:57:33 -08:00
{
return $array_functions_assoc ;
}
$merged = array_merge ( $array_functions_assoc , $this -> pluginLinks ( E_16_PLUGMANAGER , " array " ));
$sorted = multiarray_sort ( $merged , 'title' ); // this deleted the e-xxxx and p-xxxxx keys.
return $this -> restoreKeys ( $sorted ); // we restore the keys with this.
2012-12-03 01:40:47 -08:00
}
2022-04-04 10:54:24 -07:00
/**
* @ param $newarray
* @ return array
*/
private function restoreKeys ( $newarray ) // Put core button array in the same format as plugin button array.
2013-02-26 18:57:33 -08:00
{
$array_functions_assoc = array ();
foreach ( $newarray as $key => $val )
{
if ( varset ( $val [ 'key' ])) // Plugin Array.
{
$key = $val [ 'key' ];
$array_functions_assoc [ $key ] = $val ;
}
}
2017-12-01 17:00:02 -08:00
2013-02-26 18:57:33 -08:00
return $array_functions_assoc ;
}
2019-01-15 08:55:34 -08:00
/**
* Return the default array of icon identifiers for the admin " Control Panel " . ( infopanel and flexpanel )
* @ return array
*/
public function getDefaultAdminPanelArray ()
{
$iconlist = $this -> adminLinks ();
$defArray = array ();
$exclude = array (
'e-administrator' ,
'e-updateadmin' ,
'e-banlist' ,
'e-cache' ,
'e-comment' ,
'e-credits' ,
'e-db' ,
'e-docs' ,
'e-emoticon' ,
'e-users_extended' ,
'e-fileinspector' ,
'e-language' ,
'e-ugflag' ,
'e-notify' ,
'e-phpinfo' ,
'e-upload' ,
'e-cron' ,
'e-search' ,
'e-admin_log' ,
'e-eurl'
);
foreach ( $iconlist as $k => $v )
{
if ( ! in_array ( $k , $exclude ))
{
$defArray [] = $k ;
}
}
return $defArray ;
}
2022-04-04 10:54:24 -07:00
/**
* @ param $newarray
* @ return array
*/
2013-02-26 18:57:33 -08:00
private function convert_core_icons ( $newarray ) // Put core button array in the same format as plugin button array.
2012-12-03 02:21:51 -08:00
{
2013-02-26 18:57:33 -08:00
$array_functions_assoc = array ();
2012-12-03 02:21:51 -08:00
foreach ( $newarray as $key => $val )
{
if ( varset ( $val [ 0 ]))
{
$key = " e- " . basename ( $val [ 0 ], " .php " );
2013-02-26 18:57:33 -08:00
$val [ 'key' ] = $key ;
2012-12-03 02:21:51 -08:00
$val [ 'icon' ] = $val [ 5 ];
$val [ 'icon_32' ] = $val [ 6 ];
$val [ 'title' ] = $val [ 1 ];
$val [ 'link' ] = $val [ 0 ];
$val [ 'caption' ] = $val [ '2' ];
2013-02-25 17:15:46 -08:00
$val [ 'cat' ] = $val [ '4' ];
2012-12-03 02:21:51 -08:00
$val [ 'perms' ] = $val [ '3' ];
$array_functions_assoc [ $key ] = $val ;
}
2013-02-26 18:57:33 -08:00
2012-12-03 02:21:51 -08:00
}
return $array_functions_assoc ;
}
2013-02-25 17:15:46 -08:00
/**
* Convert from plugin category found in plugin . xml to Navigation Category ID number .
*/
function plugCatToCoreCat ( $cat )
{
$convert = array (
'settings' => array ( 1 , 'setMenu' ),
'users' => array ( 2 , 'userMenu' ),
'content' => array ( 3 , 'contMenu' ),
'tools' => array ( 4 , 'toolMenu' ),
'manage' => array ( 6 , 'managMenu' ),
'misc' => array ( 7 , 'miscMenu' ),
'help' => array ( 20 , 'helpMenu' )
);
return ( int ) vartrue ( $convert [ $cat ][ 0 ]);
}
2017-02-03 20:18:45 -08:00
/**
* Get Plugin Links - rewritten for v2 . 1.5
* @ param string $iconSize
* @ param string $linkStyle standard = new in v2 . 1.5 | array | adminb
* @ return array | string
*/
function pluginLinks ( $iconSize = E_16_PLUGMANAGER , $linkStyle = 'adminb' )
{
$plug = e107 :: getPlug ();
$data = $plug -> getInstalled ();
$arr = array ();
$pref = e107 :: getPref ();
2017-02-06 08:47:39 -08:00
foreach ( $data as $path => $ver )
2017-02-03 20:18:45 -08:00
{
if ( ! e107 :: isInstalled ( $path ))
{
continue ;
}
if ( ! empty ( $pref [ 'lan_global_list' ]) && ! in_array ( $path , $pref [ 'lan_global_list' ]))
{
e107 :: loadLanFiles ( $path , 'admin' );
}
2017-02-04 12:49:44 -08:00
$plug -> load ( $path );
2017-02-03 20:18:45 -08:00
$key = ( $linkStyle === 'standard' ) ? " plugnav- " . $path : 'p-' . $path ;
2017-02-04 12:49:44 -08:00
$url = $plug -> getAdminUrl ();
$cat = $plug -> getCategory ();
2017-02-03 20:18:45 -08:00
if ( empty ( $url ) || $cat === 'menu' )
{
continue ;
}
// Keys compatible with legacy and new admin layouts.
$arr [ $key ] = array (
2017-02-04 12:49:44 -08:00
'text' => $plug -> getName (),
'description' => $plug -> getDescription (),
2017-02-03 20:18:45 -08:00
'link' => $url ,
2017-02-04 12:49:44 -08:00
'image' => $plug -> getIcon ( 16 ),
'image_large' => $plug -> getIcon ( 32 ),
2017-02-03 20:18:45 -08:00
'category' => $cat ,
2017-02-04 12:49:44 -08:00
'perm' => " P " . $plug -> getId (),
2017-02-03 20:18:45 -08:00
'sort' => 2 ,
'sub_class' => null ,
// Legacy Keys.
'key' => $key ,
2017-02-04 12:49:44 -08:00
'title' => $plug -> getName (),
'caption' => $plug -> getAdminCaption (),
'perms' => " P " . $plug -> getId (),
'icon' => $plug -> getIcon ( 16 ),
'icon_32' => $plug -> getIcon ( 32 ),
'cat' => $this -> plugCatToCoreCat ( $plug -> getCategory ())
2017-02-03 20:18:45 -08:00
);
}
//ksort($arr, SORT_STRING);
if ( $linkStyle === " array " || $iconSize === 'assoc' || $linkStyle === 'standard' )
{
return $arr ;
}
$text = '' ;
foreach ( $arr as $plug_key => $plug_value )
{
$the_icon = ( $iconSize == E_16_PLUGMANAGER ) ? $plug_value [ 'icon' ] : $plug_value [ 'icon_32' ];
$text .= $this -> renderAdminButton ( $plug_value [ 'link' ], $plug_value [ 'title' ], $plug_value [ 'caption' ], $plug_value [ 'perms' ], $the_icon , $linkStyle );
}
return $text ;
}
2012-12-03 01:40:47 -08:00
/**
* XXX the NEW version of e_admin_menu ();
* Build admin menus - addmin menus are now supporting unlimitted number of submenus
* TODO - add this to a handler for use on front - end as well ( tree , sitelinks . sc replacement )
*
* $e107_vars structure :
* $e107_vars [ 'action' ][ 'text' ] -> link title
* $e107_vars [ 'action' ][ 'link' ] -> if empty '#action' will be added as href attribute
* $e107_vars [ 'action' ][ 'image' ] -> ( new ) image tag
* $e107_vars [ 'action' ][ 'perm' ] -> permissions via getperms ()
* $e107_vars [ 'action' ][ 'userclass' ] -> user class permissions via check_class ()
* $e107_vars [ 'action' ][ 'include' ] -> additional < a > tag attributes
* $e107_vars [ 'action' ][ 'sub' ] -> ( new ) array , exactly the same as $e107_vars ' first level e.g. $e107_vars[' action '][' sub '][' action2 '][' link ' ] ...
* $e107_vars [ 'action' ][ 'sort' ] -> ( new ) used only if found in 'sub' array - passed as last parameter ( recursive call )
* $e107_vars [ 'action' ][ 'link_class' ] -> ( new ) additional link class
* $e107_vars [ 'action' ][ 'sub_class' ] -> ( new ) additional class used only when sublinks are being parsed
*
* @ param string $title
* @ param string $active_page
* @ param array $e107_vars
* @ param array $tmpl
* @ param array $sub_link
* @ param bool $sortlist
* @ return string parsed admin menu ( or empty string if title is empty )
*/
function admin ( $title , $active_page , $e107_vars , $tmpl = array (), $sub_link = false , $sortlist = false )
{
2013-07-12 07:13:10 -07:00
$tp = e107 :: getParser ();
2012-12-03 01:40:47 -08:00
if ( ! $tmpl )
2020-12-21 17:46:32 -08:00
{
2021-01-27 12:20:58 -08:00
$tmpl = e107 :: getCoreTemplate ( 'admin' , 'menu' , false );
2020-12-21 17:46:32 -08:00
}
2012-12-03 01:40:47 -08:00
/*
* Search for id
*/
2021-01-29 09:27:38 -08:00
$extraParms = array ();
2012-12-03 01:40:47 -08:00
$temp = explode ( '--id--' , $title , 2 );
$title = $temp [ 0 ];
$id = str_replace ( array ( ' ' , '_' ), '-' , varset ( $temp [ 1 ]));
2021-01-29 09:27:38 -08:00
if ( isset ( $e107_vars [ '_extras_' ])) // hold icon info, but could be more.
{
$extraParms = $e107_vars [ '_extras_' ];
unset ( $e107_vars [ '_extras_' ]);
}
2012-12-03 01:40:47 -08:00
unset ( $temp );
/*
* SORT
*/
if ( $sortlist == TRUE )
{
$temp = $e107_vars ;
unset ( $e107_vars );
$func_list = array ();
foreach ( array_keys ( $temp ) as $key )
{
$func_list [] = $temp [ $key ][ 'text' ];
}
usort ( $func_list , 'strcoll' );
foreach ( $func_list as $func_text )
{
foreach ( array_keys ( $temp ) as $key )
{
if ( $temp [ $key ][ 'text' ] == $func_text )
{
$e107_vars [] = $temp [ $key ];
}
}
}
unset ( $temp );
}
2017-12-01 17:00:02 -08:00
if ( empty ( $e107_vars ))
2013-04-24 01:45:54 -07:00
{
2017-12-01 17:00:02 -08:00
return null ;
2013-04-24 01:45:54 -07:00
}
2017-12-01 17:00:02 -08:00
2012-12-03 01:40:47 -08:00
$kpost = '' ;
$text = '' ;
if ( $sub_link )
{
$kpost = '_sub' ;
}
2021-01-06 11:52:29 -08:00
elseif ( isset ( $tmpl [ 'start' ]))
2012-12-03 01:40:47 -08:00
{
$text = $tmpl [ 'start' ];
}
2020-06-02 12:02:43 -07:00
2012-12-03 01:40:47 -08:00
//FIXME - e_parse::array2sc()
2019-06-26 13:48:53 -07:00
/* $search = array ();
2012-12-03 01:40:47 -08:00
$search [ 0 ] = '/\{LINK_TEXT\}(.*?)/si' ;
$search [ 1 ] = '/\{LINK_URL\}(.*?)/si' ;
$search [ 2 ] = '/\{ONCLICK\}(.*?)/si' ;
$search [ 3 ] = '/\{SUB_HEAD\}(.*?)/si' ;
$search [ 4 ] = '/\{SUB_MENU\}(.*?)/si' ;
$search [ 5 ] = '/\{ID\}(.*?)/si' ;
$search [ 6 ] = '/\{SUB_ID\}(.*?)/si' ;
$search [ 7 ] = '/\{LINK_CLASS\}(.*?)/si' ;
$search [ 8 ] = '/\{SUB_CLASS\}(.*?)/si' ;
$search [ 9 ] = '/\{LINK_IMAGE\}(.*?)/si' ;
2017-11-19 07:29:10 -08:00
$search [ 10 ] = '/\{LINK_SUB_OVERSIZED\}/si' ;
2019-06-26 13:48:53 -07:00
$search [ 11 ] = '/\{LINK_DATA\}/si' ; */
2017-11-19 07:29:10 -08:00
2015-07-11 14:07:04 -07:00
2012-12-03 01:40:47 -08:00
foreach ( array_keys ( $e107_vars ) as $act )
{
2017-12-01 17:00:02 -08:00
if ( isset ( $e107_vars [ $act ][ 'perm' ]) && $e107_vars [ $act ][ 'perm' ] !== false && ! getperms ( $e107_vars [ $act ][ 'perm' ])) // check perms first.
2012-12-03 01:40:47 -08:00
{
continue ;
}
2015-07-11 14:07:04 -07:00
2012-12-03 01:40:47 -08:00
2012-12-10 16:01:44 -08:00
if ( isset ( $e107_vars [ $act ][ 'header' ]))
{
2021-02-01 18:18:30 -08:00
$text .= str_replace ( '{HEADING}' , $e107_vars [ $act ][ 'header' ], $tmpl [ 'heading' ]);
2012-12-10 16:01:44 -08:00
continue ;
}
2021-01-20 12:07:29 -08:00
if ( isset ( $e107_vars [ $act ][ 'divider' ]) && ! empty ( $tmpl [ 'divider' ]))
2012-12-10 16:01:44 -08:00
{
2013-03-07 05:02:04 -08:00
$text .= $tmpl [ 'divider' ];
2012-12-10 16:01:44 -08:00
continue ;
}
2021-02-05 10:17:51 -08:00
2012-12-03 01:40:47 -08:00
// check class so that e.g. e_UC_NOBODY will result no permissions granted (even for main admin)
if ( isset ( $e107_vars [ $act ][ 'userclass' ]) && ! e107 :: getUser () -> checkClass ( $e107_vars [ $act ][ 'userclass' ], false )) // check userclass perms
{
continue ;
}
2015-07-11 14:07:04 -07:00
2021-02-05 10:17:51 -08:00
$replace = array ();
2015-07-11 14:07:04 -07:00
2012-12-03 01:40:47 -08:00
$rid = str_replace ( array ( ' ' , '_' ), '-' , $act ) . ( $id ? " - { $id } " : '' );
2013-03-10 18:43:44 -07:00
//XXX && !is_numeric($act) ???
2020-06-02 12:02:43 -07:00
if (( $active_page == ( string ) $act )
|| ( str_replace ( " ? " , " " , e_PAGE . e_QUERY ) == str_replace ( " ? " , " " , $act ))
2020-12-29 08:04:52 -08:00
|| e_REQUEST_HTTP === varset ( $e107_vars [ $act ][ 'link' ])
2020-06-02 12:02:43 -07:00
)
2012-12-03 01:40:47 -08:00
{
2021-11-25 07:36:07 -08:00
$temp = isset ( $tmpl [ 'button_active' . $kpost ]) ? $tmpl [ 'button_active' . $kpost ] : '' ;
2012-12-03 01:40:47 -08:00
}
else
{
2021-01-06 11:52:29 -08:00
$temp = isset ( $tmpl [ 'button' . $kpost ]) ? $tmpl [ 'button' . $kpost ] : '' ;
2012-12-03 01:40:47 -08:00
}
2020-06-02 12:02:43 -07:00
// e107::getDebug()->log($e107_vars[$act]['link']);
2012-12-03 01:40:47 -08:00
// $temp = $tmpl['button'.$kpost];
// echo "ap = ".$active_page;
// echo " act = ".$act."<br /><br />";
2017-01-24 15:19:40 -08:00
2012-12-03 01:40:47 -08:00
2020-12-21 17:46:32 -08:00
if ( $rid === 'adminhome' )
2012-12-03 01:40:47 -08:00
{
$temp = $tmpl [ 'button_other' . $kpost ];
}
2017-01-24 15:19:40 -08:00
if ( ! empty ( $e107_vars [ $act ][ 'template' ]))
2012-12-03 01:40:47 -08:00
{
2017-01-24 15:19:40 -08:00
$tmplateKey = 'button_' . $e107_vars [ $act ][ 'template' ] . $kpost ;
2021-01-16 13:32:35 -08:00
$temp = varset ( $tmpl [ $tmplateKey ]);
2012-12-03 01:40:47 -08:00
}
2017-01-24 15:19:40 -08:00
2021-01-22 06:32:59 -08:00
$replace [ 'LINK_TEXT' ] = str_replace ( " " , " " , varset ( $e107_vars [ $act ][ 'text' ]));
2021-02-03 11:46:32 -08:00
$replace [ 'LINK_DESCRIPTION' ] = varset ( $e107_vars [ $act ][ 'description' ]);
2019-06-26 13:48:53 -07:00
2012-12-03 01:40:47 -08:00
// valid URLs
2019-06-26 13:48:53 -07:00
$replace [ 'LINK_URL' ] = str_replace ( array ( '&' , '&' ), array ( '&' , '&' ), vartrue ( $e107_vars [ $act ][ 'link' ], " # { $act } " ));
$replace [ 'ONCLICK' ] = '' ;
2015-02-14 23:34:15 -08:00
if ( vartrue ( $e107_vars [ $act ][ 'include' ]))
2012-12-03 01:40:47 -08:00
{
2019-06-26 13:48:53 -07:00
$replace [ 'ONCLICK' ] = $e107_vars [ $act ][ 'include' ];
2012-12-03 01:40:47 -08:00
//$replace[2] = $js ? " onclick=\"showhideit('".$act."');\"" : " onclick=\"document.location='".$e107_vars[$act]['link']."'; disabled=true;\"";
}
2019-06-26 13:48:53 -07:00
$replace [ 'SUB_HEAD' ] = $title ;
$replace [ 'SUB_MENU' ] = '' ;
2012-12-03 01:40:47 -08:00
2019-06-26 13:48:53 -07:00
$replace [ 'ID' ] = $id ? " id='eplug-nav- { $rid } ' " : '' ;
$replace [ 'SUB_ID' ] = $rid ;
2012-12-03 01:40:47 -08:00
2019-06-26 13:48:53 -07:00
$replace [ 'LINK_CLASS' ] = varset ( $e107_vars [ $act ][ 'link_class' ]);
$replace [ 'SUB_CLASS' ] = '' ;
2021-02-03 11:46:32 -08:00
if ( ! isset ( $e107_vars [ $act ][ 'image_src' ]) && ! isset ( $e107_vars [ $act ][ 'icon' ]))
{
$e107_vars [ $act ][ 'image_src' ] = self :: guessMenuIcon ( $act . '/' . $act );
}
2013-07-12 07:13:10 -07:00
2020-12-20 11:50:10 -08:00
if ( ! empty ( $e107_vars [ $act ][ 'image_src' ]) && strpos ( $e107_vars [ $act ][ 'image_src' ], '.glyph' ) !== false )
2013-07-12 07:13:10 -07:00
{
2019-06-26 13:48:53 -07:00
$replace [ 'LINK_IMAGE' ] = $tp -> toGlyph ( $e107_vars [ $act ][ 'image_src' ], array ( 'space' => ' ' ));
2013-07-12 07:13:10 -07:00
}
else
{
2019-06-26 13:48:53 -07:00
$replace [ 'LINK_IMAGE' ] = varset ( $e107_vars [ $act ][ 'image' ]);
2013-07-12 07:13:10 -07:00
}
2015-07-11 14:07:04 -07:00
2021-01-28 11:43:32 -08:00
$replace [ 'LINK_SUB_OVERSIZED' ] = ( isset ( $e107_vars [ $act ][ 'sub' ]) && count ( $e107_vars [ $act ][ 'sub' ]) > 15 ) ? 'oversized' : '' ;
2017-11-19 07:29:10 -08:00
2015-07-11 14:07:04 -07:00
if ( ! empty ( $e107_vars [ $act ][ 'link_data' ]))
{
$dataTmp = array ();
foreach ( $e107_vars [ $act ][ 'link_data' ] as $k => $v )
{
$dataTmp [] = $k . '="' . $v . '"' ;
}
2019-06-26 13:48:53 -07:00
$replace [ 'LINK_DATA' ] = implode ( " " , $dataTmp ); // $e107_vars[$act]['link_data']
2015-07-11 14:07:04 -07:00
}
2017-11-19 07:29:10 -08:00
2019-06-26 13:48:53 -07:00
$replace [ 'LINK_BADGE' ] = isset ( $e107_vars [ $act ][ 'badge' ][ 'value' ]) ? $tp -> toLabel ( $e107_vars [ $act ][ 'badge' ][ 'value' ], varset ( $e107_vars [ $act ][ 'badge' ][ 'type' ])) : '' ;
2017-11-19 07:29:10 -08:00
2020-12-21 17:46:32 -08:00
if ( $rid === 'logout' || $rid === 'home' || $rid === 'language' )
2012-12-03 01:40:47 -08:00
{
$START_SUB = $tmpl [ 'start_other_sub' ];
}
else
{
2021-01-06 11:52:29 -08:00
$START_SUB = isset ( $tmpl [ 'start_sub' ]) ? $tmpl [ 'start_sub' ] : '' ;
2012-12-03 01:40:47 -08:00
}
2017-12-01 17:00:02 -08:00
if ( ! empty ( $e107_vars [ $act ][ 'sub' ]))
2012-12-03 01:40:47 -08:00
{
2019-06-26 13:48:53 -07:00
$replace [ 'SUB_ID' ] = $id ? " id='eplug-nav- { $rid } -sub' " : '' ;
$replace [ 'LINK_CLASS' ] = ' ' . varset ( $e107_vars [ $act ][ 'link_class' ], 'e-expandit' );
$replace [ 'SUB_CLASS' ] = ' ' . varset ( $e107_vars [ $act ][ 'sub_class' ], 'e-hideme e-expandme' );
2019-07-02 09:38:51 -07:00
$replace [ 'SUB_MENU' ] = $tp -> parseTemplate ( $START_SUB , false , $replace );
2019-06-26 13:48:53 -07:00
$replace [ 'SUB_MENU' ] .= $this -> admin ( false , $active_page , $e107_vars [ $act ][ 'sub' ], $tmpl , true , ( isset ( $e107_vars [ $act ][ 'sort' ]) ? $e107_vars [ $act ][ 'sort' ] : $sortlist ));
2021-01-06 11:52:29 -08:00
$replace [ 'SUB_MENU' ] .= isset ( $tmpl [ 'end_sub' ]) ? $tmpl [ 'end_sub' ] : '' ;
2012-12-03 01:40:47 -08:00
}
2019-06-26 13:48:53 -07:00
2021-01-27 12:53:45 -08:00
$text .= $tp -> simpleParse ( $temp , $replace );
2021-02-05 10:17:51 -08:00
2012-12-03 01:40:47 -08:00
}
2021-01-06 11:52:29 -08:00
$text .= ( ! $sub_link && isset ( $tmpl [ 'end' ])) ? $tmpl [ 'end' ] : '' ;
2012-12-03 01:40:47 -08:00
if ( $sub_link || empty ( $title ))
{
return $text ;
}
$ns = e107 :: getRender ();
2017-02-05 15:49:03 -08:00
$ns -> setUniqueId ( $id );
2021-01-29 09:27:38 -08:00
$srch = array ( '{ICON}' , '{CAPTION}' );
$repl = array ( varset ( $extraParms [ 'icon' ]), $title );
2021-09-04 15:06:19 +02:00
$caption = isset ( $tmpl [ 'caption' ]) ? ( string ) $tmpl [ 'caption' ] : '' ;
$title = str_replace ( $srch , $repl , $caption );
2021-01-29 09:27:38 -08:00
$ret = $ns -> tablerender ( $title , $text , 'default' , true );
2019-06-26 13:48:53 -07:00
$ns -> setUniqueId ( null );
2021-01-29 09:27:38 -08:00
2021-01-29 11:03:04 -08:00
if ( ! empty ( $extraParms [ 'return' ]))
{
return $ret ;
}
echo $ret ;
2012-12-03 01:40:47 -08:00
}
2012-12-03 02:21:51 -08:00
// Previously admin.php -> render_links();
2022-04-04 10:54:24 -07:00
/**
* @ param $link
* @ param $title
* @ param $description
* @ param $perms
* @ param $icon
* @ param $mode
* @ return string
*/
2012-12-03 02:21:51 -08:00
function renderAdminButton ( $link , $title , $description , $perms , $icon = FALSE , $mode = FALSE )
{
2012-12-03 18:41:25 -08:00
global $td ;
2012-12-03 02:21:51 -08:00
$tp = e107 :: getParser ();
2012-12-03 18:41:25 -08:00
$mes = e107 :: getMessage ();
2013-02-26 21:27:36 -08:00
$cols = defset ( 'ADLINK_COLS' , 5 );
2012-12-03 02:21:51 -08:00
$text = '' ;
if ( getperms ( $perms ))
{
$description = strip_tags ( $description );
2020-12-21 17:46:32 -08:00
if ( $mode === 'adminb' )
2012-12-03 02:21:51 -08:00
{
$text = " <tr><td class='forumheader3'>
< div class = 'td' style = 'text-align:left; vertical-align:top; width:100%'
onmouseover = \ " eover(this, 'forumheader5') \" onmouseout= \" eover(this, 'td') \" onclick= \" document.location.href=' " . $link . " ' \" >
" . $icon . " < b > " . $title . " </ b > " .( $description ? " [ < span class = 'field-help' > " . $description . " </ span > ] " : " " ). " </ div ></ td ></ tr > " ;
}
else
{
2020-12-21 17:46:32 -08:00
if ( $mode !== " div " && $mode !== 'div-icon-only' )
2012-12-03 02:21:51 -08:00
{
2012-12-15 16:41:37 -08:00
if ( $td == ( $cols + 1 ))
2012-12-03 02:21:51 -08:00
{
$text .= '</tr>' ;
$td = 1 ;
}
if ( $td == 1 )
{
$text .= '<tr>' ;
}
}
switch ( $mode )
{
case 'default' :
2013-02-26 21:27:36 -08:00
$text .= " <td class='td' style='text-align:left; vertical-align:top; width:20%; white-space:nowrap'>
< a class = 'core-mainpanel-link-icon e-tip' href = '".$link."' title = '{$description}' > " . $icon . " " . $tp->toHTML ( $title ,FALSE, " defs , emotes_off " ). " </ a ></ td > " ;
2012-12-03 02:21:51 -08:00
break ;
case 'classis' :
$text .= " <td style='text-align:center; vertical-align:top; width:20%'><a class='core-mainpanel-link-icon' href=' " . $link . " ' title=' { $description } '> " . $icon . " </a><br />
2013-02-26 21:27:36 -08:00
< a class = 'core-mainpanel-link-text' href = '".$link."' title = '{$description}' >< b > " . $tp->toHTML ( $title ,FALSE, " defs , emotes_off " ). " </ b ></ a ></ td > " ;
2012-12-03 02:21:51 -08:00
break ;
case 'beginner' :
$text .= " <td style='text-align:center; vertical-align:top; width:20%' ><a class='core-mainpanel-link-icon' href=' " . $link . " ' > " . $icon . " </a>
< div style = 'padding:5px' >
< a class = 'core-mainpanel-link-text' href = '".$link."' title = '".$description."' >< b > " . $tp->toHTML ( $title ,FALSE, " defs , emotes_off " ). " </ b ></ a ></ div >< br />< br />< br /></ td > " ;
break ;
case 'div' :
2021-01-26 15:08:58 -08:00
$text .= " <div class='core-mainpanel-block col-md-2'><a data-toggle='tooltip' data-bs-toggle='tooltip' class='core-mainpanel-link-icon btn btn-default btn-secondary muted' href=' " . $link . " ' title=' { $description } '> " . $icon . "
2013-02-06 13:01:09 -08:00
< small class = 'core-mainpanel-link-text' > " . $tp->toHTML ( $title ,FALSE, " defs , emotes_off " ). " </ small ></ a >
2012-12-03 02:21:51 -08:00
</ div > " ;
break ;
case 'div-icon-only' :
2018-01-10 15:06:40 -08:00
$text .= " <div class='core-mainpanel-block e-tip' title=' { $description } '><a class='core-mainpanel-link-icon btn btn-default btn-secondary e-tip' href=' " . $link . " ' > " . $icon . " </a></div> " ;
2012-12-03 02:21:51 -08:00
break ;
default :
break ;
}
$td ++ ;
}
}
2020-12-18 19:55:12 -08:00
//else
//{
2012-12-03 18:41:25 -08:00
// echo "no Perms";
2020-12-18 19:55:12 -08:00
//}
2012-12-03 02:21:51 -08:00
return $text ;
}
2022-04-04 10:54:24 -07:00
/**
* @ param $category
* @ param $type
* @ return mixed | string | void
*/
2012-12-14 12:19:13 +02:00
public function cacheString ( $category , $type = 'sys' )
{
if ( ! isset ( $this -> _md5cache [ $category ]))
{
$uclist = e107 :: getUser () -> getClassList ();
sort ( $uclist , SORT_NUMERIC );
$this -> _md5cache [ $category ] = md5 ( $category . $uclist );
}
switch ( $type )
{
case 'sys' :
return $this -> cacheBase () . $this -> _md5cache [ $category ];
break ;
case 'md5' :
return $this -> _md5cache [ $category ];
break ;
}
}
2022-04-04 10:54:24 -07:00
/**
* @ return string
*/
2012-12-14 12:19:13 +02:00
public function cacheBase ()
{
return 'nomd5_sitelinks_' ;
}
2012-12-14 17:22:04 -08:00
/**
* TODO Cache
*/
2020-12-27 12:46:37 -08:00
public function render ( $data , $template , $opts = array ())
2012-12-14 16:32:39 +02:00
{
2020-12-21 17:46:32 -08:00
if ( empty ( $data ) || empty ( $template ) || ! is_array ( $template ))
{
return '' ;
}
2012-12-14 16:32:39 +02:00
2019-04-30 14:01:05 -07:00
/** @var navigation_shortcodes $sc */
$sc = e107 :: getScBatch ( 'navigation' );
2020-12-27 12:46:37 -08:00
$sc -> template = $template ;
if ( ! empty ( $opts [ 'class' ]))
{
$sc -> navClass = $opts [ 'class' ];
}
2020-12-27 14:30:51 -08:00
$head = e107 :: getParser () -> parseTemplate ( $template [ 'start' ], true , $sc );
2013-05-06 16:33:56 -07:00
$ret = " " ;
2013-05-30 14:18:23 -07:00
$sc -> counter = 1 ;
2013-10-24 13:09:43 +03:00
$this -> activeMainFound = false ;
2013-10-24 11:33:37 +03:00
2012-12-14 16:32:39 +02:00
foreach ( $data as $_data )
2012-12-18 01:32:33 -08:00
{
2013-10-24 13:09:43 +03:00
$active = ( $this -> isActive ( $_data , $this -> activeMainFound )) ? " _active " : " " ;
2016-12-20 11:31:45 -08:00
$sc -> setDepth ( 0 );
2013-10-24 13:09:43 +03:00
$sc -> setVars ( $_data ); // isActive is allowed to alter data
2021-01-17 20:30:05 -08:00
$itemTmpl = ! empty ( $_data [ 'link_sub' ]) ? $template [ 'item_submenu' . $active ] : $template [ 'item' . $active ];
2016-12-20 11:31:45 -08:00
$ret .= e107 :: getParser () -> parseTemplate ( $itemTmpl , true , $sc );
2013-05-30 14:18:23 -07:00
$sc -> active = ( $active ) ? true : false ;
2013-10-24 13:09:43 +03:00
if ( $sc -> active )
{
$this -> activeMainFound = true ;
}
2013-05-30 14:18:23 -07:00
$sc -> counter ++ ;
2012-12-14 16:32:39 +02:00
}
2020-12-27 14:30:51 -08:00
$foot = e107 :: getParser () -> parseTemplate ( $template [ 'end' ], true , $sc );
2013-05-06 16:33:56 -07:00
return ( $ret != '' ) ? $head . $ret . $foot : '' ;
2012-12-14 16:32:39 +02:00
}
2012-12-14 17:22:04 -08:00
2012-12-14 16:32:39 +02:00
2012-12-11 15:08:29 -08:00
/**
2012-12-14 17:22:04 -08:00
* --------------- CODE - EFFICIENT APPROACH -------------------------
* FIXME syscache
2012-12-11 15:08:29 -08:00
*/
2017-11-01 12:36:32 -07:00
public function initData ( $cat = 1 , $opt = array ())
2012-12-11 15:08:29 -08:00
{
2012-12-15 04:42:13 -08:00
$sql = e107 :: getDb ( 'sqlSiteLinks' );
2017-11-01 12:36:32 -07:00
2020-12-21 17:46:32 -08:00
$ins = ( $cat > 0 ) ? " link_category = " . ( int ) $cat . " AND " : " " ;
2017-11-01 12:36:32 -07:00
2017-11-01 18:16:28 -07:00
$query = " SELECT * FROM #links WHERE " . $ins . " ((link_class >= 0 AND link_class IN ( " . USERCLASS_LIST . " )) OR (link_class < 0 AND ABS(link_class) NOT IN ( " . USERCLASS_LIST . " )) ) ORDER BY link_order,link_parent ASC " ;
2016-01-31 11:41:29 -08:00
2012-12-15 04:42:13 -08:00
$outArray = array ();
2016-01-31 11:41:29 -08:00
$data = $sql -> retrieve ( $query , true );
2017-11-01 13:01:01 -07:00
$ret = $this -> compile ( $data , $outArray );
2017-11-01 12:36:32 -07:00
if ( ! empty ( $opt [ 'flat' ]))
{
$newArr = array ();
2017-11-01 13:01:01 -07:00
foreach ( $ret as $row )
2017-11-01 12:36:32 -07:00
{
2021-01-24 17:00:02 -08:00
$ignore = ( ! empty ( $opt [ 'noempty' ]) && ( empty ( $row [ 'link_url' ]) || $row [ 'link_url' ] === '#' ));
2017-11-01 13:01:01 -07:00
$tmp = ( array ) $row [ 'link_sub' ];
2017-11-01 12:36:32 -07:00
2017-11-01 13:01:01 -07:00
unset ( $row [ 'link_sub' ]);
if ( $ignore !== true )
2017-11-01 12:36:32 -07:00
{
2017-11-01 13:01:01 -07:00
$newArr [] = $row ;
2017-11-01 12:36:32 -07:00
}
2017-11-01 13:01:01 -07:00
if ( ! empty ( $tmp ))
{
foreach ( $tmp as $val )
{
2021-01-25 09:14:45 -08:00
if ( ! is_array ( $val ))
{
continue ;
}
$tmp2 = $val [ 'link_sub' ];
2017-11-01 13:01:01 -07:00
unset ( $val [ 'link_sub' ]);
$newArr [] = $val ;
if ( ! empty ( $tmp2 ))
{
foreach ( $tmp2 as $k => $v )
{
$tmp3 = ( array ) $v [ 'link_sub' ];
unset ( $v [ 'link_sub' ]);
$newArr [] = $v ;
foreach ( $tmp3 as $sub )
{
$newArr [] = $sub ;
}
}
}
}
}
2017-11-01 12:36:32 -07:00
}
2017-11-01 13:01:01 -07:00
//e107::getDebug()->log($newArr);
2017-11-01 12:36:32 -07:00
return $newArr ;
}
2016-12-20 11:31:45 -08:00
return $ret ;
2012-12-14 17:22:04 -08:00
}
2012-12-14 16:32:39 +02:00
2012-12-03 02:21:51 -08:00
2012-12-14 17:22:04 -08:00
/**
* Compile Array Structure
*/
2012-12-17 04:21:16 -08:00
public function compile ( & $inArray , & $outArray , $pid = 0 )
2012-12-13 02:02:42 -08:00
{
2016-05-07 09:07:38 -07:00
if ( ! is_array ( $inArray ) || ! is_array ( $outArray )){ return null ; }
$frm = e107 :: getForm ();
2016-12-20 11:31:45 -08:00
foreach ( $inArray as $key => $val )
2012-12-14 17:22:04 -08:00
{
if ( $val [ 'link_parent' ] == $pid )
{
$val [ 'link_sub' ] = $this -> isDynamic ( $val );
2016-05-07 09:07:38 -07:00
if ( empty ( $val [ 'link_identifier' ]) && ! empty ( $val [ 'link_function' ]))
{
$val [ 'link_identifier' ] = $frm -> name2id ( $val [ 'link_function' ]);
}
2013-03-08 13:08:06 +02:00
// prevent loop of death
2020-12-21 17:46:32 -08:00
if ( $val [ 'link_id' ] != $pid )
{
$this -> compile ( $inArray , $val [ 'link_sub' ], $val [ 'link_id' ]);
}
2012-12-14 17:22:04 -08:00
$outArray [] = $val ;
}
}
return $outArray ;
}
2012-12-14 16:32:39 +02:00
2012-12-03 02:21:51 -08:00
2012-12-11 16:04:32 -08:00
/**
2012-12-14 17:22:04 -08:00
* Check for Dynamic Function
2013-10-28 21:30:24 -07:00
* @ example class : method ( $parm )
2012-12-11 16:04:32 -08:00
*/
2012-12-14 17:22:04 -08:00
protected function isDynamic ( $row )
{
2012-12-17 12:14:52 -08:00
if ( varset ( $row [ 'link_sub' ]))
{
return $row [ 'link_sub' ];
}
2017-03-15 16:49:55 -07:00
if ( ! empty ( $row [ 'link_function' ]))
2013-10-28 21:30:24 -07:00
{
$parm = false ;
2012-12-14 17:22:04 -08:00
list ( $path , $method ) = explode ( " :: " , $row [ 'link_function' ]);
2017-03-15 16:49:55 -07:00
if ( $path === 'theme' )
{
$text = e107 :: callMethod ( 'theme_shortcodes' , $method , $row ); // no parms as theme_shortcodes may be added as needed.
if ( ! empty ( $text ))
{
return '<div class="dropdown-menu">' . $text . '</div>' ; // @todo use template?
}
2018-08-24 16:04:12 -07:00
e107 :: getDebug () -> log ( " Theme shortcode ( " . $method . " ) could not be found for use in sitelink " );
return array ();
2017-03-15 16:49:55 -07:00
}
2013-10-28 21:30:24 -07:00
2021-12-02 11:35:12 -08:00
if ( ! file_exists ( e_PLUGIN . $path . " /e_sitelink.php " ) || ! e107 :: isInstalled ( $path ))
2018-08-24 16:04:12 -07:00
{
2020-12-18 19:55:12 -08:00
return array ();
2018-08-24 16:04:12 -07:00
}
2012-12-14 17:22:04 -08:00
if ( include_once ( e_PLUGIN . $path . " /e_sitelink.php " ))
{
2021-12-02 11:35:12 -08:00
if ( strpos ( $method , " ( " ))
{
list ( $method , $prm ) = explode ( " ( " , $method );
$parm = rtrim ( $prm , " ) " );
}
2013-02-26 03:43:52 -08:00
$class = $path . " _sitelink " ;
2016-12-20 11:31:45 -08:00
if ( $sublinkArray = e107 :: callMethod ( $class , $method , $parm , $row )) //TODO Cache it.
2012-12-14 17:22:04 -08:00
{
return $sublinkArray ;
}
}
}
2012-12-11 15:08:29 -08:00
2012-12-14 17:22:04 -08:00
return array ();
}
2012-12-03 01:40:47 -08:00
2012-12-14 17:22:04 -08:00
/**
2012-12-14 21:39:17 -08:00
* TODO Extensive Active Link Detection ;
2012-12-14 17:22:04 -08:00
*
*/
2019-04-30 14:01:05 -07:00
public function isActive ( & $data = array (), $removeOnly = false , $exactMatch = false )
2012-12-14 17:22:04 -08:00
{
2020-12-21 17:46:32 -08:00
if ( empty ( $data ))
{
return null ;
}
2017-02-28 09:55:35 -08:00
2013-10-24 13:09:43 +03:00
### experimental active match added to the URL (and removed after parsing)
### Example of main link: {e_BASE}some/url/#?match/string1^match/string2
### It would match http://your.domain/match/string/ or http://your.domain/match/string2?some=vars
### '#?' is the alternate active check trigger
if ( strpos ( $data [ 'link_url' ], '#?' ) !== false )
{
if ( $removeOnly )
{
2020-06-02 12:02:43 -07:00
$arr = explode ( '#?' , $data [ 'link_url' ], 2 );
$data [ 'link_url' ] = array_shift ( $arr );
2019-04-30 14:01:05 -07:00
return null ;
2013-10-24 13:09:43 +03:00
}
2013-10-25 21:46:01 +03:00
$_temp = explode ( '#?' , $data [ 'link_url' ], 2 );
$data [ 'link_url' ] = $_temp [ 0 ] ? $_temp [ 0 ] : '#' ;
$matches = explode ( '^' , $_temp [ 1 ]);
2013-10-24 13:09:43 +03:00
foreach ( $matches as $match )
{
if ( strpos ( e_REQUEST_URL , $match ) !== false )
{
return true ;
}
}
}
// No need of further checks
2020-12-21 17:46:32 -08:00
if ( $removeOnly )
{
return null ;
}
2013-10-24 13:09:43 +03:00
2013-02-14 15:37:42 +02:00
// already checked by compile() or external source
2020-12-21 17:46:32 -08:00
if ( isset ( $data [ 'link_active' ]))
{
return $data [ 'link_active' ];
}
2013-02-14 15:37:42 +02:00
$dbLink = e_HTTP . e107 :: getParser () -> replaceConstants ( $data [ 'link_url' ], TRUE , TRUE );
2016-03-10 21:53:59 -08:00
// $dbLink = e107::getParser()->replaceConstants($data['link_url'], TRUE, TRUE);
$dbLink = str_replace ( " // " , " / " , $dbLink ); // precaution for e_HTTP inclusion above.
2017-02-28 09:55:35 -08:00
if ( ! empty ( $data [ 'link_owner' ]) && ! empty ( $data [ 'link_sefurl' ]))
{
$dbLink = e107 :: url ( $data [ 'link_owner' ], $data [ 'link_sefurl' ]);
}
2020-12-18 19:55:12 -08:00
//if(E107_DBG_PATH)
//{
2016-12-01 14:00:37 -08:00
// e107::getDebug()->log("db=".$dbLink."<br />url=".e_REQUEST_URI."<br /><br />");
2020-12-18 19:55:12 -08:00
// }
2012-12-14 21:39:17 -08:00
2013-10-25 21:46:01 +03:00
if ( $exactMatch )
{
2020-12-21 17:46:32 -08:00
if ( e_REQUEST_URI == $dbLink )
{
return true ;
}
2013-10-25 21:46:01 +03:00
}
// XXX this one should go soon - no cotroll at all
elseif ( e_REQUEST_HTTP == $dbLink )
2012-12-14 21:39:17 -08:00
{
return true ;
}
2017-03-04 22:58:07 +01:00
elseif ( e_REQUEST_HTTP . " index.php " == $dbLink )
{
return true ;
}
2012-12-14 21:39:17 -08:00
2017-10-17 16:22:56 -07:00
if ( ! empty ( $data [ 'link_active' ])) // Can be used by e_sitelink.php
2013-11-06 17:31:02 -08:00
{
return true ;
}
2021-07-14 12:18:42 -07:00
// New e107 v.2.3.1 - using e107::nav('active', link url);
$manualOverride = e107 :: getRegistry ( 'core/e107/navigation/active' );
if ( ! empty ( $manualOverride ) && empty ( $data [ 'link_sub' ]))
{
2021-07-15 17:51:08 -07:00
if ( strpos ( $dbLink , $manualOverride ) !== false )
2021-07-14 12:18:42 -07:00
{
return true ;
}
}
2013-11-06 17:31:02 -08:00
2021-07-14 12:18:42 -07:00
// XXX Temporary Fix - @deprecated.
2013-05-17 16:43:14 -07:00
// Set the URL matching in the page itself. see: forum_viewforum.php and forum_viewtopic.php
2016-05-16 11:44:38 -07:00
if ( defined ( " NAVIGATION_ACTIVE " ) && empty ( $data [ 'link_sub' ]))
2013-05-17 16:43:14 -07:00
{
if ( strpos ( $data [ 'link_url' ], NAVIGATION_ACTIVE ) !== false )
{
return true ;
}
}
2012-12-14 17:22:04 -08:00
return false ;
}
2012-12-11 15:08:29 -08:00
}