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"> </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; }
public function content() { $content = new Brick('div'); $content->addClass('field-content'); $content->append($this->input()); $content->append($this->icon()); return $content; }
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; }
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; }
public function icon() { $icon = new Brick('div'); $icon->addClass('field-icon'); $icon->append('<span>.' . $this->extension . '</span>'); return $icon; }
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; }
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; }
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; }
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"> </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 element() { $element = parent::element(); $script = new Brick('script', false); $script->append('previewImagesFromSidebar()'); $element->append($script); return $element; }
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; }
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; }
<?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; });
<?php return function ($page) { // label option $option = new Brick('a', icon('magic', 'left') . l('pages.url.uid.label.option'), array('class' => 'btn btn-icon label-option', 'href' => '#', 'data-title' => str::slug($page->title()))); // url preview $preview = new Brick('div', '', array('class' => 'uid-preview')); $preview->append(ltrim($page->parent()->uri() . '/', '/')); $preview->append('<span>' . $page->slug() . '</span>'); // create the form $form = new Kirby\Panel\Form(array('uid' => array('label' => l('pages.url.uid.label') . $option, 'type' => 'text', 'icon' => 'chain', 'autofocus' => true, 'help' => $preview, 'default' => $page->slug()))); $form->buttons->submit->val(l('change')); $form->cancel($page); return $form; };
private function input_serialized() { # Wrapper $serialized_content = new Brick('div'); $serialized_content->addClass('field-hidden field-serialized'); # Field (Hidden: Users shouldn't be able to manipulate the JSON we'll store in here) $serialized_input = $this->input(); $serialized_input->attr('type', 'hidden'); # Combine & Ship It $serialized_content->append($serialized_input); return $serialized_content; }
<?php return function ($problems) { $form = new Kirby\Panel\Form(array('info' => array('type' => 'info'))); if (count($problems) > 1) { $info = new Brick('ol'); foreach ($problems as $problem) { $info->append('<li>' . $problem . '</li>'); } } else { $info = new Brick('p'); foreach ($problems as $problem) { $info->append($problem); } } // add the list of problems to the info field $form->fields->info->text = (string) $info; // setup the retry button $form->buttons->submit->value = l('installation.check.retry'); $form->buttons->submit->autofocus = true; $form->style('centered'); $form->alert(l('installation.check.text')); return $form; };
/** * 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); }
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(); }
/** * 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; }
/** * 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); }
$imagethumb = html::img($placeholderSRC, array('data-src' => $thumburl, 'data-sizes' => "auto", 'data-srcset' => $ms_datasrcset, 'class' => $class . ' lazyload', 'alt' => html($alt))); } else { $imagethumb = html::img($placeholderSRC, array('data-src' => $thumburl, 'class' => $class . ' lazyload', 'alt' => html($alt))); } // echo "imagethumb =<br>" . htmlentities($imagethumb); /* $imagethumb = '<img data-sizes="auto" src="lqip-src.jpg" data-srcset="lqip-src.jpg 220w, image2.jpg 300w, image3.jpg 600w, image4.jpg 900w" class="lazyload" />'; */ $noscript = '<noscript><img src="' . $thumburl . '" class="' . $class . '" width="' . $thumbwidth . '" height="' . $thumbheight . '" alt="' . html($alt) . '"/></noscript>'; } // Output different markup, depending on lazyload or not if ($lazyload == true) { $lazydiv->append($imagethumb); if ($noscript) { // If noscript is set, append to figure $lazydiv->append($noscript); } if ($outputlink == 1) { $figure->append('<a target="_blank" href="' . $image->url() . '" data-size="' . $image->width() . 'x' . $image->height() . '"><div class="image">' . $lazydiv . '</div></a>'); } else { $figure->append('<div class="image">' . $lazydiv . '</div>'); } } else { if ($outputlink == 1) { $figure->append('<a target="_blank" href="' . $image->url() . '" data-size="' . $image->width() . 'x' . $image->height() . '"><div class="image">' . $imagethumb . '</div></a>'); } else { $figure->append('<div class="image">' . $imagethumb . '</div>'); }
<?php /** * Thumb * ---- * (Cropped) thumb generation. * * What it does: * Generates a thumb image in a <figure> tag. * * Usage: * (thumb: image.jpg width: 225 height: 225 alt: Just a thumb) * (thumb: image.jpg width: 225 height: 225 quality: 75 alt: Thumb with quality 75) * (thumb: image.jpg width: 400 height: 250 crop: true alt: Thumb cropped) * * Example: * http://altair.studiodumbar.com/images */ kirbytext::$tags['thumb'] = array('attr' => array('width', 'height', 'alt', 'quality', 'crop'), 'html' => function ($tag) { $url = $tag->attr('thumb'); $file = $tag->file($url); $quality = $tag->attr('quality', c::get('thumb.quality', 100)); $image = thumb($file, array('width' => $tag->attr('width'), 'height' => $tag->attr('height'), 'alt' => $tag->attr('alt'), 'quality' => $quality, 'crop' => $tag->attr('crop'))); $figure = new Brick('figure'); $figure->append($image); return $figure; });
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)) { $text = $tag->attr('tel');
// 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) { $field->readonly = true;
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'); } $html->append($source); } return $html; });
<?php return function ($problems) { $form = new Kirby\Panel\Form(array('info' => array('type' => 'info'))); $info = new Brick('ol'); foreach ($problems as $problem) { $info->append('<li>' . $problem . '</li>'); } // add the list of problems to the info field $form->fields->info->text = (string) $info; // setup the retry button $form->buttons->submit->value = l('installation.check.retry'); $form->buttons->submit->autofocus = true; $form->style('centered'); $form->alert(l('installation.check.text')); return $form; };
/** * Create input element * * @since 1.0.0 * * @return \Brick */ public function input() { // Set up modals $modals = tpl::load(__DIR__ . DS . 'partials' . DS . 'modals.php', array('field' => $this)); // Set up translation $translation = tpl::load(__DIR__ . DS . 'partials' . DS . 'translation.php', array('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(array('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')); // 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); }
$imagethumb = html::img('/assets/images/loader.gif', array('data-src' => $thumburl, 'class' => $class, 'alt' => html($alt))); } // [3] Resrc image; full size thumb (let resrc resize and optimize the biggest possible thumb!) if ($lazyload == false && c::get('resrc') == true) { $imagethumb = html::img('', array('data-src' => 'http://' . c::get('resrc.plan') . '/' . c::get('resrc.params') . '/' . $thumburl, 'class' => $class . ' resrc', 'alt' => html($alt))); } // [4] Lazyload + resrc image; full size thumb (let resrc resize and optimize the biggest possible thumb!) if ($lazyload == true && c::get('resrc') == true) { $imagethumb = html::img('/assets/images/loader.gif', array('data-src' => 'http://' . c::get('resrc.plan') . '/' . c::get('resrc.params') . '/' . $thumburl, 'class' => $class . ' js-resrcIsLazy', 'alt' => html($alt))); } // Output different markup, depending on lazyload or not if ($lazyload == true) { $lazydiv->append($imagethumb); if (isset($griddiv)) { $griddiv->append($lazydiv); $figure->append($griddiv); } else { $figure->append($lazydiv); } } else { $figure->append($imagethumb); } $i++; } // Add caption if (!empty($caption)) { // Also add break class to figcaption if alignment is set to image if (count($widths) > 0 && isset($align)) { $figure->append('<figcaption class="FigureImage-caption u-size' . $width . '--' . $break . '">' . kirbytext($caption) . '</figcaption>'); } else { $figure->append('<figcaption class="FigureImage-caption">' . kirbytext($caption) . '</figcaption>');
* What it does: * Embeds youtube or vimeo video in a fluid embed. * * Usage: * 1) (video: 77383196 source: vimeo) * 2) (video: hXU63NXzg5A source: youtube ratio: 4by3) * 3) (video: zJs9p-VNORw source: vimeo ratio: 2by1) */ kirbytext::$tags['video'] = array('attr' => array('ratio', 'source'), 'html' => function ($tag) { $video = $tag->attr('video'); $ratio = $tag->attr('ratio'); $source = $tag->attr('source'); // fill the ratio string if ($ratio == '') { $ratio = 'FluidEmbed--16by9'; } else { $ratio = 'FluidEmbed--' . $ratio; } // display the embedcode if ($source == 'vimeo') { $videoelement = '<iframe src="//player.vimeo.com/video/' . $video . '?title=0&byline=0&portrait=0&color=0000ff" width="' . c::get('video.height', '500') . '" height="' . c::get('video.width', '281') . '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'; } elseif ($source == 'youtube') { $videoelement = '<iframe width="' . c::get('video.width', '500') . '" height="' . c::get('video.height', '281') . '" src="//www.youtube.com/embed/' . $video . '?rel=0" frameborder="0" allowfullscreen></iframe>'; } else { $videoelement = '<a href="' . $video . '" class="FluidEmbed-item">' . $video . '</a>'; } $figure = new Brick('figure'); $figure->addClass('FluidEmbed ' . $ratio); $figure->append($videoelement); return $figure; });