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

  • ConfigBlock
  • ConfigOperation
  • Hooks
  • Module

Functions

  • _search_excerpt_replace
  • make_set
  • query_contents
  • query_google
  • query_pages
  • search_excerpt
  • search_forms
  • truncate_utf8
  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\Search;
 13 
 14 use ICanBoogie\I18n;
 15 use ICanBoogie\Route;
 16 
 17 use Brickrouge\A;
 18 use Brickrouge\Element;
 19 use Brickrouge\Form;
 20 use Brickrouge\Text;
 21 
 22 /**
 23  * A block to configure search.
 24  */
 25 class ConfigBlock extends \Icybee\ConfigBlock
 26 {
 27     static protected function add_assets(\Brickrouge\Document $document)
 28     {
 29         parent::add_assets($document);
 30 
 31         $document->css->add('../../public/admin.css');
 32         $document->js->add('../../public/admin.js');
 33     }
 34 
 35     protected function lazy_get_attributes()
 36     {
 37         global $core;
 38 
 39         $page = $core->site->resolve_view_target('search/home');
 40 
 41         if ($page)
 42         {
 43             $description_link = (string) new A($page->title, \ICanBoogie\Routing\contextualize("/admin/pages/$page->nid/edit"));
 44         }
 45         else
 46         {
 47             $description_link = '<q>' . new A('Pages', \ICanBoogie\Routing\contextualize('/admin/pages')) . '</q>';
 48         }
 49 
 50         return \ICanBoogie\array_merge_recursive
 51         (
 52             parent::lazy_get_attributes(), array
 53             (
 54                 Element::GROUPS => array
 55                 (
 56                     'primary' => array
 57                     (
 58                         'description' => I18n\t($page ? 'description' : 'description_nopage', array(':link' => $description_link))
 59                     )
 60                 )
 61             )
 62         );
 63     }
 64 
 65     protected function lazy_get_children()
 66     {
 67         global $core;
 68 
 69         $ns = $this->module->flat_id;
 70 
 71         return array_merge
 72         (
 73             parent::lazy_get_children(), array
 74             (
 75                 "local[$ns.scope]" => $this->create_control_scope(),
 76 
 77                 "local[$ns.limits.home]" => new Text
 78                 (
 79                     array
 80                     (
 81                         Form::LABEL => 'limits_home',
 82                         Element::DEFAULT_VALUE => 5
 83                     )
 84                 ),
 85 
 86                 "local[$ns.limits.list]" => new Text
 87                 (
 88                     array
 89                     (
 90                         Form::LABEL => 'limits_list',
 91                         Element::DEFAULT_VALUE => 10
 92                     )
 93                 )
 94             )
 95         );
 96     }
 97 
 98     protected function create_control_scope()
 99     {
100         global $core;
101 
102         $options = array();
103         $modules = $core->modules;
104 
105         foreach ($core->modules->descriptors as $module_id => $descriptor)
106         {
107             if (!isset($core->modules[$module_id]))
108             {
109                 continue;
110             }
111 
112             if (!$modules->is_extending($module_id, 'contents') && !$modules->is_extending($module_id, 'pages'))
113             {
114                 continue;
115             }
116 
117             $options[$module_id] = I18n\t($descriptor[Module::T_TITLE], array(), array('scope' => 'module_title'));
118         }
119 
120         $options['google'] = '<em>Google</em>';
121 
122         asort($options);
123 
124         #
125 
126         $ns = $this->module->flat_id;
127 
128         $scope = explode(',', $core->site->metas[$ns . '.scope']);
129         $scope = array_combine($scope, array_fill(0, count($scope), true));
130 
131         $sorted_options = array();
132 
133         foreach ($scope as $module_id => $dummy)
134         {
135             if (empty($options[$module_id]))
136             {
137                 continue;
138             }
139 
140             $sorted_options[$module_id] = $options[$module_id];
141         }
142 
143         $sorted_options += $options;
144 
145         $el = '<ul class="sortable self-handle">';
146 
147         foreach ($sorted_options as $module_id => $label)
148         {
149             $el .= '<li>';
150             $el .= new Element
151             (
152                 'input', array
153                 (
154                     Element::LABEL => $label,
155 
156                     'name' => "local[$ns.scope][$module_id]",
157                     'type' => 'checkbox',
158                     'checked' => !empty($scope[$module_id])
159                 )
160             );
161 
162             $el .= '</li>';
163         }
164 
165         $el .= '</ul>';
166 
167         return new Element
168         (
169             'div', array
170             (
171                 Form::LABEL => 'scope',
172                 Element::INNER_HTML => $el,
173                 Element::DESCRIPTION => 'scope'
174             )
175         );
176     }
177 }
Autodoc API documentation generated by ApiGen 2.8.0