Example #1
0
 public function input()
 {
     $select = new Brick('select');
     $select->addClass('selectbox');
     $select->attr(array('name' => $this->name(), 'id' => $this->id(), 'required' => $this->required(), 'autocomplete' => $this->autocomplete(), 'autofocus' => $this->autofocus(), 'readonly' => $this->readonly(), 'disabled' => $this->disabled()));
     $id = $this->id();
     $select->append($this->option('', '', $this->value() == ''));
     if ($this->readonly()) {
         $select->attr('tabindex', '-1');
     }
     foreach ($this->options() as $value => $text) {
         $select->append($this->option($value, $text, $this->value() == $value));
     }
     $inner = new Brick('div');
     $inner->addClass('selectbox-wrapper');
     $inner->append($select);
     $wrapper = new Brick('div');
     $wrapper->addClass('input input-with-selectbox');
     $wrapper->append($inner);
     if ($this->readonly()) {
         $wrapper->addClass('input-is-readonly');
     } else {
         $wrapper->attr('data-focus', 'true');
     }
     echo "<script>console.log('layout " . $id . "');</script>";
     echo "<script>buildLayout(" . $id . ");</script>";
     return $wrapper;
 }
Example #2
0
 public function input()
 {
     $select = new Brick('select');
     $select->addClass('selectbox');
     $select->attr(array('name' => $this->name(), 'id' => $this->id(), 'required' => $this->required(), 'autocomplete' => $this->autocomplete(), 'autofocus' => $this->autofocus(), 'readonly' => $this->readonly(), 'disabled' => $this->disabled()));
     $default = $this->default();
     if (!$this->required() or empty($default)) {
         $select->append($this->option('', '', $this->value() == ''));
     }
     if ($this->readonly()) {
         $select->attr('tabindex', '-1');
     }
     foreach ($this->options() as $value => $text) {
         $select->append($this->option($value, $text, $this->value() == $value));
     }
     $inner = new Brick('div');
     $inner->addClass('selectbox-wrapper');
     $inner->append($select);
     $wrapper = new Brick('div');
     $wrapper->addClass('input input-with-selectbox');
     $wrapper->append($inner);
     if ($this->readonly()) {
         $wrapper->addClass('input-is-readonly');
     } else {
         $wrapper->attr('data-focus', 'true');
     }
     return $wrapper;
 }
Example #3
0
 protected function template($class = false)
 {
     $output = new Brick('div');
     $output->addClass('oembed');
     if ($class !== false) {
         $output->addClass($class);
     } else {
         $output->addClass('oembed-' . substr(md5($this->url), 0, 6));
     }
     if ($this->media->get('type') === 'video') {
         $output = OembedTemplate::ratio($output, $this->media);
         if (c::get('oembed.lazyvideo', false)) {
             $output->addClass('oembed-lazyvideo');
         }
         $play = OembedTemplate::play();
         $output->append($play);
         $thumb = OembedTemplate::thumb($this->thumb->get($this->media()));
         $output->append($thumb);
         $html = OembedTemplate::embed($this->media, $this->autoplay);
     } else {
         $html = $this->media->get('html');
     }
     $html = OembedTemplate::validation($html);
     $output->append($html);
     return $output;
 }
Example #4
0
 public function input()
 {
     $input = new Brick('input');
     $input->addClass('input');
     $input->attr(array('type' => $this->type(), 'value' => html($this->value(), false), 'required' => $this->required(), 'name' => $this->name(), 'autocomplete' => $this->autocomplete() === false ? 'off' : 'on', 'autofocus' => $this->autofocus(), 'placeholder' => $this->i18n($this->placeholder()), 'readonly' => $this->readonly(), 'disabled' => $this->disabled(), 'id' => $this->id()));
     if ($this->readonly()) {
         $input->attr('tabindex', '-1');
         $input->addClass('input-is-readonly');
     }
     return $input;
 }
 public function item($value, $text)
 {
     $input = $this->input($value);
     $label = new Brick('input', $this->i18n($text));
     $label->addClass('input');
     $label->attr('data-focus', 'true');
     $label->prepend($input);
     if ($this->readonly) {
         $label->addClass('input-is-readonly');
     }
     return $label;
 }
Example #6
0
 public function counter()
 {
     if (!$this->minLength() && !$this->maxLength() || $this->readonly()) {
         return null;
     }
     $counter = new Brick('div');
     $counter->addClass('field-counter marginalia text');
     $length = str::length(trim($this->value()));
     if ($this->outsideRange($length)) {
         $counter->addClass('outside-range');
     }
     $counter->data('field', 'counter');
     $counter->html($length . ($this->maxLength() ? '/' . $this->maxLength() : ''));
     return $counter;
 }
