Esempio n. 1
0
 function RenderChunk($slug = "", $cachelength = "")
 {
     if (!empty($slug)) {
         // Returns a new query or a cached one
         $cache_folder = SERVER_CACHE_ROOT;
         // This usually points to /htdocs/cache/ on Modwest servers
         if (empty($cachelength)) {
             $cachelength = 60 * 60 * 3;
         }
         // seconds * minutes * hours = cache for 3 hours
         $usecache = false;
         $cachefile = $cache_folder . $slug . '.html';
         $user = Users::GetCurrentUser();
         // Skip using a cached file is there is a user logged in right now
         if (empty($user)) {
             // Check if we have this request cached recently;
             if (file_exists($cachefile)) {
                 if (time() - filemtime($cachefile) <= $cachelength) {
                     // Is this file recent enough to use?
                     $cachecontents = file_get_contents($cachefile);
                     // Return the cached xml
                     if (!empty($cachecontents)) {
                         return $cachecontents;
                         $usecache = true;
                         // not neccesary, as the return statement stops execution
                     }
                 } else {
                     unlink($cachefile);
                 }
                 // File stale or empty, delete
             }
         }
         if (!$usecache) {
             $result = Chunks::FindBySlug($slug);
             $result = image_display($result->content);
             $result = email_display($result);
             // Store our cache version
             file_put_contents($cachefile, $result);
             return $result;
         }
     } else {
         return null;
     }
 }
Esempio n. 2
0
 function get_content()
 {
     if (array_key_exists('content', $this)) {
         $content = $this->content;
     } elseif (array_key_exists('description', $this)) {
         $content = $this->description;
     } else {
         return null;
     }
     if (isset($content)) {
         // The order in which these run is important.
         $content = document_display($content);
         // searching for {{document:name_of_doc{{ pattern
         $content = video_display($content);
         // searching for {{video:name_of_vid{{ pattern
         $content = email_display($content);
         /// Need to run email before we insert them from a product
         $content = product_display($content);
         // searching for {{product:name_of_product{{ pattern
         $content = image_display($content);
         // searching for {{name_of_image{{ pattern
         $content = gallery_display($content);
         // searching for {{galery:name_of_gal{{ pattern
         $content = carousel_display($content);
         // searching for {{carousel:name_of_gal{{ pattern
         $content = random_from_gallery_display($content);
         // searching for {{random-from-gallery:name_of_gal{{ pattern
         $content = testimonial_display($content);
         // searching for {{testimonial:name_of_test{{ pattern
         return $content;
     }
 }