Example #1
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;
 }
Example #2
0
 public function preview()
 {
     $figure = new Brick('figure');
     if ($image = $this->image()) {
         $figure->attr('style', 'background-image: url(' . $image->crop(75)->url() . ')');
         $url = $image->url('edit');
     } else {
         $figure->attr('style', 'background-image: url(' . $this->value() . ')');
         $url = '';
     }
     return '<a href="' . $url . '" class="input-preview">' . $figure . '</a>';
 }
Example #3
0
 public static function thumb($thumbnail)
 {
     $thumb = new Brick('div');
     $thumb->addClass('thumb');
     $thumb->attr('style', 'background-image: url(' . $thumbnail . ')');
     return $thumb;
 }
Example #4
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 #5
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 #6
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 #7
0
 public function item($value, $text)
 {
     $input = $this->input($value);
     $label = new Brick('label', $this->i18n($text));
     $label->addClass('input');
     $label->attr('data-focus', 'true');
     $label->prepend($input);
     return $label;
 }
 public function input()
 {
     $input = new Brick('input', null);
     $input->addClass('input');
     $input->attr(array('type' => $this->type(), 'value' => '', '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()));
     $input->tag('textarea');
     $input->removeAttr('type');
     $input->removeAttr('value');
     $input->data('field', 'editor');
     $input->html('{{yamlvalues}}' ?: false);
     if (!is_array($this->value())) {
         $input->val('{{yamlvalues}}');
     }
     if ($this->readonly()) {
         $input->attr('tabindex', '-1');
         $input->addClass('input-is-readonly');
     }
     return $input;
 }
Example #9
0
 public function mapsearch()
 {
     $mapsearch = new Brick('div');
     $mapsearch->addClass('mapsearch');
     // Search field
     $input = new Brick("input");
     $input->attr("id", "geo-search-field");
     $input->attr("placeholder", "Zoek naar locatie");
     $input->addClass("input mapsearch-field");
     // Search button
     $button = new Brick("input");
     $button->attr("id", "geo-search-submit");
     $button->attr("type", "button");
     $button->attr("value", "Zoek");
     $button->addClass("btn btn-rounded mapsearch-button");
     $mapsearch->append($input);
     $mapsearch->append($button);
     return $mapsearch;
 }
Example #10
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 #11
0
 public function label()
 {
     if (!$this->label) {
         return null;
     }
     $label = new Brick('label', $this->i18n($this->label));
     $label->addClass('label');
     $label->attr('for', $this->id());
     if ($this->required()) {
         $label->append(new Brick('abbr', '*', array('title' => l::get('required', 'Required'))));
     }
     return $label;
 }
Example #12
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 #13
0
 public function item($value, $text)
 {
     $input = $this->input($value);
     $label = new Brick('label');
     $label->addClass('input');
     $label->attr('data-focus', 'true');
     $text = new Brick('span', $this->i18n($text));
     $label->prepend($text);
     $label->prepend($input);
     if ($this->readonly) {
         $label->addClass('input-is-readonly');
     }
     return $label;
 }
Example #14
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 #15
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 #17
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 #18
0
     // Intrinsic image's ratio
     $ratio = 1 / $image->ratio();
     // Max. height of image
     $thumbheight = round($thumbwidth * $ratio);
 }
 // Percentage-padding to set image aspect ratio (prevents reflow on image load)
 $percentage_padding = floor(round($ratio * 100, 2) * 100) / 100;
 // 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');
     }
     $lazydiv = new Brick('div');
     $lazydiv->addClass('FigureImage-lazy lazyload');
     $lazydiv->attr('style', 'padding-bottom: ' . number_format($percentage_padding, 2, '.', '') . '%;');
 }
 // Set width class names of image(s)
 $width = $widths[$i];
 // If there is one or more width set (and it's not in a feed), apply the width variable(s)
 if ($feed != true) {
     if (count($widths) > 0) {
         // The first part (the 1 of 3)
         $classgridpart = str::substr($width, 0, 1);
         // The total (the 3)
         $classgridtot = str::substr($width, 3, 1);
         // Add extra griddiv for lazyload
         if ($lazyload == true) {
             // Set the class for the image
             $class = 'FigureImage-item';
             // Set the class on the grid div
Example #19
0
 private function input_lng()
 {
     # Wrapper
     $lng_content = new Brick('div');
     $lng_content->addClass('field-content field-lng');
     # Input (Locked: We use the map UI to update these)
     $lng_input = new Brick('input');
     $lng_input->attr('tabindex', '-1');
     $lng_input->attr('readonly', true);
     $lng_input->addClass('input input-split-right input-is-readonly place-lng');
     $lng_input->attr('placeholder', l::get('fields.place.longitude', 'Longitude'));
     $lng_input->val($this->pick('lng'));
     # Combine & Ship It
     $lng_content->append($lng_input);
     return $lng_content;
 }
Example #20
0
 /**
  * Generate label markup
  *
  * @since 1.0.0
  *
  * @return string
  */
 public function label()
 {
     /* Action button */
     $action = new Brick('a');
     $action->addClass('file-add-button label-option');
     $action->html('<i class="icon icon-left fa fa-plus-circle"></i>' . l('pages.show.files.add'));
     $action->attr('href', purl($this->page(), 'upload'));
     /* Label */
     $label = parent::label();
     /**
      * Fields don't have to have a label assigned.
      * With this, we deal with missing label information.
      *
      * @since 1.3.0
      */
     if (!is_null($label)) {
         $label->addClass('figure-label');
         $label->append($action);
         return $label;
     }
     return;
 }
 /**
  * Create input element.
  *
  * @since 1.0.0
  *
  * @return Brick
  */
 public function input()
 {
     $input = new Brick('input');
     /* Set general attributes */
     $input->attr(array('type' => 'text', 'name' => $this->name(), 'id' => $this->id(), 'value' => $this->value(), 'required' => $this->required(), 'autocomplete' => 'off', 'tabindex' => '-1', 'disabled' => $this->option('disabled'), 'readonly' => $this->option('readonly')));
     $input->addClass('input-is-readonly');
     /* Set data attributes */
     $input->data(array('field' => 'rangesliderfield', 'min' => $this->option('min'), 'max' => $this->option('max'), 'step' => $this->option('step'), 'prefix' => $this->option('prefix'), 'postfix' => $this->option('postfix')));
     return $input;
 }
Example #22
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 #23
0
field::$methods['int'] = function ($field, $default = 0) {
    $val = $field->empty() ? $default : $field->value;
    return intval($val);
};
/**
 * Get a float value for the Field
 * @param Field $field The calling Kirby Field instance
 * @param int $default Default value returned if field is empty
 * @return float
 */
field::$methods['float'] = function ($field, $default = 0) {
    $val = $field->empty() ? $default : $field->value;
    return floatval($val);
};
field::$methods['toStructure'] = field::$methods['structure'] = function ($field) {
    return structure($field->yaml(), $field->page());
};
field::$methods['link'] = function ($field, $attr1 = array(), $attr2 = array()) {
    $a = new Brick('a', $field->value());
    if (is_string($attr1)) {
        $a->attr('href', url($attr1));
        $a->attr($attr2);
    } else {
        $a->attr('href', $field->page()->url());
        $a->attr($attr1);
    }
    return $a;
};
field::$methods['toUrl'] = field::$methods['url'] = function ($field) {
    return url($field->value());
};
Example #24
0
<?php

/**
 * http://html5doctor.com/cite-and-blockquote-reloaded/
 */
kirbytext::$tags['blockquote'] = array('attr' => array('lang', 'cite', 'link'), 'html' => function ($tag) {
    $quote = $tag->attr('blockquote');
    $lang = $tag->attr('lang');
    $cite = $tag->attr('cite');
    $link = $tag->attr('link');
    $quoteTag = new Brick('blockquote');
    $quoteTag->attr('lang', $lang);
    $quoteTag->append(kirbytext($quote));
    $cite = $cite ?: preg_replace('/^https?:\\/\\//i', null, $link);
    if (!$cite) {
        return $quoteTag;
    }
    if ($link) {
        $linkTag = new Brick('a');
        $linkTag->attr('href', $link);
        $linkTag->append($cite);
    }
    $citeTag = new Brick('cite');
    $citeTag->append(isset($linkTag) ? $linkTag : $cite);
    $quoteTag->append($citeTag);
    return $quoteTag;
});
 /**
  * Create input element.
  *
  * @since 1.0.0
  *
  * @return \Brick
  */
 public function input()
 {
     // Set up textarea
     $input = parent::input();
     $input->tag('textarea');
     $input->removeAttr('type');
     $input->removeAttr('value');
     $input->html($this->value() ?: false);
     $input->data(array('field' => 'codeeditorfield', 'editor' => '#' . $this->id() . '-editor', 'mode' => $this->mode, 'theme' => $this->theme, 'height' => $this->height, 'folding' => $this->folding, 'require-path' => purl($this->page(), 'field/' . $this->name() . '/codeeditor/ace/require')));
     /**
      * 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('codeeditor-wrapper');
     $wrapper->addClass('codeeditor-field-' . $this->name);
     if ($this->height === 'auto') {
         $wrapper->addClass('codeeditor-field-autoheight');
     }
     // Set up code editor element
     $editor = new Brick('div', false);
     $editor->addClass('codeeditor-editor');
     $editor->attr('id', $this->id() . '-editor');
     $editor->append($this->value());
     return $wrapper->append($input)->append($editor);
 }
Example #26
0
     // Intrinsic image's ratio
     $ratio = 1 / $image->ratio();
     // Max. height of image
     $thumbheight = round($thumbwidth * $ratio);
 }
 // Percentage-padding to set image aspect ratio (prevents reflow on image load)
 $percentage_padding = round($ratio * 100, 2);
 // 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');
     }
     $lazydiv = new Brick('div');
     $lazydiv->addClass('FigureImage-lazy lazyload');
     $lazydiv->attr('style', 'padding-bottom: ' . $percentage_padding . '%;');
 }
 // Set width class names of image(s)
 $width = $widths[$i];
 // If there is one or more width set (and it's not in a feed), apply the width variable(s)
 if ($feed != true) {
     if (count($widths) > 0) {
         // The first part (the 1 of 3)
         $classgridpart = str::substr($width, 0, 1);
         // The total (the 3)
         $classgridtot = str::substr($width, 3, 1);
         // Add extra griddiv for lazyload
         if ($lazyload == true) {
             // Set the class for the image
             $class = 'FigureImage-item';
             // Set the class on the grid div
Example #27
0
 /**
  * Generate label markup
  *
  * @since 1.0.0
  *
  * @return string
  */
 public function label()
 {
     /* Action button */
     $action = new Brick('a');
     $action->addClass('file-add-button label-option');
     $action->html('<i class="icon icon-left fa fa-plus-circle"></i>' . l('pages.show.files.add'));
     $action->attr('href', purl($this->page(), 'upload'));
     /* Label */
     $label = parent::label();
     $label->addClass('figure-label');
     $label->append($action);
     return $label;
 }
Example #28
0
 /**
  * Generate label markup.
  *
  * @since 1.0.0
  *
  * @return string
  */
 public function label()
 {
     /* Edit button */
     $edit = new Brick('a');
     $edit->addClass('file-edit-button label-option');
     $edit->html('<i class="icon icon-left fa fa-pencil"></i>' . l('pages.show.files.edit'));
     $edit->attr('href', $this->page()->url('files'));
     /* Add button */
     $add = new Brick('a');
     $add->addClass('file-add-button label-option');
     $add->html('<i class="icon icon-left fa fa-plus-circle"></i>' . l('pages.show.files.add'));
     /**
      * FIX: With Kirby 2.2 the structure of the "Add file" actions changed.
      * Let's make sure we handle both the old >2.1 and the new 2.2+ ways.
      *
      * @since 1.5.0
      */
     if (version_compare(Kirby::version(), '2.2', '>=')) {
         $add->attr('href', '#upload');
         $add->data('upload', 'true');
     } else {
         $add->attr('href', purl($this->page(), 'upload'));
     }
     /* Actions container */
     $actions = new Brick('span');
     $actions->addClass('hgroup-option-right selector-hgroup-option-right');
     $actions->append($edit);
     $actions->append($add);
     /* Label */
     $label = parent::label();
     /**
      * FIX: Fields don't have to have a label assigned.
      * With this, we deal with missing label information.
      *
      * @since 1.3.0
      */
     if (!is_null($label)) {
         $label->addClass('figure-label');
         $label->append($actions);
         return $label;
     }
     return;
 }
Example #29
0
 /**
  * @param array $attr
  * @return string
  */
 public function html($attr = array())
 {
     if ($this->type() != 'image') {
         return false;
     }
     $img = new Brick('img');
     $img->attr('src', $this->url());
     $img->attr('alt', ' ');
     if (is_string($attr) || is_object($attr) && method_exists($attr, '__toString')) {
         $img->attr('alt', (string) $attr);
     } else {
         if (is_array($attr)) {
             $img->attr($attr);
         }
     }
     return $img;
 }
Example #30
0
 if (empty($videos)) {
     return false;
 }
 // find the poster for this video
 foreach ($page->images() as $i) {
     if (preg_match('!^' . preg_quote($id) . '!i', $i->name())) {
         $poster = $i;
         break;
     }
 }
 $width = $tag->attr('width', c::get('kirbytext.video.width'));
 $height = $tag->attr('height', c::get('kirbytext.video.height'));
 $uid = $tag->attr('uid', $id);
 $name = $tag->attr('name', $id);
 $html = new Brick('video');
 $html->attr('width', $width);
 $html->attr('height', $height);
 $html->attr('data-uid', $uid);
 $html->attr('data-name', $name);
 $html->attr('preload', 'none');
 $html->attr('class', trim('video sublime' . $class));
 if ($poster) {
     $html->attr('poster', $poster->url());
 }
 foreach ($videos as $video) {
     $source = new Brick('source');
     $source->attr('src', $video->url());
     $source->attr('type', $video->mime());
     if (f::extension($video->name()) == 'hd') {
         $source->attr('data-quality', 'hd');
     }