/**
  * 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 Segue1UrlResolver();
     }
     return self::$instance;
 }
Exemple #2
0
 /**
  * Execute
  * 
  * @return mixed
  * @access public
  * @since 4/3/08
  */
 public function execute()
 {
     // Add in RequestContext data from URLs that were converted to Segue2 format,
     // but retain Segue1 parameters
     $get = array('action' => 'site');
     $segue1Identifiers = array('site', 'section', 'page', 'story');
     foreach ($segue1Identifiers as $key) {
         if (!isset($get[$key]) && RequestContext::value($key)) {
             $get[$key] = RequestContext::value($key);
         }
     }
     $resolver = Segue1UrlResolver::instance();
     $resolver->resolveGetArray($get);
     // If the resolver didn't forward us, try just going to the site listed.
     if (isset($get['site'])) {
         RequestContext::sendTo(MYURL . "/sites/" . $get['site']);
     } else {
         throw new NullArgumentException("Could no resolve URL, no site specified.");
     }
 }
Exemple #3
0
        /*********************************************************
         * Redirect for short form /sites/mysitename urls
         *********************************************************/
        if (isset($_SERVER['PATH_INFO']) && preg_match('/^\\/sites\\/([\\w_-]+)\\/?/', $_SERVER['PATH_INFO'], $matches)) {
            $harmoni->request->setRequestParam('site', $matches[1]);
            $harmoni->request->setModuleAction('view', 'html');
        }
        $harmoni->execute();
    } catch (UnknownActionException $e) {
        // If we are passed a Segue1-style URL, forward to an appropriate place.
        Segue1UrlResolver::forwardCurrentIfNeeded();
        // If we were not forwarded, re-throw
        throw $e;
    } catch (UnknownIdException $e) {
        // If we are passed a Segue1-style URL, forward to an appropriate place.
        Segue1UrlResolver::forwardCurrentIfNeeded();
        // If we were not forwarded, re-throw
        throw $e;
    }
    // Handle certain types of uncaught exceptions specially. In particular,
    // Send back HTTP Headers indicating that an error has ocurred to help prevent
    // crawlers from continuing to pound invalid urls.
} catch (UnknownActionException $e) {
    SegueErrorPrinter::handleException($e, 404);
} catch (NullArgumentException $e) {
    SegueErrorPrinter::handleException($e, 400);
} catch (PermissionDeniedException $e) {
    SegueErrorPrinter::handleException($e, 403);
} catch (UnknownIdException $e) {
    SegueErrorPrinter::handleException($e, 404);
} catch (Exception $e) {