Esempio n. 1
0
    public function render()
    {
        global $core;
        $panel = new Element('div', array('class' => 'install-panel'));
        $component = $this->component;
        $rendered_component = (string) $component;
        $content = '';
        $name = $component['name'];
        $title = $component[self::TITLE];
        $description = $component[self::DESCRIPTION];
        if ($rendered_component) {
            $content = '<div class="install-panel-content">' . $rendered_component . '</div>';
        } else {
            $panel->add_class('no-content');
        }
        if ($name) {
            $panel['id'] = "panel-{$name}";
            $panel->add_class("install-panel--{$name}");
        }
        if (!empty($core->session->install['done'][$name])) {
            $panel->add_class('done');
        }
        $panel[Element::INNER_HTML] = <<<EOT
<div class="install-panel-inner">
\t<h3 class="install-panel-title">{$title}</h3>
\t<div class="install-panel-description">{$description}</div>
\t{$content}
</div>
EOT;
        return (string) $panel;
    }
Esempio n. 2
0
 protected function render_inner_html()
 {
     global $core;
     $page = $core->request->context->page;
     $translations_by_language = $this->collect();
     new LanguagesElement\CollectEvent($this, array('languages' => &$translations_by_language));
     if (count($translations_by_language) == 1) {
         throw new ElementIsEmpty();
     }
     /*
     if ($template)
     {
     	return $patron($template, $translations_by_language);
     }
     */
     $page_language = $page->language;
     $links = array();
     foreach ($translations_by_language as $language => $record) {
         $link = new Element('a', array(Element::INNER_HTML => $language, 'class' => 'btn language--' . \Brickrouge\normalize($language), 'href' => $record->url));
         if ($language == $page_language) {
             $link->add_class('active');
         }
         $links[$language] = $link;
     }
     new LanguagesElement\AlterEvent($this, array('links' => &$links, 'languages' => &$translations_by_language, 'page' => $page));
     return implode('', $links);
 }
Esempio n. 3
0
 /**
  * Adds the `contents-name` and `selector-name` properties.
  *
  * @see Brickrouge.Element::alter_dataset()
  */
 protected function alter_dataset(array $dataset)
 {
     $dataset = parent::alter_dataset($dataset);
     $dataset['contents-name'] = $this['name'];
     $dataset['selector-name'] = $this[self::SELECTOR_NAME];
     return $dataset;
 }
Esempio n. 4
0
    protected function render_inner_html()
    {
        return parent::render_inner_html() . <<<EOT
{$this->elements['login']}
{$this->elements['password']}
EOT;
    }
Esempio n. 5
0
 /**
  * @throws ElementIsEmpty if the element has no options.
  *
  * @see Brickrouge.Element::render_outer_html()
  */
 protected function render_outer_html()
 {
     if (!$this[Element::OPTIONS]) {
         throw new ElementIsEmpty();
     }
     return parent::render_outer_html();
 }
Esempio n. 6
0
 protected function render_inner_html_for_select()
 {
     global $core;
     $native = $core->site->native->language;
     $constructor = $this[self::CONSTRUCTOR];
     $options = [];
     if ($constructor == 'pages') {
         $nodes = $core->models['pages']->select('nid, parentid, title')->filter_by_language($native)->order('weight, created')->all(\PDO::FETCH_OBJ);
         $tree = PagesModel::nestNodes($nodes);
         if ($tree) {
             PagesModel::setNodesDepth($tree);
             $records = PagesModel::levelNodesById($tree);
             foreach ($records as $record) {
                 $options[$record->nid] = str_repeat(" ", $record->depth * 4) . $record->title;
             }
         }
     } else {
         $options = $core->models['nodes']->select('nid, title')->filter_by_constructor_and_language($constructor, $native)->order('title')->pairs;
         foreach ($options as &$label) {
             $label = \ICanBoogie\shorten($label);
         }
         unset($label);
     }
     $this[self::OPTIONS] = [null => 'none'] + $options;
     return parent::render_inner_html_for_select();
 }
 public function offsetUnset($attribute)
 {
     if ($attribute == 'name' || $attribute == 'value') {
         unset($this->pop_image[$attribute]);
         return;
     }
     parent::offsetUnset($attribute);
 }
Esempio n. 8
0
 /**
  * @throws ElementIsEmpty if the inner HTML is empty.
  */
 protected function render_inner_html()
 {
     $html = parent::render_inner_html();
     if (!$html) {
         throw new ElementIsEmpty();
     }
     return $html;
 }
