Beispiel #1
0
 /**
  * Execute
  * 
  * @return void
  * @access public
  * @since 7/31/08
  */
 public function execute()
 {
     try {
         if (!RequestContext::value('id')) {
             throw new InvalidArgumentException("Id is expected.");
         }
         $selection = Segue_Selection::instance();
         $director = SiteDispatcher::getSiteDirector();
         $component = $director->getSiteComponentById(RequestContext::value('id'));
         if ($selection->isSiteComponentInSet($component)) {
             $selection->removeSiteComponent($component);
         }
         $this->start();
         $selection->reset();
         while ($selection->hasNext()) {
             $siteComponent = $selection->nextSiteComponent();
             print "\n\t<siteComponent type='" . $siteComponent->getComponentClass() . "' ";
             if (method_exists($siteComponent, 'isSection')) {
                 if ($siteComponent->isSection()) {
                     print "navType='Section' ";
                 } else {
                     print "navType='Page' ";
                 }
             }
             print "id='" . $siteComponent->getId() . "' ";
             print "displayName=\"" . str_replace('"', '&quot', preg_replace('/\\s+/', ' ', strip_tags($siteComponent->getDisplayName()))) . "\" ";
             print "/>";
         }
         $this->end();
     } catch (Exception $e) {
         HarmoniErrorHandler::logException($e);
         $this->error($e->getMessage(), get_class($e));
     }
 }
