Esempio n. 1
0
 function funky_cache_create($page)
 {
     if ($page->funky_cache_enabled) {
         $data['url'] = URI_PUBLIC . CURRENT_URI . URL_SUFFIX;
         // Correct URL for frontpage - should become index.html
         if ($data['url'] == URI_PUBLIC . URL_SUFFIX) {
             $data['url'] = URI_PUBLIC . 'index' . funky_cache_suffix();
         }
         $data['url'] = funky_cache_folder() . $data['url'];
         $data['url'] = preg_replace('#//#', '/', $data['url']);
         $data['page'] = $page;
         if (!($cache = FunkyCachePage::findOneFrom('FunkyCachePage', 'url=?', array($data['url'])))) {
             $cache = new FunkyCachePage($data);
         }
         $cache->page = $page;
         $cache->save();
     }
 }
Esempio n. 2
0
 public function beforeSave()
 {
     $this->created_on = date('Y-m-d H:i:s');
     /* If directories do not exist create them. */
     $parts = explode('/', $this->path());
     $file = array_pop($parts);
     /* If deep link create directories when needed. */
     $dir = '';
     foreach ($parts as $part) {
         if (!is_dir($dir .= "/{$part}")) {
             mkdir($dir);
         }
     }
     /* Fix case when articles.html is created before articles/ */
     /* TODO This still creates on extra directory in the end.  */
     if ('archive' == $this->page->behavior_id || $this->page instanceof PageArchive) {
         $dir .= '/' . basename($file, funky_cache_suffix());
         if (!is_dir($dir)) {
             mkdir($dir);
         }
     }
     return file_put_contents($this->path(), $this->content(), LOCK_EX);
 }
Esempio n. 3
0
  if (-f $document_root<?php 
echo URI_PUBLIC;
echo trim(funky_cache_folder(), '/');
echo URI_PUBLIC;
?>
index<?php 
echo funky_cache_suffix();
?>
) {
      rewrite ^/$ <?php 
echo URI_PUBLIC;
echo trim(funky_cache_folder(), '/');
echo URI_PUBLIC;
?>
index<?php 
echo funky_cache_suffix();
?>
 last;
  }

  # Check for other cached pages from static cache folder.
  if (-f $document_root<?php 
echo URI_PUBLIC;
echo trim(funky_cache_folder(), '/');
?>
$request_uri) {
      rewrite (.*) <?php 
echo URI_PUBLIC;
echo trim(funky_cache_folder(), '/');
?>
$request_uri last;