Ejemplo n.º 1
0
 private function validatePath(&$path, $id)
 {
     if (!Utils::isValidURL($path)) {
         $userfile = "{$_SERVER['DOCUMENT_ROOT']}/tpl/{$this->tpl_no}/{$path}";
         if (!file_exists($userfile)) {
             unset($path);
             return;
         }
         if (!Config\MINIFICATION_ENABLED) {
             $path .= '?' . filemtime($userfile);
             //force cache refresh if file is changed
             return;
         }
         $userfiletime = $_SERVER['DOCUMENT_ROOT'] . '/tmp/' . md5($path) . $this->tpl_no . $id;
         $ext = "min.{$id}";
         $updateTime = 0;
         if (!file_exists($userfiletime) || intval(file_get_contents($userfiletime)) < ($updateTime = filemtime($userfile))) {
             Minification::minifyTemplateFile($userfiletime, $userfile, $userfile . $ext, $id);
             $updateTime = time();
         }
         $path .= $ext . "?{$updateTime}";
         // append min.ext to file path, and add ?time, to force cache refresh if file is changed
     }
 }