You are here

static function CMISRepositoryWrapper::extractObjectFromNode in CMIS API 7

Same name and namespace in other branches
  1. 6.4 cmis_common/lib/cmis_repository_wrapper.php \CMISRepositoryWrapper::extractObjectFromNode()
  2. 6.3 cmis_common/lib/cmis_repository_wrapper.php \CMISRepositoryWrapper::extractObjectFromNode()
2 calls to CMISRepositoryWrapper::extractObjectFromNode()
CMISRepositoryWrapper::extractObject in cmis_common/lib/cmis_repository_wrapper.php
CMISRepositoryWrapper::extractObjectFeedFromNode in cmis_common/lib/cmis_repository_wrapper.php

File

cmis_common/lib/cmis_repository_wrapper.php, line 249

Class

CMISRepositoryWrapper

Code

static function extractObjectFromNode($xmlnode) {

  // Extracts the contents of an Object and organizes them into:
  //  -- Links
  //  -- Properties
  //  -- the Object ID
  // RRM -- NEED TO ADD ALLOWABLEACTIONS
  $retval = new stdClass();
  $retval->links = CMISRepositoryWrapper::getLinksArray($xmlnode);
  $retval->renditions = array();
  $retval->properties = array();
  $prop_nodes = $xmlnode
    ->getElementsByTagName("object")
    ->item(0)
    ->getElementsByTagName("properties")
    ->item(0)->childNodes;
  foreach ($prop_nodes as $pn) {
    if ($pn->attributes) {

      //supressing errors since PHP sometimes sees DOM elements as "non-objects"
      @($retval->properties[$pn->attributes
        ->getNamedItem("propertyDefinitionId")->nodeValue] = $pn
        ->getElementsByTagName("value")
        ->item(0)->nodeValue);
    }
  }
  $renditions = $xmlnode
    ->getElementsByTagName("object")
    ->item(0)
    ->getElementsByTagName("rendition");
  $renditionArray = array();

  // Add renditions to CMIS object
  $i = 0;
  if ($renditions->length > 0) {
    foreach ($renditions as $rendition) {
      $rend_nodes = $rendition->childNodes;
      foreach ($rend_nodes as $rend) {
        if ($rend->localName != NULL) {
          $renditionArray[$i][$rend->localName] = $rend->nodeValue;
        }
      }
      $i++;
    }
  }
  $retval->renditions = $renditionArray;
  $properties = $xmlnode
    ->getElementsByTagName("object")
    ->item(0)
    ->getElementsByTagName("properties")
    ->item(0);

  // hack in Alfresco Aspect Properties
  if ($properties
    ->getElementsByTagName("aspects")
    ->item(0)) {
    $alf_prop_nodes = $properties
      ->getElementsByTagName("aspects")
      ->item(0)
      ->getElementsByTagName("properties")
      ->item(0)->childNodes;
    foreach ($alf_prop_nodes as $pn) {
      if ($pn->attributes) {
        $item = $pn->attributes
          ->getNamedItem("propertyDefinitionId");
        if ($item) {
          $first = $pn
            ->getElementsByTagName("value")
            ->item(0);
          if ($first) {
            $retval->properties[$item->nodeValue] = $first->nodeValue;
          }
        }
      }
    }
  }
  $retval->uuid = $xmlnode
    ->getElementsByTagName("id")
    ->item(0)->nodeValue;
  $retval->id = $retval->properties["cmis:objectId"];
  return $retval;
}