Shortens an URL
It removes http:// or https:// and uses str::short afterwards
static public short ( string $url, integer $chars = false, boolean $base = false, string $rep = '…' ) : string | ||
$url | string | The URL to be shortened |
$chars | integer | The final number of characters the URL should have |
$base | boolean | True: only take the base of the URL. |
$rep | string | The element, which should be added if the string is too long. Ellipsis is the default. |
return | string | The shortened URL |
public function __construct($mention) { $this->mention = $mention; $this->data = $mention->data['author']; $this->page = $mention->page; if (empty($this->data['url'])) { $this->data['url'] = $this->mention->data['url']; } if (empty($this->data['name'])) { $this->data['name'] = url::short(url::base($this->data['url'])); } $this->field('url'); $this->field('name'); }
/** * Shortens an URL * It removes http:// or https:// and uses str::short afterwards * * @param string $url The URL to be shortened * @param int $chars The final number of characters the URL should have * @param boolean $base True: only take the base of the URL. * @param string $rep The element, which should be added if the string is too long. Ellipsis is the default. * @return string The shortened URL */ static function shorturl($url, $chars = false, $base = false, $rep = '…') { return url::short($url, $chars, $base, $rep); }
?> <div class="screen-refl"><a class="btn-white" href="<?php echo $reference->link(); ?> ">visit</a></div> </div> <a href="<?php echo $reference->link(); ?> "> <h2 class="gamma truncate"><?php echo html($reference->title()); ?> </h2> <p><?php echo url::short($reference->link()); ?> </p> </a> </li><!-- --><?php } ?> </ul> <?php $pagination = $references->pagination(); ?> <?php if ($references->pagination()->hasPages()) { ?>
<div class="dashboard-box"> <a class="dashboard-item" target="_blank" href="<?php echo url(); ?> "> <figure> <span class="dashboard-item-icon dashboard-item-icon-with-border"><i class="fa fa-chain"></i></span> <figcaption class="dashboard-item-text"><?php e(url::isAbsolute(url()), url::short(url()), url()); ?> </figcaption> </figure> </a> </div>
?> "><?php _l('dashboard.index.site.title'); ?> </a> </span> </h2> <div class="field field-is-readonly"> <div class="field-content"> <div class="input input-is-readonly"> <a target="_blank" href="<?php echo url(); ?> "><?php echo url::short(url()); ?> </a> </div> <div class="field-icon"> <i class="icon fa fa-chain"></i> </div> </div> </div> </div> <div class="section white dashboard-section"> <h2 class="hgroup hgroup-single-line cf"> <span class="hgroup-title">
} return $figure; } else { $class = trim($tag->attr('class') . ' ' . $tag->attr('imgclass')); return $_link($_image($class)); } }); // link tag kirbytext::$tags['link'] = array('attr' => array('text', 'class', 'title', 'rel', 'lang', 'target', 'popup'), 'html' => function ($tag) { $link = url($tag->attr('link'), $tag->attr('lang')); $text = $tag->attr('text'); if (empty($text)) { $text = $link; } if (str::isURL($text)) { $text = url::short($text); } return html::a($link, $text, array('rel' => $tag->attr('rel'), 'class' => $tag->attr('class'), 'title' => $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'); } return html::a('tel:' . $tel, html($text), array('rel' => $tag->attr('rel'), 'class' => $tag->attr('class'), 'title' => html($tag->attr('title')))); }); // twitter tag kirbytext::$tags['twitter'] = array('attr' => array('class', 'title', 'text', 'rel', 'target', 'popup'), 'html' => function ($tag) { // get and sanitize the username