diff --git a/bl-kernel/admin/controllers/edit-tag.php b/bl-kernel/admin/controllers/edit-tag.php
new file mode 100644
index 00000000..caae1270
--- /dev/null
+++ b/bl-kernel/admin/controllers/edit-tag.php
@@ -0,0 +1,44 @@
+exists($tagKey)) {
+ Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the tag: '.$tagKey);
+ Redirect::page('tags');
+}
+
+$tagMap = $tags->getMap($tagKey);
+
+// Title of the page
+$layout['title'] .= ' - '.$L->g('Edit Tag').' [ '.$tagMap['name'] . ' ] ';
diff --git a/bl-kernel/admin/controllers/new-tag.php b/bl-kernel/admin/controllers/new-tag.php
new file mode 100644
index 00000000..34a7b2e1
--- /dev/null
+++ b/bl-kernel/admin/controllers/new-tag.php
@@ -0,0 +1,32 @@
+g('New tag');
diff --git a/bl-kernel/admin/controllers/tags.php b/bl-kernel/admin/controllers/tags.php
new file mode 100644
index 00000000..095e75f5
--- /dev/null
+++ b/bl-kernel/admin/controllers/tags.php
@@ -0,0 +1,26 @@
+g('Tags');
diff --git a/bl-kernel/admin/themes/booty/html/navbar.php b/bl-kernel/admin/themes/booty/html/navbar.php
index 835984a4..1fa5a061 100644
--- a/bl-kernel/admin/themes/booty/html/navbar.php
+++ b/bl-kernel/admin/themes/booty/html/navbar.php
@@ -28,6 +28,10 @@
p('Categories') ?>
+
+
+ p('Tags') ?>
+
p('Users') ?>
diff --git a/bl-kernel/admin/themes/booty/html/sidebar.php b/bl-kernel/admin/themes/booty/html/sidebar.php
index fad9080f..d0c79856 100644
--- a/bl-kernel/admin/themes/booty/html/sidebar.php
+++ b/bl-kernel/admin/themes/booty/html/sidebar.php
@@ -38,6 +38,9 @@
p('Categories') ?>
+
+ p('Tags') ?>
+
p('Users') ?>
diff --git a/bl-kernel/admin/themes/booty/init.php b/bl-kernel/admin/themes/booty/init.php
index c53a852c..bac07f89 100644
--- a/bl-kernel/admin/themes/booty/init.php
+++ b/bl-kernel/admin/themes/booty/init.php
@@ -385,6 +385,32 @@ EOF;
return <<$text
+EOF;
+ }
+
+ public static function linkedPagesTable($pagesArray){
+ global $pages;
+ global $L;
+
+ $rows = array();
+ $headingTemplate = '%s | %s | %s |
';
+ $heading = sprintf($headingTemplate, $L->g('Page'), $L->g('Url'), $L->g('Type'));
+ $elemTemplate = '%s | %s | %s |
';
+
+ foreach($pagesArray as $pageKey){
+ $tmpPage = new Page($pageKey);
+ if($tmpPage){
+ $rows[] = sprintf($elemTemplate, $tmpPage->slug(), $tmpPage->title(), $tmpPage->title(), $tmpPage->slug(), $tmpPage->slug(), $tmpPage->slug(), $tmpPage->type());
+ }
+ }
+
+ $rows = implode('', $rows);
+
+return <<
+ $heading
+ $rows
+
EOF;
}
}
diff --git a/bl-kernel/admin/views/edit-tag.php b/bl-kernel/admin/views/edit-tag.php
new file mode 100644
index 00000000..e65a10e8
--- /dev/null
+++ b/bl-kernel/admin/views/edit-tag.php
@@ -0,0 +1,81 @@
+
+
+'jsform')); ?>
+
+
+
+ $L->g('Edit Tag'), 'icon'=>'cog')); ?>
+
+
+'tokenCSRF',
+ 'value'=>$security->getTokenCSRF()
+ ));
+
+ echo Bootstrap::formInputHidden(array(
+ 'name'=>'action',
+ 'value'=>'edit'
+ ));
+
+ echo Bootstrap::formInputHidden(array(
+ 'name'=>'oldKey',
+ 'value'=>$tagMap['key']
+ ));
+
+ echo Bootstrap::formInputText(array(
+ 'name'=>'name',
+ 'label'=>$L->g('Name'),
+ 'value'=>$tagMap['name'],
+ 'class'=>'',
+ 'placeholder'=>'',
+ 'tip'=>''
+ ));
+
+ echo Bootstrap::formInputText(array(
+ 'name'=>'newKey',
+ 'label'=>$L->g('Friendly URL'),
+ 'value'=>$tagMap['key'],
+ 'class'=>'',
+ 'placeholder'=>'',
+ 'tip'=>DOMAIN_TAGS.$tagMap['key']
+ ));
+
+ echo '' . $L->g('linked-pages') . '
';
+ if(sizeof($tagMap['list']) > 0){
+ echo Bootstrap::linkedPagesTable($tagMap['list']);
+ }
+ else {
+ echo $L->g('no-linked-pages');
+ }
+
+echo Bootstrap::formClose();
+
+?>
+
+
+$L->g('Delete'),
+ 'buttonPrimaryClass'=>'btn-danger jsbuttonDeleteAccept',
+ 'buttonSecondary'=>$L->g('Cancel'),
+ 'buttonSecondaryClass'=>'btn-link',
+ 'modalTitle'=>$L->g('Delete tag'),
+ 'modalText'=>$L->g('Are you sure you want to delete this tag?'),
+ 'modalId'=>'jsdeleteModal'
+ ));
+?>
+
diff --git a/bl-kernel/admin/views/new-tag.php b/bl-kernel/admin/views/new-tag.php
new file mode 100644
index 00000000..63c2e524
--- /dev/null
+++ b/bl-kernel/admin/views/new-tag.php
@@ -0,0 +1,29 @@
+
+
+'jsform', 'class'=>'tab-content')); ?>
+
+
+
+ $L->g('New tag'), 'icon'=>'tag')); ?>
+
+
+'tokenCSRF',
+ 'value'=>$security->getTokenCSRF()
+ ));
+
+ echo Bootstrap::formInputText(array(
+ 'name'=>'name',
+ 'label'=>$L->g('Name'),
+ 'value'=>isset($_POST['tag'])?$_POST['tag']:'',
+ 'class'=>'',
+ 'placeholder'=>'',
+ 'tip'=>''
+ ));
+?>
+
+
diff --git a/bl-kernel/admin/views/tags.php b/bl-kernel/admin/views/tags.php
new file mode 100644
index 00000000..e4934213
--- /dev/null
+++ b/bl-kernel/admin/views/tags.php
@@ -0,0 +1,33 @@
+$L->g('Tags'), 'icon'=>'tags'));
+
+echo Bootstrap::link(array(
+ 'title'=>$L->g('Add a new tag'),
+ 'href'=>HTML_PATH_ADMIN_ROOT.'new-tag',
+ 'icon'=>'plus'
+));
+
+echo '
+
+';
diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php
index e63be907..e423fcd5 100644
--- a/bl-kernel/boot/init.php
+++ b/bl-kernel/boot/init.php
@@ -127,6 +127,7 @@ $pages = new Pages();
$users = new Users();
$tags = new Tags();
$categories = new Categories();
+$tags = new Tags();
$site = new Site();
$url = new Url();
$security = new Security();
diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php
index 2f2518f0..452af9c9 100644
--- a/bl-kernel/functions.php
+++ b/bl-kernel/functions.php
@@ -744,6 +744,84 @@ function deleteCategory($args) {
return true;
}
+// Add a new tag to the system
+// Returns TRUE is successfully added, FALSE otherwise
+function createTag($args) {
+ global $tags;
+ global $L;
+ global $syslog;
+
+ if (Text::isEmpty($args['name'])) {
+ Alert::set($L->g('Tag name is empty'), ALERT_STATUS_FAIL);
+ return false;
+ }
+
+ if ($tags->add(array('name'=>$args['name'], 'description'=>$args['description']))) {
+ // Add to syslog
+ $syslog->add(array(
+ 'dictionaryKey'=>'new-tag-created',
+ 'notes'=>$args['name']
+ ));
+
+ Alert::set($L->g('Tag added'), ALERT_STATUS_OK);
+ return true;
+ }
+
+ Alert::set($L->g('The tag already exists'), ALERT_STATUS_FAIL);
+ return false;
+}
+
+function editTag($args) {
+ global $L;
+ global $pages;
+ global $tags;
+ global $syslog;
+
+ if (Text::isEmpty($args['name']) || Text::isEmpty($args['newKey']) ) {
+ Alert::set($L->g('Empty fields'));
+ return false;
+ }
+
+ $newTagKey = $tags->edit($args);
+
+ if ($newTagKey==false) {
+ Alert::set($L->g('The category already exists'));
+ return false;
+ }
+
+ // Change the tag key in the pages database
+ $pages->changeTag($args['oldKey'], $newTagKey);
+
+ // Add to syslog
+ $syslog->add(array(
+ 'dictionaryKey'=>'tag-edited',
+ 'notes'=>$newTagKey
+ ));
+
+ Alert::set($L->g('The changes have been saved'));
+ return true;
+}
+
+function deleteTag($args) {
+ global $L;
+ global $tags;
+ global $syslog;
+
+ // Remove the category by key
+ $tags->remove($args['oldKey']);
+
+ // Remove the category from the pages ? or keep it if the user want to recovery the category ?
+
+ // Add to syslog
+ $syslog->add(array(
+ 'dictionaryKey'=>'tag-deleted',
+ 'notes'=>$args['oldKey']
+ ));
+
+ Alert::set($L->g('The changes have been saved'));
+ return true;
+}
+
// Returns an array with all the categories
// By default, the database of categories is alphanumeric sorted
function getCategories() {
diff --git a/bl-languages/de_CH.json b/bl-languages/de_CH.json
index 07197101..44d1f06d 100644
--- a/bl-languages/de_CH.json
+++ b/bl-languages/de_CH.json
@@ -54,6 +54,7 @@
"dashboard": "Dashboard",
"manage-users": "Benutzer verwalten",
"manage-categories": "Kategorien verwalten",
+ "manage-tags": "Schlagwörter verwalten",
"general-settings": "Allgemeine Einstellungen",
"advanced-settings": "Erweiterte Einstellungen",
"thanks-for-support-bludit": "Vielen Dank für die Unterstützung von Bludit!",
@@ -73,6 +74,7 @@
"content": "Inhalte",
"category": "Kategorie",
"categories": "Kategorien",
+ "tag":"Schlagwort",
"users": "Benutzer",
"settings": "Einstellungen",
"general": "Allgemein",
@@ -81,6 +83,7 @@
"manage-content": "Inhalte verwalten",
"add-new-content": "Neuen Inhalt erstellen",
"new-category": "Neue Kategorie",
+ "new-tag": "Neues Schlagwort",
"you-do-not-have-sufficient-permissions": "Keine Berechtigung, die Seite aufzurufen.",
"add-a-new-user": "Neuer Benutzer",
"url-associated-with-the-content": "Der URL kann selbst angepasst werden.",
@@ -129,6 +132,7 @@
"friendly-url": "URL",
"image-description": "Bildbeschreibung",
"add-a-new-category": "Neue Kategorie hinzufügen",
+ "add-a-new-tag": "Neues Schlagwort hinzufügen",
"name": "Name",
"username": "Benutzername",
"first-name": "Vorname",
@@ -164,6 +168,9 @@
"activate": "Aktivieren",
"deactivate": "Deaktivieren",
"edit-category": "Kategorie bearbeiten",
+ "edit-tag": "Schlagwort bearbeiten",
+ "no-linked-pages": "Keine Seiten verlinkt",
+ "linked-pages": "Verlinkte Seiten",
"delete": "Löschen",
"password": "Passwort",
"confirm-password": "Passwort wiederholen",
@@ -178,6 +185,8 @@
"profile-picture": "Profil-Bild",
"edit-or-delete-your-categories": "Kategorien bearbeiten oder löschen.",
"create-a-new-category-to-organize-your-content": "Eine neue Kategorie hinzufügen.",
+ "edit-or-delete-your-tags": "Schlagwörter bearbeiten oder löschen.",
+ "create-a-new-tag-to-organize-your-content": "Ein neues Schlagwort hinzufügen.",
"confirm-delete-this-action-cannot-be-undone": "Bestätigung der Löschung. Diese kann nicht rückgängig gemacht werden.",
"do-you-want-to-disable-the-user": "Soll der Benutzer deaktiviert werden?",
"new-password": "Neues Passwort",
@@ -214,6 +223,9 @@
"new-category-created": "Kategorie hinzugefügt",
"category-deleted": "Kategorie gelöscht",
"category-edited": "Kategorie bearbeitet",
+ "new-tag-created": "Schlagwort hinzugefügt",
+ "tag-deleted": "Schlagwort gelöscht",
+ "tag-edited": "Schlagwort bearbeitet",
"new-user-created": "Benutzer hinzugefügt",
"user-edited": "Benutzer bearbeitet",
"user-deleted": "Benutzer gelöscht",
@@ -332,6 +344,8 @@
"done": "Bestätigen",
"delete-category": "Kategorie löschen",
"are-you-sure-you-want-to-delete-this-category?": "Bist du sicher, dass Du diese Kategorie löschen möchtest?",
+ "delete-tag": "Schlagwort löschen",
+ "are-you-sure-you-want-to-delete-this-tag?": "Bist du sicher, dass Du dieses Schlagwort löschen möchtest?",
"confirm-new-password": "Bestätige das neue Passwort",
"the-nickname-is-almost-used-in-the-themes-to-display-the-author-of-the-content": "Der Nickname wird als Name des Autors von Beiträgen angezeigt.",
"allow-unicode": "Unicode",
diff --git a/bl-languages/en.json b/bl-languages/en.json
index 9c03dace..c53795d2 100644
--- a/bl-languages/en.json
+++ b/bl-languages/en.json
@@ -53,6 +53,7 @@
"dashboard": "Dashboard",
"manage-users": "Manage users",
"manage-categories": "Manage categories",
+ "manage-tags": "Manage tags",
"general-settings": "General settings",
"advanced-settings": "Advanced settings",
"thanks-for-support-bludit": "Thanks for support Bludit",
@@ -80,6 +81,7 @@
"manage-content": "Manage content",
"add-new-content": "Add new content",
"new-category": "New category",
+ "new-tag": "New tag",
"you-do-not-have-sufficient-permissions": "You do not have sufficient permissions",
"add-a-new-user": "Add a new user",
"url-associated-with-the-content": "URL associated with the content.",
@@ -128,6 +130,7 @@
"friendly-url": "Friendly URL",
"image-description": "Image description",
"add-a-new-category": "Add a new category",
+ "add-a-new-tag": "Add a new tag",
"name": "Name",
"username": "Username",
"first-name": "First name",
@@ -163,6 +166,9 @@
"activate": "Activate",
"deactivate": "Deactivate",
"edit-category": "Edit category",
+ "edit-tag": "Edit tag",
+ "no-linked-pages": "No linked pages",
+ "linked-pages": "Linked pages",
"delete": "Delete",
"password": "Password",
"confirm-password": "Confirm Password",
@@ -177,6 +183,8 @@
"profile-picture": "Profile picture",
"edit-or-delete-your-categories": "Edit or delete your categories",
"create-a-new-category-to-organize-your-content": "Create a new category to organize your content",
+ "edit-or-delete-your-tags": "Edit or delete your tags",
+ "create-a-new-tag-to-organize-your-content": "Create a new tag to organize your content",
"confirm-delete-this-action-cannot-be-undone": "Confirm delete, this action cannot be undone.",
"do-you-want-to-disable-the-user": "Do you want to disable the user ?",
"new-password": "New password",
@@ -213,6 +221,9 @@
"new-category-created": "New category created",
"category-deleted": "Category deleted",
"category-edited": "Category edited",
+ "new-tag-created": "New tag created",
+ "tag-deleted": "tag deleted",
+ "tag-edited": "tag edited",
"new-user-created": "New user created",
"user-edited": "User edited",
"user-deleted": "User deleted",
@@ -331,6 +342,8 @@
"done": "Done",
"delete-category": "Delete category",
"are-you-sure-you-want-to-delete-this-category?": "Are you sure you want to delete this category?",
+ "delete-tag": "Delete tag",
+ "are-you-sure-you-want-to-delete-this-tag?": "Are you sure you want to delete this tag?",
"confirm-new-password": "Confirm new password",
"the-nickname-is-almost-used-in-the-themes-to-display-the-author-of-the-content": "The nickname is almost used in the themes to display the author of the content",
"allow-unicode": "Allow Unicode",
@@ -377,4 +390,4 @@
"thumbnail-width-in-pixels": "Thumbnail width in pixels (px).",
"thumbnail-height-in-pixels": "Thumbnail height in pixels (px).",
"thumbnail-quality-in-percentage": "Thumbnail quality in percentage (%)."
-}
\ No newline at end of file
+}