function assetTreeConvertToOneRegionTemplate(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL) { if (!isset($params['site-storage']) || !isset($params['global-link-script']) || !isset($params['page-title']) || !isset($params['search-form']) || !isset($params['content-type'])) { throw new \Exception("Some of the parameters are missing."); } $type = $child->getType(); if ($type != a\Page::TYPE) { return; } // skip entire folder if (strpos($child->getPathPath(), "_extra/") !== false) { return; } if (strpos($child->getPathPath(), "_cascade/") !== false) { return; } $site_storage_block = $params['site-storage']; $global_link_script_block = $params['global-link-script']; $page_title_block = $params['page-title']; $search_form_block = $params['search-form']; $one_region_ct = $params['content-type']; $page = $service->getAsset($child->getType(), $child->getId()); try { $page->setContentType($one_region_ct); $cur_sd = $page->getStructuredData(); $new_sd = $cur_sd->mapData(); $page->setStructuredData($new_sd); $page->setBlock("site-config-group;site-storage", $site_storage_block)->setBlock("site-config-group;global-link-script", $global_link_script_block)->setBlock("site-config-group;page-title", $page_title_block)->setBlock("site-config-group;search-form", $search_form_block)->edit(); } catch (\Exception $e) { echo $page->getId(), BR; throw $e; } }
function assetTreeFixPhantomNodes(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL) { // skip entire folder if (strpos($child->getPathPath(), "_extra/") !== false) { return; } if (strpos($child->getPathPath(), "_cascade/") !== false) { return; } $type = $child->getType(); if ($type != a\Page::TYPE && $type != a\DataBlock::TYPE) { return; } try { $asset = $child->getAsset($service); if ($asset->hasPhantomNodes()) { $asset->mapData(); } } catch (e\NoSuchFieldException $e) { if ($type == a\Page::TYPE) { $asset = new a\PagePhantom($service, $child->toStdClass()); } else { $asset = new a\DataDefinitionBlockPhantom($service, $child->toStdClass()); } $dd = $asset->getDataDefinition(); $healthy_sd = new p\StructuredData($dd->getStructuredData(), $service, $dd->getId()); $phantom_sd = $asset->getStructuredDataPhantom(); $healthy_sd = $healthy_sd->removePhantomNodes($phantom_sd); $asset->setStructuredData($healthy_sd); } }
function assetTreeChangeFull(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL) { // skip entire folder if (strpos($child->getPathPath(), "_extra/") !== false) { return; } if (strpos($child->getPathPath(), "_cascade/") !== false) { return; } $type = $child->getType(); if ($type != a\Page::TYPE) { return; } $page = $child->getAsset($service); try { if ($page->hasStructuredData()) { $node_ids = array("size", "content-group;0;content-group-size", "content-group;1;content-group-size", "content-group;2;content-group-size", "content-group;3;content-group-size"); foreach ($node_ids as $node_id) { if ($page->hasNode($node_id) && ($page->getText($node_id) == "Full" || $page->getText($node_id) == "" || $page->getText($node_id) == NULL)) { $page->setText($node_id, "full")->edit(); } } } } catch (\Exception $e) { echo $page->getId(), BR; throw $e; } }
function assetTreeReportPagePath(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL) { $type = $child->getType(); if ($type != a\Page::TYPE) { return; } echo $child->getPathPath(), BR; }
function processPage(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL) { // Get the next page to be processed $page = $child->getAsset($service); echo "<tr>\n"; // get the full Page asset echo "<td><a href='" . $GLOBALS['url'] . $child->getId() . "'>" . $child->getPathPath() . "</a></td>\n<td>" . $page->getContentTypePath() . "</td>\n"; echo "</tr>\n"; }
function assetTreeRemoveUnwantedPage(aohs\AssetOperationHandlerService $service, p\Child $child, array $params = NULL, array &$results = NULL) { if ($child->getType() != a\Page::TYPE) { return; } $page_path = $child->getPathPath(); // junk page names if (u\StringUtility::endsWith($page_path, "/pdf") || u\StringUtility::endsWith($page_path, "/word") || u\StringUtility::endsWith($page_path, "/externallink") || u\StringUtility::endsWith($page_path, "/keytiny") || u\StringUtility::endsWith($page_path, "/index-2")) { $service->delete($child->toStdClass()); } }
function assetTreeSearchForNeedleInHaystack(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL) { $type = $child->getType(); $needle = $params[$type]['needle']; // the method name should be defined for the asset // and returns a string $method = $params[$type]['method']; $haystack = $child->getAsset($service)->{$method}(); if (strpos($haystack, $needle) !== false) { $results[$type][] = $child->getPathPath(); } }
function changeContentType(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL) { // Get the next page to be processed $page = $child->getAsset($service); echo "<tr>\n"; // get the full Page asset echo "<td>" . $child->getPathPath() . "</td>\n<td>" . $page->getContentTypePath() . "</td>\n"; /* Assumes old and new content types are associated with the same data definition. http://www.upstate.edu/cascade-admin/projects/web-services/oop/classes/asset-classes/page.php */ $page->setContentType($GLOBALS['newContentType'], true)->edit(); }
function assetTreeReportPhantomNodes(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL) { if (!isset($results) || !is_array($results)) { throw new \Exception("The results array is required"); } $type = $child->getType(); if ($type != a\Page::TYPE && $type != a\DataBlock::TYPE) { return; } if (!isset($results[$type])) { $results[$type] = array(); } $asset = $child->getAsset($service); if ($asset->hasPhantomNodes()) { $results[$type][] = $child->getPathPath(); } }
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) == "") { throw new \Exception("No pattern is supplied"); } if (!isset($results) || !is_array($results)) { throw new \Exception("No results array is supplied"); } $asset = $child->getAsset($service); $identifiers = $asset->searchTextByPattern($pattern); if (count($identifiers) > 0) { $results[$child->getPathPath()] = $identifiers; } }
function processPage(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL) { $contentType = "9fb82b39956aa0783236eb66c57479a3"; // Content Types/Bootstrap/Standard Bootstrap $newContentType = $cascade->getAsset(a\ContentType::TYPE, $contentType); // Get the next page to be processed $page = $child->getAsset($service); echo "<tr>\n"; // get the full Page asset echo "<td>" . $child->getPathPath() . "</td>\n<td>" . $page->getContentTypePath() . "</td>\n"; /* Assumes old and new content types are associated with the same data definition. http://www.upstate.edu/cascade-admin/projects/web-services/oop/classes/asset-classes/page.php */ $page->setContentType($newContentType, true)->edit(); // Recheck the page's current content type echo "<td>" . $page->getContentTypeId() . "</td>\n"; echo "</tr>\n"; }
function assetTreeReplaceTextByPattern(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"]; $replacement = $params["replacement"]; if (!isset($pattern) || trim($pattern) == "") { throw new \Exception("No pattern is supplied"); } if (!isset($replacement) || trim($replacement) == "") { throw new \Exception("No replacement is supplied"); } $asset = $child->getAsset($service); if (count($asset->searchTextByPattern($pattern)) > 0) { echo $child->getPathPath(), BR; $asset->replaceByPattern($pattern, $replacement)->edit(); } }
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 static function assetTreeReportScheduledPublishPublishSet(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL) { if (!isset($params['cache'])) { throw new e\ReportException(S_SPAN . c\M::NULL_CACHE . E_SPAN); } $cache = $params['cache']; $path = $child->getPathPath(); $type = $child->getType(); if ($type != PublishSet::TYPE) { return; } $ps = $cache->retrieveAsset($child); if ($ps->getUsesScheduledPublishing()) { $time_expression = self::getTimeInfo($ps); $site = $ps->getSiteName(); $results[$type][] = $site . ":" . $path . ", " . $time_expression; } }
function assetTreeSwitchPageContentType(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL) { if ($child->getType() != a\Page::TYPE) { return; } // make sure that there is a content type passed in if (!isset($params['ct'])) { throw new \Exception("No content type is supplied"); } // make sure that there is a base page passed in if (!isset($params['bp'])) { throw new \Exception("No base page is supplied"); } // pages to skip if (isset($params['skip'])) { $skip = $params['skip']; } if (in_array($child->getPathPath(), $skip)) { return; } $ct = $params['ct']; $bp = $params['bp']; // retrieve page to be processed $p = $child->getAsset($service); // get number of content-group $identifier = "content-group;0"; $num_of_groups = 1; // get the number of instances of the multiple node if ($p->hasIdentifier($identifier)) { $num_of_groups = $p->getNumberOfSiblings($identifier); } // get the current structured data with data $sd_old = $p->getStructuredData(); if (!isset($sd_old)) { return; } // create enough instances of the multiple field if ($num_of_groups > 1) { $bp->createNInstancesForMultipleField($num_of_groups, $identifier); } // get the blank structured data with needed nodes $sd_new = clone $bp->getStructuredData(); // roll back the base page if ($num_of_groups > 1) { $bp->createNInstancesForMultipleField(1, $identifier); } // switch the content type $p->setContentType($ct, false); // fix the data if (u\StringUtility::endsWith($child->getPathPath(), 'index')) { $sd_new->setText("right-column", "yes"); } else { $sd_new->setText("right-column", "no"); } $sd_new->setText("left-column", "yes"); $sd_new->setText("left-column-group;left-setup", "default"); // the H1 $sd_new->setText("main-content-title", $sd_old->getText("main-content-title")); // main WYSIWYG $sd_new->setText("main-content-content", $sd_old->getText("main-content-content")); // multiple groups with choosers for ($i = 0; $i < $num_of_groups; $i++) { $identifier = "content-group;" . $i . ";content-group-chooser"; // null the id for the upcoming round $block_id = NULL; // read the block if ($sd_old->hasIdentifier($identifier)) { $block_id = $sd_old->getBlockId($identifier); } // if there is a block attached if (isset($block_id) && $block_id != "") { $b = a\Block::getBlock($service, $block_id); $sd_new->setBlock($identifier, $b); $identifier = "content-group;" . $i . ";content-group-size"; $size_str = strtolower($sd_old->getText($identifier)); // fix the possible value for the new data definition if ($size_str != 'full') { $size_str = 'half'; } $sd_new->setText($identifier, $size_str); $identifier = "content-group;" . $i . ";content-group-block-floating"; $sd_new->setText($identifier, strtolower($sd_old->getText($identifier))); } // WYSIWYGs in group $identifier = "content-group;" . $i . ";content-group-content"; $sd_new->setText($identifier, $sd_old->getText($identifier)); } // set the data $p->setStructuredData($sd_new); }
function assetTreeSwitchPageContentType(aohs\AssetOperationHandlerService $service, p\Child $child, array $params = NULL, array &$results = NULL) { if ($child->getType() != a\Page::TYPE) { return; } // make sure that there is a content type passed in if (!isset($params['ct'])) { throw new \Exception("No content type is supplied"); } // make sure that there is a base page passed in if (!isset($params['bp'])) { throw new \Exception("No base page is supplied"); } // make sure that there are global blocks passed in if (!isset($params['google-tag']) || !isset($params['site-storage']) || !isset($params['link-script']) || !isset($params['page-title']) || !isset($params['search-form'])) { throw new \Exception("No global blocks are supplied"); } // pages to skip if (isset($params['skip'])) { $skip = $params['skip']; } // skip whatever that is supposed to be skipped if (isset($skip) && is_array($skip) && in_array($child->getPathPath(), $skip)) { return; } // retrieve all required assets $ct = $params['ct']; $bp = $params['bp']; $google_tag = $params['google-tag']; $site_storage = $params['site-storage']; $link_script = $params['link-script']; $page_title = $params['page-title']; $search_form = $params['search-form']; // can run into phantom nodes try { // retrieve page to be processed $p = $child->getAsset($service); // get number of content-group $identifier = "content-group;0"; $num_of_groups = 1; // get the number of instances of the multiple node if ($p->hasIdentifier($identifier)) { $num_of_groups = $p->getNumberOfSiblings($identifier); } // get the current structured data with data $sd_old = $p->getStructuredData(); if (!isset($sd_old)) { return; } // create enough instances of the multiple field if ($num_of_groups > 1) { $bp->createNInstancesForMultipleField($num_of_groups, $identifier); } // get the blank structured data with needed nodes $sd_new = clone $bp->getStructuredData(); // roll back the base page if ($num_of_groups > 1) { $bp->createNInstancesForMultipleField(1, $identifier); } // switch the content type $p->setContentType($ct, false); // fix the data if (u\StringUtility::endsWith($p->getPath(), 'index')) { $sd_new->setText("right-column", "yes"); } else { $sd_new->setText("right-column", "no"); } $sd_new->setText("left-column", "yes"); $sd_new->setText("left-column-group;left-setup", "default"); // the H1 echo "Title: ", $p->getMetadata()->getTitle(), BR; $title = $p->getMetadata()->getTitle() != "" ? $p->getMetadata()->getTitle() : "Title to be set"; $sd_new->setText("main-content-title", $p->getMetadata()->getTitle()); // main WYSIWYG $sd_new->setText("main-content-content", $sd_old->getText("main-content-content")); // multiple groups with choosers for ($i = 0; $i < $num_of_groups; $i++) { $identifier = "content-group;" . $i . ";content-group-chooser"; // null the id for the upcoming round $block_id = NULL; // read the block if ($sd_old->hasIdentifier($identifier)) { $block_id = $sd_old->getBlockId($identifier); } // if there is a block attached if (isset($block_id) && $block_id != "") { $b = a\Block::getBlock($service, $block_id); $sd_new->setBlock($identifier, $b); $identifier = "content-group;" . $i . ";content-group-size"; $size_str = strtolower($sd_old->getText($identifier)); // fix the possible value for the new data definition if ($size_str != 'full') { $size_str = 'half'; } $sd_new->setText($identifier, $size_str); $identifier = "content-group;" . $i . ";content-group-block-floating"; $sd_new->setText($identifier, strtolower($sd_old->getText($identifier))); } // WYSIWYGs in group $identifier = "content-group;" . $i . ";content-group-content"; $sd_new->setText($identifier, $sd_old->getText($identifier)); } // set the data $p->setStructuredData($sd_new); } catch (e\NoSuchFieldException $e) { $page_id = $child->getId(); $phantom_page = new a\PagePhantom($service, $service->createId(a\PagePhantom::TYPE, $page_id)); $dd = $phantom_page->getDataDefinition(); $healthy_sd = new p\StructuredData($dd->getStructuredData(), $service, $dd->getId()); $phantom_sd = $phantom_page->getStructuredDataPhantom(); $healthy_sd = $healthy_sd->removePhantomNodes($phantom_sd); $phantom_page->setStructuredData($healthy_sd); } // attach the five global blocks $p->setBlock("site-config-group;google-tag-manager", $google_tag)->setBlock("site-config-group;site-storage", $site_storage)->setBlock("site-config-group;global-link-script", $link_script)->setBlock("site-config-group;page-title", $page_title)->setBlock("site-config-group;search-form", $search_form)->setBlock("site-config-group;global-script")->edit(); }
function assetTreeSearchByName(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL) { if (is_array($results)) { $path = $child->getPathPath(); $type = $child->getType(); // no name supplied if (!isset($params[c\F::SEARCH_BY_NAME][$type]['name'])) { return; } else { $name = $params[c\F::SEARCH_BY_NAME][$type]['name']; } if (!isset($results[c\F::SEARCH_BY_NAME])) { $results[c\F::SEARCH_BY_NAME] = array(); // if (!isset($results[c\F::SEARCH_BY_NAME][$type])) { $results[c\F::SEARCH_BY_NAME][$type] = array(); } } // if name is found in asset name if (strpos($path, $name) !== false) { $results[c\F::SEARCH_BY_NAME][$type][] = $path; } } }