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 class ManageBlock extends \Icybee\ManageBlock
 15 {
 16     /**
 17      * Adds the following columns:
 18      *
 19      * - `vocabulary`
 20      * - `scope`
 21      */
 22     protected function get_available_columns()
 23     {
 24         return array_merge(parent::get_available_columns(), array
 25         (
 26             Vocabulary::VOCABULARY => __CLASS__ . '\VocabularyColumn',
 27             Vocabulary::SCOPE => __CLASS__ . '\ScopeColumn'
 28         ));
 29     }
 30 }
 31 
 32 namespace Icybee\Modules\Taxonomy\Vocabulary\ManageBlock;
 33 
 34 use ICanBoogie\I18n;
 35 use ICanBoogie\Module;
 36 
 37 use Icybee\ManageBlock\Column;
 38 use Icybee\ManageBlock\EditDecorator;
 39 
 40 /**
 41  * Representation of the `vocabulary` column.
 42  */
 43 class VocabularyColumn extends Column
 44 {
 45     public function render_cell($record)
 46     {
 47         global $core;
 48 
 49         $vid = $record->vid;
 50         $terms = $core->models['taxonomy.terms']
 51         ->select('term')
 52         ->filter_by_vid($vid)
 53         ->order('term.weight, term')
 54         ->all(\PDO::FETCH_COLUMN);
 55 
 56         $order_link = null;
 57 
 58         if ($terms)
 59         {
 60             $last = array_pop($terms);
 61 
 62             $includes = $terms
 63                 ? I18n\t('Including: !list and !last', array('!list' => \ICanBoogie\shorten(implode(', ', $terms), 128, 1), '!last' => $last))
 64                 : I18n\t('Including: !entry', array('!entry' => $last));
 65 
 66             $order_url = \ICanBoogie\Routing\contextualize("/admin/{$this->manager->module->id}/$vid/order");
 67 
 68             $order_link = <<<EOT
 69 <a href="$order_url">Order the terms</a>
 70 EOT;
 71         }
 72         else
 73         {
 74             $includes = '<em class="light">The vocabulary is empty</em>';
 75         }
 76 
 77         if ($order_link)
 78         {
 79             $order_link = " &ndash; {$order_link}";
 80         }
 81 
 82         return new EditDecorator($record->vocabulary, $record) . <<<EOT
 83 <br /><span class="small">{$includes}{$order_link}</span>
 84 EOT;
 85     }
 86 }
 87 
 88 /**
 89  * Representation of the `scope` column.
 90  */
 91 class ScopeColumn extends Column
 92 {
 93     public function render_cell($record)
 94     {
 95         global $core;
 96 
 97         $scope = $this->manager->module->model('scopes')
 98         ->select('constructor')
 99         ->where('vid = ?', $record->vid)
100         ->all(\PDO::FETCH_COLUMN);
101 
102         if ($scope)
103         {
104             $context = $core->site->path;
105 
106             foreach ($scope as &$constructor)
107             {
108                 $constructor = '<a href="' . $context . '/admin/' . $constructor . '">' . I18n\t($core->modules->descriptors[$constructor][Module::T_TITLE]) . '</a>';
109             }
110 
111             $last = array_pop($scope);
112 
113             $includes = $scope
114                 ? I18n\t(':list and :last', array(':list' => \ICanBoogie\shorten(implode(', ', $scope), 128, 1), ':last' => $last))
115                 : I18n\t(':one', array(':one' => $last));
116         }
117         else
118         {
119             $includes = '<em>Aucune portée</em>';
120         }
121 
122         return '<span class="small">' . $includes . '</span>';
123     }
124 }
Autodoc API documentation generated by ApiGen 2.8.0