/** * Visit a Block * * @param object BlockSiteComponent $siteComponent * @return mixed * @access public * @since 6/11/08 */ public function visitBlock(BlockSiteComponent $siteComponent) { $orig = $siteComponent->getDisplayName(); $new = $this->replacePlaceholders($orig); if ($orig != $new) { $siteComponent->updateDisplayName($new); } // $orig = $siteComponent->getDescription(); // $new = $this->replacePlaceholders($orig); // if ($orig != $new) // $siteComponent->updateDescription($new); $asset = $siteComponent->getAsset(); $orig = $asset->getContent()->asString(); $new = $this->replacePlaceholders($orig); if ($orig != $new) { $asset->updateContent(Blob::withValue($new)); } }
/** * Update the asset content based on the values from the wizard * * @param array $results * @param object Asset $asset * @return void * @access public * @since 10/26/05 */ function updateAssetContent($results, $asset) { // Content if ($results['checked'] == '1') { $content = $asset->getContent(); $newContent = Blob::withValue($results['value']); if (is_object($content) && !$content->isEqualTo($newContent)) { $asset->updateContent($newContent); } } }
/** * Update the asset content based on the values from the wizard * * @param array $results * @param object Asset $asset * @return void * @access public * @since 10/26/05 */ function updateAssetContent($results, $asset) { // Content try { $content = $asset->getContent(); $newContent = Blob::withValue($results); if (is_object($content) && !$content->isEqualTo($newContent)) { $asset->updateContent($newContent); } } catch (UnimplementedException $e) { $this->saveMessages[] = _("Could not content.") . " " . _("Not supported by this repository."); } catch (PermissionDeniedException $e) { $this->saveMessages[] = _("Could not content.") . " " . _("Permission denied."); } }
/** * Set the persisted 'content' of this plugin. * Content is a single persisted string that can be used if the complexity of * 'dataRecords' is not needed. * * @param string $content * @return void * @access public * @since 1/13/06 */ public final function setContent($content) { $string = Blob::withValue($content); $this->_asset->updateContent($string); }
/** * Save our results. Tearing down and unsetting the Wizard is handled by * in {@link runWizard()} and does not need to be implemented here. * * @param string $cacheName * @return boolean TRUE if save was successful and tear-down/cleanup of the * Wizard should ensue. * @access public * @since 4/28/05 */ function saveWizard($cacheName) { $wizard = $this->getWizard($cacheName); if (!$wizard->validate()) { return false; } // Make sure we have a valid Repository $idManager = Services::getService("Id"); $authZ = Services::getService("AuthZ"); $repository = $this->getRepository(); $properties = $wizard->getAllValues(); if (isset($properties['parentstep']['parent']) && $properties['parentstep']['parent'] && $properties['parentstep']['parent'] != 'NONE') { $parentId = $idManager->getId($properties['parentstep']['parent']); $authorizedToAddToParent = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.add_children"), $parentId); } // First, verify that we chose a parent that we can add children to. if (!$properties['parentstep']['parent'] || $properties['parentstep']['parent'] == 'NONE' || isset($parentId) && $authorizedToAddToParent) { // Get the type from the select if one is specified if (is_string($properties['typestep']['type'])) { $typeString = urldecode($properties['typestep']['type']); $assetType = HarmoniType::fromString($typeString); } else { if (is_array($properties['typestep']['type']) && $properties['typestep']['type']['type_domain'] && $properties['typestep']['type']['type_authority'] && $properties['typestep']['type']['type_keyword']) { $domain = $properties['typestep']['type']['type_domain']; $authority = $properties['typestep']['type']['type_authority']; $keyword = $properties['typestep']['type']['type_keyword']; $description = $properties['typestep']['type']['type_description']; if (!($domain && $authority && $keyword)) { $wizard->setStep("typestep"); return false; } $assetType = new Type($domain, $authority, $keyword, $description); } else { $assetType = new Type("Asset Types", "edu.middlebury", "Generic Asset", "This is an <em>Asset</em> of unspecified type."); } } $asset = $repository->createAsset($properties['namedescstep']['display_name'], $properties['namedescstep']['description'], $assetType); $assetId = $asset->getId(); $this->_assetId = $assetId; if (isset($properties['contentstep']['content'])) { $content = Blob::withValue($properties['contentstep']['content']); try { $asset->updateContent($content); } catch (UnimplementedException $e) { $this->saveMessages[] = _("Could set Asset content.") . " " . _("Not supported by this repository."); } } // Update the effective/expiration dates // if ($properties['datestep']['effective_date']) // $asset->updateEffectiveDate( // DateAndTime::fromString($properties['datestep']['effective_date'])); // if ($properties['datestep']['expiration_date']) // $asset->updateExpirationDate( // DateAndTime::fromString($properties['datestep']['expiration_date'])); // Add our parent if we have specified one. if ($properties['parentstep']['parent'] && $properties['parentstep']['parent'] != 'NONE') { $parentId = $idManager->getId($properties['parentstep']['parent']); $parentAsset = $repository->getAsset($parentId); $parentAsset->addAsset($assetId); } // Log the success or failure if (Services::serviceRunning("Logging")) { $loggingManager = Services::getService("Logging"); $log = $loggingManager->getLogForWriting("Concerto"); $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified."); $priorityType = new Type("logging", "edu.middlebury", "Event_Notice", "Normal events."); $item = new AgentNodeEntryItem("Create Node", "Asset added"); $item->addNodeId($assetId); $item->addNodeId($repository->getId()); $log->appendLogWithTypes($item, $formatType, $priorityType); } return TRUE; } else { $wizard->setStep("parentstep"); return FALSE; } }