summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlsces <lester@lsces.co.uk>2025-08-27 17:12:13 +0100
committerlsces <lester@lsces.co.uk>2025-08-27 17:12:13 +0100
commit72ad9a9e51db8f54eae01991d6905db6b4306c19 (patch)
treef5a82fb5772c418712f58462d11d08b04ce84a2e
parentda8147a0536f1f5189afd03a996359d32b98ba65 (diff)
downloadnexus-72ad9a9e51db8f54eae01991d6905db6b4306c19.tar.gz
nexus-72ad9a9e51db8f54eae01991d6905db6b4306c19.tar.bz2
nexus-72ad9a9e51db8f54eae01991d6905db6b4306c19.zip
Code updated to PHP8.4 and namespace
-rwxr-xr-x[-rw-r--r--]admin/admin_nexus_inc.php2
-rwxr-xr-x[-rw-r--r--]admin/schema_inc.php24
-rw-r--r--admin/upgrade_inc.php32
-rwxr-xr-x[-rw-r--r--]includes/bit_setup_inc.php31
-rwxr-xr-x[-rw-r--r--]includes/classes/Nexus.php (renamed from Nexus.php)272
-rwxr-xr-x[-rw-r--r--]includes/classes/NexusSystem.php (renamed from NexusSystem.php)9
-rwxr-xr-x[-rw-r--r--]includes/menu_lookup_inc.php (renamed from menu_lookup_inc.php)12
-rwxr-xr-x[-rw-r--r--]includes/servicefunctions_inc.php (renamed from servicefunctions_inc.php)15
-rwxr-xr-x[-rw-r--r--]index.php1
-rwxr-xr-x[-rw-r--r--]menu_items.php35
-rwxr-xr-x[-rw-r--r--]menu_sort.php10
-rwxr-xr-x[-rw-r--r--]menus.php34
-rwxr-xr-x[-rw-r--r--]plugins/menu.formelements.php18
-rwxr-xr-x[-rw-r--r--]plugins/menu.suckerfish.php19
-rwxr-xr-x[-rw-r--r--]plugins/menu.tikiwiki.php20
-rw-r--r--templates/menu_nexus.tpl2
-rw-r--r--templates/menu_nexus_admin.tpl2
17 files changed, 255 insertions, 283 deletions
diff --git a/admin/admin_nexus_inc.php b/admin/admin_nexus_inc.php
index 40c5812..39ffb04 100644..100755
--- a/admin/admin_nexus_inc.php
+++ b/admin/admin_nexus_inc.php
@@ -4,7 +4,7 @@ require_once( NEXUS_PKG_PATH.'Nexus.php');
$gNexus = new Nexus();
$gNexusSystem->scanAllPlugins( NEXUS_PKG_PATH.'plugins/' );
-$feedback = array();
+$feedback = [];
if( !empty( $_REQUEST['rewrite_cache'] ) ) {
if( $gNexus->rewriteMenuCache() ) {
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
index 13a7a07..fe85df5 100644..100755
--- a/admin/schema_inc.php
+++ b/admin/schema_inc.php
@@ -1,6 +1,6 @@
<?php
-$tables = array(
+$tables = [
'nexus_menus' => "
menu_id I4 AUTO PRIMARY,
plugin_guid C(16) NOTNULL,
@@ -22,7 +22,7 @@ $tables = array(
rsrc_type C(16),
perm C(128)
",
-);
+];
global $gBitInstaller;
@@ -30,20 +30,18 @@ foreach( array_keys( $tables ) AS $tableName ) {
$gBitInstaller->registerSchemaTable( NEXUS_PKG_NAME, $tableName, $tables[$tableName] );
}
-$gBitInstaller->registerPackageInfo( NEXUS_PKG_NAME, array(
+$gBitInstaller->registerPackageInfo( NEXUS_PKG_NAME, [
'description' => 'Nexus allows you to create multi level menus using a simple and intuitive interface. Menus can be of a dropdown style using css.',
'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>',
-) );
+] );
// ### Default UserPermissions
-$gBitInstaller->registerUserPermissions( NEXUS_PKG_NAME, array(
- array('p_nexus_insert_item', 'Can insert menu item in a menu while editing a page', 'registered', NEXUS_PKG_NAME),
- array('p_nexus_create_menus', 'Can create new menus using Nexus', 'editors', NEXUS_PKG_NAME),
-) );
+$gBitInstaller->registerUserPermissions( NEXUS_PKG_NAME, [
+ [ 'p_nexus_insert_item', 'Can insert menu item in a menu while editing a page', 'registered', NEXUS_PKG_NAME],
+ [ 'p_nexus_create_menus', 'Can create new menus using Nexus', 'editors', NEXUS_PKG_NAME],
+] );
// ### Default Preferences
-$gBitInstaller->registerPreferences( NEXUS_PKG_NAME, array(
- array( NEXUS_PKG_NAME, 'nexus_menu_text', 'Menus' ),
-) );
-
-?>
+$gBitInstaller->registerPreferences( NEXUS_PKG_NAME, [
+ [ NEXUS_PKG_NAME, 'nexus_menu_text', 'Menus' ],
+] );
diff --git a/admin/upgrade_inc.php b/admin/upgrade_inc.php
deleted file mode 100644
index d649c4f..0000000
--- a/admin/upgrade_inc.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-global $gBitSystem, $gUpgradeFrom, $gUpgradeTo;
-
-$upgrades = array(
-
- 'BWR1' => array(
- 'BWR2' => array(
-// de-tikify tables
-array( 'DATADICT' => array(
- array( 'DROPTABLE' => array(
- 'tiki_nexus_plugins'
- )),
- array( 'RENAMETABLE' => array(
- 'tiki_nexus_menus' => 'nexus_menus',
- 'tiki_nexus_menu_items' => 'nexus_menu_items',
- )),
- array( 'RENAMECOLUMN' => array(
- 'nexus_menus' => array(
- '`type`' => '`menu_type` C(16)'
- ),
- )),
-)),
-
- )
- ),
-);
-
-if( isset( $upgrades[$gUpgradeFrom][$gUpgradeTo] ) ) {
- $gBitSystem->registerUpgrade( NEXUS_PKG_NAME, $upgrades[$gUpgradeFrom][$gUpgradeTo] );
-}
-?>
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php
index 8914323..4faf129 100644..100755
--- a/includes/bit_setup_inc.php
+++ b/includes/bit_setup_inc.php
@@ -5,29 +5,41 @@
* @package Nexus
* @subpackage functions
*/
+use Bitweaver\Nexus\NexusSystem;
+
global $gBitSystem, $gBitUser, $gLibertySystem, $gBitThemes;
-$registerHash = array(
+$pRegisterHash = [
'package_name' => 'nexus',
'package_path' => dirname( dirname( __FILE__ ) ).'/',
'service' => LIBERTY_SERVICE_MENU,
-);
-$gBitSystem->registerPackage( $registerHash );
+];
+
+// fix to quieten down VS Code which can't see the dynamic creation of these ...
+define( 'NEXUS_PKG_NAME', $pRegisterHash['package_name'] );
+define( 'NEXUS_PKG_URL', BIT_ROOT_URL . basename( $pRegisterHash['package_path'] ) . '/' );
+define( 'NEXUS_PKG_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/' );
+define( 'NEXUS_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/');
+define( 'NEXUS_PKG_CLASS_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/classes/');
+define( 'NEXUS_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/');
+
+$gBitSystem->registerPackage( $pRegisterHash );
if( $gBitSystem->isPackageActive( 'nexus' ) ) {
// load nexus plugins
- require_once( NEXUS_PKG_PATH.'NexusSystem.php' );
+
global $gNexusSystem;
$gNexusSystem = new NexusSystem();
+
if( !$gBitSystem->isFeatureActive( NEXUS_PKG_NAME.'_plugin_file_suckerfish' ) ) {
$gNexusSystem->scanAllPlugins( NEXUS_PKG_PATH.'plugins/' );
} else {
$gNexusSystem->loadActivePlugins();
}
- $gBitSmarty->assignByRef( 'gNexusSystem', $gNexusSystem );
+ $gBitSmarty->assign( 'gNexusSystem', $gNexusSystem );
// include service functions
- require_once( NEXUS_PKG_INCLUDE_PATH.'servicefunctions_inc.php' );
+ require_once NEXUS_PKG_INCLUDE_PATH.'servicefunctions_inc.php';
$gLibertySystem->registerService( LIBERTY_SERVICE_MENU, NEXUS_PKG_NAME, array(
'content_store_function' => 'nexus_content_store',
@@ -37,21 +49,20 @@ if( $gBitSystem->isPackageActive( 'nexus' ) ) {
) );
if( $gBitUser->hasPermission( 'p_nexus_create_menus' ) ) {
- $menuHash = array(
+ $menuHash = [
'package_name' => NEXUS_PKG_NAME,
'index_url' => NEXUS_PKG_URL.'index.php',
'menu_template' => 'bitpackage:nexus/menu_nexus.tpl',
- );
+ ];
$gBitSystem->registerAppMenu( $menuHash );
}
if( is_dir( TEMP_PKG_PATH.'nexus/modules/' ) ) {
// make sure the template knows about the custom top bar
if( is_file( TEMP_PKG_PATH.'nexus/modules/top_bar_inc.tpl' ) ) {
- $gBitSmarty->assign( 'use_custom_top_bar', TRUE );
+ $gBitSmarty->assign( 'use_custom_top_bar', true );
}
}
$gBitThemes->loadCss( NEXUS_PKG_PATH.'css/nexus.css' );
}
-?>
diff --git a/Nexus.php b/includes/classes/Nexus.php
index ba532ba..f688590 100644..100755
--- a/Nexus.php
+++ b/includes/classes/Nexus.php
@@ -11,7 +11,12 @@
/**
* required setup
*/
-require_once( NEXUS_PKG_PATH.'NexusSystem.php' );
+namespace Bitweaver\Nexus;
+use Bitweaver\BitBase;
+use Bitweaver\Fisheye\FisheyeGallery;
+use Bitweaver\Liberty\LibertyStructure;
+use Bitweaver\KernelTools;
+use Bitweaver\Themes\BitweaverExtension;
/**
* @package nexus
@@ -25,38 +30,38 @@ class Nexus extends NexusSystem {
/**
* Initialisation of this class
*/
- function Nexus( $pMenuId=NULL ) {
+ public function Nexus( $pMenuId=null ) {
parent::__construct();
$this->mMenuId = $pMenuId;
// if the cache folder doesn't exist yet, create it
if( !is_dir( TEMP_PKG_PATH.NEXUS_PKG_NAME.'/modules' ) ) {
- mkdir_p( TEMP_PKG_PATH.NEXUS_PKG_NAME.'/modules' );
+ KernelTools::mkdir_p( TEMP_PKG_PATH.NEXUS_PKG_NAME.'/modules' );
}
}
/**
* Load the menu
*/
- function load() {
- if( @BitBase::verifyId( $this->mMenuId ) ) {
+ public function load() {
+ if( BitBase::verifyId( $this->mMenuId ) ) {
$this->mInfo = $this->getMenu( $this->mMenuId );
$this->mInfo['items'] = $this->getItemList( $this->mMenuId );
$this->mInfo['tree'] = $this->createMenuTree( $this->mInfo['items'] );
}
- return( count( $this->mInfo ) );
+ return count( $this->mInfo );
}
/**
* Get menu information from database
* @param $pMenuId menu id of the menu we want information from
*/
- function getMenu( $pMenuId=NULL ) {
- $ret = array();
- if( !@BitBase::verifyId( $pMenuId ) && $this->isValid() ) {
+ public function getMenu( $pMenuId=null ) {
+ $ret = [];
+ if( !BitBase::verifyId( $pMenuId ) && $this->isValid() ) {
$pMenuId = $this->mMenuId;
}
- $bindVars = array();
+ $bindVars = [];
$query = 'SELECT nm.* FROM `'.BIT_DB_PREFIX.'nexus_menus` nm';
if( is_numeric( $pMenuId ) ) {
$query .= ' WHERE nm.`menu_id`=?';
@@ -75,8 +80,8 @@ class Nexus extends NexusSystem {
* Get menu information from database
* @param $pMenuId menu id of the menu we want information from
*/
- function getMenuList( $pFindString=NULL, $pSortMode=NULL, $pOffset=NULL, $pMaxRows=NULL ) {
- $bindVars = array();
+ public function getMenuList( $pFindString=null, $pSortMode=null, $pOffset=null, $pMaxRows=null ) {
+ $bindVars = [];
$mid = '';
if( $pFindString ) {
$mid .= " WHERE UPPER(nm.`title`) LIKE ? ";
@@ -87,13 +92,12 @@ class Nexus extends NexusSystem {
}
$query = 'SELECT nm.`menu_id` FROM `'.BIT_DB_PREFIX.'nexus_menus` nm'.$mid;
- if( $pMaxRows && is_numeric( $pMaxRows ) ) {
- $result = $this->mDb->query( $query, $bindVars, $pOffset, $pMaxRows );
- } else {
- $result = $this->mDb->query( $query, $bindVars );
- }
+ $result = $pMaxRows && is_numeric( $pMaxRows )
+ ? $this->mDb->query( $query, $bindVars, $pOffset, $pMaxRows )
+ : $this->mDb->query( $query, $bindVars );
+
$menuIds = $result->getRows();
- $menus = array();
+ $menus = [];
foreach( $menuIds as $menuId ) {
$tmpMenu = new Nexus( $menuId['menu_id'] );
$tmpMenu->load();
@@ -107,10 +111,10 @@ class Nexus extends NexusSystem {
* Create usable menu tree
* @param $pMenuHash full menu as supplied by '$this->getItemList( $pMenuId );'
* @param $pStripped if set to true, removes all permissions, user isn't part of
- * @return menu with all menu items sorted with first and last items of each 'level' marked. items that contain siblings are marked with 'head' = TRUE;
+ * @return array menu with all menu items sorted with first and last items of each 'level' marked. items that contain siblings are marked with 'head' = true;
*/
- function createMenuTree( $pMenuHash, $pStripped=FALSE, $parent_id=0, $pForceBuild=FALSE ) {
- $ret = array();
+ public function createMenuTree( $pMenuHash, $pStripped=false, $parent_id=0, $pForceBuild=false ) {
+ $ret = [];
if( $pForceBuild || $this->isValid() && empty( $this->mInfo['tree'] )) {
if( $pStripped && $parent_id == 0 ) {
$pMenuHash = $this->checkUserPermission( $pMenuHash );
@@ -121,27 +125,27 @@ class Nexus extends NexusSystem {
$row_max = count( $children );
foreach( $children as $item ) {
$aux = $item;
- $aux['first'] = ( $pos == 1 );
- $aux['last'] = FALSE;
- $aux['head'] = FALSE;
+ $aux['first'] = $pos == 1;
+ $aux['last'] = false;
+ $aux['head'] = false;
$ret[] = $aux;
//Recursively add any children
- $subs = $this->createMenuTree( $pMenuHash, $pStripped, $item['item_id'], TRUE );
+ $subs = $this->createMenuTree( $pMenuHash, $pStripped, $item['item_id'], true );
if( !empty( $subs ) ) {
// mark items that have children
$row_last = count( $ret );
- $ret[$row_last - 1]['head'] = TRUE;
+ $ret[$row_last - 1]['head'] = true;
$ret = array_merge( $ret, $subs );
}
if( $pos == $row_max ) {
- if( @BitBase::verifyId( $item['parent_id'] ) ) {
- $tmpItem = $this->getItemList( NULL, $item['parent_id'] );
+ if( BitBase::verifyId( $item['parent_id'] ) ) {
+ $tmpItem = $this->getItemList( null, $item['parent_id'] );
$aux = $tmpItem[$item['parent_id']];
} else {
$aux['item_id'] = $item['item_id'];
}
- $aux['first'] = FALSE;
- $aux['last'] = TRUE;
+ $aux['first'] = false;
+ $aux['last'] = true;
$ret[] = $aux;
}
$pos++;
@@ -155,11 +159,11 @@ class Nexus extends NexusSystem {
/**
* Strip out all items a user doesn't have permission to view
* @param $pMenuHash full menu as supplied by '$this->getItemList( $pMenuId );'
- * @return menu containing only items user is allowed to view
+ * @return array menu containing only items user is allowed to view
*/
- function checkUserPermission( $pMenuHash ) {
+ public function checkUserPermission( $pMenuHash ) {
global $gBitUser;
- $ret = array();
+ $ret = [];
foreach( $pMenuHash as $item ) {
if( !empty( $item['perm'] ) ) {
if( $gBitUser->hasPermission( $item['perm'] ) ) {
@@ -177,8 +181,8 @@ class Nexus extends NexusSystem {
* @param $pMenuHash full menu as supplied by '$this->getItemList( $pMenuId );'
* @return array of items with a given parent_id
*/
- function getChildItems( $pMenuHash, $parent_id=0 ) {
- $ret = array();
+ public function getChildItems( $pMenuHash, $parent_id=0 ) {
+ $ret = [];
foreach( $pMenuHash as $item ) {
if( $item['parent_id'] == $parent_id ) {
$ret[] = $item;
@@ -189,59 +193,56 @@ class Nexus extends NexusSystem {
/**
* Validate that a menu is being loaded and present
- * @return TRUE if all is ok
+ * @return true if all is ok
*/
- function isValid() {
- return( BitBase::verifyId( $this->mMenuId ) );
+ public function isValid() {
+ return BitBase::verifyId( $this->mMenuId );
}
/**
* Check if all required items are present for menu creation / insertion
* @return number of errors encountered
*/
- function verifyMenu( &$pParamHash ) {
+ public function verifyMenu( &$pParamHash ) {
if( empty( $pParamHash['title'] ) ) {
- $this->mErrors['verify_title'] = tra( 'Could not store menu because no title was given.' );
+ $this->mErrors['verify_title'] = KernelTools::tra( 'Could not store menu because no title was given.' );
}
if( empty( $pParamHash['description'] ) ) {
- $pParamHash['description'] = NULL;
+ $pParamHash['description'] = null;
}
// set the default plugin_guid to suckerfish menus
if( empty( $pParamHash['plugin_guid'] ) ) {
$pParamHash['plugin_guid'] = NEXUS_PLUGIN_GUID_SUCKERFISH;
}
$type_name = 'type_' . $pParamHash['plugin_guid'];
- if ( empty( $pParamHash[$type_name] )) {
- $pParamHash['menu_type'] = 'nor';
- }
- else {
- $pParamHash['menu_type'] = $pParamHash[$type_name];
- }
+ $pParamHash['menu_type'] = $pParamHash[$type_name] ?? 'nor';
+
if( empty( $pParamHash['editable'][0] ) || !is_numeric( $pParamHash['editable'][0] ) ) {
$pParamHash['editable'][0] = 0;
}
$pParamHash['editable'] = $pParamHash['editable'][0];
- return( count( $this->mErrors ) == 0 );
+ return count( $this->mErrors ) == 0;
}
/**
* Store menu in db
- * @param menu_id if set, will update given menu - if not set, we create a new entry in the db
- * @param title title of menu
- * @param description description of menu
- * @param menu_type type of menu
- * @param editable if menu is editable by other users - takes 0 or 1
- * @return new menu menu_id or FALSE if not created
+ * @param array hash of values
+ * @var int menu_id if set, will update given menu - if not set, we create a new entry in the db
+ * @var string title title of menu
+ * @var string description description of menu
+ * @var string menu_type type of menu
+ * @var bool editable if menu is editable by other users - takes 0 or 1
+ * @return int|bool new menu menu_id or false if not created
*/
- function storeMenu( &$pParamHash ) {
- $ret = FALSE;
+ public function storeMenu( &$pParamHash ) {
+ $ret = false;
if( $this->verifyMenu( $pParamHash ) ) {
$this->mDb->StartTrans();
- if( !@BitBase::verifyId( $pParamHash['menu_id'] ) ) {
+ if( !BitBase::verifyId( $pParamHash['menu_id'] ?? 0 ) ) {
$query = "INSERT INTO `".BIT_DB_PREFIX."nexus_menus`( `title`,`description`,`menu_type`,`plugin_guid`,`editable` ) VALUES(?,?,?,?,?)";
$result = $this->mDb->query( $query, array( $pParamHash['title'], $pParamHash['description'], $pParamHash['menu_type'], $pParamHash['plugin_guid'], $pParamHash['editable'] ) );
$query = "SELECT MAX(`menu_id`) FROM `".BIT_DB_PREFIX."nexus_menus`";
- $ret = $this->mDb->getOne( $query, array() );
+ $ret = $this->mDb->getOne( $query, [] );
} else {
$query = "UPDATE `".BIT_DB_PREFIX."nexus_menus` SET `title`=?,`description`=?,`menu_type`=?,`plugin_guid`=?,`editable`=? WHERE `".BIT_DB_PREFIX."nexus_menus`.`menu_id`=?";
$result = $this->mDb->query( $query, array( $pParamHash['title'], $pParamHash['description'], $pParamHash['menu_type'], $pParamHash['plugin_guid'], $pParamHash['editable'], $pParamHash['menu_id'] ) );
@@ -250,7 +251,7 @@ class Nexus extends NexusSystem {
$this->mDb->CompleteTrans();
$this->writeMenuCache( $ret );
} else {
- error_log( "Error storing menu: " . vc($this->mErrors) );
+ error_log( "Error storing menu: " . \Bitweaver\vc($this->mErrors) );
}
return $ret;
}
@@ -259,7 +260,7 @@ class Nexus extends NexusSystem {
* Delete menu and associated menu items from db
* @return number of errors encountered
*/
- function expungeMenu( $pMenuId ) {
+ public function expungeMenu( $pMenuId ) {
// first off, remove the menu from the layout
global $gBitThemes, $gBitSystem;
$menu = $this->getMenu( $this->mMenuId );
@@ -276,18 +277,18 @@ class Nexus extends NexusSystem {
// rewrite the entire cache, just to make sure everything is in order
$this->rewriteMenuCache();
- return( count( $this->mErrors ) == 0 );
+ return count( $this->mErrors ) == 0;
}
/**
* Get menu items from the database
* @param $pItemId ID of menu item to get. if set, we only get this item.
* @param $pMenuId ID of menu to get
- * @return all menu items with a given menu ID
+ * @return array all menu items with a given menu ID
*/
- function getItemList( $pMenuId=NULL, $pItemId=NULL ) {
- $bindVars = array();
- $ret = array();
+ public function getItemList( $pMenuId=null, $pItemId=null ) {
+ $bindVars = [];
+ $ret = [];
$query = 'SELECT nmi.* FROM `'.BIT_DB_PREFIX.'nexus_menu_items` nmi';
if( is_numeric( $pItemId ) ) {
$query .= ' WHERE nmi.`item_id`=?';
@@ -323,12 +324,12 @@ class Nexus extends NexusSystem {
/**
* Create the correct url for a given item
* @param $pItemHash complete item hash
- * @return url
+ * @return string url
*/
- function printUrl( $pItemHash ) {
+ public function printUrl( $pItemHash ) {
global $gLibertySystem, $gBitSystem;
$contentTypes = $gLibertySystem->mContentTypes;
- $ret = NULL;
+ $ret = null;
if( isset( $pItemHash['rsrc'] ) && isset( $pItemHash['rsrc_type'] )) {
switch( $pItemHash['rsrc_type'] ) {
@@ -346,7 +347,7 @@ class Nexus extends NexusSystem {
$type = &$contentTypes[$row['content_type_guid']];
if( empty( $type['content_object'] )) {
- include_once( $gBitSystem->mPackages[$type['handler_package']]['path'].$type['handler_file'] );
+ include_once $gBitSystem->mPackages[$type['handler_package']]['path'].$type['handler_file'];
$type['content_object'] = new $type['handler_class']();
}
@@ -365,9 +366,9 @@ class Nexus extends NexusSystem {
/**
* Verify rsrc handed to us and specify what type it is
- * @return fixed rsrc and corresponding rsrc_type
+ * @return void fixed rsrc and corresponding rsrc_type
*/
- function verifyRsrc( &$pParamHash ) {
+ public function verifyRsrc( &$pParamHash ) {
// if we have something like http:// or ftp:// in the url, we know it's external
if( preg_match( "/^([a-zA-Z]{2,8}:\/\/)/i", $pParamHash['rsrc'] ) ) {
$pParamHash['rsrc_type'] = 'external';
@@ -390,25 +391,25 @@ class Nexus extends NexusSystem {
* Verify if a given menu item contains all required information and prepare menu_items table for item insertion.
* @return number of errors encountered
*/
- function verifyItem( &$pParamHash ) {
- if( empty( $pParamHash['hint'] ) ) { $pParamHash['hint'] = NULL; }
- if( empty( $pParamHash['perm'] ) ) { $pParamHash['perm'] = NULL; }
+ public function verifyItem( &$pParamHash ) {
+ if( empty( $pParamHash['hint'] ) ) { $pParamHash['hint'] = null; }
+ if( empty( $pParamHash['perm'] ) ) { $pParamHash['perm'] = null; }
if( empty( $pParamHash['title'] ) ) {
- $this->mErrors['verify_item_title'] = tra( 'Could not store menu item. No item title was given.' );
+ $this->mErrors['verify_item_title'] = KernelTools::tra( 'Could not store menu item. No item title was given.' );
}
- if( !@BitBase::verifyId( $pParamHash['menu_id'] ) ) {
- $this->mErrors['verify_menu_id'] = tra( 'Could not store menu item. Invalid menu id. Menu id ' ).': '.$pParamHash['menu_id'];
+ if( !BitBase::verifyId( $pParamHash['menu_id'] ?? 0 ) ) {
+ $this->mErrors['verify_menu_id'] = KernelTools::tra( 'Could not store menu item. Invalid menu id. Menu id ' ).': '.$pParamHash['menu_id'];
} else {
$this->mDb->StartTrans();
- if( !@BitBase::verifyId( $pParamHash['parent_id'] ) ) {
+ if( !BitBase::verifyId( $pParamHash['parent_id'] ?? 0 ) ) {
$pParamHash['parent_id'] = 0;
// if no parent_id is not known, but we have an after_ref_id, we use that to work out the parent_id
- if( @BitBase::verifyId( $pParamHash['after_ref_id'] ) ) {
+ if( BitBase::verifyId( $pParamHash['after_ref_id'] ?? 0 ) ) {
$pParamHash['parent_id'] = $this->mDb->getOne("SELECT `parent_id` FROM `".BIT_DB_PREFIX."nexus_menu_items` WHERE `item_id`=?", array( (int)$pParamHash['after_ref_id'] ) );
}
}
$pParamHash['max'] = 0;
- if( @BitBase::verifyId( $pParamHash['after_ref_id'] ) ) {
+ if( BitBase::verifyId( $pParamHash['after_ref_id'] ?? 0 ) ) {
$pParamHash['max'] = $this->mDb->getOne("SELECT `pos` FROM `".BIT_DB_PREFIX."nexus_menu_items` WHERE `item_id`=?", array( (int)$pParamHash['after_ref_id'] ) );
if( $pParamHash['max'] > 0 ) {
//If max is 5 then we are inserting after position 5 so we'll insert 5 and move all the others
@@ -419,36 +420,37 @@ class Nexus extends NexusSystem {
$this->mDb->CompleteTrans();
$pParamHash['max']++;
// if we get passed the position of where the item is to go, we pass it to 'max' -- used for importStructure()
- if( @BitBase::verifyId( $pParamHash['pos'] ) && !@BitBase::verifyId( $pParamHash['after_ref_id'] ) ) {
+ if( BitBase::verifyId( $pParamHash['pos'] ?? 0 ) && !BitBase::verifyId( $pParamHash['after_ref_id'] ?? 0 ) ) {
$pParamHash['max'] = $pParamHash['pos'];
}
// work out what type of rsrc was passed in and fix
if( !empty( $pParamHash['rsrc'] ) ) {
$this->verifyRsrc( $pParamHash );
} else {
- $pParamHash['rsrc'] = NULL;
- $pParamHash['rsrc_type'] = NULL;
+ $pParamHash['rsrc'] = null;
+ $pParamHash['rsrc_type'] = null;
}
}
- return( count( $this->mErrors ) == 0 );
+ return count( $this->mErrors ) == 0;
}
/**
* Create a menu item entry
- * @param parent_id The parent entry to add this to. If NULL, create new structure.
- * @param after_ref_id The entry to add this one after. If NULL, put it in position 0.
- * @param title The wiki page to reference
- * @return the new entries item_id or FALSE if not created.
+ * @param array hash of values
+ * @var int parent_id The parent entry to add this to. If null, create new structure.
+ * @var int after_ref_id The entry to add this one after. If null, put it in position 0.
+ * @var string title The wiki page to reference
+ * @return int|bool the new entries item_id or false if not created.
*/
- function storeItem( &$pParamHash ) {
- $ret = FALSE;
+ public function storeItem( &$pParamHash ) {
+ $ret = false;
if ( $this->verifyItem( $pParamHash ) ) {
$this->mDb->StartTrans();
- if( !@BitBase::verifyId( $pParamHash['item_id'] ) ) {
+ if( !BitBase::verifyId( $pParamHash['item_id'] ?? 0 ) ) {
$query = "INSERT INTO `".BIT_DB_PREFIX."nexus_menu_items`( `menu_id`,`parent_id`,`pos`,`title`,`hint`,`rsrc`,`rsrc_type`,`perm` ) VALUES( ?,?,?,?,?,?,?,? )";
$result = $this->mDb->query( $query, array( (int)$pParamHash['menu_id'], (int)$pParamHash['parent_id'], (int)$pParamHash['max'], $pParamHash['title'], $pParamHash['hint'], $pParamHash['rsrc'], $pParamHash['rsrc_type'], $pParamHash['perm'] ) );
$query = "SELECT MAX(`item_id`) FROM `".BIT_DB_PREFIX."nexus_menu_items`";
- $ret = $this->mDb->getOne( $query, array() );
+ $ret = $this->mDb->getOne( $query, [] );
} else {
$query = "UPDATE `".BIT_DB_PREFIX."nexus_menu_items` SET `title`=?, `hint`=?, `rsrc`=?, `rsrc_type`=?, `perm`=? WHERE `item_id`=?";
$result = $this->mDb->query( $query, array( $pParamHash['title'], $pParamHash['hint'], $pParamHash['rsrc'], $pParamHash['rsrc_type'], $pParamHash['perm'], $pParamHash['item_id'] ) );
@@ -457,7 +459,7 @@ class Nexus extends NexusSystem {
$this->mDb->CompleteTrans();
$this->rewriteMenuCache();
} else {
- return( count( $this->mErrors ) == 0 );
+ return count( $this->mErrors ) == 0;
}
return $ret;
}
@@ -465,13 +467,13 @@ class Nexus extends NexusSystem {
/**
* Delete item
* @param $pItemId item to be removed
- * @return deleted item information
+ * @return bool deleted item information
*/
- function expungeItem( $pItemId=NULL, $pWriteCache=TRUE ) {
- if( @BitBase::verifyId( $pItemId ) ) {
+ public function expungeItem( $pItemId=null, $pWriteCache=true ) {
+ if( BitBase::verifyId( $pItemId ) ) {
// get full information of item that we are removing
- $remItem = $this->getItemList( NULL, $pItemId );
- if( @BitBase::verifyId( $remItem[$pItemId]['item_id'] ) ) {
+ $remItem = $this->getItemList( null, $pItemId );
+ if( BitBase::verifyId( $remItem[$pItemId]['item_id'] ) ) {
$remItem = $remItem[$pItemId];
$this->mDb->StartTrans();
// get all items that are on the same level
@@ -504,32 +506,32 @@ class Nexus extends NexusSystem {
}
return $remItem;
} else {
- $this->mErrors['remove_item'] = tra( "There was a problem trying to remove the menu item." );
- return FALSE;
+ $this->mErrors['remove_item'] = KernelTools::tra( "There was a problem trying to remove the menu item." );
+ return false;
}
} else {
- $this->mErrors['remove_item_id'] = tra( "The menu item could not be removed because no valid item id was given." );
- return FALSE;
+ $this->mErrors['remove_item_id'] = KernelTools::tra( "The menu item could not be removed because no valid item id was given." );
+ return false;
}
}
/**
* Remove items to content that has been removed
* @param $pMenuId menu from which we want to remove dead links
- * @return titles of links removed
+ * @return array titles of links removed
* @TODO check for items in structures. if they don't exist there, replace them with the appropriate content id
*/
- function expungeDeadItems( $pMenuId=NULL ) {
+ public function expungeDeadItems( $pMenuId=null ) {
if( isset( $pMenuId ) && is_numeric( $pMenuId ) ) {
// get $contentList
- include_once( LIBERTY_PKG_INCLUDE_PATH.'get_content_list_inc.php' );
+ include_once LIBERTY_PKG_INCLUDE_PATH.'get_content_list_inc.php';
foreach( $contentList as $contentItem ) {
$contentIds[] = $contentItem['content_id'];
}
- $deathList = FALSE;
+ $deathList = [];
foreach( $this->mInfo['items'] as $item ) {
if( $item['rsrc_type'] == 'content_id' && !in_array( $item['rsrc'], $contentIds ) ) {
- $this->expungeItem( $item['item_id'], FALSE );
+ $this->expungeItem( $item['item_id'], false );
$deathList[] = $item['title'];
}
}
@@ -542,7 +544,7 @@ class Nexus extends NexusSystem {
* Move item west
* @param $pItemId item id of item to be moved
*/
- function moveItemWest( $pItemId=NULL ) {
+ public function moveItemWest( $pItemId=null ) {
if( $this->isValid() && $pItemId ) {
// pass current item into managable array
$item = $this->mInfo["items"][$pItemId];
@@ -551,7 +553,7 @@ class Nexus extends NexusSystem {
$parentItem = $this->getItemList( $this->mMenuId, (int)$item["parent_id"] );
$parentItem = $parentItem[$item["parent_id"]];
$this->mDb->StartTrans();
- if( !@BitBase::verifyId( $parentItem["parent_id"] ) ) {
+ if( !BitBase::verifyId( $parentItem["parent_id"] ) ) {
$max_row = $this->mDb->getOne("SELECT `pos` FROM `".BIT_DB_PREFIX."nexus_menu_items` WHERE `item_id`=?", array( $item['parent_id'] ) );
$parent_item['pos'] = $max_row;
$parent_item['parent_id'] = 0;
@@ -572,7 +574,7 @@ class Nexus extends NexusSystem {
* Move item east
* @param $pItemId item id of item to be moved
*/
- function moveItemEast( $pItemId=NULL ) {
+ public function moveItemEast( $pItemId=null ) {
if( $this->isValid() && $pItemId ) {
// pass current item into managable array
$item = $this->mInfo["items"][$pItemId];
@@ -583,11 +585,7 @@ class Nexus extends NexusSystem {
//Get last child item for previous sibling
$query = "SELECT `pos` FROM `".BIT_DB_PREFIX."nexus_menu_items` WHERE `parent_id`=? AND `menu_id`=? ORDER BY `pos` DESC";
$result = $this->mDb->query( $query, array( (int)$previous["item_id"], (int)$item["menu_id"] ) );
- if( $res = $result->fetchRow() ) {
- $pos = $res["pos"];
- } else {
- $pos = 0;
- }
+ $pos = ( $res = $result->fetchRow() ) ? $res["pos"] : 0;
$query = "UPDATE `".BIT_DB_PREFIX."nexus_menu_items` SET `parent_id`=?, `pos`=(? + 1) WHERE `item_id`=?";
$this->mDb->query( $query, array( (int)$previous["item_id"], (int)$pos, (int)$item["item_id"] ) );
//Move items up below that had previous parent and pos
@@ -603,7 +601,7 @@ class Nexus extends NexusSystem {
* Move item south
* @param $pItemId item id of item to be moved
*/
- function moveItemSouth( $pItemId=NULL ) {
+ public function moveItemSouth( $pItemId=null ) {
if( $this->isValid() && $pItemId ) {
// pass current item into managable array
$item = $this->mInfo["items"][$pItemId];
@@ -625,7 +623,7 @@ class Nexus extends NexusSystem {
* Move item north
* @param $pItemId item id of item to be moved
*/
- function moveItemNorth( $pItemId=NULL ) {
+ public function moveItemNorth( $pItemId=null ) {
if( $this->isValid() && $pItemId ) {
// pass current item into managable array
$item = $this->mInfo["items"][$pItemId];
@@ -647,15 +645,15 @@ class Nexus extends NexusSystem {
* Imports a structure from liberty_structures to nexus including hierarchy
* @return number of errors encountered
*/
- function importStructure( $pStructureId=NULL ) {
+ public function importStructure( $pStructureId=null ) {
if( $pStructureId || !is_numeric( $pStructureId ) ) {
- include_once( LIBERTY_PKG_CLASS_PATH.'LibertyStructure.php');
+
$structure = new LibertyStructure( $pStructureId );
$structure->load();
// order matters for these conditionals
if( empty( $structure ) || !$structure->isValid() ) {
- $this->mErrors['structure'] = tra( 'Invalid structure' );
+ $this->mErrors['structure'] = KernelTools::tra( 'Invalid structure' );
}
if( $structure->mInfo['root_structure_id'] == $structure->mInfo['structure_id'] ) {
@@ -683,7 +681,7 @@ class Nexus extends NexusSystem {
if( $structureItem['first'] ) {
// get id of the current item
$query = "SELECT MAX(`item_id`) FROM `".BIT_DB_PREFIX."nexus_menu_items`";
- $parentPath[] = $this->mDb->getOne( $query, array() );
+ $parentPath[] = $this->mDb->getOne( $query, [] );
$parent_id = end( $parentPath );
}
if( $structureItem['last'] ) {
@@ -698,19 +696,19 @@ class Nexus extends NexusSystem {
'title' => $structureItem['title'],
'pos' => $tmpItem['pos'],
'parent_id' => $parent_id,
- 'rsrc' => isset( $structureItem['structure_id'] ) ? $structureItem['structure_id'] : NULL,
+ 'rsrc' => isset( $structureItem['structure_id'] ) ? $structureItem['structure_id'] : null,
'rsrc_type' => 'structure_id'
);
$storedItem = $this->storeItem( $itemHash );
}
}
} else {
- $this->mErrors['store_menu'] = tra( 'The menu could not be stored.' );
+ $this->mErrors['store_menu'] = KernelTools::tra( 'The menu could not be stored.' );
}
} else {
- $this->mErrors['structure_id'] = tra( 'No valid structure id was given.' );
+ $this->mErrors['structure_id'] = KernelTools::tra( 'No valid structure id was given.' );
}
- return( count( $this->mErrors ) == 0 );
+ return count( $this->mErrors ) == 0;
}
/**
@@ -718,7 +716,7 @@ class Nexus extends NexusSystem {
* @param $pMenuId menu id of the menu for which we want to create a cache file
* @return number of errors encountered
*/
- function rewriteMenuCache() {
+ public function rewriteMenuCache() {
if( is_dir( $path = TEMP_PKG_PATH.NEXUS_PKG_NAME.'/modules' ) ) {
$handle = opendir( $path );
while( false!== ( $cache_file = readdir( $handle ) ) ) {
@@ -735,9 +733,9 @@ class Nexus extends NexusSystem {
}
}
} else {
- $this->mErrors['chache_rewrite'] = tra( "The cache directory for nexus menus doesn't exist." );
+ $this->mErrors['chache_rewrite'] = KernelTools::tra( "The cache directory for nexus menus doesn't exist." );
}
- return( count( $this->mErrors ) == 0 );
+ return count( $this->mErrors ) == 0;
}
/**
@@ -745,8 +743,8 @@ class Nexus extends NexusSystem {
* @param $pMenuId menu id of the menu for which we want to create a cache file
* @return number of errors encountered
*/
- function writeMenuCache( $pMenuId=NULL ) {
- if( $this->isValid() && !@BitBase::verifyId( $pMenuId )) {
+ public function writeMenuCache( $pMenuId=null ) {
+ if( $this->isValid() && !BitBase::verifyId( $pMenuId )) {
$pMenuId = $this->mInfo['menu_id'];
}
@@ -768,26 +766,25 @@ class Nexus extends NexusSystem {
fwrite( $h, $cache_string );
fclose( $h );
} else {
- $this->mErrors['write_module_cache'] = tra( "Unable to write to" ).': '.realpath( $cache_file );
+ $this->mErrors['write_module_cache'] = KernelTools::tra( "Unable to write to" ).': '.realpath( $cache_file );
}
}
} else {
- $this->mErrors['write_module_cache'] = tra( "Unable to write the cache file because there was something wrong with the plugin " ).': '.$cacheMenu->mInfo['plugin_guid'];
+ $this->mErrors['write_module_cache'] = KernelTools::tra( "Unable to write the cache file because there was something wrong with the plugin " ).': '.$cacheMenu->mInfo['plugin_guid'];
}
- return( count( $this->mErrors ) == 0 );
+ return count( $this->mErrors ) == 0;
}
/**
* This is not in use yet. would be good if this could be updated directly from the db
*/
- function getGalleryListMenu( $pParentId=NULL ) {
+ public function getGalleryListMenu( $pParentId=null ) {
global $gBitSystem, $gFisheyeGallery;
- require_once( FISHEYE_PKG_PATH.'FisheyeGallery.php');
$gFisheyeGallery = new FisheyeGallery();
- $hash['root_only'] = TRUE;
- $hash['get_thumbnails'] = FALSE;
+ $hash['root_only'] = true;
+ $hash['get_thumbnails'] = false;
$galleryList = $gFisheyeGallery->getList( $hash );
foreach( $galleryList as $key => $gal ) {
@@ -801,4 +798,3 @@ class Nexus extends NexusSystem {
return $ret;
}
}
-?>
diff --git a/NexusSystem.php b/includes/classes/NexusSystem.php
index 3578492..9c08e3a 100644..100755
--- a/NexusSystem.php
+++ b/includes/classes/NexusSystem.php
@@ -13,7 +13,9 @@
/**
* Setup
*/
-require_once( LIBERTY_PKG_CLASS_PATH.'LibertySystem.php' );
+namespace Bitweaver\Nexus;
+use Bitweaver\Liberty\LibertySystem;
+
define( 'NEXUS_DEFAULT_MENU', 'suckerfish' );
/**
@@ -32,12 +34,11 @@ class NexusSystem extends LibertySystem {
* @access public
* @return void
*/
- function NexusSystem() {
+ public function NexusSystem() {
// Set the package using LibertySystem
$this->mSystem = NEXUS_PKG_NAME;
$this->mPluginPath = NEXUS_PKG_PATH."plugins/";
- parent::__construct( FALSE );
+ parent::__construct( false );
}
}
-?>
diff --git a/menu_lookup_inc.php b/includes/menu_lookup_inc.php
index a122a4e..0781eb6 100644..100755
--- a/menu_lookup_inc.php
+++ b/includes/menu_lookup_inc.php
@@ -7,15 +7,17 @@
*/
global $gNexus;
-if( @BitBase::verifyId( $_REQUEST['menu_id'] ) ) {
+use Bitweaver\Nexus\Nexus;
+use Bitweaver\BitBase;
+
+if( BitBase::verifyId( $_REQUEST['menu_id'] ?? 0 ) ) {
$menuId = $_REQUEST['menu_id'];
$gNexus = new Nexus( $menuId );
} else {
$gNexus = new Nexus();
- $menuId = NULL;
+ $menuId = null;
}
$gNexus -> load();
-$gBitSmarty->assignByRef( 'gNexus', $gNexus );
-$gBitSmarty->assignByRef( 'menuId', $menuId );
-?>
+$gBitSmarty->assign( 'gNexus', $gNexus );
+$gBitSmarty->assign( 'menuId', $menuId );
diff --git a/servicefunctions_inc.php b/includes/servicefunctions_inc.php
index 17bbac1..84d33e6 100644..100755
--- a/servicefunctions_inc.php
+++ b/includes/servicefunctions_inc.php
@@ -6,12 +6,14 @@
* @subpackage functions
*/
+namespace Bitweaver\Nexus;
+
/**
* Nexus edit template service
*/
-function nexus_content_edit( $pObject=NULL ) {
+function nexus_content_edit( $pObject=null ) {
global $gBitSmarty;
- require_once( NEXUS_PKG_PATH.'Nexus.php' );
+
$nexus = new Nexus();
$nexusList = $nexus->getMenuList();
@@ -31,7 +33,7 @@ function nexus_content_edit( $pObject=NULL ) {
* Nexus preview service
* when we hit preview, we make the selections persistent
*/
-function nexus_content_preview( $pObject=NULL ) {
+function nexus_content_preview( $pObject=null ) {
}
/**
@@ -40,22 +42,21 @@ function nexus_content_preview( $pObject=NULL ) {
*/
function nexus_content_store( $pObject, $pParamHash ) {
global $gBitSystem, $gBitUser, $gBitSmarty;
- require_once( NEXUS_PKG_PATH.'Nexus.php' );
+
$nexus = new Nexus();
if( !empty( $pParamHash['content_id'] ) && !empty( $pParamHash['nexus']['menu_id'] ) ) {
$nexusHash['title'] = $pParamHash['content_store']['title'];
- $nexusHash['hint'] = ( !empty( $pParamHash['description'] ) ? $pParamHash['description'] : NULL );
+ $nexusHash['hint'] = !empty( $pParamHash['description'] ) ? $pParamHash['description'] : null;
$nexusHash['menu_id'] = $pParamHash['nexus']['menu_id'];
$nexusHash['after_ref_id'] = $pParamHash['nexus']['after_ref_id'];
$nexusHash['rsrc'] = $pParamHash['content_id'];
$nexusHash['rsrc_type'] = 'content_id';
if( !$nexus->storeItem( $nexusHash ) ) {
- $gBitSystem->fatalError( "There was an error storing the item: ".vc( $nexus->mErrors ));
+ $gBitSystem->fatalError( "There was an error storing the item: ".\Bitweaver\vc( $nexus->mErrors ));
}
$nexus->load();
} elseif( !empty( $pParamHash['nexus']['remove_item'] ) ) {
$nexus->expungeItem( $pParamHash['nexus']['remove_item'] );
}
}
-?>
diff --git a/index.php b/index.php
index d121ea5..f6dbc00 100644..100755
--- a/index.php
+++ b/index.php
@@ -1,3 +1,2 @@
<?php
header("location: menus.php");
-?>
diff --git a/menu_items.php b/menu_items.php
index 81ffce9..4c33b74 100644..100755
--- a/menu_items.php
+++ b/menu_items.php
@@ -9,18 +9,19 @@
/**
* required setup
*/
-require_once( '../kernel/includes/setup_inc.php' );
-require_once( NEXUS_PKG_PATH.'Nexus.php');
-include_once( NEXUS_PKG_INCLUDE_PATH.'menu_lookup_inc.php' );
+namespace Bitweaver\Liberty;
+require_once '../kernel/includes/setup_inc.php';
+use Bitweaver\KernelTools;
+include_once NEXUS_PKG_INCLUDE_PATH.'menu_lookup_inc.php';
$gBitSystem->verifyPermission( 'p_nexus_create_menus' );
if( empty( $_REQUEST['menu_id'] ) ) {
- bit_redirect( NEXUS_PKG_URL.'index.php' );
+ KernelTools::bit_redirect( NEXUS_PKG_URL.'index.php' );
}
// get content and pass it on
-include_once( LIBERTY_PKG_INCLUDE_PATH.'get_content_list_inc.php' );
+include_once LIBERTY_PKG_INCLUDE_PATH.'get_content_list_inc.php';
$gBitSmarty->assign( 'contentSelect', $contentSelect );
$gBitSmarty->assign( 'contentTypes', $contentTypes );
@@ -37,23 +38,23 @@ if( isset( $_REQUEST['store_item'] ) ) {
} else {
$formfeedback['error'] = $gNexus->mErrors;
}
- bit_redirect( NEXUS_PKG_URL.'menu_items.php?menu_id='.$_REQUEST['menu_id'] );
+ KernelTools::bit_redirect( NEXUS_PKG_URL.'menu_items.php?menu_id='.$_REQUEST['menu_id'] );
}
if( isset( $_REQUEST['remove_item'] ) && is_array( $_REQUEST['remove_item'] ) ) {
foreach( $_REQUEST['remove_item'] as $rem_id ) {
- if( $delItem = $gNexus->expungeItem( $rem_id, FALSE ) ) {
+ if( $delItem = $gNexus->expungeItem( $rem_id, false ) ) {
$delList[] = $delItem['title'];
} else {
$formfeedback['error'] = $gNexus->mErrors;
}
}
if( !empty( $delList ) ) {
- $formfeedback['success'] = tra( 'The following items were successfully removed from the menu' ).': ';
+ $formfeedback['success'] = KernelTools::tra( 'The following items were successfully removed from the menu' ).': ';
$gBitSmarty->assign( 'delList', $delList );
}
$gNexus->writeMenuCache();
- bit_redirect( NEXUS_PKG_URL.'menu_items.php?menu_id='.$_REQUEST['menu_id'] );
+ KernelTools::bit_redirect( NEXUS_PKG_URL.'menu_items.php?menu_id='.$_REQUEST['menu_id'] );
}
if( !empty( $_REQUEST['item_id'] ) ) {
@@ -71,11 +72,8 @@ if( isset( $formfeedback ) ) {
}
// get all available perms only when the admin is visiting here.
-if( $gBitUser->isAdmin() ) {
- $tmpPerms = $gBitUser->getGroupPermissions();
-} else {
- $tmpPerms = $gBitUser->mPerms;
-}
+$tmpPerms = $gBitUser->isAdmin() ? $gBitUser->getGroupPermissions() : $gBitUser->mPerms;
+
$perms['no permission'][''] = 'none';
foreach( $tmpPerms as $perm => $info ) {
$perms[$info['package']][$perm] = $perm;
@@ -83,18 +81,18 @@ foreach( $tmpPerms as $perm => $info ) {
$gBitSmarty->assign( 'perms', $perms );
// get a list of available resource types
-$rsrcTypes = array(
+$rsrcTypes = [
'internal' => 'URL',
'external' => 'URL',
'content_id' => 'Content ID',
'structure_id' => 'Structure ID',
//'menu_id' => 'Menu ID',
// 'gallery_list' => 'Gallery List', // this is not in use yet - xing
-);
+];
$gBitSmarty->assign( 'rsrcTypes', $rsrcTypes );
// get all available menus that can be included
-$menuHashList = array();
+$menuHashList = [];
$menuList[''] = '';
$menuHashList = $gNexus->getMenuList();
foreach( $menuHashList as $menu ) {
@@ -106,5 +104,4 @@ if( count( $menuList ) > 1 ) {
$gBitSmarty->assign( 'menuList', $menuList );
}
-$gBitSystem->display( 'bitpackage:nexus/menu_items.tpl' , 'Nexus Menus', array( 'display_mode' => 'display' ));
-?>
+$gBitSystem->display( 'bitpackage:nexus/menu_items.tpl' , 'Nexus Menus', [ 'display_mode' => 'display' ]);
diff --git a/menu_sort.php b/menu_sort.php
index df5dbf3..a242f78 100644..100755
--- a/menu_sort.php
+++ b/menu_sort.php
@@ -9,10 +9,11 @@
/**
* required setup
*/
-require_once( '../kernel/includes/setup_inc.php' );
+require_once '../kernel/includes/setup_inc.php';
global $gBitSystem;
-require_once( NEXUS_PKG_PATH.'Nexus.php');
-include_once( NEXUS_PKG_INCLUDE_PATH.'menu_lookup_inc.php' );
+use Bitweaver\Nexus\Nexus;
+
+include_once NEXUS_PKG_INCLUDE_PATH.'menu_lookup_inc.php';
$gBitSystem->verifyPermission( 'p_nexus_create_menus' );
@@ -43,5 +44,4 @@ if( isset( $_REQUEST['tab'] ) ) {
$gBitSmarty->assign( 'nexus_file', strtolower( 'mod_'.preg_replace( "/ /", "_", $gNexus->mInfo['title'] ).'_'.$gNexus->mInfo['menu_id'].'.tpl' ) );
$gBitSystem->setBrowserTitle( 'Nexus Menus' );
-$gBitSystem->display( 'bitpackage:nexus/menu_sort.tpl' , NULL, array( 'display_mode' => 'display' ));
-?>
+$gBitSystem->display( 'bitpackage:nexus/menu_sort.tpl' , null, array( 'display_mode' => 'display' ));
diff --git a/menus.php b/menus.php
index 54047c4..136bc89 100644..100755
--- a/menus.php
+++ b/menus.php
@@ -9,10 +9,11 @@
/**
* required setup
*/
-require_once( '../kernel/includes/setup_inc.php' );
+require_once '../kernel/includes/setup_inc.php';
global $gBitSystem;
-require_once( NEXUS_PKG_PATH.'Nexus.php');
-include_once( NEXUS_PKG_INCLUDE_PATH.'menu_lookup_inc.php' );
+use Bitweaver\KernelTools;
+
+include_once NEXUS_PKG_INCLUDE_PATH.'menu_lookup_inc.php';
$formfeedback = '';
$gBitSystem->verifyPermission( 'p_nexus_create_menus' );
@@ -23,13 +24,13 @@ if( isset( $_REQUEST['action'] ) ) {
}
if( $_REQUEST['action'] == 'remove' ) {
- $formHash['remove'] = TRUE;
+ $formHash['remove'] = true;
$formHash['menu_id'] = $menuId;
$msgHash = array(
- 'label' => tra('Delete Menu'),
+ 'label' => KernelTools::tra('Delete Menu'),
'confirm_item' => $gNexus->mInfo['title'],
- 'warning' => tra('Remove this menu including all menu items associated with it.'),
- 'error' => tra('This cannot be undone!'),
+ 'warning' => KernelTools::tra('Remove this menu including all menu items associated with it.'),
+ 'error' => KernelTools::tra('This cannot be undone!'),
);
$gBitSystem->confirmDialog( $formHash,$msgHash );
}
@@ -41,17 +42,17 @@ if( isset( $_REQUEST['action'] ) ) {
$deadHtml .= '<li>'.$dead.'</li>';
}
$deadHtml .= '</ul>';
- $formfeedback['warning'] = tra( 'Links that were dead and removed from ' ).": ".$gNexus->mInfo['title'].$deadHtml;
+ $formfeedback['warning'] = KernelTools::tra( 'Links that were dead and removed from ' ).": ".$gNexus->mInfo['title'].$deadHtml;
} else {
- $formfeedback['success'] = tra( 'No dead links were found for this menu.' );
+ $formfeedback['success'] = KernelTools::tra( 'No dead links were found for this menu.' );
}
}
if( $_REQUEST['action'] == 'convert_structure' ) {
if( $gNexus->importStructure( $_REQUEST['structure_id'] ) ) {
- $formfeedback['success'] = tra( 'The structure was successfully imported as menu.' );
+ $formfeedback['success'] = KernelTools::tra( 'The structure was successfully imported as menu.' );
} else {
- $gBitSystem->fatalError( tra("There was an error importing the structure ").vc( $gNexus->mErrors ));
+ $gBitSystem->fatalError( KernelTools::tra("There was an error importing the structure ").\Bitweaver\vc( $gNexus->mErrors ));
}
}
}
@@ -61,7 +62,7 @@ if( isset( $_REQUEST['confirm'] ) ) {
header ("Location: ".NEXUS_PKG_URL."menus.php");
die;
} else {
- $gBitSystem->fatalError( tra("There was an error deleting the menu ").vc( $gNexus->mErrors ));
+ $gBitSystem->fatalError( KernelTools::tra("There was an error deleting the menu ").\Bitweaver\vc( $gNexus->mErrors ));
}
}
@@ -73,7 +74,7 @@ if( isset( $_REQUEST['store_menu'] ) ) {
die;
}
$gNexus->load();
- $formfeedback['success'] = tra( "The following menu was updated successfully" ).": ".$gNexus->mInfo['title'] ;
+ $formfeedback['success'] = KernelTools::tra( "The following menu was updated successfully" ).": ".$gNexus->mInfo['title'] ;
}
$gBitSmarty->assign( 'menuList', $menuList = $gNexus->getMenuList() );
@@ -82,10 +83,10 @@ $gBitSmarty->assign( 'formfeedback', $formfeedback );
// options only available if there is a top bar menu
if( is_file( TEMP_PKG_PATH.'nexus/modules/top_bar_inc.tpl' ) ) {
// if the top bar is set and we don't need it, remove it.
- $nuke_top_bar = TRUE;
+ $nuke_top_bar = true;
foreach( $menuList as $menu ) {
if( $menu['plugin_guid'] == NEXUS_PLUGIN_GUID_SUCKERFISH && $menu['menu_type'] == 'hor' ) {
- $nuke_top_bar = FALSE;
+ $nuke_top_bar = false;
}
}
@@ -95,5 +96,4 @@ if( is_file( TEMP_PKG_PATH.'nexus/modules/top_bar_inc.tpl' ) ) {
}
$gBitSystem->setBrowserTitle( 'Nexus Menus' );
-$gBitSystem->display( 'bitpackage:nexus/menus.tpl' , NULL, array( 'display_mode' => 'display' ));
-?>
+$gBitSystem->display( 'bitpackage:nexus/menus.tpl' , null, array( 'display_mode' => 'display' ));
diff --git a/plugins/menu.formelements.php b/plugins/menu.formelements.php
index e0bab74..1b4e87e 100644..100755
--- a/plugins/menu.formelements.php
+++ b/plugins/menu.formelements.php
@@ -18,7 +18,7 @@ global $gNexusSystem;
define( 'NEXUS_PLUGIN_GUID_FORMELEMENTSMENU', 'formelements' );
$pluginParams = array(
- 'auto_activate' => FALSE,
+ 'auto_activate' => false,
'write_cache_function' => 'write_form_menu_cache',
'title' => 'Formelements menu',
'description' => 'Menus using form elements',
@@ -50,15 +50,15 @@ function write_form_menu_cache( $pMenuHash ) {
$menu_name = strtolower( $menu_name );
$menu_file = $pMenuHash->mInfo['cache']['file'];
if ( $pMenuHash->mInfo['menu_type'] != 'qdd' ) {
- $data = '{bitmodule title="{tr}'.$pMenuHash->mInfo['title'].'{/tr}" name="'.$menu_name.'"}';
+ $data = '{bitmodule title="'.$pMenuHash->mInfo['title'].'" name="'.$menu_name.'"}';
}
else {
$data = '{bitmodule name="'.$menu_name.'"}';
}
// if a permission has been set, we need to work out when to close the {if} clause
- $permCloseIds = array();
- $perm_close = FALSE;
- $next_cycle = FALSE;
+ $permCloseIds = [];
+ $perm_close = false;
+ $next_cycle = false;
foreach( $pMenuHash->mInfo['tree'] as $key => $item ) {
if( !empty( $item['perm'] ) ) {
$perm_open = '{if $gBitUser->hasPermission("'.$item['perm'].'")}';
@@ -94,14 +94,14 @@ function write_form_menu_cache( $pMenuHash ) {
// close permission clauses
if( $next_cycle ) {
$data .= '{/if}';
- $next_cycle = FALSE;
+ $next_cycle = false;
}
if( in_array( $item['item_id'], $permCloseIds ) ) {
- $next_cycle = TRUE;
+ $next_cycle = true;
}
if( $perm_close ) {
$data .= '{/if}';
- $perm_close = FALSE;
+ $perm_close = false;
}
}
if( $item['last'] ) {
@@ -115,7 +115,7 @@ function write_form_menu_cache( $pMenuHash ) {
// open permission if clause
$data .= $perm_open;
if( !$item['head'] ) {
- $perm_close = TRUE;
+ $perm_close = true;
} else {
$permCloseIds[] = $item['item_id'];
}
diff --git a/plugins/menu.suckerfish.php b/plugins/menu.suckerfish.php
index 67c084e..bbb5321 100644..100755
--- a/plugins/menu.suckerfish.php
+++ b/plugins/menu.suckerfish.php
@@ -18,7 +18,7 @@ global $gNexusSystem;
define( 'NEXUS_PLUGIN_GUID_SUCKERFISH', 'suckerfish' );
$pluginParams = array(
- 'auto_activate' => TRUE,
+ 'auto_activate' => true,
'write_cache_function' => 'write_suckerfish_cache',
'title' => 'Suckerfish Menus',
'description' => 'Sophisticated and flexible CSS driven dropdown menus',
@@ -46,13 +46,13 @@ function write_suckerfish_cache( $pMenuHash ) {
$menu_name = strtolower( $menu_name );
$menu_file = $pMenuHash->mInfo['cache']['file'];
- $data = '{bitmodule title="{tr}'.$pMenuHash->mInfo['title'].'{/tr}" name="'.$menu_name.'" classplus="nexus-menu"}';
+ $data = '{bitmodule title="'.$pMenuHash->mInfo['title'].'" name="'.$menu_name.'" classplus="nexus-menu"}';
$data .= '<div class="suckerfish">';
// if a permission has been set, we need to work out when to close the {if} clause
- $permCloseIds = array();
- $perm_close = FALSE;
- $next_cycle = FALSE;
+ $permCloseIds = [];
+ $perm_close = false;
+ $next_cycle = false;
$menu_id = 'nexus'.$pMenuHash->mInfo['menu_id'].'-{$moduleParams.layout_area}{$moduleParams.pos}';
foreach( $pMenuHash->mInfo['tree'] as $key => $item ) {
@@ -67,14 +67,14 @@ function write_suckerfish_cache( $pMenuHash ) {
// close permission clauses
if( $next_cycle ) {
$data .= '{/if}';
- $next_cycle = FALSE;
+ $next_cycle = false;
}
if( in_array( $item['item_id'], $permCloseIds ) ) {
- $next_cycle = TRUE;
+ $next_cycle = true;
}
if( $perm_close ) {
$data .= '{/if}';
- $perm_close = FALSE;
+ $perm_close = false;
}
}
@@ -85,7 +85,7 @@ function write_suckerfish_cache( $pMenuHash ) {
// open permission if clause
$data .= '{if $gBitUser->hasPermission("'.$item['perm'].'")}';
if( !$item['head'] ) {
- $perm_close = TRUE;
+ $perm_close = true;
} else {
$permCloseIds[] = $item['item_id'];
}
@@ -100,7 +100,6 @@ function write_suckerfish_cache( $pMenuHash ) {
}
}
- $data .= '<!--[if lt IE 8]><script type="text/javascript">BitBase.fixIEDropMenu("'.$menu_id.'");</script><![endif]-->';
$data .= '<div class="clear"></div>';
$data .= '</div>';
$data .= '{/bitmodule}';
diff --git a/plugins/menu.tikiwiki.php b/plugins/menu.tikiwiki.php
index 6c51299..a0c071d 100644..100755
--- a/plugins/menu.tikiwiki.php
+++ b/plugins/menu.tikiwiki.php
@@ -17,7 +17,7 @@ global $gNexusSystem;
define( 'NEXUS_PLUGIN_GUID_TIKIWIKI', 'tikiwiki' );
$pluginParams = array(
- 'auto_activate' => TRUE,
+ 'auto_activate' => true,
'write_cache_function' => 'write_tikiwiki_cache',
'title' => 'TikiWiki menus',
'description' => 'expandable menu reminiscent of the tikiwiki menu',
@@ -47,12 +47,12 @@ function write_tikiwiki_cache( $pMenuHash ) {
$menu_name = preg_replace( "/ +/", "_", trim( $pMenuHash->mInfo['title'] ) );
$menu_name = strtolower( $menu_name );
$menu_file = $pMenuHash->mInfo['cache']['file'];
- $data = '{bitmodule title="{tr}'.$pMenuHash->mInfo['title'].'{/tr}" name="'.$menu_name.'"}';
+ $data = '{bitmodule title="'.$pMenuHash->mInfo['title'].'" name="'.$menu_name.'"}';
$data .= '<div class="tikiwiki menu">';
// if a permission has been set, we need to work out when to close the {if} clause
- $permCloseIds = array();
- $perm_close = FALSE;
- $perm_cycle = FALSE;
+ $permCloseIds = [];
+ $perm_close = false;
+ $perm_cycle = false;
$type = $pMenuHash->mInfo['menu_type'];
foreach( $pMenuHash->mInfo['tree'] as $key => $item ) {
if( $item['first'] ) {
@@ -61,14 +61,14 @@ function write_tikiwiki_cache( $pMenuHash ) {
// close permission clauses
if( $perm_cycle ) {
$data .= '{/if}';
- $perm_cycle = FALSE;
+ $perm_cycle = false;
}
if( in_array( $item['item_id'], $permCloseIds ) ) {
- $perm_cycle = TRUE;
+ $perm_cycle = true;
}
if( $perm_close ) {
$data .= '{/if}';
- $perm_close = FALSE;
+ $perm_close = false;
}
}
if( $item['last'] ) {
@@ -78,7 +78,7 @@ function write_tikiwiki_cache( $pMenuHash ) {
// open permission if clause
$data .= '{if $gBitUser->hasPermission("'.$item['perm'].'")}';
if( !$item['head'] ) {
- $perm_close = TRUE;
+ $perm_close = true;
} else {
$permCloseIds[] = $item['item_id'];
}
@@ -101,7 +101,7 @@ function write_tikiwiki_cache( $pMenuHash ) {
$data .= '</div><!-- end .menu -->';
// apply state of expandable menus
- $data .= '<script type="text/javascript">';
+ $data .= '<script>';
foreach( $pMenuHash->mInfo['tree'] as $key => $item ) {
if( $item['first'] ) {
$togid = 'togid'.$item['item_id'];
diff --git a/templates/menu_nexus.tpl b/templates/menu_nexus.tpl
index 783c009..dbda709 100644
--- a/templates/menu_nexus.tpl
+++ b/templates/menu_nexus.tpl
@@ -1,5 +1,5 @@
{strip}
-{if $packageMenuTitle}<a class="dropdown-toggle" data-toggle="dropdown" href="#"> {tr}{$packageMenuTitle}{/tr} <b class="caret"></b></a>{/if}
+{if !empty($packageMenuTitle)}<a class="dropdown-toggle" data-toggle="dropdown" href="#"> {tr}{$packageMenuTitle}{/tr} <b class="caret"></b></a>{/if}
<ul class="{$packageMenuClass}">
<li><a class="head" href="{$smarty.const.NEXUS_PKG_URL}menus.php">{booticon ipackage="icons" iname="icon-sitemap" iexplain="Menus" ilocation=menu}</a></li>
{if $gNexus->mInfo.menu_id}
diff --git a/templates/menu_nexus_admin.tpl b/templates/menu_nexus_admin.tpl
index 66e67f5..1d7d1ad 100644
--- a/templates/menu_nexus_admin.tpl
+++ b/templates/menu_nexus_admin.tpl
@@ -1,5 +1,5 @@
{strip}
-{if $packageMenuTitle}<a href="#"> {tr}{$packageMenuTitle|capitalize}{/tr}</a>{/if}
+{if !empty($packageMenuTitle)}<a href="#"> {tr}{$packageMenuTitle|capitalize}{/tr}</a>{/if}
<ul class="{$packageMenuClass}">
<li><a class="item" href="{$smarty.const.KERNEL_PKG_URL}admin/index.php?page=nexus">{tr}Nexus{/tr}</a></li>
<li><a class="item" href="{$smarty.const.NEXUS_PKG_URL}">{tr}Nexus Menus{/tr}</a></li>