Esempio n. 9
0
 public function validate($value, \ICanBoogie\Errors $errors)
 {
     $from = $this[self::FROM];
     $to = $this[self::TO];
     if ($from < $to ? $value < $from || $value > $to : $value > $from || $value < $to) {
         $errors[$this['name']] = new FormattedString("The value should be between :from and :to, %value given.", array('from' => $from, 'to' => $to, 'value' => $value));
     }
     return parent::validate($value, $errors);
 }
Esempio n. 10
0
 public function __toString()
 {
     global $core;
     $list = $core->site->templates;
     if (!$list) {
         return '<p class="warn">There is no template available.</p>';
     }
     $options = array_combine($list, $list);
     $this[self::OPTIONS] = array(null => '<auto>') + $options;
     return parent::__toString();
 }
Esempio n. 11
0
 protected function render_inner_html()
 {
     $rc = new Element('input', ['type' => 'hidden', 'name' => $this['name'], 'value' => $this['value']]) . parent::render_inner_html();
     $constructor = $this[self::T_CONSTRUCTOR];
     $rc .= '<div class="search">';
     $rc .= new Text(['class' => 'search', 'placeholder' => I18n\t('Search')]);
     $rc .= $this->get_results(['selected' => $this['value']], $constructor);
     $rc .= '</div>';
     $this->dataset['constructor'] = $constructor;
     return $rc;
 }
Esempio n. 12
0
 public function render()
 {
     global $core;
     /* @var $blueprint Blueprint */
     $blueprint = $core->models['pages']->blueprint($core->site_id);
     $blueprint->populate();
     $options = [];
     foreach ($blueprint->ordered_records as $record) {
         $options[$record->nid] = str_repeat(" ", $record->depth * 4) . $record->label;
     }
     $this[self::OPTIONS] = [null => ''] + $options;
     return parent::render();
 }
Esempio n. 13
0
 public function render_inner_html()
 {
     $value = $this['value'];
     if ($value) {
         if (is_string($value)) {
             $value = json_decode($value, true);
         }
         foreach ($value as $identifier => $v) {
             $this->elements[$identifier]['value'] = $v;
         }
     }
     return parent::render_inner_html();
 }
Esempio n. 14
0
    public function render_inner_html()
    {
        $app = $this->app;
        $selected_category = null;
        $selected_subcategory = null;
        $selected_view = $this['value'];
        $categories = [];
        $descriptors = $app->modules->descriptors;
        $views = $app->views;
        foreach ($views as $id => $view) {
            list($module_id, $type) = explode('/', $id) + [1 => null];
            if (!isset($app->modules[$module_id])) {
                continue;
            }
            $category = 'Misc';
            $subcategory = 'Misc';
            if ($type !== null && isset($descriptors[$module_id])) {
                $descriptor = $descriptors[$module_id];
                if (isset($descriptor[Descriptor::CATEGORY])) {
                    $category = $descriptors[$module_id][Descriptor::CATEGORY];
                    $category = $this->t($category, [], ['scope' => 'module_category']);
                }
                $subcategory = $descriptor[Descriptor::TITLE];
                $subcategory = $this->t(strtr($module_id, '.', '_'), [], ['scope' => 'module_title', 'default' => $subcategory]);
            }
            $categories[$category][$subcategory][$id] = $view;
            if ($id == $selected_view) {
                $selected_category = $category;
                $selected_subcategory = $subcategory;
            }
        }
        uksort($categories, 'ICanBoogie\\unaccent_compare_ci');
        foreach ($categories as $category => $subcategories) {
            uksort($subcategories, 'ICanBoogie\\unaccent_compare_ci');
            $categories[$category] = $subcategories;
        }
        $rendered_categories = $this->render_categories($categories, $selected_category);
        $rendered_subcategories = $this->render_subcategories($categories, $selected_category, $selected_subcategory);
        $rendered_views = $this->render_views($categories, $selected_category, $selected_subcategory, $selected_view);
        return parent::render_inner_html() . <<<EOT
<table>
\t<tr>
\t\t<td class="view-editor-categories">{$rendered_categories}</td>
\t\t<td class="view-editor-subcategories">{$rendered_subcategories}</td>
\t\t<td class="view-editor-views">{$rendered_views}</td>
\t</tr>
</table>
EOT;
    }
