Example #1
0
 /**
  * Creates object structure from given XML type string
  *
  * @static
  * @param string $source
  * @return eZPage
  */
 public static function createFromXML($source)
 {
     $newObj = new eZPage();
     if ($source) {
         $dom = new DOMDocument('1.0', 'utf-8');
         $success = $dom->loadXML($source);
         $root = $dom->documentElement;
         foreach ($root->childNodes as $node) {
             if ($node->nodeType == XML_ELEMENT_NODE && $node->nodeName == 'zone') {
                 $zoneNode = eZPageZone::createFromXML($node);
                 $newObj->addZone($zoneNode);
             } elseif ($node->nodeType == XML_ELEMENT_NODE) {
                 $newObj->setAttribute($node->nodeName, $node->nodeValue);
             }
         }
         if ($root->hasAttributes()) {
             foreach ($root->attributes as $attr) {
                 $newObj->setAttribute($attr->name, $attr->value);
             }
         }
     }
     $zoneINI = eZINI::instance('zone.ini');
     $layoutName = $newObj->attribute('zone_layout');
     if ($zoneINI->hasVariable($layoutName, 'Zones')) {
         foreach ($zoneINI->variable($layoutName, 'Zones') as $zoneIdentifier) {
             foreach ($newObj->attribute('zones') as $inObjectZone) {
                 if ($inObjectZone->attribute('zone_identifier') === $zoneIdentifier) {
                     continue 2;
                 }
             }
             $newZone = $newObj->addZone(new eZPageZone());
             $newZone->setAttribute('id', md5(mt_rand() . microtime() . $newObj->getZoneCount()));
             $newZone->setAttribute('zone_identifier', $zoneIdentifier);
             $newZone->setAttribute('action', 'add');
         }
     }
     return $newObj;
 }
Example #2
0
 /**
  * Creates object structure from given XML type string
  *
  * @static
  * @param string $source
  * @return eZPage
  */
 public static function createFromXML($source)
 {
     $newObj = new eZPage();
     if ($source) {
         $dom = new DOMDocument('1.0', 'utf-8');
         $success = $dom->loadXML($source);
         $root = $dom->documentElement;
         foreach ($root->childNodes as $node) {
             if ($node->nodeType == XML_ELEMENT_NODE && $node->nodeName == 'zone') {
                 $zoneNode = eZPageZone::createFromXML($node);
                 $newObj->addZone($zoneNode);
             } elseif ($node->nodeType == XML_ELEMENT_NODE) {
                 $newObj->setAttribute($node->nodeName, $node->nodeValue);
             }
         }
         if ($root->hasAttributes()) {
             foreach ($root->attributes as $attr) {
                 $newObj->setAttribute($attr->name, $attr->value);
             }
         }
     }
     return $newObj;
 }
 /**
  * Returns the content data for the given content object attribute.
  *
  * @param eZContentObjectAttribute $contentObjectAttribute
  * @return eZPage
  */
 function objectAttributeContent($contentObjectAttribute)
 {
     $source = $contentObjectAttribute->attribute('data_text');
     $page = eZPage::createFromXML($source);
     return $page;
 }