Exemplo n.º 1
0
 /**
  * Create a new Controller instance.
  */
 public function __construct()
 {
     // Setup the used Template to default, if it is not already defined.
     if (!isset($this->template)) {
         $this->template = Config::get('app.template');
     }
 }
Exemplo n.º 2
0
 /**
  * Create a new URL Generator instance.
  *
  * @param  \Nova\Routing\RouteCollection  $routes
  * @param  \Symfony\Component\HttpFoundation\Request   $request
  * @return void
  */
 public function __construct(RouteCollection $routes, Request $request)
 {
     $this->routes = $routes;
     $this->setRequest($request);
     // Wheter or not are used the Unnamed Parameters.
     if ('unnamed' == Config::get('routing.parameters', 'named')) {
         $this->legacyRouting = true;
     }
 }
Exemplo n.º 3
0
 public static function process($fetch = false)
 {
     $config = Config::get('profiler');
     if ($config['useForensics'] != true) {
         return null;
     }
     // The QuickProfiller was enabled into Configuration.
     $profiler = new static();
     return $profiler->display($fetch);
 }
Exemplo n.º 4
0
 /**
  * Change the Framework Language.
  */
 public function change($language)
 {
     $languages = Config::get('languages');
     // Only set language if it's in the Languages array
     if (preg_match('/[a-z]/', $language) && in_array($language, array_keys($languages))) {
         Session::set('language', $language);
         // Store the current Language in a Cookie lasting five years.
         Cookie::queue(PREFIX . 'language', $language, Cookie::FIVEYEARS);
     }
     return Redirect::back();
 }
Exemplo n.º 5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $error = false;
     $path = Config::get('cache.path', 'app/Storage/Cache');
     if (!is_dir($path)) {
         $output->writeln("<error>Cache directory does not exist. path: {$path}</>");
         $error = true;
     }
     self::cleanCache($path);
     $output->writeln("<info>Cache directory has been cleaned. path: {$path}</>");
 }
 /**
  * Register the Assets Dispatcher.
  */
 public function registerAssetsDispatcher()
 {
     // NOTE: When this method is executed, the Config Store is not yet available.
     $driver = Config::get('routing.assets.driver', 'default');
     if ($driver == 'custom') {
         $className = Config::get('routing.assets.dispatcher');
     } else {
         $className = 'Nova\\Routing\\Assets\\' . ucfirst($driver) . 'Dispatcher';
     }
     // Bind the calculated class name to the Assets Dispatcher Interface.
     $this->app->bind('Nova\\Routing\\Assets\\DispatcherInterface', $className);
 }
Exemplo n.º 7
0
 public function index($token)
 {
     if ($this->token != $token) {
         return Response::make('', 403);
         // Error 403 (Access denied)
     }
     // Get the execution date and time as translated string.
     $format = __d('system', '%d %b %Y, %R');
     $date = Carbon::now()->formatLocalized($format);
     // Execute the CRON tasks.
     $result = $this->executeCron();
     // Create the page information.
     $title = __d('system', '{0} - Cron executed on {1}', Config::get('app.name'), $date);
     return $this->getView()->with('title', $title)->with('content', $result);
 }
Exemplo n.º 8
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $error = false;
     $path = Config::get('session.files', 'app/Storage/Sessions');
     if ($input->getArgument('lifeTime')) {
         $lifeTime = $input->getArgument('lifeTime');
     } else {
         $lifeTime = Config::get('session.lifetime', 180);
     }
     if (!is_dir($path)) {
         $output->writeln("<error>Session directory does not exist. path: {$path}</>");
         $error = true;
     }
     self::clearSessions($path, $lifeTime);
     $output->writeln("<info>The sessions have been cleared. Lifetime: {$lifeTime}, path: {$path}</>");
 }