Example #7
0
 public static function play()
 {
     $play = new Brick('div');
     $play->addClass('play');
     $play->append('<img src="' . url('assets/oembed/oembed-play.png') . '" alt="Play">');
     return $play;
 }
Example #8
0
 public function icon()
 {
     $icon = new Brick('div');
     $icon->addClass('field-icon');
     $icon->append('<span>.' . $this->extension . '</span>');
     return $icon;
 }
Example #9
0
 public function headline()
 {
     if (!$this->readonly) {
         /*  $fieldName = $this->name;
               $blueprint = $this->page()->blueprint();
         	$fieldsets = $blueprint->fields($this)->$fieldName->fieldsets;*/
         $fieldsets = $this->fieldsets();
         $add = new Brick('a');
         $add->html('<i class="icon icon-left fa fa-chevron-circle-down"></i>' . l('fields.structure.add'));
         $add->addClass('structure-add-button label-option');
         $add->data('modal', true);
         $dropDown = new Brick("div");
         $dropDown->addClass('builder-drop-down');
         $addList = new Brick('ul');
         $addList->addClass('builder-add-list');
         foreach ($fieldsets as $fieldsetName => $fieldsetFields) {
             $addListItem = new Brick('li');
             $addListItemLink = new Brick('a');
             $addListItemLink->html('<i class="icon icon-left fa fa-plus-circle"></i>' . $fieldsetFields['label']);
             $addListItemLink->addClass('builder-add-button');
             $addListItemLink->data('modal', true);
             $addListItemLink->attr('href', purl($this->page, 'field/' . $this->name . '/builder/add?fieldset=' . $fieldsetName));
             $addListItem->append($addListItemLink);
             $addList->append($addListItem);
         }
         $dropDown->append($addList);
     } else {
         $addList = null;
         $add = null;
     }
     $label = BaseField::label();
     $label->append($add);
     $label->append($dropDown);
     return $label;
 }
Example #10
0
 public function content()
 {
     $html = '<ul class="input-list field-grid cf">';
     switch ($this->columns()) {
         case 2:
             $width = ' field-grid-item-1-2';
             break;
         case 3:
             $width = ' field-grid-item-1-3';
             break;
         case 4:
             $width = ' field-grid-item-1-4';
             break;
         case 5:
             $width = ' field-grid-item-1-5';
             break;
         default:
             $width = '';
             break;
     }
     foreach ($this->options() as $key => $value) {
         $html .= '<li class="input-list-item field-grid-item' . $width . '">';
         $html .= $this->item($key, $value);
         $html .= '</li>';
     }
     $html .= '</ul>';
     $content = new Brick('div');
     $content->addClass('field-content');
     $content->append($html);
     return $content;
 }
Example #11
0
 public function content()
 {
     $relation = new Brick('div');
     $relation->addClass('input input-display');
     if ($this->readonly()) {
         $relation->addClass('input-is-readonly');
     }
     $relation->data(array('field' => 'relation', 'search' => $this->search ? 1 : 0, 'readonly' => ($this->readonly or $this->disabled) ? 1 : 0));
     $relation->append('<div class="placeholder">&nbsp;</div>');
     $content = new Brick('div');
     $content->addClass('field-content input-with-relationbox');
     $content->append($relation);
     // list with options
     $html = '<div class="input-list">';
     if ($this->search) {
         $html .= '<input class="relationbox-search" placeholder="Type to filter options">';
     }
     $html .= '<ul>';
     foreach ($this->options() as $key => $value) {
         $html .= '<li class="input-list-item">';
         $html .= $this->item($key, $value);
         $html .= '</li>';
     }
     $html .= '</ul>';
     $html .= '</div>';
     $content->append($html);
     $content->append($this->icon());
     return $content;
 }
Example #12
0
 public function template()
 {
     $wrapper = new Brick('div', null);
     $wrapper->data('tab-name', $this->i18n($this->label));
     $wrapper->data('field', 'tabs');
     $wrapper->addClass('tab-placeholder');
     return $wrapper;
 }
 public function content()
 {
     $content = new Brick('div');
     $content->addClass('field-content');
     $content->append($this->input());
     $content->append($this->icon());
     return $content;
 }
Example #14
0
 public static function time($timestamp, $format = 'short', $classes = '')
 {
     $brick = new Brick('time');
     $brick->datetime = Date::format($timestamp, 'iso');
     $brick->text(Date::format($timestamp, $format));
     $brick->addClass($classes);
     return $brick;
 }