Esempio n. 15
0
 /**
  * Adds the `alert-error`, `alert-info` and `alert-success` class names according to the
  * {@link CONTEXT} attribute.
  *
  * Adds the `alert-block` class name if the {@link HEADING} attribute is defined.
  *
  * Adds the `undismissable` class name if the {@link UNDISMISSABLE} attribute is true.
  *
  * @inheritdoc
  */
 protected function alter_class_names(array $class_names)
 {
     $class_names = parent::alter_class_names($class_names);
     $context = $this[self::CONTEXT];
     if ($context) {
         $class_names['alert-' . $context] = true;
     }
     if ($this[self::HEADING]) {
         $class_names['alert-block'] = true;
     }
     if ($this[self::UNDISMISSABLE]) {
         $class_names['undismissable'] = true;
     }
     return $class_names;
 }
Esempio n. 16
0
 protected function render_inner_html()
 {
     $rc = parent::render_inner_html();
     $value = $this['value'];
     $name = $this['name'];
     if ($value && !is_numeric($value)) {
         $value = json_decode($value);
     }
     $class = 'Icybee\\Modules\\Nodes\\PopNode';
     $constructor = $this['data-constructor'] ?: 'nodes';
     if ($constructor == 'images') {
         $class = 'Icybee\\Modules\\Images\\PopImage';
     }
     $rc .= (string) new $class(array(\Icybee\Modules\Nodes\PopNode::T_CONSTRUCTOR => $constructor, 'name' => $name, 'value' => $value));
     return $rc;
 }
Esempio n. 17
0
 public function render_inner_html()
 {
     global $core;
     $config = $core->configs->synthesize('widgets', 'merge');
     if (!$config) {
         return new Alert('There is no widget defined.', array(Alert::CONTEXT => Alert::CONTEXT_INFO));
     }
     $rc = parent::render_inner_html();
     $value = $this['value'];
     $name = $this['name'];
     $value = is_array($value) ? array_flip($value) : array();
     // TODO-20100204: check deprecated widgets ids
     $list = array_merge($value, $config);
     //\ICanBoogie\log('value: \1, list: \2 \3', array($value, $list, array_merge($value, $list)));
     foreach ($list as $id => $widget) {
         $rc .= '<li>';
         $rc .= new Element(Element::TYPE_CHECKBOX, array(Element::LABEL => $widget['title'], 'name' => $name . '[' . $id . ']', 'checked' => isset($value[$id])));
         $rc .= '</li>';
     }
     return $rc;
 }
Esempio n. 18
0
    public function __toString()
    {
        global $core;
        try {
            $site = $core->site;
            $value = (int) $this['value'];
            $options = $core->models['forms']->select('nid, title')->where('nid = ? OR ((siteid = 0 OR siteid = ?) AND (language = "" OR language = ?))', $value, $site->siteid, $site->language)->order('title')->pairs;
            if (!$options) {
                $url = \Brickrouge\escape($core->site->path . '/admin/forms/new');
                return <<<EOT
<a href="{$url}" class="btn btn-info">Créer un premier formulaire...</a>
EOT;
            }
            if ($this->type == 'select') {
                $options = array(null => '') + $options;
            }
            $this[self::OPTIONS] = $options;
        } catch (\Exception $e) {
            return \Brickrouge\render_exception($e);
        }
        return parent::__toString();
    }
Esempio n. 19
0
 /**
  * Alters the dataset with the `base-url`, `actions` and `external-css` attributes.
  *
  * @see Brickrouge.Element::alter_dataset()
  */
 public function alter_dataset(array $dataset)
 {
     global $core;
     $dataset = parent::alter_dataset($dataset);
     $document = $core->document;
     $css = $this[self::STYLESHEETS] ?: array();
     $css[] = Document::resolve_url(\Brickrouge\ASSETS . 'brickrouge.css');
     if (!$css) {
         $info = \Icybee\Modules\Pages\Module::get_template_info('page.html');
         if (isset($info[1])) {
             $css = $info[1];
         }
     }
     array_unshift($css, Document::resolve_url('assets/body.css'));
     $try = \ICanBoogie\DOCUMENT_ROOT . 'public/page.css';
     if (file_exists($try)) {
         $css[] = Document::resolve_url($try);
     }
     $actions = $this[self::ACTIONS] ?: 'standard';
     if ($actions == 'standard') {
         $actions = 'bold italic underline strikethrough | formatBlock justifyleft justifyright justifycenter justifyfull | insertunorderedlist insertorderedlist indent outdent | undo redo | createlink unlink | image | removeformat paste outline toggleview';
         if (0) {
             $actions .= ' / tableadd | tableedit | tablerowspan tablerowsplit tablerowdelete | tablecolspan tablecolsplit tablecoldelete';
             $document->css->add('mooeditable/Assets/MooEditable/MooEditable.Table.css');
             $document->js->add('mooeditable/Source/MooEditable/MooEditable.Table.js');
         }
     } else {
         if ($actions == 'minimal') {
             $actions = 'bold italic underline strikethrough | insertunorderedlist insertorderedlist | undo redo | createlink unlink | removeformat paste toggleview';
         }
     }
     $dataset['base-url'] = '/';
     $dataset['actions'] = $actions;
     $dataset['external-css'] = $css;
     return $dataset;
 }
