categories.lib.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /* Copyright (C) 2011 Regis Houssin <regis.houssin@inodbox.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. * or see https://www.gnu.org/
  17. */
  18. /**
  19. * \file htdocs/core/lib/categories.lib.php
  20. * \brief Ensemble de fonctions de base pour le module categorie
  21. * \ingroup categorie
  22. */
  23. /**
  24. * Prepare array with list of tabs
  25. *
  26. * @param Object $object Object related to tabs
  27. * @param string $type Type of category
  28. * @return array Array of tabs to show
  29. */
  30. function categories_prepare_head(Categorie $object, $type)
  31. {
  32. global $langs, $conf, $user;
  33. // Load translation files required by the page
  34. $langs->loadLangs(array('categories', 'products'));
  35. $h = 0;
  36. $head = array();
  37. $head[$h][0] = DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&amp;type='.$type;
  38. $head[$h][1] = $langs->trans("Category");
  39. $head[$h][2] = 'card';
  40. $h++;
  41. $head[$h][0] = DOL_URL_ROOT.'/categories/photos.php?id='.$object->id.'&amp;type='.$type;
  42. $head[$h][1] = $langs->trans("Photos");
  43. $head[$h][2] = 'photos';
  44. $h++;
  45. if (getDolGlobalInt('MAIN_MULTILANGS')) {
  46. $head[$h][0] = DOL_URL_ROOT.'/categories/traduction.php?id='.$object->id.'&amp;type='.$type;
  47. $head[$h][1] = $langs->trans("Translation");
  48. $head[$h][2] = 'translation';
  49. $h++;
  50. }
  51. $head[$h][0] = DOL_URL_ROOT.'/categories/info.php?id='.$object->id.'&amp;type='.$type;
  52. $head[$h][1] = $langs->trans("Info");
  53. $head[$h][2] = 'info';
  54. $h++;
  55. // Show more tabs from modules
  56. // Entries must be declared in modules descriptor with line
  57. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  58. // $this->tabs = array('entity:-tabname); to remove a tab
  59. complete_head_from_modules($conf, $langs, $object, $head, $h, 'categories_'.$type);
  60. complete_head_from_modules($conf, $langs, $object, $head, $h, 'categories_'.$type, 'remove');
  61. return $head;
  62. }
  63. /**
  64. * Prepare array with list of tabs
  65. *
  66. * @return array Array of tabs to show
  67. */
  68. function categoriesadmin_prepare_head()
  69. {
  70. global $langs, $conf, $user, $db;
  71. $extrafields = new ExtraFields($db);
  72. $extrafields->fetch_name_optionals_label('categorie');
  73. $langs->load("categories");
  74. $h = 0;
  75. $head = array();
  76. $head[$h][0] = DOL_URL_ROOT.'/categories/admin/categorie.php';
  77. $head[$h][1] = $langs->trans("Setup");
  78. $head[$h][2] = 'setup';
  79. $h++;
  80. $head[$h][0] = DOL_URL_ROOT.'/categories/admin/categorie_extrafields.php';
  81. $head[$h][1] = $langs->trans("ExtraFieldsCategories");
  82. $nbExtrafields = $extrafields->attributes['categorie']['count'];
  83. if ($nbExtrafields > 0) {
  84. $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
  85. }
  86. $head[$h][2] = 'attributes_categories';
  87. $h++;
  88. // Show more tabs from modules
  89. // Entries must be declared in modules descriptor with line
  90. // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
  91. // $this->tabs = array('entity:-tabname); to remove a tab
  92. complete_head_from_modules($conf, $langs, null, $head, $h, 'categoriesadmin');
  93. complete_head_from_modules($conf, $langs, null, $head, $h, 'categoriesadmin', 'remove');
  94. return $head;
  95. }