public function addUserWriteAccess(a\User $u)
 {
     if (self::DEBUG) {
         u\DebugUtility::out("Granting write access to " . $u->getName());
     }
     $this->setAccess($u, c\T::WRITE);
     return $this;
 }
 public function setDoPASV($bool)
 {
     if (!c\BooleanValues::isBoolean($bool)) {
         throw new e\UnacceptableValueException(S_SPAN . "The value {$bool} must be a boolean." . E_SPAN);
     }
     if (self::DEBUG) {
         u\DebugUtility::out($bool ? 'true' : 'false');
     }
     $this->getProperty()->doPASV = $bool;
     return $this;
 }
 public function getFolder()
 {
     if ($this->isFolder() && $this->getIndexedFolderId() != NULL) {
         $service = $this->getService();
         if (self::DEBUG) {
             u\DebugUtility::out("Returning folder" . "ID " . $this->getIndexedFolderPath());
         }
         return new Folder($service, $service->createId(Folder::TYPE, $this->getIndexedFolderId()));
     }
     return NULL;
 }
 public function addDynamicFieldDefinition($field_name, $type, $label, $required = false, $visibility = c\T::VISIBLE, $possible_values = "")
 {
     if ($this->hasDynamicMetadataFieldDefinition($field_name)) {
         throw new \Exception(S_SPAN . "The dynamic field definition {$field_name} already exists." . E_SPAN);
     }
     if ($type != c\T::TEXT && trim($possible_values) == "") {
         throw new e\EmptyValueException(S_SPAN . c\M::EMPTY_POSSIBLE_VALUES . E_SPAN);
     }
     $dmfd = AssetTemplate::getDynamicMetadataFieldDefinition();
     $dmfd->dynamicMetadataFieldDefinition->name = $field_name;
     $dmfd->dynamicMetadataFieldDefinition->label = $label;
     $dmfd->dynamicMetadataFieldDefinition->fieldType = $type;
     $dmfd->dynamicMetadataFieldDefinition->required = $required;
     $dmfd->dynamicMetadataFieldDefinition->visibility = $visibility;
     if ($type != c\T::TEXT) {
         $dmfd->dynamicMetadataFieldDefinition->possibleValues = new \stdClass();
         $values = u\StringUtility::getExplodedStringArray(";", $possible_values);
         $value_count = count($values);
         if ($value_count == 1) {
             $pv = new \stdClass();
             $pv->value = $values[0];
             $pv->selectedByDefault = false;
             $dmfd->dynamicMetadataFieldDefinition->possibleValues->possibleValue = $pv;
         } else {
             $dmfd->dynamicMetadataFieldDefinition->possibleValues->possibleValue = array();
             foreach ($values as $value) {
                 if (self::DEBUG) {
                     u\DebugUtility::out($value);
                 }
                 $pv = new \stdClass();
                 $pv->value = $value;
                 $pv->selectedByDefault = false;
                 $dmfd->dynamicMetadataFieldDefinition->possibleValues->possibleValue[] = $pv;
             }
         }
     }
     if (self::DEBUG && self::DUMP) {
         u\DebugUtility::dump($dmfd);
     }
     $dmfd_obj = new p\DynamicMetadataFieldDefinition($dmfd->dynamicMetadataFieldDefinition);
     $this->dynamic_metadata_field_definitions[] = $dmfd_obj;
     if (self::DEBUG && self::DUMP) {
         u\DebugUtility::dump($dmfd_obj->toStdClass());
     }
     $this->edit();
     $this->processDynamicMetadataFieldDefinition();
     return $this;
 }
 public function edit()
 {
     $asset = new \stdClass();
     //$this->getProperty()->metadata   = $this->metadata->toStdClass();
     $asset->{$p = $this->getPropertyName()} = $this->getProperty();
     $asset->{$p = $this->getPropertyName()}->metadata = $this->metadata->toStdClass();
     if (self::DEBUG) {
         u\DebugUtility::dump($asset);
     }
     // edit asset
     $service = $this->getService();
     $service->edit($asset);
     if (!$service->isSuccessful()) {
         throw new e\EditingFailureException(S_SPAN . c\M::EDIT_ASSET_FAILURE . E_SPAN . $service->getMessage());
     }
     return $this->reloadProperty();
 }
 public function __construct(aohs\AssetOperationHandlerService $service, \stdClass $audit_std)
 {
     if ($service == NULL) {
         throw new e\NullServiceException(S_SPAN . c\M::NULL_SERVICE . E_SPAN);
     }
     if ($audit_std == NULL) {
         throw new e\EmptyValueException(S_SPAN . c\M::EMPTY_AUDIT . E_SPAN);
     }
     if (self::DEBUG) {
         u\DebugUtility::dump($audit_std->identifier);
     }
     $this->service = $service;
     $this->audit_std = $audit_std;
     $this->user = $audit_std->user;
     $this->action = $audit_std->action;
     $this->identifier = new p\Identifier($audit_std->identifier);
     $this->date_time = new \DateTime($audit_std->date);
 }
 public static function initialize(aohs\AssetOperationHandlerService $service)
 {
     try {
         $service->listMessages();
         if ($service->isSuccessful()) {
             $messages = $service->getListedMessages();
             $temp_msg = array();
             if (!($messages->message == NULL)) {
                 if (!is_array($messages->message)) {
                     $temp_msg[] = $messages->message;
                 } else {
                     $temp_msg = $messages->message;
                 }
                 foreach ($temp_msg as $message) {
                     $id = $message->id;
                     $to = $message->to;
                     $from = $message->from;
                     $date = $message->date;
                     $subject = trim($message->subject);
                     $body = $message->body;
                     self::$all_message_ids[] = $id;
                     $message_obj = new Message($message);
                     // store all messages
                     self::$all_messages[] = $message_obj;
                     self::$id_obj_map[$id] = $message_obj;
                     // from whom?
                     if (!isset($message_ids_from[$from])) {
                         self::$message_ids_from[$from] = array();
                     }
                     self::$message_ids_from[$from][] = $id;
                     if ($from != 'system') {
                         self::$non_system_messages[] = $message_obj;
                     }
                     if (self::DEBUG) {
                         u\DebugUtility::out($message_obj->getType());
                     }
                     if ($message_obj->getType() == Message::TYPE_EXPIRATION) {
                         self::$asset_expiration_message[] = $message_obj;
                         self::$asset_expiration_message_ids[] = $id;
                     } else {
                         if ($message_obj->getType() == Message::TYPE_PUBLISH) {
                             self::$publish_messages[] = $message_obj;
                             self::$publish_message_ids[] = $id;
                             // no issues
                             if (strpos($subject, "(0 issue(s))") !== false) {
                                 if (self::DEBUG) {
                                     echo "L::121 " . $id . BR;
                                 }
                                 self::$publish_message_ids_without_issues[] = $id;
                                 self::$publish_messages_without_issues[] = $message_obj;
                             } else {
                                 if (self::DEBUG) {
                                     echo "L::124 " . $id . BR;
                                 }
                                 self::$publish_message_ids_with_issues[] = $id;
                                 self::$publish_messages_with_issues[] = $message_obj;
                             }
                         } else {
                             if ($message_obj->getType() == Message::TYPE_UNPUBLISH) {
                                 self::$unpublish_messages[] = $message_obj;
                                 self::$unpublish_message_ids[] = $id;
                                 // no issues
                                 if (strpos($subject, "(0 issue(s))") !== false) {
                                     self::$unpublish_message_ids_without_issues[] = $id;
                                     self::$unpublish_messages_without_issues[] = $message_obj;
                                 } else {
                                     self::$unpublish_message_ids_with_issues[] = $id;
                                     self::$unpublish_messages_with_issues[] = $message_obj;
                                 }
                             } else {
                                 if ($message_obj->getType() == Message::TYPE_SUMMARY) {
                                     self::$summary_messages[] = $message_obj;
                                     self::$summary_message_ids[] = $id;
                                     // 0 failures
                                     if (strpos($subject, "(0 failures)") !== false) {
                                         self::$summary_message_ids_no_failures[] = $id;
                                         self::$summary_messages_no_failures[] = $message_obj;
                                     } else {
                                         self::$summary_message_ids_with_failures[] = $id;
                                         self::$summary_messages_with_failures[] = $message_obj;
                                     }
                                 } else {
                                     if ($message_obj->getType() == Message::TYPE_WORKFLOW) {
                                         self::$workflow_messages[] = $message_obj;
                                         self::$workflow_message_ids[] = $id;
                                         // is complete
                                         if (strpos($subject, "is complete") !== false) {
                                             self::$workflow_message_ids_is_complete[] = $id;
                                             self::$workflow_messages_complete[] = $message_obj;
                                         } else {
                                             self::$workflow_message_ids_other[] = $id;
                                             self::$workflow_messages_other[] = $message_obj;
                                         }
                                     } else {
                                         self::$other_messages[] = $message_obj;
                                         self::$other_message_ids[] = $id;
                                     }
                                 }
                             }
                         }
                     }
                     // date
                 }
                 usort(self::$all_messages, self::NAME_SPACE . "\\" . 'Message::compare');
                 usort(self::$publish_messages, self::NAME_SPACE . "\\" . 'Message::compare');
                 usort(self::$unpublish_messages, self::NAME_SPACE . "\\" . 'Message::compare');
                 usort(self::$workflow_messages, self::NAME_SPACE . "\\" . 'Message::compare');
                 usort(self::$other_messages, self::NAME_SPACE . "\\" . 'Message::compare');
                 usort(self::$publish_messages_with_issues, self::NAME_SPACE . "\\" . 'Message::compare');
                 usort(self::$unpublish_messages_with_issues, self::NAME_SPACE . "\\" . 'Message::compare');
                 usort(self::$workflow_messages_other, self::NAME_SPACE . "\\" . 'Message::compare');
                 usort(self::$non_system_messages, self::NAME_SPACE . "\\" . 'Message::compare');
             }
             //var_dump( $workflow_message_ids_is_complete );
         } else {
             echo "Failed to list messages. " . $service->getMessage();
         }
     } catch (\Exception $e) {
         echo S_PRE . $e . E_PRE;
     }
 }
        u\DebugUtility::dump($dmfd->getDefaultValue()->toStdClass());
        u\DebugUtility::out($dmfd->getDefaultValueString());
    }
    u\DebugUtility::out($dmfd->getFieldType());
    u\DebugUtility::out($dmfd->getLabel());
    u\DebugUtility::out($dmfd->getName());
    u\DebugUtility::dump($dmfd->getPossibleValues());
    u\DebugUtility::dump($dmfd->getPossibleValueStrings());
    u\DebugUtility::dump(u\StringUtility::boolToString($dmfd->getRequired()));
    u\DebugUtility::dump($dmfd->getVisibility());
    u\DebugUtility::dump(u\StringUtility::boolToString($dmfd->hasPossibleValue("Spanish")));
    $dmfd->removeValue("Chinese");
    $ms->edit()->dump();
    $dmfd->setLabel("Languages");
    $ms->edit()->dump();
    $dmfd->setRequired(true);
    $ms->edit()->dump();
    $dmfd->unsetSelectedByDefault("Japanese");
    $ms->edit()->dump();
    // radio
    $dmfd = $ms->getDynamicMetadataFieldDefinition("gender");
    $dmfd->setSelectedByDefault("Male");
    u\DebugUtility::dump($dmfd->toStdClass());
    $ms->edit()->dump();
    $dmfd->setVisibility(c\T::VISIBLE);
    $ms->edit()->dump();
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
} catch (\Error $er) {
    echo S_PRE . $er . E_PRE;
}
            u\DebugUtility::dump($page->getPageLevelRegionBlockFormat());
            // get page properties
            echo "Metadata" . BR;
            $md = $page->getMetadata();
            u\DebugUtility::dump($md->toStdClass());
            echo "Dynamic fields" . BR;
            $fns = $md->getDynamicFieldNames();
            u\DebugUtility::dump($fns);
            echo "Structured data" . BR;
            $sd = $page->getStructuredData();
            u\DebugUtility::dump($sd->toStdClass());
            echo "Fully qualified identifiers" . BR;
            // identifiers of structured data
            u\DebugUtility::dump($page->getIdentifiers());
            // get data from a node
            echo $page->getText("main-content-title") . BR;
            // subscribers
            echo "Subscribers" . BR;
            u\DebugUtility::dump($page->getSubscribers());
            break;
        case "Site":
            $site = $cascade->getSite($site_name);
            // get the base folder
            $base_folder = $site->getBaseFolder()->dump(true);
            // content type container
            echo $site->getRootContentTypeContainerId() . BR;
            break;
    }
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
}
<?php

