Example #1
0
 /**
  * Get the correct view for the form
  *
  * @param $view
  * @return View|null|Template
  */
 public function getView($view)
 {
     if (Template::exists('Form/' . $view)) {
         return Template::getAdminTemplate('Form/' . $view);
     }
     return new View($view, B8_PATH . 'Form/View/');
 }
Example #2
0
 public function render($item)
 {
     if (!is_null($item)) {
         $parts = explode('\\', get_class($item));
         $class = array_pop($parts);
         $view = Template::getAdminTemplate('Search/Type/' . $class);
         $view->result = $item;
         return $view->render();
     }
 }
Example #3
0
 /**
  * Handle the requested action
  *
  * @param $action
  * @param $params
  * @return mixed
  */
 public function handleAction($action, $params)
 {
     try {
         $thisClass = explode('\\', get_class($this));
         $module = $thisClass[1];
         $this->view = Template::getAdminTemplate($this->className . '/' . $action, $module);
         $this->view->currentUser = $this->currentUser;
     } catch (\Exception $ex) {
         $error = '<div class="alert alert-danger">You have not created a view for: ';
         $error .= $this->className . '/' . $action . '</div>';
         $this->view = new Template($error);
     }
     // Set up GlobalMessage:
     if (!empty($this->view)) {
         if (!empty($_SESSION['GlobalMessage']['success'])) {
             $this->view->GlobalMessage()->success = $_SESSION['GlobalMessage']['success'];
             unset($_SESSION['GlobalMessage']['success']);
         }
         if (!empty($_SESSION['GlobalMessage']['error'])) {
             $this->view->GlobalMessage()->error = $_SESSION['GlobalMessage']['error'];
             unset($_SESSION['GlobalMessage']['error']);
         }
         if (!empty($_SESSION['GlobalMessage']['info'])) {
             $this->view->GlobalMessage()->info = $_SESSION['GlobalMessage']['info'];
             unset($_SESSION['GlobalMessage']['info']);
         }
     }
     $output = parent::handleAction($action, $params);
     if (empty($output) && !empty($this->view)) {
         $output = $this->view->render();
     }
     $this->response->setContent($output);
     if ($this->response->hasLayout()) {
         $this->layout->user = $_SESSION['user'];
         $this->layout->content = $this->response->getContent();
         $this->response->setContent($this->layout->render());
     }
     return $this->response;
 }
Example #4
0
 protected function loadTimeline()
 {
     $logStore = Store::get('Log');
     $items = $logStore->getTimeline();
     $timeline = [];
     $lastDate = new \DateTime('1970-01-01');
     foreach ($items as $item) {
         if ($item->getLogDate()->format('Y-m-d') != $lastDate->format('Y-m-d')) {
             $date = $item->getLogDate()->format('M j Y');
             $timeline[] = "<li class=\"time-label\">\n                                    <span class=\"bg-blue\">\n                                        {$date}\n                                    </span>\n                                </li>";
             $lastDate = $item->getLogDate();
         }
         $keyDate = $item->getLogDate()->format('Y-m-d');
         $key = md5($keyDate . $item->getScope() . '.' . $item->getType() . '.' . $item->getScopeId());
         if (array_key_exists($key, $timeline)) {
             continue;
         }
         $template = 'Dashboard/Timeline/' . $item->getScope();
         if (!Template::exists($template)) {
             $template = 'Dashboard/Timeline/default';
         }
         $template = Template::getAdminTemplate($template);
         $template->icon = 'info';
         $template->item = $item;
         $template->decoded = @json_decode($item->getMessage(), true);
         switch ($item->getType()) {
             case 2:
                 $template->color = 'green';
                 $template->verb = 'created';
                 break;
             case 4:
                 $template->color = 'red';
                 $template->verb = 'deleted';
                 break;
             case 8:
                 $template->color = 'blue';
                 $template->verb = 'edited';
                 break;
             case 128:
                 $template->color = 'blue';
                 $template->verb = 'published';
                 break;
         }
         switch ($item->getScope()) {
             case 'user':
                 $template->icon = 'user';
                 break;
             case 'page':
                 $template->icon = 'file-text';
                 break;
             case 'file':
                 $template->icon = 'image';
                 break;
             case 'info':
                 $template->icon = 'user';
                 break;
         }
         $timeline[$key] = $template->render();
         if (count($timeline) >= 20) {
             break;
         }
     }
     return $timeline;
 }
Example #5
0
 protected function setupLegacyTemplate($controller, $action)
 {
     if (LegacyTemplate::exists($controller . '/' . $action)) {
         $this->template = new Template('legacy', 'admin');
         $this->view = LegacyTemplate::getAdminTemplate($controller . '/' . $action);
         $this->view->currentUser = $this->currentUser;
     }
 }