mirror of
				https://github.com/Mibew/CanteenHTML5.git
				synced 2025-10-31 18:31:05 +03:00 
			
		
		
		
	Compare commits
	
		
			5 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| a5b4190d60 | |||
| 6d7736e222 | |||
| 9f7340ec78 | |||
| 7bdec8e106 | |||
| a29ea00c29 | 
| @ -10,4 +10,4 @@ docs.helpers=${docs.themedir}/path.js | ||||
| git=git | ||||
| git.docs=gh-pages | ||||
| git.master=master | ||||
| version=1.1.4 | ||||
| version=1.1.5 | ||||
|  | ||||
| @ -1,32 +1,48 @@ | ||||
| { | ||||
| 	"name": "canteen/html5", | ||||
|     "name": "mibew/html5", | ||||
|     "description" : "Create dynamic, valid HTML5 markup with a simple an intuitive PHP API", | ||||
| 	"version" : "1.1.4", | ||||
|     "version" : "1.1.5", | ||||
|     "type": "library", | ||||
| 	"keywords": ["html5", "markup", "document", "html", "tags"], | ||||
|     "keywords": [ | ||||
|         "html5", | ||||
|         "markup", | ||||
|         "document", | ||||
|         "html", | ||||
|         "tags" | ||||
|     ], | ||||
|     "license": "MIT", | ||||
| 	"homepage" : "http://github.com/Canteen/CanteenHTML5", | ||||
| 	"time": "2014-10-31", | ||||
|     "homepage" : "http://github.com/Mibew/CanteenHTML5", | ||||
|     "time": "2021-07-09", | ||||
|     "authors": [ | ||||
|         { | ||||
|             "name": "Matt Karl", | ||||
|             "email": "matt@mattkarl.com", | ||||
|         	    "homepage": "http://github.com/bigtimebuddy", | ||||
|         	    "role": "Developer" | ||||
|             "homepage": "http://github.com/bigtimebuddy" | ||||
|         }, | ||||
|         { | ||||
|             "name": "Mibew Messenger project", | ||||
|             "homepage": "https://mibew.org/" | ||||
|         } | ||||
|     ], | ||||
|     "autoload": { | ||||
|         	"psr-4": {"Canteen\\HTML5\\": "src/"}, | ||||
|         	"files": ["src/HTML5.php"] | ||||
|         "psr-4": { | ||||
|             "Canteen\\HTML5\\": "src/" | ||||
|         }, | ||||
|         "files": [ | ||||
|             "src/HTML5.php" | ||||
|         ] | ||||
|     }, | ||||
|     "require": { | ||||
|         "php": ">=5.3.0" | ||||
|     }, | ||||
|     "replace": { | ||||
|         "canteen/html5": "~1.1.4" | ||||
|     }, | ||||
|     "minimum-stability": "dev", | ||||
|     "repositories": [ | ||||
|         { | ||||
|             "type": "vcs", | ||||
| 			"url": "https://github.com/Canteen/CanteenHTML5" | ||||
|             "url": "https://github.com/Mibew/CanteenHTML5" | ||||
|         } | ||||
|     ] | ||||
| } | ||||
|  | ||||
| @ -53,5 +53,3 @@ | ||||
| 
 | ||||
|     // Output the result formatted nice with indents
 | ||||
|     echo $doc; | ||||
| 
 | ||||
| ?>
 | ||||
| @ -113,7 +113,7 @@ namespace Canteen\HTML5 | ||||
|             // Match the name=value in the attributes string
 | ||||
|             preg_match_all('/([a-z]+[a-z\-]*)\=("[^\"]*"|\'[^\']*\'|[^\s\"\']*)/',$str, $arr); | ||||
| 
 | ||||
