function charcountnospaces($content) { $words = kirbytext($content); $words = strip_tags($words); $words = trim($words); $words = ereg_replace('[[:space:]]+', '', $words); $charcount = strlen($words); return $charcount; }
function readingtime($content, $params = array()) { $defaults = array('minute' => 'minute', 'minutes' => 'minutes', 'second' => 'second', 'seconds' => 'seconds', 'format' => '{minutesCount} {minutesLabel}, {secondsCount} {secondsLabel}'); $options = array_merge($defaults, $params); //$words = str_word_count(strip_tags($content)); $words = kirbytext($content); $words = str_word_count(strip_tags($words)); $minutesCount = floor($words / 200); $secondsCount = floor($words % 200 / (200 / 60)); $minutesLabel = $minutesCount == 1 ? $options['minute'] : $options['minutes']; $secondsLabel = $secondsCount == 1 ? $options['second'] : $options['seconds']; $replace = array('minutesCount' => $minutesCount, 'minutesLabel' => $minutesLabel, 'secondsCount' => $secondsCount, 'secondsLabel' => $secondsLabel); $result = $options['format']; foreach ($replace as $key => $value) { $result = str_replace('{' . $key . '}', $value, $result); } return $result; }
public static function convert($text) { $n = 1; $notes = array(); if (preg_match_all(self::$patternFootnote, $text, $matches)) { foreach ($matches[0] as $fn) { $notes[$n] = preg_replace(self::$patternContent, '\\1', $fn); if (substr($notes[$n], 1, 4) == '<no>') { $substitute = ''; } else { $substitute = '<sup class="footnote">'; $substitute .= '<a href="#fn-' . $n . '" id="fnref-' . $n . '">' . $n . '</a>'; $substitute .= '</sup>'; } $text = str_replace($fn, $substitute, $text); $notes[$n] = kirbytext($notes[$n]); $notes[$n] = str_replace('<p>', '', $notes[$n]); $notes[$n] = str_replace('</p>', '', $notes[$n]); $n++; } // build footnotes references $text .= "<div class='footnotes' id='footnotes'>"; $text .= "<div class='footnotedivider'></div>"; $text .= "<ol>"; for ($i = 1; $i < $n; $i++) { $text .= "<li id='fn-" . $i . "'>"; if (substr($notes[$i], 0, 4) == '<no>') { $notes[$i] = str_replace('<no>', "", $notes[$i]); $text .= $notes[$i] . "</li>"; } else { $text .= $notes[$i] . " <span class='footnotereverse'><a href='#fnref-" . $i . "'>↩</a></span></li>"; } } $text .= "</ol>"; $text .= "</div>"; if (c::get('footnotes.smoothscroll', false)) { $text .= self::script(); } return $text; } return $text; }
public static function blockFigure($content, $caption = false, $caption_top = false, $caption_class = false) { if ($caption === false) { return $content; } if (is_string($caption)) { $caption = kirbytext($caption); $figcaption = \Html::tag("figcaption", $caption); } else { $figcaption = ""; } if ($caption_top !== false) { $content = $figcaption . $content; } else { $content = $content . $figcaption; } $attr = array(); if ($caption_class !== false && !empty($caption_class)) { $attr['class'] = $caption_class . ($caption_top !== false ? " figcaption-top" : " figcaption-bottom"); } else { $attr['class'] = $caption_top !== false ? "figcaption-top" : "figcaption-bottom"; } return \Html::tag("figure", $content, $attr); }
?> "><?php echo kirbytext($article->text()); ?> </a></td> <td><a href="<?php echo $article->url(); ?> "><?php echo kirbytext($article->type()); ?> </a></td> <td class="margin-row"><a href="<?php echo $article->url(); ?> "><?php echo kirbytext($article->year()); ?> </a></td> </tr> <?php } ?> </table> </main> <?php snippet('footer');
<?php snippet('header'); snippet('menu'); ?> <section id="main"> <div class="container"> <div class="seven columns intro"> <?php echo kirbytext($page->intro()); ?> </div> <div class="five columns currently"> <?php echo kirbytext($page->currently()); ?> </div> </div> </section> <?php snippet('footer');
private function clean($fn) { $fn = preg_replace($this->regexContent, '\\1', $fn); return str_replace(array('<p>', '</p>'), '', kirbytext($fn)); }
<div class="row large-space-top"> <footer class="small-12 small-centered medium-12 columns"> <?php echo kirbytext($site->copyright()); ?> </footer> </div> <?php echo js('assets/js/vendor/jquery.js'); echo js('assets/js/foundation/foundation.min.js'); echo js('assets/js/foundation/foundation.interchange.js'); echo js('assets/js/foundation/foundation.topbar.js'); echo js('assets/js/vendor/kudos.js'); ?> <script> $(function() { $(document).foundation(); var kudos = $.ajax({url: "?kudos",async: false}); var parts = window.location.pathname.split('/'); uid = parts[parts.length-1] + parts[parts.length-2]; $(".num").html(kudos.responseText); $("figure.kudoable").kudoable(); if(localStorage.getItem(uid) == 'true') { $("figure.kudoable").addClass("complete"); }
<ul class="docs-index-list list-4"> <?php foreach ($page->children()->visible() as $item) { ?> <!-- --><li> <div class="text"> <h2 class="delta docs-icon"><a href="<?php echo $item->url(); ?> "><?php echo html($item->title()); ?> </a></h2> <?php echo kirbytext($item->description()); ?> </div> <a class="btn" href="<?php echo $item->url(); ?> ">Learn more</a> </li><!-- --><?php } ?> </ul> <?php } ?>
function kirbytextRaw($content) { $text = kirbytext($content); return preg_replace('/(.*)<\\/p>/', '$1', preg_replace('/<p>(.*)/', '$1', $text)); }
?> <div class="cheatsheet-grid"> <?php foreach ($child->children() as $doc) { ?> <div class="cheatsheet-grid-item"> <a href="<?php echo $doc->url(); ?> "> <h3 class="gamma"><?php echo html($doc->title()); ?> </h3> <?php echo kirbytext($doc->excerpt()); ?> </a> </div> <?php } ?> </div> </section> <?php } ?> </main>
* Converts html entities and specialchars in the field * value to valid xml entities * @param Field $field The calling Kirby Field instance * @return Field */ field::$methods['xml'] = field::$methods['x'] = function ($field) { $field->value = xml($field->value); return $field; }; /** * Parses the field value as kirbytext * @param Field $field The calling Kirby Field instance * @return Field */ field::$methods['kirbytext'] = field::$methods['kt'] = function ($field) { $field->value = kirbytext($field); return $field; }; /** * Parses the field value as markdown * @param Field $field The calling Kirby Field instance * @return Field */ field::$methods['markdown'] = field::$methods['md'] = function ($field) { $field->value = markdown($field->value); return $field; }; /** * Converts the field value to lower case * @param Field $field The calling Kirby Field instance * @return Field
<h2><?php echo $pages->about->title(); ?> </h2> <div class="content"> <?php foreach ($pages->about->images()->limit(1) as $key => $image) { ?> <div class="bio-image" style="background-image:url(<?php echo $image->url(); ?> );"> </div> <?php } ?> <div class="bio-text"> <?php echo kirbytext($pages->about->about()); ?> </div> </div>
<?php snippet('header'); ?> <main class="main grid" role="main"> <h1 class="alpha"><?php echo html($page->title()); ?> </h1> <section class="col-3-6 text"> <h2 class="beta">Responsibility</h2> <?php echo kirbytext($page->contact()); ?> </section> <section class="col-3-6 last text"> <h2 class="beta">Disclaimer</h2> <?php echo kirbytext($page->disclaimer()); ?> </section> </main> <?php snippet('footer');
<footer class="site-footer" role="contentinfo"> <?php echo kirbytext($site->info()); ?> </footer> </body> </html>
">Documentation</a></li> <?php if ($page->tutorial() != '') { ?> <li><a href="<?php echo url(); echo $page->tutorial(); ?> ">Tutorial</a></li> <?php } ?> </ul> <div class="text smaller"> <?php echo kirbytext($page->description()); ?> </div> <?php if ($page->author() != '') { ?> <small>Made by <a href="<?php echo $page->author_url(); ?> "><?php echo $page->author(); ?> </a><?php if ($page->twitter() != '') { ?> | <a href="http://twitter.com/<?php
<?php // use template name as twig template filename $template = $page->template() . '.' . c::get('twig.file.extension'); // pass data to twig template echo $twig->render($template, ['site' => $site, 'page' => ['title' => $page->title(), 'template' => $page->template(), 'text' => kirbytext($page->text())]]);
$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>'); } } return $figure; });
</video> <?php } ?> </section> <?php } ?> <section class="about"> <h2 class="site-description"><?php echo $site->description(); ?> </h2> <?php echo kirbytext($pages->find('/about-us')->text()); ?> </section> <section class="main"> <nav class="main-nav"> <div class="ctrl shutter" title="Open Thumb Menu"></div> <div class="ctrl left" title="Previous Image"><img src="/assets/images/arrow_rightleft.png" alt"left arrow"/></div> <div class="ctrl right" title="Next Image"><img src="/assets/images/arrow_rightleft.png" alt"right arrow"/></div> <div class="ctrl up" title="Previous Project"><!--<img src="/assets/images/arrow_updown.png" alt"up arrow"/>--></div> <div class="ctrl down" title="Next Project"><!--<img src="/assets/images/arrow_updown.png" alt"down arrow"/>--></div> </nav> <div class="main-frame"> </div> </section>
<?php /** * Table Plugin * based on Bastian Allgeier <*****@*****.**> Columns plugin. * * @author Julien Gargot <*****@*****.**> * @version 1.0.0 */ kirbytext::$pre[] = function ($kirbytext, $text) { $text = preg_replace_callback('!\\(table(…|\\.{3})\\)(.*?)\\((…|\\.{3})table\\)!is', function ($matches) use($kirbytext) { $rows = preg_split('!(\\n|\\r\\n)\\+{4}\\s+(\\n|\\r\\n)!', $matches[2]); $html = array(); foreach ($rows as $row) { $field = new Field($kirbytext->field->page, null, trim($row)); $columns = preg_split('!(\\n|\\r\\n)\\/{4}\\s+(\\n|\\r\\n)!', $field); $htmlColumns = array(); foreach ($columns as $column) { $field = new Field($kirbytext->field->page, null, trim($column)); $htmlColumns[] = '<td>' . kirbytext($field) . '</td>'; } $html[] = '<tr>' . implode($htmlColumns) . '</tr>'; } return '<table class="' . c::get('table.container', 'table') . '">' . implode($html) . '</table>'; }, $text); return $text; };
<?php echo kirbytext($text);
if ($page->citation() != "") { ?> <cite itemprop="author"><?php echo $page->citation(); ?> </cite> <?php } ?> <?php } else { ?> <?php $array_testamonials = $site->find('generic-testamonials')->testamonials()->yaml(); $array_key = array_rand($array_testamonials); $testamonial = kirbytext($array_testamonials[$array_key]['text']); $cite = $array_testamonials[$array_key]['cite']; ?> <blockquote itemprop="description"> <?php echo $testamonial; ?> </blockquote> <?php if ($cite != "") { ?> <cite itemprop="author"> <?php echo $cite; ?> </cite>
?> <a href="<?php echo getPanelURL($article, 'show'); ?> " class="edit"> <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> </a> <?php } ?> </div> </header> <div class="content"> <div class="text"> <?php echo kirbytext($article->text()); ?> </div> <div class="gallery"> <?php $filenames = $article->attachments()->split(','); if (count($filenames) < 2) { $filenames = array_pad($filenames, 2, ''); } $files = call_user_func_array(array($article->files(), 'find'), $filenames); foreach ($files as $image) { echo kirbytag(array('image' => $image->filename(), 'taille' => 'image grid', 'thumbwidth' => 1200, 'originalPage' => $article, 'alt' => $image->caption())); } ?> </div> </div>
<div class="bodytext"><?php echo kirbytext($data->who_text()); ?> </div> </div> <div class="about__foot"> <h3 class="about__ftitle"><?php echo l::get("want to participate"); ?> </h3><a href="#contact" class="button--ghost_main_active js-scrollTo"><?php echo l::get("contact us"); ?> </a> </div> </div> <div class="aboutlist__item about"> <div class="about__head"> <h2 class="about__title"><?php echo kirbytext($data->whom_title()); ?> </h2> </div> <div class="about__body"> <div class="bodytext"><?php echo kirbytext($data->whom_text()); ?> </div> </div> </div> </div> </section>
public function preview($pattern, $file) { $data = ['pattern' => $pattern, 'file' => $file]; if (get('raw') == 'true') { $this->raw($pattern, $file); } if ($file->filename() == $pattern->name() . '.html.php') { $views = ['preview', 'html', 'php']; $snippet = 'html'; // pass the mode to the template $data['view'] = in_array(get('view'), $views) ? get('view') : $this->kirby->option('patterns.preview.mode', 'preview'); switch ($data['view']) { case 'preview': try { $pattern->render(); $data['content'] = '<iframe src="' . $pattern->url() . '/preview"></iframe>'; } catch (Exception $e) { $data['content'] = $this->error($e); } break; case 'php': $data['content'] = $this->codeblock($file); break; case 'html': $data['content'] = $this->codeblock($pattern); break; } } else { if (in_array(strtolower($file->extension()), ['gif', 'jpg', 'jpeg', 'svg', 'png'])) { $snippet = 'image'; } else { if (in_array(strtolower($file->extension()), ['md', 'mdown'])) { $snippet = 'markdown'; $data['content'] = kirbytext($file->read()); } else { $ext = $file->extension(); $code = ['php', 'html', 'js', 'css', 'scss', 'less', 'json', 'txt']; if (in_array($ext, $code)) { $snippet = 'code'; $data['content'] = $this->codeblock($file); } else { $snippet = 'empty'; } } } } return $this->view('previews/' . $snippet, $data); }
function excerpt($text, $length = 140) { return str::excerpt(kirbytext($text), $length); }
<item> <title><?php echo xml($item->title()); ?> </title> <link><?php echo xml($item->url()); ?> </link> <pubDate><?php echo xml(strftime('%a, %d %b %Y %R %Z', $item->date())); ?> </pubDate> <description><![CDATA[<?php echo kirbytext($item->text()); ?> ]]></description> <itunes:author><?php echo xml($author); ?> </itunes:author> <itunes:subtitle><?php echo xml($subtitle); ?> </itunes:subtitle> <itunes:summary><?php echo xml($summary); ?> </itunes:summary>
* @version 0.2 Optional custom class */ kirbytext::$tags['blockquote'] = array('attr' => array('class', 'language', 'attribution', 'link'), 'html' => function ($tag) { $quote = $tag->attr('blockquote'); $class = $tag->attr('class', 'blockquote'); $language = $tag->attr('language'); $attribution = $tag->attr('attribution'); $link = $tag->attr('link'); // Start blockquote with the optional language attribute $buffer = '<blockquote class="' . $class . '"'; if ($language) { $buffer .= ' lang="' . $language . '"'; } $buffer .= '>' . "\n"; // The quote itself $buffer .= '<div class="' . $class . '__quote">' . kirbytext($quote) . '</div>' . "\n"; // When attribution or link is available, place it as a cite in the blockquote footer if ($attribution or $link) { $buffer .= '<footer class="' . $class . '__footer">' . "\n" . '<cite class="' . $class . '__attribution">'; if ($attribution and $link) { $buffer .= '<a class="' . $class . '__link" href="' . $link . '">' . $attribution . '</a>'; } elseif ($attribution) { $buffer .= $attribution; } elseif ($link) { $buffer .= '<a class="' . $class . '__link" href="' . $link . '">' . $link . '</a>'; } $buffer .= '</cite>' . "\n" . '</footer>' . "\n"; } // End blockquote $buffer .= '</blockquote>' . "\n"; // Output buffer
<?php if (!isset($_GET['ajax'])) { snippet('_header'); } ?> <section class="cover"> <?php echo kirbytext($page->text()); ?> </section> <?php if (!isset($_GET['ajax'])) { snippet('_footer'); }
* @version 0.2 Optional custom class */ kirbytext::$tags['blockquote'] = array('attr' => array('class', 'language', 'attribution', 'link'), 'html' => function ($tag) { $quote = $tag->attr('blockquote'); $class = $tag->attr('class', 'blockquote'); $language = $tag->attr('language'); $attribution = $tag->attr('attribution'); $link = $tag->attr('link'); // Start blockquote with the optional language attribute $buffer = '<blockquote class="' . $class . '"'; if ($language) { $buffer .= ' lang="' . $language . '"'; } $buffer .= '>' . "\n"; // The quote itself $buffer .= kirbytext($quote) . "\n"; // When attribution or link is available, place it as a cite in the blockquote footer if ($attribution or $link) { $buffer .= '<cite class="' . $class . '__attribution">'; if ($attribution and $link) { $buffer .= '<a class="' . $class . '__link" href="' . $link . '">' . $attribution . '</a>'; } elseif ($attribution) { $buffer .= $attribution; } elseif ($link) { $buffer .= '<a class="' . $class . '__link" href="' . $link . '">' . $link . '</a>'; } $buffer .= '</cite>'; } // End blockquote $buffer .= '</blockquote>' . "\n"; // Output buffer