is() public static method

Alias for the "currentRouteName" method.
public static is ( ) : boolean
return boolean
Example #1
0
/**
 * @param $routes
 * @param string $active
 * @return string
 */
function set_active($routes = [], $active = 'active')
{
    foreach ($routes as $route) {
        if (Route::is($route)) {
            return $active;
        }
    }
}
Example #2
0
/**
 * @param array $routes
 * @param string $active
 * @return string|void
 */
function activate($routes = [], $active = 'active')
{
    foreach ($routes as $route) {
        if (Route::is($route)) {
            return $active;
        }
    }
    return;
}
 /**
  * Determine whether the given menu is active based on current route name.
  *
  * @param  string $menu
  * @return boolean
  */
 function active_menu($menu)
 {
     switch ($menu) {
         case 'users':
             return (Route::is('user*') || Route::is('company.user*') || Route::is('role.user*')) && !Route::is('user.process.index');
         case 'roles':
             return (Route::is('role*') || Route::is('company.role*')) && !Route::is('role.user*');
     }
 }
 /**
  * Display a listing of tarefas
  *
  * @return Response
  */
 public function index()
 {
     $data = Input::get();
     $data['view'] = Input::has('view') ? Input::get('view') : 'today';
     // today, late, next, done
     $data['paginate'] = Input::has('paginate') ? Input::get('paginate') : 10;
     $dt = new Carbon();
     $tarefas = Tarefa::where(function ($query) use($data, $dt) {
         switch ($data['view']) {
             case 'late':
                 $query->where('date', '<', $dt->format('Y-m-d'))->where('done', false);
                 break;
             case 'next':
                 $query->where('date', '>', $dt->format('Y-m-d'))->where('done', false);
                 break;
             case 'done':
                 $query->where('done', true);
                 break;
             default:
                 // TODAY
                 $query->where('date', '>=', $dt->startOfDay()->format('Y-m-d'))->where('date', '<=', $dt->endOfDay()->format('Y-m-d'));
                 break;
         }
     })->orderBy(Input::get('order_by', 'date'), Input::get('order', 'DESC'))->with('cliente', 'conversas')->paginate(Input::get('paginate', 10));
     // $tarefas = Tarefa::orderBy('date', 'DESC')->with('cliente')->get();
     $hoje = date('Y-m-d');
     $ontem = Carbon::create(date('Y'), date('m'), date('d'))->subDay();
     $amanha = Carbon::create(date('Y'), date('m'), date('d'))->addDay();
     $proximo = Carbon::create(date('Y'), date('m'), date('d'))->addDay();
     //Igual amanhã?
     if ($proximo->isWeekend()) {
         $proximo = new Carbon('next monday');
     }
     $tarefas->pendentes = Tarefa::where('date', '<', $hoje)->where('done', 0)->orderBy('date', 'ASC')->with('cliente', 'conversas')->get();
     $tarefas->hoje = Tarefa::where('date', '<', $amanha->startOfDay())->where('date', '>', $ontem)->where('done', 0)->with('cliente', 'conversas')->get();
     $tarefas->nextDay = Tarefa::where('done', 0)->where('date', '>=', $amanha)->where('date', '<', $proximo->addDay())->orderBy('date', 'DESC')->with('cliente', 'conversas')->get();
     $tarefas->proximas = Tarefa::where('date', '>=', $amanha)->orderBy('date', 'ASC')->where('done', 0)->with('cliente', 'conversas')->get();
     $tarefas->concluidas = Tarefa::where('done', 1)->orderBy('updated_at', 'DESC')->with('cliente', 'conversas')->get();
     $tarefas->days = $tarefas->groupBy(function ($tarefa) {
         return date('Y-m-d', strtotime($tarefa->date));
     });
     if (Request::ajax()) {
         return $tarefas;
     }
     if (Route::is('tarefas.print')) {
         return View::make('tarefas.print', compact('tarefas'));
     } else {
         return View::make('tarefas.index', compact('tarefas'));
     }
 }
 /**
  * Display a listing of the resource.
  * GET /contacts
  *
  * @return Response
  */
 public function index()
 {
     // $agenda = new CreateAgendaEventsTable;
     // $agenda->down();
     // $agenda->up();
     // exit;
     $data = Input::get();
     $data['view'] = Input::has('view') ? Input::get('view') : 'day';
     $data['date'] = Input::has('date') ? Input::get('date') : date('Y-m-d');
     $data['next'] = Input::has('next') ? Input::get('next') : 0;
     $data['prev'] = Input::has('prev') ? Input::get('prev') : 0;
     $data['type'] = Input::has('type') ? Input::get('type') : NULL;
     $tarefas = array();
     $agendaevents = array();
     if ($data['type'] == 'tarefa' || $data['type'] == NULL) {
         $tarefas = $this->getTarefas($data);
         $tarefas = $tarefas->groupBy(function ($tarefa) {
             return date('Y-m-d', strtotime($tarefa->date));
         })->toArray();
     }
     if ($data['type'] == 'agendaevent' || $data['type'] == NULL) {
         $agendaevents = $this->getAgendaEvents($data);
         $agendaevents = $agendaevents->groupBy(function ($agendaevent) {
             return date('Y-m-d', strtotime($agendaevent->date_start));
         })->toArray();
     }
     // $agendaevents['date_start'] = array_merge($tarefas['date']);
     $events = array_merge_recursive($tarefas, $agendaevents);
     // $events = array_merge($agendaevents);
     ksort($events);
     // print_r( $events );
     $navigation_links = $this->getNavigationLinks($data);
     $labels = $this->getLabels($data);
     if (Route::is('agenda.print')) {
         return View::make('agenda.print', compact('events', 'navigation_links', 'labels', 'carbon'));
     } else {
         return View::make('agenda.index', compact('events', 'navigation_links', 'labels', 'carbon'));
     }
 }