Beispiel #2
0
 /**
  * Execute this action.
  * 
  * @return void
  * @access public
  * @since 7/28/08
  */
 public function execute()
 {
     if (!$this->isAuthorizedToExecute()) {
         throw new PermissionDeniedException(_("Your are not authorized to copy this site here."));
     }
     $srcSlot = $this->getSourceSlot();
     $srcSiteAsset = $this->getSourceSiteAsset();
     $director = SiteDispatcher::getSiteDirector();
     $srcComponent = $director->getSiteComponentFromAsset($srcSiteAsset);
     $destSlot = $this->getDestSlot();
     if (RequestContext::value('command') == 'copy') {
         try {
             /*********************************************************
              * Export the Site
              *********************************************************/
             $exportDir = DATAPORT_TMP_DIR . "/" . $srcSlot->getShortname() . "-" . str_replace(':', '_', DateAndTime::now()->asString());
             mkdir($exportDir);
             // Do the export
             $visitor = new DomExportSiteVisitor($exportDir);
             $visitor->enableStatusOutput(_("Exporting from original location."));
             $srcComponent->acceptVisitor($visitor);
             $doc = $visitor->doc;
             // Validate the result
             // 			printpre(htmlentities($doc->saveXMLWithWhitespace()));
             // 			$tmp = new Harmoni_DomDocument;
             // 			$tmp->loadXML($doc->saveXMLWithWhitespace());
             // 			$tmp->schemaValidateWithException(MYDIR."/doc/raw/dtds/segue2-site.xsd");
             $doc->schemaValidateWithException(MYDIR . "/doc/raw/dtds/segue2-site.xsd");
             // 			printpre($this->listDir($exportDir));
             // 			throw new Exception('test');
             /*********************************************************
              * Import the site
              *********************************************************/
             $importer = new DomImportSiteVisitor($doc, $exportDir, $director);
             if (RequestContext::value('copy_permissions') == 'true') {
                 $importer->enableRoleImport();
             }
             if (RequestContext::value('copy_discussions') != 'true') {
                 $importer->disableCommentImport();
             }
             // 			if (isset($values['owners'])) {
             // 				$idMgr = Services::getService('Id');
             // 				foreach($values['owners']['admins'] as $adminIdString)
             // 					$importer->addSiteAdministrator($idMgr->getId($adminIdString));
             // 			}
             $importer->enableStatusOutput(_("Importing into new location"));
             $importer->makeUserSiteAdministrator();
             $site = $importer->importAtSlot($destSlot->getShortname());
             // Delete the decompressed Archive
             $this->deleteRecursive($exportDir);
             /*********************************************************
              * Log the success
              *********************************************************/
             if (Services::serviceRunning("Logging")) {
                 $loggingManager = Services::getService("Logging");
                 $log = $loggingManager->getLogForWriting("Segue");
                 $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("Copy Site", "Site copied from placeholder, '" . $srcSlot->getShortname() . "' to '" . $destSlot->getShortname() . "'.");
                 $item->addNodeId($site->getQualifierId());
                 $log->appendLogWithTypes($item, $formatType, $priorityType);
             }
         } catch (Exception $e) {
             $this->deleteRecursive($exportDir);
             if (file_exists($exportDir . ".tar.gz")) {
                 unlink($exportDir . ".tar.gz");
             }
             throw $e;
         }
     } else {
         // Detach the site from the source slot.
         $srcSlot->deleteSiteId();
         // Attach the site to the dest slot.
         $destSlot->setSiteId($srcSiteAsset->getId());
         // Make the source an alias of the destination so that links still work.
         $srcSlot->makeAlias($destSlot);
         /*********************************************************
          * Log the success
          *********************************************************/
         if (Services::serviceRunning("Logging")) {
             $loggingManager = Services::getService("Logging");
             $log = $loggingManager->getLogForWriting("Segue");
             $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("Move Site", "Site moved from placeholder, '" . $srcSlot->getShortname() . "' to '" . $destSlot->getShortname() . "'.");
             $item->addNodeId($destSlot->getSiteId());
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
     }
     // Remove from selection?
     if (RequestContext::value('remove_after_use') == 'remove') {
         $selection = Segue_Selection::instance();
         $selection->removeSiteComponent($srcComponent);
     }
     print "\n" . _("Done");
     exit;
 }
 /**
  * Visit a menu organizer and return the menu GUI component that corresponds
  * to it.
  * 
  * @param object MenuOrganizerSiteComponent
  * @return object Component
  * @access public
  * @since 1/15/07
  */
 public function visitMenuOrganizer(MenuOrganizerSiteComponent $organizer)
 {
     $guiContainer = parent::visitMenuOrganizer($organizer);
     // Add the "Append" form to the organizer
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.add_children"), $organizer->getQualifierId())) {
         $allowed = array();
         $allowed[] = _("Pages and Sections");
         $allowed[] = new Type('segue-multipart', 'edu.middlebury', 'ContentPage_multipart');
         $allowed[] = new Type('segue-multipart', 'edu.middlebury', 'SubMenu_multipart');
         $allowed[] = new Type('segue-multipart', 'edu.middlebury', 'SidebarSubMenu_multipart');
         $allowed[] = new Type('segue-multipart', 'edu.middlebury', 'SidebarContentPage_multipart');
         // 		$allowed[] = new Type('segue', 'edu.middlebury', 'NavBlock');
         $allowed[] = _("Content Blocks");
         $pluginManager = Services::getService("PluginManager");
         $allowed = array_merge($allowed, $pluginManager->getEnabledPlugins());
         $formHtml = "\n\t<div class='ui2_add_form_wrapper'>";
         $formHtml .= $this->getAddFormHTML($organizer->getId(), null, $allowed, true);
         // Move/Copy from selection
         $formHtml .= "\n\t | " . Segue_Selection::instance()->getMoveCopyLink($organizer);
         $formHtml .= "\n\t</div>";
         $childComponent = $guiContainer->add($this->addFlowChildWrapper($organizer, $organizer->getTotalNumberOfCells(), new UnstyledMenuItem($formHtml, 2)), null, '100%', null, TOP);
         // Add a spacer at the end of the menu
         $guiContainer->add(new UnstyledMenuItem("<div> &nbsp; </div>"));
     }
     // Add controls bar and border
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $organizer->getQualifierId())) {
         $controlsHTML = $this->getBarPreHTML('#00F', $organizer) . $this->getControlsHTML($organizer, "<em>" . $this->_classNames['MenuOrganizer'] . "</em>", $organizer->acceptVisitor($this->_controlsVisitor), '#00F', '#99F', '#66F');
         $guiContainer->setPreHTML($controlsHTML . "\n<div style='z-index: 0;'>" . $guiContainer->getPreHTML($null = null));
         $guiContainer->setPostHTML($guiContainer->getPostHTML($null = null) . "</div>" . $this->getBarPostHTML());
     }
     return $guiContainer;
 }
