Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • CloudElement
  • DeleteBlock
  • DeleteOperation
  • EditBlock
  • Hooks
  • ManageBlock
  • Model
  • Module
  • OrderOperation
  • SaveOperation
  • Vocabulary
  1 <?php
  2 
  3 /*
  4  * This file is part of the Icybee package.
  5  *
  6  * (c) Olivier Laviale <olivier.laviale@gmail.com>
  7  *
  8  * For the full copyright and license information, please view the LICENSE
  9  * file that was distributed with this source code.
 10  */
 11 
 12 namespace Icybee\Modules\Taxonomy\Vocabulary;
 13 
 14 use ICanBoogie\I18n;
 15 
 16 use Brickrouge\Element;
 17 use Brickrouge\Form;
 18 use Brickrouge\Text;
 19 use Brickrouge\Widget;
 20 
 21 use Icybee\Modules\Nodes\TitleSlugCombo;
 22 
 23 class EditBlock extends \Icybee\EditBlock
 24 {
 25     static protected function add_assets(\Brickrouge\Document $document)
 26     {
 27         parent::add_assets($document);
 28 
 29         $document->css->add(DIR . 'public/admin.css');
 30     }
 31 
 32     protected function lazy_get_attributes()
 33     {
 34         return \ICanBoogie\array_merge_recursive
 35         (
 36             parent::lazy_get_attributes(), array
 37             (
 38                 Element::GROUPS => array
 39                 (
 40                     'settings' => array
 41                     (
 42                         'title' => 'Options',
 43                         'weight' => 100
 44                     )
 45                 )
 46             )
 47         );
 48     }
 49 
 50     protected function lazy_get_children()
 51     {
 52         return array_merge
 53         (
 54             parent::lazy_get_children(), array
 55             (
 56                 Vocabulary::VOCABULARY => new TitleSlugCombo
 57                 (
 58                     array
 59                     (
 60                         Form::LABEL => 'title',
 61                         Element::REQUIRED => true
 62                     )
 63                 ),
 64 
 65                 Vocabulary::SCOPE => $this->get_control__scope(),
 66 
 67                 Vocabulary::IS_TAGS => new Element
 68                 (
 69                     Element::TYPE_CHECKBOX, array
 70                     (
 71 
 72                         Element::LABEL => 'is_tags',
 73                         Element::GROUP => 'settings',
 74                         Element::DESCRIPTION => 'is_tags'
 75                     )
 76                 ),
 77 
 78                 Vocabulary::IS_MULTIPLE => new Element
 79                 (
 80                     Element::TYPE_CHECKBOX, array
 81                     (
 82                         Element::LABEL => 'Multiple appartenance',
 83                         Element::GROUP => 'settings',
 84                         Element::DESCRIPTION => "Les enregistrements peuvent appartenir à
 85                         plusieurs terms du vocabulaire (c'est toujours le cas pour les
 86                         <em>étiquettes</em>)"
 87                     )
 88                 ),
 89 
 90                 Vocabulary::IS_REQUIRED => new Element
 91                 (
 92                     Element::TYPE_CHECKBOX, array
 93                     (
 94                         Element::LABEL => 'Requis',
 95                         Element::GROUP => 'settings',
 96                         Element::DESCRIPTION => 'Au moins un terme de ce vocabulaire doit être
 97                         sélectionné.'
 98                     )
 99                 ),
100 
101                 Vocabulary::SITEID => $this->get_control__site()
102             )
103         );
104     }
105 
106     protected function get_control__scope()
107     {
108         global $core;
109 
110         $scope_options = array();
111         $modules = $core->modules;
112 
113         foreach ($modules->descriptors as $module_id => $descriptor)
114         {
115             if ($module_id == 'nodes' || !isset($modules[$module_id]))
116             {
117                 continue;
118             }
119 
120             $is_instance = $modules->is_extending($module_id, 'nodes');
121 
122             if (!$is_instance)
123             {
124                 continue;
125             }
126 
127             $scope_options[$module_id] = I18n\t($module_id, array(), array('scpope' => 'module_title', 'default' => $descriptor[Module::T_TITLE]));
128         }
129 
130         uasort($scope_options, 'ICanBoogie\unaccent_compare_ci');
131 
132         $scope_value = null;
133         $vid = $this->values[Vocabulary::VID];
134 
135         if ($vid)
136         {
137             $scope_value = $this->module->model('scopes')->select('constructor, 1')->filter_by_vid($vid)->pairs;
138 
139             $this->values[Vocabulary::SCOPE] = $scope_value;
140         }
141 
142         return new Element
143         (
144             Element::TYPE_CHECKBOX_GROUP, array
145             (
146                 Form::LABEL => 'scope',
147                 Element::OPTIONS => $scope_options,
148                 Element::REQUIRED => true,
149 
150                 'class' => 'list combo',
151                 'value' => $scope_value
152             )
153         );
154     }
155 
156     protected function get_control__site()
157     {
158         global $core;
159 
160         if (!$core->user->has_permission(\Icybee\Modules\Nodes\Module::PERMISSION_MODIFY_BELONGING_SITE))
161         {
162             return;
163         }
164 
165         // TODO-20100906: this should be added by the "sites" modules using the alter event.
166 
167         return new Element
168         (
169             'select', array
170             (
171                 Form::LABEL => 'siteid',
172                 Element::OPTIONS => array
173                 (
174                     null => ''
175                 )
176                 + $core->models['sites']->select('siteid, IF(admin_title != "", admin_title, concat(title, ":", language))')->order('admin_title, title')->pairs,
177 
178                 Element::DEFAULT_VALUE => $core->site_id,
179                 Element::GROUP => 'admin',
180                 Element::DESCRIPTION => 'siteid'
181             )
182         );
183     }
184 }
Autodoc API documentation generated by ApiGen 2.8.0