Exemplo n.º 1
1
 /**
  * @param array $parameters
  *
  * @return string
  */
 public static function render(array $parameters)
 {
     list($sortColumn, $sortParameter, $title, $queryParameters) = self::parseParameters($parameters);
     $title = self::applyFormatting($title);
     $icon = Config::get('columnsortable.default_icon_set');
     foreach (Config::get('columnsortable.columns') as $value) {
         if (in_array($sortColumn, $value['rows'])) {
             $icon = $value['class'];
         }
     }
     if (Request::get('sort') == $sortParameter && in_array(Request::get('order'), ['asc', 'desc'])) {
         $icon .= Request::get('order') === 'asc' ? Config::get('columnsortable.asc_suffix', '-asc') : Config::get('columnsortable.desc_suffix', '-desc');
         $direction = Request::get('order') === 'desc' ? 'asc' : 'desc';
     } else {
         $icon = Config::get('columnsortable.sortable_icon');
         $direction = Config::get('columnsortable.default_direction_unsorted', 'asc');
     }
     $iconAndTextSeparator = Config::get('columnsortable.icon_text_separator', '');
     $clickableIcon = Config::get('columnsortable.clickable_icon', false);
     $trailingTag = $iconAndTextSeparator . '<i class="' . $icon . '"></i>' . '</a>';
     if ($clickableIcon === false) {
         $trailingTag = '</a>' . $iconAndTextSeparator . '<i class="' . $icon . '"></i>';
     }
     $anchorClass = self::getAnchorClass();
     $queryString = http_build_query(array_merge($queryParameters, array_filter(Request::except('sort', 'order', 'page')), ['sort' => $sortParameter, 'order' => $direction]));
     return '<a' . $anchorClass . ' href="' . url(Request::path() . '?' . $queryString) . '"' . '>' . htmlentities($title) . $trailingTag;
 }
Exemplo n.º 2
0
 function show()
 {
     //        dd(Page::all()->toArray());
     $page = Page::orWhere(function ($query) {
         $query->where('url', '=', Request::path());
     })->orWhere(function ($query) {
         $query->where('url', '=', '/' . Request::path());
     })->orWhere(function ($query) {
         $query->where('url', '=', Request::url());
     })->orWhere(function ($query) {
         $query->where('url', '=', Request::route()->getPath());
     })->orWhere(function ($query) {
         $query->where('url', '=', '/' . Request::route()->getPath());
     })->get()->first();
     $ps = Post::where('page_id', '=', $page->id)->orderBy('sort', 'ASC')->orderBy('id', 'ASC')->get();
     $posts = [];
     foreach ($page->template()->first()->sections() as $sec) {
         $posts[$sec->name] = [];
     }
     foreach ($ps as $p) {
         $posts[$p->section()->first()->name][] = $p;
     }
     $pages = [];
     foreach (Page::all() as $pi) {
         $pages[$pi->name] = $pi;
     }
     $fn = str_replace('.blade.php', '', $page->template()->first()->filename);
     return View::make("aui/templates/" . $fn)->with('posts', $posts)->with('pages', $pages)->with('page', $page);
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app['router']->before(function ($request) {
         // First clear out all "old" visitors
         Visitor::clear();
         $page = Request::path();
         $ignore = Config::get('visitor-log::ignore');
         if (is_array($ignore) && in_array($page, $ignore)) {
             //We ignore this site
             return;
         }
         $visitor = Visitor::getCurrent();
         if (!$visitor) {
             //We need to add a new user
             $visitor = new Visitor();
             $visitor->ip = Request::getClientIp();
             $visitor->useragent = Request::server('HTTP_USER_AGENT');
             $visitor->sid = str_random(25);
         }
         $user = null;
         $usermodel = strtolower(Config::get('visitor-log::usermodel'));
         if (($usermodel == "auth" || $usermodel == "laravel") && Auth::check()) {
             $user = Auth::user()->id;
         }
         if ($usermodel == "sentry" && class_exists('Cartalyst\\Sentry\\SentryServiceProvider') && Sentry::check()) {
             $user = Sentry::getUser()->id;
         }
         //Save/Update the rest
         $visitor->user = $user;
         $visitor->page = $page;
         $visitor->save();
     });
 }