Beispiel #4
0
 /**
  * 
  * 
  * @param <##>
  * @return <##>
  * @access public
  * @since 1/18/06
  */
 public function printSiteShort(Asset $asset, $action, $num, Slot $otherSlot = null)
 {
     $harmoni = Harmoni::instance();
     $assetId = $asset->getId();
     $authZ = Services::getService('AuthZ');
     $idMgr = Services::getService('Id');
     if (!$authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId) && !$otherSlot->isUserOwner()) {
         return new UnstyledBlock('', BLANK);
     }
     $container = new Container(new YLayout(), BLOCK, STANDARD_BLOCK);
     $fillContainerSC = new StyleCollection("*.fillcontainer", "fillcontainer", "Fill Container", "Elements with this style will fill their container.");
     $fillContainerSC->addSP(new MinHeightSP("88%"));
     // 	$fillContainerSC->addSP(new WidthSP("100%"));
     // 	$fillContainerSC->addSP(new BorderSP("3px", "solid", "#F00"));
     $container->addStyle($fillContainerSC);
     $centered = new StyleCollection("*.centered", "centered", "Centered", "Centered Text");
     $centered->addSP(new TextAlignSP("center"));
     // Use the alias instead of the Id if it is available.
     $viewUrl = SiteDispatcher::getSitesUrlForSiteId($assetId->getIdString());
     $slotManager = SlotManager::instance();
     try {
         $sitesTrueSlot = $slotManager->getSlotBySiteId($assetId);
     } catch (Exception $e) {
     }
     // Print out the content
     ob_start();
     print "\n\t<div class='portal_list_slotname'>";
     if (isset($sitesTrueSlot)) {
         if (is_null($otherSlot) || $sitesTrueSlot->getShortname() == $otherSlot->getShortname()) {
             print $sitesTrueSlot->getShortname();
         } else {
             print $otherSlot->getShortname();
             $targets = array();
             $target = $otherSlot->getAliasTarget();
             while ($target) {
                 $targets[] = $target->getShortname();
                 if ($target->isAlias()) {
                     $target = $target->getAliasTarget();
                 } else {
                     $target = null;
                 }
             }
             print "\n<br/>";
             print str_replace('%1', implode(' &raquo; ', $targets), _("(an alias of %1)"));
             // Add Alias info.
             // 				if ($otherSlot->isAlias()) {
             // 					ob_start();
             //
             // 					print _("This slot is an alias of ").$slot->getAliasTarget()->getShortname();
             //
             // 					$container->add(new UnstyledBlock(ob_get_clean()), "100%", null, LEFT, TOP);
             // 				}
         }
     } else {
         print _("ID#") . ": " . $assetId->getIdString();
     }
     print "\n\t</div>";
     print "\n\t<div class='portal_list_site_title'>";
     if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) {
         print "\n\t\t<a href='" . $viewUrl . "'>";
         print "\n\t\t\t<strong>" . HtmlString::getSafeHtml($asset->getDisplayName()) . "</strong>";
         print "\n\t\t</a>";
         print "\n\t\t<br/>";
         print "\n\t\t<a href='" . $viewUrl . "' style='font-size: smaller;'>";
         print "\n\t\t\t" . $viewUrl;
         print "\n\t\t</a>";
     }
     print "\n\t</div>";
     print "\n\t<div class='portal_list_controls'>\n\t\t";
     $controls = array();
     if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) {
         $controls[] = "<a href='" . $viewUrl . "'>" . _("view") . "</a>";
     }
     // Hide all edit links if not authenticated to prevent web spiders from traversing them
     if ($this->isAuthenticated) {
         // While it is more correct to check modify permission permission, doing
         // so forces us to check AZs on the entire site until finding a node with
         // authorization or running out of nodes to check. Since edit-mode actions
         // devolve into view-mode if no authorization is had by the user, just
         // show the links all the time to cut page loads from 4-6 seconds to
         // less than 1 second.
         if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) {
             $controls[] = "<a href='" . SiteDispatcher::quickURL($action->getUiModule(), 'editview', array('node' => $assetId->getIdString())) . "'>" . _("edit") . "</a>";
         }
         // 		if ($action->getUiModule() == 'ui2') {
         // 			$controls[] = "<a href='".SiteDispatcher::quickURL($action->getUiModule(), 'arrangeview', array('node' => $assetId->getIdString()))."'>"._("arrange")."</a>";
         // 		}
         // add link to tracking
         if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) {
             $trackUrl = $harmoni->request->quickURL("participation", "actions", array('node' => $assetId->getIdString()));
             ob_start();
             print " <a target='_blank' href='" . $trackUrl . "'";
             print ' onclick="';
             print "var url = '" . $trackUrl . "'; ";
             print "window.open(url, 'site_map', 'width=600,height=600,resizable=yes,scrollbars=yes'); ";
             print "return false;";
             print '"';
             print ">" . _("track") . "</a>";
             $controls[] = ob_get_clean();
         }
         if (!is_null($otherSlot) && $otherSlot->isAlias() && $otherSlot->isUserOwner()) {
             $controls[] = "<a href='" . $harmoni->request->quickURL('slots', 'remove_alias', array('slot' => $otherSlot->getShortname())) . "' onclick=\"if (!confirm('" . str_replace("%1", $otherSlot->getShortname(), str_replace("%2", $otherSlot->getAliasTarget()->getShortname(), _("Are you sure that you want \\'%1\\' to no longer be an alias of \\'%2\\'?"))) . "')) { return false; }\">" . _("remove alias") . "</a>";
         } else {
             if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.delete'), $assetId)) {
                 $controls[] = "<a href='" . $harmoni->request->quickURL($action->getUiModule(), 'deleteComponent', array('node' => $assetId->getIdString())) . "' onclick=\"if (!confirm('" . _("Are you sure that you want to permenantly delete this site?") . "')) { return false; }\">" . _("delete") . "</a>";
             }
         }
         // Add a control to select this site for copying. This should probably
         // have its own authorization, but we'll use add_children/modify for now.
         if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.modify'), $assetId)) {
             if (isset($sitesTrueSlot) && (is_null($otherSlot) || $sitesTrueSlot->getShortname() == $otherSlot->getShortname())) {
                 $controls[] = Segue_Selection::instance()->getAddLink(SiteDispatcher::getSiteDirector()->getSiteComponentFromAsset($asset));
             }
         }
     }
     print implode("\n\t\t | ", $controls);
     print "\n\t</div>";
     if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) {
         $description = HtmlString::withValue($asset->getDescription());
         $description->trim(25);
         print "\n\t<div class='portal_list_site_description'>" . $description->asString() . "</div>";
     }
     print "\n\t<div style='clear: both;'></div>";
     print $this->getExportControls($assetId, $otherSlot, $sitesTrueSlot);
     $component = new UnstyledBlock(ob_get_clean());
     $container->add($component, "100%", null, LEFT, TOP);
     return $container;
 }
