Esempio n. 1
0
 /**
  * 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);
     });
 }
Esempio n. 2
0
<?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">';
});
Esempio n. 3
0
<?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;
});
Esempio n. 4
0
@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 &nbsp;<span class="
glyphicon glyphicon-file">  </span></a>
      
      <!-- Buttons, labels, and many other things can be placed here! -->
      <!-- Here is a label for example -->
Esempio n. 5
0
<?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);
});
Esempio n. 6
0
<?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;
});
Esempio n. 7
0
function tag_open($tag)
{
    HTML::macro($tag, function ($attributes = null) use($tag) {
        return HTML::tag_open($tag, $attributes);
    });
}
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;
});
Esempio n. 9
0
        $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');
Esempio n. 10
0
        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 . '" ';
Esempio n. 11
0
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>';
});
Esempio n. 12
0
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]);
});
Esempio n. 13
0
<?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>';
});
Esempio n. 14
0
    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;
});
Esempio n. 15
0
<?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;
});
Esempio n. 16
0
<?php

HTML::macro('glyph', function ($what, $class = '') {
    $a = ['class' => "glyphicon glyphicon-{$what}"];
    if (!empty($class)) {
        $a['class'] .= ' ' . $class;
    }
    return HTML::span('', $a);
});
HTML::macro('pageHeader', function ($innards) {
    return '<div class="page-header"><h1>' . $innards . '</h1></div>';
});
HTML::macro('label', function ($name, $value = null, $options = array(), $optional = false) {
    if ($optional) {
        return HTML::label_optional($name, $value, $options);
    }
    return Form::label($name, $value, $options);
});
HTML::macro('label_optional', function ($name, $value = null, $options = array()) {
    $optional = ' <small><span class="text-muted label-optional">(optional)</span></small>';
    return HTML::decode(Form::label($name, $value . $optional, $options));
});
HTML::macro('bootstrap_label', function ($what, $type = null, $attributes = null, $class = '') {
    // default | primary | success | info | warning | danger
    $type = is_null($type) ? 'default' : $type;
    $class = !empty($class) ? ' ' . $class : $class;
    return '<span class="label label-' . $type . $class . '"' . HTML::atts($attributes) . '>' . $what . '</span>';
});
Esempio n. 17
0
        $date_format = 'Y-m-d';
        // FIXME: $forum_date_formats[$pun_user['date_format']];
    }
    if (is_null($time_format)) {
        $time_format = 'H:i';
        // FIXME: $forum_time_formats[$pun_user['time_format']];
    }
    $date = gmdate($date_format, $timestamp);
    $today = gmdate($date_format, $now + $diff);
    $yesterday = gmdate($date_format, $now + $diff - 86400);
    if (!$no_text) {
        if ($date == $today) {
            $date = trans('fluxbb::common.today');
        } elseif ($date == $yesterday) {
            $date = trans('fluxbb::common.yesterday');
        }
    }
    if ($date_only) {
        return $date;
    } elseif ($time_only) {
        return gmdate($time_format, $timestamp);
    } else {
        return $date . ' ' . gmdate($time_format, $timestamp);
    }
});
//
// A wrapper for PHP's number_format function
//
HTML::macro('number_format', function ($number, $decimals = 0) {
    return is_numeric($number) ? number_format($number, $decimals, trans('fluxbb::common.lang_decimal_point'), trans('fluxbb::common.lang_thousands_sep')) : $number;
});
Esempio n. 18
0
HTML::macro('twitter_user_home_timeline', function ($user, $count = 20) {
    $twitterRole = Twitter::getHomeTimeline(['screen_name' => $user, 'count' => $count, 'format' => 'json']);
    $parsed_json = json_decode($twitterRole, true);
    //dd($parsed_json);
    $result = '<ul class="timeline">';
    $result .= '<li class="time-label">';
    $result .= '<span class="bg-red">';
    //$result .= '<a href="https://twitter.com/'.$user->profile->twitter_username.'" target="_blank">';
    $result .= $user->profile->twitter_username;
    //$result .= '</a>';
    $result .= '</span>';
    $result .= '</li>';
    foreach ($parsed_json as $key => $value) {
        $result .= '<li>';
        $result .= '<i class="fa fa-twitter bg-blue"></i>';
        $result .= '<div class="timeline-item">';
        $result .= '<span class="time"><i class="fa fa-clock-o"></i> ' . date('M d, y g:i A', strtotime($value['created_at'])) . '</span>';
        $result .= '<h3 class="timeline-header">';
        $result .= '<a href="https://twitter.com/' . $value['user']['screen_name'] . '" target="_blank">';
        $result .= $value['user']['name'];
        $result .= '</a>';
        $result .= '</h3>';
        $result .= '<div class="timeline-body">';
        $result .= $value['text'];
        $result .= '</div>';
        $result .= '<div class="timeline-footer">';
        //$result .= '<a class="btn btn-primary btn-xs">...</a>';
        $result .= '</div>';
        $result .= '</div>';
        $result .= '</li>';
    }
    $result .= '</ul>';
    return $result;
});
Esempio n. 19
0
<?php

// Inspired by: http://forums.laravel.io/viewtopic.php?id=827
HTML::macro('nav_item', function ($url, $text, $a_attr = array(), $active_class = 'active', $li_attrs = array()) {
    $href = HTML::link($url, $text, $a_attr);
    $response = '';
    if (Request::is($url) || Request::is($url . '/*')) {
        if (isset($li_attrs['class'])) {
            $li_attrs['class'] .= ' ' . $active_class;
        } else {
            $li_attrs['class'] = $active_class;
        }
    }
    return '<li ' . HTML::attributes($li_attrs) . '>' . $href . '</li>';
});
Esempio n. 20
0
    return '
	<span ng-app="rating" title=' . $value . '>
		<span ng-init="value' . $id . ' = ' . round($value) . '">
			<rating ng-model="value' . $id . '" readonly="true">' . round($value) . '</rating>
		</span>
	</span>
	';
});
HTML::macro('listLink', function ($name, $link, $ignoreLastSegments = false) {
    $reqUrl = Request::url();
    $isLink = $reqUrl == $link;
    if ($ignoreLastSegments && !$isLink) {
        $isLink = strpos($reqUrl, "{$link}/") !== false;
    }
    $output = $isLink ? '<li class="active">' : '<li>';
    $output .= '<a href="' . url($link) . '">' . $name . '</a></li>';
    return $output;
});
HTML::macro('buttonLink', function ($name, $link, $ignoreLastSegments = false, $ignoreLastChar = false) {
    $reqUrl = Request::url();
    $isLink = $reqUrl == $link;
    if ($ignoreLastSegments && !$isLink) {
        $isLink = strpos($reqUrl, "{$link}/") !== false;
        if ($ignoreLastChar && !$isLink) {
            $isLink = strpos($reqUrl, substr($link, 0, -1) . "/") !== false;
        }
    }
    $output = '<a type="button" class="btn btn-lg' . ($isLink ? ' active' : '') . '"';
    $output .= ' href="' . url($link) . '">' . $name . '</a>';
    return $output;
});
<?php

/*
Note:   Requires font awesome assets installed.
See:    http://fontawesome.io/
*/
HTML::macro('fa', function ($what, $class = '', $attributes = null) {
    $c = "fa fa-{$what}";
    if (!empty($class)) {
        $c .= ' ' . $class;
    }
    return '<i class="' . $c . '"' . HTML::atts($attributes) . '></i>';
});
HTML::macro('extlink', function () {
    return HTML::fa('external-link', 'text-muted');
});
Esempio n. 22
0
|
| Next we will load the filters file for the application. This gives us
| a nice separate location to store our route and application filter
| definitions instead of putting them all in the main routes file.
|
*/
require app_path() . '/filters.php';
//require app_path().'/libraries/function/great_circle_distance.php';
//require app_path().'/libraries/function/flight_duration.php';
Form::macro('time_dropdown', function ($name, $options) {
    for ($i = 0; $i <= 23; $i++) {
        if ($i < 10) {
            $i = '0' . $i;
        }
        $hours[] = $i;
    }
    for ($i = 0; $i < 60; $i += 5) {
        if ($i < 10) {
            $i = '0' . $i;
        }
        $minutes[$i] = $i;
    }
    return '<div class="row"><div class="col-sm-6">' . Form::select($name . '[hours]', $hours, null, $options) . '</div><div class="col-sm-6">' . Form::select($name . '[minutes]', $minutes, null, $options) . '</div></div>';
});
HTML::macro('sort_link', function ($sortby) {
    return '<a href="' . action('AirportsController@index', array('sortby' => $sortby)) . '"><span class="glyphicon glyphicon-sort"></span></a>';
});
Form::macro('airports', function ($id, $options, $default = '') {
    $options['class'] = $options['class'] . ' airportsAutocomplete';
    return Form::hidden($id, $default, $options);
});
Esempio n. 23
0
<?php