Exemplo n.º 4
0
 /**
  * Ensure user is logged in
  *
  * @return
  */
 public function auth()
 {
     if (!$this->auth->check()) {
         $redirect = '?redirect=' . urlencode(Request::path());
         return Redirect::to('/auth/login' . $redirect)->with('error_message', Lang::get('messages.login_access_denied'));
     }
 }
 /**
  * Register the application services.
  *
  * @return void
  */
 public function register()
 {
     $configPath = __DIR__ . '/../config/sql-logging.php';
     $this->mergeConfigFrom($configPath, 'sql-logging');
     if (config('sql-logging.log', false)) {
         Event::listen('illuminate.query', function ($query, $bindings, $time) {
             $data = compact('bindings', 'time');
             // Format binding data for sql insertion
             foreach ($bindings as $i => $binding) {
                 if ($binding instanceof \DateTime) {
                     $bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
                 } else {
                     if (is_string($binding)) {
                         $bindings[$i] = "'{$binding}'";
                     }
                 }
             }
             // Insert bindings into query
             $query = str_replace(array('%', '?'), array('%%', '%s'), $query);
             $query = vsprintf($query, $bindings);
             $log = new Logger('sql');
             $log->pushHandler(new StreamHandler(storage_path() . '/logs/sql-' . date('Y-m-d') . '.log', Logger::INFO));
             // if log request data
             if (config('sql-logging.log_request', false)) {
                 $data['request_path'] = Request::path();
                 $data['request_method'] = Request::method();
                 $data['request_data'] = Request::all();
             }
             // add records to the log
             $log->addInfo($query, $data);
         });
     }
 }
Exemplo n.º 6
0
 private function hasAccess()
 {
     $patterns_quoted = preg_quote($this->block->exception, '/');
     $to_replace = ['/(\\r\\n?|\\n)/', '/\\\\\\*/'];
     $replacements = ['|', '.*'];
     $regexpPatter = '/^(' . preg_replace($to_replace, $replacements, $patterns_quoted) . ')$/';
     return (bool) preg_match($regexpPatter, Request::path());
     return true;
 }
Exemplo n.º 7
0
/**
 * Permet d'ajouter la classe active en fonction de la route
 * @param $path
 * @return bool|string
 */
function active($path)
{
    $request = \Illuminate\Support\Facades\Request::path();
    $match = $request === '/' ? '/' : explode('/', $request)[0];
    if ($match === $path) {
        return "class='active'";
    }
    return false;
}
Exemplo n.º 8
0
 private function item(&$item)
 {
     $tpm = array_search(Request::path(), array_column($item['sub'], 'route'));
     if ($tpm !== false) {
         $item['active'] = 'active open';
         $item['open'] = 'open';
         $item['display'] = 'block';
         $item['sub'][$tpm]['active'] = 'active';
     }
 }
Exemplo n.º 9
0
 public function getHtmlCss($cssfiles)
 {
     $files = is_array($cssfiles) ? $cssfiles : func_get_args();
     $cacheKey = CssKeys::getSingleKey(Request::path());
     if (Cache::has($cacheKey)) {
         $cssoutput = Cache::get($cacheKey);
         return $this->getAsyncStylesheet($cssoutput, $files);
     } else {
         return $this->getStylesheetLink($files);
     }
 }