/*
This program shows how to use the Report class to report
pages in a folder containing long titles.
*/
$start_time = time();
require_once 'cascade_ws_ns/auth_chanw.php';
use cascade_ws_constants as c;
use cascade_ws_asset as a;
use cascade_ws_property as p;
use cascade_ws_utility as u;
use cascade_ws_exception as e;
try {
    $site_name = 'cascade-admin';
    $folder_path = 'projects/web-services/oop/classes/asset-tree';
    $results = $report->setRootContainer($cascade->getAsset(a\Folder::TYPE, $folder_path, $site_name));
    u\DebugUtility::dump($report->reportLongTitle(15, a\Page::TYPE, true));
    $end_time = time();
    echo "\nTotal time taken: " . ($end_time - $start_time) . " seconds\n";
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
    $end_time = time();
    echo "\nTotal time taken: " . ($end_time - $start_time) . " seconds\n";
}
 public function isPublishable()
 {
     $path = $this->getPath();
     if (self::DEBUG) {
         u\DebugUtility::out($path);
     }
     if ($this->getPath() == '/') {
         return $this->getShouldBePublished();
     } else {
         $parent = $this->getAsset($this->getService(), Folder::TYPE, $this->getParentContainerId());
         return $parent->isPublishable() && $this->getShouldBePublished();
     }
 }
                  $pcs->setConfigurationPageRegionFormat( 'Mobile', 'DEFAULT',
                          $cascade->getAsset( 
                              a\XsltFormat::TYPE, 
                              '404872688b7f0856002a5e11bb8c8642' )
                      )->edit();
              
                  //$pcs->setDefaultConfiguration( "Mobile" )->edit();
                  $pcs->setFormat( "Mobile",
                      $cascade->getAsset( 
                          a\XsltFormat::TYPE, 
                          '404872688b7f0856002a5e11bb8c8642' )
                  )->edit();
            */
            //$pcs->setIncludeXMLDeclaration( "Mobile", true )->edit();
            $pcs->setOutputExtension("Mobile", ".php")->setPublishable("Mobile", true)->setSerializationType("Mobile", "XML")->edit();
            if ($mode != 'all') {
                break;
            }
        case 'raw':
            $pcs = $service->retrieve($service->createId(c\T::CONFIGURATIONSET, $id), c\P::CONFIGURATIONSET);
            //$pr = new PageRegion( $pcs->pageConfigurations->
            //pageConfiguration[3]->pageRegions->pageRegion[0] );
            //var_dump( $pr );
            u\DebugUtility::dump($pcs);
            if ($mode != 'all') {
                break;
            }
    }
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
}
<?php

