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

  • AdjustNode
  • ConfigOperation
  • DeleteBlock
  • DeleteOperation
  • EditBlock
  • ExportBlock
  • ExportOperation
  • Helpers
  • Hooks
  • ImportOperation
  • ManageBlock
  • Model
  • Module
  • Node
  • OfflineOperation
  • OnlineOperation
  • PopNode
  • QueryOperationOperation
  • SaveOperation
  • TitleSlugCombo
  • Update20131208
  • Update20140405
  • ViewProvider

Functions

  • slugize
  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\Nodes;
 13 
 14 use Icybee\Modules\Nodes\Node;
 15 
 16 use Brickrouge\Element;
 17 use Brickrouge\Form;
 18 
 19 /**
 20  * A block used to edit a node.
 21  */
 22 class EditBlock extends \Icybee\EditBlock
 23 {
 24     /**
 25      * Adds the "Visibility" group.
 26      *
 27      * The visibility group should be used to group controls related to the visibility of the
 28      * record on the site e.g. online status, view exclusion, navigation exclusion...
 29      *
 30      * The visibility group is created with an initial weight of 400.
 31      */
 32     protected function lazy_get_attributes()
 33     {
 34         $attributes = parent::lazy_get_attributes();
 35 
 36         $attributes[Element::GROUPS]['visibility'] = [
 37 
 38             'title' => 'Visibility',
 39             'weight' => 400
 40 
 41         ];
 42 
 43         return $attributes;
 44     }
 45 
 46     /**
 47      * Adds the `title`, `is_online`, `uid` and `siteid` elements.
 48      *
 49      * The `uid` and `siteid` elements are added according to the context.
 50      */
 51     protected function lazy_get_children()
 52     {
 53         $values = $this->values;
 54 
 55         return array_merge(parent::lazy_get_children(), [
 56 
 57             Node::TITLE => new TitleSlugCombo([
 58 
 59                 Form::LABEL => 'title',
 60                 Element::REQUIRED => true,
 61                 TitleSlugCombo::T_NODEID => $values[Node::NID],
 62                 TitleSlugCombo::T_SLUG_NAME => 'slug'
 63 
 64             ]),
 65 
 66             Node::UID => $this->get_control__user(),
 67             Node::SITEID => $this->get_control__site(), // TODO-20100906: this should be added by the "sites" modules using the alter event.
 68             Node::IS_ONLINE => new Element(Element::TYPE_CHECKBOX, [
 69 
 70                 Element::LABEL => 'is_online',
 71                 Element::DESCRIPTION => 'is_online',
 72                 Element::GROUP => 'visibility'
 73 
 74             ])
 75         ]);
 76     }
 77 
 78     /**
 79      * Returns the control for the user of the node.
 80      *
 81      * @param array $properties
 82      * @param array $attributes
 83      *
 84      * @return void|\Brickrouge\Element
 85      */
 86     protected function get_control__user()
 87     {
 88         global $core;
 89 
 90         if (!$core->user->has_permission(Module::PERMISSION_ADMINISTER, $this->module))
 91         {
 92             return;
 93         }
 94 
 95         $users = $core->models['users']->select('uid, username')->order('username')->pairs;
 96 
 97         if (count($users) < 2)
 98         {
 99             return;
100         }
101 
102         return new Element('select', [
103 
104             Form::LABEL => 'User',
105             Element::OPTIONS => [ null => '' ] + $users,
106             Element::REQUIRED => true,
107             Element::DEFAULT_VALUE => $core->user->uid,
108             Element::GROUP => 'admin',
109             Element::DESCRIPTION => 'user'
110 
111         ]);
112     }
113 
114     /**
115      * Returns control for the site the node belongs to.
116      *
117      * @param array $properties
118      * @param array $attributes
119      *
120      * @return void|\Brickrouge\Element
121      */
122     protected function get_control__site()
123     {
124         global $core;
125 
126         if (!$core->user->has_permission(Module::PERMISSION_MODIFY_BELONGING_SITE, $this->module))
127         {
128             return;
129         }
130 
131         $sites = $core->models['sites']->select('siteid, IF(admin_title != "", admin_title, concat(title, ":", language))')->order('admin_title, title')->pairs;
132 
133         if (count($sites) < 2)
134         {
135             $this->attributes[Form::HIDDENS][Node::SITEID] = $core->site_id;
136 
137             return;
138         }
139 
140         return new Element('select', [
141 
142             Form::LABEL => 'siteid',
143             Element::OPTIONS => [ null => '' ] + $sites,
144             Element::GROUP => 'admin',
145             Element::DESCRIPTION => 'siteid'
146 
147         ]);
148     }
149 }
Autodoc API documentation generated by ApiGen 2.8.0