Exemplo n.º 10
0
 /**
  * @param string $url
  * @param string $name
  * @param string $position
  * @param array  $attributes
  *
  * @return $this
  */
 public function link($url, $name, $position = "BL", $attributes = array())
 {
     $match_url = trim(parse_url($url, PHP_URL_PATH), '/');
     if (Request::path() != $match_url) {
         $url = Persistence::get($match_url, parse_url($url, PHP_URL_QUERY));
     }
     $attributes = array_merge(array("class" => "btn btn-default"), $attributes);
     $this->button_container[$position][] = HTML::link($url, $name, $attributes);
     $this->links[] = $url;
     return $this;
 }
Exemplo n.º 11
0
function isActiveUrl($path, $output = 'active')
{
    if ($path !== '/') {
        // not a frontpage
        $path = trim($path, '/');
    }
    $actualPath = \Illuminate\Support\Facades\Request::path();
    if (strpos($actualPath, $path) !== false) {
        return $output;
    }
}
Exemplo n.º 12
0
 /**
  * @param string $url
  * @param string $name
  * @param string $position
  * @param array  $attributes
  *
  * @return $this
  */
 public function link($url, $name, $position = "BL", $attributes = array())
 {
     $base = str_replace(Request::path(), '', strtok(Request::fullUrl(), '?'));
     $match_url = str_replace($base, '/', strtok($url, '?'));
     if (Request::path() != $match_url) {
         $url = Persistence::get($match_url, parse_url($url, PHP_URL_QUERY));
     }
     $attributes = array_merge(array("class" => "btn btn-default"), $attributes);
     $this->button_container[$position][] = HTML::link($url, $name, $attributes);
     $this->links[] = $url;
     return $this;
 }
Exemplo n.º 13
0
 /**
  * @return mixed
  */
 private function getPageBySlug()
 {
     $path = Request::path();
     //ie whatever/subpage/and-so-on
     $slugs = explode("/", $path);
     $first_slug = $slugs['0'];
     $last_slug = $slugs[count($slugs) - 1];
     $slug = $last_slug;
     //Page by Slug
     $page = Page::with("content")->published()->where('slug', '=', $slug)->first();
     return $page;
 }
Exemplo n.º 14
0
 public function parseRequestDetails()
 {
     $result = ['action' => 'index', 'arguments' => []];
     $thisPath = urlbuilder($this->getUrl())->path();
     $requestUrl = urlbuilder(RequestFacade::path())->shift($thisPath);
     if (count($requestUrl->segments()) == 0) {
         return $result;
     }
     $result['action'] = $requestUrl->shiftSegment();
     $result['arguments'] = $requestUrl->segments();
     return $result;
 }
Exemplo n.º 15
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             session(['path' => Request::path()]);
             return redirect(route('getLogin'));
         }
     }
     return $next($request);
 }
Exemplo n.º 16
0
 public static function post($slug = '')
 {
     if (empty($slug)) {
         $slug = Request::path();
     }
     if ($slug[0] !== '/') {
         $slug = '/' . $slug;
     }
     $post = Post::where('slug', $slug)->with('tags', 'serie')->first();
     if ($post && $post->type === 'post' && ($post->published_at === null || $post->status !== 'active')) {
         return null;
     }
     return $post;
 }
Exemplo n.º 17
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $firstSegment = Request::segment(1);
     $locale = config('app.locale');
     if (in_array($firstSegment, config('translatable.locales'))) {
         $locale = $firstSegment;
     }
     // Throw a 404 if website in this language is offline
     if (!config('typicms.' . $locale . '.status')) {
         abort(404);
     }
     // Remove preview param if no admin user connected
     if (Input::get('preview') && !Auth::check()) {
         return Redirect::to(Request::path());
     }
     return $next($request);
 }
 /**
  * Returns the matching static view for the request (if the file
  * exists), otherwise returns the 404 response.
  *
  * TODO: Review the security of matchStaticView() function. Does
  * the Laravel framework already filter the "Request::path()" or
  * "View::make()" methods, or do we need to filter out possible
  * directory traversal attacks from the "requestPath" variable?
  *
  * @param  array $parameters Optional parameters for the View
  * @param  string $view Render the content with the specific view template
  * @return View
  */
 private function matchStaticView($parameters = array(), $view = null)
 {
     $basePath = rtrim(base_path(), "/");
     $requestPath = rtrim(mb_strtolower(Request::path()), "/");
     $fullStaticViewPath = "{$basePath}/resources/views/pages/{$requestPath}";
     $staticViewFilename = "pages/{$requestPath}";
     if (is_dir($fullStaticViewPath)) {
         $staticViewFilename .= "/index";
     }
     if (View::exists($staticViewFilename)) {
         return View::make($staticViewFilename, $parameters);
     }
     if (isset($view) && View::exists($view)) {
         return View::make($view, $parameters);
     }
     # Otherwise return the 404 response
     return App::abort(404);
 }