Exemplo n.º 9
0
 /**
  * Serve a File.
  *
  * @param string $path
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function serve($path, SymfonyRequest $request)
 {
     if (!file_exists($path)) {
         return new Response('File Not Found', 404);
     } else {
         if (!is_readable($path)) {
             return new Response('Unauthorized Access', 403);
         }
     }
     // Collect the current file information.
     $guesser = MimeTypeGuesser::getInstance();
     // Even the Symfony's HTTP Foundation have troubles with the CSS and JS files?
     //
     // Hard coding the correct mime types for presently needed file extensions.
     switch ($fileExt = pathinfo($path, PATHINFO_EXTENSION)) {
         case 'css':
             $contentType = 'text/css';
             break;
         case 'js':
             $contentType = 'application/javascript';
             break;
         default:
             $contentType = $guesser->guess($path);
             break;
     }
     if (str_is('text/*', $contentType) || $contentType == 'application/javascript') {
         $response = $this->createFileResponse($path, $request);
     } else {
         $response = $this->createBinaryFileResponse($path);
     }
     // Set the Content type.
     $response->headers->set('Content-Type', $contentType);
     // Set the Cache Control.
     $cacheTime = Config::get('routing.assets.cacheTime', 10800);
     $response->setTtl(600);
     $response->setMaxAge($cacheTime);
     $response->setSharedMaxAge(600);
     // Prepare against the Request instance.
     $response->isNotModified($request);
     return $response;
 }
Exemplo n.º 10
0
 /**
  * Load the Configuration Group for the key.
  *
  * @param    string     $group
  * @return     array
  */
 public function load($group)
 {
     return Config::get($group, array());
 }
Exemplo n.º 11
0
 /**
  * Return a default View instance.
  *
  * @return \Nova\View\View
  * @throws \BadMethodCallException
  */
 protected function getView(array $data = array())
 {
     list(, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
     // Retrieve the called Controller method from the caller.
     $method = $caller['function'];
     // Transform the complete class name on a path like variable.
     $path = str_replace('\\', '/', static::class);
     // Check for a valid controller on Application.
     if (preg_match('#^App/Controllers/(.*)$#i', $path, $matches)) {
         $view = $matches[1] . '/' . ucfirst($method);
         return View::make($view, $data);
     }
     // Retrieve the Modules namespace from their configuration.
     $namespace = Config::get('modules.namespace', 'App\\Modules\\');
     // Transform the Modules namespace on a path like variable.
     $basePath = str_replace('\\', '/', rtrim($namespace, '\\'));
     // Check for a valid controller on Modules.
     if (preg_match('#^' . $basePath . '/(.+)/Controllers/(.*)$#i', $path, $matches)) {
         $view = $matches[2] . '/' . ucfirst($method);
         return View::make($view, $data, $matches[1]);
     }
     // If we arrived there, the called class is not a Controller; go Exception.
     throw new BadMethodCallException('Invalid Controller namespace: ' . static::class);
 }
Exemplo n.º 12
0
 /**
  * Find the View file.
  *
  * @param    string     $view
  * @param    string     $template
  * @return    string
  */
 protected function find($view, $template = null)
 {
     // Calculate the current Template name.
     $template = $template ?: Config::get('app.template');
     // Calculate the search path.
     $path = sprintf('Templates/%s/%s', $template, $view);
     // Make the path absolute and adjust the directory separator.
     $path = str_replace('/', DS, APPDIR . $path);
     // Find the View file depending on the Language direction.
     $language = $this->getLanguage();
     if ($language->direction() == 'rtl') {
         // Search for the View file used on the RTL languages.
         $filePath = $this->finder->find($path . '-rtl');
     } else {
         $filePath = null;
     }
     if (is_null($filePath)) {
         $filePath = $this->finder->find($path);
     }
     if (!is_null($filePath)) {
         return $filePath;
     }
     throw new \InvalidArgumentException("Unable to load the view '" . $view . "' on template '" . $template . "'.", 1);
 }
Exemplo n.º 13
0
 public function __construct()
 {
     $this->config = Config::get('recaptcha', array());
 }
Exemplo n.º 14
0
 protected function __construct()
 {
     $this->config = Config::get('profiler', array());
 }