Beispiel #5
0
 /**
  * Execute this action.
  * 
  * @return void
  * @access public
  * @since 7/28/08
  */
 public function execute()
 {
     if (!$this->isAuthorizedToExecute()) {
         throw new PermissionDeniedException(_("Your are not authorized to move/copy items here."));
     }
     // Clear any output buffers.
     while (ob_get_level()) {
         ob_end_clean();
     }
     $director = SiteDispatcher::getSiteDirector();
     foreach (RequestContext::value('sourceIds') as $sourceId) {
         print "\n<hr/>";
         try {
             $sourceComponent = $director->getSiteComponentById($sourceId);
             switch (RequestContext::value('command')) {
                 case 'copy':
                     $successMessage = _("Successfully copied %1.");
                     $this->copyComponent($sourceComponent);
                     break;
                 case 'move':
                     $successMessage = _("Successfully moved %1.");
                     $this->moveComponent($sourceComponent);
                     break;
                 case 'reference':
                     $successMessage = _("Created a reference to %1.");
                     $this->referenceComponent($sourceComponent);
                     break;
                 default:
                     throw new InvalidArgumentException("Unknown command '" . RequestContext::value('command') . "'");
             }
             // Ensure that the current user is an editor of the component.
             // They may have had implicit Editor and only Author at the destination.
             $roleMgr = SegueRoleManager::instance();
             $editor = $roleMgr->getRole('editor');
             $role = $roleMgr->getUsersRole($sourceComponent->getQualifierId(), true);
             if ($role->isLessThan($editor)) {
                 $editor->applyToUser($sourceComponent->getQualifierId(), true);
             }
             print "\n" . str_replace("%1", htmlspecialchars($sourceComponent->getDisplayName()), $successMessage);
             // Remove from selection?
             if (RequestContext::value('remove_after_use') == 'remove') {
                 $selection = Segue_Selection::instance();
                 $selection->removeSiteComponent($sourceComponent);
             }
         } catch (Exception $e) {
             print "\n" . htmlspecialchars($e->getMessage());
         }
     }
     print "\n<br/><br/>" . _("Done");
     exit;
 }
 /**
  * Answer controls for adding to the selection.
  * 
  * @param object BlockSiteComponent $siteComponent
  * @return string
  * @access public
  * @since 8/5/08
  */
 public function getSelectionAdd(BlockSiteComponent $siteComponent)
 {
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     $harmoni = Harmoni::instance();
     if (!$authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $siteComponent->getQualifierId())) {
         return false;
     }
     return Segue_Selection::instance()->getAddLink($siteComponent);
 }
