Example #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));
     }
 }
 /**
  * Answer the organizer above the reference node that can accept the component type given.
  * 
  * @param object SiteComponent $refNode
  * @param object Type $componentType
  * @return object OrganizerSiteComponent
  * @access public
  * @since 1/15/09
  * @static
  */
 public static function getOrganizerForComponentType(SiteComponent $refNode, Type $componentType)
 {
     // For pages and sections, find the menu above our component.
     if ($componentType->getDomain() == 'segue-multipart') {
         $parentComponent = $refNode->getParentComponent();
         while ($parentComponent) {
             if ($parentComponent->getComponentClass() == 'MenuOrganizer') {
                 return $parentComponent;
             }
             $parentComponent = $parentComponent->getParentComponent();
         }
         // If we didn't find a menu above our ref node, maybe we started in a heading.
         // Search down for a menu.
         $director = SiteDispatcher::getSiteDirector();
         $rootNode = $director->getRootSiteComponent($refNode->getId());
         $result = $rootNode->acceptVisitor(new GetMenuBelowSiteVisitor());
         if ($result) {
             return $result;
         }
         // If we still haven't found a menu, then there isn't one in this site.
         // Nothing more we can do.
         throw new OperationFailedException("Cannot create a " . $componentType->getKeyword() . ". Site " . $rootNode->getSlot()->getShortname() . " - '" . $rootNode->getDisplayName() . "' does not have any menus to add this component to.");
     } else {
         $parentComponent = $refNode->getParentComponent();
         while ($parentComponent) {
             if ($parentComponent->getComponentClass() == 'FlowOrganizer' || $parentComponent->getComponentClass() == 'MenuOrganizer') {
                 return $parentComponent;
             }
         }
         // If we haven't found a flow organizer above the refNode, something is wrong.
         throw new OperationFailedException("Cannot create a " . $componentType->getKeyword() . ". A ContentOrganizer was not found above reference node " . $refNode->getId());
     }
 }
 /**
  * Execute the action
  * 
  * @return mixed
  * @access public
  */
 public function execute()
 {
     try {
         if (!$this->isAuthorizedToExecute()) {
             throw new PermissionDeniedException();
         }
         ob_start();
         $harmoni = Harmoni::instance();
         $component = SiteDispatcher::getCurrentNode();
         $site = SiteDispatcher::getCurrentRootNode();
         $slotMgr = SlotManager::instance();
         $slot = $slotMgr->getSlotBySiteId($site->getId());
         $exportDirname = $slot->getShortname() . "-html";
         $exportDir = DATAPORT_TMP_DIR . "/" . $exportDirname;
         $archivePath = DATAPORT_TMP_DIR . '/' . $exportDirname . ".zip";
         if (!file_exists($exportDir)) {
             header('HTTP/1.1 404 Not Found');
             print "Not Found";
             exit;
         }
         header("Content-Type: text/html;");
         $this->printStatus($exportDir);
     } catch (PermissionDeniedException $e) {
         header('HTTP/1.1 403 Forbidden');
         header("Content-Type: text/plain;");
         print _("You are not authorized to monitor the export this component.");
         exit;
     }
     exit;
 }
Example #4
0
 /**
  * Visit a Block
  * 
  * @param object BlockSiteComponent $siteComponent
  * @return mixed
  * @access public
  * @since 8/31/07
  */
 public function visitBlock(BlockSiteComponent $siteComponent)
 {
     // check to see if user is authorized to view block
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     if (!$authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view_comments"), $idManager->getId($siteComponent->getId()))) {
         return;
     }
     $harmoni = Harmoni::instance();
     //get all comments for site component
     $commentsManager = CommentManager::instance();
     $comments = $commentsManager->getAllComments($siteComponent->getAsset());
     while ($comments->hasNext()) {
         $comment = $comments->next();
         $item = $this->addItem(new RSSItem());
         $item->setTitle($comment->getSubject());
         $item->setLink(SiteDispatcher::quickURL("view", "html", array("node" => $siteComponent->getId())) . "#comment_" . $comment->getIdString(), true);
         $item->setPubDate($comment->getModificationDate());
         $agentMgr = Services::getService("Agent");
         $agent = $comment->getAuthor();
         $item->setAuthor($agent->getDisplayName());
         $item->setCommentsLink(SiteDispatcher::quickURL("view", "html", array("node" => $siteComponent->getId())));
         $pluginMgr = Services::getService("PluginManager");
         $plugin = $pluginMgr->getPlugin($comment->getAsset());
         $item->setDescription($plugin->executeAndGetMarkup());
         // MediaFile eclosures.
         try {
             foreach ($plugin->getRelatedMediaFiles() as $file) {
                 $item->addEnclosure($file->getUrl(), $file->getSize()->value(), $file->getMimeType());
             }
         } catch (UnimplementedException $e) {
         }
     }
 }
