* Made it more visible where to drop the fields in manage fields view for a collection.
* Added a note about some options in collections manage view.
* Improved breakpoint behavior
+ * After already selected a collection the add and tags manage action has this collection already set.
1.3 - Rrajigar Mine 2022-10-08
* Fixed install sql file.
`id` int UNSIGNED NOT NULL,
`text` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`action` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `contextaction` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`icon` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`owner` int NOT NULL DEFAULT '0',
`group` int NOT NULL DEFAULT '0',
-- Dumping data for table `#REPLACEME#_menu`
--
-INSERT INTO `#REPLACEME#_menu` (`id`, `text`, `action`, `icon`, `owner`, `group`, `rights`, `position`, `category`) VALUES
-(1, 'Dashboard', '', 'home', 1, 1, 'rw-r--r--', 0, 'show'),
-(2, 'Collections', 'collections', 'database', 1, 1, 'rw-r--r--', 1, 'show'),
-(3, 'Tags', 'tags', 'tag', 1, 1, 'rw-r--r--', 2, 'show'),
-(4, 'Add', 'manageentry', 'plus-circle', 1, 2, 'rw-rw----', 0, 'manage'),
-(6, 'Tags', 'managetags', 'tag', 1, 2, 'rw-rw----', 2, 'manage'),
-(7, 'Collections', 'managecolletions', 'database', 1, 2, 'rw-rw----', 3, 'manage'),
-(8, 'Users', 'manageusers', 'users', 1, 1, 'rw-------', 4, 'manage'),
-(9, 'Login', 'auth', '', 1, 1, 'rw-r--r--', 0, ''),
-(10, 'Collection fields', 'managecollectionfields', '', 1, 2, 'rw-rw----', 0, ''),
-(11, 'Entry', 'entry', '', 1, 1, 'rw-r--r--', 0, ''),
-(12, 'Search', 'search', '', 1, 1, 'rw-r--r--', 0, ''),
-(14, 'Tool', 'tool', '', 1, 2, 'rw-rw----', 0, ''),
-(15, 'Advanced search', 'advancedsearch', '', 1, 1, 'rw-r--r--', 0, ''),
-(16, 'Profile', 'profile', 'user', 1, 2, 'rw-rw----', 6, 'manage'),
-(17, 'Groups', 'managegroups', 'users', 1, 1, 'rw-------', 5, 'manage'),
-(18, 'Bulkedit', 'bulkedit', '', 1, 2, 'rw-rw----', 0, ''),
-(19, 'System Information', 'sysinfo', 'info', 1, 1, 'rw-------', 3, 'show');
+INSERT INTO `#REPLACEME#_menu` (`id`, `text`, `action`, `contextaction`, `icon`, `owner`, `group`, `rights`, `position`, `category`) VALUES
+(1, 'Dashboard', '', 'home', '', 1, 1, 'rw-r--r--', 0, 'show'),
+(2, 'Collections', 'collections', '', 'database', 1, 1, 'rw-r--r--', 1, 'show'),
+(3, 'Tags', 'tags', '', 'tag', 1, 1, 'rw-r--r--', 2, 'show'),
+(4, 'Add', 'manageentry', 'collection', 'plus-circle', 1, 2, 'rw-rw----', 0, 'manage'),
+(6, 'Tags', 'managetags', 'collection', 'tag', 1, 2, 'rw-rw----', 2, 'manage'),
+(7, 'Collections', 'managecolletions', '', 'database', 1, 2, 'rw-rw----', 3, 'manage'),
+(8, 'Users', 'manageusers', '', 'users', 1, 1, 'rw-------', 4, 'manage'),
+(9, 'Login', 'auth', '', '', 1, 1, 'rw-r--r--', 0, ''),
+(10, 'Collection fields', 'managecollectionfields', '', '', 1, 2, 'rw-rw----', 0, ''),
+(11, 'Entry', 'entry', '', '', 1, 1, 'rw-r--r--', 0, ''),
+(12, 'Search', 'search', '', '', 1, 1, 'rw-r--r--', 0, ''),
+(14, 'Tool', 'tool', '', '', 1, 2, 'rw-rw----', 0, ''),
+(15, 'Advanced search', 'advancedsearch', '', '', 1, 1, 'rw-r--r--', 0, ''),
+(16, 'Profile', 'profile', '', 'user', 1, 2, 'rw-rw----', 6, 'manage'),
+(17, 'Groups', 'managegroups', '', 'users', 1, 1, 'rw-------', 5, 'manage'),
+(18, 'Bulkedit', 'bulkedit', '', '', 1, 2, 'rw-rw----', 0, ''),
+(19, 'System Information', 'sysinfo', '', 'info', 1, 1, 'rw-------', 3, 'show');
+
-- --------------------------------------------------------
# DB changes. Run each line against your bibliotheca DB.
# Replace #REPLACEME# with your table prefix. Default is bib
-ALTER TABLE `#REPLACEME#_collection` ADD `defaultSortOrder` VARCHAR(4) CHARACTER SET utf8mb4_unicode_ci COLLATE utf8mb4_bin NOT NULL AFTER `defaultSortField`;
+ALTER TABLE `#REPLACEME#_collection` ADD `defaultSortOrder` VARCHAR(4) NOT NULL AFTER `defaultSortField`;
+ALTER TABLE `#REPLACEME#_menu` ADD `contextaction` VARCHAR(64) NOT NULL AFTER `action`;
+UPDATE `#REPLACEME#_menu` SET `contextaction` = 'collection' WHERE `bib_menu`.`id` = 4;
+UPDATE `#REPLACEME#_menu` SET `contextaction` = 'collection' WHERE `bib_menu`.`id` = 6;
$Doomguy = new Doomguy($DB);
# menu Object
$Gorenest = new GoreNest($DB,$Doomguy);
-$Gorenest->loadMenu();
$_requestMode = false;
if(isset($_GET['p']) && !empty($_GET['p'])) {
public function __construct(mysqli $db, Doomguy $user) {
$this->_DB = $db;
$this->_User = $user;
+ $this->_loadMenu();
+ }
+
+ /**
+ * Get the menu data for given area and category.
+ * This shows only entries which have a category set.
+ * No category can be used for hidden entries.
+ *
+ * @param string $category
+ * @param bool $reload
+ * @param array $_contextActions
+ * @return array
+ */
+ public function get(string $category, bool $reload = false, array $_contextActions = array()): array {
+ $ret = array();
+
+ if(empty($category)) return $ret;
+
+ if($reload === false && isset($this->_menuData[$category])) {
+ return $this->_updateContextActions($this->_menuData[$category], $_contextActions);
+ }
+
+ $this->_loadMenu();
+ if(isset($this->_menuData[$category])) {
+ $ret = $this->_menuData[$category];
+ }
+
+ return $this->_updateContextActions($ret, $_contextActions);
}
/**
*
* @return void
*/
- public function loadMenu(): void {
+ private function _loadMenu(): void {
# reset the menu
$this->_menuData = array();
- $queryStr = "SELECT id, text, action, icon, category
+ $queryStr = "SELECT id, text, action, icon, category, contextaction
FROM `".DB_PREFIX."_menu`
WHERE ".$this->_User->getSQLRightsString()."
ORDER BY position";
$query = $this->_DB->query($queryStr);
if($query !== false && $query->num_rows > 0) {
while(($result = $query->fetch_assoc()) != false) {
- $this->_menuData[$result['category']][$result['id']] = $result;
$this->_allowedPageRequests[$result['action']] = $result['action'];
+ $this->_menuData[$result['category']][$result['id']] = $result;
}
}
}
}
/**
- * Get the menu data for given area and category.
- * This shows only entries which have a category set.
- * No category can be used for hidden entries.
+ * Return allowed page requests
*
- * @param string $category
- * @param bool $reload
* @return array
*/
- public function get(string $category, bool $reload = false): array {
- $ret = array();
-
- if(empty($category)) return $ret;
-
- if($reload === false && isset($this->_menuData[$category])) {
- return $this->_menuData[$category];
- }
-
- $this->loadMenu();
- if(isset($this->_menuData[$category])) {
- $ret = $this->_menuData[$category];
- }
-
- return $ret;
+ public function allowedPageRequests(): array {
+ return $this->_allowedPageRequests;
}
/**
- * Return allowed page requests
+ * Check if there is the need to modify the action value based on contextaction column
+ * and $_contextActions array
*
+ * @param array $_menuData
+ * @param array $_contextActions
* @return array
*/
- public function allowedPageRequests(): array {
- return $this->_allowedPageRequests;
+ private function _updateContextActions(array $_menuData, array $_contextActions): array {
+ if(!empty($_contextActions)) {
+ foreach($_menuData as $id=>$data) {
+ if(isset($_contextActions[$data['contextaction']])) {
+ $_menuData[$id]['action'] = $data['action'].'&'.$data['contextaction'].'='.$_contextActions[$data['contextaction']];
+ }
+ }
+ }
+ return $_menuData;
}
}
* @param array $modify
* @return string
*/
- static function createFromParameterLinkQuery(array $array, $modify=array()): string {
+ static function createFromParameterLinkQuery(array $array, array $modify = array()): string {
$ret = '';
if(!empty($modify)) {
`id` int UNSIGNED NOT NULL,
`text` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`action` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `contextaction` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`icon` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`owner` int NOT NULL DEFAULT '0',
`group` int NOT NULL DEFAULT '0',
-- Dumping data for table `#REPLACEME#_menu`
--
-INSERT INTO `#REPLACEME#_menu` (`id`, `text`, `action`, `icon`, `owner`, `group`, `rights`, `position`, `category`) VALUES
-(1, 'Dashboard', '', 'home', 1, 1, 'rw-r--r--', 0, 'show'),
-(2, 'Collections', 'collections', 'database', 1, 1, 'rw-r--r--', 1, 'show'),
-(3, 'Tags', 'tags', 'tag', 1, 1, 'rw-r--r--', 2, 'show'),
-(4, 'Add', 'manageentry', 'plus-circle', 1, 2, 'rw-rw----', 0, 'manage'),
-(6, 'Tags', 'managetags', 'tag', 1, 2, 'rw-rw----', 2, 'manage'),
-(7, 'Collections', 'managecolletions', 'database', 1, 2, 'rw-rw----', 3, 'manage'),
-(8, 'Users', 'manageusers', 'users', 1, 1, 'rw-------', 4, 'manage'),
-(9, 'Login', 'auth', '', 1, 1, 'rw-r--r--', 0, ''),
-(10, 'Collection fields', 'managecollectionfields', '', 1, 2, 'rw-rw----', 0, ''),
-(11, 'Entry', 'entry', '', 1, 1, 'rw-r--r--', 0, ''),
-(12, 'Search', 'search', '', 1, 1, 'rw-r--r--', 0, ''),
-(14, 'Tool', 'tool', '', 1, 2, 'rw-rw----', 0, ''),
-(15, 'Advanced search', 'advancedsearch', '', 1, 1, 'rw-r--r--', 0, ''),
-(16, 'Profile', 'profile', 'user', 1, 2, 'rw-rw----', 6, 'manage'),
-(17, 'Groups', 'managegroups', 'users', 1, 1, 'rw-------', 5, 'manage'),
-(18, 'Bulkedit', 'bulkedit', '', 1, 2, 'rw-rw----', 0, ''),
-(19, 'System Information', 'sysinfo', 'info', 1, 1, 'rw-------', 3, 'show');
+INSERT INTO `#REPLACEME#_menu` (`id`, `text`, `action`, `contextaction`, `icon`, `owner`, `group`, `rights`, `position`, `category`) VALUES
+(1, 'Dashboard', '', 'home', '', 1, 1, 'rw-r--r--', 0, 'show'),
+(2, 'Collections', 'collections', '', 'database', 1, 1, 'rw-r--r--', 1, 'show'),
+(3, 'Tags', 'tags', '', 'tag', 1, 1, 'rw-r--r--', 2, 'show'),
+(4, 'Add', 'manageentry', 'collection', 'plus-circle', 1, 2, 'rw-rw----', 0, 'manage'),
+(6, 'Tags', 'managetags', 'collection', 'tag', 1, 2, 'rw-rw----', 2, 'manage'),
+(7, 'Collections', 'managecolletions', '', 'database', 1, 2, 'rw-rw----', 3, 'manage'),
+(8, 'Users', 'manageusers', '', 'users', 1, 1, 'rw-------', 4, 'manage'),
+(9, 'Login', 'auth', '', '', 1, 1, 'rw-r--r--', 0, ''),
+(10, 'Collection fields', 'managecollectionfields', '', '', 1, 2, 'rw-rw----', 0, ''),
+(11, 'Entry', 'entry', '', '', 1, 1, 'rw-r--r--', 0, ''),
+(12, 'Search', 'search', '', '', 1, 1, 'rw-r--r--', 0, ''),
+(14, 'Tool', 'tool', '', '', 1, 2, 'rw-rw----', 0, ''),
+(15, 'Advanced search', 'advancedsearch', '', '', 1, 1, 'rw-r--r--', 0, ''),
+(16, 'Profile', 'profile', '', 'user', 1, 2, 'rw-rw----', 6, 'manage'),
+(17, 'Groups', 'managegroups', '', 'users', 1, 1, 'rw-------', 5, 'manage'),
+(18, 'Bulkedit', 'bulkedit', '', '', 1, 2, 'rw-rw----', 0, ''),
+(19, 'System Information', 'sysinfo', '', 'info', 1, 1, 'rw-------', 3, 'show');
-- --------------------------------------------------------
* limitations under the License.
*/
+## optional context action
+# the key has to match the column contextaction of the menuentry
+# $_collection comes from the $Viewscript
+$_contextActions = array();
+if(!empty($_collection)) {
+ $_contextActions['collection'] = $_collection;
+}
+
$_menuShow = $Gorenest->get('show');
-$_menuManage = $Gorenest->get('manage');
+$_menuManage = $Gorenest->get('manage', false, $_contextActions);
?>
<nav class="uk-navbar-container" uk-navbar>
<div class="uk-navbar-left">