Exemplo n.º 1
0
 public function getItemElement()
 {
     $element = new Element('li');
     $link = new Link($this->link, $this->value, $this->attributes);
     $element->appendChild($link);
     return $element;
 }
Exemplo n.º 2
0
 public function getMenuItemLinkElement()
 {
     $a = new Link();
     $a->setValue('');
     if ($this->menuItem->getIcon()) {
         $icon = new Element('i');
         $icon->addClass('fa fa-' . $this->menuItem->getIcon());
         $a->appendChild($icon);
     }
     if ($this->menuItem->getLink()) {
         $a->href($this->menuItem->getLink());
     }
     foreach ($this->menuItem->getLinkAttributes() as $key => $value) {
         $a->setAttribute($key, $value);
     }
     // Set styling for accessiblity options
     if (Config::get('concrete.accessibility.toolbar_large_font')) {
         $spacing = 'padding-top: 15px';
         $height = 'line-height:17px;';
     } else {
         $spacing = 'padding: 16px 5px;';
         $height = 'line-height:14px;';
     }
     $wbTitle = new Element('div');
     $wbTitle->style($height . $spacing);
     $wbTitle->addClass('wb-fourms')->setValue($this->menuItem->getLabel());
     $a->appendChild($wbTitle);
     return $a;
 }
Exemplo n.º 3
0
 public static function content(ContentBlockController $controller)
 {
     $content = $controller->getSearchableContent();
     $dom = new HtmlDomParser();
     $r = $dom->str_get_html($content, true, true, DEFAULT_TARGET_CHARSET, false);
     if (is_object($r)) {
         foreach ($r->find('concrete-picture') as $picture) {
             $fID = $picture->fid;
             $fo = File::getByID($fID);
             if (is_object($fo)) {
                 $tag = new AmpImg($fo);
                 $tag->alt($picture->alt);
                 $picture->outertext = (string) $tag;
             }
         }
         foreach ($r->find('img') as $img) {
             $tag = new Element('amp-img');
             $tag->alt($img->alt);
             $tag->src($img->src);
             $tag->height($img->height);
             $tag->width($img->width);
             $img->outertext = (string) $tag;
         }
         foreach ($r->find('*[style]') as $element) {
             $element->removeAttribute('style');
         }
         $content = (string) $r->restore_noise($r);
     }
     $content = LinkAbstractor::translateFrom($content);
     return $content;
 }
Exemplo n.º 4
0
 public function getColumnHtmlObjectEditMode()
 {
     $column = $this->getColumnHtmlObject();
     $inner = new Element('div');
     $inner->addClass('ccm-layout-column-inner ccm-layout-column-highlight');
     $column->appendChild($inner);
     return $column;
 }
 public function getListIconElement()
 {
     $env = \Environment::get();
     $type = $this->controller->getAttributeType();
     $url = $env->getURL(implode('/', array(DIRNAME_ATTRIBUTES . '/' . $type->getAttributeTypeHandle() . '/' . FILENAME_BLOCK_ICON)), $type->getPackageHandle());
     $img = new Element('img');
     $img->addClass('ccm-attribute-icon')->src($url)->width(16)->height(16);
     return $img;
 }
 protected function getColumnValue()
 {
     $span = new Element('span');
     $link = new Element('a', t('XML Element'), array('href' => '#'));
     $tooltip = new Element('i', '', array('class' => 'launch-tooltip fa fa-question-circle', 'title' => t('Raw CIF XML Imported because this attribute is not installed or mapped to an existing attribute.')));
     $span->appendChild($link);
     $span->appendChild($tooltip);
     return $span;
 }
Exemplo n.º 7
0
 protected function getColumnElement($contents)
 {
     $element = new Element('div');
     $element->addClass($this->getAreaLayoutColumnClass())->id('ccm-layout-column-' . $this->arLayoutColumnID);
     $inner = new Element('div');
     $inner->addClass('ccm-layout-column-inner');
     $inner->setValue($contents);
     $element->appendChild($inner);
     return $element;
 }
 /**
  * @return string
  */
 public function __toString()
 {
     $e = new Element('script');
     $e->type('text/javascript')->src($this->getAssetURL());
     if (!$this->conditional) {
         return (string) $e;
     } else {
         return sprintf('<!--[if %s]>%s<![endif]-->', $this->conditional, (string) $e);
     }
 }
Exemplo n.º 9
0
 public function getItemElement()
 {
     $element = new Element('li');
     $link = new Link('#', $this->getItemName());
     $link->setAttribute('data-tree-action', $this->getAction());
     $link->setAttribute('dialog-title', $this->getDialogTitle());
     $link->setAttribute('data-tree-action-url', $this->getActionURL());
     $element->appendChild($link);
     return $element;
 }