HTML::macro('image_link', function ($url = '', $img = '', $alt = '', $link_name = '', $param = '', $active = true, $ssl = false) {
    $url = $ssl == true ? URL::to_secure($url) : URL::to($url);
    $img = HTML::image($img, $alt);
    $img .= $link_name;
    $link = $active == true ? HTML::link($url, '#', $param) : $img;
    $link = str_replace('#', $img, $link);
    return $link;
});
HTML::macro('icon_link', function ($url = '', $icon = '', $link_name = '', $param = '', $active = true, $ssl = false) {
    $url = $ssl == true ? URL::to_secure($url) : URL::to($url);
    $icon = '<i class="' . $icon . '" aria-hidden="true"></i>' . $link_name;
    $link = $active == true ? HTML::link($url, '#', $param) : $icon;
    $link = str_replace('#', $icon, $link);
    return $link;
});
HTML::macro('icon_btn', function ($url = '', $icon = '', $link_name = '', $param = '', $active = true, $ssl = false) {
    $url = $ssl == true ? URL::to_secure($url) : URL::to($url);
    $icon = $link_name . ' <i class="' . $icon . '" aria-hidden="true"></i>';
    $link = $active == true ? HTML::link($url, '#', $param) : $icon;
    $link = str_replace('#', $icon, $link);
    return $link;
});
// SHOW USERNAME
HTML::macro('show_username', function () {
    $the_username = Auth::user()->name === Auth::user()->email ? is_null(Auth::user()->first_name) ? Auth::user()->name : Auth::user()->first_name : (is_null(Auth::user()->name) ? Auth::user()->email : Auth::user()->name);
    return $the_username;
});
Esempio n. 24
0
 * @copyright 2012 CreativityKills, LLC
 * @link http://github.com/CreativityKills/placeholdr/
 * @version 1.0
 */
