aliroXML Class Reference

List of all members.

Public Member Functions

 __get ($property)
 baseAttribute ($attribute)
 loadFile ($xmlfile, $attribs=0)
 loadString ($xmlstring, $attribs=0)
 xmlerror ($errno, $errmsg)
 getXML ($properties)

Static Public Member Functions

static attribArray ($xmlobject)
static elementArray ($xmlobject)

Protected Attributes

 $xmlobject = null
 $maintag = ''
 $valid = true


Detailed Description

Definition at line 11 of file aliroXML.php.


Member Function Documentation

aliroXML::__get ( property  ) 

Definition at line 16 of file aliroXML.php.

00016                                       {
00017         if (is_null($this->xmlobject) OR is_null($result = $this->xmlobject->$property)) return null;
00018         return $result;
00019     }

aliroXML::baseAttribute ( attribute  ) 

Definition at line 21 of file aliroXML.php.

00021                                                {
00022         return (string) $this->xmlobject[$attribute];
00023     }

aliroXML::loadFile ( xmlfile,
attribs = 0 
)

Definition at line 25 of file aliroXML.php.

References loadString(), and T_().

00025                                                     {
00026         if (!file_exists($xmlfile)) throw new aliroXMLException(sprintf(T_('Requested XML file %s does not exist'), $xmlfile));
00027         if (!is_readable($xmlfile)) throw new aliroXMLException(sprintf(T_('Requested XML file %s is not readable'), $xmlfile));
00028         $string = file_get_contents($xmlfile);
00029         return $this->loadString($string, $attribs);
00030     }

aliroXML::loadString ( xmlstring,
attribs = 0 
)

Definition at line 32 of file aliroXML.php.

References T_().

Referenced by loadFile().

00032                                                         {
00033         $ampencode = '/(&(?!(#[0-9]{1,5};))(?!([0-9a-zA-Z]{1,10};)))/';
00034         $xmlstring = preg_replace($ampencode, '&', $xmlstring);
00035         $tag = preg_match('/(<(?!\?)(?!\!)[^> ]*)/', $xmlstring, $matches);
00036         if ($tag) $this->maintag = substr($matches[0],1);
00037         else throw new aliroXMLException(T_('XML Handler cannot find main tag'));
00038         $filename = ('install' == $this->maintag) ? 'josinstall' : $this->maintag;
00039         $filename = _ALIRO_ABSOLUTE_PATH.'/xml/'.$filename.'.dtd';
00040         if (!file_exists($filename)) throw new aliroXMLException(T_('XML Handler - no matching DTD'));
00041         $href = 'file://'.$filename;
00042         $xmlstring = '<?xml version="1.0" encoding="utf-8"?>'
00043         ."<!DOCTYPE $this->maintag SYSTEM \"$href\">"
00044         .strstr($xmlstring, $matches[0]);
00045         set_error_handler(array($this, 'xmlerror'));
00046         $this->xmlobject = simplexml_load_string($xmlstring, null, LIBXML_DTDVALID);
00047         restore_error_handler();
00048         return $this->valid;
00049     }

aliroXML::xmlerror ( errno,
errmsg 
)

Definition at line 51 of file aliroXML.php.

References T_().

00051                                                {
00052         $this->valid = false;
00053         $split = explode('parser error :', $errmsg);
00054         if (isset($split[1])) $errordetail = T_(' parser error: ').$split[1];
00055         else $errordetail = T_(' non-parser XML error').$errmsg;
00056         throw new aliroXMLException(T_('An XML processing error occurred in class aliroXML'.$errordetail));
00057     }

aliroXML::getXML ( properties  ) 

Definition at line 59 of file aliroXML.php.

00059                                          {
00060         $ps = explode('->', $properties);
00061         $obj = $this->xmlobject;
00062         foreach ($ps as $p) {
00063             if (is_null($obj)) return null;
00064             if ('[' == $p[0] AND ']' == substr($p,-1)) return (string)$obj[substr($p,1,-1)];
00065             if (is_null($obj = $obj->$p)) return null;
00066         }
00067         return $obj;
00068     }

static aliroXML::attribArray ( xmlobject  )  [static]

Definition at line 70 of file aliroXML.php.

References $xmlobject.

Referenced by aliroLanguageExtended::extractOneLocale(), and aliroLanguageExtended::getLocales().

00070                                                     {
00071         $result = array();
00072         foreach ($xmlobject->attributes() as $key=>$value) $result[$key] = (string) $value;
00073         return $result;
00074     }

static aliroXML::elementArray ( xmlobject  )  [static]

Definition at line 76 of file aliroXML.php.

References $xmlobject.

Referenced by aliroLanguageExtended::extractOneLocale().

00076                                                      {
00077         $result = array();
00078         foreach ($xmlobject as $element) $result[] = (string) $element;
00079         return $result;
00080     }


Member Data Documentation

aliroXML::$xmlobject = null [protected]

Definition at line 12 of file aliroXML.php.

Referenced by attribArray(), and elementArray().

aliroXML::$maintag = '' [protected]

Definition at line 13 of file aliroXML.php.

aliroXML::$valid = true [protected]

Definition at line 14 of file aliroXML.php.


The documentation for this class was generated from the following file:

Generated on Thu Apr 17 13:03:31 2008 for ALIRO by  doxygen 1.5.5