예제 #1
0
 /**
  * Override parent function. 
  * Override Smarty. I don't wants it. But BEWARE: the loadHeader and loadFooter bits require 
  * the functionality of the original fetchTemplate function.  ARRRGH.  You try to escape but you can't.
  *
  * @param string $file (relative to the views directory)
  * @return rendered string (e.g. HTML)
  */
 public function fetchTemplate($file)
 {
     // Conditional override! Gross!
     // If we don't give Smarty a free pass, we end up with "View file does not exist" errors because
     // MODX relies on the parent fetchTemplate function to load up its header.tpl and footer.tpl files. Ick.
     if (substr($file, -4) == '.tpl') {
         return parent::fetchTemplate($file);
     }
     $this->modx->log(\modX::LOG_LEVEL_DEBUG, 'File: ' . $file, '', 'BaseController::' . __FUNCTION__);
     $path = $this->modx->getOption('assman.core_path', '', MODX_CORE_PATH . 'components/assman/') . 'views/';
     $data = $this->getPlaceholders();
     $this->modx->log(\modX::LOG_LEVEL_DEBUG, 'View: ' . $file . ' data: ' . print_r($data, true), '', 'BaseController::' . __FUNCTION__, 'Line:' . __LINE__);
     if (!is_file($path . $file)) {
         $this->modx->log(\modX::LOG_LEVEL_ERROR, 'View file does not exist: ' . $file, '', 'BaseController::' . __FUNCTION__, 'Line:' . __LINE__);
         return $this->modx->lexicon('view_not_found', array('file' => 'views/' . $file));
     }
     // Load up our page [header] + content + [footer]
     ob_start();
     if (!isset($this->scriptProperties['_nolayout'])) {
         $this->modx->log(\modX::LOG_LEVEL_DEBUG, 'Including header.php', '', 'BaseController::' . __FUNCTION__, 'Line:' . __LINE__);
         include $path . 'header.php';
     }
     include $path . $file;
     if (!isset($this->scriptProperties['_nolayout'])) {
         $this->modx->log(\modX::LOG_LEVEL_DEBUG, 'Including footer.php', '', 'BaseController::' . __FUNCTION__, 'Line:' . __LINE__);
         include $path . 'footer.php';
     }
     $content = ob_get_clean();
     return $content;
 }