require_once 'cascade_ws_ns/auth_chanw.php';
use cascade_ws_AOHS as aohs;
use cascade_ws_constants as c;
use cascade_ws_asset as a;
use cascade_ws_property as p;
use cascade_ws_utility as u;
use cascade_ws_exception as e;
try {
    $page = $cascade->getAsset(a\Page::TYPE, '2a47653d8b7f08ee3c48c4e996f9054a');
    $page->setRegionFormat("RWD", "BANNER FULL WIDTH", $cascade->getAsset(a\XsltFormat::TYPE, '5a654ee68b7f0856001b890211c4f553'))->edit();
    // display the page-level block/format information
    u\DebugUtility::dump($page->getPageLevelRegionBlockFormat());
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
}
require_once 'auth_tutorial7.php';
use cascade_ws_AOHS as aohs;
use cascade_ws_constants as c;
use cascade_ws_asset as a;
use cascade_ws_property as p;
use cascade_ws_utility as u;
use cascade_ws_exception as e;
try {
    $page_id = "824b63c68b7ffe830539acf09bc3135b";
    $page = $cascade->getAsset(a\Page::TYPE, $page_id);
    $audits = $page->getAudits();
    //u\DebugUtility::dump( $audits );
    $audit0 = $audits[0];
    $audit1 = $audits[1];
    $audit0->display();
    $audit1->display();
    echo "Action: ", $audit0->getAction(), BR;
    echo "Audit asset: ", BR;
    u\DebugUtility::dump($audit0->getAuditedAsset());
    echo "Date: ", date_format($audit0->getDate(), 'Y-m-d H:i:s'), BR;
    echo "Identifier: ", BR;
    u\DebugUtility::dump($audit0->getIdentifier());
    echo "User: "******"cascade_ws_asset\\Audit");
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
} catch (\Error $er) {
    echo S_PRE . $er . E_PRE;
}
 public function getPageRegion($name)
 {
     if (self::DEBUG) {
         u\DebugUtility::dump($this->page_region_map);
     }
     if (!isset($this->page_region_map[$name])) {
         throw new e\NoSuchPageRegionException(S_SPAN . "The region {$name} does not exist." . E_SPAN);
     }
     return $this->page_region_map[$name];
 }