Exemplo n.º 10
0
 public function getColumnHtmlObjectEditMode()
 {
     $column = $this->getPresetColumnObject();
     if ($column) {
         $html = $column->getColumnHtmlObject();
         $inner = new Element('div');
         $inner->addClass('ccm-layout-column-inner ccm-layout-column-highlight');
         $inner->setValue($this->getContents(true));
         $html->appendChild($inner);
         return $html;
     }
 }
Exemplo n.º 11
0
 public function getLayoutContainerHtmlObject()
 {
     $gf = $this->layout->getThemeGridFrameworkObject();
     if (is_object($gf)) {
         $dom = new HtmlDomParser();
         $r = $dom->str_get_html($gf->getPageThemeGridFrameworkRowStartHTML() . $gf->getPageThemeGridFrameworkRowEndHTML());
         $nodes = $r->childNodes();
         $node = $nodes[0];
         $element = new Element($node->tag);
         $element->id($node->id);
         $element->class($node->class);
         return $element;
     }
 }
Exemplo n.º 12
0
 public function testCanDynamicallyCreateObjects()
 {
     $object = Element::p('foo')->class('bar');
     $matcher = $this->getMatcher();
     $matcher['attributes']['class'] = 'bar';
     $this->assertHTML($matcher, $object);
 }
Exemplo n.º 13
0
 public function getPresetContainerHtmlObject()
 {
     $dom = new HtmlDomParser();
     $r = $dom->str_get_html($this->arrayPreset['container']);
     if (is_object($r)) {
         $nodes = $r->childNodes();
         $node = $nodes[0];
         if (is_object($node)) {
             $element = new Element($node->tag);
             $element->class($node->class);
         }
     }
     if (!isset($element)) {
         $element = new Element('div');
     }
     return $element;
 }
Exemplo n.º 14
0
 public function testGetSelectOptions()
 {
     $select = $this->former->select('foo')->options($this->options);
     foreach ($this->options as $key => $option) {
         $options[$key] = Element::create('option', $option, array('value' => $key));
     }
     $this->assertEquals($select->getOptions(), $options);
 }
Exemplo n.º 15
0
 /**
  * Build a new Media Object
  *
  * @param string $image   Image URL
  * @param string $title   Title
  * @param string $content Content
  */
 public function __construct($image, $title, $content)
 {
     $this->addClass('media');
     $image = Image::create($image);
     $figure = Element::figure($image)->class('media-object');
     $body = Element::div()->class('media-body');
     $title = Element::h2($title)->class('media-heading');
     $this->nest(array('figure' => $figure, 'body' => $body->nest(array('title' => $title, 'content' => $content))));
 }
Exemplo n.º 16
0
 public function getPresetContainerHtmlObject()
 {
     $dom = new HtmlDomParser();
     $r = $dom->str_get_html($this->arrayPreset['container']);
     if (is_object($r)) {
         $nodes = $r->childNodes();
         $node = $nodes[0];
         if (is_object($node)) {
             $element = new Element($node->tag);
             foreach ($node->getAllAttributes() as $key => $value) {
                 $element->setAttribute($key, $value);
             }
         }
     }
     if (!isset($element)) {
         $element = new Element('div');
     }
     return $element;
 }
Exemplo n.º 17
0
 public function getMenuElement()
 {
     if ($this->items->count() > $this->minItemThreshold) {
         $menu = new Element('div', null, $this->menuAttributes);
         $menu->addClass('popover')->addClass('fade');
         $menu->appendChild((new Element('div'))->addClass('arrow'));
         $inner = (new Element('div'))->addClass('popover-inner');
         $list = (new Element('ul'))->addClass('dropdown-menu');
         /**
          * @var $item ItemInterface
          */
         foreach ($this->items as $item) {
             $list->appendChild($item->getItemElement());
         }
         $inner->appendChild($list);
         $menu->appendChild($inner);
         return $menu;
     }
 }
Exemplo n.º 18
0
 /**
  * @return string
  */
 public function render()
 {
     $label = Element::label($this->label)->for($this->id);
     if ($this->inputCheckable) {
         $p = Element::create($this->container)->nest(['field' => parent::render(), 'label' => $label, 'close' => '<br>']);
     } else {
         $p = Element::create($this->container)->nest(['label' => $label, 'field' => parent::render()]);
     }
     return $p->render();
 }