Example #5
0
 /**
  * Answer a links back to the main Segue pages
  * 
  * @return object GUIComponent
  * @access public
  * @since 1/12/07
  */
 function getCommandsComponent()
 {
     $harmoni = Harmoni::instance();
     ob_start();
     print "<div class='commands'>";
     print "<a href='";
     print SiteDispatcher::quickURL('view', 'html');
     print "' title='" . _("Go to View-Mode") . "'>";
     print _("view") . "</a>";
     print " | <a href='";
     print SiteDispatcher::quickURL('ui2', 'editview');
     print "' title='" . _("Go to Edit-Mode") . "'>";
     print _("edit") . "</a>";
     print " | " . _("header/footer");
     print " | <a href='";
     print SiteDispatcher::quickURL('ui2', 'arrangeview');
     print "' title='" . _("Go to Arrange-Mode") . "'>";
     print _("arrange") . "</a>";
     // Add permissions button
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     // Rather than checking the entire site, we will just check the current node.
     // This forces users who are not site-wide admins to browse to the place where
     // they are administrators in order to see the permissions button, but
     // cuts load-times for non-admins on a given large site from 35s to 1.4s.
     if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view_authorizations"), SiteDispatcher::getCurrentNode()->getQualifierId())) {
         $url = SiteDispatcher::quickURL("roles", "choose_agent", array("node" => SiteDispatcher::getCurrentNodeId(), "returnModule" => $harmoni->request->getRequestedModule(), "returnAction" => $harmoni->request->getRequestedAction()));
         print " | \n\t<a href='#' onclick='window.location = \"{$url}\".urlDecodeAmpersands(); return false;'>";
         print _("roles") . "</a>";
     }
     print " | " . self::getUiSwitchForm();
     print "</div>";
     $ret = new Component(ob_get_clean(), BLANK, 2);
     return $ret;
 }
 /**
  * Add a link for a node
  * 
  * @param object SiteComponent $node
  * @return void
  * @access public
  * @since 5/31/07
  */
 function addLink($node)
 {
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace(null);
     $this->_links[] = "<a href='" . SiteDispatcher::quickUrl($this->getModule(), $this->getAction(), array('node' => $node->getId())) . "'>" . $node->getDisplayName() . "</a>";
     $harmoni->request->endNamespace();
 }
Example #7
0
 /**
  * Answer the appropriate site visitor for this action
  * 
  * @return object SiteVisitor
  * @access public
  * @since 9/24/07
  */
 function getSiteVisitor()
 {
     if (!isset($this->visitor)) {
         $requestedNode = SiteDispatcher::getCurrentNode();
         $this->visitor = new EditHeaderFooterSiteVisitor();
     }
     return $this->visitor;
 }
 /**
  * Answer the current site id for this source.
  * 
  * @return string $id
  * @access private
  * @since 5/15/08
  */
 private function getSiteId()
 {
     if (isset($this->siteId)) {
         return $this->siteId;
     } else {
         return SiteDispatcher::getCurrentRootNode()->getId();
     }
 }
Example #9
0
 /**
  * Answer the items with given tag for a given item
  * 
  * @return object TagIterator
  * @access public
  * @since 11/8/06
  */
 function getItems()
 {
     $tag = $this->getTag();
     $SiteComponent = SiteDispatcher::getCurrentNode();
     $visitor = new TaggableItemVisitor();
     $items = $SiteComponent->acceptVisitor($visitor);
     $tagIds = $tag->getItemsInList($items);
     return $tag->getItemsWithIdsInSystem($tagIds, "segue");
 }
