CampURI::__construct PHP Method

__construct() public method

Class constructor
public __construct ( string $p_uri = 'SELF' )
$p_uri string The full URI string
    public function __construct($p_uri = 'SELF')
    {
        $this->m_config = CampConfig::singleton();
        if (isset($p_uri) && $p_uri != 'SELF') {
            $uriString = $p_uri;
        } else {
            // ... otherwise we build the uri from the server itself.
            //
            // checks whether the site is being queried through SSL
            if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') {
                $scheme = 'https://';
            } else {
                $scheme = 'http://';
            }
            // this works at least for apache, some research is needed
            // in order to support other web servers.
            if (!empty($_SERVER['PHP_SELF'])) {
                $uriString = $scheme . $_SERVER['HTTP_HOST'];
            }
            if (isset($_SERVER['REQUEST_URI'])) {
                $uriString .= $_SERVER['REQUEST_URI'];
            }
            // some cleaning directives
            $uriString = urldecode($uriString);
            $uriString = str_replace('"', '"', $uriString);
            $uriString = str_replace('<', '&lt;', $uriString);
            $uriString = str_replace('>', '&gt;', $uriString);
            $uriString = preg_replace('/eval\\((.*)\\)/', '', $uriString);
            $uriString = preg_replace('/[\\\\"\\\'][\\s]*javascript:(.*)[\\\\"\\\']/', '""', $uriString);
        }
        $this->parse($uriString);
        $this->m_queryArray = array_merge($this->m_queryArray, CampRequest::GetInput('POST'));
        $this->readUser();
    }

Usage Example

 /**
  * Class constructor
  *
  * @param string $p_uri
  *                      The full URI string
  */
 public function __construct($p_uri = null)
 {
     parent::__construct($p_uri);
     try {
         $this->setURLType(URLTYPE_SHORT_NAMES);
         // HUGE TODO: rewrite this - remove globals controller usage!
         if (array_key_exists('controller', $GLOBALS)) {
             if (is_object($GLOBALS['controller'])) {
                 $this->setURL($GLOBALS['controller']->getRequest());
             } else {
                 $this->setURLFromSymfony(Zend_Registry::get('container')->getService('request'));
             }
         } else {
             $this->setURL(new Zend_Controller_Request_Http());
         }
         $this->m_validURI = true;
         $this->validateCache(false);
     } catch (Exception $e) {
         $this->m_validURI = false;
         $this->m_errorCode = $e->getCode();
         if (!is_null($this->m_publication)) {
             $tplId = CampSystem::GetInvalidURLTemplate($this->m_publication->identifier, null, null, !$this->m_preview);
             $themePath = $this->getThemePath();
             $tplId = substr($tplId, strlen($themePath));
             $template = new MetaTemplate($tplId, $themePath);
             if ($template->defined()) {
                 $this->m_template = $template;
             }
             CampTemplate::singleton()->config_dir = APPLICATION_PATH . '/../themes/' . $themePath . '_conf';
         }
         CampTemplate::singleton()->trigger_error($e->getMessage());
     }
 }
All Usage Examples Of CampURI::__construct