← Back to team overview

anewt-developers team mailing list archive

[Branch ~uws/anewt/anewt.uws] Rev 1704: [page] Don't use class members for head and body nodes

 

------------------------------------------------------------
revno: 1704
committer: Wouter Bolsterlee <uws@xxxxxxxxx>
branch nick: anewt.uws
timestamp: Tue 2009-07-21 21:06:08 +0200
message:
  [page] Don't use class members for head and body nodes
  
  ... since only the render() method needs access to these
  nodes.
modified:
  page/page.lib.php

=== modified file 'page/page.lib.php'
--- page/page.lib.php	2009-07-20 20:39:48 +0000
+++ page/page.lib.php	2009-07-21 19:06:08 +0000
@@ -16,12 +16,6 @@
  */
 class AnewtPage extends Container
 {
-	/** \private Head element */
-	private $_head;
-
-	/** \private Body element */
-	private $_body;
-
 	/** \private Page content */
 	private $_content;
 
@@ -77,14 +71,6 @@
 			'use-wrapper-div' => true,
 			'wrapper-div-id' => 'wrapper',
 		));
-
-
-		/* Create basic element nodes */
-
-		$this->_head = new AnewtXMLDomElement('head');
-		$this->_body = new AnewtXMLDomElement('body');
-		$this->_head->always_render_closing_tag = true;
-		$this->_body->always_render_closing_tag = true;
 	}
 
 
@@ -382,10 +368,17 @@
 	 */
 	public function render()
 	{
+		/* Create basic element nodes */
+
+		$head = new AnewtXMLDomElement('head');
+		$body = new AnewtXMLDomElement('body');
+		$head->always_render_closing_tag = true;
+		$body->always_render_closing_tag = true;
+
 		/* Content-type in meta tag. This must be the first element inside the
 		 * <head>...</head> element. */
 
-		$this->_head->append_child(ax_meta(array(
+		$head->append_child(ax_meta(array(
 			'http-equiv' => 'Content-type',
 			'content'    => $this->build_content_type_charset(),
 		)));
@@ -405,7 +398,7 @@
 
 			$base = new AnewtXHTMLBase();
 			$base->set_attribute('href', $base_uri);
-			$this->_head->append_child($base);
+			$head->append_child($base);
 		}
 
 
@@ -413,34 +406,34 @@
 
 		$title = $this->_get('title');
 		if (!is_null($title))
-			$this->_head->append_child(ax_title($title));
+			$head->append_child(ax_title($title));
 
 
 		/* Dublin Core metadata. See http://dublincore.org/documents/dcq-html/ * */
 
 		if ($this->_get('show-dublin-core'))
 		{
-			$this->_head->append_child(ax_link(array(
+			$head->append_child(ax_link(array(
 				'rel'  => 'schema.DC',
 				'href' => 'http://purl.org/dc/elements/1.1/')));
 
-			$this->_head->append_child(ax_meta_name_content('DC.language', $this->_get('language')));
+			$head->append_child(ax_meta_name_content('DC.language', $this->_get('language')));
 
 			if (!is_null($title))
-				$this->_head->append_child(ax_meta_name_content('DC.title', $title));
+				$head->append_child(ax_meta_name_content('DC.title', $title));
 
 			if ($this->_isset('creator'))
-				$this->_head->append_child(ax_meta_name_content('DC.creator', $this->_get('creator')));
+				$head->append_child(ax_meta_name_content('DC.creator', $this->_get('creator')));
 
 			if ($this->_isset('description'))
-				$this->_head->append_child(ax_meta_name_content('DC.description', $this->_get('description')));
+				$head->append_child(ax_meta_name_content('DC.description', $this->_get('description')));
 
 			if ($this->_isset('date'))
 				$date = $this->get('date');
 			else
 				$date = AnewtDateTime::now();
 
-			$this->_head->append_child(ax_meta_name_content('DC.date', AnewtDateTime::date($date)));
+			$head->append_child(ax_meta_name_content('DC.date', AnewtDateTime::date($date)));
 		}
 
 
@@ -450,7 +443,7 @@
 		if (!is_null($generator))
 		{
 			assert('is_string($generator);');
-			$this->_head->append_child(ax_meta_name_content('generator', $generator));
+			$head->append_child(ax_meta_name_content('generator', $generator));
 		}
 
 
@@ -460,7 +453,7 @@
 		if (!is_null($robots))
 		{
 			assert('is_string($robots);');
-			$this->_head->append_child(ax_meta(array(
+			$head->append_child(ax_meta(array(
 				'name'    => 'robots',
 				'content' => $robots,
 			)));
@@ -469,8 +462,8 @@
 
 		/* Links (including stylesheets) and JavaScripts */
 
-		$this->_head->append_children($this->_links);
-		$this->_head->append_children($this->_javascripts);
+		$head->append_children($this->_links);
+		$head->append_children($this->_javascripts);
 
 
 		/* Favicon */
@@ -479,7 +472,7 @@
 		if (!is_null($favicon))
 		{
 			assert('is_string($favicon);');
-			$this->_head->append_child(ax_link_favicon($favicon));
+			$head->append_child(ax_link_favicon($favicon));
 		}
 
 
@@ -512,7 +505,7 @@
 				unset ($div);
 			}
 
-			$this->_body->append_child($buffer);
+			$body->append_child($buffer);
 
 		}
 		else
@@ -524,7 +517,7 @@
 				throw new AnewtException('Pages not using blocks should not have content in blocks');
 
 			if ($this->_content)
-				$this->_body->append_child($this->_content);
+				$body->append_child($this->_content);
 		}
 
 
@@ -541,8 +534,8 @@
 			'lang'     => $this->_get('language'),
 			));
 
-		$html->append_child($this->_head);
-		$html->append_child($this->_body);
+		$html->append_child($head);
+		$html->append_child($body);
 		$document->append_child($html);
 
 		return $document;



--
lp:anewt
https://code.launchpad.net/~uws/anewt/anewt.uws

Your team Anewt developers is subscribed to branch lp:anewt.
To unsubscribe from this branch go to https://code.launchpad.net/~uws/anewt/anewt.uws/+edit-subscription.