Example #10
0
 /**
  * Answer the tags for given item by everyone 
  * 
  * @return object TagIterator
  * @access public
  * @since 11/8/06
  */
 function getTags()
 {
     $harmoni = Harmoni::instance();
     $tagManager = Services::getService("Tagging");
     $SiteComponent = SiteDispatcher::getCurrentNode();
     $visitor = new TaggableItemVisitor();
     $items = $SiteComponent->acceptVisitor($visitor);
     SiteDispatcher::passthroughContext();
     $tags = $tagManager->getTagsForItems($items, TAG_SORT_ALFA, $this->getNumTags());
     return $tags;
 }
Example #11
0
 /**
  * Answer the items with given tag in a given Segue site
  * 
  * @return object TagIterator
  * @access public
  * @since 11/8/06
  */
 function getItems()
 {
     $tag = $this->getTag();
     $rootSiteComponent = SiteDispatcher::getCurrentRootNode();
     $tagManager = Services::getService("Tagging");
     $agentId = $tagManager->getCurrentUserId();
     $visitor = new TaggableItemVisitor();
     $items = $rootSiteComponent->acceptVisitor($visitor);
     $tagIds = $tag->getItemsInList($items);
     return $tag->getItemsForAgentInListinSystem($tagIds, $agentId, "segue");
 }
Example #12
0
 /**
  * Answer the appropriate site visitor for this action
  * 
  * @return object SiteVisitor
  * @access public
  * @since 1/7/08
  */
 public function getSiteVisitor()
 {
     if (!isset($this->visitor)) {
         $requestedNode = SiteDispatcher::getCurrentNode();
         if ($requestedNode->acceptVisitor(new IsBlockVisitor())) {
             $this->visitor = new HistorySiteVisitor($requestedNode);
         } else {
             $this->visitor = new ViewModeSiteVisitor();
         }
     }
     return $this->visitor;
 }
 /**
  * Answer the plugin content for a block
  * 
  * @param object BlockSiteComponent $block
  * @return string
  * @access public
  * @since 1/7/08
  */
 function getPluginContent($block)
 {
     if ($block->getId() != $this->_node->getId()) {
         return parent::getPluginContent($block);
     }
     $harmoni = Harmoni::instance();
     $pluginManager = Services::getService('PluginManager');
     $plugin = $pluginManager->getPlugin($block->getAsset());
     if (!strlen(RequestContext::value('late_rev'))) {
         return _("No version specified");
     }
     $lateVersion = $plugin->getVersion(RequestContext::value('late_rev'));
     if (RequestContext::value('early_rev')) {
         $earlyVersion = $plugin->getVersion(RequestContext::value('early_rev'));
     } else {
         $earlyVersion = $lateVersion->getPrecedingVersion();
     }
     ob_start();
     // 		print "\n<h3 class='diff_title'>"._("Selected Versions")."</h3>";
     print "\n<a href='";
     $browseHistoryUrl = SiteDispatcher::quickURL($harmoni->request->getRequestedModule(), 'view_history', array('node' => SiteDispatcher::getCurrentNodeId(), 'early_rev' => RequestContext::value('early_rev'), 'late_rev' => RequestContext::value('late_rev')));
     print $browseHistoryUrl;
     $harmoni->history->markReturnUrl('revert_' . $block->getId(), $browseHistoryUrl);
     print "'>";
     print "\n<input type='button' value='" . _('&laquo; Choose Versions') . "'/>";
     print "</a>";
     print "\n<table class='version_compare'>";
     print "\n\t<thead>";
     print "\n\t\t<tr>";
     print "\n\t\t\t<th>";
     print $this->getHeadingBlock($earlyVersion);
     print "\n\t\t\t</th>";
     print "\n\t\t\t<th>";
     print $this->getHeadingBlock($lateVersion);
     print "\n\t\t\t</th>";
     print "\n\t\t</tr>";
     print "\n\t</thead>";
     print "\n\t<tbody>";
     print "\n\t\t<tr>";
     print "\n\t\t\t<td>";
     print $earlyVersion->getMarkup();
     print "\n\t\t\t</td>";
     print "\n\t\t\t<td>";
     print $lateVersion->getMarkup();
     print "\n\t\t\t</td>";
     print "\n\t\t</tr>";
     print "\n\t</tbody>";
     print "\n</table>";
     print "\n<h3 class='diff_title'>" . _("Changes") . "</h3>";
     print $plugin->getVersionDiff($earlyVersion->getVersionXml(), $lateVersion->getVersionXml());
     return ob_get_clean();
 }
