Example #1
0
 /**
  * This class implements the Singleton pattern. There is only ever
  * one instance of the this class and it is accessed only via the 
  * ClassName::instance() method.
  * 
  * @return object 
  * @access public
  * @since 5/26/05
  * @static
  */
 public static function instance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new Segue_AccessLog();
     }
     return self::$instance;
 }
 /**
  * Answer an array of the slots in this category.
  * 
  * @return array of Slot objects
  * @access public
  * @since 4/1/08
  */
 public function getSlots()
 {
     $slots = array();
     $slotMgr = SlotManager::instance();
     foreach (Segue_AccessLog::instance()->getRecentSlots() as $shortname) {
         try {
             $slots[] = $slotMgr->getSlotByShortname($shortname);
         } catch (UnknownIdException $e) {
         }
     }
     return $slots;
 }
Example #3
0
 /**
  * Execute the Action
  * 
  * @param object Harmoni $harmoni
  * @return mixed
  * @access public
  */
 function execute()
 {
     $harmoni = Harmoni::instance();
     /*********************************************************
      * Split sites based on their location-category
      *********************************************************/
     $rootSiteComponent = SiteDispatcher::getCurrentRootNode();
     try {
         $slot = $rootSiteComponent->getSlot();
         // 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
     //
     $this->mainScreen = new Container(new YLayout(), BLOCK, BACKGROUND_BLOCK);
     $this->addHead($this->mainScreen);
     CommentManager::instance()->disableCommenting();
     CommentManager::instance()->disableSorting();
     $this->addSiteContent($this->mainScreen);
     return $this->mainScreen;
 }
Example #4
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;
 }