You are here

function CMISService::processPropertyTemplates in CMIS API 6.3

Same name and namespace in other branches
  1. 6.4 cmis_common/lib/cmis_repository_wrapper.php \CMISService::processPropertyTemplates()
  2. 7 cmis_common/lib/cmis_repository_wrapper.php \CMISService::processPropertyTemplates()
2 calls to CMISService::processPropertyTemplates()
CMISService::postObject in cmis_common/lib/cmis_repository_wrapper.php
CMISService::updateProperties in cmis_common/lib/cmis_repository_wrapper.php

File

cmis_common/lib/cmis_repository_wrapper.php, line 574

Class

CMISService

Code

function processPropertyTemplates($objectType, $propMap) {
  static $propTemplate;
  static $propertyTypeMap;
  if (!isset($propTemplate)) {
    $propTemplate = CMISService::getPropertyTemplate();
  }
  if (!isset($propertyTypeMap)) {

    // Not sure if I need to do this like this
    $propertyTypeMap = array(
      "integer" => "Integer",
      "boolean" => "Boolean",
      "datetime" => "DateTime",
      "decimal" => "Decimal",
      "html" => "Html",
      "id" => "Id",
      "string" => "String",
      "url" => "Url",
      "xml" => "Xml",
    );
  }
  $propertyContent = "";
  $hash_values = array();
  foreach ($propMap as $propId => $propValue) {
    $hash_values['propertyType'] = $propertyTypeMap[$this
      ->getPropertyType($objectType, $propId)];
    $hash_values['propertyId'] = $propId;
    if (is_array($propValue)) {
      $first_one = true;
      $hash_values['properties'] = "";
      foreach ($propValue as $val) {

        //This is a bit of a hack
        if ($first_one) {
          $first_one = false;
        }
        else {
          $hash_values['properties'] .= "</cmis:values>\n<cmis:values>";
        }
        $hash_values['properties'] .= $val;
      }
    }
    else {
      $hash_values['properties'] = $propValue;
    }

    //echo "HASH:\n";

    //print_r(array("template" =>$propTemplate, "Hash" => $hash_values));
    $propertyContent .= CMISRepositoryWrapper::processTemplate($propTemplate, $hash_values);
  }
  return $propertyContent;
}