Example #14
0
 /**
  * Answer the items with given tag in a Segue site by a given user
  * 
  * @return object TagIterator
  * @access public
  * @since 11/8/06
  */
 function getItems()
 {
     $harmoni = Harmoni::instance();
     $tag = $this->getTag();
     $rootSiteComponent = SiteDispatcher::getCurrentRootNode();
     $tagManager = Services::getService("Tagging");
     $agentId = $tagManager->getCurrentUserId();
     $visitor = new TaggableItemVisitor();
     $items = $rootSiteComponent->acceptVisitor($visitor);
     $tagIds = $tag->getItemsInList($items);
     //printpre($tagIds);
     return $tag->getItemsForAgent($agentId);
 }
Example #15
0
 /**
  * Answer the tags for a given items for a given user 
  * 
  * @return object TagIterator
  * @access public
  * @since 11/8/06
  */
 function getTags()
 {
     $harmoni = Harmoni::instance();
     $tag = $this->getTag();
     $siteComponent = SiteDispatcher::getCurrentNode();
     $agentManager = Services::getService("Agent");
     $tagManager = Services::getService("Tagging");
     $agentId = $tagManager->getCurrentUserId();
     $visitor = new TaggableItemVisitor();
     $items = $siteComponent->acceptVisitor($visitor);
     SiteDispatcher::passthroughContext();
     $tags = $tagManager->getTagsForItemsByAgent($items, $agentId);
     return $tags;
 }
 /**
  * Execute this action for generating an XML response with participation summary information
  * 
  * @return mixed
  * @access public
  * @since 4/25/05
  */
 public function execute()
 {
     if (!$this->isAuthorizedToExecute()) {
         $this->error("Permission Denied");
     }
     $node = SiteDispatcher::getCurrentNode();
     $id = RequestContext::value('participant');
     $view = new Participation_View($node);
     $idMgr = Services::getService('Id');
     $participantView = new Participation_Participant($view, $idMgr->getId($id));
     $this->start();
     print "\n\t<role id='comments' number='" . $participantView->getNumActionsByCategory('commenter') . "'/>";
     print "\n\t<role id='author' number='" . $participantView->getNumActionsByCategory('author') . "'/>";
     print "\n\t<role id='editor' number='" . $participantView->getNumActionsByCategory('editor') . "'/>";
     $this->end();
 }
Example #17
0
 /**
  * Add the site header gui components
  * 
  * @return Component
  * @access public
  * @since 4/7/08
  */
 public function getSiteHeader()
 {
     $harmoni = Harmoni::instance();
     ob_start();
     $harmoni->request->startNamespace('polyphony-tags');
     print "\n<form action='" . SiteDispatcher::quickURL(null, null, array('tag' => RequestContext::value('tag'))) . "' method='post' style='display: inline;'>";
     print "\n\t<select name='" . RequestContext::name('num_tags') . "'";
     print " onchange='this.form.submit()'>";
     $options = array(50, 100, 200, 400, 600, 1000, 0);
     foreach ($options as $option) {
         print "\n\t\t<option value='" . $option . "' " . ($option == $this->getNumTags() ? " selected='selected'" : "") . ">" . ($option ? $option : _('all')) . "</option>";
     }
     print "\n\t</select>";
     print "\n</form>";
     $harmoni->request->endNamespace();
     return new Block(str_replace('%1', ob_get_clean(), _("Showing top %1 tags")), STANDARD_BLOCK);
 }
Example #18
0
 /**
  * Process changes to the site components. This is the method that the various
  * actions that modify the site should override.
  * 
  * @param object SiteDirector $director
  * @return void
  * @access public
  * @since 4/14/06
  */
 function processChanges(SiteDirector $director)
 {
     $component = $director->getSiteComponentById(SiteDispatcher::getCurrentNodeId());
     $component->acceptVisitor(new ModifySettingsSiteVisitor());
     /*********************************************************
      * Log the event
      *********************************************************/
     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("Component Modified", $component->getComponentClass() . " modified.");
         $item->addNodeId($component->getQualifierId());
         $site = $component->getDirector()->getRootSiteComponent($component->getId());
         if (!$component->getQualifierId()->isEqual($site->getQualifierId())) {
             $item->addNodeId($site->getQualifierId());
         }
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
 }