Exemplo n.º 19
0
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $exception
  *
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $exception)
 {
     if ($exception instanceof NotFoundHttpException && Request::acceptsHtml() && !Request::ajax() && !strrpos(Request::path(), '/assets/', -strlen(Request::path())) !== false) {
         return $this->handleNotFound();
     }
     if ($exception instanceof AccessDeniedException || $exception instanceof InvalidRequestException) {
         return response()->json([], 401);
     } else {
         if ($exception instanceof FatalErrorException) {
             $message = $exception->getMessage();
             if (App::environment() === 'production') {
                 $message = 'An error occured';
             }
             return response()->json(['error' => $message], 500);
         }
     }
     return parent::render($request, $exception);
 }
 public function composerSeo()
 {
     view()->composer('common.seo', function ($view) {
         $path = Request::path();
         $seos = SeoInfo::seoMap();
         $seo;
         if (starts_with($path, 'notes')) {
             $seo = $seos['notes'];
         } else {
             if (starts_with($path, 'guide')) {
                 $seo = $seos['guide'];
             } else {
                 if (starts_with($path, 'activity')) {
                     $seo = $seos['activity'];
                 } else {
                     $seo = $seos['index'];
                 }
             }
         }
         return $view->with('seo', $seo);
     });
 }
Exemplo n.º 21
0
 /**
  * @param array $parameters
  * @return string
  */
 public static function link(array $parameters)
 {
     if (count($parameters) === 1) {
         $parameters[1] = ucfirst($parameters[0]);
     }
     $col = $parameters[0];
     $title = $parameters[1];
     $icon = Config::get('columnsortable.sortable_icon');
     foreach (Config::get('columnsortable.columns') as $key => $value) {
         if (in_array($col, $value['rows'])) {
             $icon = $value['class'];
         }
     }
     if (Input::get('sort') == $col && in_array(Input::get('order'), ['asc', 'desc'])) {
         $icon = $icon . '-' . Input::get('order');
     } else {
         $icon = Config::get('columnsortable.sortable_icon');
     }
     $parameters = ['sort' => $col, 'order' => Input::get('order') === 'asc' ? 'desc' : 'asc'];
     $query_string = http_build_query(array_merge(Request::route()->parameters(), $parameters));
     return '<a href="' . url(Request::path() . '?' . $query_string) . '"' . '>' . htmlentities($title) . '</a>' . ' ' . '<i class="' . $icon . '"></i>';
 }