Example #6
0
 /**
  * @return bool
  */
 function isOnPages()
 {
     return Route::is('admin.pages.*');
 }
Example #7
0
<?php

$cache_config = File::open(__DIR__ . DS . 'states' . DS . 'config.txt')->unserialize();
$route_cache = false;
if (isset($cache_config['path'][$config->url_path])) {
    $route_cache = $cache_config['path'][$config->url_path];
} else {
    foreach ($cache_config['path'] as $path => $exp) {
        if (Route::is($path)) {
            $route_cache = $exp;
            break;
        }
    }
}
if ($route_cache !== false) {
    Weapon::add('shield_before', function () use($config, $route_cache) {
        $q = !empty($config->url_query) ? '.' . md5($config->url_query) : "";
        $cache = CACHE . DS . str_replace(array('/', ':'), '.', $config->url_path) . $q . '.cache';
        $time = file_exists($cache) ? filemtime($cache) : false;
        if ($time !== false && ($route_cache === true || time() - $route_cache * 60 * 60 < $time)) {
            $content = file_get_contents($cache);
            if (strpos($content, '<?xml ') === 0 || strpos($content, '</html>') !== false) {
                $content .= '<!-- cached: ' . date('Y-m-d H:i:s', $time) . ' -->';
            }
            $content = Filter::apply('cache:input', $content);
            $content = Filter::apply('cache:output', $content);
            echo $content;
            exit;
        }
        Weapon::add('shield_after', function ($G) use($cache) {
            $G['data']['cache'] = $cache;
Example #8
0
| cross-site request forgery attacks. If this special token in a user
| session does not match the one given in this request, we'll bail.
|
*/
Route::filter('csrf', function () {
    if (Session::token() != Input::get('_token')) {
        throw new Illuminate\Session\TokenMismatchException();
    }
});
Route::filter('manage_topics', function () {
    if (Auth::guest()) {
        return Redirect::guest('login-required');
    } elseif (!Entrust::can('manage_topics')) {
        // Checks the current user
        return Redirect::route('admin-required');
    }
});
Route::filter('manage_users', function () {
    if (Auth::guest()) {
        return Redirect::guest('login-required');
    } elseif (!Entrust::can('manage_users')) {
        // Checks the current user
        return Redirect::route('admin-required');
    }
});
Route::filter('check_banned_user', function () {
    // Check Banned User
    if (Auth::check() && !Route::is('user-banned') && Auth::user()->is_banned) {
        return Redirect::route('user-banned');
    }
});
Example #9
0
    Weapon::fire(array('on_shield_update', 'on_shield_' . $mode, 'on_shield_' . md5($slug) . '_update', 'on_shield_' . md5($slug) . '_' . $mode), array($G, $G));
    $new_config = Get::state_config();
    $new_config['shield'] = $path === 'attach' ? $slug : 'normal';
    File::serialize($new_config)->saveTo(STATE . DS . 'config.txt', 0600);
    $G = array('data' => array('id' => $slug, 'action' => $path));
    Notify::success(Config::speak('notify_success_updated', $speak->shield));
    foreach (glob(LOG . DS . 'asset.*.log', GLOB_NOSORT) as $asset_cache) {
        File::open($asset_cache)->delete();
    }
    Guardian::kick($config->manager->slug . '/shield/' . $slug);
});
/**
 * Shield Updater (Base)
 * ---------------------
 */
if ($route = Route::is($config->manager->slug . '/shield/(:any)/update')) {
    Weapon::add('routes_before', function () use($config, $speak, $route) {
        if (!Route::accepted($route['path'])) {
            Route::accept($route['path'], function () use($config, $speak, $route) {
                if ($request = Request::post()) {
                    $s = $route['lot'][0];
                    $request = Filter::apply('request:__shield', $request, $s);
                    Guardian::checkToken($request['token']);
                    unset($request['token']);
                    // remove token from request array
                    File::serialize($request)->saveTo(SHIELD . DS . $s . DS . 'states' . DS . 'config.txt', 0600);
                    Notify::success(Config::speak('notify_success_updated', $speak->shield));
                    Guardian::kick(File::D($config->url_current));
                }
            });
        }
Example #10
0
/**
 * Custom Function(s)
 * ------------------
 *
 * Add your own custom function(s) here. You can do something like
 * making custom widget(s), custom route(s), custom filter(s),
 * custom weapon(s), loading custom asset(s), etc. So that you can
 * manipulate the site output without having to touch the CMS core.
 *
 */
// HTML output manipulation
Filter::add('chunk:output', function ($content, $path) use($config, $speak) {
    $name = File::N($path);
    // Add an icon to the log in form button
    if ($name === 'page.body' && Route::is($config->manager->slug . '/login')) {
        return str_replace('>' . $speak->login . '</button>', '><i class="fa fa-key"></i> ' . trim(strip_tags($speak->login)) . '</button>', $content);
    }
    // Add an icon to the older and newer link text
    if ($name === 'pager') {
        $content = str_replace('>' . $speak->newer . '</a>', '><i class="fa fa-angle-left"></i> ' . trim(strip_tags($speak->newer)) . '</a>', $content);
        $content = str_replace('>' . $speak->older . '</a>', '>' . trim(strip_tags($speak->older)) . ' <i class="fa fa-angle-right"></i></a>', $content);
    }
    // Add an icon to the article date
    if ($name === 'article.time') {
        $content = str_replace('<time ', '<i class="fa fa-calendar"></i> <time ', $content);
    }
    // Add an icon to the comments title
    if ($name === 'comments.header') {
        $content = str_replace('<h3>', '<h3><i class="fa fa-comments"></i> ', $content);
    }
Example #11
0
        $P = array('data' => array('id' => $slug));
        Weapon::fire(array('on_plugin_update', 'on_plugin_destruct', 'on_plugin_' . md5($slug) . '_update', 'on_plugin_' . md5($slug) . '_destruct'), array($P, $P));
        File::open($plugin)->delete();
        // delete later ...
        Notify::success(Config::speak('notify_success_deleted', $speak->plugin));
        Guardian::kick($config->manager->slug . '/plugin');
    } else {
        Notify::warning(Config::speak('notify_confirm_delete_', '<strong>' . $info['title'] . '</strong>'));
    }
    Shield::lot(array('segment' => 'plugin'))->attach('manager');
});
/**
 * Plugin Updater (Base)
 * ---------------------
 */
if ($route = Route::is($config->manager->slug . '/plugin/(:any)/update')) {
    Weapon::add('routes_before', function () use($config, $speak, $route) {
        if (!Route::accepted($route['path'])) {
            Route::accept($route['path'], function () use($config, $speak, $route) {
                if ($request = Request::post()) {
                    $s = $route['lot'][0];
                    $request = Filter::apply('request:__plugin', $request, $s);
                    Guardian::checkToken($request['token']);
                    unset($request['token']);
                    // remove token from request array
                    File::serialize($request)->saveTo(PLUGIN . DS . $s . DS . 'states' . DS . 'config.txt', 0600);
                    Notify::success(Config::speak('notify_success_updated', $speak->plugin));
                    Guardian::kick(File::D($config->url_current));
                }
            });
        }
Example #12
0
 function on_route($route)
 {
     return Route::current() ? Route::is($route) : false;
 }
Example #13
0
    $name = File::N($path);
    // Add an icon to the older and newer link text
    if ($name === 'pager') {
        $content = str_replace('>' . $speak->newer . '</a>', '><i class="fa fa-angle-left"></i> ' . trim(strip_tags($speak->newer)) . '</a>', $content);
        $content = str_replace('>' . $speak->older . '</a>', '>' . trim(strip_tags($speak->older)) . ' <i class="fa fa-angle-right"></i></a>', $content);
    }
    // Add an icon to the article date
    if ($name === 'article.time') {
        $content = str_replace('<time ', '<i class="fa fa-calendar"></i> <time ', $content);
    }
    // Add an icon to the comments title
    if ($name === 'comments.header') {
        $content = str_replace('<h3>', '<h3><i class="fa fa-comments"></i> ', $content);
    }
    // Add an icon to the comment form button
    if ($name === 'comment.form') {
        $content = str_replace('>' . $speak->publish . '</button>', '><i class="fa fa-check-circle"></i> ' . trim(strip_tags($speak->publish)) . '</button>', $content);
    }
    // Add an icon to the log in/out link
    if ($name === 'block.footer.bar') {
        $content = str_replace('>' . $speak->log_in . '</a>', '><i class="fa fa-sign-in"></i> ' . trim(strip_tags($speak->log_in)) . '</a>', $content);
        $content = str_replace('>' . $speak->log_out . '</a>', '><i class="fa fa-sign-in"></i> ' . trim(strip_tags($speak->log_out)) . '</a>', $content);
    }
    // Add an icon to the log in form button
    if (Route::is($config->manager->slug . '/login') && $name === 'page.body') {
        return str_replace('>' . $speak->login . '</button>', '><i class="fa fa-key"></i> ' . trim(strip_tags($speak->login)) . '</button>', $content);
    }
    return $content;
});
// Exclude these fields on index, tag, archive, search page ...
Config::set($config->page_type . '_fields_exclude', array('content', 'content_raw'));
Example #14
0
 /**
  * Return the "active" class if current route is matched.
  *
  * @param  string|array $route
  * @param  string $output
  * @return string|null
  */
 function active_route($route, $output = 'active')
 {
     if (is_array($route)) {
         if (call_user_func_array('Route::is', $route)) {
             return $output;
         }
     } else {
         if (Route::is($route)) {
             return $output;
         }
     }
 }
Example #15
0
Route::get('cart', 'PaymentController@index');
Route::get('cart/remove/event/{id}', 'PaymentController@removeEventCart');
Route::post('cart/add/event/{id}', 'PaymentController@addEventCart');
Route::get('cart/select', array('before' => 'auth', 'as' => 'checkout.select', 'uses' => 'PaymentController@selectplayer'));
Route::post('cart/select/{id}', array('before' => 'auth', 'as' => 'checkout.select.addplayer', 'uses' => 'PaymentController@addplayertocart'));
Route::delete('cart/select/{id}', array('before' => 'auth', 'as' => 'checkout.select.removeplayer', 'uses' => 'PaymentController@removeplayertocart'));
Route::get('checkout', array('before' => 'auth', 'as' => 'checkout', 'uses' => 'PaymentController@create'));
Route::get('checkout/success', array('before' => 'auth', 'as' => 'checkout.success', 'uses' => 'PaymentController@success'));
Route::post('checkout/store', array('before' => 'auth', 'as' => 'checkout.store', 'uses' => 'PaymentController@store'));
Route::post('checkout/validate', array('before' => 'auth', 'as' => 'checkout.validate', 'uses' => 'PaymentController@validate'));
Route::post('checkout/discount', array('before' => 'auth', 'as' => 'checkout.discount', 'uses' => 'DiscountController@validate'));
//Helper API
Route::post('api/image/upload', 'ImageController@upload');
Route::post('api/image/crop', 'ImageController@crop');
Route::get('api/ical/create/{id}', 'CalendarController@create');
Route::get('api/export/team/{id}', array('before' => 'auth', 'uses' => 'ExportController@team'));
Route::get('api/export/event/{id}', array('before' => 'auth', 'uses' => 'ExportController@event'));
Route::post('api/export/report/', array('before' => 'auth', 'uses' => 'ExportController@report'));
Route::post('api/queue/push', function () {
    return Queue::marshal();
});
//** smart link macro **//
HTML::macro('smart_link', function ($route) {
    if (Route::is($route) or Request::is($route)) {
        $active = "selected";
    } else {
        $active = '';
    }
    return $active;
});
App::bind('confide.user_validator', 'UserValidation');
{
    global $config, $speak, $segment;
    $q = str_replace('&', '&amp;', HTTP::query(array('parent' => $response->id, 'post' => $response->post)));
    echo (Weapon::exist($segment[0] . '_footer') ? ' / ' : "") . Cell::a($config->manager->slug . '/' . $segment[0] . '/ignite' . $q, $speak->reply);
}
// Show total comment repl(y|ies)
function __do_response_reply_count($response)
{
    global $config, $speak, $segment;
    $e = File::E($response->path);
    $replies = count(glob(COMMENT . DS . '*_*_' . Date::slug($response->id) . '.{txt,hold}', GLOB_NOSORT | GLOB_BRACE));
    $t = Jot::icon('reply-all') . ' ' . $replies;
    $tt = array('title' => $replies . ' ' . ($replies === 1 ? $speak->{$segment[0] . '_reply'} : $speak->{$segment[0] . '_replies'}));
    echo ($e === 'hold' || $replies === 0 ? Cell::span($t, $tt) : Cell::a($config->manager->slug . '/' . $segment[0] . '?filter=parent%3A' . $response->id, $t, null, $tt)) . ' &middot; ';
}
if (Route::is($config->manager->slug . '/' . $segment[0] . '/ignite') && ($parent = Request::get('parent', false))) {
    if ($response = call_user_func('Get::' . $segment[0], $parent)) {
        Weapon::add('tab_content_1_before', function () use($segment, $response) {
            $post = call_user_func('Get::' . $segment[1] . 'Anchor', $response->post);
            echo Cell::h3($response->name . ($post ? ' &raquo; ' . Cell::a($response->permalink, $post->title, '_blank') : "")) . $response->message . Cell::hr() . Cell::h4(Config::speak($segment[0] . '_reply_to_', $response->name));
        }, 0.1);
    }
    Weapon::add('shield_before', function () use($config, $segment, $parent) {
        $to = call_user_func('Get::' . $segment[0] . 'Anchor', $parent);
        $to = $to !== false ? $to->name : $parent;
        $to_text = Config::speak($segment[0] . '_reply_to_', $to);
        Config::set('page_title', $to_text . $config->title_separator . Config::get('page_title'));
    });
}
// Apply `__do_response_reply` weapon
Weapon::add($segment[0] . '_footer', '__do_response_reply', 20.1);