<?php

require_once 'cascade_ws_ns/auth_chanw.php';
use cascade_ws_AOHS as aohs;
use cascade_ws_constants as c;
use cascade_ws_asset as a;
use cascade_ws_property as p;
use cascade_ws_utility as u;
use cascade_ws_exception as e;
try {
    $dd_block = $cascade->getAsset(a\DataDefinitionBlock::TYPE, "32fca8458b7f08ee384a2061ad1d5f17");
    u\DebugUtility::dump($dd_block->getIdentifiers());
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
}
 private function getStructuredDataNode($xml_element, $type, $identifier)
 {
     if (self::DEBUG) {
         u\DebugUtility::out("{$type}, {$identifier}");
     }
     $obj = AssetTemplate::getStructuredDataNode();
     if ($type == c\T::GROUP) {
         $obj->type = $type;
         $obj->identifier = $identifier;
         $obj->structuredDataNodes = new \stdClass();
         $child_count = count($xml_element->children());
         $more_than_one = $child_count > 1 ? true : false;
         if ($more_than_one) {
             $obj->structuredDataNodes->structuredDataNode = array();
             foreach ($xml_element->children() as $child) {
                 $child_type = $child->getName();
                 if (self::DEBUG) {
                     u\DebugUtility::out("Child type in group: {$child_type}");
                 }
                 if (isset($child[c\T::IDENTIFIER])) {
                     $child_identifier = $child[c\T::IDENTIFIER]->__toString();
                     $child_std = $this->createChildStd($child, $child_type, $child_identifier);
                     $obj->structuredDataNodes->structuredDataNode[] = $child_std;
                 }
             }
         } else {
             $xml_array = $xml_element->children();
             //var_dump( $xml_array );
             $child = $xml_array[0];
             $child_type = $child->getName();
             if (self::DEBUG) {
                 u\DebugUtility::out("Child type in group: {$child_type}");
             }
             $child_identifier = $child[c\T::IDENTIFIER]->__toString();
             $child_std = $this->createChildStd($child, $child_type, $child_identifier);
             $obj->structuredDataNodes->structuredDataNode = $child_std;
         }
     } else {
         $obj->type = $type;
         $obj->identifier = $identifier;
     }
     return $obj;
 }