Exemplo n.º 22
0
 /**
  * Register any application authentication / authorization services.
  *
  * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
  * @return void
  */
 public function boot(GateContract $gate)
 {
     $this->registerPolicies($gate);
     $gate->define('crud-users', function () {
         return \Auth::user()->isAdmin();
     });
     $gate->define('auth', function () {
         return \Auth::check();
     });
     $gate->define('home', function () {
         return Request::path() === '/' || Request::path() == 'home' || Request::path() == '' ? true : false;
     });
     $gate->define('admin/users', function () {
         return strpos(Request::path(), 'admin/users') === false ? true : false;
     });
     $gate->define('ismobile', function () {
         $agent = new Agent();
         return $agent->isMobile();
     });
     $gate->define('isphone', function () {
         $agent = new Agent();
         return $agent->isPhone();
     });
 }
 function markSelected(&$menuItems)
 {
     $selectedItems = 0;
     $uri = Request::path();
     foreach ($menuItems as &$menuItem) {
         $selectedChildren = 0;
         if ($uri == trim($menuItem['href'], "/")) {
             $menuItem['class'] = 'selected';
             $menuItem['open'] = true;
             $selectedItems++;
         }
         if (isset($menuItem['sub_menu'])) {
             if (!empty($menuItem['sub_menu'])) {
                 $selectedChildren += markSelected($menuItem['sub_menu']);
             }
         }
         if ($selectedChildren > 0) {
             $menuItem['class'] = 'child-selected';
             $menuItem['open'] = true;
         }
         $selectedItems += $selectedChildren;
     }
     return $selectedItems;
 }
Exemplo n.º 24
0
 private function makeJson($view, $data, $jsonData = false)
 {
     if ($jsonData) {
         return Response::json(array('jsonData' => $data, 'title' => $this->title));
     }
     $response['template'] = View::make($view, $data)->render();
     $response['style'] = $this->style;
     $response['script'] = $this->script;
     $response['title'] = $this->title;
     $response['uri'] = Request::path();
     return Response::json($response);
 }
Exemplo n.º 25
0
 public static function build($vars)
 {
     $params = array_merge((array) Request::path(), $vars);
     return http_build_query($params);
 }
Exemplo n.º 26
0
 public static function clear()
 {
     Session::forget('rapyd.' . Request::path());
 }
Exemplo n.º 27
0
 /**
  * CMS constructor.
  */
 public function __construct()
 {
     $this->lang = App::getLocale();
     $this->path = str_replace('/', '#', Request::path());
     $this->blocks = Block::where('language', $this->lang)->where('path', $this->path)->select('content', 'block')->get()->keyBy('block')->toArray();
 }
Exemplo n.º 28
0
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     $installer = new InstallController();
     // if a migration is missing scape to the installation
     if (empty($installer->inactiveMigrations()) && DB::table('ticketit_settings')->count() != 0) {
         // Send the Agent User model to the view under $u
         view()->composer('*', function ($view) {
             if (auth()->check()) {
                 $u = Agent::find(auth()->user()->id);
                 $view->with('u', $u);
             }
             $setting = new Setting();
             $view->with('setting', $setting);
         });
         // Adding HTML5 color picker to form elements
         CollectiveForm::macro('custom', function ($type, $name, $value = "#000000", $options = []) {
             $field = $this->input($type, $name, $value, $options);
             return $field;
         });
         // Passing to views the master view value from the setting file
         view()->composer('ticketit::*', function ($view) {
             $tools = new ToolsController();
             $master = Setting::grab('master_template');
             $email = Setting::grab('email.template');
             $view->with(compact('master', 'email', 'tools'));
         });
         // Send notification when new comment is added
         Comment::creating(function ($comment) {
             if (Setting::grab('comment_notification')) {
                 $notification = new NotificationsController();
                 $notification->newComment($comment);
             }
         });
         // Send notification when ticket status is modified
         Ticket::updating(function ($modified_ticket) {
             if (Setting::grab('status_notification')) {
                 $original_ticket = Ticket::find($modified_ticket->id);
                 if ($original_ticket->status_id != $modified_ticket->status_id || $original_ticket->completed_at != $modified_ticket->completed_at) {
                     $notification = new NotificationsController();
                     $notification->ticketStatusUpdated($modified_ticket, $original_ticket);
                 }
             }
             if (Setting::grab('assigned_notification')) {
                 $original_ticket = Ticket::find($modified_ticket->id);
                 if ($original_ticket->agent->id != $modified_ticket->agent->id) {
                     $notification = new NotificationsController();
                     $notification->ticketAgentUpdated($modified_ticket, $original_ticket);
                 }
             }
             return true;
         });
         // Send notification when ticket status is modified
         Ticket::created(function ($ticket) {
             if (Setting::grab('assigned_notification')) {
                 $notification = new NotificationsController();
                 $notification->newTicketNotifyAgent($ticket);
             }
             return true;
         });
         $this->loadTranslationsFrom(__DIR__ . '/Translations', 'ticketit');
         $this->loadViewsFrom(__DIR__ . '/Views', 'ticketit');
         $this->publishes([__DIR__ . '/Views' => base_path('resources/views/vendor/ticketit')], 'views');
         $this->publishes([__DIR__ . '/Translations' => base_path('resources/lang/vendor/ticketit')], 'lang');
         $this->publishes([__DIR__ . '/Public' => public_path('vendor/ticketit')], 'public');
         $this->publishes([__DIR__ . '/Migrations' => base_path('database/migrations')], 'db');
         // Check public assets are present, publish them if not
         //            $installer->publicAssets();
         $main_route = Setting::grab('main_route');
         $admin_route = Setting::grab('admin_route');
         include __DIR__ . '/routes.php';
     } elseif (Request::path() == 'tickets-install') {
         $this->loadTranslationsFrom(__DIR__ . '/Translations', 'ticketit');
         $this->loadViewsFrom(__DIR__ . '/Views', 'ticketit');
         $this->publishes([__DIR__ . '/Migrations' => base_path('database/migrations')], 'db');
         Route::get('/tickets-install', ['middleware' => 'auth', 'uses' => 'Kordy\\Ticketit\\Controllers\\InstallController@index']);
         Route::post('/tickets-install', ['middleware' => 'auth', 'uses' => 'Kordy\\Ticketit\\Controllers\\InstallController@setup']);
     }
 }
