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); }
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; }
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; }
$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; }
</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; }
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; }
try { $site_names = array("cru", "com", "medicine"); foreach ($site_names as $site) { $search_for = new \stdClass(); $search_for->matchType = c\T::MATCH_ANY; $search_for->searchGroups = true; $search_for->assetName = $site; // $site as group name $service->search($search_for); // if succeeded if ($service->getSuccess()) { echo "<h2>Search Result for {$site}</h2>"; if (is_null($service->getSearchMatches()->match)) { echo "No results<br />"; } else { u\DebugUtility::dump($service->getSearchMatches()->match); } } else { echo "Search failed.<br />"; echo $service->getMessage(); } } // search all groups $search_for = new \stdClass(); $search_for->matchType = c\T::MATCH_ANY; $search_for->searchGroups = true; $search_for->assetName = "*"; // the wild card $service->search($search_for); // if succeeded if ($service->isSuccessful()) {
<?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 static function assetTreeUpdateDataDefinitionBlock(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL) { if (isset($params['source-cascade'])) { $source_cascade = $params['source-cascade']; } else { echo c\M::SOURCE_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['source-site'])) { $source_site = $params['source-site']; } else { echo c\M::SOURCE_SITE_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; } if (isset($params['update-data'])) { $update_data = $params['update-data']; } else { $update_data = true; } if (isset($params['update-metadata'])) { $update_metadata = $params['update-metadata']; } else { $update_metadata = true; } if (self::DEBUG && self::DUMP) { u\DebugUtility::out("Retrieving block"); u\DebugUtility::dump($child->toStdClass()); } try { $source_block = $child->getAsset($service); $source_block_path = u\StringUtility::removeSiteNameFromPath($source_block->getPath()); } catch (\Exception $e) { throw new e\CascadeInstancesErrorException($e . BR . S_SPAN . "Path: " . $child->getPathPath() . E_SPAN); } $target_dd = NULL; // it will fail if there is any irregularity in the block if ($source_block->hasStructuredData()) { $source_block_dd = $source_block->getDataDefinition(); $source_block_dd_path = u\StringUtility::removeSiteNameFromPath($source_block_dd->getPath()); $source_block_dd_site = $source_block_dd->getSiteName(); $target_block_dd_site = $source_block_dd_site; // compare the two data definitions $source_dd = Asset::getAsset($service, DataDefinition::TYPE, $source_block_dd_path, $source_block_dd_site); // the data definition must be there $target_dd = $target_cascade->getAsset(DataDefinition::TYPE, $source_block_dd_path, $target_block_dd_site); $source_xml = new \SimpleXMLElement($source_dd->getXml()); $target_xml = new \SimpleXMLElement($target_dd->getXml()); if (!u\XMLUtility::isXmlIdentical($source_xml, $target_xml)) { throw new e\CascadeInstancesErrorException(S_SPAN . c\M::DIFFERENT_DATA_DEFINITIONS . E_SPAN); } $source_structured_data_std = $source_block->getStructuredData()->toStdClass(); $target_dd_id = $target_dd->getId(); $target_structured_data_std = $source_structured_data_std; $target_structured_data_std->definitionId = $target_dd_id; } else { $source_content = $source_block->getXhtml(); } $source_block_path_array = u\StringUtility::getExplodedStringArray("/", $source_block_path); $source_block_path = $source_block_path_array[count($source_block_path_array) - 1]; $source_block_parent_path = $source_block->getParentContainerPath(); // create block $target_site_name = $target_site->getName(); // parent must be there $target_parent = $target_cascade->getAsset(Folder::TYPE, $source_block_parent_path, $target_site_name); $target_block = $target_cascade->createXhtmlDataDefinitionBlock($target_parent, $source_block_path, $target_dd, $source_content); // update data if ($update_data) { if ($target_block->hasStructuredData()) { if (self::DEBUG && self::DUMP) { u\DebugUtility::dump($target_structured_data_std); } try { $target_service = $target_cascade->getService(); $identifiers = $source_block->getIdentifiers(); $identifier_asset_map = array(); foreach ($identifiers as $identifier) { if ($source_block->isAssetNode($identifier)) { $block_id = $source_block->getBlockId($identifier); if (isset($block_id)) { $resource_id = $block_id; $source_resource_type = Block::getBlockType($service, $resource_id); } $file_id = $source_block->getFileId($identifier); if (isset($file_id)) { $resource_id = $file_id; $source_resource_type = File::TYPE; } $page_id = $source_block->getPageId($identifier); if (isset($page_id)) { $resource_id = $page_id; $source_resource_type = Page::TYPE; } $symlink_id = $source_block->getSymlinkId($identifier); if (isset($symlink_id)) { $resource_id = $symlink_id; $source_resource_type = Symlink::TYPE; } if (isset($resource_id)) { $source_resource = $service->retrieve($service->createId($source_resource_type, $resource_id)); if ($service->isSuccessful()) { $source_resource_site = $source_resource->siteName; $source_resource_path = $source_resource->path; $target_resource_site = $source_resource_site; try { $asset = $target_cascade->getAsset($source_resource_type, $source_resource_path, $source_resource_site); $identifier_asset_map[$identifier] = $asset; } catch (\Exception $e) { if ($exception_thrown) { throw new e\CascadeInstancesErrorException($e . BR . S_SPAN . "Block: " . $source_block->getPath() . BR . "Resource: " . $source_resource_path . E_SPAN); } else { u\DebugUtility::out($e->getMessage() . BR . "<span style='color:red;font-weight:bold;'>" . "Block: " . $source_block->getPath() . BR . "Resource: " . $source_resource_path . "</span>"); } } } else { echo "Failed to retrieve resource." . BR; } // reinitialized for the next round $resource_id = NULL; } } } $identifiers = array_keys($identifier_asset_map); $count = count($identifiers); $structured_data = new p\StructuredData($target_structured_data_std, $target_service); if ($count > 0) { foreach ($identifiers as $identifier) { $asset = $identifier_asset_map[$identifier]; $type = $asset->getType(); switch ($type) { case 'file': $method = 'setFile'; break; case 'page': $method = 'setPage'; break; case 'symlink': $method = 'setSymlink'; break; default: $method = 'setBlock'; } if ($structured_data->hasNode($identifier)) { $structured_data->{$method}($identifier, $asset); } } } $target_block->setStructuredData($structured_data); } catch (\Exception $e) { if (self::DEBUG) { u\DebugUtility::out($child->getPathPath()); } } } } if ($update_metadata) { self::setMetadataSet($target_cascade, $source_site, $target_site, $source_block, $target_block, $exception_thrown); } }
private function processPageConfigurations($page_config_std) { $this->page_configurations = array(); if (!is_array($page_config_std)) { $page_config_std = array($page_config_std); } if (self::DEBUG && self::DUMP) { u\DebugUtility::dump($page_config_std); } foreach ($page_config_std as $pc_std) { $pc = new p\PageConfiguration($pc_std, $this->getService(), self::TYPE); $this->page_configurations[] = $pc; $this->page_configuration_map[$pc->getName()] = $pc; } }
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 { $page_path = "index"; $page = $service->retrieve($service->createId(a\Page::TYPE, $page_path, "cascade-admin")); if ($service->isSuccessful()) { echo "Read successfully"; u\DebugUtility::dump($page); } 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; }
echo S_H2 . "Pages with No Authors" . E_H2; u\DebugUtility::dump($report->reportHasNoAuthor()); echo S_H2 . "Pages with No Summaries" . E_H2; u\DebugUtility::dump($report->reportHasNoSummary()); echo S_H2 . "Folders with No End Dates" . E_H2; u\DebugUtility::dump($report->reportHasNoEndDate(a\Folder::TYPE)); echo S_H2 . "Folders with End Dates" . E_H2; u\DebugUtility::dump($report->reportHasEndDate(a\Folder::TYPE)); $results = $report->setRootContainer($cascade->getAsset(a\Folder::TYPE, $folder_path, $site_name))->reportMetadataWiredFields($max, 'Global'); echo S_H2 . "Pages Containing 'Global' in Title" . E_H2; u\DebugUtility::dump($report->reportTitleContains()); $results = $report->setRootContainer($cascade->getAsset(a\Folder::TYPE, $folder_path, $site_name))->reportMetadataWiredFields($max, 'asset tree'); echo S_H2 . "Pages Containing 'asset tree' in Keywords" . E_H2; u\DebugUtility::dump($report->reportKeywordsContains()); $results = $report->setRootContainer($cascade->getAsset(a\Folder::TYPE, $folder_path, $site_name))->reportMetadataWiredFields($max, 'global functions'); echo S_H2 . "Pages Containing 'global functions' in Summary" . E_H2; u\DebugUtility::dump($report->reportSummaryContains()); $date = new DateTime('2016-05-17 00:00:00'); $results = $report->setRootContainer($cascade->getAsset(a\Folder::TYPE, $folder_path, $site_name))->reportDate($date); //u\DebugUtility::dump( $results ); echo S_H2 . "Pages with Earlier Start Date" . E_H2; u\DebugUtility::dump($report->reportStartDateBefore()); echo S_H2 . "Pages with Later Start Date" . E_H2; u\DebugUtility::dump($report->reportStartDateAfter()); $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 static function assetTreeReportPageNodeValue(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL) { if (!isset($params['node-value'])) { throw new e\ReportException(S_SPAN . "The \$node-value array is not set. " . E_SPAN); } if (!isset($params['cache'])) { throw new e\ReportException(S_SPAN . c\M::NULL_CACHE . E_SPAN); } $cache = $params['cache']; $type = $child->getType(); // skip irrelevant children if ($type != Page::TYPE && $type != Folder::TYPE) { return; } $node_value = $params['node-value']; if (!is_array($node_value)) { throw new e\ReportException(S_SPAN . "The \$node-value array is not set. " . E_SPAN); } $count = count($node_value); //if( self::DEBUG && self::DUMP ) { u\DebugUtility::dump( $node_value ); } //if( self::DEBUG ) { u\DebugUtility::out( "Count: $count" ); } if ($count == 0) { return; } else { if ($count > 1) { if (isset($params['disjunctive'])) { $disjunctive = $params['disjunctive']; } else { $disjunctive = true; } } } $page = $cache->retrieveAsset($child); // skip xhtml pages if (!$page->hasStructuredData()) { return; } if ($count == 1) { $identifier_value = $node_value[0]; $keys = array_keys($identifier_value); $identifier = $keys[0]; $value = trim($identifier_value[$identifier]); // match a node if ($page->hasNode($identifier) && $page->isTextNode($identifier)) { // empty node value if ($value == "" && $page->getText($identifier) == $value) { $results[Page::TYPE][] = $child->getPathPath(); } else { if ($value != "" && strpos($page->getText($identifier), $value) !== false) { $results[Page::TYPE][] = $child->getPathPath(); } } } else { return; } } else { if (self::DEBUG) { u\DebugUtility::out("Count more than 1"); } if ($disjunctive) { // pass any test foreach ($node_value as $node_value_pair) { if (self::DEBUG && self::DUMP) { u\DebugUtility::dump($node_value_pair); } $keys = array_keys($node_value_pair); $identifier = $keys[0]; $value = trim($node_value_pair[$identifier]); if ($page->hasNode($identifier) && $page->isTextNode($identifier)) { if (self::DEBUG) { u\DebugUtility::out("Matched a node"); } if (self::DEBUG) { u\DebugUtility::out("Identifier: {$identifier}"); } if (self::DEBUG) { u\DebugUtility::out("Value: {$value}"); } // different if ($value == "" && $page->getText($identifier) != $value || $value != "" && strpos($page->getText($identifier), $value) === false) { if (self::DEBUG) { u\DebugUtility::out("\$page->getText: " . $page->getText($identifier) . BR . "Value not matched. Continue."); } continue; // check next pair } else { $results[Page::TYPE][] = $child->getPathPath(); return; // found } } else { continue; } // check next pair } } else { if (self::DEBUG) { u\DebugUtility::out("Conjunctive"); } if (self::DEBUG && self::DUMP) { u\DebugUtility::dump($node_value); } // must pass all the tests foreach ($node_value as $node_value_pair) { if (self::DEBUG && self::DUMP) { u\DebugUtility::dump($node_value_pair); } $keys = array_keys($node_value_pair); $identifier = $keys[0]; $value = trim($node_value_pair[$identifier]); //if( self::DEBUG ) { u\DebugUtility::out( "Identifier: $identifier" ); } //if( self::DEBUG ) { u\DebugUtility::out( "Value: $value" ); } if ($page->hasNode($identifier) && $page->isTextNode($identifier)) { if (self::DEBUG) { u\DebugUtility::out("Matched a node"); } // both should be empty to match if ($value == "" && $page->getText($identifier) != "") { //if( self::DEBUG ) { u\DebugUtility::out( "Empty value not matched" ); } return; } else { if ($value != "" && strpos($page->getText($identifier), $value) === false) { //if( self::DEBUG ) { u\DebugUtility::out( "Value not matched" ); } return; } } //if( self::DEBUG ) { u\DebugUtility::out( "Continue" ); } } else { return; } } $results[Page::TYPE][] = $child->getPathPath(); } } }
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; }
} 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 '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; }
<?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; }
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; }
//$ps_std->usesScheduledPublishing = true; //$ps_std->timeToPublish = "00:00:00.000"; unset($ps_std->publishIntervalHours); unset($ps_std->cronExpression); //$day = new stdClass(); //$day->dayOfWeek = "Friday"; //$ps_std->publishDaysOfWeek = $day; //echo S_PRE; //var_dump( $ps_std ); //echo E_PRE; //echo $ps_std->timeToPublish . BR; $asset = new \stdClass(); $asset->publishSet = $ps_std; $service->edit($asset); if ($service->isSuccessful()) { echo "Edited successfully." . BR; } else { echo "Failed to edit." . BR; echo $service->getMessage(); } $ps_std = $service->retrieve($service->createId(c\T::PUBLISHSET, $id), c\P::PUBLISHSET); echo S_PRE; u\DebugUtility::dump($ps_std); echo E_PRE; if ($mode != 'all') { break; } } } catch (\Exception $e) { echo S_PRE . $e . 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 { // 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; $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) == "") {
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()); } }
<?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; }
/** * Read the asset with the given identifier * @param stdClass $identifier The identifier of the object to be read */ public function read(\stdClass $identifier) { if (self::DEBUG) { u\DebugUtility::dump($identifier); } $read_param = new \stdClass(); $read_param->authentication = $this->auth; $read_param->identifier = $identifier; $this->reply = $this->soapClient->read($read_param); $this->storeResults($this->reply->readReturn); }
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 '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; }
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; }