Example #15
0
 public function headline()
 {
     $add = new Brick('a');
     $add->html('<i class="icon icon-left fa fa-plus-circle"></i>' . l('fields.structure.add'));
     $add->addClass('structure-add-button label-option');
     $add->attr('#');
     $label = parent::label();
     $label->addClass('structure-label');
     $label->append($add);
     return $label;
 }
Example #16
0
 public function input()
 {
     $input = new Brick('input', null);
     $input->addClass('tabfield');
     $input->attr(array('id' => $this->id(), 'name' => $this->name(), 'required' => $this->required(), 'autofocus' => $this->autofocus(), 'autocomplete' => $this->autocomplete(), 'readonly' => $this->readonly(), 'type' => 'checkbox', 'checked' => v::accepted($this->value())));
     $wrapper = parent::input();
     $wrapper->tag('label');
     $wrapper->text($this->i18n($this->text()));
     $wrapper->attr('for', $this->id());
     $wrapper->removeAttr('id');
     $wrapper->addClass('tabfield');
     $wrapper->prepend($input);
     return $wrapper;
 }
Example #17
0
 /**
  * Generate field content markup
  *
  * @return string
  */
 public function content()
 {
     $wrapper = new Brick('div');
     $wrapper->addClass('subpagelist');
     $children = $this->subpages();
     // add pagination to the subpages
     $limit = $this->limit() ? $this->limit() : 10000;
     $children = $children->paginate($limit, array('page' => get('page')));
     // use existing snippet to build the list
     // @see panel/app/controllers/views/pages.php
     $subpages = new Snippet('pages/sidebar/subpages', array('title' => l('pages.show.subpages.title'), 'page' => $this->page(), 'subpages' => $children, 'addbutton' => !api::maxPages($this, $this->subpages()->max()), 'pagination' => $children->pagination()));
     // use template with defined vars
     $wrapper->html(tpl::load(__DIR__ . DS . 'template.php', array('subpages' => $subpages)));
     return $wrapper;
 }
Example #18
0
 public function headline()
 {
     if (!$this->readonly) {
         $add = new Brick('a');
         $add->html('<i class="icon icon-left fa fa-plus-circle"></i>' . l('fields.structure.add'));
         $add->addClass('structure-add-button label-option');
         $add->data('modal', true);
         $add->attr('href', purl($this->model, 'field/' . $this->name . '/structure/add'));
     } else {
         $add = null;
     }
     $label = parent::label();
     $label->addClass('structure-label');
     $label->append($add);
     return $label;
 }
Example #19
0
 /**
  * Generate field content markup
  *
  * @return string
  */
 public function content()
 {
     $wrapper = new Brick('div');
     $wrapper->addClass('subpagelist');
     $children = $this->subpages();
     // add pagination to the subpages
     $limit = $this->limit() ? $this->limit() : 10000;
     $children = $children->paginated('sidebar');
     $pagination = new Snippet('pagination', array('pagination' => $children->pagination(), 'nextUrl' => $children->pagination()->nextPageUrl(), 'prevUrl' => $children->pagination()->prevPageUrl()));
     // use existing snippet to build the list
     // @see /panel/app/src/panel/models/page/sidebar.php
     $subpages = new Snippet('pages/sidebar/subpages', array('title' => $this->i18n($this->label), 'page' => $this->page(), 'subpages' => $children, 'addbutton' => $this->page->addButton(), 'pagination' => $pagination));
     // use template with defined vars
     $wrapper->html(tpl::load(__DIR__ . DS . 'template.php', array('subpages' => $subpages)));
     return $wrapper;
 }
Example #20
0
 public function content()
 {
     $multiselect = new Brick('div');
     $multiselect->addClass('input input-display');
     if ($this->readonly()) {
         $multiselect->addClass('input-is-readonly');
     }
     $multiselect->attr(array('tabindex' => 0));
     $multiselect->data(array('field' => 'multiselect', 'search' => $this->search ? 1 : 0, 'readonly' => ($this->readonly or $this->disabled) ? 1 : 0));
     $multiselect->append('<div class="placeholder">&nbsp;</div>');
     $content = new Brick('div');
     $content->addClass('field-content input-with-multiselectbox');
     $content->append($multiselect);
     $content->append($this->optionlist());
     $content->append($this->icon());
     return $content;
 }
 public function input()
 {
     $color = new Brick('input');
     $color->addClass('colorpicker');
     if ($this->value() == "" && $this->default() !== "") {
         $value = $this->default();
     } elseif ($this->value() == "" && $this->default() == "") {
         $value = "";
     } else {
         $value = $this->value();
     }
     $color->attr(array('name' => $this->name(), 'id' => $this->id(), 'type' => "text", 'data-defaultvalue' => $value, 'value' => $value));
     $color->append($this->option('', '', $this->value() == ''));
     $wrapper = new Brick('div');
     $wrapper->addClass('input color-wrapper');
     $wrapper->append($color);
     return $color;
 }