Exemplo n.º 29
0
 /**
  * Decider for tree or vertical adding
  *
  * @param $menu
  */
 protected function add($menu)
 {
     if (empty($menu['id'])) {
         return;
     }
     if (Request::path() == $menu['uri']) {
         $menu['active'] = true;
     }
     if (empty($menu['parent_id'])) {
         $this->generated[$menu['id']] = $menu;
         return;
     }
     if (!empty($menu['active'])) {
         $this->menus[$menu['parent_id']]['active'] = true;
     }
     $this->menus[$menu['parent_id']]['children'][$menu['id']] = $menu;
     $this->add($this->menus[$menu['parent_id']]);
     // Traverse to make the parent_id null
 }
Exemplo n.º 30
0
 /**
  * this method to verify permission api
  * @param  stirng $method     [description]
  * @param  stirng $permission [description]
  */
 public function authorize($permission)
 {
     if (empty($this->tempStorage->get('id_company'))) {
         $this->invalidateToken();
         throw $this->response->error('Un Authorized, Please Re-Login', 401);
     }
     $user = JWTAuth::parseToken()->authenticate();
     $permission = Permission::where('name', $permission)->select('id')->first();
     if (count($permission) == 0) {
         throw $this->response->error('No Permission', 404);
     }
     //set dynamic url or static url controller
     if (empty($this->url)) {
         $arrUrl = explode('/', Input::path());
         array_shift($arrUrl);
         $url = '/' . $arrUrl['0'] . '/' . $arrUrl['1'];
         $menu = Menu::where('url', $url)->select('id')->first();
         if (count($menu) == 0) {
             throw $this->response->error('No Menu  ' . $url, 404);
         }
         $rolePermission = RolePermission::where('id_role', $user->id_role)->where('id_permission', $permission->id)->where('id_menu', $menu->id)->get();
         if (count($rolePermission) == 0) {
             throw $this->response->error('Unauthorized action page', 404);
         }
     } else {
         $url = $this->url;
         $menu = Menu::where('url', $url)->select('id')->first();
         if (count($menu) == 0) {
             throw $this->response->error('No Menu  ' . $url, 404);
         }
     }
 }