summaryrefslogtreecommitdiff
path: root/includes/classes/Nexus.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/classes/Nexus.php')
-rwxr-xr-xincludes/classes/Nexus.php86
1 files changed, 43 insertions, 43 deletions
diff --git a/includes/classes/Nexus.php b/includes/classes/Nexus.php
index f688590..a3bdd00 100755
--- a/includes/classes/Nexus.php
+++ b/includes/classes/Nexus.php
@@ -12,11 +12,11 @@
* required setup
*/
namespace Bitweaver\Nexus;
+
use Bitweaver\BitBase;
use Bitweaver\Fisheye\FisheyeGallery;
use Bitweaver\Liberty\LibertyStructure;
use Bitweaver\KernelTools;
-use Bitweaver\Themes\BitweaverExtension;
/**
* @package nexus
@@ -65,7 +65,7 @@ class Nexus extends NexusSystem {
$query = 'SELECT nm.* FROM `'.BIT_DB_PREFIX.'nexus_menus` nm';
if( is_numeric( $pMenuId ) ) {
$query .= ' WHERE nm.`menu_id`=?';
- $bindVars = array( $pMenuId );
+ $bindVars = [ $pMenuId ];
}
if( $result = $this->mDb->query( $query, $bindVars ) ) {
$ret = $result->fields;
@@ -240,12 +240,12 @@ class Nexus extends NexusSystem {
$this->mDb->StartTrans();
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'] ) );
+ $result = $this->mDb->query( $query, [ $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, [] );
} 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'] ) );
+ $result = $this->mDb->query( $query, [ $pParamHash['title'], $pParamHash['description'], $pParamHash['menu_type'], $pParamHash['plugin_guid'], $pParamHash['editable'], $pParamHash['menu_id'] ] );
$ret = $pParamHash['menu_id'];
}
$this->mDb->CompleteTrans();
@@ -268,11 +268,11 @@ class Nexus extends NexusSystem {
// delete menu items
$query = "DELETE FROM `".BIT_DB_PREFIX."nexus_menu_items` WHERE `menu_id`=?";
- $this->mDb->query( $query, array( $pMenuId ) );
+ $this->mDb->query( $query, [ $pMenuId ] );
// delete menu
$query = "DELETE FROM `".BIT_DB_PREFIX."nexus_menus` WHERE `menu_id`=?";
- $this->mDb->query( $query, array( $pMenuId ) );
+ $this->mDb->query( $query, [ $pMenuId ] );
// rewrite the entire cache, just to make sure everything is in order
$this->rewriteMenuCache();
@@ -292,10 +292,10 @@ class Nexus extends NexusSystem {
$query = 'SELECT nmi.* FROM `'.BIT_DB_PREFIX.'nexus_menu_items` nmi';
if( is_numeric( $pItemId ) ) {
$query .= ' WHERE nmi.`item_id`=?';
- $bindVars = array( $pItemId );
+ $bindVars = [ $pItemId ];
} elseif( is_numeric( $pMenuId ) ) {
$query .= ' WHERE nmi.`menu_id`=?';
- $bindVars = array( $pMenuId );
+ $bindVars = [ $pMenuId ];
}
$query .= ' ORDER BY nmi.`pos`';
$result = $this->mDb->query( $query, $bindVars );
@@ -342,7 +342,7 @@ class Nexus extends NexusSystem {
break;
case 'content_id':
// create *one* object for each object *type* to call virtual methods.
- $row = $this->mDb->getRow( "SELECT `title`,`content_id`,`content_type_guid` FROM `".BIT_DB_PREFIX."liberty_content` WHERE `content_id`=?", array( $pItemHash['rsrc'] ));
+ $row = $this->mDb->getRow( "SELECT `title`,`content_id`,`content_type_guid` FROM `".BIT_DB_PREFIX."liberty_content` WHERE `content_id`=?", [ $pItemHash['rsrc'] ]);
if( !empty( $row['content_type_guid'] )) {
$type = &$contentTypes[$row['content_type_guid']];
@@ -405,16 +405,16 @@ class Nexus extends NexusSystem {
$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'] ?? 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['parent_id'] = $this->mDb->getOne("SELECT `parent_id` FROM `".BIT_DB_PREFIX."nexus_menu_items` WHERE `item_id`=?", [ (int)$pParamHash['after_ref_id'] ] );
}
}
$pParamHash['max'] = 0;
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'] ) );
+ $pParamHash['max'] = $this->mDb->getOne("SELECT `pos` FROM `".BIT_DB_PREFIX."nexus_menu_items` WHERE `item_id`=?", [ (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
$query = "UPDATE `".BIT_DB_PREFIX."nexus_menu_items` SET `pos`=`pos`+1 WHERE `pos`>? AND `parent_id`=?";
- $result = $this->mDb->query( $query, array( (int)$pParamHash['max'], (int)$pParamHash['parent_id'] ) );
+ $result = $this->mDb->query( $query, [ (int)$pParamHash['max'], (int)$pParamHash['parent_id'] ] );
}
}
$this->mDb->CompleteTrans();
@@ -448,12 +448,12 @@ class Nexus extends NexusSystem {
$this->mDb->StartTrans();
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'] ) );
+ $result = $this->mDb->query( $query, [ (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, [] );
} 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'] ) );
+ $result = $this->mDb->query( $query, [ $pParamHash['title'], $pParamHash['hint'], $pParamHash['rsrc'], $pParamHash['rsrc_type'], $pParamHash['perm'], $pParamHash['item_id'] ] );
$ret = $pParamHash['item_id'];
}
$this->mDb->CompleteTrans();
@@ -478,7 +478,7 @@ class Nexus extends NexusSystem {
$this->mDb->StartTrans();
// get all items that are on the same level
$query = "SELECT * FROM `".BIT_DB_PREFIX."nexus_menu_items` WHERE `parent_id`=? ORDER BY `pos`";
- $result = $this->mDb->query( $query, array( $pItemId ) );
+ $result = $this->mDb->query( $query, [ $pItemId ] );
// this value is needed to correclty position items that are moved up a level
$pos_count = 0;
// first we move children up one level
@@ -486,33 +486,33 @@ class Nexus extends NexusSystem {
$item = $result->fields;
//Make a space for the item after its parent
$query = "UPDATE `".BIT_DB_PREFIX."nexus_menu_items` SET `pos`=`pos`+1 WHERE `pos`>?+".$pos_count." AND `parent_id`=? AND `menu_id`=?";
- $res = $this->mDb->query( $query, array( (int)$remItem['pos'], (int)$remItem['parent_id'], (int)$remItem['menu_id'] ) );
+ $res = $this->mDb->query( $query, [ (int)$remItem['pos'], (int)$remItem['parent_id'], (int)$remItem['menu_id'] ] );
// increase insertion count here
$pos_count++;
// move item up one level
$query = "UPDATE `".BIT_DB_PREFIX."nexus_menu_items` SET `parent_id`=?, `pos`=?+".$pos_count." WHERE `item_id`=?";
- $this->mDb->query( $query, array( (int)$remItem['parent_id'], (int)$remItem['pos'], (int)$item['item_id'] ) );
+ $this->mDb->query( $query, [ (int)$remItem['parent_id'], (int)$remItem['pos'], (int)$item['item_id'] ] );
$result->MoveNext();
}
// all items below remItem have to be shifted up by one
$query = "UPDATE `".BIT_DB_PREFIX."nexus_menu_items` SET `pos`=`pos`-1 WHERE `pos`>? AND `parent_id`=? AND `menu_id`=?";
- $this->mDb->query( $query, array( (int)$remItem['pos'], (int)$remItem['parent_id'], (int)$remItem['menu_id'] ) );
+ $this->mDb->query( $query, [ (int)$remItem['pos'], (int)$remItem['parent_id'], (int)$remItem['menu_id'] ] );
// finally, we are ready do delete remItem
$query = "DELETE FROM `".BIT_DB_PREFIX."nexus_menu_items` WHERE `item_id`=?";
- $result = $this->mDb->query( $query, array( $pItemId ) );
+ $result = $this->mDb->query( $query, [ $pItemId ] );
$this->mDb->CompleteTrans();
if( $pWriteCache ) {
$this->writeMenuCache( $remItem['menu_id'] );
}
return $remItem;
- } else {
+ }
$this->mErrors['remove_item'] = KernelTools::tra( "There was a problem trying to remove the menu item." );
return false;
- }
- } else {
+
+ }
$this->mErrors['remove_item_id'] = KernelTools::tra( "The menu item could not be removed because no valid item id was given." );
return false;
- }
+
}
/**
@@ -554,16 +554,16 @@ class Nexus extends NexusSystem {
$parentItem = $parentItem[$item["parent_id"]];
$this->mDb->StartTrans();
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'] ) );
+ $max_row = $this->mDb->getOne("SELECT `pos` FROM `".BIT_DB_PREFIX."nexus_menu_items` WHERE `item_id`=?", [ $item['parent_id'] ] );
$parent_item['pos'] = $max_row;
$parent_item['parent_id'] = 0;
}
//Make a space for the item after its parent
$query = "UPDATE `".BIT_DB_PREFIX."nexus_menu_items` SET `pos`=`pos`+1 WHERE `pos`>? AND `parent_id`=?";
- $this->mDb->query( $query, array( (int)$parentItem["pos"], (int)$parentItem["parent_id"] ) );
+ $this->mDb->query( $query, [ (int)$parentItem["pos"], (int)$parentItem["parent_id"] ] );
//Move the item up one level
$query = "UPDATE `".BIT_DB_PREFIX."nexus_menu_items` SET `parent_id`=?, `pos`=(? + 1) WHERE `item_id`=?";
- $this->mDb->query($query, array( (int)$parentItem["parent_id"], (int)$parentItem["pos"], $pItemId ) );
+ $this->mDb->query($query, [ (int)$parentItem["parent_id"], (int)$parentItem["pos"], $pItemId ] );
$this->mDb->CompleteTrans();
$this->writeMenuCache( $item['menu_id'] );
}
@@ -580,17 +580,17 @@ class Nexus extends NexusSystem {
$item = $this->mInfo["items"][$pItemId];
$this->mDb->StartTrans();
$query = "SELECT `item_id`, `pos` FROM `".BIT_DB_PREFIX."nexus_menu_items` WHERE `pos`<? AND `parent_id`=? AND `menu_id`=? ORDER BY `pos` DESC";
- $result = $this->mDb->query( $query, array( (int)$item["pos"], (int)$item["parent_id"], (int)$item["menu_id"] ) );
+ $result = $this->mDb->query( $query, [ (int)$item["pos"], (int)$item["parent_id"], (int)$item["menu_id"] ] );
if( $previous = $result->fetchRow() ) {
//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"] ) );
+ $result = $this->mDb->query( $query, [ (int)$previous["item_id"], (int)$item["menu_id"] ] );
$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"] ) );
+ $this->mDb->query( $query, [ (int)$previous["item_id"], (int)$pos, (int)$item["item_id"] ] );
//Move items up below that had previous parent and pos
$query = "UPDATE `".BIT_DB_PREFIX."nexus_menu_items` SET `pos`=`pos`-1 WHERE `pos`>? AND `parent_id`=? AND `menu_id`=?";
- $this->mDb->query( $query, array( $item["pos"], $item["parent_id"], $item["menu_id"] ) );
+ $this->mDb->query( $query, [ $item["pos"], $item["parent_id"], $item["menu_id"] ] );
$this->mDb->CompleteTrans();
$this->writeMenuCache( $item['menu_id'] );
}
@@ -607,12 +607,12 @@ class Nexus extends NexusSystem {
$item = $this->mInfo["items"][$pItemId];
$this->mDb->StartTrans();
$query = "SELECT `item_id`, `pos` FROM `".BIT_DB_PREFIX."nexus_menu_items` WHERE `pos`>? AND `parent_id`=? ORDER BY `pos` ASC";
- $result = $this->mDb->query( $query, array( (int)$item["pos"], (int)$item["parent_id"] ) );
+ $result = $this->mDb->query( $query, [ (int)$item["pos"], (int)$item["parent_id"] ] );
if( $res = $result->fetchRow() ) {
//Swap position values
$query = "UPDATE `".BIT_DB_PREFIX."nexus_menu_items` SET `pos`=? WHERE `item_id`=?";
- $this->mDb->query( $query, array( (int)$item["pos"], (int)$res["item_id"] ) );
- $this->mDb->query( $query, array( (int)$res["pos"], (int)$item["item_id"] ) );
+ $this->mDb->query( $query, [ (int)$item["pos"], (int)$res["item_id"] ] );
+ $this->mDb->query( $query, [ (int)$res["pos"], (int)$item["item_id"] ] );
}
$this->mDb->CompleteTrans();
$this->writeMenuCache( $item['menu_id'] );
@@ -629,12 +629,12 @@ class Nexus extends NexusSystem {
$item = $this->mInfo["items"][$pItemId];
$this->mDb->StartTrans();
$query = "SELECT `item_id`, `pos` from `".BIT_DB_PREFIX."nexus_menu_items` WHERE `pos`<? AND `parent_id`=? ORDER BY `pos` desc";
- $result = $this->mDb->query( $query, array((int)$item["pos"], (int)$item["parent_id"] ) );
+ $result = $this->mDb->query( $query, [(int)$item["pos"], (int)$item["parent_id"] ] );
if( $res = $result->fetchRow() ) {
//Swap position values
$query = "UPDATE `".BIT_DB_PREFIX."nexus_menu_items` SET `pos`=? WHERE `item_id`=?";
- $this->mDb->query( $query, array( (int)$res["pos"], (int)$item["item_id"] ) );
- $this->mDb->query( $query, array( (int)$item["pos"], (int)$res["item_id"] ) );
+ $this->mDb->query( $query, [ (int)$res["pos"], (int)$item["item_id"] ] );
+ $this->mDb->query( $query, [ (int)$item["pos"], (int)$res["item_id"] ] );
}
$this->mDb->CompleteTrans();
$this->writeMenuCache( $item['menu_id'] );
@@ -666,14 +666,14 @@ class Nexus extends NexusSystem {
$menuHash['title'] = $rootStructure->mInfo['title'];
if( $menu_id = $this->storeMenu( $menuHash ) ) {
// we need to insert the structure title manually, as this is not part of the structure
- $itemHash = array(
+ $itemHash = [
'menu_id' => $menu_id,
'title' => $rootStructure->mInfo['title'],
'pos' => 1,
'parent_id' => 0,
'rsrc' => $rootStructure->mInfo['structure_id'],
- 'rsrc_type' => 'structure_id'
- );
+ 'rsrc_type' => 'structure_id',
+ ];
$storedItem = $this->storeItem( $itemHash );
// insert all nodes in structure as menu items
@@ -691,14 +691,14 @@ class Nexus extends NexusSystem {
} else {
// save the item in the menu
$tmpItem = $rootStructure->getNode( $structureItem['structure_id'] );
- $itemHash = array(
+ $itemHash = [
'menu_id' => $menu_id,
'title' => $structureItem['title'],
'pos' => $tmpItem['pos'],
'parent_id' => $parent_id,
- 'rsrc' => isset( $structureItem['structure_id'] ) ? $structureItem['structure_id'] : null,
- 'rsrc_type' => 'structure_id'
- );
+ 'rsrc' => $structureItem['structure_id'] ?? null,
+ 'rsrc_type' => 'structure_id',
+ ];
$storedItem = $this->storeItem( $itemHash );
}
}