本文整理汇总了PHP中Converter::url方法的典型用法代码示例。如果您正苦于以下问题:PHP Converter::url方法的具体用法?PHP Converter::url怎么用?PHP Converter::url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Converter
的用法示例。
在下文中一共展示了Converter::url方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
protected static function create($array, $indent = "", $FP = "", $i = 0)
{
$c_url = Config::get('url');
$c_url_current = Config::get('url_current');
$c_element = self::$config;
$c_class = $c_element['classes'];
$html = $indent . str_repeat(TAB, $i) . '<' . $c_element[$i === 0 ? 'trunk' : 'branch'] . ($i === 0 ? $c_class['trunk'] !== false ? ' class="' . $c_class['trunk'] . '"' : "" : ($c_class['branch'] !== false ? ' class="' . sprintf($c_class['branch'], $i / 2) . '"' : "")) . '>' . NL;
foreach ($array as $key => $value) {
if (!is_array($value)) {
$url = Converter::url($value);
$hole = $value === "" ? ' ' . $c_class['chink'] : "";
$current = $url === $c_url_current || $url !== $c_url && strpos($c_url_current . '/', $url . '/') === 0 ? ' ' . $c_class['current'] : "";
$c = trim(($c_class['twig'] !== false ? $c_class['twig'] : "") . $hole . $current);
$twig = '<' . $c_element['twig'] . ($c ? ' class="' . $c . '"' : "") . '>';
if ($value !== "") {
// List item without link: `array('foo')`
if (is_int($key)) {
$twig .= Filter::colon($FP . 'anchor', '<span class="a">' . $value . '</span>');
// List item without link: `array('foo' => null)`
} else {
if (is_null($value)) {
$twig .= Filter::colon($FP . 'anchor', '<span class="a">' . $key . '</span>');
// List item with link: `array('foo' => '/')`
} else {
$url = Filter::colon($FP . 'url', $url);
$twig .= Filter::colon($FP . 'anchor', '<a href="' . $url . '">' . $key . '</a>');
}
}
}
$s = explode(' ', $c_element['twig']);
$s = $s[0];
$html .= $indent . str_repeat(TAB, $i + 1) . Filter::colon($FP . 'twig', $twig . '</' . $s . '>', $i + 1) . NL;
} else {
// `text (path/to/url)`
if (preg_match('#^\\s*(.*?)\\s*\\((.*?)\\)\\s*$#', $key, $match)) {
$_key = $match[1];
$_value = trim($match[2]) !== "" ? Converter::url($match[2]) : '#';
} else {
$_key = $key;
$_value = null;
}
$url = Filter::colon($FP . 'url', $_value);
$s = explode(' ', $c_element['branch']);
$s = ' ' . $s[0];
$current = $url === $c_url_current || $url !== $c_url && strpos($c_url_current . '/', $url . '/') === 0 ? ' ' . $c_class['current'] : "";
$c = trim(($c_class['twig'] !== false ? $c_class['twig'] : "") . $current . $s);
$twig = '<' . $c_element['twig'] . ($c ? ' class="' . $c . '"' : "") . '>';
$twig .= NL . $indent . str_repeat(TAB, $i + 2);
$twig .= Filter::colon($FP . 'anchor', $_value !== null ? '<a href="' . $url . '">' . $_key . '</a>' : '<span class="a">' . $_key . '</span>');
$twig .= NL . self::create($value, $indent, $FP, $i + 2);
$twig .= $indent . str_repeat(TAB, $i + 1);
$s = explode(' ', $c_element['twig']);
$s = $s[0];
$html .= $indent . str_repeat(TAB, $i + 1) . Filter::colon($FP . 'twig', $twig . '</' . $s . '>', $i + 1) . NL;
}
}
$s = explode(' ', $c_element[$i === 0 ? 'trunk' : 'branch']);
$s = $s[0];
return Filter::colon($FP . 'branch', rtrim($html, NL) . (!empty($array) ? NL . $indent . str_repeat(TAB, $i) : "") . '</' . $s . '>', $i) . NL;
}
示例2: manager
/**
* Widget Manager
* --------------
*
* [1]. Widget::manager('MENU');
* [2]. Widget::manager('BAR');
*
*/
public static function manager($type = 'MENU')
{
if (!Guardian::happy()) {
return "";
}
$T1 = TAB;
if ($type === 'MENU') {
$menus = array();
if ($_menus = Mecha::A(Config::get('manager_menu'))) {
$_menus = Mecha::eat($_menus)->order('ASC', 'stack', true, 10)->vomit();
foreach ($_menus as $k => $v) {
// < 1.1.3
if (is_string($v)) {
$menus[$k] = $v;
} else {
$stack = isset($v['stack']) ? $v['stack'] : 10;
$_k = (strpos($v['icon'], '<') === false ? '<i class="fa fa-fw fa-' . $v['icon'] . '"></i>' : $v['icon']) . ' <span class="label">' . $k . '</span>' . (isset($v['count']) && ($v['count'] === '∞' || (double) $v['count'] > 0) ? ' <span class="counter">' . $v['count'] . '</span>' : "");
$menus[$_k] = isset($v['url']) ? $v['url'] : null;
}
}
}
$html = O_BEGIN . '<div class="widget widget-manager widget-manager-menu" id="widget-manager-menu-' . self::$id['manager_menu'] . '">' . NL;
self::$id['manager_menu']++;
$html .= Menu::get($menus, 'ul', $T1, 'manager:');
$html .= '</div>' . O_END;
$html = Filter::apply('widget', $html);
return Filter::apply('widget:manager.menu', Filter::apply('widget:manager', $html));
}
if ($type === 'BAR') {
$html = O_BEGIN . '<div class="widget widget-manager widget-manager-bar" id="widget-manager-bar-' . self::$id['manager_bar'] . '">' . NL;
self::$id['manager_bar']++;
$bars = array();
if ($_bars = Mecha::A(Config::get('manager_bar'))) {
$_bars = Mecha::eat($_bars)->order('ASC', 'stack', true, 10)->vomit();
foreach ($_bars as $k => $v) {
if (is_string($v)) {
$bar = $v;
} else {
$t = ' data-tooltip="' . Text::parse(isset($v['description']) ? $v['description'] : $k, '->encoded_html') . '"';
$bar = isset($v['url']) ? '<a class="item" href="' . Converter::url($v['url']) . '"' . $t . '>' : '<span class="item a"' . $t . '>';
$bar .= isset($v['icon']) ? strpos($v['icon'], '<') === false ? Jot::icon($v['icon']) : $v['icon'] : $k;
$bar .= ' <span class="label">' . $k . '</span>';
if (isset($v['count']) && ($v['count'] === '∞' || (double) $v['count'] > 0)) {
$bar .= ' <span class="counter">' . $v['count'] . '</span>';
}
$bar .= isset($v['url']) ? '</a>' : '</span>';
}
$bars[] = Filter::apply('manager:bar.item', $bar);
}
}
$html .= $T1 . Filter::apply('manager:bar', implode(' ', $bars)) . NL;
$html .= '</div>';
return Filter::apply('widget:manager.bar', Filter::apply('widget:manager', $html));
}
}
示例3: create
public static function create($array, $type = 'ul', $depth = "", $FP = "", $i = 0)
{
$c_url = Config::get('url');
$c_url_current = Config::get('url_current');
$c_class = self::$config['classes'];
$html = $depth . str_repeat(TAB, $i) . '<' . $type . ($i > 0 ? $c_class['children'] !== false ? ' class="' . sprintf($c_class['children'], $i / 2) . '"' : "" : ($c_class['parent'] !== false ? ' class="' . $c_class['parent'] . '"' : "")) . '>' . NL;
foreach ($array as $key => $value) {
if (!is_array($value)) {
// List item separator: `array('|')`
if ($key === '|' || is_int($key) && $value === '|') {
$html .= Filter::apply($FP . 'list.item.separator', Filter::apply($FP . 'list.item', $depth . str_repeat(TAB, $i + 1) . '<li class="' . $c_class['separator'] . '"></li>' . NL, $i + 1), $i + 1);
// List item without link: `array('foo')`
} else {
if (is_int($key)) {
$html .= Filter::apply($FP . 'list.item', $depth . str_repeat(TAB, $i + 1) . '<li><span class="a">' . $value . '</span></li>' . NL, $i + 1);
// List item without link: `array('foo' => null)`
} else {
if (is_null($value)) {
$html .= Filter::apply($FP . 'list.item', $depth . str_repeat(TAB, $i + 1) . '<li><span class="a">' . $key . '</span></li>' . NL, $i + 1);
// List item with link: `array('foo' => '/')`
} else {
$value = Converter::url($value);
$html .= Filter::apply($FP . 'list.item', $depth . str_repeat(TAB, $i + 1) . '<li' . ($value === $c_url_current || $value !== $c_url && strpos($c_url_current . '/', $value . '/') === 0 ? ' class="' . $c_class['selected'] . '"' : "") . '><a href="' . $value . '">' . $key . '</a></li>' . NL, $i + 1);
}
}
}
} else {
if (preg_match('#(.*?)\\s*\\((.*?)\\)\\s*$#', $key, $matches)) {
$_key = $matches[1];
$_value = Converter::url($matches[2]);
} else {
$_key = $key;
$_value = '#';
}
$html .= Filter::apply($FP . 'list.item', $depth . str_repeat(TAB, $i + 1) . '<li' . ($_value === $c_url_current || $_value !== $c_url && strpos($c_url_current . '/', $_value . '/') === 0 ? ' class="' . $c_class['selected'] . '"' : "") . '>' . NL . str_repeat(TAB, $i + 2) . '<a href="' . $_value . '">' . $_key . '</a>' . NL . self::create($value, $type, $depth, $FP, $i + 2) . $depth . str_repeat(TAB, $i + 1) . '</li>' . NL, $i + 1);
}
}
return Filter::apply($FP . 'list', rtrim($html, NL) . (!empty($array) ? NL . $depth . str_repeat(TAB, $i) : "") . '</' . $type . '>' . NL, $i);
}
示例4: array
}
}
Menu::add('manager', $menus);
$html .= Menu::manager('ul', $T1);
}
if ($type === 'BAR') {
$bars = array();
if ($_bars = Mecha::A(Config::get('manager_bar'))) {
$_bars = Mecha::eat($_bars)->order('ASC', 'stack', true, 10)->vomit();
foreach ($_bars as $k => $v) {
if (is_string($v)) {
$bar = $v;
} else {
$t = ' data-tooltip="' . Text::parse(isset($v['description']) ? $v['description'] : $k, '->encoded_html') . '"';
if (isset($v['url'])) {
$url = Filter::colon('manager:url', Converter::url($v['url']));
$c = $config->url_current === $url ? ' ' . Widget::$config['classes']['current'] : "";
$bar = '<a class="item' . $c . '" href="' . $url . '"' . $t . '>';
} else {
$bar = '<span class="item a"' . $t . '>';
}
$bar .= isset($v['icon']) ? strpos($v['icon'], '<') === false ? Jot::icon($v['icon']) : $v['icon'] : $k;
$bar .= ' <span class="label">' . $k . '</span>';
if (isset($v['count']) && ($v['count'] === '∞' || (double) $v['count'] > 0)) {
$bar .= ' <span class="counter">' . $v['count'] . '</span>';
}
$bar .= isset($v['url']) ? '</a>' : '</span>';
}
$bars[] = $bar;
}
}
示例5: kick
/**
* ============================================================
* URL REDIRECTION
* ============================================================
*
* -- CODE: ---------------------------------------------------
*
* Guardian::kick('manager/login');
*
* ------------------------------------------------------------
*
*/
public static function kick($path = "")
{
$path = Converter::url(File::url($path));
$path = Filter::apply('guardian:kick', $path);
$G = array('data' => array('url' => $path));
Session::set('url_origin', Config::get('url_current'));
Weapon::fire('before_kick', array($G, $G));
header('Location: ' . $path);
exit;
}
示例6: function
// `<script>`
Cell::add('script', function ($attr = array(), $content = "", $indent = 0) {
if (is_string($attr)) {
$attr = array('src' => Converter::url($attr));
}
return Cell::unit('script', $content, $attr, $indent);
});
// `<a>`
Cell::add('a', function ($href = null, $content = "", $target = null, $attr = array(), $indent = 0) {
$attr['href'] = Converter::url($href);
$attr['target'] = $target === true ? '_blank' : $target;
return Cell::unit('a', $content, $attr, $indent);
});
// `<img>`
Cell::add('img', function ($src = null, $alt = null, $attr = array(), $indent = 0) {
$attr['src'] = Converter::url($src);
$attr['alt'] = Cell::protect($alt);
return Cell::unit('img', false, $attr, $indent);
});
// `<(ol|ul)>`
foreach (array('ol', 'ul') as $unit) {
Cell::add($unit, function ($list = array(), $attr = array(), $indent = 0) use($unit) {
$html = Cell::begin($unit, $attr, $indent) . NL;
foreach ($list as $k => $v) {
if (is_array($v)) {
$html .= Cell::begin('li', array(), $indent + 1) . $k . NL;
$html .= call_user_func('Cell::' . $unit, $v, $attr, $indent + 2) . NL;
$html .= Cell::end('li', $indent + 1) . NL;
} else {
$html .= Cell::unit('li', $v, array(), $indent + 1) . NL;
}
示例7: array
if (!isset($attr['class'])) {
$attr['class'] = array();
}
$attr['class'] = array_merge(array('text-' . $kind), (array) $attr['class']);
return Cell::unit('a', $text, $attr, $indent);
});
// File uploader
Jot::add('uploader', function ($action, $accept = null, $fields = array()) {
$speak = Config::speak();
$html = Cell::begin('form', array('class' => array('form-ignite', 'form-upload'), 'action' => Converter::url($action), 'method' => 'post', 'enctype' => 'multipart/form-data')) . NL;
$html .= Form::hidden('token', Guardian::token(), array(), 1) . NL;
foreach ($fields as $name => $value) {
$html .= Form::hidden($name, $value, array(), 1) . NL;
}
$html .= Cell::begin('span', array('class' => array('input-outer', 'btn', 'btn-default')), 1) . NL;
$html .= Cell::unit('span', Jot::icon('folder-open') . ' ' . $speak->manager->placeholder_file, array(), 2) . NL;
$html .= Form::file('file', array('title' => $speak->manager->placeholder_file, 'data' => array('icon-ready' => 'fa fa-check', 'icon-error' => 'fa fa-times', 'accepted-extensions' => $accept)), 2) . NL;
$html .= Cell::end() . ' ' . Jot::button('action:cloud-upload', $speak->upload) . NL;
$html .= Cell::end();
return $html;
});
// File finder
Jot::add('finder', function ($action, $name = 'q', $fields = array()) {
$html = Cell::begin('form', array('class' => 'form-ignite form-find', 'action' => Converter::url($action), 'method' => 'get')) . NL;
foreach ($fields as $key => $value) {
$html .= Form::hidden($key, $value) . NL;
}
$html .= Form::text($name, Request::get($name, null), null, array(), 1) . ' ' . Jot::button('action:search', Config::speak('find')) . NL;
$html .= Cell::end();
return $html;
});