本文整理汇总了PHP中HTML::macro方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML::macro方法的具体用法?PHP HTML::macro怎么用?PHP HTML::macro使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTML
的用法示例。
在下文中一共展示了HTML::macro方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
\HTML::macro('activeClass', function ($path, $active = 'active') {
if (Request::is($path . "*")) {
return $active;
}
return '';
});
\Validator::resolver(function ($translator, $data, $rules, $messages) {
return new CustomValidator($translator, $data, $rules, $messages);
});
\Blade::extend(function ($value) {
return preg_replace('/\\@define(.+)/', '<?php ${1}; ?>', $value);
});
}
示例2: function
<?php
/**
* Created by PhpStorm.
* User: alex
* Date: 9/25/14
* Time: 2:59 PM
*/
Form::macro("check", function ($name, $value = 1, $checked = null, $options = array()) {
return Form::hidden($name, 0) . Form::checkbox($name, $value, $checked, $options);
});
Form::macro('errors', function ($errors, $field = false) {
if ($errors->any()) {
if ($field && !$errors->has($field)) {
return null;
}
return View::make('partials.errors_form', ['errors' => $errors, 'field' => $field]);
}
return null;
});
HTML::macro('gravatar', function ($email, $size = 32, $default = 'mm') {
return '<img src="http://www.gravatar.com/avatar/' . md5(strtolower(trim($email))) . '?s=' . $size . '&d=' . $default . '" alt="Avatar">';
});
示例3: function
<?php
HTML::macro('discussion', function ($discussion, $article_id, $level) {
$result = '<div class="discussion-main col-xs-12 ' . ($level < 5 ? 'commentary-new-level' : 'x') . '">
<div class="discussion-commentary row">
<div class="col-xs-3">' . HTML::profilePicture($discussion->user, '100%', '100%', ['class' => 'discussion-profile col-xs-3']) . '</div>
<div class="col-xs-9 discussion-right">
<span class="discussion-author-info">' . link_to_action('UserController@getProfile', $discussion->user->fullname, ['user_id' => $discussion->user->slug]) . ' <a class="discussion-date"> ' . $discussion->created_at . ' </a></span>
<p>' . $discussion->text . '</p>
</div>';
if (Auth::check()) {
$result .= '<div class="col-xs-12 discussion-bottom">
<span class="reply-link pull-right">
<a onclick="resizeArea(' . $discussion->id . ')" name="reply">Odpovedať</a>';
if (Auth::user()->hasRole(\App\Models\User::ADMIN_ROLE) || Auth::user()->hasRole(\App\Models\User::TEACHER_ROLE)) {
$result .= '<br> <a href="' . action('DiscussionController@getDelete', ['id' => $discussion->id]) . '" style="color:red">Zmazať nevhodný komentár</a>';
}
$result .= '</span>' . Form::open(['url' => action('DiscussionController@postAddDiscussion'), 'method' => 'post']) . Form::hidden('parent', $discussion->id) . Form::hidden('article_id', $article_id) . '<textarea id="' . $discussion->id . '" class="reply" style="" name="text"></textarea><br>' . Form::submit('Odoslať', ['class' => 'btn btn-ba-style hidden-btn ' . $discussion->id, 'name' => 'action']) . Form::close() . '</div>';
}
$children = \App\Models\Discussion::where('parent', '=', $discussion->id)->orderBy('created_at', 'ASC')->get();
foreach ($children as $child) {
$result .= HTML::discussion($child, $article_id, $level + 1);
}
$result .= '</div>
</div>';
return $result;
});
示例4: function
@extends('header')
@section('title')Ver Cliente @stop
@section('head')
<script src="{{asset('vendor/browser/browser.js')}}" type="text/javascript"></script>
<script src="{{asset('vendor/print/printElement.js')}}" type="text/javascript"></script>
@stop
@section('encabezado') CLIENTES @stop
@section('encabezado_descripcion') Ver Cliente @stop
@section('nivel') <li><a href="{{URL::to('clientes')}}"><i class="ion-person-stalker"></i> Clientes</a></li>
<li class="active">Ver </li> @stop
@section('content')
<?php
HTML::macro('tab_link', function ($url, $text, $active = false) {
$class = $active ? ' class="active"' : '';
return '<li' . $class . '><a href="' . URL::to($url) . '" data-toggle="tab">' . $text . '</a></li>';
});
?>
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">Nombre de Cliente: {{ $client->name }}</h3>
<div class="box-tools pull-right">
<a href="{{ url('factura/new/'.$client->id) }}" class="btn btn-success btn-sm btn-block">Facturar <span class="
glyphicon glyphicon-file"> </span></a>
<!-- Buttons, labels, and many other things can be placed here! -->
<!-- Here is a label for example -->
示例5: function
HTML::macro('profileGrid', function ($profiles) {
$_user = [];
foreach ($profiles as $profile) {
$_user[] = HTML::profilePicture($profile, 125, 125, ['class' => 'img-circle']) . '<h3>' . $profile->fullname . '</h3>';
}
$count = count($_user);
for ($i = 0; $i < $count; $i++) {
if ($count % 3 == 0) {
$_user[$i] = '<div class="col-md-4">' . $_user[$i] . '</div>';
continue;
}
if ($i >= $count - $count % 3) {
if ($count % 3 == 1) {
$_user[$i] = '<div class="col-md-12">' . $_user[$i] . '</div>';
} else {
if ($i % 3 == 0) {
$_user[$i] = '<div class="col-md-offset-2 col-md-4">' . $_user[$i] . '</div>';
} else {
$_user[$i] = '<div class="col-md-4">' . $_user[$i] . '</div>';
}
}
} else {
$_user[$i] = '<div class="col-md-4">' . $_user[$i] . '</div>';
}
}
$result = '<div class="row">';
$result .= implode('</div><div class="row">', array_map(function ($i) {
return implode("", $i);
}, array_chunk($_user, 3)));
$result = $result . '</div>';
return $result;
});
示例6: function
<?php
HTML::macro('flash_message', function () {
$alerts = array();
$alert_types = array('error', 'success', 'warning', 'info');
foreach ($alert_types as $type) {
if (Session::has($type)) {
array_push($alerts, '<div class="flash flash-' . $type . '">');
array_push($alerts, Session::get($type));
array_push($alerts, '</div>');
}
}
return implode("", $alerts);
});
示例7: function
<?php
HTML::macro('tags', function ($article) {
$collection = collect(array_flatten($article->tags()->get(['name'])->toArray()))->map(function ($tag) {
return '<span class="tag label label-info"><a href="' . url('/?search=' . $tag) . '">' . $tag . '</a></span>';
})->all();
$result = implode(' ', $collection);
if ($result != '') {
$result = '<span class="article-info" style="display: inline-block">' . $result . '</span><br>';
}
return $result;
});
示例8: tag_open
function tag_open($tag)
{
HTML::macro($tag, function ($attributes = null) use($tag) {
return HTML::tag_open($tag, $attributes);
});
}
示例9: explode
$active = '';
}
/*
$link = explode('/', Request::path());
if ($link[count($link)-2].'/'.$link[count($link)-1] == $route)
$active = "class = 'active'";
else
$active = '';
*/
return '<li ' . $active . '><a href="' . url('admin/' . $route) . '">' . $text . '</a></li>';
});
/* Menu items macro in frontend */
HTML::macro('menu_items_by_type', function ($type) {
$result = "";
foreach (MenuItem::getActiveMenus($type) as $menu) {
$result .= "<li><a href='" . url($menu->url) . "'>" . $menu->title . "</a></li>";
}
return $result;
});
//Testing
Route::get('test', function () {
//echo AppConfig::getData('order', 'na');
print_r(AppConfig::getStatusList('article'));
});
Route::get('force_login', function () {
Auth::loginUsingId(4);
return 'OK!';
});
Route::get('setpass', function () {
$user = User::find(2);
$user->password = Hash::make('hehehe');
示例10: function
if (isset($classes) && !empty($classes)) {
$listElement .= ' class="' . $classes . ' collapse in">';
} else {
$listElement .= ' class="collapse in">';
}
} else {
if (isset($classes) && !empty($classes)) {
$listElement .= ' class="' . $classes . ' collapse" >';
} else {
$listElement .= ' class="collapse">';
}
}
return HTML::decode($listElement);
});
HTML::macro('activeSubMenuDropClose', function () {
return '</ul>';
});
/**
* -----------------------------------------------------------------------------
* Form macros
* -----------------------------------------------------------------------------
*
* Saját form függvények definiálása.
*
*/
Form::macro('selection', function ($name, $options, $attr = NULL, $selected = NULL) {
$select = '<select ';
$select .= 'id="' . $name . '" ';
$select .= 'name="' . $name . '" ';
foreach ($attr as $key => $value) {
$select .= $key . '="' . $value . '" ';
示例11: function
HTML::macro('breadcrumbs', function () {
$str = '<ol class="breadcrumb">';
// Get the breadcrumbs by exploding the current path.
$basePath = Utils::basePath();
$parts = explode('?', $_SERVER['REQUEST_URI']);
$path = $parts[0];
if ($basePath != '/') {
$path = str_replace($basePath, '', $path);
}
$crumbs = explode('/', $path);
foreach ($crumbs as $key => $val) {
if (is_numeric($val)) {
unset($crumbs[$key]);
}
}
$crumbs = array_values($crumbs);
for ($i = 0; $i < count($crumbs); $i++) {
$crumb = trim($crumbs[$i]);
if (!$crumb) {
continue;
}
if ($crumb == 'company') {
return '';
}
$name = trans("texts.{$crumb}");
if ($i == count($crumbs) - 1) {
$str .= "<li class='active'>{$name}</li>";
} else {
$str .= '<li>' . link_to($crumb, $name) . '</li>';
}
}
return $str . '</ol>';
});
示例12: define
define('DEFAULT_LOCALE', 'es');
define('IPX_ACCOUNT_KEY', 'nGN0MGAljj16ANu5EE7x7VwoDJEg3Gxu');
//usado para el registro de la cuenta al momento de la creacion
define('RANDOM_KEY_LENGTH', 32);
define('RECENTLY_VIEWED', 'RECENTLY_VIEWED');
define('PAYMENT_TYPE_CREDIT', 2);
define('INVOICE_STATUS_DRAFT', 1);
define('INVOICE_STATUS_SENT', 2);
define('INVOICE_STATUS_VIEWED', 3);
define('INVOICE_STATUS_PARTIAL', 4);
define('INVOICE_STATUS_PAID', 5);
// tal vez se pueda utilizar algo de este codigo pero no confio hay que ver XD
// Validator::extend('positive', function($attribute, $value, $parameters)
// {
// $value = preg_replace('/[^0-9\.\-]/', '', $value);
// return floatval($value) > 0;
// });
// Validator::extend('has_credit', function($attribute, $value, $parameters)
// {
// $publicClientId = $parameters[0];
// $amount = $parameters[1];
// $client = Client::scope($publicClientId)->firstOrFail();
// $getTotalCredit = Credit::where('client_id','=',$client->id)->sum('balance');
// return $getTotalCredit >= $amount;
// });
HTML::macro('image_data', function ($imagePath) {
return 'data:image/jpeg;base64,' . base64_encode(file_get_contents(public_path() . '/' . $imagePath));
});
Validator::extend('less_than', function ($attribute, $value, $parameters) {
return floatval($value) <= floatval($parameters[0]);
});
示例13: function
<?php
HTML::macro('tabItem', function ($url, $caption, $icon, $colorStyle, $aClass = '') {
$actualUrl = Request::url();
return '<a class="tab-item ' . $colorStyle . ' ' . ($url == $actualUrl ? 'tab-item-active' : '') . ' ' . $aClass . '" ' . ($caption == 'Viac' ? '' : 'href="' . $url . '"') . '>
<i class="icon ' . $icon . ' ' . $aClass . '"></i>
<span class="tab-title">' . $caption . '</span>
</a>';
});
示例14: implode
return implode(' ', $tag_lists);
});
HTML::macro('show_users', function ($users) {
$user_lists = [];
foreach ($users as $user) {
$image = HTML::gravator($user["email"], 20);
$username = $user['username'];
$user_page_url = route('user.profile', compact('username'));
$user_lists[] = $image . ' <a href="' . $user_page_url . '">' . e($username) . '</a>';
}
return implode(' ', $user_lists);
});
HTML::macro('markdown', function ($str) {
$parser = new Owl\Libraries\CustomMarkdown();
$parser->enableNewlines = true;
return $parser->parse($str);
});
HTML::macro('diff', function ($from, $to) {
$from = mb_convert_encoding($from, 'HTML-ENTITIES', 'UTF-8');
$to = mb_convert_encoding($to, 'HTML-ENTITIES', 'UTF-8');
$granularity = new cogpowered\FineDiff\Granularity\Word();
$diff = new cogpowered\FineDiff\Diff($granularity);
$result = htmlspecialchars_decode($diff->render($from, $to));
return nl2br($result);
});
HTML::macro('date_replace', function ($str) {
$str = str_replace("%{Year}", date('Y'), $str);
$str = str_replace("%{month}", date('m'), $str);
$str = str_replace("%{day}", date('d'), $str);
return $str;
});
示例15: function
<?php
HTML::macro('tr', function ($status) {
switch ($status) {
case 'pending':
$build = "<tr class = 'warning'>";
break;
case 'taken':
$build = "<tr class = 'success'>";
break;
case 'rejected':
$build = "<tr class = 'danger'>";
break;
}
return $build;
});
//Specials buttons
/*
Ej: {{HTML::create_button($name,$url,$class)}}
{{HTML::create_button('admin','admins.create')}}
*/
HTML::macro('create_button', function ($object, $url = "null", $class = "btn-primary") {
if ($url == 'null') {
$url = $object . 's.create';
}
$build = '<a class="btn ' . $class . '" href="' . URL::route($url) . '">
<i class="fa fa-plus"></i> Crear ' . $object . '
</a>';
return $build;
});