Exemplo n.º 19
0
 /**
  * Create a label element from a string
  *
  * @param string $label
  * @param string $field
  *
  * @return Element
  */
 protected function createLabel($label, $field = null)
 {
     if ($label instanceof Element) {
         $label = $label->getValue();
     }
     $label = Helpers::translate($label);
     $label = Element::create('label', $label)->for($field ?: strtolower($label));
     $label->addClass($this->app['former.framework']->getLabelClasses());
     return $label;
 }
Exemplo n.º 20
0
 public function getMenuItemLinkElement()
 {
     $a = new Link();
     $a->setValue('');
     if ($this->menuItem->getIcon()) {
         $icon = new Element('i');
         $icon->addClass('fa fa-' . $this->menuItem->getIcon());
         $a->appendChild($icon);
     }
     if ($this->menuItem->getLink()) {
         $a->href($this->menuItem->getLink());
     }
     foreach ($this->menuItem->getLinkAttributes() as $key => $value) {
         $a->setAttribute($key, $value);
     }
     $label = new Element('span');
     $label->addClass('ccm-toolbar-accessibility-title')->setValue($this->menuItem->getLabel());
     $a->appendChild($label);
     return $a;
 }
Exemplo n.º 21
0
    /**
     * Renders a breadcrumb item
     *
     * @param string $content The item content
     * @param boolean $active Whether the item is active or not
     *
     * @return string
     */
    protected static function renderItem($content, $active = false)
    {
        $item = Element::li($content);

        // If the link is not active it's the last one, don't append separator
        if ($active) {
            $item->addClass('active');
        }

        return $item;
    }
Exemplo n.º 22
0
 /**
  * Prints out the current label
  *
  * @param  string $field The field to create a label for
  *
  * @return string        A <label> tag
  */
 protected function getLabel($field = null)
 {
     // Don't create a label if none exist
     if (!$field or !$this->label) {
         return null;
     }
     // Wrap label in framework classes
     $this->label->addClass($this->app['former.framework']->getLabelClasses());
     $this->label = $this->app['former.framework']->createLabelOf($field, $this->label);
     $this->label = $this->app['former.framework']->wrapLabel($this->label);
     return $this->label;
 }
 public function getMenuItemLinkElement()
 {
     $link = new Link('#', '');
     $link->setAttribute('data-panel-url', \URL::to('/ccm/system/panels/page/relations'));
     $link->setAttribute('title', t('View related pages'));
     $link->setAttribute('data-launch-panel', 'page_relations');
     if (is_object($this->multilingualSection)) {
         $icon = $this->flagService->getFlagIcon($this->multilingualSection->getIcon());
         $accessibility = new Element('span', $this->multilingualSection->getLanguageText());
         $accessibility->addClass('ccm-toolbar-accessibility-title');
         $link->appendChild($icon);
         $link->appendChild($accessibility);
     } else {
         $icon = new Element('i', '');
         $icon->addClass('fa fa-sitemap');
         $accessibility = new Element('span', t('Related Pages'));
         $accessibility->addClass('ccm-toolbar-accessibility-title');
         $link->appendChild($icon);
         $link->appendChild($accessibility);
     }
     return $link;
 }
Exemplo n.º 24
0
 /**
  * Renders a breadcrumb item
  *
  * @param string  $content The item content
  * @param boolean $active  Whether the item is active or not
  *
  * @return string
  */
 protected static function renderItem($content, $active = false)
 {
     $item = Element::li($content);
     $separator = Helpers::getContainer('config')->get('bootstrapper::breadcrumbs_separator');
     $separator = Element::span($separator)->addClass('divider');
     // If the link is not active it's the last one, don't append separator
     if (!$active) {
         $item->nest($separator);
     } else {
         $item->addClass('active');
     }
     return $item;
 }
