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 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()); } }
/** * Construct an asset object * * @param AssetOperationHandlerService $service The service object * @param stdClass $identifier The identifier of the asset * @throws NullServiceException if the service object is NULL * @throws NullIdentifierException if the identifier object is NULL * @throws NullAssetException if the asset cannot be retrieved */ public function __construct(aohs\AssetOperationHandlerService $service, \stdClass $identifier) { if ($service == NULL) { throw new e\NullServiceException(c\M::NULL_SERVICE); } if ($identifier == NULL) { throw new e\NullIdentifierException(c\M::NULL_IDENTIFIER); } if (self::DEBUG && self::DUMP) { u\DebugUtility::dump($identifier); } // get the property $property = $service->retrieve($identifier, c\T::$type_property_name_map[$identifier->type]); if ($property == NULL) { if (isset($identifier->id)) { $id = $identifier->id; } if (isset($identifier->path)) { $path = $identifier->path->path; if (isset($identifier->path->siteName)) { $site_name = $identifier->path->siteName; } } if (!isset($id)) { $id = $path; } throw new e\NullAssetException(S_SPAN . "The " . c\T::$type_property_name_map[$identifier->type] . " cannot be retrieved. ID/Path: " . $id . ". " . (isset($site_name) ? "Site: " . $site_name . ". " : "") . E_SPAN . BR . $service->getMessage()); } // store information $this->service = $service; $this->identifier = $identifier; //stdClass $this->type = $identifier->type; $this->property_name = c\T::$type_property_name_map[$this->type]; $this->property = $property; if (isset($property->id)) { $this->id = $property->id; } if (isset($property->name)) { $this->name = $property->name; } if (isset($property->path)) { $this->path = $property->path; } if (isset($property->siteId)) { $this->site_id = $property->siteId; } if (isset($property->siteName)) { $this->site_name = $property->siteName; } }
public function __construct(\stdClass $sd = NULL, aohs\AssetOperationHandlerService $service = NULL, $data_definition_id = NULL, $data2 = NULL, $data3 = NULL) { // a data definition block will have a data definition id in the sd object // a page will need to pass into the data definition id if (isset($sd)) { // store the data if (isset($sd->definitionId)) { $this->definition_id = $sd->definitionId; $this->type = a\DataDefinitionBlock::TYPE; } else { if (isset($data_definition_id)) { $this->definition_id = $data_definition_id; $this->type = a\Page::TYPE; } } if (isset($sd->definitionPath)) { $this->definition_path = $sd->definitionPath; } // initialize the arrays $this->children = array(); $this->node_map = array(); // store the data definition $this->data_definition = new a\DataDefinition($service, $service->createId(a\DataDefinition::TYPE, $this->definition_id)); // turn structuredDataNode into an array if (isset($sd->structuredDataNodes->structuredDataNode) && !is_array($sd->structuredDataNodes->structuredDataNode)) { $child_nodes = array($sd->structuredDataNodes->structuredDataNode); } elseif (isset($sd->structuredDataNodes->structuredDataNode)) { $child_nodes = $sd->structuredDataNodes->structuredDataNode; if (self::DEBUG) { u\DebugUtility::out("Number of nodes in std: " . count($child_nodes)); } } // convert stdClass to objects StructuredDataNodePhantom::processStructuredDataNodePhantom('', $this->children, $child_nodes, $this->data_definition); } $this->node_map = $this->getIdentifierNodeMap(); $this->identifiers = array_keys($this->node_map); $this->host_asset = $data2; $this->service = $service; if (self::DEBUG) { u\DebugUtility::out("First node ID: " . $first_node_id); } }
public static function getLinkableType(aohs\AssetOperationHandlerService $service, $id_string) { $types = array(Page::TYPE, File::TYPE, Symlink::TYPE); $type_count = count($types); for ($i = 0; $i < $type_count; $i++) { $id = $service->createId($types[$i], $id_string); $operation = new \stdClass(); $read_op = new \stdClass(); $read_op->identifier = $id; $operation->read = $read_op; $operations[] = $operation; } $service->batch($operations); $reply_array = $service->getReply()->batchReturn; for ($j = 0; $j < $type_count; $j++) { if ($reply_array[$j]->readResult->success == 'true') { foreach (c\T::$type_property_name_map as $type => $property) { if (isset($reply_array[$j]->readResult->asset->{$property})) { return $type; } } } } return "The id does not match any asset type."; }
public static function initialize(aohs\AssetOperationHandlerService $service) { try { $service->listMessages(); if ($service->isSuccessful()) { $messages = $service->getListedMessages(); $temp_msg = array(); if (!($messages->message == NULL)) { if (!is_array($messages->message)) { $temp_msg[] = $messages->message; } else { $temp_msg = $messages->message; } foreach ($temp_msg as $message) { $id = $message->id; $to = $message->to; $from = $message->from; $date = $message->date; $subject = trim($message->subject); $body = $message->body; self::$all_message_ids[] = $id; $message_obj = new Message($message); // store all messages self::$all_messages[] = $message_obj; self::$id_obj_map[$id] = $message_obj; // from whom? if (!isset($message_ids_from[$from])) { self::$message_ids_from[$from] = array(); } self::$message_ids_from[$from][] = $id; if ($from != 'system') { self::$non_system_messages[] = $message_obj; } if (self::DEBUG) { u\DebugUtility::out($message_obj->getType()); } if ($message_obj->getType() == Message::TYPE_EXPIRATION) { self::$asset_expiration_message[] = $message_obj; self::$asset_expiration_message_ids[] = $id; } else { if ($message_obj->getType() == Message::TYPE_PUBLISH) { self::$publish_messages[] = $message_obj; self::$publish_message_ids[] = $id; // no issues if (strpos($subject, "(0 issue(s))") !== false) { if (self::DEBUG) { echo "L::121 " . $id . BR; } self::$publish_message_ids_without_issues[] = $id; self::$publish_messages_without_issues[] = $message_obj; } else { if (self::DEBUG) { echo "L::124 " . $id . BR; } self::$publish_message_ids_with_issues[] = $id; self::$publish_messages_with_issues[] = $message_obj; } } else { if ($message_obj->getType() == Message::TYPE_UNPUBLISH) { self::$unpublish_messages[] = $message_obj; self::$unpublish_message_ids[] = $id; // no issues if (strpos($subject, "(0 issue(s))") !== false) { self::$unpublish_message_ids_without_issues[] = $id; self::$unpublish_messages_without_issues[] = $message_obj; } else { self::$unpublish_message_ids_with_issues[] = $id; self::$unpublish_messages_with_issues[] = $message_obj; } } else { if ($message_obj->getType() == Message::TYPE_SUMMARY) { self::$summary_messages[] = $message_obj; self::$summary_message_ids[] = $id; // 0 failures if (strpos($subject, "(0 failures)") !== false) { self::$summary_message_ids_no_failures[] = $id; self::$summary_messages_no_failures[] = $message_obj; } else { self::$summary_message_ids_with_failures[] = $id; self::$summary_messages_with_failures[] = $message_obj; } } else { if ($message_obj->getType() == Message::TYPE_WORKFLOW) { self::$workflow_messages[] = $message_obj; self::$workflow_message_ids[] = $id; // is complete if (strpos($subject, "is complete") !== false) { self::$workflow_message_ids_is_complete[] = $id; self::$workflow_messages_complete[] = $message_obj; } else { self::$workflow_message_ids_other[] = $id; self::$workflow_messages_other[] = $message_obj; } } else { self::$other_messages[] = $message_obj; self::$other_message_ids[] = $id; } } } } } // date } usort(self::$all_messages, self::NAME_SPACE . "\\" . 'Message::compare'); usort(self::$publish_messages, self::NAME_SPACE . "\\" . 'Message::compare'); usort(self::$unpublish_messages, self::NAME_SPACE . "\\" . 'Message::compare'); usort(self::$workflow_messages, self::NAME_SPACE . "\\" . 'Message::compare'); usort(self::$other_messages, self::NAME_SPACE . "\\" . 'Message::compare'); usort(self::$publish_messages_with_issues, self::NAME_SPACE . "\\" . 'Message::compare'); usort(self::$unpublish_messages_with_issues, self::NAME_SPACE . "\\" . 'Message::compare'); usort(self::$workflow_messages_other, self::NAME_SPACE . "\\" . 'Message::compare'); usort(self::$non_system_messages, self::NAME_SPACE . "\\" . 'Message::compare'); } //var_dump( $workflow_message_ids_is_complete ); } else { echo "Failed to list messages. " . $service->getMessage(); } } catch (\Exception $e) { echo S_PRE . $e . E_PRE; } }
function assetTreeRemoveAsset(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL) { if (is_array($results) && is_array($results[c\F::REPORT_ORPHANS]) && in_array($child->getPathPath(), $results[c\F::REPORT_ORPHANS][$child->getType()])) { if (isset($params[c\F::REMOVE_ASSET][c\F::UNCONDITIONAL_REMOVAL]) && $params[c\F::REMOVE_ASSET][c\F::UNCONDITIONAL_REMOVAL] == true) { $service->delete($child->toStdClass()); } else { if (!in_array($child->getId(), $params[c\F::REMOVE_ASSET][$child->getType()]) && !in_array($child->getPathPath(), $params[c\F::REMOVE_ASSET][$child->getType()])) { $service->delete($child->toStdClass()); } } } }