Beispiel #7
0
 /**
  * Add the header controls to the main screen gui component
  * 
  * @param object Component $mainScreen
  * @return object Component The allWrapper
  * @access public
  * @since 4/7/08
  */
 public function addHeaderControls(Component $mainScreen)
 {
     $harmoni = Harmoni::instance();
     /*********************************************************
      * Additional setup
      *********************************************************/
     $rootSiteComponent = SiteDispatcher::getCurrentRootNode();
     $outputHandler = $harmoni->getOutputHandler();
     /*********************************************************
      * Theme
      *********************************************************/
     $outputHandler->setCurrentTheme($rootSiteComponent->getTheme());
     /*********************************************************
      * Other headers and footers
      *********************************************************/
     // Remove any existing title tags from the head text
     print preg_replace("/<title>[^<]*<\\/title>/", "", $outputHandler->getHead());
     //Add our new title
     print "\n\t\t<title>";
     print strip_tags(SiteDispatcher::getCurrentNode()->acceptVisitor(new BreadCrumbsVisitor(SiteDispatcher::getCurrentNode())));
     print "</title>";
     // Add our common Harmoni javascript libraries
     require POLYPHONY_DIR . "/main/library/Harmoni.js.inc.php";
     print Segue_MediaLibrary::getHeadHtml();
     $outputHandler->setHead(ob_get_clean());
     UserDataHelper::writeHeadJs();
     // Add the RSS head links
     RssLinkPrinter::addHeadLinks(SiteDispatcher::getCurrentNode());
     // Add the selection Panel
     Segue_Selection::instance()->addHeadJavascript();
     $allWrapper = new Container(new YLayout(), BLANK, 1);
     if (defined('SEGUE_SITE_HEADER')) {
         $this->siteMessage = $allWrapper->add(new Component($this->getSegueSiteHeader(), BLANK, 1), "100%", null, CENTER, TOP);
     }
     // :: login, links and commands
     $this->headRow = $allWrapper->add(new Container(new XLayout(), BLANK, 1), $rootSiteComponent->getWidth(), null, CENTER, TOP);
     $this->leftHeadColumn = $this->headRow->add($this->getSegueLinksComponent(), null, null, LEFT, TOP);
     $rightHeadColumn = $this->headRow->add(new Container(new YLayout(), BLANK, 1), null, null, CENTER, TOP);
     $rightHeadColumn->add($this->getLoginComponent(), null, null, RIGHT, TOP);
     if ($this->isAuthorizedToExecute()) {
         $rightHeadColumn->add($this->getCommandsComponent(), null, null, RIGHT, TOP);
     }
     $allWrapper->add($mainScreen, $rootSiteComponent->getWidth(), null, CENTER, TOP);
     // :: Top Row ::
     // 		$this->headRow = $mainScreen->add(
     // 			new Container(new XLayout, HEADER, 1),
     // 			"100%", null, CENTER, TOP);
     // 		$this->leftHeadColumn = $this->headRow->add(
     // 			new UnstyledBlock("<h1>".$rootSiteComponent->getTitleMarkup()."</h1>"),
     // 			null, null, LEFT, TOP);
     return $allWrapper;
 }