From f53bba9955d2234f4e034bcb61752a6d422f8a5e Mon Sep 17 00:00:00 2001 From: Banana Date: Sun, 17 Jan 2021 19:58:47 +0100 Subject: [PATCH] page titles. Deletion of a collection removes the storage too --- upgrade/from-version-1.0.txt | 1 + webclient/index.php | 3 ++- webclient/lib/managecollections.class.php | 2 ++ webclient/lib/summoner.class.php | 4 ++-- webclient/lib/tentacle.class.php | 2 +- webclient/lib/trite.class.php | 3 +++ .../view/default/advancedsearch/advancedsearch.php | 1 + webclient/view/default/auth/auth.php | 2 ++ webclient/view/default/collections/collections.php | 4 ++++ webclient/view/default/entry/entry.php | 8 ++++++++ webclient/view/default/main.php | 2 +- .../managecollectionfields.php | 2 ++ .../default/managecolletions/managecolletions.php | 2 ++ webclient/view/default/manageentry/manageentry.html | 1 + webclient/view/default/manageentry/manageentry.php | 7 +++++++ .../view/default/managegroups/managegroups.php | 2 ++ webclient/view/default/managetags/managetags.php | 1 + webclient/view/default/manageusers/manageusers.php | 1 + webclient/view/default/profile/profile.php | 1 + webclient/view/default/tags/tags.php | 4 ++++ webclient/view/default/tool/tool.php | 13 ++++++++----- 21 files changed, 56 insertions(+), 10 deletions(-) diff --git a/upgrade/from-version-1.0.txt b/upgrade/from-version-1.0.txt index 968a158..87ae5a2 100644 --- a/upgrade/from-version-1.0.txt +++ b/upgrade/from-version-1.0.txt @@ -13,3 +13,4 @@ INSERT INTO `#REPLACEME#_menu` (`id`, `text`, `action`, `icon`, `owner`, `group` DELETE FROM `#REPLACEME#_menu` WHERE `bib_menu`.`id` = 13; INSERT INTO `#REPLACEME#_menu` (`id`, `text`, `action`, `icon`, `owner`, `group`, `rights`, `position`, `category`) VALUES (NULL, 'Groups', 'managegroups', 'users', '1', '1', 'rw-------', '5', 'manage'); UPDATE `#REPLACEME#_menu` SET `position` = '6' WHERE `bib_menu`.`id` = 16; +UPDATE `#REPLACEME#_menu` SET `group` = '2', `rights` = 'rw-rw----' WHERE `bib_menu`.`id` = 14; diff --git a/webclient/index.php b/webclient/index.php index 0492f88..acfe2f6 100644 --- a/webclient/index.php +++ b/webclient/index.php @@ -59,6 +59,7 @@ $DB = false; $TemplateData = array(); $TemplateData['pagination'] = array(); $TemplateData['searchAction'] = 'index.php'; +$TemplateData['pageTitle'] = 'Dashboard'; # the view $View = Summoner::themefile('dashboard/dashboard.html', UI_THEME); # the script @@ -97,7 +98,7 @@ if(isset($_GET['p']) && !empty($_GET['p'])) { $View = Summoner::themefile($_requestMode.'/'.$_requestMode.'.html', UI_THEME); } -# now inlcude the script +# now include the script # this sets information into $Data and can overwrite $View if(!empty($ViewScript)) { require_once $ViewScript; diff --git a/webclient/lib/managecollections.class.php b/webclient/lib/managecollections.class.php index 6abecea..11d737f 100644 --- a/webclient/lib/managecollections.class.php +++ b/webclient/lib/managecollections.class.php @@ -415,6 +415,8 @@ class ManageCollections { $this->_DB->query($queryStrEntry); $this->_DB->query($queryStrFields); + Summoner::recursive_remove_directory(PATH_STORAGE.'/'.$id); + $ret = true; } catch (Exception $e) { diff --git a/webclient/lib/summoner.class.php b/webclient/lib/summoner.class.php index 8e00afa..5a285d0 100644 --- a/webclient/lib/summoner.class.php +++ b/webclient/lib/summoner.class.php @@ -377,9 +377,9 @@ class Summoner { } /** - * delete and/or empty a diretory + * delete and/or empty a directory * - * $empty = true => empty the diretory but do not delete it + * $empty = true => empty the directory but do not delete it * * @param string $directory * @param bool $empty diff --git a/webclient/lib/tentacle.class.php b/webclient/lib/tentacle.class.php index cca6271..7e6bab4 100644 --- a/webclient/lib/tentacle.class.php +++ b/webclient/lib/tentacle.class.php @@ -50,7 +50,7 @@ class Tentacle { * Validate if given action is a valid tool and if the user has access * * @param string $identifier - * @return bool + * @return bool|mixed */ public function validate($identifier) { $ret = false; diff --git a/webclient/lib/trite.class.php b/webclient/lib/trite.class.php index 211142a..b323a36 100644 --- a/webclient/lib/trite.class.php +++ b/webclient/lib/trite.class.php @@ -252,6 +252,9 @@ class Trite { if(!empty($result['value'])) { $ret[$result['id']]['entries'][$result['value']] = $result['value']; } + elseif(!isset($ret[$result['id']]['entries'])) { + $ret[$result['id']]['entries'] = array(); + } } } } catch (Exception $e) { diff --git a/webclient/view/default/advancedsearch/advancedsearch.php b/webclient/view/default/advancedsearch/advancedsearch.php index 1b88311..5ce42ca 100644 --- a/webclient/view/default/advancedsearch/advancedsearch.php +++ b/webclient/view/default/advancedsearch/advancedsearch.php @@ -27,6 +27,7 @@ if(isset($_GET['collection']) && !empty($_GET['collection'])) { $_collection = Summoner::validate($_collection,'digit') ? $_collection : false; } +$TemplateData['pageTitle'] = 'Advanced search'; $TemplateData['loadedCollection'] = array(); $TemplateData['collections'] = array(); $TemplateData['collectionFields'] = array(); diff --git a/webclient/view/default/auth/auth.php b/webclient/view/default/auth/auth.php index 6939a46..a5be9a4 100644 --- a/webclient/view/default/auth/auth.php +++ b/webclient/view/default/auth/auth.php @@ -18,6 +18,8 @@ // passwords used here: password_hash("somePassword", PASSWORD_DEFAULT); +$TemplateData['pageTitle'] = 'Auth'; + if(isset($_GET['m']) && !empty($_GET['m'])) { if($_GET['m'] == "logout") { $Doomguy->logOut(); diff --git a/webclient/view/default/collections/collections.php b/webclient/view/default/collections/collections.php index 1200856..3253069 100644 --- a/webclient/view/default/collections/collections.php +++ b/webclient/view/default/collections/collections.php @@ -49,6 +49,7 @@ if(isset($_POST['navSearch'])) { require_once(Summoner::themefile('system/pagination_before.php',UI_THEME)); +$TemplateData['pageTitle'] = "Collection overview"; $TemplateData['loadedCollection'] = array(); $TemplateData['storagePath'] = ''; $TemplateData['entries'] = array(); @@ -93,6 +94,9 @@ if(!empty($_collection)) { if (!empty($_search)) { $TemplateData['search'] = $_search; } + + $TemplateData['pageTitle'] = $Trite->param('name'); + } else { $TemplateData['message']['content'] = "Can not load given collection."; diff --git a/webclient/view/default/entry/entry.php b/webclient/view/default/entry/entry.php index 704ba3e..f6e7752 100644 --- a/webclient/view/default/entry/entry.php +++ b/webclient/view/default/entry/entry.php @@ -35,6 +35,7 @@ if(isset($_GET['id']) && !empty($_GET['id'])) { $_id = Summoner::validate($_id,'digit') ? $_id : false; } +$TemplateData['pageTitle'] = '?'; $TemplateData['fieldViewDefault'] = Summoner::themefile('entry/field-unknown.html', UI_THEME); $TemplateData['entry'] = array(); $TemplateData['loadedCollection'] = array(); @@ -51,6 +52,13 @@ if(!empty($_collection) && !empty($_id)) { $ManageEntry->setCollection($Trite->param('id')); $TemplateData['showEdit'] = $ManageEntry->canEditEntry($_id); + + if(isset($TemplateData['entry']['fields']['title'])) { + $TemplateData['pageTitle'] = $TemplateData['entry']['fields']['title']['value'].' - '.$Trite->param('name'); + } + else { + $TemplateData['pageTitle'] = ' - '.$Trite->param('name'); + } } else { $TemplateData['message']['content'] = 'Can not load given collection.'; diff --git a/webclient/view/default/main.php b/webclient/view/default/main.php index 48511cc..3e6f722 100644 --- a/webclient/view/default/main.php +++ b/webclient/view/default/main.php @@ -10,7 +10,7 @@ - Bibliotheca + <?php echo $TemplateData['pageTitle']; ?> - Bibliotheca
diff --git a/webclient/view/default/managecollectionfields/managecollectionfields.php b/webclient/view/default/managecollectionfields/managecollectionfields.php index 1a70cbd..8ef8125 100644 --- a/webclient/view/default/managecollectionfields/managecollectionfields.php +++ b/webclient/view/default/managecollectionfields/managecollectionfields.php @@ -27,6 +27,8 @@ $ManangeCollectionFields = new ManageCollectionFields($DB,$Doomguy); $TemplateData['availableFields'] = $ManangeCollectionFields->getAvailableFields(); $TemplateData['existingFields'] = array(); +$TemplateData['pageTitle'] = 'Manage collection fields'; + $_id = false; if(isset($_GET['id']) && !empty($_GET['id'])) { $_id = trim($_GET['id']); diff --git a/webclient/view/default/managecolletions/managecolletions.php b/webclient/view/default/managecolletions/managecolletions.php index b029a3b..2111163 100644 --- a/webclient/view/default/managecolletions/managecolletions.php +++ b/webclient/view/default/managecolletions/managecolletions.php @@ -31,6 +31,8 @@ $TemplateData['editData']['rights'] = Summoner::prepareRightsArray('rwxr--r--'); $TemplateData['editData']['tool'] = array(); $TemplateData['existingFields'] = array(); +$TemplateData['pageTitle'] = 'Manage collection'; + // @todo providing the id is enough $_editMode = false; if(isset($_GET['m']) && !empty($_GET['m'])) { diff --git a/webclient/view/default/manageentry/manageentry.html b/webclient/view/default/manageentry/manageentry.html index 4bb6397..573d720 100644 --- a/webclient/view/default/manageentry/manageentry.html +++ b/webclient/view/default/manageentry/manageentry.html @@ -29,6 +29,7 @@ if(!empty($TemplateData['editFields'])) { if(!empty($TemplateData['editData']['_isOwner'])) { ?> +
Rights
diff --git a/webclient/view/default/manageentry/manageentry.php b/webclient/view/default/manageentry/manageentry.php index 29720e1..ba7f5d9 100644 --- a/webclient/view/default/manageentry/manageentry.php +++ b/webclient/view/default/manageentry/manageentry.php @@ -21,6 +21,7 @@ $Trite = new Trite($DB,$Doomguy); require_once 'lib/manageentry.class.php'; $ManangeEntry = new Manageentry($DB,$Doomguy); +$TemplateData['pageTitle'] = 'Manage entry - '; $TemplateData['editFields'] = array(); $TemplateData['editData'] = array(); $TemplateData['loadedCollection'] = ''; @@ -50,6 +51,8 @@ if(!empty($_collection)) { $TemplateData['editFields'] = $ManangeEntry->getEditFields(); $TemplateData['availableTools'] = $Trite->getAvailableTools(); + $TemplateData['pageTitle'] = 'Add - '.$Trite->param('name'); + if(!empty($_id)) { $TemplateData['storagePath'] = PATH_WEB_STORAGE . '/' . $_collection . '/' . $_id; @@ -60,6 +63,9 @@ if(!empty($_collection)) { $TemplateData['message']['content'] = "Entry has no value in title field."; $TemplateData['message']['status'] = "error"; } + else { + $TemplateData['pageTitle'] = 'Edit - '.$TemplateData['editData']['title'].' - '.$Trite->param('name'); + } } if(isset($_POST['submitForm'])) { @@ -149,5 +155,6 @@ if(!empty($_collection)) { } } else { + $TemplateData['pageTitle'] .= 'collection overview'; $TemplateData['existingCollections'] = $Trite->getCollections("write"); } diff --git a/webclient/view/default/managegroups/managegroups.php b/webclient/view/default/managegroups/managegroups.php index 4220091..2936ffb 100644 --- a/webclient/view/default/managegroups/managegroups.php +++ b/webclient/view/default/managegroups/managegroups.php @@ -20,6 +20,8 @@ $Possessed = new Possessed($DB, $Doomguy); $TemplateData['existingGroups'] = $Possessed->getGroups(); $TemplateData['editData'] = false; +$TemplateData['pageTitle'] = 'Manage groups'; + $_id = false; if(isset($_GET['id']) && !empty($_GET['id'])) { $_id = trim($_GET['id']); diff --git a/webclient/view/default/managetags/managetags.php b/webclient/view/default/managetags/managetags.php index 4560353..329b57d 100644 --- a/webclient/view/default/managetags/managetags.php +++ b/webclient/view/default/managetags/managetags.php @@ -35,6 +35,7 @@ if(isset($_GET['id']) && !empty($_GET['id'])) { $TemplateData['loadedCollection'] = array(); $TemplateData['collections'] = array(); +$TemplateData['pageTitle'] = 'Manage tags'; if(!empty($_collection)) { $TemplateData['loadedCollection'] = $Trite->load($_collection, "write"); diff --git a/webclient/view/default/manageusers/manageusers.php b/webclient/view/default/manageusers/manageusers.php index 09c11bb..7c431ff 100644 --- a/webclient/view/default/manageusers/manageusers.php +++ b/webclient/view/default/manageusers/manageusers.php @@ -21,6 +21,7 @@ $TemplateData['existingGroups'] = $Possessed->getGroups(); $TemplateData['existingUsers'] = $Possessed->getUsers(); $TemplateData['editData'] = false; $TemplateData['editData']['groups'] = array(); +$TemplateData['pageTitle'] = 'Manage users'; $_id = false; if(isset($_GET['id']) && !empty($_GET['id'])) { diff --git a/webclient/view/default/profile/profile.php b/webclient/view/default/profile/profile.php index 7d6397e..2deb759 100644 --- a/webclient/view/default/profile/profile.php +++ b/webclient/view/default/profile/profile.php @@ -19,6 +19,7 @@ require_once 'lib/possessed.class.php'; $Possessed = new Possessed($DB, $Doomguy); $TemplateData['editData'] = $Doomguy->getAllUserData(); +$TemplateData['pageTitle'] = 'Profile'; if(!empty($TemplateData['editData'])) { if(isset($_POST['submitForm'])) { diff --git a/webclient/view/default/tags/tags.php b/webclient/view/default/tags/tags.php index edc5c2b..d64bf97 100644 --- a/webclient/view/default/tags/tags.php +++ b/webclient/view/default/tags/tags.php @@ -33,6 +33,7 @@ if(isset($_GET['id']) && !empty($_GET['id'])) { $_id = Summoner::validate($_id,'digit') ? $_id : false; } +$TemplateData['pageTitle'] = 'Tags - '; $TemplateData['loadedCollection'] = array(); $TemplateData['tags'] = array(); $TemplateData['search'] = false; @@ -56,6 +57,8 @@ if(!empty($_collection)) { } $Trite->getTags(); + + $TemplateData['pageTitle'] = $Trite->param('name'); } else { $TemplateData['message']['content'] = "Can not load given collection."; @@ -63,5 +66,6 @@ if(!empty($_collection)) { } } else { + $TemplateData['pageTitle'] .= 'collection overview'; $TemplateData['collections'] = $Trite->getCollections(); } diff --git a/webclient/view/default/tool/tool.php b/webclient/view/default/tool/tool.php index 2ca39e2..cb568f5 100644 --- a/webclient/view/default/tool/tool.php +++ b/webclient/view/default/tool/tool.php @@ -18,13 +18,14 @@ require_once 'lib/tentacle.class.php'; $Tools = new Tentacle($DB,$Doomguy); -require_once 'lib/managecollections.class.php'; -$ManangeCollections = new ManageCollections($DB,$Doomguy); require_once 'lib/managecollectionfields.class.php'; $ManangeCollectionsFields = new ManageCollectionFields($DB, $Doomguy); require_once 'lib/manageentry.class.php'; $Manageentry = new Manageentry($DB,$Doomguy); +require_once 'lib/trite.class.php'; +$Trite = new Trite($DB,$Doomguy); +$TemplateData['pageTitle'] = 'Tool'; $TemplateData['tool'] = array(); $TemplateData['tool']['viewFile'] = ''; $TemplateData['collection'] = array(); @@ -49,15 +50,15 @@ if(isset($_GET['t']) && !empty($_GET['t'])) { } if(!empty($_collection) && !empty($_t)) { - $collection = $ManangeCollections->getCollection($_collection,"write"); + $collection = $Trite->load($_collection,"write"); $toolInfo = $Tools->validate($_t); if(!empty($collection) && !empty($toolInfo)) { $TemplateData['tool'] = $toolInfo; $TemplateData['collection'] = $collection; - $ManangeCollectionsFields->setCollection($_collection); - $Manageentry->setCollection($_collection); + $ManangeCollectionsFields->setCollection($Trite->param('id')); + $Manageentry->setCollection($Trite->param('id')); if(!empty($_id)) { $TemplateData['editEntry'] = $Manageentry->getEditData($_id); @@ -68,6 +69,8 @@ if(!empty($_collection) && !empty($_t)) { if(file_exists($_toolFile) && file_exists($_toolViewFile)) { require_once $_toolFile; $TemplateData['tool']['viewFile'] = $_toolViewFile; + + $TemplateData['pageTitle'] .= ' - '.$toolInfo['name']; } else { $TemplateData['tool']['viewFile'] = ''; -- 2.39.5