Esempio n. 20
0
 public function __construct()
 {
     $action = new Button("Install", array('class' => 'btn btn-primary', 'type' => 'submit'));
     parent::__construct('div', array(PanelDecorator::TITLE => t('panel.install.title'), Element::CHILDREN => array(t('panel.install.content', array('action' => $action))), 'name' => 'install'));
 }
Esempio n. 21
0
 protected function alter_dataset(array $dataset)
 {
     return parent::alter_dataset($dataset) + array('photo' => $this['value'] ? $this['value']->id : null);
 }
Esempio n. 22
0
 public function __construct(array $attributes = array())
 {
     parent::__construct('select', $attributes + array(Element::OPTIONS => array(null => '', 'en' => 'English', 'fr' => 'French'), Element::INLINE_HELP => t('language.description')));
 }
Esempio n. 23
0
 public function __construct($tags)
 {
     parent::__construct('ol', $tags + array(self::DIVIDER => self::DEFAULT_DIVIDER, 'class' => 'breadcrumb'));
 }
Esempio n. 24
0
 public function __construct(Page $page, array $attributes = array())
 {
     $this->page = $page;
     parent::__construct('div', $attributes + array('class' => 'nav-branch'));
 }
Esempio n. 25
0
 /**
  * Validates the form using the provided values.
  *
  * @inheritdoc
  */
 public function validate($values, Errors $errors)
 {
     #
     # validation without prior save
     #
     if (empty($values[self::STORED_KEY_NAME])) {
         $this->__sleep();
     }
     #
     # we flatten the array so that we can easily get values
     # for keys such as `cars[1][color]`
     #
     $values = array_flatten($values);
     $this->values = $values;
     #
     # process required values
     #
     $validators = $this->validators;
     foreach ($validators as $identifier => $element) {
         $element->form = $this;
         $element->name = $identifier;
         $element->label = self::select_element_label($element);
     }
     #
     # process required elements
     #
     $this->validate_required_elements($this->required, $validators, $values, $errors);
     #
     # process elements validators
     #
     # note: If the value for the element is `null` and the value is not required the element's
     # validator is *not* called.
     #
     foreach ($validators as $name => $element) {
         $value = isset($values[$name]) ? $values[$name] : null;
         if (($value === null || $value === '') && empty($this->required[$name])) {
             continue;
         }
         $element->validate($value, $errors);
     }
     // FIXME-20111013: ICanBoogie won't save the errors in the session, so we have to do it ourselves for now.
     store_form_errors($this->name, $errors);
     if (count($errors)) {
         return false;
     }
     return parent::validate($values, $errors);
 }
Esempio n. 26
0
 /**
  * Circumvent Element constructor.
  */
 public function __construct(array $attributes = [])
 {
     parent::__construct('div', $attributes);
 }
Esempio n. 27
0
 /**
  * Unset a data attribute.
  *
  * @param string $property
  */
 public function offsetUnset($property)
 {
     $this->element->offsetUnset(self::serialize_property($property));
 }
Esempio n. 28
0
 public function __construct(Module $module)
 {
     $this->module = $module;
     parent::__construct('div', ['id' => 'dashboard']);
 }
Esempio n. 29
0
 public function __construct(array $attributes = array())
 {
     parent::__construct('textarea', $attributes + array('class' => 'editor code php'));
 }
Esempio n. 30
0
 /**
  * Adds the `control-name` property.
  *
  * @see Brickrouge.Element::alter_dataset()
  */
 protected function alter_dataset(array $dataset)
 {
     return parent::alter_dataset(array_merge($dataset, array('control-name' => $this['name'])));
 }