Example #22
0
 // Set break class used in layout grid
 if (count($imageresult) > 1) {
     $breakclass = ' Grid--breakFrom' . ucfirst($break);
 } else {
     $breakclass = '';
 }
 // Set possible align classes
 if (isset($align)) {
     $alignclass = ' FigureImage--align' . ucfirst($align);
     // Add capitalized align class (IE: Grid--alignCenter)
 } else {
     $alignclass = '';
 }
 // Add figure DOM element with appended classes
 $figure = new Brick('figure');
 $figure->addClass('FigureImage' . $gridclass . $breakclass . $alignclass);
 // If feed/rss page, lazyload is always disable
 if (kirby()->request()->path()->last() == 'feed') {
     $lazyload = false;
 } else {
     $lazyload = c::get('lazyload', false);
 }
 // Create markup for every image
 $i = 0;
 foreach ($imageresult as $image) {
     // Initialize wrapper divs if lazyloading
     if ($lazyload == true) {
         // Only init griddiv when $gridcellclass or one or more width is set
         if ($gridcellclass != '' || count($widths) > 0) {
             $griddiv = new Brick('div');
         }
Example #23
0
 public function __toString()
 {
     // auto-trigger the submit event when the form is being echoed
     if (get('_csfr') and csfr(get('_csfr'))) {
         $this->trigger('submit');
     }
     $this->append($this->alert());
     $fieldset = new Brick('fieldset');
     $fieldset->addClass('fieldset field-grid cf');
     foreach ($this->fields() as $field) {
         $fieldset->append($field);
     }
     $this->append($fieldset);
     $this->append($this->buttons());
     $this->append(static::field('hidden', array('name' => '_csfr', 'value' => csfr())));
     return parent::__toString();
 }
Example #24
0
 /**
  * Create editor element
  *
  * This creates our main editor <div>.
  *
  * @since 1.0.0
  *
  * @return \Brick
  */
 protected function editor()
 {
     /*
        Prepare editor element
     */
     $editor = new Brick('div');
     $editor->addClass('input');
     $editor->addClass('wysiwyg-editor');
     $editor->attr('id', $this->id() . '-editor');
     $editor->data(array('storage' => $this->id(), 'buttons' => implode(',', $this->buttons), 'double-returns' => $this->doubleReturns, 'dragdrop-medium' => $this->mediumDragDrop));
     /*
        Parse markdown and set editor content
     */
     $editor->html($this->convertToHtml($this->value() ?: ''));
     return $editor;
 }
Example #25
0
 /**
  * Generate field content markup
  *
  * @since 1.0.0
  *
  * @return string
  */
 public function content()
 {
     $wrapper = new Brick('div');
     $wrapper->addClass('selector');
     $wrapper->data(array('field' => 'selector', 'name' => $this->name(), 'page' => $this->page(), 'mode' => $this->mode, 'autoselect' => $this->autoselect()));
     $wrapper->html(tpl::load(__DIR__ . DS . 'template.php', array('field' => $this)));
     return $wrapper;
 }
Example #26
0
    $image = html::img($url, array('width' => $tag->attr('width'), 'height' => $tag->attr('height'), 'class' => $tag->attr('imgclass'), 'title' => html($title), 'alt' => html($alt)));
    if ($tag->attr('link')) {
        // build the href for the link
        if ($link == 'self') {
            $href = $url;
        } else {
            if ($file and $link == $file->filename()) {
                $href = $file->url();
            } else {
                $href = $link;
            }
        }
        $image = html::a(url($href), $image, array('rel' => $tag->attr('rel'), 'class' => $tag->attr('linkclass'), 'title' => html($tag->attr('title')), 'target' => $tag->target()));
    }
    $figure = new Brick('figure');
    $figure->addClass($tag->attr('class'));
    $figure->append($image);
    if (!empty($caption)) {
        $figure->append('<figcaption>' . html($caption) . '</figcaption>');
    }
    return $figure;
});
// link tag
kirbytext::$tags['link'] = array('attr' => array('text', 'class', 'title', 'rel', 'target', 'popup'), 'html' => function ($tag) {
    return html::a(url($tag->attr('link')), html($tag->attr('text')), array('rel' => $tag->attr('rel'), 'class' => $tag->attr('class'), 'title' => html($tag->attr('title')), 'target' => $tag->target()));
});
// tel tag
kirbytext::$tags['tel'] = array('attr' => array('text', 'class', 'title'), 'html' => function ($tag) {
    $text = $tag->attr('text');
    $tel = str_replace(array('/', ' ', '-'), '', $tag->attr('tel'));
    if (empty($text)) {
Example #27
0
 public function element()
 {
     $element = new Brick('div');
     $element->addClass('field');
     $element->addClass('field-grid-item');
     if ($this->error) {
         $element->addClass('field-with-error');
     }
     if ($this->width) {
         $element->addClass('field-grid-item-' . str_replace('/', '-', $this->width));
     }
     if ($this->readonly) {
         $element->addClass('field-is-readonly');
     }
     if ($this->disabled) {
         $element->addClass('field-is-disabled');
     }
     if ($this->icon) {
         $element->addClass('field-with-icon');
     }
     $element->addClass('field-name-' . $this->name);
     return $element;
 }
Example #28
0
 /**
  * Get a link that allows to delete the comment. Only available to registered
  * users.
  *
  * @return  Brick|string
  */
 public function deleteLink()
 {
     // Ensure the current user is allowed to edit the comment
     if (!$this->exists || !$this->currentUserCan('delete')) {
         return '';
     }
     $uri = $this->page()->uri();
     $hash = $this->page()->hash();
     $id = $this->id();
     $link = new Brick('a');
     $link->attr('href', $this->actionUrl('delete'));
     $link->data('href', $this->actionUrl('delete', true));
     $link->addClass('comment-delete-link js-delete');
     $link->text(l('comments.comment.delete', 'Delete'));
     return $link;
 }
Example #29
0
return function ($page) {
    // create the form
    $form = new Kirby\Panel\Form($page->getFormFields(), $page->getFormData());
    // add the blueprint name as css class
    $form->addClass('form-blueprint-' . $page->blueprint()->name());
    // center the submit button
    $form->centered = true;
    // set the keep api
    $form->data('keep', $page->url('keep'));
    // set the autofocus on the title field
    $form->fields->title->autofocus = true;
    // add the changes alert
    if ($page->changes()->differ()) {
        // display unsaved changes
        $alert = new Brick('div');
        $alert->addClass('text');
        $alert->append('<span>' . l('pages.show.changes.text') . '</span>');
        $form->buttons->prepend('changes', $alert);
        $form->buttons->cancel->attr('href', $page->url('discard'));
        $form->buttons->cancel->html(l('pages.show.changes.button'));
        // add wide buttons
        $form->buttons->cancel->addClass('btn-wide');
        $form->buttons->submit->addClass('btn-wide');
    } else {
        // remove the cancel button
        $form->buttons->cancel = '';
    }
    // check for untranslatable fields
    if (panel()->site()->language() != panel()->site()->defaultLanguage()) {
        foreach ($form->fields() as $field) {
            if ($field->translate() == false) {
Example #30
0
 /**
  * Create input element.
  *
  * @since 1.0.0
  * @return \Brick
  */
 public function input()
 {
     // Set up modals
     $modals = tpl::load(__DIR__ . DS . 'partials' . DS . 'modals.php', ['field' => $this]);
     // Set up translation
     $translation = tpl::load(__DIR__ . DS . 'partials' . DS . 'translation.php', ['translations' => $this->translation]);
     // Set up textarea
     $input = parent::input();
     $input->tag('textarea');
     $input->removeAttr('type');
     $input->removeAttr('value');
     $input->html($this->value() ?: false);
     $input->data(['field' => 'markdownfield', 'toolbar' => $this->toolbar ? 'true' : 'false', 'tools' => implode(',', $this->tools), 'header1' => $this->header1, 'header2' => $this->header2, 'kirbytext' => c::get('panel.kirbytext', true) ? 'true' : 'false']);
     /*
        FIX: Prevent Google Chrome from trying to validate the underlying
        invisible textarea. the Panel will handle this instead.
     
        See: https://github.com/JonasDoebertin/kirby-visual-markdown/issues/42
     */
     $input->removeAttr('required');
     // Set up wrapping element
     $wrapper = new Brick('div', false);
     $wrapper->addClass('markdownfield-wrapper');
     $wrapper->addClass('markdownfield-field-' . $this->name);
     return $wrapper->append($modals)->append($translation)->append($input);
 }