Example #19
0
 /**
  * Execute the action
  * 
  * @return void
  * @access public
  * @since 7/10/08
  */
 public function execute()
 {
     if (!$this->isAuthorizedToExecute()) {
         throw new PermissionDeniedException();
     }
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     $hierarchyManager = Services::getService('Hierarchy');
     $site = SiteDispatcher::getCurrentRootNode();
     $hierarchy = $hierarchyManager->getHierarchy($idManager->getId("edu.middlebury.authorization.hierarchy"));
     $infoList = $hierarchy->traverse($idManager->getId($site->getId()), Hierarchy::TRAVERSE_MODE_DEPTH_FIRST, Hierarchy::TRAVERSE_DIRECTION_DOWN, Hierarchy::TRAVERSE_LEVELS_ALL);
     $status = new StatusStars(str_replace('%1', $infoList->count(), _("Rebuilding Implicit AZs on %1 nodes.")));
     $status->initializeStatistics($infoList->count());
     $azCache = $authZ->getAuthorizationCache();
     while ($infoList->hasNext()) {
         $info = $infoList->next();
         $node = $hierarchy->getNode($info->getNodeId());
         // 			printpre("Rebuilding implicit AZs for ".$node->getId()." '".$node->getDisplayName()."'. Ancestors:");
         // 			printpre($node->getAncestorIds());
         $azCache->createHierarchyImplictAZs($node, $node->getAncestorIds());
         $status->updateStatistics();
     }
     printpre("Done.");
     /*********************************************************
      * Log the event
      *********************************************************/
     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", "Error", "Errors that did not halt execution");
         $item = new AgentNodeEntryItem("Rebuilt Implict AZs", "Hierarchy-Implicit AZs for site '" . $site->getDisplayName() . "' were rebuilt manually.");
         $item->addNodeId($site->getQualifierId());
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
 }
 /**
  * Answer the Url for this component id.
  *
  * Note: this is clunky that this object has to know about harmoni and 
  * what action to target. Maybe rewrite...
  * 
  * @param string $id
  * @return string
  * @access public
  * @since 4/4/06
  */
 function getUrlForComponent($id)
 {
     $harmoni = Harmoni::instance();
     $origUrl = $harmoni->history->getReturnURL('view_history_' . $this->_node->getId());
     $module = $harmoni->request->getModuleFromUrl($origUrl);
     if ($module == false) {
         $module = 'ui1';
     }
     $action = $harmoni->request->getActionFromUrl($origUrl);
     if ($action == false) {
         $action = 'view';
     }
     return SiteDispatcher::quickURL($module, $action, array("node" => $id));
 }
 /**
  * Answer the form for Adding new components
  * 
  * @param string $organizerId
  * @param integer $cellIndex
  * @param array $allowed Which components to allow addition of: MenuOrganizer, FlowOrganizer, FixedOrganizer
  * @return string The form HTML
  * @access public
  * @since 4/14/06
  */
 function getInsertFormHTML($director, $organizerId, $cellIndex, $allowed)
 {
     ob_start();
     $harmoni = Harmoni::instance();
     print "\n<form action='";
     print $harmoni->request->quickURL('ui2', 'addComponent', array('returnNode' => SiteDispatcher::getCurrentNodeId(), 'returnAction' => $this->_action));
     print "' method='post'>";
     print "\n\t<input type='hidden' name='" . RequestContext::name('organizerId') . "' value='" . $organizerId . "'/>";
     print "\n\t<input type='hidden' name='" . RequestContext::name('cellIndex') . "' value='" . $cellIndex . "'/>";
     print "\n\t<div style='text-decoration: underline; cursor: pointer; white-space: nowrap;'";
     print "onclick='this.style.display=\"none\"; this.nextSibling.style.display=\"block\";'";
     print ">";
     print "\n\t\t" . _("Insert New...");
     print "\n\t</div>";
     print "<div style='display: none'>";
     // Selection of our menu target
     if (in_array('MenuOrganizer', $allowed)) {
         $menuTarget = $this->getDefaultMenuTargetId($director, $organizerId, $cellIndex);
         if (!$menuTarget) {
             $menuTarget = 'NewCellInNavOrg';
         }
         // 			print "<br/>".$menuTarget;
         print "\n\t\t\t<input type='hidden' name='" . RequestContext::name('menuTarget') . "' value='" . $menuTarget . "'/>";
     }
     print "\n\t\t<select name='" . RequestContext::name('componentType') . "'>";
     foreach ($allowed as $type) {
         print "\n\t\t\t<option value='" . $type->asString() . "'>";
         if (isset($this->_classNames[$type->getKeyword()])) {
             print $this->_classNames[$type->getKeyword()];
         } else {
             print $type->getKeyword();
         }
         print "</option>";
     }
     print "\n\t\t</select>";
     print "\n\t\t<div style=''>";
     print "\n\t\t\t<input type='submit' value='" . _('Create') . "'/>";
     print "\n\t\t\t<input type='button' ";
     print "onclick='this.parentNode.parentNode.style.display=\"none\"; this.parentNode.parentNode.previousSibling.style.display=\"block\";'";
     print " value='" . _("Cancel") . "'/>";
     print "\n\t\t</div>";
     print "\n\t</div>";
     print "</form>";
     return ob_get_clean();
 }
