HosipLan

Untitled

Mar 8th, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1.     public function macroTimestamp(Latte\MacroNode $node, Latte\PhpWriter $writer)
  2.     {
  3.         $class = get_called_class();
  4.         return $writer->write('echo %escape(' . $class . '::timestamp(%node.arg, $_presenter->context->parameters['wwwDir']);');
  5.     }
  6.  
  7.     public static function timestamp($file, $wwwDir)
  8.     {
  9.         $filepath = realpath($wwwDir . '/' . $node->args);
  10.         if (file_exists($filepath)) {
  11.             $mtime = filemtime($filepath);
  12.             $mtime = dechex($mtime);
  13.  
  14.         } else {
  15.             $mtime = 0; // Fail silently
  16.         }
  17.        
  18.         return $filepath . '?' . $mtime;
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment