예제 #1
0
 /**
  * setData constructor.
  *
  * @param \Aura\Web\Request $request
  * @param \Aura\Web\Response $response
  * @param \Aura\View\View $view
  */
 public function __construct($request, $response, $view)
 {
     $status = 'success';
     $message = 'Image saved successfully.';
     $image = $request->files->get('file', ['error' => 1]);
     $secureToken = (new Config())->getConfig()['secure_token'];
     $retrievedSecureToken = $request->query->get('key', '');
     if ($secureToken !== $retrievedSecureToken) {
         $status = 'error';
         $message = 'Incorrect secure token';
     } else {
         if ($image['error'] === 0) {
             $fileSystem = new Filesystem();
             $tmpName = $image['tmp_name'];
             $path = '../storage/';
             try {
                 $fileSystem->copy($tmpName, $path . $image['name']);
             } catch (\Exception $e) {
                 Log::addError('Image upload error: ' . $e->getMessage());
                 $status = 'error';
                 $message = 'Move image exception: ' . $e->getMessage();
             }
         } else {
             Log::addError('Image upload error: ' . serialize($image));
             $status = 'error';
             $message = 'Image upload error';
         }
     }
     $view->setData(['status' => $status, 'message' => $message]);
     $response->content->set($view->__invoke());
 }
 protected function setTemplate(View $view, RootConfig $config)
 {
     $template = $config->getTemplate();
     if (!$template) {
         $template = dirname(dirname(dirname(__DIR__))) . '/templates/main.php';
     }
     if (!file_exists($template) && !is_readable($template)) {
         throw new Exception("Cannot find template '{$template}'.");
     }
     $registry = $view->getViewRegistry();
     $registry->set('__BOOKDOWN__', $template);
     $view->setView('__BOOKDOWN__');
 }
 /**
  * Prepare the layout, if any.
  *
  * If the params contains a non-empty 'layout' variable, that value
  * will be used to seed a layout
  *
  * If a layout is discovered in this way, it will override the one set in
  * the constructor, if any.
  *
  * @param array $params
  * @return null
  */
 private function prepareLayout($params)
 {
     if (isset($params['layout'])) {
         $this->layout = $params['layout'];
     }
     $this->renderer->setLayout($this->layout);
 }
예제 #4
0
 /**
  * setData constructor.
  *
  * @param \Aura\Web\Request $request
  * @param \Aura\Web\Response $response
  * @param \Aura\View\View $view
  */
 public function __construct($request, $response, $view)
 {
     $status = 'success';
     $message = 'Data written successfully.';
     $secureToken = (new Config())->getConfig()['secure_token'];
     $retrievedSecureToken = $request->query->get('key', '');
     if ($secureToken !== $retrievedSecureToken) {
         $status = 'error';
         $message = 'Incorrect secure token';
     } else {
         $post = $request->post;
         $query = (new \Database\Query())->insert()->into('system_log')->cols(['log_time' => $post->get('date', 'NOW()'), 'cpu_utilization' => $post->get('cpu_utilization', 0), 'memory_free' => $post->get('memory_free', 0), 'memory_used' => $post->get('memory_used', 0), 'uptime_p' => $post->get('uptime_p', ''), 'uptime_s' => $post->get('uptime_s', ''), 'system_load' => $post->get('system_load', ''), 'process_number' => $post->get('process_number', 0), 'disk_utilization' => $post->get('disk_utilization', ''), 'network_utilization' => $post->get('network_utilization', ''), 'logged_in_users' => $post->get('logged_in_users', ''), 'logged_in_users_count' => $post->get('logged_in_users_count', 0), 'users_work' => $post->get('users_work', ''), 'hostname' => $post->get('hostname', ''), 'ip_internal' => $post->get('ip_internal', ''), 'ip_external' => $post->get('ip_external', ''), 'extra' => $post->get('extra', '')]);
         (new Connect())->query($query);
     }
     $view->setData(['status' => $status, 'message' => $message]);
     $response->content->set($view->__invoke());
 }
예제 #5
0
 /**
  * @param View $view
  */
 public function useTemplateForContent(View $view)
 {
     $this->setContent($view->__invoke());
 }
 /**
  * Inject helpers into the View
  *
  * In each case, injects with the custom url/serverurl implementations.
  *
  * @param View $renderer
  * @param ContainerInterface $container
  */
 private function injectHelpers(View $renderer, ContainerInterface $container)
 {
     $helpers = $renderer->getHelpers();
     $helpers->set('url', function () use($container) {
         if (!$container->has(UrlHelper::class)) {
             throw new Exception\MissingHelperException(sprintf('An instance of %s is required in order to create the "url" view helper; not found', UrlHelper::class));
         }
         return $container->get(UrlHelper::class);
     });
     $helpers->set('serverurl', function () use($container) {
         if (!$container->has(ServerUrlHelper::class)) {
             throw new Exception\MissingHelperException(sprintf('An instance of %s is required in order to create the "url" view helper; not found', ServerUrlHelper::class));
         }
         return $container->get(ServerUrlHelper::class);
     });
 }
예제 #7
0
 /**
  * Prepare
  *
  * @return mixed
  *
  * @access protected
  */
 protected function prepare()
 {
     $this->view->addData(['request' => $this->request]);
 }
예제 #8
0
파일: Viewd.php 프로젝트: jnjxp/viewd
 /**
  * Has
  *
  * @param string $name name of script
  *
  * @return bool
  *
  * @access protected
  */
 protected function has($name)
 {
     return $this->view->getViewRegistry()->has($name);
 }