Example #22
0
 /**
  * Answer the url to return to
  * 
  * @return string
  * @access public
  * @since 6/4/07
  */
 function getReturnUrl()
 {
     if (isset($this->_newIsNav) && $this->_newIsNav && isset($this->_newId)) {
         $harmoni = Harmoni::instance();
         return SiteDispatcher::quickURL('ui1', 'editNav', array('node' => $this->_newId, 'returnAction' => $harmoni->request->get("returnAction"), 'returnNode' => $this->_newId));
     } else {
         return parent::getReturnUrl();
     }
 }
 /**
  * Answer the Url for this component id.
  *
  * Note: this is clunky that this object has to know about harmoni and 
  * what action to target. Maybe rewrite...
  * 
  * @param string $id
  * @return string
  * @access public
  * @since 4/4/06
  */
 protected function getUrlForComponent($id)
 {
     $harmoni = Harmoni::instance();
     if ($harmoni->request->getRequestedModule() == 'versioning') {
         $origUrl = $harmoni->history->getReturnURL('view_history_' . SiteDispatcher::getCurrentNodeId());
         $module = $harmoni->request->getModuleFromUrl($origUrl);
         if ($module == false) {
             $module = 'ui1';
         }
         $action = $harmoni->request->getActionFromUrl($origUrl);
         if ($action == false) {
             $action = 'view';
         }
     } else {
         $module = $harmoni->request->getRequestedModule();
         $action = $harmoni->request->getRequestedAction();
     }
     return SiteDispatcher::quickURL($module, $action, array("node" => $id));
 }
Example #24
0
 /**
  * Answer the site component for a given Id string
  * 
  * @param string $id
  * @return object SiteComponent
  * @access protected
  * @since 6/4/07
  */
 protected function getSiteComponentForIdString($id)
 {
     $director = SiteDispatcher::getSiteDirector();
     return $director->getSiteComponentById(strval($id));
 }
Example #25
0
 /**
  * Visit a Fixed Organizer
  * 
  * @param object FixedOrganizerSiteComponent $siteComponent
  * @return mixed
  * @access public
  * @since 8/31/07
  */
 public function visitFixedOrganizer(FixedOrganizerSiteComponent $siteComponent)
 {
     $numCells = $siteComponent->getTotalNumberOfCells();
     $rootSiteComponent = SiteDispatcher::getCurrentRootNode();
     $isHeaderFooterVisitor = new IsHeaderFooterSiteVisitor();
     for ($i = 0; $i < $numCells; $i++) {
         $child = $siteComponent->getSubcomponentForCell($i);
         if (is_object($child)) {
             // don't include in feed if header and footer blocks
             if (!$child->acceptVisitor($isHeaderFooterVisitor)) {
                 $child->acceptVisitor($this);
             }
         }
     }
 }