| 			foreach($arr[1] as $i=>$name) | ||||
|             foreach ($arr[1] as $i=>$name) | ||||
|             { | ||||
|                 $value = $arr[2][$i]; | ||||
| 
 | ||||
| @ -135,10 +135,14 @@ namespace Canteen\HTML5 | ||||
|         public function __get($name) | ||||
|         { | ||||
|             if (method_exists($this , $method =('get' . ucfirst($name)))) | ||||
|             { | ||||
|                 return $this->$method(); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 throw new HTML5Error(HTML5Error::INVALID_GETTER, $name); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /** | ||||
|         *  General purpose setter for setting attribute->name and attribute->value | ||||
| @ -149,10 +153,14 @@ namespace Canteen\HTML5 | ||||
|         public function __set($name, $value) | ||||
|         { | ||||
|             if (method_exists($this , $method =('set' . ucfirst($name)))) | ||||
|             { | ||||
|                 return $this->$method($value); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 throw new HTML5Error(HTML5Error::INVALID_SETTER, $name); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /** | ||||
|         *  See if a property exists | ||||
| @ -166,5 +174,3 @@ namespace Canteen\HTML5 | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| ?>
 | ||||
| @ -30,9 +30,7 @@ namespace Canteen\HTML5 | ||||
|         */ | ||||
|         public function __toString() | ||||
|         { | ||||
| 			return '<!-- '.$this->_tag.' -->'; | ||||
|             return '<!-- ' . $this->_tag . ' -->'; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| ?>
 | ||||
| @ -70,7 +70,7 @@ namespace Canteen\HTML5 | ||||
|             $this->body = html('body'); | ||||
|             $this->title = html('title', $title); | ||||
| 
 | ||||
| 			$this->head->addChild(html('meta', 'charset='.$charset)); | ||||
|             $this->head->addChild(html('meta', 'charset=' . $charset)); | ||||
|             $this->head->addChild($this->title); | ||||
| 
 | ||||
|             $this->addChild($this->head); | ||||
| @ -86,7 +86,9 @@ namespace Canteen\HTML5 | ||||
|         { | ||||
|             $result = $this->docType . parent::__toString(); | ||||
|             if ($this->beautify) | ||||
|             { | ||||
|                 $result = self::beautify($result); | ||||
|             } | ||||
|             return $result; | ||||
|         } | ||||
| 
 | ||||
| @ -113,5 +115,3 @@ namespace Canteen\HTML5 | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| ?>
 | ||||
| @ -31,7 +31,7 @@ namespace Canteen\HTML5 | ||||
|         public function __toString() | ||||
|         { | ||||
|             $buffer = ''; | ||||
| 			foreach($this->getChildren() as $child) | ||||
|             foreach ($this->getChildren() as $child) | ||||
|             { | ||||
|                 $buffer .= $child->__toString(); | ||||
|             } | ||||
| @ -39,5 +39,3 @@ namespace Canteen\HTML5 | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| ?>
 | ||||
| @ -22,7 +22,10 @@ namespace Canteen\HTML5 | ||||
|             spl_autoload_register(function($name) | ||||
|             { | ||||
|                 // Ignore class names not in the HTML5 namespace
 | ||||
| 				if (!preg_match('/^Canteen\\\HTML5\\\/', $name)) return; | ||||
|                 if (!preg_match('/^Canteen\\\HTML5\\\/', $name)) | ||||
|                 { | ||||
|                     return; | ||||
|                 } | ||||
| 
 | ||||
|                 // Remove the HTML5 namespace
 | ||||
|                 $name = preg_replace('/^Canteen\\\HTML5\\\/', '', $name); | ||||
| @ -31,7 +34,7 @@ namespace Canteen\HTML5 | ||||
|                 $name = str_replace("\\", '/', $name); | ||||
| 
 | ||||
|                 // Include the class relative to here
 | ||||
| 				include __DIR__.'/'.$name.'.php'; | ||||
|                 include __DIR__ . '/' . $name . '.php'; | ||||
|             }); | ||||
|         } | ||||
| 
 | ||||
| @ -41,7 +44,7 @@ namespace Canteen\HTML5 | ||||
|         */ | ||||
|         static public function useGlobal() | ||||
|         { | ||||
| 			include __DIR__.'/html.php'; | ||||
|             include __DIR__ . '/html.php'; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @ -152,15 +155,17 @@ namespace Canteen\HTML5 | ||||
|             new NodeContainer($tag, $childrenOrAttributes, $attributes); | ||||
| 
 | ||||
|         // Take the selectors convert them into id or class
 | ||||
| 		foreach($selectors[0] as $selector) | ||||
|         foreach ($selectors[0] as $selector) | ||||
|         { | ||||
| 			switch($selector[0]) | ||||
|             switch ($selector[0]) | ||||
|             { | ||||
|                 case '#' : | ||||
|                     $node->id = substr($selector, 1); | ||||
|                     break; | ||||
|                 case '.' : | ||||
| 					if ($node->class) $node->class .= ' '; | ||||
|                     if ($node->class) { | ||||
|                         $node->class .= ' '; | ||||
|                     } | ||||
|                     $node->class .= substr($selector, 1); | ||||
|                     break; | ||||
|             } | ||||
|  | ||||
| @ -140,5 +140,3 @@ namespace Canteen\HTML5 | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| ?>
 | ||||
							
								
								
									
										19
									
								
								src/Node.php
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								src/Node.php
									
									
									
									
									
								
							| @ -12,11 +12,12 @@ namespace Canteen\HTML5 | ||||
|     *       echo html('br'); | ||||
|     * | ||||
|     *  @class Node | ||||
|     *  @extends Proto | ||||
|     *  @constructor | ||||
|     *  @param {String} [tag=null] The name of the tag | ||||
|     *  @param {Array|String} [attributes=null] The collection of tag attributes | ||||
|     */ | ||||
| 	class Node | ||||
|     class Node extends Proto | ||||
|     { | ||||
|         /** | ||||
|         *  The string name of the tag | ||||
| @ -133,14 +134,18 @@ namespace Canteen\HTML5 | ||||
|             { | ||||
|                 throw new HTML5Error(HTML5Error::EMPTY_ATTRIBUTE_NAME); | ||||
|             } | ||||
| 			foreach($this->_attributes as $i=>$attribute)  | ||||
|             foreach ($this->_attributes as $i=>$attribute) | ||||
|             { | ||||
|                 if ($attribute->name === $name) | ||||
|                 { | ||||
|                     if (!$this->isEmpty($value)) | ||||
|                     { | ||||
|                         $attribute->value = $value; | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         unset($this->_attributes[$i]); | ||||
|                     } | ||||
|                     return $this; | ||||
|                 } | ||||
|             } | ||||
| @ -164,7 +169,7 @@ namespace Canteen\HTML5 | ||||
|             { | ||||
|                 throw new HTML5Error(HTML5Error::EMPTY_ATTRIBUTE_NAME); | ||||
|             } | ||||
| 			foreach($this->_attributes as $attribute)  | ||||
|             foreach ($this->_attributes as $attribute) | ||||
|             { | ||||
|                 if ($attribute->name === $name) | ||||
|                 { | ||||
| @ -185,7 +190,7 @@ namespace Canteen\HTML5 | ||||
|         { | ||||
|             if (is_array($values)) | ||||
|             { | ||||
| 				foreach($values as $name=>$value) | ||||
|                 foreach ($values as $name=>$value) | ||||
|                 { | ||||
|                     $this->setAttribute($name, $value); | ||||
|                 } | ||||
| @ -236,7 +241,7 @@ namespace Canteen\HTML5 | ||||
|         */ | ||||
|         public function getData($name) | ||||
|         { | ||||
| 			return $this->getAttribute('data-'.$name);	 | ||||
|             return $this->getAttribute('data-' . $name); | ||||
|         } | ||||
| 
 | ||||
|         /** | ||||
| @ -260,7 +265,7 @@ namespace Canteen\HTML5 | ||||
|         { | ||||
|             $buffer = '<'; | ||||
|             $buffer .= $this->_tag; | ||||
| 			foreach($this->_attributes as $attribute)  | ||||
|             foreach ($this->_attributes as $attribute) | ||||
|             { | ||||
|                 $buffer .= (string)$attribute; | ||||
|             } | ||||
| @ -336,5 +341,3 @@ namespace Canteen\HTML5 | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| ?>
 | ||||
| @ -45,7 +45,7 @@ namespace Canteen\HTML5 | ||||
|                 } | ||||
|                 if (is_array($children)) | ||||
|                 { | ||||
| 					foreach($children as $child) | ||||
|                     foreach ($children as $child) | ||||
|                     { | ||||
|                         $this->addChild($child); | ||||
|                     } | ||||
| @ -141,7 +141,7 @@ namespace Canteen\HTML5 | ||||
|                 throw new HTML5Error(HTML5Error::EMPTY_CHILD); | ||||
|             } | ||||
| 
 | ||||
| 			for($i = 0; $i < count($this->_children); $i++) | ||||
|             for ($i = 0; $i < count($this->_children); $i++) | ||||
|             { | ||||
|                 $child = $this->_children[$i]; | ||||
|                 if ($child === $childNode) | ||||
| @ -223,7 +223,7 @@ namespace Canteen\HTML5 | ||||
|         public function __toString() | ||||
|         { | ||||
|             $buffer = $this->writeOpen(false); | ||||
| 			foreach($this->_children as $child) | ||||
|             foreach ($this->_children as $child) | ||||
|             { | ||||
|                 $buffer .= $child->__toString(); | ||||
|             } | ||||
| @ -233,5 +233,3 @@ namespace Canteen\HTML5 | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| ?>
 | ||||
							
								
								
									
										37
									
								
								src/Proto.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/Proto.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
| *  @module Canteen\HTML5 | ||||
| */ | ||||
| namespace Canteen\HTML5 | ||||
| { | ||||
|     /** | ||||
|     *  Prototype class for all Canteen\HTML5 entities | ||||
|     *  | ||||
|     *  @class Proto | ||||
|     *  @constructor | ||||
|     *  @param {String} text the plain text string | ||||
|     */ | ||||
|     class Proto | ||||
|         { | ||||
|         /** | ||||
|         *  General purpose getter to get attribute values | ||||
|         *  @method __get | ||||
|         *  @param {String} name The name of the property to set | ||||
|         */ | ||||
|         public function __get($name) | ||||
|         { | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         /** | ||||
|         *  See if a property exists | ||||
|         *  @method __isset | ||||
|         *  @param {String} name The name of the attribute | ||||
|         */ | ||||
|         public function __isset($name) | ||||
|         { | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -37,7 +37,7 @@ namespace Canteen\HTML5 | ||||
|             { | ||||
|                 assert(is_array($elements)); | ||||
| 
 | ||||
| 				foreach($elements as $child) | ||||
|                 foreach ($elements as $child) | ||||
|                 { | ||||
|                     $this->addChild($child); | ||||
|                 } | ||||
| @ -68,5 +68,3 @@ namespace Canteen\HTML5 | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| ?>
 | ||||
| @ -58,7 +58,9 @@ namespace Canteen\HTML5 | ||||
|                 'target' | ||||
|             ), | ||||
|             'bdo' => array(), | ||||
| 			'blockquote' => array('cite'), | ||||
|             'blockquote' => array( | ||||
|                 'cite' | ||||
|             ), | ||||
|             'body' => array(), | ||||
|             'br' => array(), | ||||
|             'button' => array( | ||||
| @ -82,7 +84,9 @@ namespace Canteen\HTML5 | ||||
|             'cite' => array(), | ||||
|             'code' => array(), | ||||
|             'col' => null, | ||||
| 			'colgroup' => array('span'), | ||||
|             'colgroup' => array( | ||||
|                 'span' | ||||
|             ), | ||||
|             'command' => array( | ||||
|                 'checked', | ||||
|                 'disabled', | ||||
| @ -137,7 +141,9 @@ namespace Canteen\HTML5 | ||||
|             'header' => array(), | ||||
|             'hgroup' => array(), | ||||
|             'hr' => array(), | ||||
| 			'html' => array('manifest'), | ||||
|             'html' => array( | ||||
|                 'manifest' | ||||
|             ), | ||||
|             'img' => array( | ||||
|                 'alt', | ||||
|                 'crossorigin', | ||||
| @ -207,7 +213,9 @@ namespace Canteen\HTML5 | ||||
|                 'sizes', | ||||
|                 'type' | ||||
|             ), | ||||
| 			'map' => array('name'), | ||||
|             'map' => array( | ||||
|                 'name' | ||||
|             ), | ||||
|             'mark' => array(), | ||||
|             'menu' => array(), | ||||
|             'meta' => array( | ||||
| @ -266,7 +274,9 @@ namespace Canteen\HTML5 | ||||
|                 'max', | ||||
|                 'value' | ||||
|             ), | ||||
| 			'q' => array('cite'), | ||||
|             'q' => array( | ||||
|                 'cite' | ||||
|             ), | ||||
|             'rp' => array(), | ||||
|             'rt' => array(), | ||||
|             'ruby' => array(), | ||||
| @ -290,18 +300,22 @@ namespace Canteen\HTML5 | ||||
|                 'size' | ||||
|             ), | ||||
|             'small' => array(), | ||||
| 			'source' => array('media', | ||||
|             'source' => array( | ||||
|                 'media', | ||||
|                 'src', | ||||
|                 'type' | ||||
|             ), | ||||
|             'span' => array(), | ||||
|             'strong' => array(), | ||||
| 			'style' => array('media', | ||||
|             'style' => array( | ||||
|                 'media', | ||||
|                 'scoped', | ||||
|                 'type' | ||||
|             ), | ||||
|             'sub' => array(), | ||||
| 			'table' => array('border'), | ||||
|             'table' => array( | ||||
|                 'border' | ||||
|             ), | ||||
|             'tbody' => array(), | ||||
|             'td' => array( | ||||
|                 'colspan', | ||||
| @ -329,7 +343,9 @@ namespace Canteen\HTML5 | ||||
|                 'scope' | ||||
|             ), | ||||
|             'thead' => array(), | ||||
| 			'time' => array('datetime'), | ||||
|             'time' => array( | ||||
|                 'datetime' | ||||
|             ), | ||||
|             'title' => array(), | ||||
|             'tr' => array(), | ||||
|             'track' => array( | ||||
|  | ||||
| @ -46,7 +46,7 @@ namespace Canteen\HTML5 | ||||
|                     $row->addChild(html('th', html('span', $checkbox))); | ||||
|                 } | ||||
| 
 | ||||
| 				foreach($headers as $header) | ||||
|                 foreach ($headers as $header) | ||||
|                 { | ||||
|                     $row->addChild(html('th', $header)); | ||||
|                 } | ||||
| @ -55,7 +55,7 @@ namespace Canteen\HTML5 | ||||
| 
 | ||||
|             $body = html('tbody'); | ||||
| 
 | ||||
| 			foreach($data as $d) | ||||
|             foreach ($data as $d) | ||||
|             { | ||||
|                 $row = html('tr'); | ||||
| 
 | ||||
| @ -64,16 +64,19 @@ namespace Canteen\HTML5 | ||||
|                     $td = html('td', | ||||
|                         html( | ||||
|                             'input', | ||||
| 							'type=checkbox name='.$checkbox.'[] value='.$d[$checkbox] | ||||
|                             'type=checkbox name=' . $checkbox . '[] value='.$d[$checkbox] | ||||
|                         ), | ||||
| 						'class='.$checkbox | ||||
|                         'class=' . $checkbox | ||||
|                     ); | ||||
|                     $row->addChild($td); | ||||
|                 } | ||||
| 				foreach($d as $name=>$value) | ||||
|                 foreach ($d as $name=>$value) | ||||
|                 { | ||||
| 					if ($name == $checkbox) continue; | ||||
| 					$td = html('td', $value, 'class='.$name); | ||||
|                     if ($name == $checkbox) | ||||
|                     { | ||||
|                         continue; | ||||
|                     } | ||||
|                     $td = html('td', $value, 'class=' . $name); | ||||
|                     $row->addChild($td); | ||||
|                 } | ||||
|                 $body->addChild($row); | ||||
| @ -82,5 +85,3 @@ namespace Canteen\HTML5 | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| ?>
 | ||||
| @ -35,5 +35,3 @@ namespace Canteen\HTML5 | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| ?>
 | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user