/** * Create a new controller instance. * * @return void */ public function __construct(Request $request) { $this->middleware('guest'); $lang = $request->route()->parameter('lang'); View::composer('auth.register', function ($view) use($lang) { $view->with('countries', Country::withTranslation()->get()); }); $this->loginPath = route('sign in', $request->route()->parameters()); }
/** * @param int $total Total items * @param int $limit Items limit per page, if not set the config value will be used * @param int $current If not set, it will be auto detected * * @uses Request::current * @uses Kohana::$config */ public function __construct($total, $limit = null, $current = null) { $this->request(Request::current()); $this->route($this->_request->route()); $this->_route_params = array('directory' => $this->_request->directory(), 'controller' => $this->_request->controller(), 'action' => $this->_request->action()) + $this->_request->param(); $this->_config = Kohana::$config->load('pagination'); if ($current === null) { $this->_current = (int) $this->_detect_current_page(); } else { $this->_current = (int) $current; } $this->_total = (int) $total; $this->_limit = (int) $limit ? $limit : $this->_config->limit; }
public function buildNavMenu() { $buildNavMenu = '<div class="col-sm-3 col-md-2 sidebar">'; $activePage = \Request::route()->getPath(); //basename($_SERVER['PHP_SELF']); $header_count = 0; $menuItems = file('menu_items.txt'); foreach ($menuItems as $menuItem) { $nav = explode(":", $menuItem); $page = trim($nav[0]); $link = trim($nav[1]); //if($link == 'Header'){ if (starts_with($link, 'Header')) { if ($header_count >= 1) { $buildNavMenu = $buildNavMenu . '</ul>'; } $buildNavMenu = $buildNavMenu . '<ul class="nav nav-sidebar">'; $buildNavMenu = $buildNavMenu . '<li><a href="' . substr($link, 7) . '">' . $page . '</a></li>'; $header_count++; } elseif ($link == $activePage) { $buildNavMenu = $buildNavMenu . '<li class="active"><a>' . $page . '</a></li>'; } else { $buildNavMenu = $buildNavMenu . '<li><a href="' . $link . '">' . $page . '</a></li>'; } } $buildNavMenu = $buildNavMenu . '</ul></div>'; return $buildNavMenu; }
protected function detectInformation() { $arrInfo = ['main' => ['table' => 'prj02_table0001', 'platform' => 1], 'rakunoie' => ['table' => 'prj02_table0001', 'platform' => 1], 'desio' => ['table' => 'prj02_table0001', 'platform' => 1], 'zeroclub' => ['table' => 'prj02_table0001', 'platform' => 1], 'bj_basic' => ['table' => 'prj02_table0001', 'platform' => 1], 'doctorsair' => ['table' => 'prj02_table0001', 'platform' => 1], 'lifestylenavi' => ['table' => 'prj02_table0001', 'platform' => 1], 'kaiteki' => ['table' => 'prj02_table0001', 'platform' => 1], 'nisetai2' => ['table' => 'prj02_table0001', 'platform' => 1], 'doctors_kids' => ['table' => 'prj02_table0001', 'platform' => 1], 'doctors_plan' => ['table' => 'prj02_table0001', 'platform' => 1], 'crescasa' => ['table' => 'prj02_table0006', 'platform' => 1], 'vtoheim' => ['table' => 'prj02_table0036', 'platform' => 1], 'spsex' => ['table' => 'prj02_table0037', 'platform' => 1], 'kageyama' => ['table' => 'prj02_table0039', 'platform' => 1], 'snowpeak' => ['table' => 'prj02_table0040', 'platform' => 1], 'attaka' => ['table' => 'prj02_table0041', 'platform' => 1], 'neostory' => ['table' => 'prj02_table0042', 'platform' => 1], 'senior' => ['table' => 'prj02_table0034', 'platform' => 1], 'main_sm' => ['table' => 'prj02_table0001', 'platform' => 2], 'spsex_sm' => ['table' => 'prj02_table0038', 'platform' => 2], '20heim_sm' => ['table' => 'prj02_table0043', 'platform' => 2], 'cart' => ['table' => 'prj02_table0001', 'platform' => 3], '43up' => ['table' => 'prj02_table0001', 'platform' => 1]]; $arrParameters = \Request::route()->parameters(); if (!isset($arrParameters['catalogItem']) || !in_array($arrParameters['catalogItem'], array_keys($arrInfo))) { abort(404); } // fillable attributes switch ($arrParameters['catalogItem']) { case 'senior': $arrFillable = ['ext6', 'ext7', 'ext8', 'ext9']; break; case '43up': $arrFillable = ['ext6', 'ext8', 'ext18', 'ext19', 'ext20', 'ext21', 'ext23', 'ext24', 'ext25', 'ext29', 'ext30', 'ext31', 'ext32', 'ext33', 'ext34', 'ext35', 'ext36', 'ext37', 'ext38', 'ext39', 'ext40']; break; default: $arrFillable = ['ext6', 'ext7', 'ext8', 'ext9', 'ext41', 'ext42', 'ext10', 'ext11', 'ext12', 'ext13', 'ext14', 'ext15', 'ext16', 'ext17', 'ext18', 'ext19', 'ext20', 'ext21', 'ext22', 'ext23', 'ext24', 'ext25', 'ext27', 'ext28', 'ext78', 'ext79', 'ext80', 'ext81', 'ext82', 'ext84', 'ext85', 'ext86', 'ext83', 'important', 'email_confirmation']; break; } $this->fillable = array_merge($this->fillable, $arrFillable); /* other attributes */ // Set table $this->table = $arrInfo[$arrParameters['catalogItem']]['table']; // attributes for load csv $this->platform = $arrInfo[$arrParameters['catalogItem']]['platform']; $this->platformName = $this->platform == 2 ? 'catalog_mobile' : 'catalog'; }
/** * Pass dynamicFields to view * * @param $view * @return mixed */ private function assignDynamicFieldsToPageObject($view) { $entityDynamic = null; $data = $view->getData(); //TODO Fix with event if (count($data)) { $arrType = config('asgard.dynamicfield.config.entity-type'); $arrType = array_keys($arrType); // edit entity foreach ($data as $item) { if (is_object($item)) { $className = get_class($item); if (in_array($className, $arrType)) { $entityDynamic = $item; break; } } } } // initial model data for create new; if (is_null($entityDynamic)) { $router = \Request::route()->getName(); $arrCreateRouter = config('asgard.dynamicfield.config.router'); if (array_key_exists($router, $arrCreateRouter)) { $entityDynamic = new $arrCreateRouter[$router](); } } $view->with('entityDynamic', $entityDynamic); return $view; }
/** * @param $parameters */ protected function readDbObjectForInjection($parameters) { /** @var Route $route */ $route = \Request::route(); $object = null; foreach ($parameters as $key => $value) { if ($value instanceof CmfDbObject) { // get only last object in params $object = $value; } } if (!empty($object)) { $id = $route->parameter('id', false); if ($id === false && \Request::method() !== 'GET') { $id = \Request::get('id', false); } if (empty($id)) { $this->sendRecordNotFoundResponse(); } $conditions = ['id' => $id]; $this->addConditionsForDbObjectInjection($route, $object, $conditions); $this->addParentIdsConditionsForDbObjectInjection($route, $object, $conditions); $object->find($conditions); if (!$object->exists()) { $this->sendRecordNotFoundResponse(); } } }
protected function loadCrudSubtitle() { list($controller, $action) = explode('@', \Request::route()->getAction()['uses']); if ($this->subtitle === null) { if (array_search($action, ['create', 'edit', 'index']) !== FALSE) { $this->subtitle = trans('crud.' . $action); } } }
function current_route($property = null) { $route = Request::route(); switch ($property) { case 'name': return $route->getName(); } return $route; }
/** * Get user country from session. * @param string $routeName name of route to check * @param bool $firstOccurrence active to find first occurrence of route, this method is valid to active menu on subsections * @return boolean */ function active_menu($routeName, $firstOccurrence = false) { if ($firstOccurrence) { return strpos(Request::url(), route($routeName)) === 0; } else { if (Request::route() !== null) { return Request::route()->getName() == $routeName; } } }
public function set($key = '', $current_url = '') { if (empty($key)) { $key = \Request::route()->getName(); } if (empty($current_url)) { $current_url = \Request::fullUrl(); } $session_key = $this->session_key($key); \Session::put($session_key, $current_url); }
/** * Get object of Response. * * @param string $packageRoot * @param Request $request * * @return Response|null */ public function getResponse($packageRoot, Request $request) { $packageRoot = rtrim($packageRoot, '/'); $path = $packageRoot . '/Route/' . $request->route() . '/' . $request->method() . '.php'; if (file_exists($path)) { require $path; $controllerClass = $request->package() . '\\Route_' . str_replace('/', '_', $request->route()) . '\\' . $request->method(); /** * @var BaseController $controller */ $controller = new $controllerClass($packageRoot, $request); /** * Call handler. */ $handler = $_POST['handler'] ?? $_GET['handler'] ?? 'index'; if (preg_match('/[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*/', $handler) && method_exists($controllerClass, $handler)) { $controller->{$handler}(); return $controller->getResponse(); } } return null; }
public static function process(Request $request, HttpResponse $response) { $route = $request->route($_SERVER['REQUEST_URI']); $route = array_merge(self::$_defaultRoute, $route); if (!file_exists($path = FrontController::$dirname . '/controllers/' . ucfirst($route['module']) . 'Controller.php')) { echo $path; throw new ControleurIntrouvableException('Controller not found!'); } require_once $path; $class = ucfirst($route['module']) . 'Controller'; $controller = new $class($request, $response); $controller->_moduleName = $route['module']; return $controller->launch($route['action']); }
protected function detectInformation() { $arrInfo = ['inquire' => ['main' => ['table' => 'prj02_table0002', 'fillable' => array_merge($this->fillable, ['ext53'])], 'estate' => ['table' => 'prj02_table0002', 'fillable' => array_merge($this->fillable, ['ext53'])], 'others' => ['table' => 'prj02_table0002', 'fillable' => array_merge($this->fillable, ['ext53'])], 'member' => ['table' => 'prj02_table0003', 'fillable' => array_merge($this->fillable, ['ext53', 'ext54', 'ext55', 'ext56', 'ext59', 'ext60', 'ext61', 'ext62', 'ext6', 'ext63'])], 'contact' => ['table' => 'prj02_table0004', 'fillable' => array_merge($this->fillable, ['ext7', 'ext8', 'ext18', 'ext19', 'ext25', 'ext29', 'ext30', 'ext32', 'ext33', 'ext35', 'ext50', 'ext51', 'ext53', 'ext60', 'ext74', 'ext75', 'ext76', 'ext77'])], 'air_comf' => ['table' => 'prj02_table0027', 'fillable' => array_merge($this->fillable, ['ext8', 'ext9', 'ext10', 'ext11', 'ext12', 'ext13', 'ext14', 'ext15', 'ext16', 'ext17', 'ext18', 'ext19', 'ext20', 'ext21', 'ext22', 'ext23', 'ext24', 'ext25', 'ext27', 'ext28', 'ext41', 'ext42', 'ext43', 'ext78', 'ext79', 'ext80', 'ext81', 'ext82', 'ext83', 'ext84', 'ext85', 'ext86', 'important'])], 'senior' => ['table' => 'prj02_table0033', 'fillable' => array_merge($this->fillable, ['ext53', 'ext6', 'ext7', 'ext8'])], 'main_sm' => ['table' => 'prj02_table0002', 'fillable' => array_merge($this->fillable, ['ext52', 'ext53'])]], 'mailmag' => ['main_sm' => ['table' => 'prj02_table0011', 'fillable' => ['uid', 'form', 'email1']]]]; $arrParameters = \Request::route()->parameters(); /* if (! isset($arrParameters['item']) || ! isset($arrParameters['slug']) || ! isset($arrInfo[ $arrParameters['slug'] ][ $arrParameters['item'] ]) ) { abort(404); } */ $arrInfo = $arrInfo[$arrParameters['slug']][$arrParameters['item']]; $this->table = $arrInfo['table']; $this->fillable = $arrInfo['fillable']; }
function get_css_class_for_page($type) { $array = ['nid', 'token']; $paths = Request::route(); $path = $paths->uri(); $cssClass = implode(' ', explode('/', $path)); foreach ($array as $value) { if (preg_match('/(\\W|^)({' . $value . '})(\\W|$)/', $path)) { $path = str_replace($value, $paths->parameters()[$value], $path); } } $path = clean_character($path); $cssClass = clean_character($cssClass, 'page'); return $cssClass . ' ' . $type . '-' . $path; }
public function getPage() { // $route = $request->route(); // $name = $route->getName(); $page = \Request::route()->getName(); $topics = Topic::all(); $resources = Resource::all(); $data = ["topics" => $topics, "resources" => $resources]; // return $data["topics"]; if ($page) { return view("admin.{$page}", $data); } else { return redirect('/admin', $data); } }
function common_title() { $picked = null; $route = Request::route(); if ($route) { $routeName = $route->getName(); $page = Lang::get("pages.{$routeName}"); if ($page != $routeName) { $picked = $page; } } if ($picked == null) { $picked = Lang::get('pages.home'); } return is_array($picked) ? @$picked['index'] ?: first($picked) : $picked; }
public function testPostJson() { $r = new Request(['url' => 'api/tasks/12.json', 'filter' => 'all'], ['HTTP_ACCEPT' => 'application/json;q=0.8', 'REQUEST_URI' => '/api/tasks/12.json?filter=all', 'REQUEST_METHOD' => 'POST'], ['url' => 'api/tasks/12.json', 'filter' => 'all'], ['title' => 'New Title']); $this->assertTrue($r instanceof Request); $this->assertEquals(Request::POST, $r->method()); $this->assertEquals('api/tasks/12.json', $r->url()); $this->assertEquals('json', $r->type()); $this->assertEquals('all', $r->param('filter')); $route = $r->route(); $this->assertTrue($route instanceof Route); $result = $r->response(); $this->assertTrue($result instanceof Response); $this->assertEquals("New Title", $r->param('title')); $expected = ['filter' => 'all']; $result = $r->query(); $this->assertEquals($expected, $result); }
function controller($name = NULL, $return = NULL) { return true; if (empty($name) && empty($return)) { return NULL; } $controller = explode('\\', strtolower(Request::route()->getActionName())); list($controller, $action) = explode('@', str_replace('controller', '', array_pop($controller))); $name = strtolower($name); if (strpos($name, '@') !== FALSE) { list($ifc, $ifa) = explode('@', $name); $result = $ifc == $controller && $ifa == $action; } else { $result = $name == $controller; } if ($result && !is_null($return)) { return $return; } return $result; }
/** * Page constructor. * * Analyze the request url to convert to a view template * * @param Request $request * @param array $config */ public function __construct(Request $request, array $config = []) { $this->_request = $request; $this->_config = $config; $this->_type = $request->type(); $this->_url = $request->route()->url; // @TODO find a different way to do this $parts = \explode('/', $this->_url); $last = \array_slice($parts, -1, 1, true); unset($parts[key($last)]); $this->_path = $parts; $this->_view = current($last); $period = strrpos($this->_view, '.'); if ($period) { $type = substr($this->_view, $period + 1); if (in_array($type, $this->_validTypes)) { $this->_type = $type; $this->_view = substr($this->_view, 0, $period); } } }
/** * Bootstrap any application services. * * @return void */ public function boot() { view()->composer('*', function ($view) { $current_route_name = \Request::route()->getName(); $view->with('current_route_name', $current_route_name); }); $data = WpApi::category_posts('karya', -1); //return $data; // $url = 'http://wp.syaifulgaribaldi.com/wp-json/posts?filter[posts_per_page]=-1&filter[category_name]=karya'; // $json = file_get_contents($url); // $query = json_decode($json); //var_dump($query[0]->date); // $iteration = count($query); //var_dump($iteration); // $karya = array(); // for ($i=0; $i < $iteration; $i++) { // $karya[] = array('judul' => $query[$i]->title, 'slug'=>$query[$i]->slug ); // } // $countKarya = count($karya); view()->share(['karya' => $data['results']]); }
public function generateMenu($lists, $parent = 0) { $output = ''; foreach ($lists as $key => $item) { if (has_cap($item->permission)) { if ($item->parent == $parent) { $route = $item->route ? route($item->route) : ''; $active = \Request::route()->getName() == $item->route ? ' active ' : ''; if ($item->has_child()) { $output .= '<li class="has-child ' . $active . '">'; $output .= '<a href="' . $route . '">' . '<i class="fa ' . $item->icon . '"> </i> ' . '<span> ' . $item->name . '</span> ' . '<i class="fa fa-angle-right pull-right"> </i></a>'; unset($lists[$key]); $output2 = $this->generateMenu($lists, $item->id); $output .= '<ul class="menu-child">' . $output2 . '</ul>'; } else { $output .= '<li class="' . $active . '">'; $output .= '<a href="' . $route . '">' . '<i class="fa ' . $item->icon . '"> </i> ' . '<span> ' . $item->name . '</span> ' . '</a>'; unset($lists[$key]); } $output .= '</li>'; } } } return $output; }
function space() { return ltrim(Request::route()->getPrefix(), '/') ?: 'public'; }
$permissions = new \Permissions\Check(\Request::route(), $controller); if (!Bundle::exists('auth')) { return; } // Fix route bundle if // its an administration route $uri = Request::route()->uri; $uri_parts = explode('/', $uri); // check if is set // check if first part is administration uri // check if is not only the dashboard http://site.com/[admin] if (isset($uri_parts['0']) and $uri_parts['0'] = ADM_URI and count($uri_parts) > 1) { unset($uri_parts['0']); $uri = implode('/', $uri_parts); Request::route()->bundle = Bundle::handles($uri); $controller->bundle = Request::route()->bundle; } $result = $permissions::can(Auth::user()); if (isset($result)) { if (!$result->is_allowed) { if (Request::ajax()) { return 'not permited'; } else { return \Response::error('401', get_object_vars($result)); } } } else { if (Request::ajax()) { return View::make('permissions::partials.ajax_not_authorized_page_details')->render(); } else { $data = array('username' => Auth::user()->avatar_first_name . ' ' . Auth::user()->avatar_last_name, 'group' => Auth::user()->group->name, 'role' => 'unknown');
*/ unset($input[Request::spoofer]); Input::$input = $input; //Compatibility hack set_log4php_env('ls_log_file', \Config::get('env.log_path') . '/content.log'); \Logger::configure(\Config::get('log4php')); /** * Route the request to the proper route in the application. If a * route is found, the route will be called with the current request * instance. If no route is found, the 404 response will be returned * to the browser. */ Routing\Filter::register(require APP_PATH . 'filters' . EXT); $loader = new Routing\Loader(APP_PATH, ROUTE_PATH); $router = new Routing\Router($loader, CONTROLLER_PATH); IoC::instance('laravel.routing.router', $router); Request::$route = $router->route(Request::method(), URI::current()); if (!is_null(Request::$route)) { $new_relic->name_transaction(Request::$route->key); try { $response = Request::$route->call(); } catch (\Exception $e) { $handler($e); } } else { $new_relic->name_transaction('404'); \Laravel\Routing\Filter::run(array('before'), array(), true); $response = \Response::json(['msg' => 'Not found'], 404); \Laravel\Routing\Filter::run(array('after'), array($response), true); } $response->send();
/** * Do customs validate * * @author Dung Le * * @param object objValidate * @return void */ protected function validateCustom(&$objValidate) { // Check validate extends $this->checkItem($objValidate); // check total family member $item = \Request::route()->parameters()['catalogItem']; switch ($item) { case 'senior': break; case 'main_sm': case 'spsex_sm': case '20heim_sm': $sum = $this->calFamilyMember(); if ($sum != \Input::get('ext17') || \Input::get('ext15') > 20 || \Input::get('ext16') > 20) { $this->addErrorCustom($objValidate, 'ext17', 'sum_incorrect'); } break; default: $sum = $this->calFamilyMember(); if ($sum != \Input::get('ext17')) { $this->addErrorCustom($objValidate, 'ext17', 'sum_incorrect'); } break; } }
@include('layouts.sidebar-admin') @else @include('layouts.sidebar') @endrole <!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <!-- Content Header (Page header) --> <section class="content-header"> <h1> {{ $page_title or "Page Title" }} <small>{{ $page_description or null }}</small> </h1> <!-- You can dynamically generate breadcrumbs here --> <ol class="breadcrumb"> <?php $path = \Request::route()->getPath(); $path = explode('/', $path); $max = count($path) - 1; ?> @foreach($path as $index => $name) @if($max == $index) <li class="active" >{{ $name }}</li> @else <li><a href="#">@if($index == 0) <i class="fa fa-dashboard"></i> @endif{{ $name }}</a></li> @endif @endforeach </ol> </section> <!-- Main content --> <section class="content">
public function toggle($id, $permission_type, Request $request) { if ($id <= 1) { return \Redirect::back(); } $params = array_keys(\Request::route()->parameters()); $permissions = $request->all(); if (strpos($permission_type, 'management') === false) { $provider = $this->permissionsProvider; } else { $provider = $this->permissionManagementProvider; } $type = $params[0]; switch ($type) { case 'user': $provider->toggleUserPermission($id, $permissions['entity']); \Flash::success(trans('sentinel/permission.toggled')); break; case 'group': $provider->toggleGroupPermission($id, $permissions['entity']); \Flash::success(trans('sentinel/permission.toggled')); break; } \Event::fire(new PermissionUpdated($permission_type, $id)); return \Redirect::back(); }
/** * Sets the operations params from the url */ private function _set_params() { // Get values from request $params = \Request::route('params'); $filepath = $this->config['abs_path'] . '/' . \Request::route('imagepath'); // echo $params; exit; // If enforcing params, ensure it's a match if ($this->config['enforce_presets'] and !in_array($params, $this->config['presets'])) { throw new HTTP_Exception_404('The requested URL :uri was not found on this server.', array(':uri' => Request::$current->uri())); } $image = new Image(); $image->configure(config('image')); $this->image = $image->make($filepath); // The parameters are separated by hyphens $raw_params = explode('-', $params); // Update param values from passed values foreach ($raw_params as $raw_param) { $name = $raw_param[0]; $value = substr($raw_param, 1, strlen($raw_param) - 1); if ($name == 'c') { $this->url_params[$name] = TRUE; // When croping, we must have a width and height to pass to imagecreatetruecolor method // Make width the height or vice versa if either is not passed if (empty($this->url_params['w'])) { $this->url_params['w'] = $this->url_params['h']; } if (empty($this->url_params['h'])) { $this->url_params['h'] = $this->url_params['w']; } } elseif (key_exists($name, $this->url_params)) { // Remaining expected params (w, h, q) $this->url_params[$name] = $value; } else { // Watermarks or invalid params $this->url_params[$raw_param] = $raw_param; } } // Do not scale up images if (!$this->config['scale_up']) { if ($this->url_params['w'] > $this->image->width()) { $this->url_params['w'] = $this->image->width(); } if ($this->url_params['h'] > $this->image->height()) { $this->url_params['h'] = $this->image->height(); } } // Must have at least a width or height if (empty($this->url_params['w']) and empty($this->url_params['h'])) { throw new HTTP_Exception_404('The requested URL :uri was not found on this server.', array(':uri' => Request::$current->uri())); } // Set the url filepath $this->source_file = $filepath; }
*/ Routing\Router::register('*', '(:all)', function () { return Event::first('404'); }); /* |-------------------------------------------------------------------------- | Route The Incoming Request |-------------------------------------------------------------------------- | | Phew! We can finally route the request to the appropriate route and | execute the route to get the response. This will give an instance | of the Response object that we can send back to the browser | */ $uri = URI::current(); Request::$route = Routing\Router::route(Request::method(), $uri); $response = Request::$route->call(); /* |-------------------------------------------------------------------------- | Persist The Session To Storage |-------------------------------------------------------------------------- | | If a session driver has been configured, we will save the session to | storage so it is avaiable for the next request. This will also set | the session cookie in the cookie jar to be sent to the user. | */ if (Config::get('session.driver') !== '') { Session::save(); } /*
/** * Fire an event for the current route. * * @param array $payload */ protected function fireEvent($payload = []) { Event::fire(Request::route(), $payload); }