DOM Basic: Create DOM documents in pure PHP

Recommend this page to a friend!
  Info   View files Example   View files View files (229)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2018-03-20 (2 years ago) RSS 2.0 feedNot enough user ratingsTotal: 190 This week: 1All time: 8,390 This week: 295Up
Version License PHP version Categories
dom-basic 1.0BSD License5HTML, XML, PHP 5, Libraries
Description Author

This package can create DOM documents in pure PHP.

It can create DOM documents with more options than the traditional DOM classes, like for instance setting the type of document to HTML, XHTML, XML, or custom document type, defining the open and close tags, etc..

Some classes use the singleton pattern, calls can be chained, and errors throw exceptions.

Innovation Award
PHP Programming Innovation award nominee
September 2015
Number 11


Prize: One downloadable copy of Komodo IDE
XML and HTML are used as formats to describe information structured in hierarchies, but there are other hierarchic formats used by many applications like JSON, INI, etc..

This package can define and generate hierarchic documents in XML, HTML, JSON, INI or other formats and switch between them just by changing changing some configuration values that define details like delimiter characters.

Manuel Lemos
  Performance   Level  
Innovation award
Innovation award
Nominee: 1x

Details

DOMbasic

<a href="http://guerratron.github.io/DOMbasic"><img src="http://guerratron.github.io/DOMbasic/assets/DOMbasic_logo.png" title="DOMbasic GitHub page" alt="dombasic logo" /></a> <!--- %% dombasic logo ---> *DOMbasic. Juan José Guerra Haba - 2014 - dinertron@gmail.com dombasic-full@lists.osdn.me - dombasic-private@lists.osdn.me*

DEFINITION:

PHP package to create dynamic DOM elements. It follow the OOP paradigm, implemented SINGLETON patterns, magical methods, contains error control ('own exceptions'), chaining methods, optimized memory and resources, ...

EXPLANATORY:

More flexible and lighter than the native PHP. It allows you to create any document labeling: HTML, XHTML, XML, ... including any user-defined (this includes those who are yet to be implemented) that are based on hierarchies of tags, attributes and content; this You can be achieved simply by modifying the constants file specify, opening and closing tags and a couple of other modifications.

You can create complete websites that adhere to the standards validation of its structure. A tree harbor the only variable element created, this includes visible elements (BODY) and invisible (HEAD), static (HTML) and dynamic (SCRIPTS:. EG Javascript), elements and positioning structure (xHTML) or style (CSS) ...

Although there are other ways to achieve the same (text variables, other APIs, ...) This method is designed for flexibility and dynamism, performance and low resource consumption. Once you understand the mechanism and its syntax, saving time and effort, errors are minimized and DOM construction and automated cleaner is achieved. We all know the problems that can be generated when processing a Web page on the fly successive chaining 'Echo, print, ... " making sure that the headers are not sent in advance; these errors multiplied by a thousand if we use Frameworks or type CMS (Joomla, Wordpress, Drupal, ...)

FEATURES:

They have been implemented utility functions that allow us to quickly convert theDOM* tree JSON text, HTML, XML, ... and vice versa. * Maintain tight control 'Exceptions' providing much information when debugging. Classes that follow theSINGLETON* pattern. * Contains methods 'constructor' and 'destructor' to optimize memory. Methods called magical (getter, setter, unset, clone, toString, ...*). Configuration file writable for the accommodation of the basic parameters ofINI DOM*. Chaining methods [NO GETTER*]. Programming entirely within the paradigmOOP*. * ... Other utility functions.

REQUIREMENTS:

PHP* > 4 The modules that support for readingINI,JSONandXMLfiles, must be enabled inPHP*. * Having wanted to write code. jejejejj

INSTALATION:

1. You do not require installation.

