Example #1
0
		public function __construct($data, $headers=null, $checkbox=null)
		{
			parent::__construct('table', null, null);
			
			if ($headers != null && is_array($headers))
			{
				$head = html('thead');
				$this->addChild($head);
				
				$row = html('tr');
				
				if ($checkbox != null)
				{
					$row->addChild(html('th', html('span', $checkbox)));
				}
				
				foreach($headers as $header)
				{
					$row->addChild(html('th', $header));
				}
				$head->addChild($row);
			}
			
			$body = html('tbody');
			
			foreach($data as $d)
			{
				$row = html('tr');
				
				if ($checkbox != null)
				{
					$td = html('td', 
						html(
							'input', 
							'type=checkbox name='.$checkbox.'[] value='.$d[$checkbox]
						),
						'class='.$checkbox
					);
					$row->addChild($td);
				}
				foreach($d as $name=>$value)
				{
					if ($name == $checkbox) continue;
					$td = html('td', $value, 'class='.$name);
					$row->addChild($td);
				}
				$body->addChild($row);
			}
			$this->addChild($body);
		}
Example #2
0
		/**
		*  Override for the prepareChild method on NodeContainer which 
		*  wraps each elements in a list item
		*  @method prepareChild
		*  @protected
		*  @param {Node|String|Number|Boolean|Array} childNode The child node to add, an array will get converted into another list elements.
		*  @return {Node} The child node
		*/
		protected function prepareChild($childNode)
		{
			// Recursively create new lists for each array
			if (is_array($childNode))
			{
				$list = new SimpleList($childNode, null, $this->_tag);
				return $this->prepareChild($list);
			}
			else
			{
				$childNode = parent::prepareChild($childNode);
				return html('li', $childNode);
			}
		}
Example #3
0
		/**
		*  Add this child to the beginning of a node container
		*  @method prependTo
		*  @param {NodeContainer} container The node container to prepend to to
		*  @return {Node} The instance of this Node
		*/
		public function prependTo(NodeContainer $container)
		{
			$container->addChildAt($this, 0);
			return $this;
		}
Example #4
0
		public function __construct($text)
		{
			parent::__construct($text);
		}
Example #5
0
		/**
		*  Write to HTML
		*  @method __toString
		*  @return {String} The string representation of this HTML node
		*/
		public function __toString()
		{
			$result = $this->docType . parent::__toString();
			if ($this->beautify) 
				$result = self::beautify($result);
			return $result;	
		}
Example #6
0
		public function __construct($children = null)
		{
			parent::__construct('fragment', $children, null);
		}