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

  • Hooks
  • Module
  • NodeLanguageElement
  • NodeNativeElement
 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\I18n;
13 
14 use ICanBoogie\I18n;
15 
16 use Brickrouge\Element;
17 use Brickrouge\Form;
18 
19 use Icybee\Modules\Pages\Model as PagesModel;
20 
21 /**
22  * An element to select the language of a node.
23  */
24 class NodeNativeElement extends Element
25 {
26     const CONSTRUCTOR = '#node-native-constructor';
27 
28     public function __construct(array $attributes=array())
29     {
30         global $core;
31 
32         $site = $core->site;
33         $native = $site->native->language;
34 
35         parent::__construct
36         (
37             'select', $attributes + array
38             (
39                 Form::LABEL => 'nativeid',
40                 Element::GROUP => 'i18n',
41                 Element::DESCRIPTION => I18n\t('nativeid', array('native' => $native, 'language' => $site->language), array('scope' => 'element.description'))
42             )
43         );
44     }
45 
46     protected function render_inner_html_for_select() // TODO-20120922: use a BluePrint object or a PopPage element
47     {
48         global $core;
49 
50         $native = $core->site->native->language;
51         $constructor = $this[self::CONSTRUCTOR];
52         $options = array();
53 
54         if ($constructor == 'pages')
55         {
56             $nodes = $core->models['pages']
57             ->select('nid, parentid, title')
58             ->filter_by_language($native)
59             ->order('weight, created')
60             ->all(\PDO::FETCH_OBJ);
61 
62             $tree = PagesModel::nestNodes($nodes);
63 
64             if ($tree)
65             {
66                 PagesModel::setNodesDepth($tree);
67                 $records = PagesModel::levelNodesById($tree);
68 
69                 foreach ($records as $record)
70                 {
71                     $options[$record->nid] = str_repeat("\xC2\xA0", $record->depth * 4) . $record->title;
72                 }
73             }
74         }
75         else
76         {
77             $options = $core->models['nodes']
78             ->select('nid, title')
79             ->filter_by_constructor_and_language($constructor, $native)
80             ->order('title')
81             ->pairs;
82 
83             foreach ($options as &$label)
84             {
85                 $label = \ICanBoogie\shorten($label);
86             }
87 
88             unset($label);
89         }
90 
91         $this[self::OPTIONS] = array(null => 'none') + $options;
92 
93         return parent::render_inner_html_for_select();
94     }
95 }
Autodoc API documentation generated by ApiGen 2.8.0