comparison Page.inc @ 94:2370f4450983

Document functions and move a few functions to more appropriate places.
author Tom Fredrik Blenning Klaussen <bfg@blenning.no>
date Thu, 18 Oct 2012 17:33:34 +0200
parents 8aadd7a23b68
children d98e315308cd
comparison
equal deleted inserted replaced
93:8aadd7a23b68 94:2370f4450983
6 $cache = ScriptIncludeCache::instance(__FILE__); 6 $cache = ScriptIncludeCache::instance(__FILE__);
7 $cache->includeOnce('OnlineBufferValidator.inc', $baseDir); 7 $cache->includeOnce('OnlineBufferValidator.inc', $baseDir);
8 $cache->includeOnce('Options.inc', $baseDir); 8 $cache->includeOnce('Options.inc', $baseDir);
9 /// @endcond 9 /// @endcond
10 10
11 /**
12 * Container for headers and content, used for compounding these
13 */
11 class PageContent 14 class PageContent
12 { 15 {
16 /// The headers for the page
13 public $headers = array(); 17 public $headers = array();
18 /// The content of the page
14 public $content; 19 public $content;
15 20
21 /**
22 * Constructs a PageContent object containing only content
23 *
24 * @param $content The content of this page
25 */
16 function __construct($content = "") 26 function __construct($content = "")
17 { 27 {
18 $this->content = $content; 28 $this->content = $content;
19 } 29 }
20 30
31 /**
32 * Sets a header
33 *
34 * @param $headername Name of the header
35 * @param $value Value for the header
36 */
21 function setHeader($headername, $value) 37 function setHeader($headername, $value)
22 { 38 {
23 $this->headers[$headername] = $value; 39 $this->headers[$headername] = $value;
24 } 40 }
25 41
42 /**
43 * Returns a string representation of this object, containing only
44 * the content
45 *
46 * @return the content of the page
47 */
26 function __toString() 48 function __toString()
27 { 49 {
28 return $this->content; 50 return $this->content;
29 } 51 }
30 } 52 }
158 throw new InvalidArgumentException("generateContent returned an unexpected type"); 180 throw new InvalidArgumentException("generateContent returned an unexpected type");
159 } 181 }
160 return $res; 182 return $res;
161 } 183 }
162 184
185 /**
186 * Displays the result from genPage.
187 *
188 * Printing headers and content.
189 */
163 function display() 190 function display()
164 { 191 {
165 $res = $this->genPage(); 192 $res = $this->genPage();
166 foreach ($res->headers as $header => $value) { 193 foreach ($res->headers as $header => $value) {
167 header("${header}: ${value}"); 194 header("${header}: ${value}");