/**
  * 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();
 }
 /**
  * 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;
 }
 /**
  * Answer the URL of this plugin
  * 
  * @return string
  * @access protected
  * @since 2/19/09
  */
 protected function getManageUrl()
 {
     return SiteDispatcher::quickUrl('view', 'html', array('node' => $this->getId()));
 }
 /**
  * Add a link for a node
  * 
  * @param object SiteComponent $node
  * @return void
  * @access public
  * @since 5/31/07
  */
 function addLink($node)
 {
     $this->_links[] = "<a href='" . SiteDispatcher::quickUrl("participation", "actions", array('node' => $node->getId())) . "'>" . $node->getDisplayName() . "</a>";
 }
Example #5
0
 /**
  * Execute the Action
  * 
  * @param object Harmoni $harmoni
  * @return mixed
  * @access public
  * @since 4/3/06
  */
 function execute()
 {
     $harmoni = Harmoni::instance();
     /*********************************************************
      * Split sites based on their location-category
      *********************************************************/
     try {
         $rootSiteComponent = SiteDispatcher::getCurrentRootNode();
     } catch (UnknownIdException $e) {
         // For non-existant node exceptions, redirect to the site root.
         if ($e->getCode() == 289743 && RequestContext::value('node') && RequestContext::value('site')) {
             $url = SiteDispatcher::quickURL($harmoni->request->getRequestedModule(), $harmoni->request->getRequestedAction(), array('site' => RequestContext::value('site')));
             $errorPrinter = SegueErrorPrinter::instance();
             $message = "<strong>" . _("The node you requested does not exist or has been deleted. Click %1 to go to the %2.") . "</strong>";
             $message = str_replace('%1', "<a href='" . $url . "'>" . _("here") . "</a>", $message);
             $message = str_replace('%2', "<a href='" . $url . "'>" . _("main page of the site") . "</a>", $message);
             $errorPrinter->handExceptionWithRedirect($e, 404, $message);
             exit;
         } else {
             if (RequestContext::value('site')) {
                 $slotMgr = SlotManager::instance();
                 $slot = $slotMgr->getSlotByShortname(RequestContext::value('site'));
                 // Redirect to the new URL if this site has been migrated
                 if ($redirectUrl = $slot->getMigratedRedirectUrl()) {
                     header("HTTP/1.1 301 Moved Permanently");
                     header('Location: ' . $redirectUrl);
                     exit;
                 }
                 throw $e;
             } else {
                 throw $e;
             }
         }
     }
     try {
         $slot = $rootSiteComponent->getSlot();
         // Redirect to the new URL if this site has been migrated
         if ($redirectUrl = $slot->getMigratedRedirectUrl()) {
             header("HTTP/1.1 301 Moved Permanently");
             header('Location: ' . $redirectUrl);
             exit;
         }
         if (SiteDispatcher::getBaseUrlForSlot($slot) != MYURL) {
             RequestContext::sendTo(SiteDispatcher::quickUrl());
         } else {
             /*********************************************************
              * Ensure that the requested node is a member of the site
              * listed in the URL.
              *********************************************************/
             if (!RequestContext::value('site') || RequestContext::value('site') != $slot->getShortname()) {
                 /*********************************************************
                  * This is added in Segue 2.1.0 for testing that all 
                  * Segue-generated links are producing the correct URLs.
                  * This should be removed here and in
                  *		segue/config/debug_default.conf.php
                  * after testing is complete.
                  *********************************************************/
                 if (defined('DEBUG_LOG_WRONG_SITE') && DEBUG_LOG_WRONG_SITE == true && isset($_SERVER['HTTP_REFERER']) && preg_match('#^' . str_replace('.', '\\.', MYURL) . '#', $_SERVER['HTTP_REFERER'])) {
                     HarmoniErrorHandler::logException(new WrongSiteException("Expecting site '" . $slot->getShortname() . "', saw '" . RequestContext::value('site') . "' in the url. Links to wrong sites should not be generated by Segue. If the link on the referrer page was written by Segue (and not a user), submit a bug report. Sending to " . SiteDispatcher::quickUrl()));
                 }
                 RequestContext::sendTo(SiteDispatcher::quickUrl());
             }
         }
         // Mark the site as viewed
         Segue_AccessLog::instance()->touch($slot->getShortname());
     } catch (UnknownIdException $e) {
         // No slot for the site....
     }
     $authZ = Services::getService("AuthZ");
     $recordManager = Services::getService("RecordManager");
     //
     // Begin Optimizations
     //
     // The code below queues up authorizations for all visible nodes,
     // as well as pre-fetches all of the RecordSets that have data
     // specific to the visible nodes.
     $visibleComponents = SiteDispatcher::getSiteDirector()->getVisibleComponents(SiteDispatcher::getCurrentNodeId());
     $preCacheIds = array();
     foreach ($visibleComponents as $component) {
         $id = $component->getQualifierId();
         $authZ->getIsAuthorizedCache()->queueId($id);
         $preCacheIds[] = $id->getIdString();
     }
     $recordManager->preCacheRecordsFromRecordSetIDs($preCacheIds);
     //
     // End Optimizations
     //
     $mainScreen = new Container(new YLayout(), BLOCK, BACKGROUND_BLOCK);
     $allWrapper = $this->addHeaderControls($mainScreen);
     $this->addSiteContent($mainScreen);
     $this->addFooterControls($allWrapper);
     if (defined('SEGUE_SITE_FOOTER')) {
         $allWrapper->add(new UnstyledBlock(SEGUE_SITE_FOOTER), "100%", null, CENTER, BOTTOM);
     }
     $this->mainScreen = $mainScreen;
     return $allWrapper;
 }