diff --git a/library/Class/ArticleCategorie.php b/library/Class/ArticleCategorie.php index c26f66721b47025d993c125b1f98da2ad056223f..17c9b9fad4eb56bfc3767a2371836f7182fa5e6f 100644 --- a/library/Class/ArticleCategorie.php +++ b/library/Class/ArticleCategorie.php @@ -122,27 +122,12 @@ class Class_ArticleCategorie extends Storm_Model_Abstract { } - /** [[file:~/public_html/afi-opac3/library/Trait/TreeNode.php::trait%20Trait_TreeNode%20{][voir Trait_TreeNode]] */ - public function getParent() { - return $this->getParentCategorie(); - } - - /** [[file:~/public_html/afi-opac3/library/Trait/TreeNode.php::trait%20Trait_TreeNode%20{][voir Trait_TreeNode]] */ public function getParentIdFieldName() { return 'id_cat_mere'; } - /** - * cf [[file:~/public_html/afi-opac3/library/Trait/TreeNode.php::trait%20Trait_TreeNode%20{][Trait_TreeNode]] - */ - public function getChildren() { - return $this->getSousCategories(); - } - - - public function getRecursiveSousCategories() { $all_categories = $sous_categories = $this->getSousCategories(); foreach ($sous_categories as $categorie) diff --git a/library/Class/SitothequeCategorie.php b/library/Class/SitothequeCategorie.php index 0a43ebb7f282f602e5fb2c765481f4a2125c27e4..bb9d1ba4967432383dacca4aa67961ca273ac039 100644 --- a/library/Class/SitothequeCategorie.php +++ b/library/Class/SitothequeCategorie.php @@ -45,27 +45,12 @@ class Class_SitothequeCategorie extends Storm_Model_Abstract { 'id_site' => 0]; - /** [[file:~/public_html/afi-opac3/library/Trait/TreeNode.php::trait%20Trait_TreeNode%20{][voir Trait_TreeNode]] */ - public function getParent() { - return $this->getParentCategorie(); - } - - /** [[file:~/public_html/afi-opac3/library/Trait/TreeNode.php::trait%20Trait_TreeNode%20{][voir Trait_TreeNode]] */ public function getParentIdFieldName() { return 'id_cat_mere'; } - /** - * cf [[file:~/public_html/afi-opac3/library/Trait/TreeNode.php::trait%20Trait_TreeNode%20{][Trait_TreeNode]] - */ - public function getChildren() { - return $this->getSousCategories(); - } - - - public function getIdZone() { if (!$this->hasZone()) return 0; diff --git a/library/Class/UserGroupCategorie.php b/library/Class/UserGroupCategorie.php index b1cccf99f0b8b1bf5c4bcd131acfef7b7a41a877..76f599b89fa65f4b5d3dfb1e0a3eb10f9721e9d2 100644 --- a/library/Class/UserGroupCategorie.php +++ b/library/Class/UserGroupCategorie.php @@ -51,6 +51,7 @@ class UserGroupCategorieLoader extends Storm_Model_Loader{ class Class_UserGroupCategorie extends Storm_Model_Abstract { use Trait_TreeViewableCategorie, Trait_Translator, Trait_TreeNode; + protected $_table_name = 'user_group_categorie', $_loader_class = 'UserGroupCategorieLoader', @@ -72,32 +73,11 @@ class Class_UserGroupCategorie extends Storm_Model_Abstract { $_default_attribute_values = ['parent_id' => 0]; - /** [[file:~/public_html/afi-opac3/library/Trait/TreeNode.php::trait%20Trait_TreeNode%20{][voir Trait_TreeNode]] */ - public function getParent() { - return $this->getParentCategorie(); - } - - - /** - * cf [[file:~/public_html/afi-opac3/library/Trait/TreeNode.php::trait%20Trait_TreeNode%20{][Trait_TreeNode]] - */ - public function getChildren() { - return $this->getSousCategories(); - } - - /** - * @return array - */ public function getItems() { return $this->getUserGroups(); } - public function getSousCategories() { - return parent::_get('sous_categories'); - } - - public function getIdCatMere() { return $this->getParentId(); } diff --git a/library/Trait/Tree.php b/library/Trait/Tree.php new file mode 100644 index 0000000000000000000000000000000000000000..93aa996a77afa01d223aa081609fc33ee93f3dbe --- /dev/null +++ b/library/Trait/Tree.php @@ -0,0 +1,26 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +trait Trait_Tree { + abstract public function getParent(); + abstract public function getChildren(); +} \ No newline at end of file diff --git a/library/Trait/TreeNode.php b/library/Trait/TreeNode.php index dd7e4fa7f9a65e245f163d1b5e5a81594da8adc8..177f5663f516be194952741c20cb10b16f8df3a8 100644 --- a/library/Trait/TreeNode.php +++ b/library/Trait/TreeNode.php @@ -20,6 +20,8 @@ */ trait Trait_TreeNode { + use Trait_Tree; + public static $PATH_SEPARATOR = '/'; protected $_path_cache = []; @@ -87,10 +89,12 @@ trait Trait_TreeNode { } - abstract public function getParent(); - - abstract public function getChildren(); + public function getLeaves() { + ; + } -} -?> \ No newline at end of file + public function getNodes() { + ; + } +} \ No newline at end of file diff --git a/library/Trait/TreeViewableCategorie.php b/library/Trait/TreeViewableCategorie.php index 16eb30d70251beac28feef5ad8a4f4b7c94a9e03..56dd3940c382eb36870a40a6d5a476f80fbe3aa3 100644 --- a/library/Trait/TreeViewableCategorie.php +++ b/library/Trait/TreeViewableCategorie.php @@ -16,10 +16,12 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ trait Trait_TreeViewableCategorie { + use Trait_Tree; + /** * @return bool */ @@ -75,6 +77,14 @@ trait Trait_TreeViewableCategorie { '"items": ['.implode(",", $json_items).']'. '}'; } -} -?> \ No newline at end of file + + public function getParent() { + return $this->getParentCategorie(); + } + + + public function getChildren() { + return $this->getSousCategories(); + } +} \ No newline at end of file diff --git a/library/Trait/TreeViewableItem.php b/library/Trait/TreeViewableItem.php index 0f6ba15cb367e47247378883f1713cca0869af06..eb01606fe2c3cf5c2aea1f85705014a4a66cdce7 100644 --- a/library/Trait/TreeViewableItem.php +++ b/library/Trait/TreeViewableItem.php @@ -20,6 +20,8 @@ */ trait Trait_TreeViewableItem { + use Trait_Tree; + public function getBib() { return $this->getCategorie() ? $this->getCategorie()->getBib() @@ -61,6 +63,14 @@ trait Trait_TreeViewableItem { "label" => htmlspecialchars($this->getLibelle())]); } -} -?> \ No newline at end of file + + public function getParent() { + return $this->getCategorie(); + } + + + public function getChildren() { + return []; + } +} \ No newline at end of file