Ejemplo n.º 1
0
 public static function generateCache($cache_file, $html)
 {
     if (file_exists($cache_file) && !self::getCache($cache_file)) {
         $pin_id = basename($cache_file, '.cache');
         try {
             $minifi = new JO_Minify_Html();
             $db = new JO_Db_Adapter_Pdo_Sqlite(array("dbname" => $cache_file));
             $db->delete('pins_cache', array('user_id' => (string) JO_Session::get('user[user_id]')));
             $db->insert('pins_cache', array('pin_id' => (string) $pin_id, 'user_id' => (string) JO_Session::get('user[user_id]'), 'html' => (string) $minifi->minify($html), 'template' => JO_Registry::get('template'), 'date_added' => time()));
         } catch (JO_Exception $e) {
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * @return string
  */
 public function response()
 {
     $model = JO_Request::getInstance()->getModule();
     $baseDir = $this->getLayoutPath() . DIRECTORY_SEPARATOR . $this->getTemplate() . DIRECTORY_SEPARATOR . $model;
     if (!file_exists($baseDir) || !is_dir($baseDir)) {
         require_once 'JO/Exception.php';
         throw new JO_Exception('Missing base layout directory ("' . $baseDir . '")');
     }
     $script = $baseDir . DIRECTORY_SEPARATOR . $this->getLayout() . '.phtml';
     if (!file_exists($script) || !is_file($script)) {
         require_once 'JO/Exception.php';
         throw new JO_Exception('Missing base layout file ("' . $script . '")');
     }
     ob_start();
     include $script;
     $content = ob_get_contents();
     ob_get_clean();
     if (JO_Registry::forceGet('enable_html_minify')) {
         $min = new JO_Minify_Html();
         $content = $min->minify($content);
     }
     return $content;
 }
Ejemplo n.º 3
0
 /**
  * @param string $script
  * @param string $controller
  * @return string
  */
 public function render($script, $controller)
 {
     $baseDir = $this->getBasePath() . DIRECTORY_SEPARATOR . $this->getTemplate() . DIRECTORY_SEPARATOR . $this->_formatViewName($controller);
     if (!file_exists($baseDir) || !is_dir($baseDir)) {
         require_once 'JO/Exception.php';
         return '<pre>' . new JO_Exception('Missing base view directory ("' . $baseDir . '")') . '</pre>';
     }
     $scriptFile = $baseDir . DIRECTORY_SEPARATOR . $script . '.phtml';
     if (!file_exists($scriptFile) || !is_file($scriptFile)) {
         require_once 'JO/Exception.php';
         return '<pre>' . new JO_Exception('Missing base view file ("' . $scriptFile . '")') . '</pre>';
     }
     if (is_array($this->children)) {
         foreach ($this->children as $key => $child) {
             $this->{$key} = $this->callChildren($child, $key);
         }
     }
     ob_start();
     include $scriptFile;
     $content = ob_get_contents();
     ob_get_clean();
     if (JO_Registry::forceGet('enable_html_minify')) {
         $min = new JO_Minify_Html();
         $content = $min->minify($content);
     }
     return $content;
 }
Ejemplo n.º 4
0
 /**
  * @return string
  */
 public function response()
 {
     $model = JO_Request::getInstance()->getModule();
     $baseDir = $this->getLayoutPath() . DIRECTORY_SEPARATOR . $this->getTemplate() . DIRECTORY_SEPARATOR . $model;
     if (!file_exists($baseDir) || !is_dir($baseDir)) {
         require_once 'JO/Exception.php';
         throw new JO_Exception('Missing base layout directory ("' . $baseDir . '")');
     }
     $script = $baseDir . DIRECTORY_SEPARATOR . $this->getLayout() . '.phtml';
     if (!file_exists($script) || !is_file($script)) {
         require_once 'JO/Exception.php';
         throw new JO_Exception('Missing base layout file ("' . $script . '")');
     }
     ob_start();
     include $script;
     $content = ob_get_contents();
     ob_get_clean();
     if (JO_Registry::forceGet('enable_html_minify')) {
         $min = new JO_Minify_Html();
         $content = $min->minify($content);
     }
     //        $test = new JO_Html_Dom;
     //        $test->load($content);
     //
     //        $head = $test->find('head', 0);
     //        $meta = $head->find('meta');
     //        $title = $head->find('title', 0);
     //        for($i=0; $i<count($meta); $i++) {
     //        	var_dump( $this->placeholder[$meta[$i]->name] );
     //        }exit;
     return $content;
 }