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 ;
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' );
2011-06-17 01:13:05 +00:00
$ins = ( $cat > 0 ) ? " link_category = " . intval ( $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 ;
2009-11-20 05:01:51 +00:00
if ( vartrue ( $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.
2009-11-20 05:01:51 +00:00
if ( vartrue ( $sublinkArray ))
{
$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
2009-11-21 11:36:10 +00:00
function getLinkArray ()
{
return $this -> eLinkList ;
}
2010-03-16 15:11:07 +00:00
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 ();
2006-12-02 04:36:16 +00:00
$usecache = (( trim ( defset ( 'LINKSTART_HILITE' )) != " " || trim ( defset ( 'LINKCLASS_HILITE' )) != " " ) ? false : true );
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' ];
2017-10-05 13:14:50 -07: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 ])) ? true : false ;
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 )
{
2017-01-28 10:36:26 -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
}
2010-12-13 09:23:04 +00:00
/**
* Manage Sublink Rendering
2017-01-28 10:36:26 -08:00
* @ param string $main_linkid
* @ param string $aSubStyle
* @ param string $css_class
2010-12-13 09:23:04 +00:00
* @ param object $level [ optional ]
* @ return
*/
function subLink ( $main_linkid , $aSubStyle , $css_class = '' , $level = 0 )
{
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
$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 ;
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' ;
$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 ;
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
function makeLink ( $linkInfo , $submenu = FALSE , $style = '' , $css_class = false )
{
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' ] = " " ;
}
2015-04-03 13:07:28 -07:00
if ( vartrue ( $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
{
if ( substr ( $linkInfo [ 'link_name' ], 0 , 8 ) == " submenu. " )
{
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.
}
2017-02-28 09:55:35 -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.
2016-12-10 17:05: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 );
2012-07-21 07:30:28 +00:00
if ( $linkInfo [ 'link_button' ][ 0 ] == '{' )
{
$linkstart .= " <img src=' " . $tp -> replaceConstants ( $linkInfo [ 'link_button' ], 'abs' ) . " ' alt='' style='vertical-align:middle' /> " ;
}
else
{
$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
{
2010-10-30 14:50:30 +00:00
global $PLUGINS_DIRECTORY , $tp , $pref ;
if ( ! $enabled ){ return FALSE ; }
2006-12-02 04:36:16 +00:00
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
2010-10-30 14:50:30 +00: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
global $pref ;
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
if ( e_MENU == " debug " && getperms ( '0' ))
{
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. ----------------
2007-08-02 20:42:16 +00:00
if ( stristr ( $link , $PLUGINS_DIRECTORY ) !== FALSE && stristr ( $link , " custompages " ) === FALSE )
{
2006-12-02 04:36:16 +00:00
if ( $link_qry )
2010-10-30 14:50:30 +00:00
{ // plugin links with queries
2007-08-02 20:42:16 +00:00
return ( strpos ( e_SELF , $link_slf ) && e_QUERY == $link_qry ) ? TRUE : FALSE ;
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 );
2007-08-02 20:42:16 +00:00
if ( stristr ( dirname ( e_SELF ), dirname ( $link )) !== FALSE )
{
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
if ( substr ( basename ( $link ), 0 , 8 ) == " news.php " )
{
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
2010-10-30 14:50:30 +00:00
if ( $qry [ 0 ] == " item " )
{
return ( $qry [ 2 ] == $lnk [ 1 ]) ? TRUE : FALSE ;
}
2006-12-02 04:36:16 +00:00
2010-10-30 14:50:30 +00:00
if ( $qry [ 0 ] == " all " && $lnk [ 0 ] == " all " )
{
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
2010-10-30 14:50:30 +00:00
if ( $qry [ 1 ] == " list " && $lnk [ 0 ] == " list " && $lnk [ 1 ] == $qry [ 2 ])
{
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 />";
if (( $link_slf == e_HTTP . 'page.php' ) && ( e_PAGE == 'page.php' ))
{
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 ;
}
2009-12-18 20:49:56 +00:00
if (( $link_slf == e_SELF && ! link_qry ) || ( e_QUERY && empty ( $link ) == FALSE && strpos ( e_SELF . " ? " . e_QUERY , $link ) !== FALSE ) )
{
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 ();
}
}
function getIconArray ()
{
return $this -> iconArray ;
}
function setIconArray ()
{
if ( ! defined ( 'E_32_MAIN' ))
{
e107 :: getCoreTemplate ( 'admin_icons' );
}
$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();
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
if ( vartrue ( $pref [ 'admin_separate_plugins' ]))
{
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' ;
2017-01-14 16:10:47 -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.
function adminLinks ( $mode = false )
2012-12-03 01:40:47 -08:00
{
2013-02-26 18:57:33 -08:00
if ( $mode == 'plugin' )
{
return $this -> pluginLinks ( E_16_PLUGMANAGER , " array " ) ;
2013-04-29 12:56:50 -07:00
}
2017-02-03 20:18:45 -08:00
if ( $mode == 'plugin2' )
{
return $this -> pluginLinks ( E_16_PLUGMANAGER , " standard " ) ;
}
2013-04-29 12:56:50 -07:00
$this -> setIconArray ();
if ( $mode == 'sub' )
{
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 ),
12 => array ( e_ADMIN_ABS . 'links.php' , ADLAN_138 , ADLAN_139 , 'I' , 1 , E_16_LINKS , E_32_LINKS ),
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 ),
22 => array ( e_ADMIN_ABS . 'theme.php' , ADLAN_140 , ADLAN_141 , '1' , 5 , E_16_THEMEMANAGER , E_32_THEMEMANAGER ),
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
);
2013-02-26 18:57:33 -08:00
if ( $mode == 'legacy' )
{
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
if ( $mode == 'core' ) // Core links only.
{
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
}
2013-02-26 18:57:33 -08:00
private function restoreKeys ( $newarray ) // Put core button array in the same format as plugin button array.
{
$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 ;
}
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
// Function renders all the plugin links according to the required icon size and layout style
// - common to the various admin layouts such as infopanel, classis etc.
2017-02-03 20:18:45 -08:00
/**
* @ deprecated
* @ param string $iconSize
* @ param string $linkStyle
* @ return array | string
*/
function pluginLinksOld ( $iconSize = E_16_PLUGMANAGER , $linkStyle = 'adminb' )
2012-12-03 01:40:47 -08:00
{
2012-12-03 04:21:42 -08:00
2012-12-03 02:21:51 -08:00
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
2012-12-03 01:40:47 -08:00
$plug_id = array ();
$plugin_array = array ();
e107 :: getDb () -> db_Select ( " plugin " , " * " , " plugin_installflag = 1 " ); // Grab plugin IDs.
while ( $row = e107 :: getDb () -> db_Fetch ())
{
$pth = $row [ 'plugin_path' ];
$plug_id [ $pth ] = $row [ 'plugin_id' ];
}
$pref = e107 :: getConfig ( 'core' ) -> getPref ();
2012-12-03 04:21:42 -08:00
$text = $this -> renderAdminButton ( e_ADMIN . " plugin.php " , ADLAN_98 , ADLAN_99 , " Z " , $iconSize , $linkStyle );
2012-12-03 01:40:47 -08:00
$plugs = e107 :: getObject ( 'e107plugin' );
2017-02-03 20:18:45 -08:00
2015-02-12 13:09:56 -08:00
2017-02-03 20:18:45 -08:00
if ( ! empty ( $pref [ 'plug_installed' ]))
2012-12-03 01:40:47 -08:00
{
2012-12-16 14:28:30 -08:00
foreach ( $pref [ 'plug_installed' ] as $plug => $vers )
2012-12-03 01:40:47 -08:00
{
2017-02-03 20:18:45 -08:00
2012-12-16 14:28:30 -08:00
$plugs -> parse_plugin ( $plug );
2012-12-03 01:40:47 -08:00
2012-12-16 14:28:30 -08:00
$plugin_path = $plug ;
$name = $plugs -> plug_vars [ '@attributes' ][ 'name' ];
2013-02-25 17:15:46 -08:00
/*
echo " <h1> " . $name . " ( $plug )</h1> " ;
print_a ( $plugs -> plug_vars );
*/
2012-12-16 14:28:30 -08:00
if ( ! varset ( $plugs -> plug_vars [ 'adminLinks' ][ 'link' ]))
2012-12-03 01:40:47 -08:00
{
2012-12-16 14:28:30 -08:00
continue ;
2012-12-03 01:40:47 -08:00
}
2012-12-16 14:28:30 -08:00
foreach ( $plugs -> plug_vars [ 'adminLinks' ][ 'link' ] as $tag )
{
if ( varset ( $tag [ '@attributes' ][ 'primary' ]) != 'true' )
{
continue ;
}
2015-08-24 17:39:28 -07:00
if ( ! empty ( $pref [ 'lan_global_list' ]) && ! in_array ( $plugin_path , $pref [ 'lan_global_list' ]))
2015-02-12 13:09:56 -08:00
{
e107 :: loadLanFiles ( $plugin_path , 'admin' );
}
2012-12-16 14:28:30 -08:00
$att = $tag [ '@attributes' ];
$eplug_name = $tp -> toHTML ( $name , FALSE , " defs, emotes_off " );
$eplug_conffile = $att [ 'url' ];
2015-04-06 17:28:08 -07:00
$eplug_icon_small = ( ! empty ( $att [ 'iconSmall' ])) ? $plugin_path . '/' . $att [ 'iconSmall' ] : '' ;
$eplug_icon = ( ! empty ( $att [ 'icon' ])) ? $plugin_path . '/' . $att [ 'icon' ] : '' ;
2012-12-16 14:28:30 -08:00
$eplug_caption = str_replace ( " ' " , '' , $tp -> toHTML ( $att [ 'description' ], FALSE , 'defs, emotes_off' ));
if ( varset ( $eplug_conffile ))
{
$eplug_name = $tp -> toHTML ( $eplug_name , FALSE , " defs, emotes_off " );
2014-03-13 00:21:34 +01:00
$plugin_icon = $eplug_icon_small ? " <img class='icon S16' src=' " . e_PLUGIN_ABS . $eplug_icon_small . " ' alt='' /> " : E_16_PLUGIN ;
$plugin_icon_32 = $eplug_icon ? " <img class='icon S32' src=' " . e_PLUGIN_ABS . $eplug_icon . " ' alt='' /> " : E_32_PLUGIN ;
2013-02-25 17:15:46 -08:00
$plugin_array [ 'p-' . $plugin_path ] = array (
2013-02-26 18:57:33 -08:00
'key' => 'p-' . $plugin_path ,
2013-02-25 17:15:46 -08:00
'link' => e_PLUGIN . $plugin_path . " / " . $eplug_conffile ,
2017-02-03 20:18:45 -08:00
'title' => $eplug_name ,
'caption' => $eplug_caption ,
2013-02-25 17:15:46 -08:00
'perms' => " P " . varset ( $plug_id [ $plugin_path ]),
'icon' => $plugin_icon ,
'icon_32' => $plugin_icon_32 ,
'cat' => $this -> plugCatToCoreCat ( $plugs -> plug_vars [ 'category' ])
);
2012-12-16 14:28:30 -08:00
}
}
}
}
2012-12-03 01:40:47 -08:00
// print_a($plugs->plug_vars['adminLinks']['link']);
/* echo " hello there " ;
$xml = e107 :: getXml ();
$xml -> filter = array ( '@attributes' => FALSE , 'description' => FALSE , 'administration' => FALSE ); // .. and they're all going to need the same filter
if ( $sql -> db_Select ( " plugin " , " * " , " plugin_installflag=1 " ))
{
while ( $row = $sql -> db_Fetch ())
{
extract ( $row ); // plugin_id int(10) unsigned NOT NULL auto_increment,
// plugin_name varchar(100) NOT NULL default '',
// plugin_version varchar(10) NOT NULL default '',
// plugin_path varchar(100) NOT NULL default '',
// plugin_installflag tinyint(1) unsigned NOT NULL default '0',
// plugin_addons text NOT NULL,
if ( is_readable ( e_PLUGIN . $plugin_path . " /plugin.xml " ))
{
$readFile = $xml -> loadXMLfile ( e_PLUGIN . $plugin_path . '/plugin.xml' , true , true );
if ( $readFile === FALSE )
{
echo 'Error in file: ' . e_PLUGIN . $plugin_path . '/plugin.xml' . '<br />' ;
}
else
{
loadLanFiles ( $plugin_path , 'admin' );
$eplug_name = $tp -> toHTML ( $readFile [ '@attributes' ][ 'name' ], FALSE , " defs, emotes_off " );
$eplug_conffile = $readFile [ 'administration' ][ 'configFile' ];
$eplug_icon_small = $plugin_path . '/' . $readFile [ 'administration' ][ 'iconSmall' ];
$eplug_icon = $plugin_path . '/' . $readFile [ 'administration' ][ 'icon' ];
$eplug_caption = str_replace ( " ' " , '' , $tp -> toHTML ( $readFile [ 'description' ], FALSE , 'defs, emotes_off' ));
}
}
elseif ( is_readable ( e_PLUGIN . $plugin_path . " /plugin.php " ))
{
include ( e_PLUGIN . $plugin_path . " /plugin.php " );
}
if ( varset ( $eplug_conffile ))
{
$eplug_name = $tp -> toHTML ( $eplug_name , FALSE , " defs, emotes_off " );
$plugin_icon = $eplug_icon_small ? " <img class='icon S16' src=' " . e_PLUGIN . $eplug_icon_small . " ' alt='' /> " : E_16_PLUGIN ;
$plugin_icon_32 = $eplug_icon ? " <img class='icon S32' src=' " . e_PLUGIN . $eplug_icon . " ' alt='' /> " : E_32_PLUGIN ;
$plugin_array [ 'p-' . $plugin_path ] = array ( 'link' => e_PLUGIN . $plugin_path . " / " . $eplug_conffile , 'title' => $eplug_name , 'caption' => $eplug_caption , 'perms' => " P " . $plugin_id , 'icon' => $plugin_icon , 'icon_32' => $plugin_icon_32 );
}
unset ( $eplug_conffile , $eplug_name , $eplug_caption , $eplug_icon_small );
}
}
else
{
$plugin_array = array ();
}
*/
ksort ( $plugin_array , SORT_STRING ); // To FIX, without changing the current key format, sort by 'title'
2012-12-03 04:52:23 -08:00
if ( $linkStyle == " array " || $iconSize == 'assoc' )
2012-12-03 01:40:47 -08:00
{
return $plugin_array ;
}
foreach ( $plugin_array as $plug_key => $plug_value )
{
$the_icon = ( $iconSize == E_16_PLUGMANAGER ) ? $plug_value [ 'icon' ] : $plug_value [ 'icon_32' ];
2012-12-03 04:52:23 -08:00
$text .= $this -> renderAdminButton ( $plug_value [ 'link' ], $plug_value [ 'title' ], $plug_value [ 'caption' ], $plug_value [ 'perms' ], $the_icon , $linkStyle );
2012-12-03 01:40:47 -08:00
}
return $text ;
}
/**
* 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 )
{
global $E_ADMIN_MENU ; //TODO remove me?
2013-07-12 07:13:10 -07:00
$tp = e107 :: getParser ();
2012-12-03 01:40:47 -08:00
if ( ! $tmpl )
$tmpl = $E_ADMIN_MENU ;
/*
* Search for id
*/
$temp = explode ( '--id--' , $title , 2 );
$title = $temp [ 0 ];
$id = str_replace ( array ( ' ' , '_' ), '-' , varset ( $temp [ 1 ]));
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' ;
}
else
{
$text = $tmpl [ 'start' ];
}
//FIXME - e_parse::array2sc()
$search = array ();
$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' ;
$search [ 11 ] = '/\{LINK_DATA\}/si' ;
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' ]))
{
$text .= " <li class='nav-header'> " . $e107_vars [ $act ][ 'header' ] . " </li> " ; //TODO add to Template.
continue ;
}
if ( isset ( $e107_vars [ $act ][ 'divider' ]))
{
2013-03-07 05:02:04 -08:00
// $text .= "<li class='divider'></li>";
$text .= $tmpl [ 'divider' ];
2012-12-10 16:01:44 -08:00
continue ;
}
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 ;
}
// print_a($e107_vars[$act]);
$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) ???
2013-03-10 20:59:41 -07:00
if (( $active_page == ( string ) $act ) || ( str_replace ( " ? " , " " , e_PAGE . e_QUERY ) == str_replace ( " ? " , " " , $act )))
2012-12-03 01:40:47 -08:00
{
$temp = $tmpl [ 'button_active' . $kpost ];
}
else
{
$temp = $tmpl [ 'button' . $kpost ];
}
// $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
if ( $rid == 'adminhome' )
{
$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 ;
$temp = $tmpl [ $tmplateKey ];
// e107::getDebug()->log($tmplateKey);
2012-12-03 01:40:47 -08:00
}
2017-01-24 15:19:40 -08:00
2012-12-03 01:40:47 -08:00
$replace [ 0 ] = str_replace ( " " , " " , $e107_vars [ $act ][ 'text' ]);
// valid URLs
2015-02-14 23:34:15 -08:00
$replace [ 1 ] = str_replace ( array ( '&' , '&' ), array ( '&' , '&' ), vartrue ( $e107_vars [ $act ][ 'link' ], " # { $act } " ));
2012-12-03 01:40:47 -08:00
$replace [ 2 ] = '' ;
2015-02-14 23:34:15 -08:00
if ( vartrue ( $e107_vars [ $act ][ 'include' ]))
2012-12-03 01:40:47 -08:00
{
$replace [ 2 ] = $e107_vars [ $act ][ 'include' ];
//$replace[2] = $js ? " onclick=\"showhideit('".$act."');\"" : " onclick=\"document.location='".$e107_vars[$act]['link']."'; disabled=true;\"";
}
$replace [ 3 ] = $title ;
$replace [ 4 ] = '' ;
$replace [ 5 ] = $id ? " id='eplug-nav- { $rid } ' " : '' ;
$replace [ 6 ] = $rid ;
$replace [ 7 ] = varset ( $e107_vars [ $act ][ 'link_class' ]);
$replace [ 8 ] = '' ;
2013-07-12 07:13:10 -07:00
if ( vartrue ( $e107_vars [ $act ][ 'image_src' ]) && strstr ( $e107_vars [ $act ][ 'image_src' ], '.glyph' ))
{
2014-01-17 06:49:55 -08:00
$replace [ 9 ] = $tp -> toGlyph ( $e107_vars [ $act ][ 'image_src' ], array ( 'space' => ' ' ));
2013-07-12 07:13:10 -07:00
}
else
{
$replace [ 9 ] = varset ( $e107_vars [ $act ][ 'image' ]);
}
2015-07-11 14:07:04 -07:00
2017-12-10 11:40:41 +01:00
$replace [ 10 ] = ( isset ( $e107_vars [ $act ][ 'sub' ]) && count ( $e107_vars [ $act ][ 'sub' ]) > 20 ) ? '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 . '"' ;
}
2017-11-19 07:29:10 -08:00
$replace [ 11 ] = implode ( " " , $dataTmp ); // $e107_vars[$act]['link_data']
2015-07-11 14:07:04 -07:00
}
2017-11-19 07:29:10 -08:00
2012-12-03 01:40:47 -08:00
if ( $rid == 'logout' || $rid == 'home' || $rid == 'language' )
{
$START_SUB = $tmpl [ 'start_other_sub' ];
}
else
{
$START_SUB = $tmpl [ 'start_sub' ];
}
2017-12-01 17:00:02 -08:00
if ( ! empty ( $e107_vars [ $act ][ 'sub' ]))
2012-12-03 01:40:47 -08:00
{
$replace [ 6 ] = $id ? " id='eplug-nav- { $rid } -sub' " : '' ;
$replace [ 7 ] = ' ' . varset ( $e107_vars [ $act ][ 'link_class' ], 'e-expandit' );
$replace [ 8 ] = ' ' . varset ( $e107_vars [ $act ][ 'sub_class' ], 'e-hideme e-expandme' );
$replace [ 4 ] = preg_replace ( $search , $replace , $START_SUB );
2012-12-03 18:41:25 -08:00
$replace [ 4 ] .= $this -> admin ( false , $active_page , $e107_vars [ $act ][ 'sub' ], $tmpl , true , ( isset ( $e107_vars [ $act ][ 'sort' ]) ? $e107_vars [ $act ][ 'sort' ] : $sortlist ));
2012-12-03 01:40:47 -08:00
$replace [ 4 ] .= $tmpl [ 'end_sub' ];
}
$text .= preg_replace ( $search , $replace , $temp );
// echo "<br />".$title." act=".$act;
//print_a($e107_vars[$act]);
}
$text .= ( ! $sub_link ) ? $tmpl [ 'end' ] : '' ;
if ( $sub_link || empty ( $title ))
{
return $text ;
}
$ns = e107 :: getRender ();
2017-02-05 15:49:03 -08:00
$ns -> setUniqueId ( $id );
$ns -> tablerender ( $title , $text );
2012-12-03 01:40:47 -08:00
return '' ;
}
2012-12-03 02:21:51 -08:00
// Previously admin.php -> render_links();
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 );
if ( $mode == 'adminb' )
{
$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
{
if ( $mode != " div " && $mode != 'div-icon-only' )
{
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' :
2015-07-13 19:09:30 -07:00
$text .= " <div class='core-mainpanel-block '><a data-toggle='tooltip' class='core-mainpanel-link-icon btn btn-default 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' :
2015-07-13 19:09:30 -07:00
$text .= " <div class='core-mainpanel-block e-tip' title=' { $description } '><a class='core-mainpanel-link-icon btn btn-default e-tip' href=' " . $link . " ' > " . $icon . " </a></div> " ;
2012-12-03 02:21:51 -08:00
break ;
default :
break ;
}
$td ++ ;
}
}
2012-12-03 18:41:25 -08:00
else
{
// echo "no Perms";
}
2012-12-03 02:21:51 -08:00
return $text ;
}
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 ;
}
}
public function cacheBase ()
{
return 'nomd5_sitelinks_' ;
}
2012-12-14 17:22:04 -08:00
/**
* TODO Cache
*/
public function render ( $data , $template , $useCache = true )
2012-12-14 16:32:39 +02:00
{
if ( empty ( $data ) || empty ( $template ) || ! is_array ( $template )) return '' ;
$sc = e107 :: getScBatch ( 'navigation' );
$sc -> template = $template ;
2014-01-04 06:02:24 -08:00
$head = e107 :: getParser () -> parseTemplate ( $template [ 'start' ], true );
$foot = e107 :: getParser () -> parseTemplate ( $template [ 'end' ], true );
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
2012-12-14 17:22:04 -08:00
$itemTmpl = count ( $_data [ 'link_sub' ]) > 0 ? $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
}
2013-10-24 13:09:43 +03:00
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
$ins = ( $cat > 0 ) ? " link_category = " . intval ( $cat ) . " AND " : " " ;
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
{
2017-11-01 13:01:01 -07:00
$ignore = ( ! empty ( $opt [ 'noempty' ]) && ( empty ( $row [ 'link_url' ]) || $row [ 'link_url' ] === '#' )) ? true : false ;
$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 )
{
$tmp2 = ( array ) $val [ 'link_sub' ];
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
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?
}
}
2013-10-28 21:30:24 -07:00
if ( strpos ( $method , " ( " ))
{
list ( $method , $prm ) = explode ( " ( " , $method );
$parm = rtrim ( $prm , " ) " );
}
2017-03-15 16:49:55 -07:00
2012-12-14 17:22:04 -08:00
if ( include_once ( e_PLUGIN . $path . " /e_sitelink.php " ))
{
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
*
*/
2013-10-25 21:46:01 +03:00
public function isActive ( & $data = '' , $removeOnly = false , $exactMatch = false )
2012-12-14 17:22:04 -08:00
{
2013-10-24 13:09:43 +03:00
if ( empty ( $data )) return ;
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 )
{
$data [ 'link_url' ] = array_shift ( explode ( '#?' , $data [ 'link_url' ], 2 ));
return ;
}
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
if ( $removeOnly ) return ;
2013-02-14 15:37:42 +02:00
// already checked by compile() or external source
if ( isset ( $data [ 'link_active' ])) return $data [ 'link_active' ];
$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' ]);
}
2012-12-14 21:39:17 -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 />");
2012-12-14 21:39:17 -08:00
}
2013-10-25 21:46:01 +03:00
if ( $exactMatch )
{
if ( e_REQUEST_URI == $dbLink ) return true ;
}
// 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 ;
}
2013-05-17 16:43:14 -07:00
// XXX Temporary Fix - TBD.
// 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
}
2012-12-14 17:22:04 -08:00
2013-05-30 14:18:23 -07:00
/**
* Navigation Shortcodes
* @ todo SEF
*/
2012-12-11 15:08:29 -08:00
class navigation_shortcodes extends e_shortcode
{
2013-05-30 14:18:23 -07:00
public $template ;
public $counter ;
public $active ;
2016-12-20 11:31:45 -08:00
public $depth = 0 ;
2013-05-30 14:18:23 -07:00
2012-12-11 15:08:29 -08:00
2013-05-30 14:18:23 -07:00
/**
*
* @ return string 'active' on the active link .
* @ example { LINK_ACTIVE }
*/
function sc_link_active ( $parm = '' )
{
if ( $this -> active == true )
{
return 'active' ;
}
// check if it's the first link.. (eg. anchor mode) and nothing activated.
return ( $this -> counter == 1 ) ? 'active' : '' ;
}
/**
* Return the primary_id number for the current link
* @ return integer
*/
2013-03-05 19:25:59 +02:00
function sc_link_id ( $parm = '' )
{
return intval ( $this -> var [ 'link_id' ]);
}
2013-05-30 14:18:23 -07:00
2016-12-20 11:31:45 -08:00
function sc_link_depth ( $parm = '' )
{
2017-04-19 16:35:10 -07:00
return isset ( $this -> var [ 'link_depth' ]) ? intval ( $this -> var [ 'link_depth' ]) : $this -> depth ;
2016-12-20 11:31:45 -08:00
}
function setDepth ( $val )
{
$this -> depth = intval ( $val );
}
2013-05-30 14:18:23 -07:00
/**
* Return the name of the current link
* @ return string
* @ example { LINK_NAME }
*/
2012-12-11 15:08:29 -08:00
function sc_link_name ( $parm = '' )
{
2017-10-17 16:22:56 -07:00
if ( empty ( $this -> var [ 'link_name' ]))
2013-05-06 15:06:18 -07:00
{
2017-10-17 16:22:56 -07:00
return null ;
2013-05-06 15:06:18 -07:00
}
if ( substr ( $this -> var [ 'link_name' ], 0 , 8 ) == 'submenu.' ) // BC Fix.
{
list ( $tmp , $tmp2 , $link ) = explode ( '.' , $this -> var [ 'link_name' ], 3 );
}
else
{
$link = $this -> var [ 'link_name' ];
}
return e107 :: getParser () -> toHtml ( $link , false , 'defs' );
2012-12-11 15:08:29 -08:00
}
2013-05-30 14:18:23 -07:00
2012-12-18 01:32:33 -08:00
2013-05-30 14:18:23 -07:00
/**
* Return the parent of the current link
* @ return integer
*/
2012-12-18 01:32:33 -08:00
function sc_link_parent ( $parm = '' )
{
2017-12-10 11:27:20 +01:00
return intval ( $this -> var [ 'link_parent' ]);
2012-12-18 01:32:33 -08:00
}
2012-12-11 15:08:29 -08:00
2013-05-30 14:18:23 -07:00
2015-02-01 17:28:38 -08:00
function sc_link_identifier ( $parm = '' )
{
2017-12-10 11:27:20 +01:00
return isset ( $this -> var [ 'link_identifier' ]) ? $this -> var [ 'link_identifier' ] : '' ;
2015-02-01 17:28:38 -08:00
}
2013-05-30 14:18:23 -07:00
/**
* Return the URL of the current link
* @ return string
*/
2012-12-11 15:08:29 -08:00
function sc_link_url ( $parm = '' )
{
2013-10-31 18:09:00 -07:00
$tp = e107 :: getParser ();
2015-03-31 10:21:50 -07:00
if ( ! empty ( $this -> var [ 'link_owner' ]) && ! empty ( $this -> var [ 'link_sefurl' ]))
{
return e107 :: url ( $this -> var [ 'link_owner' ], $this -> var [ 'link_sefurl' ]);
}
2013-10-31 18:09:00 -07:00
2013-02-13 17:03:53 +02:00
if ( strpos ( $this -> var [ 'link_url' ], e_HTTP ) === 0 )
{
$url = " { e_BASE} " . substr ( $this -> var [ 'link_url' ], strlen ( e_HTTP ));
}
elseif ( $this -> var [ 'link_url' ][ 0 ] != " { " && strpos ( $this -> var [ 'link_url' ], " :// " ) === false )
2013-01-31 14:29:37 -08:00
{
$url = " { e_BASE} " . $this -> var [ 'link_url' ]; // Add e_BASE to links like: 'news.php' or 'contact.php'
}
else
{
$url = $this -> var [ 'link_url' ];
}
2013-10-31 18:35:04 -07:00
$url = $tp -> replaceConstants ( $url , 'full' , TRUE );
2013-10-31 18:27:35 -07:00
if ( strpos ( $url , " { " ) !== false )
2013-10-31 18:09:00 -07:00
{
2013-10-31 18:27:35 -07:00
$url = $tp -> parseTemplate ( $url , TRUE ); // BC Fix shortcode in URL support - dynamic urls for multilanguage.
2013-10-31 18:09:00 -07:00
}
2013-10-31 18:35:04 -07:00
return $url ;
2012-12-11 15:08:29 -08:00
}
2017-01-20 13:43:20 -08:00
2017-11-19 07:29:10 -08:00
/*
function sc_link_sub_oversized ( $parm = '' )
{
$count = count ( $this -> var [ 'link_sub' ]);
if ( ! empty ( $parm ) && $count > $parm )
{
return 'oversized' ;
}
return $count ;
}
*/
2017-01-20 13:43:20 -08:00
/**
* Returns only the anchor target in the URL if one is found .
* @ param null $parm
* @ return null | string
*/
function sc_link_target ( $parm = null )
{
if ( strpos ( $this -> var [ 'link_url' ], '#' ) !== false )
{
list ( $tmp , $segment ) = explode ( '#' , $this -> var [ 'link_url' ], 2 );
return '#' . $segment ;
}
return '#' ;
}
2013-10-24 11:33:37 +03:00
function sc_link_open ( $parm = '' )
{
$type = $this -> var [ 'link_open' ] ? ( int ) $this -> var [ 'link_open' ] : 0 ;
### 0 - same window, 1 - target blank, 4 - 600x400 popup, 5 - 800x600 popup
### TODO - JS popups (i.e. bootstrap)
switch ( $type )
{
case 1 :
return ' target="_blank"' ;
break ;
case 4 :
return " onclick= \" open_window(' " . $this -> var [ 'link_url' ] . " ',600,400); return false; \" " ;
break ;
case 5 :
return " onclick= \" open_window(' " . $this -> var [ 'link_url' ] . " ',800,600); return false; \" " ;
break ;
}
return '' ;
}
2013-05-30 14:18:23 -07:00
2013-07-12 07:50:25 -07:00
/**
* @ Deprecated - Use { LINK_ICON } instead .
*/
function sc_link_image ( $parm = '' )
{
e107 :: getMessage () -> addDebug ( " Using deprecated shortcode: { LINK_IMAGE} - use { LINK_ICON} instead. " );
return $this -> sc_link_icon ( $parm );
}
2012-12-03 01:40:47 -08:00
2013-05-30 14:18:23 -07:00
/**
2013-07-12 07:50:25 -07:00
* Return the link icon of the current link
2013-05-30 14:18:23 -07:00
* @ return string
*/
2013-07-12 07:50:25 -07:00
function sc_link_icon ( $parm = '' )
2012-12-11 15:08:29 -08:00
{
2013-07-12 07:13:10 -07:00
$tp = e107 :: getParser ();
2014-01-04 06:02:24 -08:00
2017-10-17 16:22:56 -07:00
if ( empty ( $this -> var [ 'link_button' ])) return '' ;
2013-07-12 07:13:10 -07:00
2014-01-04 06:02:24 -08:00
// if($icon = $tp->toGlyph($this->var['link_button']))
// {
// return $icon;
// }
// else
2013-07-12 07:13:10 -07:00
{
2014-01-04 06:02:24 -08:00
//$path = e107::getParser()->replaceConstants($this->var['link_button'], 'full', TRUE);
2017-04-19 14:26:45 -07:00
return $tp -> toIcon ( $this -> var [ 'link_button' ], array ( 'fw' => true , 'space' => ' ' , 'legacy' => " { e_IMAGE}icons/ " ));
2013-07-12 13:52:39 -07:00
// return "<img class='icon' src='".$path."' alt='' />";
2013-07-12 07:13:10 -07:00
}
2013-07-12 07:50:25 -07:00
2012-12-11 15:08:29 -08:00
}
2013-05-30 14:18:23 -07:00
2012-12-11 15:08:29 -08:00
2013-05-30 14:18:23 -07:00
/**
* Return the link description of the current link
* @ return string
*/
2012-12-11 15:08:29 -08:00
function sc_link_description ( $parm = '' )
{
2016-07-06 18:23:53 -07:00
$toolTipEnabled = e107 :: pref ( 'core' , 'linkpage_screentip' , false );
if ( $toolTipEnabled == false || empty ( $this -> var [ 'link_description' ]))
{
return null ;
}
2012-12-11 15:08:29 -08:00
return e107 :: getParser () -> toAttribute ( $this -> var [ 'link_description' ]);
}
2013-05-30 14:18:23 -07:00
/**
* Return the parsed sublinks of the current link
* @ return string
*/
2012-12-11 15:08:29 -08:00
function sc_link_sub ( $parm = '' )
{
2016-05-07 09:07:38 -07:00
if ( empty ( $this -> var [ 'link_sub' ]))
2012-12-11 15:08:29 -08:00
{
2016-05-07 09:07:38 -07:00
return false ;
}
if ( is_string ( $this -> var [ 'link_sub' ])) // html override option.
{
2016-05-20 15:04:51 -07:00
// e107::getDebug()->log($this->var);
2016-05-07 09:07:38 -07:00
return $this -> var [ 'link_sub' ];
}
2016-12-20 11:31:45 -08:00
$this -> depth ++ ;
2016-05-07 09:07:38 -07:00
// Assume it's an array.
2016-12-20 11:31:45 -08:00
$startTemplate = ! empty ( $this -> var [ 'link_sub' ][ 0 ][ 'link_sub' ]) && isset ( $this -> template [ 'submenu_lowerstart' ]) ? $this -> template [ 'submenu_lowerstart' ] : $this -> template [ 'submenu_start' ];
$endTemplate = ! empty ( $this -> var [ 'link_sub' ][ 0 ][ 'link_sub' ]) && isset ( $this -> template [ 'submenu_lowerstart' ]) ? $this -> template [ 'submenu_lowerend' ] : $this -> template [ 'submenu_end' ];
$text = e107 :: getParser () -> parseTemplate ( str_replace ( '{LINK_SUB}' , '' , $startTemplate ), true , $this );
2016-05-07 09:07:38 -07:00
2012-12-11 15:08:29 -08:00
foreach ( $this -> var [ 'link_sub' ] as $val )
{
2013-10-25 21:46:01 +03:00
$active = ( e107 :: getNav () -> isActive ( $val , $this -> activeSubFound , true )) ? " _active " : " " ;
2013-10-24 13:09:43 +03:00
$this -> setVars ( $val ); // isActive is allowed to alter data
2017-10-17 16:22:56 -07:00
$tmpl = ! empty ( $val [ 'link_sub' ]) ? varset ( $this -> template [ 'submenu_loweritem' . $active ]) : varset ( $this -> template [ 'submenu_item' . $active ]);
2013-10-24 13:09:43 +03:00
$text .= e107 :: getParser () -> parseTemplate ( $tmpl , TRUE , $this );
if ( $active ) $this -> activeSubFound = true ;
2012-12-11 15:08:29 -08:00
}
2016-12-20 11:31:45 -08:00
$text .= e107 :: getParser () -> parseTemplate ( str_replace ( '{LINK_SUB}' , '' , $endTemplate ), true , $this );
2012-12-11 15:08:29 -08:00
return $text ;
}
2013-05-29 01:22:11 -07:00
2013-05-30 14:18:23 -07:00
/**
* Return a generated anchor for the current link .
* @ param unused
* @ return string - a generated anchor for the current link .
* @ example { LINK_ANCHOR }
*/
2013-05-29 01:22:11 -07:00
function sc_link_anchor ( $parm = '' )
{
return $this -> var [ 'link_name' ] ? '#' . e107 :: getForm () -> name2id ( $this -> var [ 'link_name' ]) : '' ;
}
2006-12-02 04:36:16 +00:00
}