/** * Returns breadcrumbs made up by URI segments * * @return string */ public static function breadcrumbs() { $breadcrumbs = []; $crumbs = Request::segments(); if (count($crumbs) < 2) { return; } $url = ""; end($crumbs); $last_key = key($crumbs); foreach ($crumbs as $key => $crumb) { $url .= '/' . $crumb; $crumb = ucwords($crumb); if ($key != $last_key) { $crumb = '<span typeof="v:Breadcrumb">' . link_to($url, $crumb, ['rel' => 'v:url', 'property' => 'v:title']) . '</span>'; } else { if (Request::segment(1) === 'snippets') { $crumb = ""; } else { $crumb = '<span class="current">' . $crumb . '</span>'; } } array_push($breadcrumbs, $crumb); } $return = '<div class="clearfix">'; $return .= '<div class="breadcrumbs" xmlns:v="http://rdf.data-vocabulary.org/#">'; $return .= '<div class="container">'; $return .= implode('<i class="fa fa-chevron-right"></i>', $breadcrumbs); $return .= '</div>'; $return .= '</div>'; $return .= '</div>'; return $return; }
function setActive($route, $class = 'active') { $segments = Request::segments(); $route = $route != '' ? explode('.', $route) : array(); return $segments === $route ? $class : ' '; // return (Route::current()->getName() == $route) ? $class : ''; }
function uri_slug() { $segments = Request::segments(0); if (isset($segments[0])) { return $segments[0]; } return 'home'; }
public function boot() { $this->package('micro/pages'); Pages::$languages = Config::get('pages::languages'); Pages::$segments = \Request::segments(); Pages::$baseURL = url(head(array_keys(Pages::$languages))); Pages::$driver = Config::get('pages::driver'); Pages::$driverConfig = Config::get('pages::driverConfig'); }
function __construct() { $this->beforeFilter('table_settings', array('except' => array('settings'))); $this->beforeFilter('table_needle', array('except' => array('settings'))); $segments = Request::segments(); $this->table = DB::table('crud_table')->where('table_name', $segments[1])->first(); $this->settings = DB::table('crud_settings')->first(); parent::__construct(); }
public function buildCSV($file = '', $timestamp = '', $sanitize = true, $del = array()) { $this->limit = null; parent::build(); $segments = \Request::segments(); $filename = $file != '' ? basename($file, '.csv') : end($segments); $filename = preg_replace('/[^0-9a-z\\._-]/i', '', $filename); $filename .= $timestamp != "" ? date($timestamp) . ".csv" : ".csv"; $save = (bool) strpos($file, "/"); //Delimiter $delimiter = array(); $delimiter['delimiter'] = isset($del['delimiter']) ? $del['delimiter'] : ';'; $delimiter['enclosure'] = isset($del['enclosure']) ? $del['enclosure'] : '"'; $delimiter['line_ending'] = isset($del['line_ending']) ? $del['line_ending'] : "\n"; if ($save) { $handle = fopen(public_path() . '/' . dirname($file) . "/" . $filename, 'w'); } else { $headers = array('Content-Type' => 'text/csv', 'Pragma' => 'no-cache', '"Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', 'Content-Disposition' => 'attachment; filename="' . $filename . '"'); $handle = fopen('php://output', 'w'); ob_start(); } fputs($handle, $delimiter['enclosure'] . implode($delimiter['enclosure'] . $delimiter['delimiter'] . $delimiter['enclosure'], $this->headers) . $delimiter['enclosure'] . $delimiter['line_ending']); foreach ($this->data as $tablerow) { $row = new Row($tablerow); foreach ($this->columns as $column) { if (in_array($column->name, array("_edit"))) { continue; } $cell = new Cell($column->name); $value = str_replace('"', '""', str_replace(PHP_EOL, '', strip_tags($this->getCellValue($column, $tablerow, $sanitize)))); // Excel for Mac is pretty stupid, and will break a cell containing \r, such as user input typed on a // old Mac. // On the other hand, PHP will not deal with the issue for use, see for instance: // http://stackoverflow.com/questions/12498337/php-preg-replace-replacing-line-break // We need to normalize \r and \r\n into \n, otherwise the CSV will break on Macs $value = preg_replace('/\\r\\n|\\n\\r|\\n|\\r/', "\n", $value); $cell->value($value); $row->add($cell); } if (count($this->row_callable)) { foreach ($this->row_callable as $callable) { $callable($row); } } fputs($handle, $delimiter['enclosure'] . implode($delimiter['enclosure'] . $delimiter['delimiter'] . $delimiter['enclosure'], $row->toArray()) . $delimiter['enclosure'] . $delimiter['line_ending']); } fclose($handle); if ($save) { //redirect, boolean or filename? } else { $output = ob_get_clean(); return \Response::make(rtrim($output, "\n"), 200, $headers); } }
public function buildCSV($file = '', $timestamp = '', $sanitize = true, $del = array()) { $this->limit = null; parent::build(); $segments = \Request::segments(); $filename = $file != '' ? basename($file, '.csv') : end($segments); $filename = preg_replace('/[^0-9a-z\\._-]/i', '', $filename); $filename .= $timestamp != "" ? date($timestamp) . ".csv" : ".csv"; $save = (bool) strpos($file, "/"); //Delimiter $delimiter = array(); $delimiter['delimiter'] = isset($del['delimiter']) ? $del['delimiter'] : ';'; $delimiter['enclosure'] = isset($del['enclosure']) ? $del['enclosure'] : '"'; $delimiter['line_ending'] = isset($del['line_ending']) ? $del['line_ending'] : "\n"; if ($save) { $handle = fopen(public_path() . '/' . dirname($file) . "/" . $filename, 'w'); } else { $headers = array('Content-Type' => 'text/csv', 'Pragma' => 'no-cache', '"Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', 'Content-Disposition' => 'attachment; filename="' . $filename . '"'); $handle = fopen('php://output', 'w'); ob_start(); } fputs($handle, $delimiter['enclosure'] . implode($delimiter['enclosure'] . $delimiter['delimiter'] . $delimiter['enclosure'], $this->headers) . $delimiter['enclosure'] . $delimiter['line_ending']); foreach ($this->data as $tablerow) { $row = new Row($tablerow); foreach ($this->columns as $column) { if (in_array($column->name, array("_edit"))) { continue; } $cell = new Cell($column->name); $value = str_replace('"', '""', str_replace(PHP_EOL, '', strip_tags($this->getCellValue($column, $tablerow, $sanitize)))); $cell->value($value); $row->add($cell); } if (count($this->row_callable)) { foreach ($this->row_callable as $callable) { $methodReflection = new \ReflectionFunction($callable); $argCount = $methodReflection->getNumberOfParameters(); if ($argCount === 1) { $callable($row); } elseif ($argCount === 2) { $callable($row, $tablerow); } } } fputs($handle, $delimiter['enclosure'] . implode($delimiter['enclosure'] . $delimiter['delimiter'] . $delimiter['enclosure'], $row->toArray()) . $delimiter['enclosure'] . $delimiter['line_ending']); } fclose($handle); if ($save) { //redirect, boolean or filename? } else { $output = ob_get_clean(); return \Response::make(rtrim($output, "\n"), 200, $headers); } }
function bodyClass() { $body_classes = array(); $class = ""; foreach (\Request::segments() as $segment) { if (is_numeric($segment) || empty($segment)) { continue; } $class .= !empty($class) ? "-" . $segment : $segment; array_push($body_classes, $class); } return !empty($body_classes) ? implode(' ', $body_classes) : NULL; }
public static function addHistoryLink($link = false, $modelName = false, $ignoreRequestForModelName = false) { if (\Session::has('adminHistoryLinks')) { $links = \Session::get('adminHistoryLinks'); } else { $links = array(); } if (!$link) { $url = explode('?', $_SERVER["REQUEST_URI"]); $link = array_shift($url) . Tools::getGets(); } if (!$modelName) { $modelName = \Request::segment(2); } $linkSegments = explode("/", $link); $action = isset($linkSegments[3]) ? $linkSegments[3] : false; $addLink = isset($linkSegments[4]) && $linkSegments[4] == "new" ? true : false; $tempLinks = $links; if (count($links)) { $delete = false; foreach ($links as $index => $cLink) { // If ModelName and Action already exist in history, it means we're going back // therefore delete all history links AFTER the current history link // and replace current history with the newly modified one if ($cLink['modelConfigName'] == $modelName && $cLink['action'] == $action) { $delete = true; // Skip this iteration because this is the link we're going back to continue; } // Delete all links after the one we're going back to if ($delete) { unset($tempLinks[$index]); } } if ($delete) { \Session::put('adminHistoryLinks', $tempLinks); // There is no need to insert the current link because it already exists // so just return return; } } $modelConfig = AdminHelper::modelExists($modelName); if ($ignoreRequestForModelName) { $returnModelName = $modelConfig ? $modelConfig->hrName : $modelName; } else { $returnModelName = $modelConfig ? count(\Request::segments()) > 2 && \Request::segment(3) == 'edit' ? $modelConfig->hrName : $modelConfig->hrNamePlural : $modelName; } $links[] = array('link' => $link, 'action' => $action, 'addLink' => $addLink, 'modelConfigName' => $modelConfig ? $modelConfig->name : $modelName, 'modelName' => $returnModelName, 'modelIcon' => $modelConfig && $modelConfig->faIcon ? $modelConfig->faIcon : 'fa-circle'); \Session::put('adminHistoryLinks', $links); }
public static function automatic() { self::$_config = config('breadcrumbs'); $parts = \Request::segments(); $current = ""; foreach ($parts as $part) { $title = str_replace("-", " ", $part); $current .= "/" . $part; if (!in_array($title, self::$_config['except'])) { self::addBreadcrumb($title, url($current)); } } return self::generate(); }
public static function bodyClass() { $bodyClasses = []; $class = ''; if (count(\Request::segments()) === 0) { $bodyClasses[] = 'home'; } else { foreach (\Request::segments() as $segment) { if (is_numeric($segment) || empty($segment)) { continue; } $class .= !empty($class) ? "-" . $segment : $segment; array_push($bodyClasses, $class); } } return !empty($bodyClasses) ? implode(' ', $bodyClasses) : null; }
/** * Store a newly created resource in storage. * POST /users * * @return Response */ public function store() { //if it is api request will get an array with ['api','v1','users'] if (in_array('api', Request::segments())) { $this->saveUser(); return Response::json(['data' => 'User saved'], 200); } //validate try { $data = ['username' => Input::get('username'), 'email' => Input::get('email'), 'password' => Input::get('password'), 'password_confirmation' => Input::get('password_confirmation'), 'telephone' => Input::get('telephone'), 'address' => Input::get('address'), 'city' => Input::get('city')]; Event::fire('user.saving', [$data]); $this->saveUser(); Auth::loginUsingId(User::orderBy('id', 'DESC')->first()->id); return Redirect::to('reservation'); } catch (ValidationException $e) { return Redirect::back()->withInput()->withErrors($e->getErrors()); } }
/** * @return Lang */ public function getCurrentLanguage() { /** * @var Lang[] $languagesList */ $languagesList = $this->getCacheTrait()->cache("allLanguages", 100, function () { return $this->getRepoTrait()->getLangRepository()->all(0, 100); }); $requestSegmentsList = \Request::segments(); foreach ($requestSegmentsList as $segment) { //usually it should be the first segment, but we cannot guarantee foreach ($languagesList as $language) { if (strcmp($segment, $language->getCode()) == 0) { return $language; } } } return null; }
/** * Set CSRF filter on every POST request * * @return void */ public function __construct() { $this->beforeFilter('csrf', array('on' => 'post')); $allowedLang = array('id', 'en'); $lang = Request::segment(1); App::setLocale($lang); if (!in_array($lang, $allowedLang)) { if (strtolower($lang) == 'en') { $lang = 'en'; App::setLocale('en'); } else { $lang = 'id'; App::setLocale('id'); } $segments = Request::segments(); $segments[0] = $lang; Redirect::to(implode('/', $segments))->send(); } }
/** * Api Model Autocaller will try to Access to the Api Model if the method URI is correct * * * @see Api for callableMethods from ApiController * @param string $method * @param array $param * @return \Illuminate\Http\JsonResponse|mixed */ public function __call($method, $param) { $data = Input::all(); $param = array_merge($param, $data); //Auto call to Api Model access if (in_array($method, Api::$callableMethods)) { $param = \Request::segments(); unset($param[0], $param[1], $param[2]); if (count($param)) { $response = call_user_func_array(array("Api", $method), $param); } else { $response = call_user_func_array(array("Api", $method), []); } if (!isset($response['msg'], $response['status'])) { $response = Api::response($response); } return Response::json($response, $response['status']); } }
/** * Bootstrap the application events. * * @return void */ public function boot(Router $router, Setting $adminpanel, PluginContract $plugin) { //add Psr4 namespace if (is_dir($plugin_dir = config('adminpanel.plugins_dir') ? config('adminpanel.plugins_dir') : base_path('plugins'))) { $autoload = (require base_path('vendor/autoload.php')); $autoload->addPsr4('Digitlimit\\Adminpanel\\Plugins\\', $plugin_dir); $autoload->register(); } //these blocks runs only if we are in adminpanel URL if ($adminpanel->isBackend()) { //view share view()->composer('*', AdminpanelDashboardComposer::class); } //register routes include_once __DIR__ . '/Http/routes.php'; include_once __DIR__ . '/Http/helpers.php'; $this->registerProviders($plugin); //use adminpanel authenticator in to adminpanel if (head(\Request::segments()) == config('adminpanel.base_url', 'adminpanel')) { $this->app->register(AdminpanelAuthServiceProvider::class); } //register middleware $this->registerMiddlewares($router); //paths $this->setViewPath(); $this->setPublications(); }
<?php $form = Request::segments()[0]; ?> {{--Message Modal Starts--}} <div class="modal fade" id="messageModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog modal-md" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel">Message About This Report</h4> </div> <form name="messageForm" onsubmit="return validateForm()" action="{{URL::to($form.'/report/send-message')}}" method="post" enctype="multipart/form-data" class="form-small"> <div class="modal-body"> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label for="">Kid Image</label> <input type="file" name="kid_image" id="" class="form-control input-sm"> </div> <div class="form-group"> <label for="">Name</label> <input type="text" name="name" id="" class="form-control input-sm"> </div> <div class="form-group"> <label for="">Mobile</label> <input type="text" placeholder="9888098880" name="mobile" id="" class="form-control input-sm"> </div> <div class="form-group">
/** * Helper that returns the name of a class representing the current page. * See for more: http://laravelsnippets.com/snippets/add-unique-body-id-helper * * @return string * * @deprecated */ function page_class() { $pageClass = preg_replace('/\\d-/', '', implode('-', Request::segments())); $pageClass = str_replace('admin-', '', $pageClass); return !empty($pageClass) && $pageClass != '-' ? $pageClass : 'homepage'; }
/** * Check if a uri resembles a definition, if so return a data object * * @param string $identifier The identifier of a resource * * @return Tdt\Core\Datasets\Data */ public static function fetchData($identifier) { // Retrieve the definition $definition_repo = \App::make('Tdt\\Core\\Repositories\\Interfaces\\DefinitionRepositoryInterface'); $definition = $definition_repo->getByIdentifier($identifier); if ($definition) { // Get the source definition $source_definition = $definition_repo->getDefinitionSource($definition['source_id'], $definition['source_type']); if ($source_definition) { // Create the correct datacontroller $controller_class = 'Tdt\\Core\\DataControllers\\' . $source_definition['type'] . 'Controller'; $data_controller = \App::make($controller_class); // Get REST parameters $uri_segments = \Request::segments(); $rest_parameters = array_diff($uri_segments, array($definition['collection_uri'], $definition['resource_name'])); $rest_parameters = array_values($rest_parameters); // Retrieve dataobject from datacontroller $data = $data_controller->readData($source_definition, $rest_parameters); $data->rest_parameters = $rest_parameters; // REST filtering if ($source_definition['type'] != 'INSTALLED' && count($data->rest_parameters) > 0) { $data->data = self::applyRestFilter($data->data, $data->rest_parameters); } return $data; } else { \App::abort(404, "Source for the definition could not be found."); } } else { \App::abort(404, "The definition could not be found."); } }
| The following filters are used to verify that the user of the current | session is logged into this application. The "basic" filter easily | integrates HTTP Basic authentication for quick, simple checking. | */ Route::filter('auth', function () { if (Auth::guest()) { return Redirect::guest('login'); } }); Route::filter('auth.basic', function () { return Auth::basic(); }); Route::filter('pageControl', function () { if (Auth::check()) { $segments = Request::segments(); //remove parameters foreach ($segments as $key => $value) { if (is_numeric($value)) { unset($segments[$key]); } } $url = implode('/', $segments); if (Auth::user()->profile_type == 'admin') { $allowedUrls = array('inicio', 'cambiarContrasena', 'usuarios', 'productos', 'productos/cargarProductosProveedor', 'productos/stock', 'distribuidores', 'distribuidoresProductos', 'pedidos', 'ajustes', 'alertas'); } else { $allowedUrls = array('inicio', 'cambiarContrasena', 'productos', 'productos/cargarProductosProveedor', 'distribuidores', 'distribuidoresProductos', 'pedidos', 'alertas'); } if (!in_array($url, $allowedUrls)) { return Redirect::to('inicio'); }
/** * Raise a 404 error and load our custom 404 message with navigation * * WARNING: DEPRECIATED!!! WILL BE REMOVED IN 1.0 RELEASE! * Should be done in your Page model, See Page.php in samples */ public static function raise404() { $nav = new LaraPagesController(); $nav = $nav->walk(null, 0, \Request::segments(), '/'); return Response::view(config('larapages.views.404', 'laraPages::main.404'), ['nav' => $nav], 404); }
/** * Get the validation rules that apply to the request. * * @author Dung Le * * @return array rules */ public function rules() { // Common rules $arrRet = parent::rules(); $segment = \Request::segments()[2]; $arrRet['ext1'] = 'catalog_in:name'; $arrRet['ext2'] = 'catalog_in:name'; $arrRet['ext3'] = 'catalog_in:name'; if ($segment == 'confirm') { $arrRet['ext1'] = 'catalog_in:key'; $arrRet['ext2'] = 'catalog_in:key'; $arrRet['ext3'] = 'catalog_in:key'; } // Get request catalog item $item = \Request::route()->parameters()['catalogItem']; switch ($item) { // extends validate form senior case 'senior': $arrRet['age'] = ''; $arrRet['sex'] = ''; $arrRet['job'] = ''; $arrRet['ext6'] = 'max:100|not_taboo'; $arrRet['ext7'] = 'max:100|not_taboo'; $arrRet['ext8'] = 'max:100|not_taboo'; $arrRet['ext9'] = 'in:' . implode(',', \Config::get('constants.SCHEDULE_OPEN_TIME')); break; case 'main_sm': case 'spsex_sm': case '20heim_sm': $this->setRulesForSP($arrRet); break; // other rules // other rules default: $arrRet['ext7'] = 'required|in:' . implode(',', \Config::get('constants.MAIL_FLG')); $arrRet['ext8'] = 'required|max:200|in:' . implode(',', \Config::get('constants.SHIPMENT_TIME')); $arrRet['ext41'] = 'required|group_in:' . implode(',', \Config::get('constants.SITUATION')); $arrRet['ext9'] = 'in:' . \Config::get('constants.FAMILY')[0]; $arrRet['ext10'] = 'in:' . \Config::get('constants.FAMILY')[1]; $arrRet['ext11'] = 'in:' . \Config::get('constants.FAMILY')[2]; $arrRet['ext12'] = 'in:' . \Config::get('constants.FAMILY')[3]; $arrRet['ext13'] = 'in:' . \Config::get('constants.FAMILY')[4]; $arrRet['ext14'] = 'in:' . \Config::get('constants.FAMILY')[5]; $arrRet['ext20'] = 'max:50|not_taboo'; $arrRet['ext15'] = 'digits_between:1,2|integer|min:0'; $arrRet['ext16'] = 'digits_between:1,2|integer|min:0'; $arrRet['ext17'] = 'digits_between:1,3|integer|min:0'; $arrRet['ext18'] = 'in:' . implode(',', \Config::get('constants.BUILD_CLASS')); $arrRet['ext19'] = 'in:' . implode(',', \Config::get('constants.BUILD_PLAN')); $arrRet['ext21'] = 'in:' . implode(',', \Config::get('constants.BUILD_PLAN_AREA21')); $arrRet['ext22'] = 'in:' . implode(',', \Config::get('constants.BUILD_PLAN_AREA22')); $arrRet['ext23'] = 'in:' . implode(',', \Config::get('constants.BUDGET')); $arrRet['ext24'] = 'in:' . implode(',', \Config::get('constants.BUDGET')); $arrRet['ext25'] = 'in:' . implode(',', \Config::get('constants.BUILD_PLAN_AREA22')); $arrRet['ext27'] = 'digits_between:1,10|integer_extend|min:0'; $arrRet['ext28'] = 'in:' . implode(',', \Config::get('constants.REQUEST_LAYOUT')); $arrRet['ext78'] = 'in:' . \Config::get('constants.INTEREST')[0]; $arrRet['ext79'] = 'in:' . \Config::get('constants.INTEREST')[1]; $arrRet['ext80'] = 'in:' . \Config::get('constants.INTEREST')[2]; $arrRet['ext81'] = 'in:' . \Config::get('constants.INTEREST')[3]; $arrRet['ext82'] = 'in:' . \Config::get('constants.INTEREST')[4]; $arrRet['ext83'] = 'max:4000|not_taboo'; $arrRet['important'] = 'size:3|group_in:' . implode(',', \Config::get('constants.IMPORTANT')); $arrRet['ext84'] = 'in:' . implode(',', \Config::get('constants.IMPORTANT')); $arrRet['ext85'] = 'in:' . implode(',', \Config::get('constants.IMPORTANT')); $arrRet['ext86'] = 'in:' . implode(',', \Config::get('constants.IMPORTANT')); break; } return $arrRet; }
</ul> </li> </ul> </aside> <!-- Right sidebar --> <aside></aside> <!-- Main section --> <section class="wrap-content" role="main" style="height:800px;"> <div class="content-header clearfix"> <?php $last = count(Request::segments()); ?> @if ($last >1) <h4>{{ucfirst(Request::segment($last))}}</h4> @else <h4>Dashboard</h4> @endif <ol class="breadcrumb"> <li> <i class="fa fa-home"></i> <a href="">Dashboard</a> </li> @for($i = 2; $i <= count(Request::segments()); $i++) <li> <i class="fa fa-angle-right"></i>
function getHereWithLang($lang) { $segments = Request::segments(); $segments[0] = $lang; return implode('/', $segments); }
public static function getPath() { return implode("/", Request::segments()); }
/** * Bootstrap the application events. * * @return void */ public function boot() { $this->package('gxela/leback-auth'); \Auth::extend('leback-auth', function () { $routes = \Config::get('leback-auth::model_routes'); $url = implode('/', \Request::segments()); $model = \Config::get('auth.model'); $name = last(explode('\\', $model)); $prefix = null; $route = null; //$provider = '\Gxela\LebackAuth\Providers\LebackAuthGenericProvider'; $guard = '\\Gxela\\LebackAuth\\Guards\\LebackAuthGenericGuard'; foreach ($routes as $route => $_model) { $route = explode('/', $route); $prefix = array_shift($route); if (starts_with($url, $prefix)) { $model = $_model; $name = last(explode('\\', $model)); $guard = '\\Gxela\\LebackAuth\\Guards\\LebackAuth' . $name . 'Guard'; //$provider = '\Gxela\LebackAuth\Providers\LebackAuth'.$name.'Provider'; break; } } return new $guard(new \Gxela\LebackAuth\Providers\LebackAuthGenericProvider(new BcryptHasher(), $model), \App::make('session.store')); }); }