use cascade_ws_constants as c;
use cascade_ws_asset as a;
use cascade_ws_property as p;
use cascade_ws_utility as u;
use cascade_ws_exception as e;
$start_time = time();
try {
    // to prevent time-out
    set_time_limit(10000);
    // to prevent using up memory when traversing a large site
    ini_set('memory_limit', '2048M');
    $pattern = "/<a[^>]+href=['\"]\\S+web\\.upstate\\.edu/";
    $params = array("pattern" => $pattern);
    $results = array();
    $cascade->getAsset(a\Folder::TYPE, "5fa0f00d8b7f0856002a5e11033c2ad1")->getAssetTree()->traverse(array(a\Page::TYPE => array("assetTreeSearchTextByPattern")), $params, $results);
    u\DebugUtility::dump($results);
    $end_time = time();
    echo "\nTotal time taken: " . ($end_time - $start_time) . " seconds\n";
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
    $end_time = time();
    echo "\nTotal time taken: " . ($end_time - $start_time) . " seconds\n";
}
function assetTreeSearchTextByPattern(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    $type = $child->getType();
    if ($type != a\Page::TYPE && $type != a\DataBlock::TYPE) {
        return;
    }
    $pattern = $params["pattern"];
    if (!isset($pattern) || trim($pattern) == "") {
 public static function assetTreeUpdatePageConfigurationSet(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
 {
     if (isset($params['source-cascade'])) {
         $source_cascade = $params['source-cascade'];
     } else {
         echo c\M::TARGET_CASCADE_NOT_SET . BR;
         return;
     }
     if (isset($params['target-cascade'])) {
         $target_cascade = $params['target-cascade'];
     } else {
         echo c\M::TARGET_CASCADE_NOT_SET . BR;
         return;
     }
     if (isset($params['target-site'])) {
         $target_site = $params['target-site'];
     } else {
         echo c\M::TARGET_SITE_NOT_SET . BR;
         return;
     }
     if (isset($params['exception-thrown'])) {
         $exception_thrown = $params['exception-thrown'];
     } else {
         echo c\M::EXCEPTION_THROWN_NOT_SET . BR;
         return;
     }
     $source_pcs = $child->getAsset($service);
     $source_pcs_name = $source_pcs->getName();
     $source_pcs_parent_path = $source_pcs->getParentContainerPath();
     // the default definition
     $source_pcs_default_config = $source_pcs->getDefaultConfiguration();
     $source_pcs_default_config_name = $source_pcs_default_config->getName();
     $source_pcs_default_config_template_path = u\StringUtility::removeSiteNameFromPath($source_pcs_default_config->getTemplatePath());
     $source_pcs_default_config_template_name = u\StringUtility::getNameFromPath($source_pcs_default_config_template_path);
     $source_pcs_default_config_template = $source_pcs_default_config->getTemplate();
     $source_pcs_default_config_template_site = $source_pcs_default_config_template->getSiteName();
     $source_pcs_default_config_extension = $source_pcs_default_config->getOutputExtension();
     $source_pcs_default_config_type = $source_pcs_default_config->getSerializationType();
     if (self::DEBUG) {
         u\DebugUtility::out("Extension: " . $source_pcs_default_config_extension . BR . "Type: " . $source_pcs_default_config_type);
     }
     $target_pcs_default_config_template_site = $source_pcs_default_config_template_site;
     try {
         // the template must be there
         $template = $target_cascade->getAsset(Template::TYPE, $source_pcs_default_config_template_path, $target_pcs_default_config_template_site);
         $target_site_name = $target_site->getName();
         // parent must be there
         $target_parent = $target_cascade->getAsset(PageConfigurationSetContainer::TYPE, $source_pcs_parent_path, $target_site_name);
         $target_pcs = $target_cascade->createPageConfigurationSet($target_parent, $source_pcs_name, $source_pcs_default_config_name, $template, $source_pcs_default_config_extension, $source_pcs_default_config_type);
         // update other configuration sets
         $source_config_names = $source_pcs->getPageConfigurationNames();
         foreach ($source_config_names as $source_config_name) {
             // retrieve config info
             $source_config = $source_pcs->getPageConfiguration($source_config_name);
             $source_template = $source_config->getTemplate();
             $source_template_path = u\StringUtility::removeSiteNameFromPath($source_template->getPath());
             $source_template_site = $source_template->getSiteName();
             $target_template_site = $source_template_site;
             // template must be there
             $target_template = $target_cascade->getAsset(Template::TYPE, $source_template_path, $target_template_site);
             // add missing configurations
             if ($source_pcs_default_config_name != $source_config_name && !$target_pcs->hasPageConfiguration($source_config_name)) {
                 $source_config_extension = $source_config->getOutputExtension();
                 $source_config_type = $source_config->getSerializationType();
                 $source_config_publishable = $source_config->getPublishable();
                 try {
                     $target_config = $target_pcs->getPageConfiguration($source_config_name);
                 } catch (e\NoSuchPageConfigurationException $e) {
                     $target_pcs->addPageConfiguration($source_config_name, $target_template, $source_config_extension, $source_config_type);
                     $target_config = $target_pcs->getPageConfiguration($source_config_name);
                 }
                 // update config
                 $target_pcs->setOutputExtension($source_config_name, $source_config_extension);
                 $target_pcs->setSerializationType($source_config_name, $source_config_type);
                 $target_pcs->setPublishable($source_config_name, $source_config_publishable);
             }
             // config format!!!
             $source_config_format_id = $source_config->getFormatId();
             if (isset($source_config_format_id)) {
                 $source_config_format = $source_cascade->getXsltFormat($source_config_format_id);
                 $source_config_format_path = u\StringUtility::removeSiteNameFromPath($source_config_format->getPath());
                 $source_config_format_site = $source_config_format->getSiteName();
                 $target_config_format_site = $source_config_format_site;
                 try {
                     if ($exception_thrown) {
                         $target_format = $target_cascade->getAsset(XsltFormat::TYPE, $source_config_format_path, $target_config_format_site);
                     } else {
                         $target_format = $target_cascade->getXsltFormat($source_config_format_path, $target_config_format_site);
                     }
                     $source_config->setFormat($target_format);
                     $target_pcs->edit();
                 } catch (\Exception $e) {
                     $msg = "The format {$source_config_format_path} does not exist in {$target_config_format_site}. ";
                     throw new e\CascadeInstancesErrorException(S_SPAN . $msg . E_SPAN . $e);
                 }
             }
             // set blocks and formats, if not $exception_thrown, skip missing ones
             $region_names = $target_template->getRegionNames();
             if (count($region_names) > 0) {
                 foreach ($region_names as $region_name) {
                     if (!$source_pcs->hasPageRegion($source_config_name, $region_name)) {
                         continue;
                     }
                     $source_block = $source_pcs->getPageRegion($source_config_name, $region_name)->getBlock();
                     $source_format = $source_pcs->getPageRegion($source_config_name, $region_name)->getFormat();
                     if ($source_block) {
                         $source_block_path = u\StringUtility::removeSiteNameFromPath($source_block->getPath());
                         $source_block_site = $source_block->getSiteName();
                         $source_block_type = $source_block->getType();
                         $target_block_site = $source_block_site;
                         try {
                             if ($exception_thrown) {
                                 $target_block = $target_cascade->getAsset($source_block_type, $source_block_path, $target_block_site);
                             } else {
                                 $class_name = c\T::getClassNameByType($source_block_type);
                                 $method = 'get' . $class_name;
                                 $target_block = $target_cascade->{$method}($source_block_path, $target_block_site);
                             }
                             $target_pcs->setConfigurationPageRegionBlock($source_config_name, $region_name, $target_block)->edit();
                         } catch (\Exception $e) {
                             $msg = "The block {$source_block_path} does not exist in {$target_block_site}. ";
                             throw new e\CascadeInstancesErrorException(S_SPAN . $msg . E_SPAN . $e);
                         }
                     }
                     if ($source_format) {
                         $source_format_path = u\StringUtility::removeSiteNameFromPath($source_format->getPath());
                         $source_format_site = $source_format->getSiteName();
                         $source_format_type = $source_format->getType();
                         $target_format_site = $source_format_site;
                         try {
                             if ($exception_thrown) {
                                 $target_format = $target_cascade->getAsset($source_format_type, $source_format_path, $target_format_site);
                             } else {
                                 $class_name = c\T::getClassNameByType($source_format_type);
                                 $method = 'get' . $class_name;
                                 $target_format = $target_cascade->{$method}($source_format_path, $target_format_site);
                             }
                             $target_pcs->setConfigurationPageRegionFormat($source_config_name, $region_name, $target_format);
                         } catch (\Exception $e) {
                             $msg = "The format {$source_format_path} does not exist in {$target_format_site}. ";
                             throw new e\CascadeInstancesErrorException(S_SPAN . $msg . E_SPAN . $e);
                         }
                     }
                 }
             }
             $target_pcs->edit();
         }
     } catch (\Exception $e) {
         //$msg = "The configuration set $source_pcs_default_config_template_path does not exist in $target_pcs_default_config_template_site. ";
         throw new e\CascadeInstancesErrorException($e);
     }
 }
     }
 case 'dump':
     $ct->dump(true);
     if ($mode != 'all') {
         break;
     }
 case 'get':
     echo "ID: " . $ct->getId() . BR;
     echo "Dumping names of contentTypePageConfigurations: " . BR;
     echo S_PRE;
     var_dump($ct->getContentTypePageConfigurationNames());
     echo E_PRE;
     $ct->getConfigurationSet()->dump(true);
     $ct->getDataDefinition()->dump(true);
     echo "Inline editable field names", BR;
     u\DebugUtility::dump($ct->getInlineEditableFieldNames());
     $ct->getMetadataSet()->dump(true);
     if ($mode != 'all') {
         break;
     }
 case 'set':
     $config_name = 'Printer';
     if ($ct->hasPageConfiguration($config_name)) {
         $ct->setPublishMode($config_name, a\ContentType::PUBLISH_MODE_ALL_DESTINATIONS)->edit();
     }
     if ($mode != 'all') {
         break;
     }
 case 'inline':
     echo S_PRE;
     var_dump($ct->getInlineEditableFieldNames());
<?php

require_once 'auth_tutorial7.php';
use cascade_ws_AOHS as aohs;
use cascade_ws_constants as c;
use cascade_ws_asset as a;
use cascade_ws_property as p;
use cascade_ws_utility as u;
use cascade_ws_exception as e;
try {
    // test static method
    $id = "06e401898b7ffe83765c5582e367462b";
    $block = a\Block::getBlock($service, $id);
    //->dump( true ); // no type info supplied
    echo a\Block::getBlockType($service, $id), BR;
    // get methods
    echo "Created by: ", $block->getCreatedBy(), BR, "Created on: ", $block->getCreatedDate(), BR, "Expiration folder ID: ", $block->getExpirationFolderId(), BR, "Expiration folder path: ", $block->getExpirationFolderPath(), BR, "Expiration folder recycled: ", u\StringUtility::boolToString($block->getExpirationFolderRecycled()), BR, "Last modified by: ", $block->getLastModifiedBy(), BR, "Last modified date: ", $block->getLastModifiedDate(), BR, "Metadata set ID: ", $block->getMetadataSetId(), BR, "Metadata set path: ", $block->getMetadataSetPath(), BR;
    u\DebugUtility::dump($block->getDynamicFields());
    u\DebugUtility::dump($block->getMetadataStdClass());
    echo u\ReflectionUtility::getClassDocumentation("cascade_ws_asset\\Block");
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
} catch (\Error $er) {
    echo S_PRE . $er . E_PRE;
}
use cascade_ws_constants as c;
use cascade_ws_asset as a;
use cascade_ws_property as p;
use cascade_ws_utility as u;
use cascade_ws_exception as e;
try {
    $cache = u\Cache::getInstance($service);
    $template_id_stdClass = $service->createId(a\Template::TYPE, "78c760648b7f0856004564242ce4d1d1");
    $template_identifier = new p\Child($template_id_stdClass);
    // test cache time
    $start_time = time();
    for ($i = 0; $i < 50; $i++) {
        $template = $cache->retrieveAsset($template_identifier);
    }
    $end_time = time();
    echo "\nTotal time taken: " . ($end_time - $start_time) . " seconds\n";
    u\DebugUtility::dump($cache);
    $cache->clearCache();
    u\DebugUtility::dump($cache);
    // test direct retrieval time
    $start_time = time();
    for ($i = 0; $i < 50; $i++) {
        $template = $template_identifier->getAsset($service);
    }
    $end_time = time();
    echo "\nTotal time taken: " . ($end_time - $start_time) . " seconds\n";
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
} catch (\Error $er) {
    echo S_PRE . $er . E_PRE;
}
 private function search($match_type = c\T::MATCH_ANY, $asset_name = '', $asset_content = '', $asset_metadata = '', $search_type = '')
 {
     if (!c\SearchTypes::isSearchType(trim($search_type))) {
         throw new e\NoSuchTypeException(S_SPAN . "The search type {$search_type} does not exist." . E_SPAN);
     }
     if ($match_type != c\T::MATCH_ANY && $match_type != c\T::MATCH_ALL) {
         throw new e\NoSuchTypeException(S_SPAN . "The match type {$match_type} does not exist." . E_SPAN);
     }
     $search_for = new \stdClass();
     $search_for->matchType = $match_type;
     $search_for->{$search_type} = true;
     if (trim($asset_name) != "") {
         $search_for->assetName = $asset_name;
     }
     if (trim($asset_content) != "") {
         $search_for->assetContent = $asset_content;
     }
     if (trim($asset_metadata) != "") {
         $search_for->assetMetadata = $asset_metadata;
     }
     if (self::DEBUG && self::DUMP) {
         u\DebugUtility::dump($search_for);
     }
     $this->service->search($search_for);
     // if succeeded
     if ($this->service->isSuccessful()) {
         $results = array();
         if (!is_null($this->service->getSearchMatches()->match)) {
             $temp = $this->service->getSearchMatches()->match;
             if (!is_array($temp)) {
                 $temp = array($temp);
             }
             foreach ($temp as $match) {
                 $results[] = new p\Identifier($match);
             }
         }
         return $results;
     } else {
         throw new e\SearchException($this->service->getMessage());
     }
 }
    </multiselect>
    */
    $field_name = "languages";
    echo "Testing {$field_name}", BR;
    if ($m->hasDynamicField($field_name)) {
        $multiselect = $m->getDynamicField($field_name);
        u\DebugUtility::dump($multiselect->toStdClass());
        $new_values = array("Japanese", "English");
        if ($ms->hasDynamicMetadataFieldDefinition($field_name)) {
            $dmfd = $ms->getDynamicMetadataFieldDefinition($field_name);
            $valid = true;
            foreach ($new_values as $new_value) {
                if (!$dmfd->hasPossibleValue($new_value)) {
                    $valid = false;
                    break;
                }
            }
            if ($valid) {
                $m->setDynamicFieldValues($field_name, $new_values);
            }
        }
    }
    u\DebugUtility::dump($m->toStdClass());
    // commit all changes
    $block->edit();
    echo u\ReflectionUtility::getClassDocumentation("cascade_ws_property\\Metadata");
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
} catch (\Error $er) {
    echo S_PRE . $er . E_PRE;
}
 /**
  * Create an asset object, bridging this class and the Asset classes
  * @param string 
  * @param string $type The type of the asset
  * @param string $id_path Either the ID string or the path of the asset
  * @param binary $site_name The site name
  *
  * @return mixed The asset object
  * @throw Exception if the asset cannot be retrieved
  */
 public function getAsset($type, $id_path, $site_name = NULL)
 {
     if (!in_array($type, c\T::getTypeArray())) {
         throw new e\NoSuchTypeException(S_SPAN . "The type {$type} does not exist." . E_SPAN);
     }
     $class_name = c\T::$type_class_name_map[$type];
     // get class name
     $class_name = a\Asset::NAME_SPACE . "\\" . $class_name;
     try {
         return new $class_name($this, $this->createId($type, $id_path, $site_name));
     } catch (\Exception $e) {
         if (self::DEBUG && self::DUMP) {
             u\DebugUtility::out($e->getMessage());
         }
         throw $e;
     }
 }
<?php

require_once 'cascade_ws_ns/auth_chanw.php';
use cascade_ws_AOHS as aohs;
use cascade_ws_constants as c;
use cascade_ws_asset as a;
use cascade_ws_property as p;
use cascade_ws_utility as u;
use cascade_ws_exception as e;
try {
    $page = $cascade->getAsset(a\Page::TYPE, "beda1ad58b7f08ee7691912d9470a54f");
    $dd = $page->getDataDefinition();
    // stdClass object, used when new StructuredData( $new_sd_stdClass )
    $new_sd_stdClass = $dd->getStructuredData();
    u\DebugUtility::dump($new_sd_stdClass);
    // StructuredData object, use this to map data and setStructuredData
    $new_sd = $dd->getStructuredDataObject();
    u\DebugUtility::dump($new_sd_stdClass);
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
}
 private function getType($id_string)
 {
     if (self::DEBUG) {
         u\DebugUtility::out("string: " . $id_string);
     }
     if (isset($this->service)) {
         $types = array('block', 'format');
         $type_count = count($types);
         for ($i = 0; $i < $type_count; $i++) {
             $id = $this->service->createId($types[$i], $id_string);
             $operation = new \stdClass();
             $read_op = new \stdClass();
             $read_op->identifier = $id;
             $operation->read = $read_op;
             $operations[] = $operation;
         }
         $this->service->batch($operations);
         $reply_array = $this->service->getReply()->batchReturn;
         if (self::DEBUG && self::DUMP) {
             u\DebugUtility::dump($reply_array);
         }
         for ($j = 0; $j < $type_count; $j++) {
             if ($reply_array[$j]->readResult->success == 'true') {
                 foreach (c\T::$type_property_name_map as $type => $property) {
                     //echo "$type => $property" . BR;
                     if (isset($reply_array[$j]->readResult->asset->{$property})) {
                         return $type;
                     }
                 }
             }
         }
     }
     return NULL;
 }
        echo "Tis true", BR;
    } else {
        echo "Tis false", BR;
    }
    if (u\StringUtility::stringToBool(0)) {
        echo "Tis true", BR;
    } else {
        echo "Tis false", BR;
    }
    if (u\StringUtility::stringToBool("")) {
        echo "Tis true", BR;
    } else {
        echo "Tis false", BR;
    }
    echo u\StringUtility::boolToString(true), BR;
    echo u\StringUtility::startsWith("Hello", "He") ? "yes" : "no", BR;
    echo u\StringUtility::startsWith("Hello", "e") ? "yes" : "no", BR;
    echo u\StringUtility::removeSiteNameFromPath("site://cascade-admin/web-services/api/utility-classes/debug-utility"), BR;
    echo u\StringUtility::getParentPathFromPath("/web-services/api/utility-classes/debug-utility"), BR;
    echo u\StringUtility::getNameFromPath("/web-services/api/utility-classes/debug-utility"), BR;
    echo u\StringUtility::getMethodName("structuredData"), BR;
    u\DebugUtility::dump(u\StringUtility::getExplodedStringArray(";", "this;0;that;3;these"));
    echo u\StringUtility::getFullyQualifiedIdentifierWithoutPositions("this;0;that;3;these"), BR;
    echo u\StringUtility::endsWith("Hello", "lo") ? "yes" : "no", BR;
    echo u\StringUtility::endsWith("Hello", "l") ? "yes" : "no", BR;
    echo u\ReflectionUtility::getClassDocumentation("cascade_ws_utility\\StringUtility", true);
} catch (\Exception $e) {
    echo S_PRE . $e . E_PRE;
} catch (\Error $er) {
    echo S_PRE . $er . E_PRE;
}
<?php