Place the pakage in the desired route by which to call to instructions 'include' or 'require'. (obviously if it's in a compressed format before DECOMPRESS) We suggest creating a folder (for example DOM) and place it inside.

USE:

Load the main input class 'DOM_element' by 'include' or some variant clause:include_once, require ...* by example: ... require(realpath(dirname(__FILE__))."/DOM/DOM_element.php"); ... After this, to creatingDOM* elements: ... $div1=new DOM_element('div1'); ... * Add attributes and properties: ... $div1->setTag("div")->id="container"; ... * Add content: ... $div1->setText("TEXT INTO 'container' DIV")->addChild($div2); ... * Print: ... echo $div1->toHTML(); ...

WEB FLOW CREATION:

* The normal flow for building a Web page would be: DOCTYPE -> HTML (HEAD -> BODY).

All this would contain the entire document. (SEE EXAMPLES FOR MORE FULL SHOW)  

* DOCUMENT:

  No special labels or attributes element is purely the DOM representation, the element tree, the container document in full:
	  `... $document=new DOM_element('document'); ...`  
		`... $document->setTag(''); ...`  
		`...   $conf=array( "TYPE"=>"2", "DESC"=>"",
				               "OPEN_TAG_LEFT"=>"", "OPEN_TAG_RIGHT"=>"", 
				               "CLOSE_TAG_LEFT"=>"", "CLOSE_TAG_RIGHT"=>"" ); ...`  
		`... $document->setConfiguration($conf); ...`  

* DOCTYPE:

  This being another special element (it is an element of definition, structure and style), we should also do it using both special 
	opening tag but no closing and unnamed attributes:  
	  `... $doctype=new DOM_element("doctype"); ...`  
		`... $doctype->setTag("DOCTYPE"); ...`  
		`... $conf=array( "TYPE"=>"doctype", "DESC"=>"Tipo de Documento (DTD)",
										 "OPEN_TAG_LEFT"=>"<!", "OPEN_TAG_RIGHT"=>">", 
										 "CLOSE_TAG_LEFT"=>"", "CLOSE_TAG_RIGHT"=>"" ); ...`  
		`... $doctype->setConfiguration($conf); ...`  
		//STARTING A KEY FOR '_null' means an attribute without key (doctype)  
		`... $doctype->addAttrib("_null1", "-//W3C//DTD XHTML 1.0 Transitional//EN"); ...`  
		`... $doctype->_null2="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"; //atributo asignado diréctamente ...`  
		_NOTE: Also keep in mind that not harbor any element._  

* HTML:

  Container of elements HEAD and BODY. Depending on the type of document to create (HTML 1.0, xHTML, HTML5, ...) 
  will implement those or other parameters:  
	  `... $html=new DOM_element('html'); ...`  
		`... $html->setTag("html"); ...`  
		`... $html->xmlns="http://www.w3.org/1999/xhtml"; ...`  

* HEAD:

  Invisible element of page:  
	  `... $head=new DOM_element('head'); ...`  
	  `... $head->setTag("head")->addChild($title); ...`  

* BODY:

	Visual element of page:  
	  `... $body=new DOM_element('body'); ...`  
		`... $body->setTag("body")->addChild($div1); ...`  

* SEWING OF ELEMENTS:

  `... $html->setChildren(array($html, $body)); ...`  
  `... $document->setChildren(array($doctype, $html)); ...`  

* WEB PRINTING:

  `... echo $document->toHTML(); ...`  

NOTE: (SEE EXAMPLES IN THE 'EXAMPLES' FOLDER FOR A MORE FULL SHOW)  
  Files folder image Files  
File Role Description
Files folder imageassets (2 files)
Files folder imageDOCS (5 files, 2 directories)
Files folder imageexamples (4 files)
Files folder imageexceptions (8 files)
Files folder imageutil (3 files)
Accessible without login Plain text file config.ini Data INI Data File
Plain text file DOM_attribs.php Class Aux. Class
Plain text file DOM_element.php Class Main Class
Plain text file DOM_Interface.php Class Main Interface
Plain text file DOM_textNode.php Class Child Class
Accessible without login HTML file index.html Doc. web access page
Accessible without login Plain text file LICENSE Lic. GNU GPL v2
Accessible without login Plain text file README.md Doc. Howto, instalation, ... mini-Help

 Version Control Unique User Downloads Download Rankings  
 100%
Total:190
This week:1
All time:8,390
This week:295Up

For more information send a message to info at phpclasses dot org.