OSDN Git Service

Creación y administración de documentos basados en DOM mediante PHP
[dombasic/DOMbasic.git] / README.txt
1 ------------------------------------------------------------
2 DOMbasic. Juan José Guerra Haba - 2014 - dinertron@gmail.com
3 dombasic-full@lists.osdn.me - dombasic-private@lists.osdn.me
4 ------------------------------------------------------------
5
6 DEFINITION:
7 ----------
8 Pakete written in PHP to create DOM elements dynamically.
9 Follow the OOP paradigm, implemented SINGLETON patterns, magical methods,
10 contains error control ('own exceptions'), chaining methods,
11 optimized memory and resources, ...
12
13 EXPLANATORY:
14 -----------
15 More flexible and lighter than the native PHP. It allows you to create any
16 document labeling: HTML, XHTML, XML, ... including any
17 user-defined (this includes those who are yet to be implemented)
18 that are based on hierarchies of tags, attributes and content; this
19 You can be achieved simply by modifying the constants file specify, 
20 opening and closing tags and a couple of other modifications.
21
22 You can create complete websites that adhere to the standards
23 validation of its structure. A tree harbor the only variable element
24 created, this includes visible elements (BODY) and invisible (HEAD)
25 static (HTML) and dynamic (SCRIPTS:. EG Javascript), elements
26 and positioning structure (xHTML) or style (CSS) ...
27
28 Although there are other ways to achieve the same (text variables, other APIs, ...)
29 This method is designed for flexibility and dynamism, performance and low resource consumption.
30 Once you understand the mechanism and its syntax, saving time and effort, errors are minimized
31 and DOM construction and automated cleaner is achieved.
32 We all know the problems that can be generated when processing a Web page on the fly successive chaining
33 'Echo, print, ... " making sure that the headers are not sent in advance; these errors
34 multiplied by a thousand if we use Frameworks or type CMS (Joomla, Wordpress, Drupal, ...)
35
36 CARACTERÍSTICAS:
37 ---------------
38   - They have been implemented utility functions that allow us to quickly convert the DOM tree
39 JSON text, HTML, XML, ... and vice versa.
40   - Maintain tight control 'Exceptions' providing much information when debugging.
41   - Classes that follow the SINGLETON pattern.
42   - Contains methods 'builders' and 'destructive' to optimize memory.
43   - Methods called magical (getter, setter, unset, clone, toString, ...).
44   - Configuration file writable for the accommodation of the basic parameters of INI DOM.
45   - Chaining methods [NO GETTER].
46   - Programming entirely within the paradigm OOP.
47   - ... Other utility functions.
48
49 REQUISITOS:
50  - PHP > 4
51  - The modules that support for reading INI, JSON and XML files, must be enabled in PHP.
52  - Having wanted to write code. jejejejj
53  
54 INSTALACION:
55  - You do not require installation. Place the Pakete in the desired route by which to call to instructions 'include' or 'require'.
56    (obviously if it's in a compressed format before DECOMPRESS)
57   We suggest creating a folder (for example DOM) and place it inside.
58  
59 UTILIZACIÓN:
60  - Load the main input class 'DOM_element' by 'include' or some variant clause: include_once, require ...
61    by example: ... require(realpath(dirname(__FILE__))."/DOM/DOM_element.php");
62  - After this, to creating DOM elements:
63    ... $div1=new DOM_element('div1'); ...
64  - Add attributes and properties:
65    ... $div1->setTag("div")->id="container"; ...
66  - Add content:
67    ... $div1->setText("TEXTO DENTRO DE DIV 'contenedor'")->addChild($div2); ...
68  - Print:
69    ... echo $div1->toHTML(); ...
70          
71 FLUJO EN CREACIÓN DE PÁGINA WEB:
72   - The normal flow for building a Web page would be: DOCTYPE -> HTML (HEAD -> BODY). All this would contain the entire document.
73    (SEE EXAMPLES FOR MORE FULL SHOW)
74         
75         - DOCUMENT:
76           No special labels or attributes element is purely the DOM representation, the element tree, the container document in full:
77                   ... $document=new DOM_element('document'); ...
78                         ... $document->setTag(''); ...
79                         ...   $conf=array( "TYPE"=>"2", "DESC"=>"",
80                                                        "OPEN_TAG_LEFT"=>"", "OPEN_TAG_RIGHT"=>"", "CLOSE_TAG_LEFT"=>"", "CLOSE_TAG_RIGHT"=>"" );
81                         ... $document->setConfiguration($conf);
82                         
83         - DOCTYPE:
84           This being another special element (it is an element of definition, structure and style), we should also do it using both special 
85                 opening tag but no closing and unnamed attributes:
86                   ... $doctype=new DOM_element("doctype"); ...
87                         ... $doctype->setTag("DOCTYPE"); ...
88                         ... $conf=array( "TYPE"=>"doctype", "DESC"=>"Tipo de Documento (DTD)",
89                                                                                          "OPEN_TAG_LEFT"=>"<!", "OPEN_TAG_RIGHT"=>">", "CLOSE_TAG_LEFT"=>"", "CLOSE_TAG_RIGHT"=>"" );
90                         ... $doctype->setConfiguration($conf);
91                         //STARTING A KEY FOR '_null' means an attribute without key (doctype)
92                         ... $doctype->addAttrib("_null1", "-//W3C//DTD XHTML 1.0 Transitional//EN"); ...
93                         ... $doctype->_null2="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"; //atributo asignado diréctamente ...
94                         NOTE: Also keep in mind that not harbor any element.
95         
96         - HTML:
97           Container of elements HEAD and BODY. Depending on the type of document to create (HTML 1.0, xHTML, HTML5, ...) will implement 
98                 those or other parameters:
99                   ... $html=new DOM_element('html'); ...
100                         ... $html->setTag("html"); ...
101                         ... $html->xmlns="http://www.w3.org/1999/xhtml"; ...
102                         
103         - HEAD:
104           Invisible element of the page:
105                   ... $head=new DOM_element('head'); ...
106                   ... $head->setTag("head")->addChild($title); ...
107         
108         - BODY:
109                 Visual element of the page:
110                   ... $body=new DOM_element('body'); ...
111                         ... $body->setTag("body")->addChild($div1); ...
112         
113         - SEWING OF ELEMENTS:
114           ... $html->setChildren(array($html, $body));
115           ... $document->setChildren(array($doctype, $html)); ...
116                 
117         - WEB PRINTING:
118           ... echo $document->toHTML(); ...
119                 
120         NOTE: (SEE EXAMPLES IN THE 'EXAMPLES' FOLDER FOR A MORE FULL SHOW)