require_once 'auth_tutorial7.php';
use cascade_ws_AOHS as aohs;
use cascade_ws_constants as c;
use cascade_ws_asset as a;
use cascade_ws_property as p;
use cascade_ws_utility as u;
use cascade_ws_exception as e;
try {
    $group_name = "cru";
    $group = $service->retrieve($service->createId(a\Group::TYPE, $group_name));
    if ($service->isSuccessful()) {
        echo "Read successfully";
        u\DebugUtility::dump($group);
    } else {
        echo "Failed to read. " . $service->getMessage();
    }
} catch (\Exception $e) {
    echo S_PRE, $e, E_PRE;
} catch (\Error $er) {
    echo S_PRE, $er, E_PRE;
}
 public function edit()
 {
     // edit the asset
     $asset = new \stdClass();
     $block = $this->getProperty();
     $block->metadata = $this->getMetadata()->toStdClass();
     if (isset($this->structured_data)) {
         $block->structuredData = $this->structured_data->toStdClass();
         $block->xhtml = NULL;
     } else {
         $block->structuredData = NULL;
         $block->xhtml = $this->xhtml;
     }
     $asset->{$p = $this->getPropertyName()} = $block;
     // edit asset
     $service = $this->getService();
     $service->edit($asset);
     if (!$service->isSuccessful()) {
         if (self::DEBUG && self::DUMP) {
             u\DebugUtility::dump($asset);
         }
         throw new e\EditingFailureException(S_SPAN . "Block: " . $this->getPath() . E_SPAN . BR . c\M::EDIT_ASSET_FAILURE . $service->getMessage());
     }
     $this->reloadProperty();
     if (isset($this->getProperty()->structuredData)) {
         $this->processStructuredData();
     }
     return $this;
 }