| 
ref = [
	{func:"sacar_comillas", descript:'Remove quotes from a string. It is used within other functions where stripslashes function does not work', 
		usage:'string $xhtml_parte-><b>sacar_comillas</b>( string <i>$str</i>)',
		parameters:[{param:'str',desc:'the string with quotes to be removed'}],
		returned:'string without quotes and without escaped internal quotes',
		examples:[{subt:'Removing quotes from text',
		code:"$str1 = "'quoted text'";<br />$str2 = $xhtml_parte->sacar_comillas($str1);<br />echo $str2; // this will output: quoted text"}]},
	{func:"propiedades", descript:'Get all the properties declared in a tag', 
		usage:'array $xhtml_parte-><b>propiedades</b>( string <i>$tag</i>)',
		parameters:[{param:'tag',desc:'the string with the tag in xhtml code'}],
		returned:'array width attribute as key and value as array value',
		examples:[{subt:'Getting properties of a tag',
		code:'$tag = "<img src='image.jpg' border='0' />";'+
			'<br />print_r($xhtml_parte->propiedades($tag));'+
			'<br />// Array ( [src] => 'image.jpg', [border] => 0)'}]},
	{func:"recomponer", descript:'Restore an property array into a string with xhtml code tag', 
		usage:'array $xhtml_parte-><b>recomponer</b>( string <i>$tagName</i>, array <i>$properties</i> '+
			'[, string <i>$quot</i>])',
		parameters:[{param:'tagName',desc:'the name of the element to represent its opening tag'},
			{param:'properties',desc:'Array where key is attribute name and value is the value of that attribute'},
			{param:'quot',desc:'Optional. Character to quote values it can be ' (default) or "'}],
		returned:'String with opening tag, or false on error and a <a href="#" onclick="show_ref(\'log\')">log</a> entry',
		examples:[{subt:'Compose an img tag',
		code:'$prp = array("src"=>"file.jpg", "alt"=>"just an image");'+
			'<br />print $xhtml_parte->recomponer("img",$prp);'+
			'<br />// <img src='file.jpg' alt='just an image' />'}]},
	{func:"cambiar_propiedad_dom", descript:'Append, delete or replace an existing tag property in each selected tag', 
		usage:'array $xhtml_parte-><b>cambiar_propiedad_dom</b>( string <i>$xhtml</i>, string <i>$sel_tag</i>, '+
			' string <i>$sel_attribute</i>, string <i>$sel_value</i>, '+
			'string <i>$attribute</i>, mixed <i>$value</i> [,bool <i>$over</i>])',
		parameters:[{param:'xhtml', desc:'Optional. The string with the xhtml code where fragment will be deleted. '+
						'If it is setted to false, object's DOM string will be assumed'},
			{param:'sel_tag',desc:'The tag where property will be affected. The method selects all <tag...>'+
						'and append/delete/replace property. '+
						'<br />See method <a href="#" onclick="show_ref(\'etiquetas\')">etiquetas</a> for more details on this'+
						'parameter'},
			{param:'sel_attribute',desc:'The attribute that must be in tag where property will be affected. '+
						'The method selects all <tag...attribute...> and append/delete/replace property. '+
						'<br />See method <a href="#" onclick="show_ref(\'etiquetas\')">etiquetas</a> for more details on this'+
						'parameter'},
			{param:'sel_value',desc:'The attribute'value that must be in tag where property will be affected. '+
						'The method selects all <tag...attribute=attribute...> and append/delete/replace property. '+
						'<br />See method <a href="#" onclick="show_ref(\'etiquetas\')">etiquetas</a> for more details on this'+
						'parameter'},
			{param:'attribute',desc:'The attribute to add, delete or replace'},
			{param:'value',desc:'The attribute's value to add or replace. If it is set to FALSE, method will destroy'+
				'the argument in the tag'},
			{param:'over',desc:'Optional. If it is TRUE (default), it overwrites the property if it exists'}],
		returned:'String with xhtml code tag, or false on error and a <a href="#" onclick="show_ref(\'log\')">log</a> entry',
		examples:[{subt:'Change language in divs',
		code:'$frgm = "<div lang='es'>Night is the time</div>'+
			'<br /><div>where fair should be controlled</div>'+
			'<br /><p>But no one do it</p>";'+
			'<br />$myfragm = new xhtml_parte($frgm);'+
			'<br />print $myfragm->cambiar_propiedad_dom(false, 'div', false, false, 'lang', '+
			''en');'+
			'<br />/* it will return'+
			'<br /><div lang='en'>Night is the time</div>'+
			'<br /><div lang='en'>where fair should be controlled</div>'+
			'<br /><p>But no one do it</p><br />*/'}]},
	{func:"cambiar_propiedad", descript:'Append or replace an existing tag property', 
		usage:'array $xhtml_parte-><b>cambiar_propiedad</b>( string <i>$tag</i>, string <i>$attribute</i>, '+
			'string <i>$value</i> [,bool <i>$over</i>])',
		parameters:[{param:'tag',desc:'the string with the tag in xhtml code'},
			{param:'attribute',desc:'The attribute to add, delete or replace'},
			{param:'value',desc:'The attribute's value to add or replace. If it is set to FALSE, method will destroy'+
				'the argument in the tag'},
			{param:'over',desc:'Optional. If it is TRUE (default), it overwrites the property if it exists'}],
		returned:'String with xhtml code tag, or false on error and a <a href="#" onclick="show_ref(\'log\')">log</a> entry',
		examples:[{subt:'Adding a tabindex to a input tag',
		code:'$tag = "<input type='text' id='inp3' />";'+
			'<br />$tab = "3";'+
			'<br />print $xhtml_parte->cambiar_propiedad($tag,"tabindex",$tab);'+
			'<br />// <input type='text' id='inp3' tabindex='3' />'}]},
	{func:"proteger_data", descript:'Prevent that string with xhtml code generates troubles in browsers and other functions', 
		usage:'string $xhtml_parte-><b>proteger_data</b>( string <i>$code</i>[, bool <i>$delete</i>])',
		parameters:[{param:'code',desc:'the string with the xhtml code'},{param:'delete', desc:'Optional. It indicates that comments must be deleted in tge returned string'}],
		returned:'String with xhtml code with html characters replaced in comments and script contents. It will return false if $code is not a string',
		examples:[{subt:'Avoiding problem of code contents in parser',
		code:"$tag1 = "<h1>This is a code in a text</h1><br />"+
			"<script><br /><!--<br /> problem_code = '</script>';<br />//--><br /></script>";"+
			"<br />print $xhtml_parte->proteger_data($tag1);<br />"+
			"/* It will output:<br />"+
			"<h1>This is a code in a text</h1><br />"+
			"<script><br />&lt;!--;<br /> problem_code = "+
			"'&lt;/script&gt;';<br />//--&gt;<br /></script>  */"}]},
	{func:"insertar", descript:'Inserts xhtml code inside other xhtml code', 
		usage:'string $xhtml_parte-><b>insertar</b>( string <i>$frag</i>[, mixed <i>$position</i> [, string <i>$xhtml</i> [, '+
			'string <i>$tag</i> [, string <i>$attribute</i> [, string <i>$value</i>] ] ] ] ])',
		parameters:[{param:'frag', desc:'the string with the xhtml code to be inserted'},
					{param:'position', desc:'Optional. Integer or boolean FALSE. It indicates from 0 to number of tags in '+
						'first order, the position where the fragment will be inserted. If it is FALSE or a lower value, '+
						'$position will be converted to <i>-1</i>, that is, at the end of xhtml code'},
					{param:'xhtml', desc:'Optional. The string with the xhtml code where fragment will be inserted. '+
						'If it is not setted, object's DOM string will be assumed'},
					{param:'tag', desc:'Optional. The tag where $fragment will be inserted. The method selects all <tag...>'+
						'and inserts $fragment at the indicated position. '+
						'If it is not setted, all first order elements (tags) will be selected'+
						'<br />See method <a href="#" onclick="show_ref(\'etiquetas\')">etiquetas</a> for more details on this'+
						'parameter'},
					{param:'attribute', desc:'Optional. The attribute that must be defined in tags where $fragment will be inserted.'+
						' The method selects all <$tag...$attribute...>'+
						'and inserts $fragment at the indicated position. '+
						'If it is not setted, all first order $tag elements will be selected.'+
						'<br />See method <a href="#" onclick="show_ref(\'etiquetas\')">etiquetas</a> for more details on this'+
						'parameter'},
					{param:'value', desc:'Optional. The value of attribute that must be defined in tags where $fragment'+
						' will be inserted.'+
						' The method selects all <$tag...$attribute...>'+
						'and inserts $fragment at the indicated position. '+
						'<br />It requires $attribute to be setted. If it is not setted, or it is setted as FALSE or "*"'+
						', all first order $tag elements with $attribute will be selected'+
						'<br />See method <a href="#" onclick="show_ref(\'etiquetas\')">etiquetas</a> for more details on this'+
						'parameter'},
					],
		returned:'Xhtml code string with fragment inserted once or in each tag selected at the $position indicated. '+
			'If some error, it will return $xhtml, but it will add a <a href="#" onclick="show_ref(\'log\')">log</a> entry',
		examples:[{subt:'Appending a row in a table',
		code:"$xhtml = "<table width='400'><tbody><br />"+
			"   <tr><td>This is one row table</td></tr><br />"+
			"</tbody></table>";"+
			"<br />$tag = "<tr><td>But this is other row</td></tr>";<br />"+
			"print $xhtml_parte->insertar($tag,-1,$xhtml,"tbody");<br />"+
			"/* It will output:<br />"+
			"<table width='400'><tbody><br />"+
			"   <tr><td>This is one row table</td></tr><br />"+
			"<tr><td>But this is other row</td></tr>"+
			"</tbody></table>  */"}]},
	{func:"eliminar", descript:'Deletes tags from xhtml code string', 
		usage:'string $xhtml_parte-><b>eliminar</b>( integer <i>$position</i> [, string <i>$xhtml</i> [, '+
			'string <i>$tag</i> [, string <i>$attribute</i> [, string <i>$value</i>] ] ] ])',
		parameters:[{param:'position', desc:'It indicates from 0 to number of tags in '+
						'first order, the position of the tag that will be deleted. If it is FALSE or a lower value than 0, '+
						'$position will be converted to <i>-1</i>, that is, the final tag'},
					{param:'xhtml', desc:'Optional. The string with the xhtml code where fragment will be deleted. '+
						'If it is not setted, object's DOM string will be assumed'},
					{param:'tag', desc:'Optional. The method selects all <$tag...>'+
						'and deletes them. It will annul $position.'+
						'<br />See method <a href="#" onclick="show_ref(\'etiquetas\')">etiquetas</a> for more details on this'+
						'parameter'},
					{param:'attribute', desc:'Optional. The attribute that must be defined in tags to be deleted.'+
						' The method selects all <$tag...$attribute...>'+
						'and deletes them. '+
						'If it is not setted, all $tag elements will be deleted.'+
						'<br />See method <a href="#" onclick="show_ref(\'etiquetas\')">etiquetas</a> for more details on this'+
						'parameter'},
					{param:'value', desc:'Optional. The value of attribute that must be defined in tags to be deleted.'+
						' The method selects all <$tag...$attribute=$value...>'+
						'and deletes them. '+
						'<br />It requires $attribute to be setted. If it is not setted, or it is setted as FALSE or "*"'+
						', all $tag elements with $attribute will be deleted'+
						'<br />See method <a href="#" onclick="show_ref(\'etiquetas\')">etiquetas</a> for more details on this'+
						'parameter'},
					],
		returned:'Xhtml code string without specific tags. '+
			'If some error, it will return $xhtml, but it will add a <a href="#" onclick="show_ref(\'log\')">log</a> entry',
		examples:[{subt:'Deleting a row in a table',
		code:"$xhtml = "<table width='400'><tbody><br />"+
			"   <tr id='one' ><td>This is the first row in table</td></tr><br />"+
			"<tr id='two'><td>This is the first row in table</td></tr>"+
			"</tbody></table>";"+
			"print $xhtml_parte->eliminar(false,$xhtml,"tr","id","two");<br />"+
			"/* It will output:<br />"+
			"<table width='400'><tbody><br />"+
			"   <tr><td>This is the first row in table</td></tr><br />"+
			"</tbody></table>  */"}]},
	{func:"etiquetas", descript:'Selects tags from xhtml code string', 
		usage:'array $xhtml_parte-><b>etiquetas</b>( [ string <i>$xhtml</i> [, '+
			'string <i>$tag</i> [, string <i>$attribute</i> [, string <i>$value</i> [, string <i>$type</i>] ] ] ] ])',
		parameters:[{param:'xhtml', desc:'Optional. The string with the xhtml code that contains tags to select. '+
						'If it is not setted, object's DOM string will be assumed'},
					{param:'tag', desc:'Optional. The method selects all <$tag...>'+
						'and deletes them. If it is setted as "*" or a non-string value it will assumed "*", that '+
						'means <i>all</i>. If it is prefixed by "!", all tags except indicated will be selected'},
					{param:'attribute', desc:'Optional. The attribute that must be defined in tags to be deleted.'+
						' The method selects all <$tag...$attribute...>. '+
						' If it is setted as "*" or a non-string value it will assumed "*", that '+
						'means <i>all</i>. If it is prefixed by "!", all $tags except those with indicated attribute '+
						'will be selected'},
					{param:'value', desc:'Optional. The value of attribute that must be defined in tags to be deleted.'+
						' The method selects all <$tag...$attribute=$value...>'+
						'<br />It requires $attribute to be setted.'+
						' If it is setted as "*" or a non-string value it will assumed "*", that '+
						'means <i>all</i>. If it is prefixed by "!", all $tags with $attribute except those wich '+	
						'indicated value will be selected'},
					{param:'type', desc:'Optional. The way that method returns selection.<ul class="normal">'+
						'<li>"nido": Will return an array <i>m</i> where:<blockquote class="bquo">'+
						'<i>m[0]</i> is an array of whole tag include opening and closing.'+
						'<br /><i>m[1]</i> is an array of tag names.'+
						'<br /><i>m[2]</i> is an array of tag contents.</blockquote></li>'+
						'<li>"cont": Will return an array of tag contents.</li>'+
						'<li>"text": Will return an array of tag contents, but with '+
						'html entities tranformed to be displayed.</li>'+
						'<li>"decl": Will return an array of opening tags (or complete tags in case of empty tags like '+
						'img or hr).</li>'+
						'<li>"cara": Will return an array of tags in array mode, where 'tagName' key will correspond'+
						'to the name of the tag and other keys will correspond to each attribute declared.</li>'+
						'<li>"nodo": Will return an array of tag declaration, contents and close. '+
						'This is the default parameter value.</li></ul>'},
					],
		returned:'Array of tag string in a xhtml code string.'+
			'If some error, it will return boolean FALSE, but it will add a <a href="#" onclick="show_ref(\'log\')">log</a> entry',
		examples:[{subt:'Selecting tags',
		code:"/* Read several examples in the file selector_examples.php */"}]},
	{func:"ver_estructura", descript:'Soft validation of xhtml structure in a string.'+
			'<br />It just review if there are forbbiden tags inside other tags (like <a> inside <a>), '+
			'<br />Unrecommended xhtml attributes inside some tags, and non repeating tags', 
		usage:'bool $xhtml_parte-><b>ver_estructura</b>( [ string <i>$xhtml</i> ])',
		parameters:[{param:'xhtml', desc:'Optional. The string with the xhtml code that contains tags to select. '+
						'If it is not setted, object's DOM string will be assumed'},
					],
		returned:'Boolean TRUE if no problem was found and FALSE and <a href="#" onclick="show_ref(\'log\')">log</a>'+
			' entries if it detects some faults.',
		examples:[{subt:'Soft structure validation',
		code:'$xhtml = "<a href='nowhere.html'>this is a link but '+
			'<a name='anchorname'> with a bad anchor inside </a> </a>";<br />'+
			'$myFragment = new xhtml_parte($xhtml);<br />'+
			'if($myFragment->ver_estructura()){<br />'+
			'   print "validated";<br />'+
			'}else{<br />'+
			'   print_r($myFragment->log);'+
			'<br />}<br />'+
			'/* It will output:<br />'+
			'Array('+
			'<br />  [0]=>"It is not allowed tags 'a' inside tags 'a'",'+
			'<br />)<br />*/'}]},
	{func:"validar", descript:'Validation of xhtml code in a string.'+
			'<br />It checks out if there are unclosed tags and CDATA declarations. '+
			'<br />It also performs some recomendations about contents, structure and syntax.', 
		usage:'bool $xhtml_parte-><b>validar</b>( [ string <i>$xhtml</i> ])',
		parameters:[{param:'xhtml', desc:'Optional. The string with the xhtml code that contains tags to select. '+
						'If it is not setted, object's DOM string will be assumed'},
					],
		returned:'Boolean TRUE if no problem was found; FALSE and <a href="#" onclick="show_ref(\'log\')">log</a>'+
			' entries if it detects some parse problems; it also returns TRUE and log entries if it has some'+
			'recomendations',
		examples:[{subt:'Selecting tags',
		code:"/* Read several examples in the file good_bad_examples.php */"}]},
	{func:"log", descript:'Object Property. Contains exceptions in object.'+
			'<br />It is filled by methods.', 
		usage:'array $xhtml_parte-><b>log</b>',
		parameters:[],
		returned:'Array with log entries. If you are interested in translate it , phrases that originates entries'+
			' starts in line 70 of xhtml_parte.php and they are used with <a href="#" onclick="show_ref(\'f\')">f</a>. array',
		examples:[]},
	{func:"f", descript:'Object Property. Contains phrases used in log entries.'+
			'<br />It is filled by constructor.', 
		usage:'array $xhtml_parte-><b>f</b>[phrase_name]',
		parameters:[],
		returned:'Array with phrases that perform log entries. They starts in line 70 of xhtml_parte.php',
		examples:[]},
	{func:"dom", descript:'Object Property. Contains the main string of xhtml code.'+
			'<br />It is filled by constructor.', 
		usage:'array $xhtml_parte-><b>dom</b>',
		parameters:[],
		returned:'String with xhtml code passed to constructor during object declaration: '+
			'<i>$myFrag = new xhtml_parte(<b>$xhtml_code_string</b>)</i>',
		examples:[]},
	{func:"TO DO", descript:'Some ideas to improve the class.', 
		usage:'Email me to [email protected]  and recommend me improvements',
		parameters:[],
		returned:'Better xhtml selection and validation',
		examples:[{subt:'In future versions I may add', 
			code:'<ul class="normal"><li><b>"tree"</b> as <i>etiquetas</i> parameter. '+
				'In order to return dom tree as multi-level array</li>'+
				'<li><b>Position</b> of tag. Much needed in validation, with row and column in the string'+
				' not realize that if there are more closing tags that needed</li>'+
				'<li><b>Stricter</b> structure validation. That returns perhaps, if tables are properly setted</li>'+
				'<li><b>Unique</b> insertion. That only inserts if the fragment does not '+
				'exists in the xhtml code string</li>'+
				'<li><b>More flexible</b> selection. That allows, perhaps, to select tags with 'tabindex' '+
				'property higher than 3</li>'+
				'</ul>'}]},
	{func:"pc_matriz_dif", descript:'External function. It calculates the differences between '+
		'two arrays and returns the difference.'+
			'<br /><strong>Unlike array_diff() It computes repeated values</strong>.'+ 
			'<br />It is declared when the xhtml_parte.php file is included.', 
		usage:'array <b>pc_matriz_dif</b>( array <i>$arr1</i>, array <i>$arr2</i>)',
		parameters:[{param:'arr1', desc:'First array to compare'},
					{param:'arr2', desc:'Second array to compare'}],
		returned:'Array with values that are not repeated between arr1 and arr2',
		examples:[{subt:'Which tag is missing',
			code:'$arr1 = array("table","tr","td","td");'+
				 '<br />$arr2 = array("table","tr","td");'+
				 '<br />print_r(pc_matriz_dif($arr1,$arr2));'+
				 '<br />// Array ("td")'}]},
];
 |