public function __toString()
 {
     try {
         return (string) $this->render();
     } catch (\Exception $e) {
         return \Brickrouge\render_exception($e);
     }
 }
Example #2
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();
    }
Example #3
0
    protected function render_panels(array $panels)
    {
        $colunms = [[], []];
        // config sign: ⚙
        foreach ($panels as $id => $descriptor) {
            try {
                if (empty($descriptor['callback'])) {
                    continue;
                }
                $contents = call_user_func($descriptor['callback']);
            } catch (\Exception $e) {
                $contents = \Brickrouge\render_exception($e);
            }
            if (!$contents) {
                continue;
            }
            $title = I18n\t($id, [], ['scope' => 'dashboard.title', 'default' => $descriptor['title']]);
            $panel = <<<EOT
<div class="panel" id="{$id}">
\t<div class="panel-title">{$title}</div>
\t<div class="panel-contents">{$contents}</div>
</div>
EOT;
            $colunms[$descriptor['column']][] = $panel;
        }
        $html = '';
        foreach ($colunms as $i => $panels) {
            $panels = implode(PHP_EOL, $panels);
            $html .= <<<EOT
<div class="column">
\t{$panels}
\t<div class="panel-holder">&nbsp;</div>
</div>
EOT;
        }
        return $html;
    }
Example #4
0
 /**
  * Return a IMG element that can be inserted as is in the document.
  *
  * The `width` and `height` attribute of the element are defined whenever possible. The `alt`
  * attribute is also defined if the image src is an Image active record.
  */
 public function __toString()
 {
     try {
         return (string) $this->to_element();
     } catch (\Exception $e) {
         echo \Brickrouge\render_exception($e);
     }
 }