Exemplo n.º 25
0
 /**
  * Render element view with data.
  *
  * @param $data
  * @return string
  */
 public function view($data)
 {
     //align
     switch ($this->align) {
         case 'center':
             $a = ['text-align' => 'center'];
             break;
         case 'right':
             $a = ['text-align' => 'right'];
             break;
         case 'left':
         default:
             $a = ['text-align' => 'left'];
     }
     $this->styles['list_div'] = array_merge($this->styles['list_div'], $a);
     //width
     $wid = floor(100 / $this->columns) - 1;
     //data and formatter
     $this->styles['list_item'] = array_merge($this->styles['list_item'], ['width' => "{$wid}%"]);
     if (array_key_exists('data', $data)) {
         $d = $data['data'];
     } else {
         $d = $data;
     }
     if (array_key_exists('label_formatter', $data)) {
         $lf = $data['label_formatter'];
     }
     if (array_key_exists('text_formatter', $data)) {
         $tf = $data['text_formatter'];
     }
     foreach ($d as $k => $v) {
         $ltext = $k;
         if (isset($lf) && is_callable($lf)) {
             $ltext = $lf($k);
         }
         $label = new Element('label', new Text($ltext));
         $label->addClass($this->getClass('list_label'))->setAttribute('style', $this->getStyle('list_label'));
         $ttext = $v;
         if (isset($tf) && is_callable($tf)) {
             $ttext = $tf($v);
         }
         $text = new Element('span', new Text($ttext));
         $text->addClass($this->getClass('list_text'))->setAttribute('style', $this->getStyle('list_text'));
         $item = new Element('div');
         $item->addClass('list_item')->setAttribute('style', $this->getStyle('list_item'));
         $item->appendChild($label)->appendChild($text);
         $this->appendChild($item);
         $this->addClass('list_div')->setAttribute('style', $this->getStyle('list_div'));
     }
     return $this->render();
 }
Exemplo n.º 26
0
 /**
  * @param string|array $_choice
  * @param string       $_value
  *
  * @return $this
  */
 public function addChoice($_choice, $_value = null)
 {
     if (is_array($_choice)) {
         $text = array_get($_choice, 'label');
         $value = array_get($_choice, 'value');
         $atts = array_except($_choice, ['label']);
     } else {
         $text = $_choice;
         $value = is_null($_value) ? $_choice : $_value;
         $atts = ['value' => $value];
     }
     $choice = Element::create('option', $text);
     $choice->setAttributes($atts);
     if ($this->isSelected($value)) {
         $choice->setAttribute('selected', 'selected');
     }
     $this->choices->push($choice);
     return $this;
 }
Exemplo n.º 27
0
 /**
  * Render element view with data.
  *
  * @param $data
  * @return string
  */
 public function view($data)
 {
     if (array_key_exists('current', $data)) {
         $this->current = $data['current'];
     }
     if (array_key_exists('title_formatter', $data)) {
         $tf = $data['title_formatter'];
     }
     if (array_key_exists('descr_formatter', $data)) {
         $df = $data['descr_formatter'];
     }
     $i = 1;
     foreach ($this->steps as $step) {
         $sdiv = new Element('div');
         $sstyle = $this->getStyle('step');
         if ($i == $this->current) {
             $sdiv->addClass($this->getClass('current'));
             $sstyle .= $this->getStyle('current');
         } elseif ($i < $this->current) {
             $sdiv->addClass($this->getClass('completed'));
             $sstyle .= $this->getStyle('completed');
         }
         $sdiv->addClass($this->getClass('step'))->setAttribute('style', $sstyle);
         $title = array_key_exists('title', $step) ? $step['title'] : '';
         $descr = array_key_exists('descr', $step) ? $step['descr'] : '';
         if (isset($tf) && is_callable($tf)) {
             $title = $tf($title);
         }
         if (isset($df) && is_callable($df)) {
             $descr = $df($descr);
         }
         $contdiv = new Element('div');
         $contdiv->addClass($this->getClass('content'))->setAttribute('style', $this->getStyle('content'));
         $tdiv = new Element('div', new Text($title));
         $tdiv->addClass($this->getClass('title'))->setAttribute('style', $this->getStyle('title'));
         $ddiv = new Element('div', new Text($descr));
         $ddiv->addClass($this->getClass('descr'))->setAttribute('style', $this->getStyle('descr'));
         $contdiv->appendChild($tdiv)->appendChild($ddiv);
         $sdiv->appendChild($contdiv);
         $this->appendChild($sdiv);
         $i++;
     }
     return $this->render();
 }
Exemplo n.º 28
0
 /**
  * @return string
  */
 public function __toString()
 {
     $e = new Element('script');
     $e->type('text/javascript')->src($this->getAssetURL());
     if (count($this->combinedAssetSourceFiles)) {
         $source = '';
         foreach ($this->combinedAssetSourceFiles as $file) {
             $source .= $file . ' ';
         }
         $source = trim($source);
         $e->setAttribute('data-source', $source);
     }
     return (string) $e;
 }
Exemplo n.º 29
0
 /**
  * Wrap a field with potential additional tags
  *
  * @param  Field $field
  *
  * @return Element A wrapped field
  */
 public function wrapField($field)
 {
     return Element::create('div', $field)->addClass('controls');
 }
Exemplo n.º 30
0
 public function getRequestIconElement()
 {
     $span = new Element('i');
     $span->addClass('fa fa-file-text-o');
     return $span;
 }