Ejemplo n.º 1
0
 /**
  * Set title of html-page
  * @param $value
  */
 public function setTitle($value)
 {
     self::$title = $value;
 }
Ejemplo n.º 2
0
 /**
  * Working with view
  */
 private function workingWithView()
 {
     $pathToViewFile = WORK_SPACE_FOLDER_PATH . 'views' . DS . (!is_null(controllerManager::$view) ? controllerManager::$view[1] . DS . controllerManager::$view[0] : $this->controllerName . DS . $this->routingInfo['function']) . '.php';
     if (!is_file($pathToViewFile) || ($content = file_get_contents($pathToViewFile)) === false) {
         crash('Unable to open view-file: ' . $pathToViewFile);
     }
     /**
      * Exclusively for CSRF protection actions in order to obtain more convenience while using
      */
     if (mb_strpos($content, '{CSRFProtection}') !== false) {
         require_once WORK_SPACE_FOLDER_PATH . 'models' . DS . 'CSRFProtectionModel.php';
         $content = str_replace('{CSRFProtection}', (new CSRFProtectionModel())->protection(), $content);
     }
     /**
      * Show fields error
      */
     if (mb_strpos($content, '{_err}') !== false) {
         $content = explode('{_err}', $content);
         array_walk($content, function (&$item, $key, $count) {
             $item = $item . ($key < $count ? "<?php echo controllerManager::getFormFieldsError({$key}); ?>" : '');
         }, count($content) - 1);
         $content = implode('', $content);
     }
     /**
      * Replace variables {} in template
      */
     foreach (controllerManager::$variables as $varName => $varValue) {
         if (mb_strpos($content, '{' . $varName . '}') !== false) {
             $content = str_replace('{' . $varName . '}', $varValue, $content);
         }
     }
     if (empty(controllerManager::$title) && isset($this->routingInfo['title'])) {
         controllerManager::$title = $this->routingInfo['title'];
     }
     $this->setResourcesFromControllerProperty();
     extract(controllerManager::$variables);
     require_once WORK_SPACE_FOLDER_PATH . 'layouts' . DS . $this->getLayout() . '.php';
     exit;
 }