changeset 84:3a1e20a5b67a

Branc merge.
author Tom Fredrik "BFG" Klaussen <bfg@blenning.no>
date Mon, 15 Oct 2012 16:52:50 +0200
parents ff5fc61aa5ea (current diff) 88904282b888 (diff)
children 590e6950fa7f
files
diffstat 1 files changed, 50 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Page.inc	Mon Oct 15 16:52:28 2012 +0200
+++ b/Page.inc	Mon Oct 15 16:52:50 2012 +0200
@@ -8,37 +8,85 @@
 /// @endcond
 
 /**
- * Functionality for generating a page
+ * Master class for generating a page
  */
 class Page
 {
   private $cache;
 
-  function __construct($cache)
+  /**
+   * Constructs a page
+   *
+   * @param $cache optionally sets a cache
+   */
+  function __construct($cache = null)
   {
     $this->setCache($cache);
   }
 
+  /**
+   * Set the cache
+   *
+   * @param $cache The cache object
+   */
   protected function setCache($cache)
   {
     $this->cache = $cache;
   }
 
+  /**
+   * Get the cache
+   *
+   * @return The cache object
+   */
   protected function getCache()
   {
     return $this->cache;
   }
 
+  /**
+   * Decide wether or not this page may be compressed.
+   *
+   * Normally this is a check for http headers, but some pages
+   * eg. pictures may not want to be compressed, and may override this
+   * function.
+   *
+   * @return bool if this page may be compressed
+   */
   function mayCompress()
   {
     return (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'));
   }
 
+  /**
+   * Turns on compression for this page
+   *
+   * @note This may not be reversed
+   */
   function startCompression()
   {
     ob_start("ob_gzhandler");
   }
 
+  /**
+   * Generates the actual content of the page
+   *
+   * @return the content buffer
+   */
+  abstract function generateContent();
+
+  /**
+   * Finishes all necessary processing to determine the cacheset of this page.
+   *
+   * @return bool if this page may be cached
+   */
+  abstract function cacheCheck();
+
+  /**
+   * Generates an appropriate response to the request.
+   *
+   * Eg. 302 NOT CHANGED, error message or the actual content
+   */
   function genPage()
   {
     if ($this->cacheCheck()) {