/** * Search for SiteComponents with the title passed going down the hierarchy * * @param object SiteComponent $startingComponent * @return mixed string or null * @access private * @since 12/3/07 */ private function searchDown(SiteComponent $startingComponent) { return $startingComponent->acceptVisitor($this); }
/** * get display name of node that action is applied to * * @return string * @access public * @since 1/23/09 */ public function getTargetDisplayName() { return $this->_node->acceptVisitor(new ParticipationBreadCrumbsVisitor($this->_node)); }
/** * get display name of node that action is applied to * * @return string * @access public * @since 1/23/09 */ public function getTargetDisplayName() { $nodeUrl = $this->_node->acceptVisitor(new ParticipationBreadCrumbsVisitor($this->_node)); $versionUrl = " (Version: " . $this->_version->getNumber() . ")"; return $nodeUrl . $versionUrl; }
/** * get all actions in the node * * @return array of Participation_Action * @access public * @since 1/23/09 */ public function getActions() { $visitor = new ParticipationSiteVisitor(); $this->_node->acceptVisitor($visitor); return $visitor->getActions(); }
/** * Copy a component. * * @param object SiteComponent * @return void * @access protected * @since 8/4/08 */ protected function copyComponent(SiteComponent $siteComponent) { $authZ = Services::getService("AuthZ"); $idMgr = Services::getService("Id"); if (!$authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.modify'), $siteComponent->getQualifierId())) { throw new PermissionDeniedException("You are not authorized to copy this node from its original location."); } try { /********************************************************* * Export the Component *********************************************************/ $exportDir = DATAPORT_TMP_DIR . "/" . $siteComponent->getId() . "-" . str_replace(':', '_', DateAndTime::now()->asString()); mkdir($exportDir); // Do the export $visitor = new DomExportSiteVisitor($exportDir); $visitor->enableStatusOutput(_("Exporting from original location.")); $siteComponent->acceptVisitor($visitor); $doc = $visitor->doc; // Validate the result // printpre(htmlentities($doc->saveXMLWithWhitespace())); $doc->schemaValidateWithException(MYDIR . "/doc/raw/dtds/segue2-subtree.xsd"); // printpre($this->listDir($exportDir)); // throw new Exception('test'); /********************************************************* * Import the Component *********************************************************/ $importer = new DomImportSiteVisitor($doc, $exportDir, SiteDispatcher::getSiteDirector()); if (RequestContext::value('copy_permissions') == 'true') { $importer->enableRoleImport(); } if (RequestContext::value('copy_discussions') == 'false') { $importer->disableCommentImport(); } $importer->enableStatusOutput(_("Importing into new location")); $newComponent = $importer->importSubtreeUnderOrganizer($this->getDestinationComponent()); // Delete the decompressed Archive $this->deleteRecursive($exportDir); return $newComponent; } catch (Exception $e) { $this->deleteRecursive($exportDir); if (file_exists($exportDir . ".tar.gz")) { unlink($exportDir . ".tar.gz"); } throw $e; } }
/** * Import data into an existing component. * * @param object DOMElement $element * @param object SiteComponent $siteComponent * @return object SiteComponent * @access protected * @since 1/22/08 */ protected function importComponent(DOMElement $element, SiteComponent $siteComponent) { if ($element->hasAttribute('new_id')) { throw new Exception("The " . $element->nodeName . " element with id '" . $element->getAttribute('id') . "' already has a new_id set."); } $element->setAttribute('new_id', $siteComponent->getId()); // Pass ourselves off to the component to traverse the hierarchy and set // data from the source document. $siteComponent->acceptVisitor($this); return $siteComponent; }
/** * Answer true if this block is in the header or footer * * @param object SiteComponent $siteComponent * @return boolean * @access public * @since 1/10/08 */ public function isHeaderOrFooter(SiteComponent $siteComponent) { if (!isset($this->isHeaderFooterVisitor)) { $this->isHeaderFooterVisitor = new IsHeaderFooterSiteVisitor(); } return $siteComponent->acceptVisitor($this->isHeaderFooterVisitor); }