Example #26
0
 /**
  * Answer the url to return to
  * 
  * @return string
  * @access public
  * @since 5/19/08
  */
 function getReturnUrl()
 {
     if (isset($this->createdCopy) && $this->createdCopy) {
         $harmoni = Harmoni::instance();
         return SiteDispatcher::quickURL('ui1', 'theme_options', array('wizardSkipToStep' => "advanced"));
     } else {
         return parent::getReturnUrl();
     }
 }
 /**
  * Answer the markup for a set of search results
  * 
  * @param string $fieldName
  * @param array $results An array of WSearchResult objects
  * @return string
  * @access public
  * @since 11/27/07
  */
 public function getResultsMarkup($fieldName, $results)
 {
     $harmoni = Harmoni::instance();
     if (count($results)) {
         print "\n\t<table id='" . RequestContext::name($fieldName) . "_output' class='search_results' cellspacing='0'>";
         $colorKey = 0;
         foreach ($results as $result) {
             print "\n\t\t<tr class='search_result_item '>";
             print "\n\t\t\t<td class='color" . $colorKey . "'>";
             print $result->getMarkup();
             print "\n\t\t\t</td>";
             print "\n\t\t\t<td class='action_button color" . $colorKey . "'>";
             $url = $harmoni->request->quickURL('roles', 'modify', array('node' => SiteDispatcher::getCurrentNodeId(), 'agent' => $result->getIdString()));
             print "\n\t\t\t<button onclick='window.location = \"{$url}\".urlDecodeAmpersands(); return false;'>" . _("Modify Roles &raquo;") . "</button>";
             print "\n\t\t\t</td>";
             print "\n\t\t</tr>";
             $colorKey = intval(!$colorKey);
         }
         print "\n\t</table>";
     }
 }
 /**
  * Answer the message body for a user.
  * 
  * @param array $user
  * @return string
  */
 protected function getEmailBody(array $user)
 {
     if (!defined('MIGRATION_REMINDER_EMAIL_MESSAGE')) {
         throw new ConfigurationErrorException('MIGRATION_REMINDER_EMAIL_MESSAGE must be defined.');
     }
     ob_start();
     print "\n\t<ul>";
     foreach ($user['slots'] as $slot) {
         $viewUrl = rtrim(SiteDispatcher::getBaseUrlForSlot($slot), '/') . '/sites/' . $slot->getShortname();
         print "\n\t\t<li>";
         print "<a href=\"" . $viewUrl . "\">" . $viewUrl . "</a>";
         print "</li>";
     }
     print "\n\t</ul>";
     $message = str_replace('[[USER]]', $user['name'], MIGRATION_REMINDER_EMAIL_MESSAGE);
     $message = str_replace('[[SITE_LIST]]', ob_get_clean(), $message);
     return $message;
 }
Example #29
0
 /**
  * Answer an array of RSS link info.
  * 
  * @param  object SiteComponent $siteComponent
  * @return array
  * @access private
  * @since 3/11/08
  * @static
  */
 private static function getLinks(SiteComponent $siteComponent)
 {
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace(null);
     $links = array();
     // Content RSS
     $links[] = array('url' => SiteDispatcher::quickUrl("rss", "content", array('node' => $siteComponent->getId())), 'label' => _('Content RSS'), 'title' => _("Content RSS for") . " " . htmlentities(strip_tags($siteComponent->getDisplayName())));
     // Comments RSS
     $links[] = array('url' => SiteDispatcher::quickUrl("rss", "comments", array('node' => $siteComponent->getId())), 'label' => _('Discussion RSS'), 'title' => _("Discussion RSS for") . " " . htmlentities(strip_tags($siteComponent->getDisplayName())));
     $harmoni->request->endNamespace();
     return $links;
 }
 /**
  * Return the browser to the page from whence they came
  * 
  * @return void
  * @access public
  * @since 10/16/06
  */
 function returnToCallerPage()
 {
     $harmoni = Harmoni::instance();
     if (!($returnAction = RequestContext::value('returnAction'))) {
         $returnAction = 'editview';
     }
     if (isset($this->newIdToSendTo)) {
         $node = $this->newIdToSendTo;
     } else {
         $node = RequestContext::value('returnNode');
     }
     RequestContext::locationHeader(SiteDispatcher::quickURL($harmoni->request->getRequestedModule(), $returnAction, array("node" => $node)));
 }