public function getFormat() { if (isset($this->getProperty()->formatId)) { return Asset::getAsset($this->getService(), XsltFormat::TYPE, $this->getProperty()->formatId); } return NULL; }
public function getFormat() { if (isset($this->format_id) && $this->format_id != "" && isset($this->service)) { if (self::DEBUG) { u\DebugUtility::out(__FUNCTION__ . BR . "Type of format: " . $this->getType($this->format_id) . BR . "Format ID: " . $this->format_id); } return a\Asset::getAsset($this->service, $this->getType($this->format_id), $this->format_id); } return NULL; }
public function getAsset(aohs\AssetOperationHandlerService $service) { if ($service == NULL) { throw new e\NullServiceException(c\M::NULL_SERVICE); } if (isset($this->id)) { return a\Asset::getAsset($service, $this->type, $this->id); } else { return a\Asset::getAsset($service, $this->type, $this->path->getPath(), $this->path->getSiteName()); } }
public function getParentContainer() { if ($this->getType() == c\T::SITE) { throw new e\WrongAssetTypeException(c\M::SITE_NO_PARENT_CONTAINER); } if ($this->getParentContainerId() != NULL) { $parent_id = $this->getParentContainerId(); $parent_type = c\T::$type_parent_type_map[$this->getType()]; return Asset::getAsset($this->getService(), $parent_type, $parent_id); } return NULL; }
public function __construct(\stdClass $cctl = NULL, aohs\AssetOperationHandlerService $service = NULL, $data1 = NULL, $data2 = NULL, $data3 = NULL) { if (isset($cctl)) { $this->content_type_id = $cctl->contentTypeId; $this->content_type_path = $cctl->contentTypePath; $this->page_configuration_id = $cctl->pageConfigurationId; $this->page_configuration_name = $cctl->pageConfigurationName; if (isset($service)) { $this->metadata_set = a\Asset::getAsset($service, a\ContentType::TYPE, $this->content_type_id)->getMetadataSet(); } $this->connector_content_type_link_params = array(); if (isset($cctl->connectorContentTypeLinkParams) && isset($cctl->connectorContentTypeLinkParams->connectorContentTypeLinkParam)) { $params = $cctl->connectorContentTypeLinkParams->connectorContentTypeLinkParam; if (!is_array($params)) { $params = array($params); } foreach ($params as $param) { $this->connector_content_type_link_params[] = new ConnectorContentTypeLinkParameter($param); } } } }
public function getReferencedAsset() { return Asset::getAsset($this->getService(), $this->getProperty()->referencedAssetType, $this->getProperty()->referencedAssetId); }
use cascade_ws_property as p; use cascade_ws_utility as u; use cascade_ws_exception as e; $mode = 'none'; //$mode = 'all'; //$mode = 'copy'; //$mode = 'display'; //$mode = 'dump'; //$mode = 'edit'; //$mode = 'getAudits'; //$mode = 'get'; //$mode = 'publishSubscribers'; try { $page_id = "824b63c68b7ffe830539acf09bc3135b"; // test static method $page = a\Asset::getAsset($service, a\Page::TYPE, $page_id); //->dump(); // static method can still be called through an object $folder = $page->getAsset($service, a\Folder::TYPE, "3890910f8b7ffe83164c93144ce01dbd")->dump(); switch ($mode) { case 'all': case 'copy': $page->copy($cascade->getAsset(a\Folder::TYPE, "3890a3f88b7ffe83164c931457a2709c"), "test-asset"); if ($mode != 'all') { break; } case 'display': $page->display(); if ($mode != 'all') { break; }
// case 7b: cron expression //$s->setCronExpression( "0 4 12 * * ?" )->edit(); if ($mode != 'all') { break; } case 'assignment': $r = $cascade->getAsset(a\Role::TYPE, 50); // site publisher $s->addRole($r)->edit(); $s->addUserToRole($r, $cascade->getAsset(a\User::TYPE, 'chanw'))->addUserToRole($r, $cascade->getAsset(a\User::TYPE, 'tuw'))->addGroupToRole($r, $cascade->getAsset(a\Group::TYPE, 'cru'))->edit(); //$s->removeRole( $r )->edit(); if ($mode != 'all') { break; } case 'set': $s->setUrl('http://www.upstate.edu/tuw-test')->setDefaultMetadataSet(a\Asset::getAsset($service, a\MetadataSet::TYPE, 'b893fd058b7f0856002a5e11185ff809'))->setCssFile(NULL)->setSiteAssetFactoryContainer(a\Asset::getAsset($service, a\AssetFactoryContainer::TYPE, '04af3e2e8b7f085600e28886d7e2221d'))->setStartingPage(a\Asset::getAsset($service, a\Page::TYPE, '04af1d7a8b7f085600e28886865346c3'))->setSendReportOnErrorOnly(true)->addUserToSendReport(a\Asset::getAsset($service, a\User::TYPE, 'tuw'))->addGroupToSendReport(a\Asset::getAsset($service, a\Group::TYPE, 'hemonc'))->setRecycleBinExpiration(a\Site::NEVER)->edit(); if ($mode != 'all') { break; } case 'publish': //$s->publish(); if ($mode != 'all') { break; } case 'asset-tree': echo S_PRE . u\XMLUtility::replaceBrackets($s->getRootAssetFactoryContainerAssetTree()->toXml()) . E_PRE; if ($mode != 'all') { break; } case 'raw': $s_std = $service->retrieve($service->createId(c\T::SITE, $id), c\P::SITE);
public function setInheritWorkflows($bool) { if (!c\BooleanValues::isBoolean($bool)) { throw new e\UnacceptableValueException(S_SPAN . "The value {$bool} must be a boolean." . E_SPAN); } // already set if ($this->inherit_workflows == $bool) { return $this; } if ($bool) { $this->inherit_workflows = $bool; $folder_id = $this->identifier->getId(); $folder = a\Asset::getAsset($this->service, a\Folder::TYPE, $folder_id); $parent = $folder->getParentContainer(); if (isset($parent)) { $parent_settings = $parent->getWorkflowSettings(); $parent_wds = $parent_settings->getWorkflowDefinitions(); if (is_array($parent_wds) && count($parent_wds) > 0) { foreach ($parent_wds as $parent_wd) { $this->inherited_workflow_definitions[] = $parent_wd; } } } } else { $this->unsetInheritWorkflows(); } return $this; }
public function getSite($site_name) { $this->getSites(); if (self::DEBUG && self::DUMP) { u\DebugUtility::dump($this->name_site_map); } if (!isset($this->name_site_map[$site_name])) { throw new e\NoSuchSiteException(S_SPAN . "The site {$site_name} does not exist." . E_SPAN); } return Asset::getAsset($this->service, Site::TYPE, $this->name_site_map[$site_name]->getId()); }
public function getPageConfigurationTemplate($name) { $this->checkPageConfiguration($name); $count = $this->page_configurations; for ($i = 0; $i < $count; $i++) { if ($this->page_configurations[$i]->getName() == $name) { $id = $this->page_configurations[$i]->getTemplateId(); return Asset::getAsset($this->getService(), Template::TYPE, $id); } } }
public function getContentType() { $service = $this->getService(); return Asset::getAsset($service, ContentType::TYPE, $this->getProperty()->contentTypeId); }
public function getTemplate() { if ($this->service == NULL) { throw new e\NullServiceException(S_SPAN . c\M::NULL_SERVICE . E_SPAN); } return a\Asset::getAsset($this->service, a\Template::TYPE, $this->template_id); }
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; $mode = 'all'; //$mode = 'display'; //$mode = 'dump'; //$mode = 'get'; //$mode = 'raw'; try { $id = "980a826b8b7f0856015997e424411695"; // Connectors $cc = a\Asset::getAsset($service, a\ConnectorContainer::TYPE, $id); switch ($mode) { case 'all': case 'display': $cc->display(); if ($mode != 'all') { break; } case 'dump': $cc->dump(true); if ($mode != 'all') { break; } case 'get': echo c\L::ID . $cc->getId() . BR . c\L::NAME . $cc->getName() . BR . c\L::PATH . $cc->getPath() . BR . c\L::PROPERTY_NAME . $cc->getPropertyName() . BR . c\L::SITE_NAME . $cc->getSiteName() . BR . c\L::TYPE . $cc->getType() . BR . ""; $children = $cc->getChildren();
function setSitePermissions(a\Cascade $cascade, $new_name) { // set group abilities $new_group = $cascade->getAsset(a\Group::TYPE, $new_name); $new_group->setWysiwygAllowFontFormatting(true)->setWysiwygAllowTextFormatting(true)->setWysiwygAllowImageInsertion(true)->setWysiwygAllowTableInsertion(true)->setWysiwygAllowFontAssignment(false)->setWysiwygAllowViewSource(false)->edit(); // the web team designers $cwt = "CWT-Designers"; $applied_to_children = true; $not_applied_to_children = false; $cascade_path = "/_cascade"; $cascade_blocks_path = $cascade_path . "/blocks"; $cascade_blocks_data_path = $cascade_blocks_path . "/data"; $cascade_blocks_upstate_path = $cascade_blocks_path . "/upstate"; $extra_path = "/_extra"; $links_path = "/_links"; $right_column_path = "/_right-column"; $footer_contact_path = "/_footer-contact"; $site_info_path = "/_site-info"; $asset_factory_container_path = "/Upstate"; $htaccess_path = "/tmp.htaccess"; setAccessRightsForAssetForAllLevel($cascade, a\Folder::TYPE, c\T::ROOT_PATH, $new_name, c\T::READ, $applied_to_children); // step 1: Base Folder // cwt: write setAccessRightsForAsset($cascade, a\Folder::TYPE, c\T::ROOT_PATH, $new_name, a\Group::TYPE, $cwt, c\T::WRITE, $applied_to_children); // new group: write setAccessRightsForAsset($cascade, a\Folder::TYPE, c\T::ROOT_PATH, $new_name, a\Group::TYPE, $new_name, c\T::WRITE, $applied_to_children, c\T::READ); // step 2: _cascade and sub-folders // cwt: write setAccessRightsForAsset($cascade, a\Folder::TYPE, $cascade_path, $new_name, a\Group::TYPE, $cwt, c\T::WRITE, $applied_to_children); // new group: read, all: read setAccessRightsForAsset($cascade, a\Folder::TYPE, $cascade_path, $new_name, a\Group::TYPE, $new_name, c\T::READ, $applied_to_children, c\T::READ); // the blocks folder // all: none setAccessRightsForAssetForAllLevel($cascade, a\Folder::TYPE, $cascade_blocks_path, $new_name, c\T::NONE, $applied_to_children); // the data folder // cwt: write setAccessRightsForAsset($cascade, a\Folder::TYPE, $cascade_blocks_data_path, $new_name, a\Group::TYPE, $cwt, c\T::WRITE, $applied_to_children); // new group: read setAccessRightsForAsset($cascade, a\Folder::TYPE, $cascade_blocks_data_path, $new_name, a\Group::TYPE, $new_name, c\T::READ, $applied_to_children); // step 3: // _extra // no groups can access _extra removeAccessRightsFromAllGroupsForAsset($cascade, a\Folder::TYPE, $extra_path, $new_name, $applied_to_children); // _links // cwt: write, new group: read, all: none setAccessRightsForAsset($cascade, a\Folder::TYPE, $links_path, $new_name, a\Group::TYPE, $cwt, c\T::WRITE, $applied_to_children); setAccessRightsForAsset($cascade, a\Folder::TYPE, $links_path, $new_name, a\Group::TYPE, $new_name, c\T::READ, $applied_to_children, c\T::NONE); // step 4: 3 configuration blocks // new group: read, all: none setAccessRightsForAsset($cascade, a\DataBlock::TYPE, $right_column_path, $new_name, a\Group::TYPE, $new_name, c\T::READ, $not_applied_to_children, c\T::NONE); setAccessRightsForAsset($cascade, a\DataBlock::TYPE, $footer_contact_path, $new_name, a\Group::TYPE, $new_name, c\T::READ, $not_applied_to_children, c\T::NONE); setAccessRightsForAsset($cascade, a\DataBlock::TYPE, $site_info_path, $new_name, a\Group::TYPE, $new_name, c\T::READ, $not_applied_to_children, c\T::NONE); // step 5: Base Folder again // new group: read, all: read setAccessRightsForAsset($cascade, a\Folder::TYPE, c\T::ROOT_PATH, $new_name, a\Group::TYPE, $new_name, c\T::READ, $not_applied_to_children, c\T::READ); // step 6: asset factories setAvailableToGroupsForAssetFactoryContainer($cascade, $new_name); // step 7: tmp.htaccess $file = $cascade->getFile($htaccess_path, $new_name); if ($file != NULL) { $ari = $cascade->getAccessRights(a\File::TYPE, $htaccess_path, $new_name); $ari->addGroupReadAccess(a\Asset::getAsset($cascade->getService(), a\Group::TYPE, $cwt)); $ari->addGroupReadAccess(a\Asset::getAsset($cascade->getService(), a\Group::TYPE, $new_name)); $ari->setAllLevel(c\T::NONE); $cascade->setAccessRights($ari, $not_applied_to_children); } }
// existing content type, new config $tc->addContentTypeLink( a\Asset::getAsset( $service, a\ContentType::TYPE, 'dd46b9bc8b7f085600a0fcdc2fdf8b99' ), 'Desktop' ); // new content type $tc->addContentTypeLink( a\Asset::getAsset( $service, a\ContentType::TYPE, 'bd6f4eaa8b7f0856002a5e117e02a456' ), 'Mobile' )->edit(); */ $tc->removeContentTypeLink(a\Asset::getAsset($service, a\ContentType::TYPE, 'bd6f4eaa8b7f0856002a5e117e02a456'))->edit(); // case 1: both empty //$tc->setHashTags( '' )->setPrefix( '' )->edit(); // case 2: tags only //$tc->setHashTags( 'this' )->setPrefix( '' )->edit(); // case 3: prefix only //$tc->setHashTags( '' )->setPrefix( 'one' )->edit(); // case 4: both //$tc->setHashTags( 'all' )->setPrefix( 'two' )->edit(); if ($mode != 'all') { break; } case 'raw': $tc_std = $service->retrieve($service->createId(c\T::TWITTERCONNECTOR, '03276c068b7f08560150c2965239b3ee'), c\P::TWITTERCONNECTOR); echo S_PRE; var_dump($tc_std);
public function setDynamicFieldValue($field, $values) { if (!is_array($values)) { $values = array($values); } $v_count = count($values); if ($this->metadata_set == NULL) { $this->metadata_set = a\Asset::getAsset($this->service, a\MetadataSet::TYPE, $this->metadata_set_id); } $df_def = $this->metadata_set->getDynamicMetadataFieldDefinition($field); $field_type = $df_def->getFieldType(); $required = $df_def->getRequired(); $df = $this->getDynamicField($field); // text can accept anything if ($field_type == c\T::TEXT && $v_count == 1) { $value = $values[0]; if ($value == NULL) { // turn NULL to empty string $value = ''; } if ($required && $value == '') { throw new e\RequiredFieldException(S_SPAN . "The {$field_type} requires non-empty value" . E_SPAN); } $v = new \stdClass(); $v->value = $value; $df->setValue(array($v)); } else { if (($field_type == c\T::RADIO || $field_type == c\T::DROPDOWN) && $v_count == 1) { $value = $values[0]; // read first value if ($value == '') { // turn empty string to NULL $value = NULL; } if ($required && $value == NULL) { // cannot be empty if required throw new e\RequiredFieldException(S_SPAN . "The {$field_type} requires non-empty value." . E_SPAN); } $possible_values = $df_def->getPossibleValueStrings(); // read from metadataSet if (!in_array($value, $possible_values) && isset($value)) { // undefined value throw new e\NoSuchValueException(S_SPAN . "The value {$value} does not exist." . E_SPAN); } $v = new \stdClass(); if ($value != '') { $v->value = $value; } $df->setValue(array($v)); } else { if (($field_type == c\T::CHECKBOX || $field_type == c\T::MULTISELECT) && $v_count > 0) { if (self::DEBUG) { u\DebugUtility::out('Setting values for checkbox or multiselect'); } if ($required && (in_array(NULL, $values) || in_array('', $values))) { throw new e\RequiredFieldException(S_SPAN . "The {$field_type} requires non-empty value." . E_SPAN); } $possible_values = $df_def->getPossibleValueStrings(); foreach ($values as $value) { if (self::DEBUG) { u\DebugUtility::out("Value: {$value}"); } if (!in_array($value, $possible_values) && isset($value)) { throw new e\NoSuchValueException(S_SPAN . "The value {$value} does not exist." . E_SPAN); } } $v_array = array(); foreach ($values as $value) { $v = new \stdClass(); $v->value = $value; $v_array[] = $v; } $df->setValue($v_array); if (self::DEBUG && self::DUMP) { u\DebugUtility::dump($df->toStdClass()); } } } } //if( self::DEBUG && self::DUMP ){ u\DebugUtility::dump( $this ); } return $this; }
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; $mode = 'all'; //$mode = 'display'; //$mode = 'dump'; //$mode = 'get'; //$mode = 'raw'; try { //$id = "fd276cfc8b7f08560159f3f0db454558"; // root $id = "54b505c28b7f085600ae2282a4b7ed71"; // test $ctc = a\Asset::getAsset($service, a\ContentTypeContainer::TYPE, $id); switch ($mode) { case 'all': case 'display': $ctc->display(); if ($mode != 'all') { break; } case 'dump': $ctc->dump(true); if ($mode != 'all') { break; } case 'get': echo c\L::ID . $ctc->getId() . BR . c\L::NAME . $ctc->getName() . R . c\L::PATH . $ctc->getPath() . BR . c\L::PROPERTY_NAME . $ctc->getPropertyName() . BR . c\L::SITE_NAME . $ctc->getSiteName() . BR . c\L::TYPE . $ctc->getType() . BR . ""; $children = $ctc->getChildren();
echo E_PRE; echo BR . S_PRE; var_dump($ps->getPagePaths()); echo E_PRE; if ($mode != 'all') { break; } case 'add': // reference $ps->addPage(a\Asset::getAsset($service, a\Page::TYPE, '08d27c2a8b7f08560139425c13e5ce17'))->addFile(a\Asset::getAsset($service, a\File::TYPE, '05ce824d8b7f08560139425c9aba7f6d'))->addFolder(a\Asset::getAsset($service, a\Folder::TYPE, 'b8bf838f8b7f0856002a5e11586fba90'))->addFolder(a\Asset::getAsset($service, a\Folder::TYPE, 'df9aa6628b7f085600adcd8159dd733a'))->edit(); if ($mode != 'all') { break; } case 'remove': // test.css $ps->removeFile(a\Asset::getAsset($service, a\File::TYPE, '05ce824d8b7f08560139425c9aba7f6d'))->removeFolder(a\Asset::getAsset($service, a\Folder::TYPE, 'df9aa6628b7f085600adcd8159dd733a'))->edit(); if ($mode != 'all') { break; } case 'set': // case 1: remove schedule //$ps->unsetScheduledPublishing()->edit(); //$ps->setScheduledPublishing( false )->edit(); // case 2: exception thrown, additional value is required //$ps->setScheduledPublishing( true )->edit(); // case 3a: every Friday at 12 am //$ps->setScheduledPublishing( true, a\PublishSet::FRIDAY )->edit(); // case 3b: every Monday at 6:30 pm //$ps->setDayOfWeek( a\PublishSet::MONDAY, '18:30:00.000' )->edit(); // case 3c: every Tuesday at 3 am /*
public function leaveGroup(Group $g) { $g->removeUser(Asset::getAsset($this->getService(), User::TYPE, $this->getProperty()->username))->edit(); return $this; }
public static function assetTreeUpdatePage(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL) { $source_content = 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; } try { $source_page = $child->getAsset($service); $source_page_path = u\StringUtility::removeSiteNameFromPath($source_page->getPath()); } catch (\Exception $e) { throw new e\CascadeInstancesErrorException($e . BR . S_SPAN . "Path: " . $child->getPathPath() . E_SPAN); } // it will fail if there is any irregularity in the page if ($source_page->hasStructuredData()) { $source_page_dd = $source_page->getDataDefinition(); $source_page_dd_path = u\StringUtility::removeSiteNameFromPath($source_page_dd->getPath()); $source_page_dd_site = $source_page_dd->getSiteName(); $target_page_dd_site = $source_page_dd_site; // compare the two data definitions $source_dd = Asset::getAsset($service, DataDefinition::TYPE, $source_page_dd_path, $source_page_dd_site); // data definition must be there $target_dd = $target_cascade->getAsset(DataDefinition::TYPE, $source_page_dd_path, $target_page_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_page->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_page->getXhtml(); } // content type $source_page_ct = $source_page->getContentType(); $source_page_ct_path = u\StringUtility::removeSiteNameFromPath($source_page_ct->getPath()); $source_page_ct_site = $source_page_ct->getSiteName(); $target_page_ct_site = $source_page_ct_site; // content type must be there $target_page_ct = $target_cascade->getAsset(ContentType::TYPE, $source_page_ct_path, $target_page_ct_site); $source_page_path_array = u\StringUtility::getExplodedStringArray("/", $source_page_path); $source_page_path = $source_page_path_array[count($source_page_path_array) - 1]; $source_page_parent_path = $source_page->getParentContainerPath(); // create page $target_site_name = $target_site->getName(); // parent must be there $target_parent = $target_cascade->getAsset(Folder::TYPE, $source_page_parent_path, $target_site_name); $target_page = $target_cascade->createPage($target_parent, $source_page_path, $target_page_ct, $source_content); // update data if ($update_data) { if ($target_page->hasStructuredData()) { try { $target_service = $target_cascade->getService(); $identifiers = $source_page->getIdentifiers(); $identifier_asset_map = array(); $identifier_method_map = array(); $structured_data = new p\StructuredData($target_structured_data_std, $target_service); foreach ($identifiers as $identifier) { // store the resources if ($source_page->isAssetNode($identifier)) { $block_id = $source_page->getBlockId($identifier); if (isset($block_id)) { $resource_id = $block_id; $source_resource_type = Block::getBlockType($service, $resource_id); } $file_id = $source_page->getFileId($identifier); if (isset($file_id)) { $resource_id = $file_id; $source_resource_type = File::TYPE; } $page_id = $source_page->getPageId($identifier); if (isset($page_id)) { $resource_id = $page_id; $source_resource_type = Page::TYPE; } $symlink_id = $source_page->getSymlinkId($identifier); if (isset($symlink_id)) { $resource_id = $symlink_id; $source_resource_type = Symlink::TYPE; } if (isset($resource_id)) { try { $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); $target_resource_id = $asset->getId(); $identifier_asset_map[$identifier] = $asset; $resource_id = NULL; } catch (\Exception $e) { if ($exception_thrown) { throw new e\CascadeInstancesErrorException($e . BR . S_SPAN . "Path: " . $source_resource_path . E_SPAN); } else { DebugUtility::out($e->getMessage()); } } } } catch (\Exception $e) { if ($exception_thrown) { throw new e\CascadeInstancesErrorException($e); } else { DebugUtility::out($e->getMessage()); } } } // reinitialized for next round $resource_id = NULL; } } $identifiers = array_keys($identifier_asset_map); $count = count($identifiers); 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'; } $identifier_method_map[$identifier] = $method; // unplug everything from source $structured_data->{$method}($identifier, NULL); // unset method name $method = NULL; } } try { $target_page->setStructuredData($structured_data); } catch (\Exception $e) { if ($exception_thrown) { throw new e\CascadeInstancesErrorException($e); } else { DebugUtility::out($e->getMessage()); } } if ($count > 0) { foreach ($identifier_method_map as $identifier => $method) { $asset = $identifier_asset_map[$identifier]; $target_page->{$method}($identifier, $identifier_asset_map[$identifier]); } } $target_page->edit(); } catch (\Exception $e) { if ($exception_thrown) { throw new e\CascadeInstancesErrorException($e); } else { DebugUtility::out($e->getMessage()); } } } // page-level blocks and formats $map = self::getPageLevelBlockFormat($source_cascade, $source_page); foreach ($map as $config_name => $regions) { if (count($regions[0]) > 0) { $region_map = $regions[0]; foreach ($region_map as $region => $block_format) { if (isset($block_format['block'])) { if (self::DEBUG) { u\DebugUtility::out("Block " . $block_format['block']); } $type = Block::getBlockType($service, $block_format['block']); if (self::DEBUG) { u\DebugUtility::out("Type " . $type); } $source_block = $source_cascade->getAsset($type, $block_format['block']); $source_block_path = u\StringUtility::removeSiteNameFromPath($source_block->getPath()); $source_block_site = $source_block->getSiteName(); if ($source_block_site == $source_page->getSiteName()) { $target_block_site = $target_page->getSiteName(); } else { $target_block_site = $source_block_site; } try { $target_block = $target_cascade->getAsset($type, $source_block_path, $target_block_site); $target_page->setRegionBlock($config_name, $region, $target_block)->edit(); if (self::DEBUG) { u\DebugUtility::out("Page: " . $target_page->getName() . " Region: " . $region); } } catch (\Exception $e) { if ($exception_thrown) { throw new e\CascadeInstancesErrorException($e); } else { DebugUtility::out($e->getMessage()); } } } else { if (isset($block_format['no-block'])) { $target_page->setRegionNoBlock($config_name, $region, true); } } if (isset($block_format['format'])) { if (self::DEBUG) { u\DebugUtility::out("Format " . $block_format['format']); } $type = Format::getFormatType($service, $block_format['format']); if (self::DEBUG) { u\DebugUtility::out("Type " . $type); } $source_format = $source_cascade->getAsset($type, $block_format['format']); $source_format_path = u\StringUtility::removeSiteNameFromPath($source_format->getPath()); $source_format_site = $source_format->getSiteName(); if ($source_format_site == $source_page->getSiteName()) { $target_format_site = $target_page->getSiteName(); } else { $target_format_site = $source_format_site; } try { $target_format = $target_cascade->getAsset($type, $source_format_path, $target_format_site); $target_page->setRegionFormat($config_name, $region, $target_format)->edit(); if (self::DEBUG) { u\DebugUtility::out("Page: " . $target_page->getName() . " Region: " . $region); } } catch (\Exception $e) { if ($exception_thrown) { throw new e\CascadeInstancesErrorException($e); } else { DebugUtility::out($e->getMessage()); } } } else { if (isset($block_format['no-format'])) { $target_page->setRegionNoFormat($config_name, $region, true); } } } } } } $target_page->setMaintainAbsoluteLinks($source_page->getMaintainAbsoluteLinks())->setShouldBeIndexed($source_page->getShouldBeIndexed())->setShouldBePublished($source_page->getShouldBePublished())->edit(); // commit everything before metadata // metadata if ($update_metadata) { $target_page->setMetadata($source_page->getMetadata()); } }
public function getPageConfigurationSet() { $service = $this->getService(); return Asset::getAsset($service, PageConfigurationSet::TYPE, $this->getProperty()->pageConfigurationSetId); }
if ($mode != 'all') { break; } case 'get': echo c\L::ID . $af->getId() . BR . c\L::NAME . $af->getName() . BR . c\L::PATH . $af->getPath() . BR . c\L::PROPERTY_NAME . $af->getPropertyName() . BR . c\L::SITE_NAME . $af->getSiteName() . BR . c\L::TYPE . $af->getType() . BR . "Allow subfolder placement: " . u\StringUtility::boolToString($af->getAllowSubfolderPlacement()) . BR . "Applicable groups: " . u\StringUtility::getCoalescedString($af->getApplicableGroups()) . BR . "Asset type: " . $af->getAssetType() . BR . "Base asset ID: " . u\StringUtility::getCoalescedString($af->getBaseAssetId()) . BR . "Base asset path: " . u\StringUtility::getCoalescedString($af->getBaseAssetPath()) . BR . "Base asset recycled: " . u\StringUtility::boolToString($af->getBaseAssetRecycled()) . BR . "Folder placement position: " . $af->getFolderPlacementPosition() . BR . "Overwrite: " . u\StringUtility::boolToString($af->getOverwrite()) . BR . c\L::PARENT_CONTAINER_ID . $af->getParentContainerId() . BR . c\L::PARENT_CONTAINER_PATH . $af->getParentContainerPath() . BR . "Placement folder ID: " . u\StringUtility::getCoalescedString($af->getPlacementFolderId()) . BR . "Placement folder path: " . u\StringUtility::getCoalescedString($af->getPlacementFolderPath()) . BR . "Placement folder recycled: " . u\StringUtility::boolToString($af->getPlacementFolderRecycled()) . BR . c\L::SITE_ID . $af->getSiteId() . BR . c\L::SITE_NAME . $af->getSiteName() . BR . "Workflow definition ID: " . u\StringUtility::getCoalescedString($af->getWorkflowDefinitionId()) . BR . "Workflow definition path: " . u\StringUtility::getCoalescedString($af->getWorkflowDefinitionPath()) . BR . "Workflow mode: " . $af->getWorkflowMode() . BR; if ($af->hasPlugin(a\AssetFactory::FILE_LIMIT_PLUGIN)) { u\DebugUtility::dump($af->getPlugin(a\AssetFactory::FILE_LIMIT_PLUGIN)); } u\DebugUtility::dump($af->getPluginNames()); u\DebugUtility::dump($af->getPluginStd()); if ($mode != 'all') { break; } case 'set': $group_name = "cru"; $group = a\Asset::getAsset($service, a\Group::TYPE, $group_name); $af->addGroup($group)->edit(); if ($af->isApplicableToGroup($group)) { echo "Applicable to ", $group->getName(), BR; } else { echo "Not applicable to {$group_name}" . BR; } $af->removeGroup($group)->edit()->dump(true); if ($af->isApplicableToGroup($group)) { echo "Applicable to {$group_name}" . BR; } else { echo "Not applicable to {$group_name}" . BR; } $af->setAllowSubfolderPlacement(true)->setBaseAsset()->setFolderPlacementPosition(1)->setOverwrite(true)->setPlacementFolder($cascade->getFolder("images", "cascade-admin"))->setWorkflowMode(c\T::NONE)->edit()->dump(true); if ($mode != 'all') { break;
public function copy(Container $parent, $new_name) { if ($new_name == "") { throw new e\EmptyNameException(c\M::EMPTY_NAME); } $service = $this->getService(); $self_identifier = $service->createId($this->getType(), $this->getId()); $service->copy($self_identifier, $parent->getIdentifier(), $new_name, false); if ($service->isSuccessful()) { $parent->reloadProperty(); // get info of new child $parent = $parent->getProperty(); $children = $parent->children->child; $child_count = count($children); if ($child_count == 1) { $children = array($children); } // look for the new child foreach ($children as $child) { $child_path = $child->path->path; $child_path_array = explode('/', $child_path); if (in_array($new_name, $child_path_array)) { $child_found = $child; break; } } // get the digital id of child $child_id = $child_found->id; // return new block object return Asset::getAsset($service, $this->getType(), $child_id); } else { throw new e\CopyErrorException(c\M::COPY_ASSET_FAILURE . $service->getMessage()); } }
if ($mode != 'all') { break; } case 'get': echo "ID: " . $fc->getId() . BR . "Name: " . $fc->getName() . BR . "Path: " . $fc->getPath() . BR . "Property name: " . $fc->getPropertyName() . BR . "Site name: " . $fc->getSiteName() . BR . "Type: " . $fc->getType() . BR . ""; $ct_path = "_common:XML"; if ($fc->hasContentType($ct_path)) { echo "The connector has content type: {$ct_path}." . BR; } else { echo "The connector does not " . "have content type: {$ct_path}." . BR; } if ($mode != 'all') { break; } case 'set': $fc->setDestination(a\Asset::getAsset($service, a\Destination::TYPE, '980c57e08b7f0856015997e42b380833'))->edit(); echo $fc->getDestinationPath(); /* // existing content type, new config $fc->addContentTypeLink( a\Asset::getAsset( $service, a\ContentType::TYPE, 'dd46b9bc8b7f085600a0fcdc2fdf8b99' ), 'Desktop' ); // new content type $fc->addContentTypeLink( a\Asset::getAsset( $service, a\ContentType::TYPE, 'bd6f4eaa8b7f0856002a5e117e02a456' ), 'Mobile' )->edit(); */
//$d->setDayOfWeek( $d->getDaysOfWeek() )->edit(); // case 6a: every 2 hours starting at 6:15 am /* $d->setScheduledPublishing( true, NULL, 2, NULL, '06:15:00.000' )->edit(); */ // case 6b: every 4 hours //$d->setPublishIntervalHours( 4 )->edit(); // case 7a: cron expression /* $d->setScheduledPublishing( true, NULL, NULL, "0 0 12 * * ?" )->edit(); */ // case 7b: cron expression //$d->setCronExpression( "0 4 12 * * ?" )->edit(); $d->addUserToSendReport(a\Asset::getAsset($service, a\User::TYPE, 'chanw'))->edit(); if ($mode != 'all') { break; } case 'raw': $d = $service->retrieve($service->createId(c\T::DESTINATION, $id), c\P::DESTINATION); echo S_PRE; var_dump($d); echo E_PRE; if ($mode != 'all') { break; } } } catch (\Exception $e) { echo S_PRE . $e . E_PRE; }