2009-08-16 16:30:56 +00:00
< ? php
/*
2009-11-18 02:07:15 +00:00
* e107 website system
*
2016-12-20 20:26:00 +00:00
* Copyright ( C ) 2008 - 2016 e107 Inc ( e107 . org )
2009-11-18 02:07:15 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
*/
2009-08-16 16:30:56 +00:00
if ( ! defined ( 'e107_INIT' )) { exit ; }
2016-12-20 20:26:00 +00:00
$frm = e107 :: getForm ();
2009-08-16 16:30:56 +00:00
class e_menuManager {
var $menu_areas = array ();
var $curLayout ;
var $menuId ;
var $menuNewLoc ;
var $dragDrop ;
var $menuActivateLoc ;
var $menuActivateIds ;
var $debug ;
var $menuMessage ;
2012-06-03 01:42:05 +00:00
var $style = 'default' ;
2009-08-16 16:30:56 +00:00
function __construct ( $dragdrop = FALSE )
{
2013-02-27 17:18:33 +01:00
global $HEADER , $FOOTER , $NEWSHEADER ;
$pref = e107 :: getPref ();
2016-12-20 10:58:43 +01:00
$tp = e107 :: getParser ();
2009-08-16 16:30:56 +00:00
$this -> debug = FALSE ;
$this -> dragDrop = $dragdrop ;
if ( $this -> dragDrop )
{
$this -> debug = TRUE ;
}
if ( $NEWSHEADER )
{
$HEADER .= $NEWSHEADER ;
}
if ( isset ( $_POST [ 'custom_select' ]))
{
$this -> curLayout = $_POST [ 'custom_select' ];
}
2009-08-19 14:39:57 +00:00
elseif ( isset ( $_GET [ 'lay' ]))
2009-08-16 16:30:56 +00:00
{
$this -> curLayout = $_GET [ 'lay' ];
}
else
{
2015-02-14 23:34:15 -08:00
$this -> curLayout = vartrue ( $_GET [ 'configure' ], $pref [ 'sitetheme_deflayout' ]);
2009-08-16 16:30:56 +00:00
}
2016-12-20 10:58:43 +01:00
$this -> curLayout = $tp -> filter ( $this -> curLayout );
2009-08-19 14:39:57 +00:00
$this -> dbLayout = ( $this -> curLayout != $pref [ 'sitetheme_deflayout' ]) ? $this -> curLayout : " " ; //menu_layout is left blank when it's default.
2009-08-16 16:30:56 +00:00
2012-12-08 15:52:40 +01:00
if ( isset ( $_POST [ 'menu_id' ]) || vartrue ( $_GET [ 'id' ]))
2009-08-16 16:30:56 +00:00
{
2012-05-04 17:56:21 +00:00
$this -> menuId = ( isset ( $_POST [ 'menu_id' ])) ? intval ( $_POST [ 'menu_id' ]) : intval ( $_GET [ 'id' ]);
2009-08-16 16:30:56 +00:00
}
2012-05-04 17:56:21 +00:00
if ( /*$menu_act == "sv" || */ isset ( $_POST [ 'class_submit' ]))
2009-08-16 16:30:56 +00:00
{
$this -> menuSaveVisibility ();
2012-05-04 17:56:21 +00:00
}
elseif ( isset ( $_POST [ 'parms_submit' ]))
{
$this -> menuSaveParameters ();
2009-08-16 16:30:56 +00:00
}
2012-12-08 15:52:40 +01:00
if ( vartrue ( $_GET [ 'mode' ]) == " deac " )
2009-08-16 16:30:56 +00:00
{
$this -> menuDeactivate ();
}
if ( $_GET [ 'mode' ] == " conf " )
{
$this -> menuGoConfig ();
}
$this -> menuGrabLayout ();
$menu_array = $this -> parseheader ( $HEADER . $FOOTER , 'check' );
if ( $menu_array )
{
sort ( $menu_array , SORT_NUMERIC );
$menu_check = 'set' ;
foreach ( $menu_array as $menu_value )
{
if ( $menu_value != $menu_check )
{
$this -> menu_areas [] = $menu_value ;
}
$menu_check = $menu_value ;
}
}
$this -> menuModify ();
2012-12-08 15:52:40 +01:00
if ( vartrue ( $_POST [ 'menuActivate' ]))
2009-08-16 16:30:56 +00:00
{
2016-12-20 10:58:43 +01:00
$menuActivate = $tp -> filter ( $_POST [ 'menuActivate' ]);
$this -> menuActivateLoc = key ( $menuActivate );
$this -> menuActivateIds = $tp -> filter ( $_POST [ 'menuselect' ]);
2009-08-16 16:30:56 +00:00
$this -> menuActivate ();
}
2012-12-08 15:52:40 +01:00
if ( vartrue ( $_POST [ 'menuSetCustomPages' ]))
2009-08-16 16:30:56 +00:00
{
2016-12-20 10:58:43 +01:00
$custompages = $tp -> filter ( $_POST [ 'custompages' ]);
$this -> menuSetCustomPages ( $custompages );
2009-08-16 16:30:56 +00:00
}
if ( isset ( $_POST [ 'menuUsePreset' ]) && $_POST [ 'curLayout' ])
{
$this -> menuSetPreset ();
}
$this -> menuSetConfigList (); // Update Active MenuConfig List.
}
// -------------------------------------------------------------------------
function menuRenderIframe ( $url = '' )
2013-02-27 17:18:33 +01:00
{
$ns = e107 :: getRender ();
$sql = e107 :: getDb ();
2009-08-16 16:30:56 +00:00
if ( ! $url )
{
2009-08-19 14:39:57 +00:00
$url = e_SELF . " ?configure= " . $this -> curLayout ;
2009-08-16 16:30:56 +00:00
}
2013-04-14 17:06:02 -07:00
// $cnt = $sql->select("menus", "*", "menu_location > 0 AND menu_layout = '$curLayout' ORDER BY menu_name "); // calculate height to remove vertical scroll-bar.
2009-08-16 16:30:56 +00:00
2013-04-14 17:06:02 -07:00
// $text = "<object class='well' type='text/html' id='menu_iframe' data='".$url."' width='100%' style='overflow:auto;width: 100%; height: ".(($cnt*90)+600)."px; border: 0px' ></object>";
$text = " <iframe class='well' id='menu_iframe' src=' " . $url . " ' width='100%' scrolling='no' style='width: 100%; height: 800px; border: 0px' ></iframe> " ;
2009-08-16 16:30:56 +00:00
return $text ;
}
function menuRenderMessage ()
{
// return $this->menuMessage;
2013-02-27 17:18:33 +01:00
$text = e107 :: getMessage () -> render ( 'menuUi' );
2009-08-16 16:30:56 +00:00
// $text .= "ID = ".$this->menuId;
return $text ;
2012-05-04 17:56:21 +00:00
2009-08-16 16:30:56 +00:00
}
function menuAddMessage ( $message , $type = E_MESSAGE_INFO , $session = false )
{
2013-02-27 17:18:33 +01:00
e107 :: getMessage () -> add ( array ( $message , 'menuUi' ), $type , $session );
2009-08-16 16:30:56 +00:00
}
// -------------------------------------------------------------------------
function menuGrabLayout ()
{
2013-12-25 02:00:46 -08:00
global $HEADER , $FOOTER , $CUSTOMHEADER , $CUSTOMFOOTER , $LAYOUT ;
if ( isset ( $LAYOUT ) && is_array ( $LAYOUT )) // $LAYOUT is a combined $HEADER,$FOOTER.
{
foreach ( $LAYOUT as $key => $template )
{
list ( $hd , $ft ) = explode ( " { ---} " , $template );
2013-12-30 06:23:12 -08:00
$HEADER [ $key ] = isset ( $LAYOUT [ '_header_' ]) ? $LAYOUT [ '_header_' ] . $hd : $hd ;
$FOOTER [ $key ] = isset ( $LAYOUT [ '_footer_' ]) ? $ft . $LAYOUT [ '_footer_' ] : $ft ;
2013-12-25 02:00:46 -08:00
}
unset ( $hd , $ft );
}
if (( $this -> curLayout == 'legacyCustom' || $this -> curLayout == 'legacyDefault' ) && ( isset ( $CUSTOMHEADER ) || isset ( $CUSTOMFOOTER )) ) // 0.6 themes.
{
if ( $this -> curLayout == 'legacyCustom' )
{
$HEADER = ( $CUSTOMHEADER ) ? $CUSTOMHEADER : $HEADER ;
$FOOTER = ( $CUSTOMFOOTER ) ? $CUSTOMFOOTER : $FOOTER ;
}
}
elseif ( $this -> curLayout && $this -> curLayout != " legacyCustom " && ( isset ( $CUSTOMHEADER [ $this -> curLayout ]) || isset ( $CUSTOMFOOTER [ $this -> curLayout ]))) // 0.7 themes
{
// echo " MODE 0.7 ".$this->curLayout;
$HEADER = ( $CUSTOMHEADER [ $this -> curLayout ]) ? $CUSTOMHEADER [ $this -> curLayout ] : $HEADER ;
$FOOTER = ( $CUSTOMFOOTER [ $this -> curLayout ]) ? $CUSTOMFOOTER [ $this -> curLayout ] : $FOOTER ;
}
elseif ( $this -> curLayout && is_array ( $HEADER ) && isset ( $HEADER [ $this -> curLayout ]) && isset ( $FOOTER [ $this -> curLayout ])) // 0.8 themes - we use only $HEADER and $FOOTER arrays.
{
// echo " MODE 0.8 ".$this->curLayout;
$HEADER = $HEADER [ $this -> curLayout ];
$FOOTER = $FOOTER [ $this -> curLayout ];
}
2009-08-16 16:30:56 +00:00
2013-12-25 02:00:46 -08:00
// Almost the same code as found in templates/header_default.php ---------
2009-08-16 16:30:56 +00:00
}
function menuGoConfig ()
{
if ( ! $_GET [ 'path' ] || ( $_GET [ 'mode' ] != " conf " ))
{
return ;
}
$file = urldecode ( $_GET [ 'path' ]) . " .php " ;
2016-12-02 13:51:32 -08:00
$file = e107 :: getParser () -> filter ( $file );
$newurl = e_PLUGIN_ABS . $file . " ?id= " . intval ( $_GET [ 'id' ]) . '&iframe=1' ;
2009-08-16 16:30:56 +00:00
/*
return " <object type='text/html' id='menu_iframe' data=' " . $newurl . " ' width='100%' style='overflow:auto;width: 100%; border: 0px' ></object> " ;
*/
header ( " Location: " . $newurl );
exit ;
// echo "URL = ".$newurl;
// $newurl = $PLUGINS_DIRECTORY.$location."/{$position}{$this->menuNewLoc}.php";
// $newurl = SITEURL.str_replace("//", "/", $newurl);
// echo "<script type='text/javascript'>alert($newurl); top.location.href = '{$newurl}'; </script> ";
// exit;
}
// -----------------------------------------------------------------------------
function menuModify ()
{
2013-02-27 17:18:33 +01:00
$sql = e107 :: getDb ();
2016-12-20 10:58:43 +01:00
$tp = e107 :: getParser ();
2009-08-16 16:30:56 +00:00
$menu_act = " " ;
2016-12-20 10:58:43 +01:00
if ( isset ( $_POST [ 'menuAct' ]))
2009-08-16 16:30:56 +00:00
{
2016-12-20 10:58:43 +01:00
foreach ( $_POST [ 'menuAct' ] as $k => $v )
{
if ( trim ( $v ))
2009-08-16 16:30:56 +00:00
{
2016-12-20 10:58:43 +01:00
$value = $tp -> filter ( $_POST [ 'menuAct' ][ $k ]);
$this -> menuId = intval ( $k );
list ( $menu_act , $location , $position , $this -> menuNewLoc ) = explode ( " . " , $value );
2009-08-16 16:30:56 +00:00
}
2016-12-20 10:58:43 +01:00
}
2009-08-16 16:30:56 +00:00
}
if ( $menu_act == " move " )
{
$this -> menuMove ();
}
2016-12-20 10:58:43 +01:00
if ( isset ( $location ) && isset ( $position ) && $menu_act == " bot " )
2009-08-16 16:30:56 +00:00
{
2013-03-03 01:24:54 -08:00
$menu_count = $sql -> count ( " menus " , " (*) " , " WHERE menu_location=' { $location } ' AND menu_layout = ' " . $this -> dbLayout . " ' " );
2009-08-16 16:30:56 +00:00
$sql -> db_Update ( " menus " , " menu_order= " . ( $menu_count + 1 ) . " WHERE menu_order=' { $position } ' AND menu_location=' { $location } ' AND menu_layout = ' $this->dbLayout ' " );
$sql -> db_Update ( " menus " , " menu_order=menu_order-1 WHERE menu_location=' { $location } ' AND menu_order > { $position } AND menu_layout = ' " . $this -> dbLayout . " ' " );
2014-10-23 11:07:18 -07:00
e107 :: getLog () -> add ( 'MENU_06' , $location . '[!br!]' . $position . '[!br!]' . $this -> menuId , E_LOG_INFORMATIVE , '' );
2009-08-16 16:30:56 +00:00
}
2016-12-20 10:58:43 +01:00
if ( isset ( $location ) && isset ( $position ) && $menu_act == " top " )
2009-08-16 16:30:56 +00:00
{
$sql -> db_Update ( " menus " , " menu_order=menu_order+1 WHERE menu_location=' { $location } ' AND menu_order < { $position } AND menu_layout = ' " . $this -> dbLayout . " ' " , $this -> debug );
$sql -> db_Update ( " menus " , " menu_order=1 WHERE menu_id=' { $this -> menuId } ' " );
2014-10-23 11:07:18 -07:00
e107 :: getLog () -> add ( 'MENU_05' , $location . '[!br!]' . $position . '[!br!]' . $this -> menuId , E_LOG_INFORMATIVE , '' );
2009-08-16 16:30:56 +00:00
}
2016-12-20 10:58:43 +01:00
if ( isset ( $location ) && isset ( $position ) && $menu_act == " dec " )
2009-08-16 16:30:56 +00:00
{
$sql -> db_Update ( " menus " , " menu_order=menu_order-1 WHERE menu_order=' " . ( $position + 1 ) . " ' AND menu_location=' { $location } ' AND menu_layout = ' " . $this -> dbLayout . " ' " , $this -> debug );
2014-06-14 19:38:57 +02:00
$sql -> db_Update ( " menus " , " menu_order=menu_order+1 WHERE menu_id=' { $this -> menuId } ' AND menu_location=' { $location } ' AND menu_layout = ' " . $this -> dbLayout . " ' " );
2014-10-23 11:07:18 -07:00
e107 :: getLog () -> add ( 'MENU_08' , $location . '[!br!]' . $position . '[!br!]' . $this -> menuId , E_LOG_INFORMATIVE , '' );
2009-08-16 16:30:56 +00:00
}
2016-12-20 10:58:43 +01:00
if ( isset ( $location ) && isset ( $position ) && $menu_act == " inc " )
2009-08-16 16:30:56 +00:00
{
$sql -> db_Update ( " menus " , " menu_order=menu_order+1 WHERE menu_order=' " . ( $position - 1 ) . " ' AND menu_location=' { $location } ' AND menu_layout = ' " . $this -> dbLayout . " ' " , $this -> debug );
$sql -> db_Update ( " menus " , " menu_order=menu_order-1 WHERE menu_id=' { $this -> menuId } ' AND menu_location=' { $location } ' AND menu_layout = ' " . $this -> dbLayout . " ' " );
2014-10-23 11:07:18 -07:00
e107 :: getLog () -> add ( 'MENU_07' , $location . '[!br!]' . $position . '[!br!]' . $this -> menuId , E_LOG_INFORMATIVE , '' );
2009-08-16 16:30:56 +00:00
}
2009-08-19 14:39:57 +00:00
if ( ! isset ( $_GET [ 'configure' ]))
2009-08-16 16:30:56 +00:00
{ // Scan plugin directories to see if menus to add
$this -> menuScanMenus ();
}
2016-12-20 10:58:43 +01:00
2009-08-16 16:30:56 +00:00
}
// ----------------------------------------------------------------------------
function menuSetPreset ()
{
2016-12-20 10:58:43 +01:00
global $location ;
2013-02-27 17:18:33 +01:00
$sql = e107 :: getDb ();
2016-12-20 10:58:43 +01:00
$tp = e107 :: getParser ();
2009-08-16 16:30:56 +00:00
2016-12-20 10:58:43 +01:00
if ( ! $menuAreas = $this -> getMenuPreset ())
2009-08-16 16:30:56 +00:00
{
2013-12-30 06:23:12 -08:00
e107 :: getMessage () -> addDebug ( " No Menu Preset Found " );
2016-12-20 10:58:43 +01:00
return false ;
2009-08-16 16:30:56 +00:00
}
2016-12-20 10:58:43 +01:00
$sql -> db_Update ( " menus " , " menu_location='0' WHERE menu_layout = ' " . $this -> dbLayout . " ' " ); // Clear All existing.
2009-08-16 16:30:56 +00:00
foreach ( $menuAreas as $val )
{
2016-12-20 10:58:43 +01:00
if ( $sql -> select ( " menus " , 'menu_name, menu_path' , " menu_name = ' " . $tp -> filter ( $val [ 'menu_name' ]) . " ' LIMIT 1 " ))
2009-08-16 16:30:56 +00:00
{
2016-12-20 10:58:43 +01:00
$row = $sql -> fetch ();
2009-08-16 16:30:56 +00:00
2016-12-20 10:58:43 +01:00
if ( ! $sql -> db_Update ( 'menus' , " menu_order=' " . ( int ) $val [ 'menu_order' ] . " ', menu_location = " . ( int ) $val [ 'menu_location' ] . " , menu_class= " . $val [ 'menu_class' ] . " WHERE menu_name=' " . $tp -> filter ( $val [ 'menu_name' ]) . " ' AND menu_layout = ' " . $this -> dbLayout . " ' LIMIT 1 " ))
2009-08-16 16:30:56 +00:00
{
2016-12-20 10:58:43 +01:00
$insert = array (
'menu_id' => 0 ,
'menu_name' => $tp -> filter ( $val [ 'menu_name' ]),
'menu_location' => ( int ) $val [ 'menu_location' ],
'menu_order' => ( int ) $val [ 'menu_order' ],
'menu_class' => $tp -> filter ( $val [ 'menu_class' ]),
'menu_pages' => '' ,
'menu_path' => $tp -> filter ( $row [ 'menu_path' ]),
'menu_layout' => $this -> dbLayout ,
'menu_parms' => '' ,
);
2009-08-16 16:30:56 +00:00
2016-12-20 10:58:43 +01:00
$sql -> insert ( " menus " , $insert );
e107 :: getLog () -> add ( 'MENU_01' , $tp -> filter ( $row [ 'menu_name' ]) . '[!br!]' . $location . '[!br!]' . varset ( $menu_count , 0 ) . '[!br!]' . $tp -> filter ( $row [ 'menu_path' ]), E_LOG_INFORMATIVE , '' );
2009-08-16 16:30:56 +00:00
}
2016-12-20 10:58:43 +01:00
}
2009-08-16 16:30:56 +00:00
}
return $menuAreas ;
}
// ----------------------------------------------------------------------------
function menuScanMenus ()
{
2013-02-27 17:18:33 +01:00
global $sql2 ;
$sql = e107 :: getDb ();
2009-08-16 16:30:56 +00:00
2016-12-20 10:58:43 +01:00
$efile = new e_file ;
$efile -> dirFilter = array ( '/' , 'CVS' , '.svn' , 'languages' );
$efile -> fileFilter [] = '^e_menu\.php$' ;
$fileList = $efile -> get_files ( e_PLUGIN , " _menu \ .php $ " , 'standard' , 2 );
2016-01-12 15:44:54 -08:00
2016-04-10 14:10:39 -07:00
// $this->menuAddMessage('Scanning for new menus', E_MESSAGE_DEBUG);
2016-12-20 10:58:43 +01:00
e107 :: getDebug () -> log ( " Scanning for new menus " , E107_DBG_BASIC );
2016-01-12 15:44:54 -08:00
2016-12-20 10:58:43 +01:00
$menuList = array (); // existing menus in table.
if ( $result = $sql -> retrieve ( 'menus' , 'menu_name' , null , true ))
{
foreach ( $result as $mn )
2014-06-26 18:08:10 -07:00
{
2016-12-20 10:58:43 +01:00
if ( $mn [ 'menu_name' ])
2014-06-26 18:08:10 -07:00
{
2016-12-20 10:58:43 +01:00
$menuList [] = $mn [ 'menu_name' ];
2014-06-26 18:08:10 -07:00
}
}
2016-12-20 10:58:43 +01:00
}
2015-04-03 13:09:32 -07:00
2016-12-20 10:58:43 +01:00
//v2.x Scan Custom Page Menus.
2015-04-03 13:09:32 -07:00
2016-12-20 10:58:43 +01:00
$pageMenus = $sql -> retrieve ( 'page' , 'page_id, menu_name, menu_title' , " menu_name !='' " , true );
foreach ( $pageMenus as $row )
{
if ( ! in_array ( $row [ 'menu_name' ], $menuList ))
2015-04-03 13:09:32 -07:00
{
2016-12-20 10:58:43 +01:00
$insert = array (
'menu_id' => 0 ,
'menu_name' => $row [ 'menu_name' ],
'menu_location' => 0 ,
'menu_order' => 0 ,
'menu_class' => 0 ,
'menu_pages' => '' ,
'menu_path' => $row [ 'page_id' ],
'menu_layout' => '' ,
'menu_parms' => ''
);
if ( $sql -> insert ( " menus " , $insert ))
2015-04-03 13:09:32 -07:00
{
2016-12-20 10:58:43 +01:00
$this -> menuAddMessage ( MENLAN_10 . " - " . $row [ 'menu_name' ], E_MESSAGE_DEBUG );
2015-04-03 13:09:32 -07:00
}
}
2016-12-20 10:58:43 +01:00
}
2015-04-03 13:09:32 -07:00
2016-12-20 10:58:43 +01:00
$menustr = varset ( $menustr );
$message = varset ( $message );
2015-04-03 13:09:32 -07:00
2016-12-20 10:58:43 +01:00
foreach ( $fileList as $file )
{
2015-04-03 13:09:32 -07:00
2016-12-20 10:58:43 +01:00
list ( $parent_dir ) = explode ( '/' , str_replace ( e_PLUGIN , " " , $file [ 'path' ]));
$file [ 'path' ] = str_replace ( e_PLUGIN , " " , $file [ 'path' ]);
$file [ 'fname' ] = str_replace ( " .php " , " " , $file [ 'fname' ]);
$valid_menu = false ;
2015-04-03 13:09:32 -07:00
2016-12-20 10:58:43 +01:00
$existing_menu = in_array ( $file [ 'fname' ], $menuList ); // $sql->count("menus", "(*)", "WHERE menu_name='{$file['fname']}'");
if ( file_exists ( e_PLUGIN . $parent_dir . '/plugin.xml' ) || file_exists ( e_PLUGIN . $parent_dir . '/plugin.php' ))
2009-08-16 16:30:56 +00:00
{
2016-12-20 10:58:43 +01:00
if ( e107 :: isInstalled ( $parent_dir ))
{ // Its a 'new style' plugin with a plugin.php file, or an even newer one with plugin.xml file - only include if plugin installed
$valid_menu = true ; // Whether new or existing, include in list
2009-08-16 16:30:56 +00:00
// echo "Include {$parent_dir}:{$file['fname']}<br />";
}
2016-12-20 10:58:43 +01:00
}
else // Just add the menu anyway
{
$valid_menu = true ;
2009-08-16 16:30:56 +00:00
// echo "Default Include {$parent_dir}:{$file['fname']}<br />";
2016-12-20 10:58:43 +01:00
}
if ( $valid_menu )
{
$menustr .= " & " . str_replace ( " .php " , " " , $file [ 'fname' ]);
if ( ! $existing_menu ) // New menu to add to list
2009-08-16 16:30:56 +00:00
{
2016-12-20 10:58:43 +01:00
$insert = array (
'menu_id' => 0 ,
'menu_name' => $file [ 'fname' ],
'menu_location' => 0 ,
'menu_order' => 0 ,
'menu_class' => 0 ,
'menu_pages' => '' ,
'menu_path' => $file [ 'path' ],
'menu_layout' => '' ,
'menu_parms' => ''
);
2009-08-17 14:47:10 +00:00
2016-12-20 10:58:43 +01:00
if ( $sql -> insert ( " menus " , $insert ))
{
// Could do admin logging here - but probably not needed
$message .= MENLAN_10 . " - " . $file [ 'fname' ] . " <br /> " ; //FIXME
}
else
{
$this -> menuAddMessage ( " Couldn't add menu: " . $file [ 'fname' ] . " to table " , E_MESSAGE_DEBUG );
2009-08-16 16:30:56 +00:00
}
}
}
2016-12-20 10:58:43 +01:00
}
2009-08-16 16:30:56 +00:00
2016-12-20 10:58:43 +01:00
//Reorder all menus into 1...x order
if ( ! is_object ( $sql2 ))
{
$sql2 = new db ;
} // Shouldn't be needed
if ( ! isset ( $sql3 ) || ! is_object ( $sql3 ))
{
$sql3 = new db ;
}
2013-05-13 00:32:11 -04:00
2016-12-20 10:58:43 +01:00
$location_count = $sql3 -> select ( " menus " , " menu_location " , " menu_location>0 GROUP BY menu_location " );
while ( $location_count )
{
if ( $sql -> select ( " menus " , " menu_id " , " menu_location= { $location_count } ORDER BY menu_order ASC " ))
2009-08-16 16:30:56 +00:00
{
2016-12-20 10:58:43 +01:00
$c = 1 ;
while ( $row = $sql -> fetch ())
2009-08-16 16:30:56 +00:00
{
2016-12-20 10:58:43 +01:00
$sql2 -> db_Update ( " menus " , " menu_order= { $c } WHERE menu_id= " . $row [ 'menu_id' ]);
$c ++ ;
2009-08-16 16:30:56 +00:00
}
}
2016-12-20 10:58:43 +01:00
$location_count -- ;
}
$sql -> select ( " menus " , " * " , " menu_path NOT REGEXP('[0-9]+') " );
while ( list ( $menu_id , $menu_name , $menu_location , $menu_order ) = $sql -> fetch ( 'num' ))
{
if ( stristr ( $menustr , $menu_name ) === false )
2009-08-16 16:30:56 +00:00
{
2016-12-20 10:58:43 +01:00
$sql2 -> db_Delete ( " menus " , " menu_name=' $menu_name ' " );
$message .= MENLAN_11 . " - " . $menu_name . " <br /> " ;
2009-08-16 16:30:56 +00:00
}
2016-12-20 10:58:43 +01:00
}
2009-08-16 16:30:56 +00:00
2016-12-20 10:58:43 +01:00
$this -> menuAddMessage ( vartrue ( $message ), E_MESSAGE_DEBUG );
2009-08-16 16:30:56 +00:00
}
// ---------------------------------------------------------------------------
function menuPresetPerms ( $val )
{
$link_class = strtolower ( trim ( $val ));
$menu_perm [ 'everyone' ] = e_UC_PUBLIC ;
$menu_perm [ 'guest' ] = e_UC_GUEST ;
$menu_perm [ 'member' ] = e_UC_MEMBER ;
$menu_perm [ 'mainadmin' ] = e_UC_MAINADMIN ;
$menu_perm [ 'admin' ] = e_UC_ADMIN ;
$menu_perm [ 'nobody' ] = e_UC_NOBODY ;
$link_class = ( $menu_perm [ $link_class ]) ? $menu_perm [ $link_class ] : e_UC_PUBLIC ;
return $link_class ;
}
2012-05-04 17:56:21 +00:00
/**
* This one will be greatly extended , allowing menus to offer UI and us
* settings per instance later ( $parm variable available for menus - same as shortcode ' s $parm )
*/
function menuInstanceParameters ()
{
2012-12-08 15:52:40 +01:00
if ( ! vartrue ( $_GET [ 'parmsId' ])) return ;
2012-05-04 17:56:21 +00:00
$id = intval ( $_GET [ 'parmsId' ]);
$frm = e107 :: getForm ();
$sql = e107 :: getDb ();
2013-03-02 21:07:42 -08:00
if ( ! $sql -> select ( " menus " , " * " , " menu_id= " . $id ))
2012-05-04 17:56:21 +00:00
{
$this -> menuAddMessage ( " Couldn't Load Menu " , E_MESSAGE_ERROR );
return ;
};
2013-03-02 21:07:42 -08:00
$row = $sql -> fetch ();
2016-01-12 15:44:54 -08:00
2012-05-04 17:56:21 +00:00
$text = " <div style='text-align:center;'>
2013-03-02 21:07:42 -08:00
< form id = 'e-save-form' method = 'post' action = '".e_SELF."?lay=".$this->curLayout."' >
2012-05-04 17:56:21 +00:00
< fieldset id = 'core-menus-parametersform' >
2016-01-12 15:44:54 -08:00
< legend > " .MENLAN_44. " " . $row['menu_name'] . " </ legend >
< table class = 'table ' >
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
" ;
if ( file_exists ( e_PLUGIN . $row [ 'menu_path' ] . " e_menu.php " )) // v2.x new e_menu.php
{
$plug = rtrim ( $row [ 'menu_path' ], '/' );
$obj = e107 :: getAddon ( $plug , 'e_menu' );
2016-02-08 13:54:44 -08:00
if ( ! is_object ( $obj ))
{
2016-12-23 08:03:28 -08:00
$text .= " <tr><td colspan='2' class='alert alert-danger'> " . e107 :: getParser () -> lanVars ( MENLAN_46 , $plug ) . " </td></tr> " ;
2016-02-08 13:54:44 -08:00
}
else
{
$menuName = substr ( $row [ 'menu_name' ], 0 , - 5 );
}
2016-12-20 10:58:43 +01:00
$menuName = varset ( $menuName );
2016-02-08 13:54:44 -08:00
$fields = e107 :: callMethod ( $obj , 'config' , $menuName );
2016-01-12 15:44:54 -08:00
if ( ! $form = e107 :: getAddon ( $plug , 'e_menu' , $plug . " _menu_form " ))
{
$form = $frm ;
}
$value = e107 :: unserialize ( $row [ 'menu_parms' ]);
2016-02-08 13:54:44 -08:00
if ( ! empty ( $fields ))
{
foreach ( $fields as $k => $v )
{
$text .= " <tr><td class='text-left'> " . $v [ 'title' ] . " </td> " ;
2016-04-14 16:37:10 -07:00
// $v['writeParms']['class'] = 'e-save';
2016-02-08 13:54:44 -08:00
$i = $k ;
if ( ! empty ( $v [ 'multilan' ]))
{
$i = $k . '[' . e_LANGUAGE . ']' ;
if ( isset ( $value [ $k ][ e_LANGUAGE ]))
{
$value [ $k ] = varset ( $value [ $k ][ e_LANGUAGE ], '' );
}
}
2016-04-14 16:37:10 -07:00
if ( ! empty ( $v [ 'help' ]))
{
$v [ 'writeParms' ][ 'title' ] = e107 :: getParser () -> toAttribute ( $v [ 'help' ]);
}
$text .= " <td class='text-left'> " . $form -> renderElement ( $i , $value [ $k ], $v );
$text .= " </td></tr> " ;
2016-02-08 13:54:44 -08:00
}
}
else
2016-01-12 15:44:54 -08:00
{
2016-12-20 20:26:00 +00:00
$text .= " <tr><td colspan='2' class='alert alert-danger'> " . MENLAN_47 . " : " . $row [ 'menu_path' ] . " e_menu.php</td></tr> " ;
2016-01-12 15:44:54 -08:00
}
}
else
{
$text .= " <tr>
< td >
" .MENLAN_45. " </ td >
< td >
" . $frm->text ('menu_parms', $row['menu_parms'] , 900, 'class=e-save&size=xxlarge'). "
</ td >
</ tr > " ;
}
$text .= " </table> " ;
2013-03-02 21:07:42 -08:00
/*
$text .= "
< div class = 'buttons-bar center' > " ;
$text .= $frm -> admin_button ( 'parms_submit' , LAN_SAVE , 'update' );
$text .= " <input type='hidden' name='menu_id' value=' " . $id . " ' />
</ div > " ;
*/
$text .= $frm -> hidden ( 'mode' , 'parms' );
$text .= $frm -> hidden ( 'menu_id' , $id );
$text .= "
2012-05-04 17:56:21 +00:00
</ fieldset >
</ form >
</ div > " ;
2013-03-02 21:07:42 -08:00
2012-05-04 17:56:21 +00:00
return $text ;
2013-04-14 18:41:53 -07:00
2012-05-04 17:56:21 +00:00
}
2009-08-16 16:30:56 +00:00
function menuVisibilityOptions ()
{
2012-12-08 15:52:40 +01:00
if ( ! vartrue ( $_GET [ 'vis' ])) return ;
2009-08-16 16:30:56 +00:00
2013-03-02 21:07:42 -08:00
$sql = e107 :: getDb ();
$frm = e107 :: getForm ();
2015-06-02 14:25:39 -07:00
$tp = e107 :: getParser ();
2013-03-02 21:07:42 -08:00
2009-08-16 16:30:56 +00:00
require_once ( e_HANDLER . " userclass_class.php " );
2013-03-02 21:07:42 -08:00
if ( ! $sql -> select ( " menus " , " * " , " menu_id= " . intval ( $_GET [ 'vis' ])))
2009-08-16 16:30:56 +00:00
{
2016-12-20 20:26:00 +00:00
$this -> menuAddMessage ( MENLAN_48 , E_MESSAGE_ERROR );
2009-08-16 16:30:56 +00:00
return ;
2013-03-02 21:07:42 -08:00
}
$row = $sql -> fetch ();
$listtype = substr ( $row [ 'menu_pages' ], 0 , 1 );
2009-08-16 16:30:56 +00:00
$menu_pages = substr ( $row [ 'menu_pages' ], 2 );
$menu_pages = str_replace ( " | " , " \n " , $menu_pages );
2013-03-02 21:07:42 -08:00
$text = " <div>
< form class = 'form-horizontal' id = 'e-save-form' method = 'post' action = '".e_SELF."?lay=".$this->curLayout."&iframe=1' >
< fieldset >
< legend > " . MENLAN_7. " " . $row['menu_name'] . " </ legend >
< table class = 'table adminform' >
< tr >
< td >
< input type = 'hidden' name = 'menuAct[{$row[' menu_id ']}]' value = 'sv.{$row[' menu_id ']}' />
2016-12-20 20:26:00 +00:00
" .LAN_VISIBLE_TO. " " .
2015-06-02 14:25:39 -07:00
$frm -> userclass ( 'menu_class' , $row [ 'menu_class' ], 'dropdown' , array ( 'options' => " public,member,guest,admin,main,classes,nobody " , 'class' => 'e-save' )) . "
2013-03-02 21:07:42 -08:00
</ td >
</ tr >
< tr >< td >< div class = 'radio' >
" ;
2009-08-16 16:30:56 +00:00
$checked = ( $listtype == 1 ) ? " checked='checked' " : " " ;
2013-03-02 21:07:42 -08:00
2016-12-20 10:58:43 +01:00
$text .= $frm -> radio ( 'listtype' , 1 , $checked , array ( 'label' => $tp -> toHTML ( MENLAN_26 , true ), 'class' => 'e-save' ));
2013-03-02 21:15:36 -08:00
$text .= " <br /> " ;
2013-03-02 21:07:42 -08:00
// $text .= "<input type='radio' class='e-save' {$checked} name='listtype' value='1' /> ".MENLAN_26."<br />";
2009-08-16 16:30:56 +00:00
$checked = ( $listtype == 2 ) ? " checked='checked' " : " " ;
2013-03-02 21:07:42 -08:00
2016-12-20 10:58:43 +01:00
$text .= $frm -> radio ( 'listtype' , 2 , $checked , array ( 'label' => $tp -> toHTML ( MENLAN_27 , true ), 'class' => 'e-save' ));
2013-03-02 21:07:42 -08:00
// $text .= "<input type='radio' class='e-save' {$checked} name='listtype' value='2' /> ".MENLAN_27."<br />";
$text .= " </div>
2013-03-02 21:15:36 -08:00
< div class = 'row' style = 'padding:10px' >
2013-03-02 21:07:42 -08:00
< div class = 'pull-left span3' >
2016-12-20 10:58:43 +01:00
< textarea name = 'pagelist' class = 'e-save span3 tbox' cols = '60' rows = '8' > " . $menu_pages . " </ textarea >
2013-03-02 21:07:42 -08:00
</ div >
2015-07-13 19:09:30 -07:00
< div class = ' span4 col-md-4' >< small > " .MENLAN_28. " </ small ></ div >
2013-03-02 21:07:42 -08:00
</ div ></ td ></ tr >
</ table > " ;
$text .= $frm -> hidden ( 'mode' , 'visibility' );
$text .= $frm -> hidden ( 'menu_id' , intval ( $_GET [ 'vis' ])); // "<input type='hidden' name='menu_id' value='".intval($_GET['vis'])."' />";
/*
$text .= "
2009-08-16 16:30:56 +00:00
< div class = 'buttons-bar center' > " ;
$text .= $frm -> admin_button ( 'class_submit' , MENLAN_6 , 'update' );
2013-03-02 21:07:42 -08:00
</ div > " ;
*/
$text .= "
2009-08-16 16:30:56 +00:00
</ fieldset >
</ form >
</ div > " ;
2013-03-02 21:07:42 -08:00
2009-08-16 16:30:56 +00:00
return $text ;
2013-03-02 21:07:42 -08:00
//$caption = MENLAN_7." ".$row['menu_name'];
//$ns->tablerender($caption, $text);
//echo $text;
2009-08-16 16:30:56 +00:00
}
// -----------------------------------------------------------------------------
function menuActivate () // Activate Multiple Menus.
{
2013-02-27 17:18:33 +01:00
$sql = e107 :: getDb ();
2009-08-16 16:30:56 +00:00
$location = $this -> menuActivateLoc ;
2013-03-03 01:24:54 -08:00
$menu_count = $sql -> count ( " menus " , " (*) " , " WHERE menu_location= " . $location . " AND menu_layout = ' " . $this -> dbLayout . " ' " );
2013-05-13 00:32:11 -04:00
$menu_count ++ ; // Need to add 1 to create NEW order number.
2009-08-19 14:39:57 +00:00
2009-08-16 16:30:56 +00:00
foreach ( $this -> menuActivateIds as $sel_mens )
{
//Get info from menu being activated
2013-03-02 21:07:42 -08:00
if ( $sql -> select ( " menus " , 'menu_name, menu_path' , " menu_id = " . intval ( $sel_mens ) . " " ))
2009-08-16 16:30:56 +00:00
{
2013-03-02 21:07:42 -08:00
$row = $sql -> fetch ();
2009-08-16 16:30:56 +00:00
//If menu is not already activated in that area, add the record.
2009-08-19 14:39:57 +00:00
//$query = "SELECT menu_name,menu_path FROM #menus WHERE menu_name='".$row['menu_name']."' AND menu_layout = '".$this->dbLayout."' AND menu_location = ".$location." LIMIT 1 ";
2013-03-02 21:07:42 -08:00
//if(!$sql->gen($query, $this->debug))
2009-08-16 16:30:56 +00:00
{
2009-08-17 15:23:44 +00:00
$insert = array (
'menu_id' => 0 ,
'menu_name' => $row [ 'menu_name' ],
'menu_location' => $location ,
'menu_order' => $menu_count ,
2016-03-23 10:22:21 -07:00
'menu_class' => intval ( $row [ 'menu_class' ]),
2009-08-17 15:23:44 +00:00
'menu_pages' => '' ,
'menu_path' => $row [ 'menu_path' ],
'menu_layout' => $this -> dbLayout ,
'menu_parms' => ''
);
2016-03-23 10:22:21 -07:00
$sql -> insert ( " menus " , $insert , $this -> debug );
2009-08-17 15:23:44 +00:00
2014-10-23 11:07:18 -07:00
e107 :: getLog () -> add ( 'MENU_01' , $row [ 'menu_name' ] . '[!br!]' . $location . '[!br!]' . $menu_count . '[!br!]' . $row [ 'menu_path' ], E_LOG_INFORMATIVE , '' );
2009-08-16 16:30:56 +00:00
$menu_count ++ ;
}
}
}
}
// -----------------------------------------------------------------------------
function menuSetCustomPages ( $array )
{
2013-02-27 17:18:33 +01:00
$pref = e107 :: getPref ();
2009-08-16 16:30:56 +00:00
$key = key ( $array );
$pref [ 'sitetheme_custompages' ][ $key ] = array_filter ( explode ( " " , $array [ $key ]));
save_prefs ();
}
// ------------------------------------------------------------------------------
function getMenuPreset ()
{
2013-02-27 17:18:33 +01:00
$pref = e107 :: getPref ();
2009-08-16 16:30:56 +00:00
$layout = $this -> curLayout ;
if ( ! isset ( $pref [ 'sitetheme_layouts' ][ $layout ][ 'menuPresets' ]))
{
2013-12-30 06:23:12 -08:00
e107 :: getMessage () -> addDebug ( print_a ( $pref [ 'sitetheme_layouts' ], true ));
2009-08-16 16:30:56 +00:00
return FALSE ;
}
2015-02-11 11:05:33 -08:00
$areas = $pref [ 'sitetheme_layouts' ][ $layout ][ 'menuPresets' ][ 'area' ];
2009-08-16 16:30:56 +00:00
2015-02-11 11:05:33 -08:00
foreach ( $areas as $area => $menus )
2009-08-16 16:30:56 +00:00
{
2015-02-11 11:05:33 -08:00
$areaID = $menus [ '@attributes' ][ 'id' ];
foreach ( $menus [ 'menu' ] as $k => $v )
2009-08-16 16:30:56 +00:00
{
2015-02-11 11:05:33 -08:00
$menuArea [] = array (
'menu_location' => $areaID ,
'menu_order' => $k ,
'menu_name' => $v [ '@attributes' ][ 'name' ] . " _menu " ,
'menu_class' => $this -> menuPresetPerms ( $v [ '@attributes' ][ 'perm' ])
);
2009-08-16 16:30:56 +00:00
}
2015-02-11 11:05:33 -08:00
}
2013-12-30 06:23:12 -08:00
2015-02-11 11:05:33 -08:00
if ( E107_DEBUG_LEVEL > 0 )
{
// e107::getMessage()->addDebug(print_a($menuArea,true));
2009-08-16 16:30:56 +00:00
}
2013-12-30 06:23:12 -08:00
2009-08-16 16:30:56 +00:00
2016-12-20 10:58:43 +01:00
return varset ( $menuArea , array ());
2009-08-16 16:30:56 +00:00
}
// ------------------------------------------------------------------------------
function checkMenuPreset ( $array , $name )
{
if ( ! is_array ( $array ))
{
return ;
}
foreach ( $array as $key => $val )
{
if ( $val [ 'menu_name' ] == $name )
{
return $val [ 'menu_location' ];
}
}
return FALSE ;
}
2012-05-04 17:56:21 +00:00
// --------------------------------------------------------------------------
function menuSaveParameters ()
{
$sql = e107 :: getDb ();
2016-12-20 10:58:43 +01:00
$tp = e107 :: getParser ();
2016-01-12 15:44:54 -08:00
$id = intval ( $_POST [ 'menu_id' ]);
if ( isset ( $_POST [ 'menu_parms' ]))
{
2016-12-20 10:58:43 +01:00
$parms = $tp -> filter ( $_POST [ 'menu_parms' ]);
$parms = $sql -> escape ( strip_tags ( $parms ));
2016-01-12 15:44:54 -08:00
}
else
{
unset ( $_POST [ 'menu_id' ], $_POST [ 'mode' ], $_POST [ 'menuActivate' ], $_POST [ 'menuSetCustomPages' ]);
2016-12-20 10:58:43 +01:00
$parms = $tp -> filter ( $_POST );
$parms = $sql -> escape ( e107 :: serialize ( $parms ));
2016-01-12 15:44:54 -08:00
if ( e_DEBUG == true )
{
// return array('msg'=>print_r($_POST,true),'error'=>true);
}
}
2016-02-28 10:44:03 -08:00
$check = $sql -> update ( " menus " , " menu_parms= \" " . $parms . " \" WHERE menu_id= " . $id . " " );
2016-01-12 15:44:54 -08:00
2012-05-04 17:56:21 +00:00
if ( $check )
{
2013-03-02 21:07:42 -08:00
return array ( 'msg' => 'All Okay' , 'error' => false );
2012-05-04 17:56:21 +00:00
// FIXME - menu log
2014-10-23 11:07:18 -07:00
//e107::getLog()->add('MENU_02',$_POST['menu_parms'].'[!br!]'.$parms.'[!br!]'.$this->menuId,E_LOG_INFORMATIVE,'');
2013-03-02 21:07:42 -08:00
// $this->menuAddMessage(LAN_SAVED,E_MESSAGE_SUCCESS);
2012-05-04 17:56:21 +00:00
}
elseif ( false === $check )
{
2016-02-28 10:44:03 -08:00
2013-03-02 21:07:42 -08:00
return array ( 'msg' => LAN_UPDATED_FAILED , 'error' => true );
}
else
{
return array ( 'msg' => 'No Changes Made' , 'error' => false ); // $this->menuAddMessage(LAN_NOCHANGE_NOTSAVED,E_MESSAGE_INFO);
2012-05-04 17:56:21 +00:00
}
}
2009-08-16 16:30:56 +00:00
// --------------------------------------------------------------------------
2013-03-02 21:07:42 -08:00
function menuSaveVisibility () // Used by Ajax
2009-08-16 16:30:56 +00:00
{
2016-12-20 10:58:43 +01:00
$tp = e107 :: getParser ();
2013-02-27 17:18:33 +01:00
$sql = e107 :: getDb ();
2016-12-20 10:58:43 +01:00
$pageList = $tp -> filter ( $_POST [ 'pagelist' ]);
$listType = $tp -> filter ( $_POST [ 'listtype' ]);
$pagelist = explode ( " \r \n " , $pageList );
2009-08-16 16:30:56 +00:00
for ( $i = 0 ; $i < count ( $pagelist ) ; $i ++ )
{
$pagelist [ $i ] = trim ( $pagelist [ $i ]);
}
$plist = implode ( " | " , $pagelist );
2016-12-20 10:58:43 +01:00
$pageparms = $listType . '-' . $plist ;
2009-08-16 16:30:56 +00:00
$pageparms = preg_replace ( " # \ | $ # " , " " , $pageparms );
2016-12-20 10:58:43 +01:00
$pageparms = ( trim ( $pageList ) == '' ) ? '' : $pageparms ;
2009-08-16 16:30:56 +00:00
2016-01-12 15:44:54 -08:00
if ( $sql -> update ( " menus " , " menu_class=' " . intval ( $_POST [ 'menu_class' ]) . " ', menu_pages=' { $pageparms } ' WHERE menu_id= " . intval ( $_POST [ 'menu_id' ])))
2009-08-16 16:30:56 +00:00
{
2014-10-23 11:07:18 -07:00
e107 :: getLog () -> add ( 'MENU_02' , $_POST [ 'menu_class' ] . '[!br!]' . $pageparms . '[!br!]' . $this -> menuId , E_LOG_INFORMATIVE , '' );
2013-03-02 21:07:42 -08:00
return array ( 'msg' => LAN_UPDATED , 'error' => false );
//$this->menuAddMessage($message,E_MESSAGE_SUCCESS);
2009-08-16 16:30:56 +00:00
}
else
{
2013-03-02 21:07:42 -08:00
return array ( 'msg' => LAN_UPDATED_FAILED , 'error' => true , 'posted' => $_POST );
// $this->menuAddMessage($message,E_MESSAGE_ERROR);
2009-08-16 16:30:56 +00:00
}
}
2013-03-02 21:07:42 -08:00
function setMenuId ( $id )
{
$this -> menuId = intval ( $id );
}
2009-08-16 16:30:56 +00:00
// -----------------------------------------------------------------------
function menuDeactivate ()
2015-04-01 11:52:50 -07:00
{
2013-03-02 21:07:42 -08:00
$sql = e107 :: getDb ();
2013-05-13 00:32:11 -04:00
$sql2 = e107 :: getDb ();
2012-05-24 15:54:25 +00:00
//echo "FOUND= ".$this->menuId;
2013-03-02 21:07:42 -08:00
$error = false ;
2015-04-01 11:52:50 -07:00
$message = '' ;
2009-08-16 16:30:56 +00:00
2013-05-13 00:32:11 -04:00
if ( $sql -> gen ( 'SELECT menu_name, menu_location, menu_order FROM #menus WHERE menu_id = ' . $this -> menuId . ' LIMIT 1' ))
2009-08-16 16:30:56 +00:00
{
2013-03-02 21:07:42 -08:00
$row = $sql -> fetch ();
2013-05-13 00:32:11 -04:00
2009-08-16 16:30:56 +00:00
//Check to see if there is already a menu with location = 0 (to maintain BC)
2013-05-13 00:32:11 -04:00
if ( $sql2 -> select ( 'menus' , 'menu_id' , " menu_name=' { $row [ 'menu_name' ] } ' AND menu_location = 0 AND menu_layout =' " . $this -> dbLayout . " ' LIMIT 1 " ))
2009-08-16 16:30:56 +00:00
{
//menu_location=0 already exists, we can just delete this record
2013-05-13 00:32:11 -04:00
if ( ! $sql2 -> db_Delete ( 'menus' , 'menu_id=' . $this -> menuId ))
2012-05-24 15:54:25 +00:00
{
$message = " Deletion Failed " ;
2013-03-02 21:07:42 -08:00
$error = true ;
2012-05-24 15:54:25 +00:00
}
2009-08-16 16:30:56 +00:00
}
else
{
//menu_location=0 does NOT exist, let's just convert this to it
2015-04-01 11:52:50 -07:00
if ( ! $sql2 -> update ( " menus " , " menu_location=0, menu_order=0, menu_class=0, menu_pages='' WHERE menu_id= " . $this -> menuId ))
2009-08-16 16:30:56 +00:00
{
$message = " FAILED " ;
2013-03-02 21:07:42 -08:00
$error = true ;
2009-08-16 16:30:56 +00:00
}
}
2013-05-13 00:32:11 -04:00
//Move all menus up (reduces order number) that have a higher menu order number than one deactivated, in the selected location.
2015-04-01 11:52:50 -07:00
$sql -> update ( " menus " , " menu_order=menu_order-1 WHERE menu_location= { $row [ 'menu_location' ] } AND menu_order > { $row [ 'menu_order' ] } AND menu_layout = ' " . $this -> dbLayout . " ' " );
2014-10-23 11:07:18 -07:00
e107 :: getLog () -> add ( 'MENU_04' , $row [ 'menu_name' ] . '[!br!]' . $row [ 'menu_location' ] . '[!br!]' . $row [ 'menu_order' ] . '[!br!]' . $this -> menuId , E_LOG_INFORMATIVE , '' );
2009-08-16 16:30:56 +00:00
}
2012-05-24 15:54:25 +00:00
else
{
2013-03-02 21:07:42 -08:00
$message = " NO CHANGES MADE : " . $this -> menuId ;
$error = true ;
2012-05-24 15:54:25 +00:00
}
2009-08-16 16:30:56 +00:00
2013-03-02 21:07:42 -08:00
return array ( 'msg' => $message , 'error' => $error );
2009-08-16 16:30:56 +00:00
}
// ----------------------------------------------------------------------
2015-04-01 11:52:50 -07:00
/**
* Move a Menu
*/
2009-08-16 16:30:56 +00:00
function menuMove ()
{ // Get current menu name
2015-04-01 11:52:50 -07:00
$sql = e107 :: getDb ();
2009-08-16 16:30:56 +00:00
2013-03-02 21:07:42 -08:00
if ( $sql -> select ( 'menus' , 'menu_name' , 'menu_id=' . $this -> menuId , 'default' ))
2009-08-16 16:30:56 +00:00
{
2013-03-02 21:07:42 -08:00
$row = $sql -> fetch ();
2009-08-16 16:30:56 +00:00
//Check to see if menu is already active in the new area, if not then move it
2013-03-02 21:07:42 -08:00
if ( ! $sql -> select ( 'menus' , 'menu_id' , " menu_name=' { $row [ 'menu_name' ] } ' AND menu_location = " . $this -> menuNewLoc . " AND menu_layout=' " . $this -> dbLayout . " ' LIMIT 1 " ))
2009-08-16 16:30:56 +00:00
{
2013-03-03 01:24:54 -08:00
$menu_count = $sql -> count ( " menus " , " (*) " , " WHERE menu_location= " . $this -> menuNewLoc );
2009-08-16 16:30:56 +00:00
$sql -> db_Update ( " menus " , " menu_location=' { $this -> menuNewLoc } ', menu_order= " . ( $menu_count + 1 ) . " WHERE menu_id= " . $this -> menuId );
2016-12-20 10:58:43 +01:00
if ( isset ( $location ) && isset ( $position ))
{
$sql -> db_Update ( " menus " , " menu_order=menu_order-1 WHERE menu_location=' { $location } ' AND menu_order > { $position } AND menu_layout=' " . $this -> dbLayout . " ' " );
}
2009-08-16 16:30:56 +00:00
}
2014-10-23 11:07:18 -07:00
e107 :: getLog () -> add ( 'MENU_03' , $row [ 'menu_name' ] . '[!br!]' . $this -> menuNewLoc . '[!br!]' . $this -> menuId , E_LOG_INFORMATIVE , '' );
2009-08-16 16:30:56 +00:00
}
}
// =-----------------------------------------------------------------------------
2013-03-06 23:01:16 -08:00
function renderOptionRow ( $row )
{
$frm = e107 :: getForm ();
$text = " " ;
$pdeta = " " ;
2016-12-20 10:58:43 +01:00
$color = ( varset ( $color ) == " white " ) ? " #DDDDDD " : " white " ;
2013-03-06 23:01:16 -08:00
if ( $row [ 'menu_pages' ] == " dbcustom " )
{
2016-12-20 20:26:00 +00:00
$pdeta = LAN_CUSTOM ;
2013-03-06 23:01:16 -08:00
}
else
{
2016-12-20 10:58:43 +01:00
$menuPreset = varset ( $menuPreset );
2013-03-06 23:01:16 -08:00
$row [ 'menu_name' ] = preg_replace ( " #_menu $ #i " , " " , $row [ 'menu_name' ]);
if ( $pnum = $this -> checkMenuPreset ( $menuPreset , $row [ 'menu_name' ] . '_menu' ))
{
$pdeta = MENLAN_39 . " { $pnum } " ;
}
}
if ( ! $this -> dragDrop )
{
$menuInf = ( ! is_numeric ( $row [ 'menu_path' ])) ? ' (' . substr ( $row [ 'menu_path' ], 0 , - 1 ) . ')' : " ( # " . $row [ 'menu_path' ] . " ) " ;
// $menuInf = $row['menu_path'];
$text .= " <tr style='background-color: $color ;color:black'>
2015-04-03 13:09:32 -07:00
< td style = 'text-align:left; color:black;' > " ;
2013-03-06 23:01:16 -08:00
$text .= $frm -> checkbox ( 'menuselect[]' , $row [ 'menu_id' ], '' , array ( 'label' => $row [ 'menu_name' ] . $menuInf ));
$text .= "
</ td >
< td style = 'color:black' >& nbsp ; " . $pdeta . " & nbsp ; </ td >
</ tr > \n " ;
}
else
{
2016-12-20 10:58:43 +01:00
$menu_count = varset ( $menu_count );
2013-03-06 23:01:16 -08:00
// Menu Choices box.
$text .= " <div class='portlet block block-archive' id='block- " . $row [ 'menu_id' ] . " ' style='border:1px outset black;text-align:left;color:black'> " ;
$text .= $this -> menuRenderMenu ( $row , $menu_count , true );
$text .= " </div> \n " ;
}
return $text ;
}
2009-08-16 16:30:56 +00:00
function menuRenderPage ()
{
2013-02-27 17:18:33 +01:00
global $HEADER , $FOOTER , $rs ;
$pref = e107 :: getPref ();
$sql = e107 :: getDb ();
2016-12-20 10:58:43 +01:00
$tp = e107 :: getParser ();
2013-02-27 17:18:33 +01:00
2014-01-07 08:21:19 -08:00
2009-08-19 14:39:57 +00:00
//FIXME - XHTML cleanup, front-end standards (elist, forms etc)
2009-08-16 16:30:56 +00:00
echo " <div id='portal'> " ;
$this -> parseheader ( $HEADER ); // $layouts_str;
2009-08-19 14:39:57 +00:00
2009-08-16 16:30:56 +00:00
$layout = ( $this -> curLayout );
2016-12-20 10:58:43 +01:00
$menuPreset = $this -> getMenuPreset ();
2009-08-16 16:30:56 +00:00
echo " <div style='text-align:center'> " ;
2009-08-19 14:39:57 +00:00
echo $rs -> form_open ( " post " , e_SELF . " ?configure= " . $this -> curLayout , " menuActivation " );
2013-04-14 18:41:53 -07:00
$text = " <table style='width:100%;margin-left:auto;margin-right:auto'> " ;
2009-08-16 16:30:56 +00:00
2013-04-14 20:25:09 -07:00
$text .= " <tr><td style='color:#2F2F2F;width:65%;text-align:center;padding-bottom:8px'> " . MENLAN_36 . " ...</td>
< td style = 'color:#2F2F2F;width:50%;padding-bottom:8px;text-align:center' >... " .MENLAN_37. " </ td ></ tr > " ;
2013-03-03 04:46:57 -08:00
$text .= " <tr><td style='width:35%;vertical-align:top;text-align:center'> " ;
2009-08-16 16:30:56 +00:00
2013-03-06 23:01:16 -08:00
2009-08-16 16:30:56 +00:00
if ( ! $this -> dragDrop )
{
2013-03-02 21:07:42 -08:00
$text .= " <div class='column' id='portal-column-block-list' style='border:1px inset black;height:250px;display:block;overflow:auto;margin-bottom:20px'> " ;
2015-04-03 19:23:55 -07:00
$text .= " <table class='table table-striped adminlist core-menumanager-main' id='core-menumanager-main' >
2013-03-02 21:07:42 -08:00
< tbody > \n " ;
2009-08-16 16:30:56 +00:00
}
else
{
2013-03-06 23:01:16 -08:00
// $text .= "<div class='column' id='remove' style='border:1px solid silver'>\n";
2009-08-16 16:30:56 +00:00
}
2016-12-20 10:58:43 +01:00
2013-03-06 23:01:16 -08:00
$pageMenu = array ();
$pluginMenu = array ();
2016-08-06 10:52:11 -07:00
$done = array ();
2013-03-06 23:01:16 -08:00
2016-08-06 10:52:11 -07:00
$sql -> select ( " menus " , " menu_name, menu_id, menu_pages, menu_path " , " 1 ORDER BY menu_name ASC " );
2013-03-02 21:07:42 -08:00
while ( $row = $sql -> fetch ())
2009-08-16 16:30:56 +00:00
{
2016-08-06 10:52:11 -07:00
if ( in_array ( $row [ 'menu_name' ], $done ))
{
continue ;
}
$done [] = $row [ 'menu_name' ];
2013-03-06 23:01:16 -08:00
if ( is_numeric ( $row [ 'menu_path' ]))
2009-08-16 16:30:56 +00:00
{
2013-03-06 23:01:16 -08:00
$pageMenu [] = $row ;
2009-08-16 16:30:56 +00:00
}
2013-03-06 23:01:16 -08:00
else
2009-08-16 16:30:56 +00:00
{
2013-03-06 23:01:16 -08:00
$pluginMenu [] = $row ;
2009-08-16 16:30:56 +00:00
}
2013-03-06 23:01:16 -08:00
}
2009-08-16 16:30:56 +00:00
2016-12-20 20:26:00 +00:00
$text .= " <tr><th colspan='2'> " . MENLAN_49 . " </th></tr> " ;
2013-03-06 23:01:16 -08:00
foreach ( $pageMenu as $row )
{
$text .= $this -> renderOptionRow ( $row );
}
2013-03-02 21:07:42 -08:00
2016-12-20 20:26:00 +00:00
$text .= " <tr><th colspan='2' > " . MENLAN_50 . " </th></tr> " ;
2013-03-06 23:01:16 -08:00
foreach ( $pluginMenu as $row )
{
$text .= $this -> renderOptionRow ( $row );
2009-08-16 16:30:56 +00:00
}
2013-03-06 23:01:16 -08:00
2013-03-02 21:07:42 -08:00
$text .= ( ! $this -> dragDrop ) ? " </tbody></table> " : " " ;
2009-08-16 16:30:56 +00:00
$text .= " </div> " ;
2013-03-03 04:46:57 -08:00
$text .= " </td><td id='menu-manage-actions' ><br /> " ;
2009-08-16 16:30:56 +00:00
foreach ( $this -> menu_areas as $menu_act )
{
2013-04-14 18:41:53 -07:00
$text .= " <input type='submit' class='menu-btn' id='menuActivate_ " . trim ( $menu_act ) . " ' name='menuActivate[ " . trim ( $menu_act ) . " ]' value=' " . MENLAN_13 . " " . trim ( $menu_act ) . " ' /><br /><br /> \n " ;
2009-08-16 16:30:56 +00:00
}
if ( $layout )
{
if ( isset ( $pref [ 'sitetheme_layouts' ][ $layout ][ 'menuPresets' ]))
{
2013-04-14 18:41:53 -07:00
$text .= " <input type='submit' class='menu-btn' name='menuUsePreset' value= \" " . MENLAN_40 . " \" onclick= \" return jsconfirm(' " . $tp -> toJS ( MENLAN_41 ) . " ') \" /><br /><br /> \n " ; // Use Menu Presets
2009-08-16 16:30:56 +00:00
$text .= " <input type='hidden' name='menuPreset' value=' " . $layout . " ' /> " ;
}
2012-05-24 15:54:25 +00:00
$text .= " <input type='hidden' name='curLayout' value=' " . $layout . " ' /> " ;
2009-08-16 16:30:56 +00:00
}
2012-05-24 15:54:25 +00:00
$text .= " <input type='hidden' id='dbLayout' value=' " . $this -> dbLayout . " ' /> " ;
2009-08-16 16:30:56 +00:00
$text .= " </td> " ;
$text .= " </tr></table> " ;
2014-03-19 12:37:44 +02:00
2014-01-07 08:21:19 -08:00
if ( ! count ( $this -> menu_areas ))
{
$text = " <div class='alert alert-block alert-warning text-left'> " ;
2016-12-20 20:26:00 +00:00
$text .= MENLAN_51 . " <br /> " ;
2014-01-07 08:21:19 -08:00
2016-12-20 10:58:43 +01:00
if ( isset ( $this -> customMenu ) && count ( $this -> customMenu ))
2014-01-07 08:21:19 -08:00
{
2016-12-20 20:26:00 +00:00
$text .= " <p> " . MENLAN_52 . " <ul ><li> " . implode ( " </li><li> " , $this -> customMenu ) . " </li></ul></p> " ;
$text .= " <p><a href=' " . e_ADMIN . " cpage.php?mode=menu&action=list&tab=2' class='button btn btn-primary'> " . MENLAN_53 . " </a></p> " ;
2014-01-07 08:21:19 -08:00
}
$text .= " </div> " ;
}
2013-04-14 18:41:53 -07:00
// $ns -> tablerender(MENLAN_22.'blabla', $text);
echo $this -> renderPanel ( MENLAN_22 , $text );
2009-08-16 16:30:56 +00:00
echo $rs -> form_close ();
echo " </div> " ;
$this -> parseheader ( $FOOTER );
if ( $this -> debug )
{
echo " <div id='debug' style='margin-left:0px;border:1px solid silver; overflow:scroll;height:250px'> </div> " ;
}
2009-08-19 14:39:57 +00:00
echo " </div> " ;
2009-08-16 16:30:56 +00:00
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
function menuSelectLayout ()
{
2012-12-08 15:52:40 +01:00
$pref = e107 :: getPref ();
2012-05-24 15:54:25 +00:00
// onchange=\"urljump(this.options[selectedIndex].value);\"
2009-08-16 16:30:56 +00:00
2013-04-14 17:06:02 -07:00
$text = " <form class='form-inline' method='post' action=' " . e_SELF . " ?configure= " . $this -> curLayout . " '> " ;
2016-12-20 20:26:00 +00:00
$text .= " <div class='buttons-bar'> " . MENLAN_54 . " : " ;
2013-04-14 18:41:53 -07:00
$text .= " <select name='custom_select' style='width:auto' id='menuManagerSelect' > \n " ; //tbox class will break links. // window.frames['menu_iframe'].location=this.options[selectedIndex].value ???
2009-08-16 16:30:56 +00:00
$search = array ( " _ " , " legacyDefault " , " legacyCustom " );
$replace = array ( " " , MENLAN_31 , MENLAN_33 );
foreach ( $pref [ 'sitetheme_layouts' ] as $key => $val )
{
$layoutName = str_replace ( $search , $replace , $key );
$layoutName .= ( $key == $pref [ 'sitetheme_deflayout' ]) ? " ( " . MENLAN_31 . " ) " : " " ;
$selected = ( $this -> curLayout == $key || ( $key == $pref [ 'sitetheme_deflayout' ] && $this -> curLayout == '' )) ? " selected='selected' " : FALSE ;
2012-05-24 15:54:25 +00:00
// $url = e_SELF."?lay=".$key;
2009-08-16 16:30:56 +00:00
2012-05-24 15:54:25 +00:00
$url = e_SELF . " ?configure= " . $key ;
2013-04-14 17:06:02 -07:00
$text .= " <option value=' " . $url . " ' { $selected } > " . $layoutName . " </option> " ;
2009-08-16 16:30:56 +00:00
}
$text .= " </select>
2013-04-14 17:06:02 -07:00
< div class = 'field-help' > " .MENLAN_30. " </ div >
2009-08-16 16:30:56 +00:00
</ div ></ form > " ;
2013-03-02 21:07:42 -08:00
// $text .= "<div id='visibility'>Something here</div>";
2009-08-16 16:30:56 +00:00
return $text ;
2012-01-10 16:31:39 +00:00
}
2010-02-13 16:37:35 +00:00
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
2012-01-10 16:31:39 +00:00
function parseheader ( $LAYOUT , $check = FALSE )
{
2009-08-16 16:30:56 +00:00
// $tmp = explode("\n", $LAYOUT);
// Split up using the same function as the shortcode handler
2010-02-13 16:37:35 +00:00
$tmp = preg_split ( '#(\{\S[^\x02]*?\S\})#' , $LAYOUT , - 1 , PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
2012-01-10 16:31:39 +00:00
$str = array ();
for ( $c = 0 ; $c < count ( $tmp ); $c ++ )
{
if ( preg_match ( " /[ \ { | \ }]/ " , $tmp [ $c ]))
{
if ( $check )
{
if ( strstr ( $tmp [ $c ], " { MENU= " ))
{
$matches = array ();
2010-02-13 16:37:35 +00:00
// Match all menu areas, menu number is limited to tinyint(3)
2012-01-10 16:31:39 +00:00
preg_match_all ( " / \ { MENU=([ \ d] { 1,3})(:[ \ w \ d]*)? \ }/ " , $tmp [ $c ], $matches );
$this -> menuSetCode ( $matches , $str );
}
}
else
{
$this -> checklayout ( $tmp [ $c ]);
}
}
else
{
if ( ! $check )
{
echo $tmp [ $c ];
}
}
}
if ( $check )
{
return $str ;
}
2009-08-16 16:30:56 +00:00
}
2010-02-13 16:37:35 +00:00
function menuSetCode ( $matches , & $ret )
{
2015-02-14 23:34:15 -08:00
if ( ! $matches || ! vartrue ( $matches [ 1 ]))
2009-08-16 16:30:56 +00:00
{
2010-02-13 16:37:35 +00:00
return ;
2009-08-16 16:30:56 +00:00
}
2010-02-13 16:37:35 +00:00
foreach ( $matches [ 1 ] as $match )
2009-08-16 16:30:56 +00:00
{
2010-02-13 16:37:35 +00:00
$ret [] = $match ;
2009-08-16 16:30:56 +00:00
}
2012-01-10 16:31:39 +00:00
}
2013-03-03 01:24:54 -08:00
function renderPanel ( $caption , $text )
{
$plugtext = " <div class='menu-panel'> " ;
$plugtext .= " <div class='menu-panel-header' title= \" " . MENLAN_34 . " \" > " . $caption . " </div> " ;
$plugtext .= $text ;
$plugtext .= " </div> " ;
return $plugtext ;
}
2012-01-10 16:31:39 +00:00
function checklayout ( $str )
2010-02-13 16:37:35 +00:00
{ // Displays a basic representation of the theme
2014-01-07 08:21:19 -08:00
global $PLUGINS_DIRECTORY , $rs , $sc_style , $menu_order , $style ; // global $style required.
2013-03-03 01:24:54 -08:00
$PLUGINS_DIRECTORY = e107 :: getFolder ( 'PLUGINS' );
2013-02-27 17:18:33 +01:00
$pref = e107 :: getPref ();
$tp = e107 :: getParser ();
$ns = e107 :: getRender ();
2015-04-01 11:52:50 -07:00
2012-01-10 16:31:39 +00:00
$menuLayout = ( $this -> curLayout != $pref [ 'sitetheme_deflayout' ]) ? $this -> curLayout : " " ;
2015-04-16 00:56:09 -07:00
// if(strstr($str, "LOGO"))
// {
// echo $tp->parseTemplate("{LOGO}");
// }
if ( strstr ( $str , " SETSTYLE " ))
2015-04-01 11:52:50 -07:00
{
$style = preg_replace ( " / \ { SETSTYLE=(.*?) \ }/si " , " \\ 1 " , $str );
$this -> style = $style ;
$ns -> setStyle ( $style );
}
2015-04-14 15:26:26 -07:00
/* elseif ( strstr ( $str , " SITENAME " ))
2012-01-10 16:31:39 +00:00
{
2012-05-04 02:07:47 +00:00
echo " [SiteName] " ;
2015-04-14 15:26:26 -07:00
} */
/* elseif ( strstr ( $str , " SITETAG " ))
2012-01-10 16:31:39 +00:00
{
echo " <div style='padding: 2px'>[SiteTag]</div> " ;
2015-04-14 15:26:26 -07:00
} */
// elseif(strstr($str, "SITELINKS"))
// {
// echo "[SiteLinks]";
// }
elseif ( strstr ( $str , " NAVIGATION " ))
2012-01-10 16:31:39 +00:00
{
2016-04-16 08:16:42 -07:00
$cust = preg_replace ( " / \ W* \ { NAVIGATION(.*?)( \ +.*)? \ } \ W*/si " , " \\ 1 " , $str );
$tp -> parseTemplate ( " { NAVIGATION " . $cust . " } " , true );
// echo "<span class='label label-info'>Navigation Area</span>";
2012-01-10 16:31:39 +00:00
}
2015-04-14 15:26:26 -07:00
elseif ( strstr ( $str , " ALERT " ))
2014-01-07 08:21:19 -08:00
{
2015-04-14 15:26:26 -07:00
//echo "[Navigation Area]";
2014-01-07 08:21:19 -08:00
}
2013-04-14 19:44:12 -07:00
elseif ( strstr ( $str , " LANGUAGELINKS " ))
2012-01-10 16:31:39 +00:00
{
2016-12-20 20:26:00 +00:00
echo " <div class=text style='padding: 2px; text-align: center'>[ " . LAN_LANGUAGE . " ]</div> " ;
2012-01-10 16:31:39 +00:00
}
2013-04-14 19:44:12 -07:00
elseif ( strstr ( $str , " CUSTOM " ))
2012-01-10 16:31:39 +00:00
{
$cust = preg_replace ( " / \ W* \ { CUSTOM=(.*?)( \ +.*)? \ } \ W*/si " , " \\ 1 " , $str );
echo " <div style='padding: 2px'>[ " . $cust . " ]</div> " ;
}
2013-04-14 19:44:12 -07:00
elseif ( strstr ( $str , " CMENU " ))
{
$cust = preg_replace ( " / \ W* \ { CMENU=(.*?)( \ +.*)? \ } \ W*/si " , " \\ 1 " , $str );
2016-12-20 10:58:43 +01:00
if ( isset ( $this -> customMenu ))
{
$this -> customMenu [] = $cust ;
}
2013-04-14 19:44:12 -07:00
echo $tp -> parseTemplate ( " { CMENU= " . $cust . " } " , true );
// echo $this->renderPanel('Embedded Custom Menu',$cust);
}
elseif ( strstr ( $str , " SETIMAGE " ))
{
$cust = preg_replace ( " / \ W* \ { SETIMAGE(.*?)( \ +.*)? \ } \ W*/si " , " \\ 1 " , $str );
echo $tp -> parseTemplate ( " { SETIMAGE " . $cust . " } " , true );
// echo $this->renderPanel('Embedded Custom Menu',$cust);
}
2016-04-16 08:16:42 -07:00
/* elseif ( strstr ( $str , " { WMESSAGE " ))
2014-01-07 08:21:19 -08:00
{
echo " <div class=text style='padding: 30px; text-align: center'>[Welcome Message Area]</div> " ;
// echo $this->renderPanel('Embedded Custom Menu',$cust);
2016-04-16 08:16:42 -07:00
} */
elseif ( strstr ( $str , " { FEATUREBOX " ))
2014-01-07 08:21:19 -08:00
{
2016-12-20 20:26:00 +00:00
echo " <div class=text style='padding: 80px; text-align: center'>[ " . LAN_PLUGIN_FEATUREBOX_NAME . " ]</div> " ;
2014-01-07 08:21:19 -08:00
// echo $this->renderPanel('Embedded Custom Menu',$cust);
}
2009-08-16 16:30:56 +00:00
// Display embedded Plugin information.
2012-01-10 16:31:39 +00:00
else if ( strstr ( $str , " PLUGIN " ))
{
$plug = preg_replace ( " / \ { PLUGIN=(.*?) \ }/si " , " \\ 1 " , $str );
$plug = trim ( $plug );
if ( file_exists (( e_PLUGIN . " { $plug } / { $plug } _config.php " )))
{
$link = e_PLUGIN . " { $plug } / { $plug } _config.php " ;
}
if ( file_exists (( e_PLUGIN . $plug . " /config.php " )))
{
$link = e_PLUGIN . $plug . " /config.php " ;
}
2013-03-03 01:24:54 -08:00
// $plugtext = "<div class='menu-panel'>";
// $plugtext .= "<div class='menu-panel-header' title=\"".MENLAN_34."\">".$plug."</div>";
2016-12-20 10:58:43 +01:00
$plugtext = ( varset ( $link )) ? " ( " . MENLAN_34 . " :<a href=' $link btn-menu' title=' " . LAN_CONFIGURE . " '> " . LAN_CONFIGURE . " </a>) " : " " ;
2013-03-03 01:24:54 -08:00
// $plugtext .= "</div>";
2012-01-10 16:31:39 +00:00
echo " <br /> " ;
2013-03-03 01:24:54 -08:00
echo $this -> renderPanel ( $plug , $plugtext );
// $ns->tablerender($plug, $plugtext);
2012-01-10 16:31:39 +00:00
}
else if ( strstr ( $str , " MENU " ))
{
2012-06-03 01:42:05 +00:00
2012-01-10 16:31:39 +00:00
$matches = array ();
if ( preg_match_all ( " / \ { MENU=([ \ d] { 1,3})(:[ \ w \ d]*)? \ }/ " , $str , $matches ))
{
2012-05-24 15:54:25 +00:00
$menuText = " " ;
2012-01-10 16:31:39 +00:00
foreach ( $matches [ 1 ] as $menu )
{
$menu = preg_replace ( " / \ { MENU=(.*?)(:.*?)? \ }/si " , " \\ 1 " , $str );
if ( isset ( $sc_style [ 'MENU' ][ 'pre' ]) && strpos ( $str , 'ret' ) !== false )
{
2012-05-24 15:54:25 +00:00
$menuText .= $sc_style [ 'MENU' ][ 'pre' ];
2012-01-10 16:31:39 +00:00
}
2012-05-24 15:54:25 +00:00
2013-03-03 01:24:54 -08:00
2012-05-24 15:54:25 +00:00
// ---------------
$menuText .= " \n \n <!-- START AREA " . $menu . " --> " ;
2013-03-03 01:24:54 -08:00
$menuText .= " <div id='start-area- " . $menu . " ' class='menu-panel'> " ;
$menuText .= " <div class='menu-panel-header' > " . MENLAN_14 . " " . $menu . " </div> \n \n " ;
2012-01-10 16:31:39 +00:00
$sql9 = new db ();
2012-05-24 15:54:25 +00:00
// $sql9 = e107::getDb('sql9');
2013-03-03 01:24:54 -08:00
if ( $sql9 -> count ( " menus " , " (*) " , " WHERE menu_location=' $menu ' AND menu_layout = ' " . $this -> dbLayout . " ' " ))
2012-01-10 16:31:39 +00:00
{
unset ( $text );
2012-05-24 15:54:25 +00:00
$menuText .= $rs -> form_open ( " post " , e_SELF . " ?configure= " . $this -> curLayout , " frm_menu_ " . intval ( $menu ));
2012-01-10 16:31:39 +00:00
2016-12-29 17:19:05 -08:00
$rows = $sql9 -> retrieve ( " menus " , " * " , " menu_location=' $menu ' AND menu_layout=' " . $this -> dbLayout . " ' ORDER BY menu_order " , true );
// $menu_count = $sql9->db_Rows();
$menu_count = count ( $rows );
if ( ! empty ( $_GET [ 'debug' ]))
{
print_a ( $rows );
}
2012-06-03 01:42:05 +00:00
$cl = ( $this -> dragDrop ) ? " 'portlet " : " regularMenu " ;
2012-05-24 15:54:25 +00:00
$menuText .= " \n <div class='column' id='area- " . $menu . " '> \n \n " ;
2016-12-29 17:19:05 -08:00
// while($row = $sql9->fetch())
foreach ( $rows as $row )
2012-01-10 16:31:39 +00:00
{
2012-05-24 15:54:25 +00:00
$menuText .= " \n \n \n <!-- Menu Start " . $row [ 'menu_name' ] . " --> \n " ;
2012-06-03 01:42:05 +00:00
$menuText .= " <div class=' { $cl } ' id='block- " . $row [ 'menu_id' ] . " - " . $menu . " '> \n " ;
2010-02-13 16:37:35 +00:00
2012-05-24 15:54:25 +00:00
// echo "<div class='ggportal'>";
2012-01-10 16:31:39 +00:00
2012-05-24 15:54:25 +00:00
// $menuText .= "hi there";
$menuText .= $this -> menuRenderMenu ( $row , $menu_count );
2012-01-10 16:31:39 +00:00
2012-05-24 15:54:25 +00:00
// echo "\n</div>";
$menuText .= " \n </div> \n " ;
$menuText .= " <!-- Menu end --> \n \n \n " ;
// echo "<div><br /></div>";
2012-01-10 16:31:39 +00:00
}
2012-05-24 15:54:25 +00:00
$menuText .= " \n \n </div> \n \n " ; // End Column
$menuText .= $rs -> form_close ();
}
else
{ // placeholder
$menuText .= " <div class='column' id='area- " . $menu . " '><!-- --></div> " ;
2012-01-10 16:31:39 +00:00
}
2012-05-24 15:54:25 +00:00
$menuText .= " </div><!-- END OF AREA --> \n \n " ;
// ---------------
2012-01-10 16:31:39 +00:00
if ( isset ( $sc_style [ 'MENU' ][ 'post' ]) && strpos ( $str , 'ret' ) !== false )
{
2012-05-24 15:54:25 +00:00
$menuText .= $sc_style [ 'MENU' ][ 'post' ];
2012-01-10 16:31:39 +00:00
}
2012-05-24 15:54:25 +00:00
2012-01-10 16:31:39 +00:00
}
}
2012-05-24 15:54:25 +00:00
2015-04-01 11:52:50 -07:00
2016-12-20 10:58:43 +01:00
$ns -> tablerender ( '' , varset ( $menuText ));
2012-01-10 16:31:39 +00:00
}
2015-04-01 11:52:50 -07:00
2015-04-14 15:26:26 -07:00
//. else if(strstr($str, "SITEDISCLAIMER"))
//{
// echo "[Sitedisclaimer]";
// }
else
2012-01-10 16:31:39 +00:00
{
2015-04-14 15:26:26 -07:00
echo $tp -> parseTemplate ( $str , true );
2012-01-10 16:31:39 +00:00
}
2009-08-16 16:30:56 +00:00
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
2012-05-24 15:54:25 +00:00
function menuRenderMenu ( $row , $menu_count , $rep = FALSE )
2009-08-16 16:30:56 +00:00
{
2013-03-03 12:23:59 -08:00
2013-02-27 17:18:33 +01:00
global $rs , $menu , $menu_info , $menu_act , $style ;
2012-06-03 01:42:05 +00:00
$style = $this -> style ;
2009-08-19 14:39:57 +00:00
// $menu_count is empty in here
2009-08-16 16:30:56 +00:00
//FIXME extract
2016-12-23 08:00:18 -08:00
$menu_location = '' ;
$menu_order = '' ;
2009-08-16 16:30:56 +00:00
extract ( $row );
2016-12-20 10:58:43 +01:00
if ( empty ( $menu_id )){ return ; }
2013-02-26 17:17:31 -08:00
2016-12-20 10:58:43 +01:00
$menu_name = varset ( $menu_name );
2009-08-16 16:30:56 +00:00
$menu_name = preg_replace ( " #_menu#i " , " " , $menu_name );
//TODO we need a CSS class for this
2016-12-20 10:58:43 +01:00
$vis = ( varset ( $menu_class ) || strlen ( varset ( $menu_pages )) > 1 ) ? " <span class='required'><i class='icon-search'></i></span> " : " " ;
2009-08-16 16:30:56 +00:00
//DEBUG div not allowed in final tags $caption = "<div style='text-align:center'>{$menu_name}{$vis}</div>";
// use theme render style instead
2012-05-04 17:58:06 +00:00
// Undocumented special parameter 'admin_title'
2012-05-04 17:56:21 +00:00
$menuParms = array ();
if ( ! empty ( $row [ 'menu_parms' ])) parse_str ( $row [ 'menu_parms' ], $menuParms );
if ( isset ( $menuParms [ 'admin_title' ]) && $menuParms [ 'admin_title' ])
{
$caption = deftrue ( $menuParms [ 'admin_title' ], $menuParms [ 'admin_title' ]) . $vis ;
}
2012-11-01 07:52:18 +00:00
elseif ( isset ( $menuParms [ 'title' ]) && $menuParms [ 'title' ])
{
$caption = deftrue ( $menuParms [ 'title' ], $menuParms [ 'title' ]) . $vis ;
}
2012-05-04 17:56:21 +00:00
else $caption = $menu_name . $vis ;
2016-12-23 08:00:18 -08:00
$menu_info = " { $menu_location } . { $menu_order } " ;
2009-08-16 16:30:56 +00:00
$text = " " ;
$conf = '' ;
2016-12-20 10:58:43 +01:00
if ( file_exists ( e_PLUGIN . varset ( $menu_path ) . $menu_name . '_menu_config.php' ))
2009-08-16 16:30:56 +00:00
{
2012-01-10 16:31:39 +00:00
$conf = $menu_path . $menu_name . '_menu_config' ;
2009-08-16 16:30:56 +00:00
}
if ( $conf == '' && file_exists ( e_PLUGIN . " { $menu_path } config.php " ))
{
$conf = " { $menu_path } config " ;
}
2013-03-02 21:07:42 -08:00
//
// $text = "<div style='white-space:nowrap'>";
$text .= '<div class="menuOptions">' ;
2012-05-24 15:54:25 +00:00
if ( ! $this -> dragDrop )
2009-08-16 16:30:56 +00:00
{
2013-03-02 21:07:42 -08:00
$text .= " <select id='menuAct_ " . $menu_id . " ' name='menuAct[ $menu_id ]' class='menu-btn' onchange='this.form.submit()' > " ;
2012-05-24 15:54:25 +00:00
$text .= $rs -> form_option ( MENLAN_25 , TRUE , " " );
// $text .= $rs->form_option(MENLAN_15, "", "deac.{$menu_info}");
if ( $conf )
{
// $text .= $rs->form_option("Configure", "", $conf); // TODO Check LAN availability
}
if ( $menu_order != 1 )
{
$text .= $rs -> form_option ( MENLAN_17 , " " , " inc. { $menu_info } " );
$text .= $rs -> form_option ( MENLAN_24 , " " , " top. { $menu_info } " );
}
if ( $menu_count != $menu_order )
2009-08-16 16:30:56 +00:00
{
2012-05-24 15:54:25 +00:00
$text .= $rs -> form_option ( MENLAN_18 , " " , " dec. { $menu_info } " );
$text .= $rs -> form_option ( MENLAN_23 , " " , " bot. { $menu_info } " );
2009-08-16 16:30:56 +00:00
}
2012-05-24 15:54:25 +00:00
foreach ( $this -> menu_areas as $menu_act )
{
if ( $menu != $menu_act )
{
$text .= $rs -> form_option ( MENLAN_19 . " " . $menu_act , " " , " move. { $menu_info } . " . $menu_act );
}
}
// Visibility is an action icon now
//$text .= $rs->form_option(MENLAN_20, "", "adv.{$menu_info}");
$text .= $rs -> form_select_close ();
2009-08-16 16:30:56 +00:00
}
2012-05-24 15:54:25 +00:00
if ( $rep == true )
{
2016-12-20 10:58:43 +01:00
$text .= " <div id='check- " . $menu_id . " '><input type='checkbox' name='menuselect[]' value=' { $menu_id } ' /> " . $menu_id . " " . varset ( $pdeta ) . " </div>
2012-05-24 15:54:25 +00:00
< div id = 'option-".$menu_id."' style = 'display:none' > " ;
}
2009-08-16 16:30:56 +00:00
//DEBUG remove inline style, switch to simple quoted string for title text value
//TODO hardcoded text
2013-03-02 21:07:42 -08:00
// $visibilityLink = e_SELF.'?'.urlencode('lay='.$this->curLayout.'&vis='.$menu_id.'&iframe=1');
$visibilityLink = e_SELF . " ?enc= " . base64_encode ( 'lay=' . $this -> curLayout . '&vis=' . $menu_id . '&iframe=1' );
2013-03-03 04:46:57 -08:00
$text .= ' < span class = " menu-options-buttons " >
2015-07-02 14:33:04 +01:00
< a class = " e-menumanager-option menu-btn " data - modal - caption = " '.LAN_VISIBILITY.' " href = " '. $visibilityLink .' " title = " '.LAN_VISIBILITY.' " >< i class = " S16 e-search-16 " ></ i ></ a > ' ;
2009-08-16 16:30:56 +00:00
if ( $conf )
{
2016-12-20 20:26:00 +00:00
$text .= '<a data-modal-caption="' . LAN_OPTIONS . '" class="e-modal-menumanager menu-btn" target="_top" href="' . e_SELF . '?lay=' . $this -> curLayout . '&mode=conf&path=' . urlencode ( $conf ) . '&id=' . $menu_id . ' & iframe = 1 "
title = " '.LAN_OPTIONS.' " >< i class = " S16 e-configure-16 " ></ i ></ a > ' ;
2009-08-16 16:30:56 +00:00
}
2012-05-04 17:56:21 +00:00
2013-03-02 21:07:42 -08:00
$editLink = e_SELF . " ?enc= " . base64_encode ( 'lay=' . $this -> curLayout . '&parmsId=' . $menu_id . '&iframe=1' );
2016-12-20 20:26:00 +00:00
$text .= '<a data-modal-caption="' . LAN_CONFIGURE . '" class="e-menumanager-option menu-btn" target="_top" href="' . $editLink . '" title="' . LAN_CONFIGURE . '"><i class="S16 e-edit-16" ></i></a>' ;
2009-08-16 16:30:56 +00:00
2016-04-13 16:43:19 -07:00
$text .= '<a title="' . LAN_DELETE . '" id="remove-' . $menu_id . '-' . $menu_location . '" class="delete e-menumanager-delete menu-btn" href="' . e_SELF . '?configure=' . $this -> curLayout . '&mode=deac&id=' . $menu_id . ' " ><i class= " S16 e - delete - 16 " ></i></a>
2012-05-24 15:54:25 +00:00
< span id = " status-'. $menu_id .' " style = " display:none " > '.($rep == true ? "" : "insert").' </ span >
2013-03-03 12:23:59 -08:00
</ span ></ div > ' ;
2009-08-16 16:30:56 +00:00
2012-05-24 15:54:25 +00:00
$text .= ( $rep == true ) ? " </div> " : " " ;
2009-08-16 16:30:56 +00:00
2013-03-03 04:46:57 -08:00
// $text .= "</div>";
2012-05-24 15:54:25 +00:00
if ( ! $this -> dragDrop )
{
2012-12-17 13:21:43 -08:00
2016-04-09 16:12:08 -07:00
return " <span class='muted'> " . $caption . " </span><br /> " . $text ;
2013-04-14 17:06:02 -07:00
// return;
2012-12-17 13:21:43 -08:00
2009-08-16 16:30:56 +00:00
2013-04-14 17:06:02 -07:00
// return $ns->tablerender($caption, $text,'', true); Theme style too unpredictable.
2012-12-17 13:21:43 -08:00
2012-05-24 15:54:25 +00:00
}
else
{
2012-06-03 01:42:05 +00:00
2012-05-24 15:54:25 +00:00
return "
< div class = 'portlet-header' > " . $caption . " </ div >
2012-06-03 01:42:05 +00:00
< div class = 'portlet-content' > " . $text . " </ div > " ;
2012-05-24 15:54:25 +00:00
}
2009-08-16 16:30:56 +00:00
}
2013-03-02 21:07:42 -08:00
function menuSaveAjax ( $mode = null )
2009-08-16 16:30:56 +00:00
{
2012-05-24 15:54:25 +00:00
2013-03-02 21:07:42 -08:00
if ( $mode == 'visibility' )
{
$ret = $this -> menuSaveVisibility ();
2013-11-21 19:42:12 -08:00
// echo json_encode($ret);
2013-03-02 21:07:42 -08:00
return ;
}
if ( $mode == 'delete' )
{
list ( $tmp , $area ) = explode ( " - " , $_POST [ 'area' ]);
if ( $_POST [ 'area' ] == 'remove' )
{
list ( $tmp , $deleteID ) = explode ( " - " , $_POST [ 'removeid' ]);
$this -> menuId = $deleteID ;
2009-08-16 16:30:56 +00:00
2013-03-02 21:07:42 -08:00
$ret = $this -> menuDeactivate ();
2013-11-21 19:42:12 -08:00
// echo json_encode($ret);
2013-03-02 21:07:42 -08:00
return ;
}
}
2012-05-24 15:54:25 +00:00
2013-03-02 21:07:42 -08:00
if ( $mode == 'parms' )
2009-08-16 16:30:56 +00:00
{
2016-01-12 15:44:54 -08:00
$ret = $this -> menuSaveParameters ();
if ( ! empty ( $ret [ 'error' ]))
{
echo json_encode ( $ret );
}
2012-05-24 15:54:25 +00:00
return ;
2009-08-16 16:30:56 +00:00
}
2013-03-02 21:07:42 -08:00
2013-11-21 19:42:12 -08:00
// print_r($_POST);
2013-03-02 21:07:42 -08:00
return ;
$this -> debug = TRUE ;
$sql = e107 :: getDb ();
2009-08-16 16:30:56 +00:00
2012-05-24 15:54:25 +00:00
// Allow deletion by ajax, but not the rest when drag/drop disabled.
if ( ! $this -> dragDrop ){ return ; }
2009-08-16 16:30:56 +00:00
2012-05-24 15:54:25 +00:00
$this -> dbLayout = $_POST [ 'layout' ];
list ( $tmp , $insertID ) = explode ( " - " , $_POST [ 'insert' ]);
$insert [] = $insertID ;
2009-08-16 16:30:56 +00:00
2013-03-02 21:07:42 -08:00
2009-08-16 16:30:56 +00:00
2012-05-24 15:54:25 +00:00
if ( $_POST [ 'mode' ] == 'insert' && count ( $insert ) && $area ) // clear out everything before rewriting everything to db.
{
$this -> menuActivateLoc = $area ; // location
$this -> menuActivateIds = $insert ; // array of ids, in order.
$this -> menuActivate ();
}
elseif ( $_POST [ 'mode' ] == 'update' )
{
2016-03-23 10:22:21 -07:00
$sql -> update ( " menus " , " menu_location = " . intval ( $area ) . " WHERE menu_id = " . intval ( $insertID ) . " " , $this -> debug );
2012-05-24 15:54:25 +00:00
}
$c = 0 ;
if ( count ( $_POST [ 'list' ]) < 2 )
{
return ;
}
// resort the menus in this 'Area"
foreach ( $_POST [ 'list' ] as $val )
{
list ( $b , $id ) = explode ( " - " , $val );
$order [] = $id ;
2016-03-23 10:22:21 -07:00
$sql -> update ( " menus " , " menu_order = " . $c . " WHERE menu_id = " . intval ( $id ) . " " , $this -> debug );
2012-05-24 15:54:25 +00:00
$c ++ ;
}
2009-08-16 16:30:56 +00:00
// same for delete etc.
2012-05-24 15:54:25 +00:00
// echo "<hr />";
2009-08-16 16:30:56 +00:00
}
function menuSetConfigList ()
{
2015-04-01 23:01:04 -07:00
e107 :: getMessage () -> addDebug ( " Scanning for Menu config files " );
2013-02-27 17:18:33 +01:00
$sql = e107 :: getDb ();
$pref = e107 :: getPref ();
2015-04-01 23:01:04 -07:00
$prev_name = '' ;
$search = array ( '_menu' , '_' );
2009-08-16 16:30:56 +00:00
2013-03-02 21:07:42 -08:00
$sql -> select ( " menus " , " * " , " menu_location != 0 ORDER BY menu_path,menu_name " );
while ( $row = $sql -> fetch ())
2009-08-16 16:30:56 +00:00
{
$link = " " ;
2015-04-01 23:01:04 -07:00
$id = substr ( $row [ 'menu_path' ], 0 , - 1 );
if ( file_exists ( e_PLUGIN . " { $row [ 'menu_path' ] } { $row [ 'menu_name' ] } _menu_config.php " ))
{
$link = $row [ 'menu_path' ] . $row [ 'menu_name' ] . " _menu_config.php " ;
}
2009-08-16 16:30:56 +00:00
2015-04-01 23:01:04 -07:00
if ( $row [ 'menu_path' ] == 'news/' )
2009-08-16 16:30:56 +00:00
{
2015-04-01 23:01:04 -07:00
$row [ 'menu_path' ] = " blogcalendar_menu/ " ;
2009-08-16 16:30:56 +00:00
}
2015-04-01 23:01:04 -07:00
if ( file_exists ( e_PLUGIN . $row [ 'menu_path' ] . " config.php " ))
2009-08-16 16:30:56 +00:00
{
2015-04-01 23:01:04 -07:00
$link = $row [ 'menu_path' ] . " config.php " ;
2009-08-16 16:30:56 +00:00
}
2015-04-01 23:01:04 -07:00
2009-08-16 16:30:56 +00:00
if ( $link )
{
2015-04-01 23:01:04 -07:00
$tmp [ $id ][ 'name' ] = ucwords ( str_replace ( $search , " " , $row [ 'menu_name' ])); // remove _
if ( vartrue ( $prev ) == $id && ( $tmp [ $id ][ 'name' ] != $prev_name ))
2009-08-16 16:30:56 +00:00
{
$tmp [ $id ][ 'name' ] .= " : " . $prev_name ;
}
$tmp [ $id ][ 'link' ] = $link ;
$prev = $id ;
2015-04-01 23:01:04 -07:00
2009-08-16 16:30:56 +00:00
$prev_name = $tmp [ $id ][ 'name' ];
}
}
2012-12-08 15:52:40 +01:00
$pref [ 'menuconfig_list' ] = vartrue ( $tmp );
2014-01-15 02:56:39 -08:00
e107 :: getConfig () -> setPref ( $pref ) -> save ( false , true , false );
2015-04-01 23:01:04 -07:00
2009-08-16 16:30:56 +00:00
}
2014-03-19 12:37:44 +02:00
} // end of Class.