/**
 * Placeholdr bundle root path.
 *
 * Using this value instead of Bundle::path('placeholdr') gives the developer
 * more options, especially when trying to rename the bundle.
 */
define('PLACEHOLDR', __DIR__ . DIRECTORY_SEPARATOR);
/**
 * Add libraries folder to autoloader loading directories.
 *
 * This will tell Laravel where to look when attempting to autoload Placeholdr
 * classes.
 */
Autoloader::directories(array(PLACEHOLDR . 'libraries'));
/**
 * Register a HTML macro for use in views.
 *
 * The Placeholdr HTML macro makes using Placeholdr within the application
 * views a breeze. Simple and elegant, the Laravel way ;)
 *
 * <code>
 * 	{{ HTML::placeholdr('300x300') }}
 * </code>
 */
HTML::macro('placeholdr', function ($dimension, $text = '', $attributes = array()) {
    return '<img src="' . URL::to_route('placeholdr', array($dimension, $text)) . '"' . HTML::attributes($attributes) . ' />';
});
Esempio n. 25
0
    $first_name = ucwords($user['first_name']);
    $last_name = ucwords($user['last_name']);
    return $first_name . ' ' . $last_name;
});
HTML::macro('loggedUserFullName', function () {
    $logged_user = AuthMgr::getLoggedUser();
    return HTML::userFullName($logged_user);
});
HTML::macro('loggedUserEmail', function () {
    $user = AuthMgr::getLoggedUser();
    return $user['email'];
});
HTML::macro('loggedUserGravatarImage', function ($alt = null, $attributes = []) {
    $logged_user = AuthMgr::getLoggedUser();
    if (empty($logged_user)) {
        return null;
    }
    return Gravatar::image($logged_user->email, $alt, $attributes);
});
/*
|--------------------------------------------------------------------------
| Helper Functions
|--------------------------------------------------------------------------
|
| Include helper functions file
|
*/
require_once 'helper_functions.php';
/*
|--------------------------------------------------------------------------
| Enable Sentry Throttling
Esempio n. 26
0
<?php

HTML::macro('meta', function ($attr = [], $content = null) {
    // Basic Meta Tags
    $HtmlBuilder = new Illuminate\Html\HtmlBuilder();
    if (!is_array($attr) && !is_null($content)) {
        return '<meta name="' . $attr . '" content="' . $content . '" />' . PHP_EOL;
    } else {
        return '<meta' . $HtmlBuilder->attributes($attr) . ' />' . PHP_EOL;
    }
});
HTML::macro('meta_facebook', function ($property, $content) {
    // Facebook Open Graph Meta Tags
    return '<meta property="og:' . $property . '" content="' . $content . '" />' . PHP_EOL;
});
HTML::macro('meta_twitter', function ($property, $content) {
    // Twitter Meta Tags
    return '<meta name="twitter:' . $property . '" content="' . $content . '" />' . PHP_EOL;
});
Esempio n. 27
0
<?php

HTML::macro('menu_link', function ($routes, $phone = false) {
    $count = count($routes);
    if ($count > 1) {
        $list = '<li>' . link_to($routes[0]["route"], $routes[0]["text"]) . '<ul style="left: 0;" class="';
        $phone ? $list .= 'dl-submenu"><li class="dl-back"><a href="#">back</a></li>' : ($list .= 'dl-submenu">');
        for ($i = 1; $i < $count; $i++) {
            $list .= '<li>' . link_to($routes[$i]["route"], $routes[$i]["text"]) . '</li>';
        }
        $list .= '</ul></li>';
        return $list;
    }
    return '<li>' . link_to($routes[0]['route'], $routes[0]['text']) . '</li>';
});
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
App::missing(function ($exception) {
    return View::make('child.404');
});
Route::get('/', function () {
    return View::make('home');
});
Esempio n. 28
0
HTML::macro('bt_nav', function ($list) {
    $html = '';
    foreach ($list as $item) {
        $html_part = '';
        $create_nav = false;
        // check permission
        if (array_key_exists('visible', $item)) {
            if (!Sentry::getUser()->hasAccess($item['visible'])) {
                // this user doesn't have access to view this nav, delete this nav
                $html_part = '';
            } else {
                // user has permission
                $create_nav = true;
            }
        } else {
            // visible not set
            $create_nav = true;
        }
        // visible is not set. Or its been set, and user have access
        if ($create_nav) {
            // Check if current sub nav is active, if yes, make it parent active.
            $subnavActive = '';
            if (array_key_exists('subnav', $item)) {
                foreach ($item['subnav'] as $subnav) {
                    if (Request::url() == $subnav['url']) {
                        $subnavActive = 'active';
                        break;
                    }
                }
            }
            $html_part .= '<li class="' . (Request::url() == $item['url'] || $subnavActive == 'active' ? 'active' : '') . '">';
            $html_part .= '  <a href="' . $item['url'] . '" class="' . $subnavActive . '">';
            $html_part .= '    <i class="' . $item['icon'] . '">';
            $html_part .= '      <b class="' . $item['icon-bg'] . '"></b>';
            $html_part .= '    </i>';
            // Add icon for dropdown
            if (array_key_exists('subnav', $item)) {
                $html_part .= '<span class="pull-right">
                           <i class="fa fa-angle-down text"></i>
                           <i class="fa fa-angle-up text-active"></i>
                         </span>';
            }
            $html_part .= '    <span class="' . (array_key_exists('small', $item) && $item['small'] == true ? 'text-xxs' : '') . '">' . $item['title'] . '</span>';
            $html_part .= '  </a>';
            // Add subnav
            if (array_key_exists('subnav', $item)) {
                $html_part .= '<ul class="nav lt">';
                foreach ($item['subnav'] as $subnav) {
                    // filter visible subnav
                    // @TODO: if there is no visible allowed, don't add this parent menu
                    if (array_key_exists('visible', $subnav)) {
                        if (!Sentry::getUser()->hasAccess($subnav['visible'])) {
                            // this user doesn't have access to view this nav, delete this nav
                            $create_subnav = false;
                        } else {
                            // user has permission
                            $create_subnav = true;
                        }
                    } else {
                        // visible not set
                        $create_subnav = true;
                    }
                    // create subnav
                    if ($create_subnav) {
                        $html_part .= '<li class="' . (Request::url() == $subnav['url'] ? 'active' : '') . '">';
                        $html_part .= '  <a href="' . $subnav['url'] . '">';
                        $html_part .= '   <i class="fa fa-angle-right"></i>';
                        $html_part .= '      <span>' . $subnav['title'] . '</span>';
                        $html_part .= '  </a>';
                        $html_part .= '</li>';
                    }
                }
                $html_part .= '</ul>';
            }
            $html_part .= '</li>';
        }
        // Append to $html
        $html .= $html_part;
    }
    return $html;
});
    return $error;
}
function fieldError($field)
{
    $error = '';
    if ($errors = Session::get('errors')) {
        $error = $errors->first($field) ? ' has-error' : '';
    }
    return $error;
}
function fieldLabel($name, $label)
{
    if (is_null($label)) {
        return '';
    }
    $name = str_replace('[]', '', $name);
    $out = '<label for="id-field-' . $name . '" class="control-label">';
    $out .= $label . '</label>';
    return $out;
}
function fieldAttributes($name, $attributes = array())
{
    $name = str_replace('[]', '', $name);
    return array_merge(['class' => 'form-control', 'id' => 'id-field-' . $name], $attributes);
}
HTML::macro('placeholder', function ($value, $label) {
    $content = $value ? $value : '<span class="label label-default">N/A</span>';
    $out = '<h4>' . $content . '</h4>';
    $out .= '<span class="text-muted text-uppercase">' . $label . '</span>';
    return $out;
});
Esempio n. 30
0
/**
 * Returns a very customised view for pagination. Simply provide the paginator instance to the
 * macro as the one and only parameter and the pagination view will handle the rest.
 *
 * @param Paginator $paginator
 */
HTML::macro('pagination', function ($paginator) {
    return View::make('shift::partials.page.pagination', compact('paginator'));
});
/**
 * Renders a menu that has been registered by the provided menuName.
 *
 * @param string|Menu $menu
 * @return View
 */
HTML::macro('menu', function ($menu) {
    // If a menu instance was not passed, let's instead try and fetch the menu by name
    if (!$menu instanceof \Tectonic\Shift\Library\Menu\Menu) {
        $menu = Menufy::menu($menu)->first();
    }
    // Render the menu
    return View::make('shift::partials.menu.menu', compact('menu'));
});
/**
 * Displays the full name for a user.
 *
 * @param object $user
 */
HTML::macro('fullName', function ($user) {
    return $user->firstName . ' ' . $user->lastName;
});