Esempio n. 1
0
 public function httpGetForHtml()
 {
     $response = parent::httpGetForHtml();
     $openIdMode = $this->getRequest()->getParameter('openid_mode');
     if ($openIdMode) {
         switch ($openIdMode) {
             case 'cancel':
                 // Identification by means of OpenID failed.
                 throw new NotAuthenticatedException('OpenID athentication failed.');
             case 'id_res':
                 // The identity provider has validated the user, so it can
                 // be set as current (as long as it's authorised).
                 try {
                     $user = Users::getFromIdentityProvider(new GoogleIdentityProvider());
                     Users::setCurrent($user);
                     // Redirect users to either the URL they originally
                     // requested, or to the index if the former is not
                     // available.
                     $response = new Redirection($this->getRequest());
                     $response->setNextUrl(Application::getCurrent()->popLastLocator() ?: '/');
                 } catch (NotAuthenticatedException $exception) {
                     // The current OpenID data is not valid. Request again.
                     $response = $this->getRequestIdentificationResponse();
                 }
                 break;
             default:
                 throw new NotAuthenticatedException('Unsupported OpenID mode.');
         }
     } else {
         // No OpenID response is present, so just ask for identity.
         $response = $this->getRequestIdentificationResponse();
     }
     return $response;
 }
Esempio n. 2
0
File: Logger.php Progetto: eix/core
 /**
  * Commits a message to application's log.
  */
 private function log($message, $level)
 {
     // Only log if the logger is enabled.
     if (!$this->isEnabled) {
         return;
     }
     if ($level <= $this->level) {
         $requestId = null;
         try {
             $requestID = Application::getCurrent()->getRequestId();
         } catch (CoreException $exception) {
             $requestID = '---';
         }
         $logMessage = sprintf('%s: %s [%s] %s' . PHP_EOL, $this->id, $requestId ?: '———', @self::$levelNames[$level], $message);
         // Commit the log message.
         if (empty($this->errorLogFile)) {
             // If no log file is specified, use the default PHP location.
             error_log($logMessage);
         } else {
             // Silence the eventual error if the message cannot be written
             // to the log, so that it doesn't interrupt the program.
             @file_put_contents($this->errorLogFile, $logMessage, FILE_APPEND);
         }
     }
 }
Esempio n. 3
0
 /**
  * Creates a data source.
  *
  * @param string $collectionName the collection or group of objects the
  * images are part of.
  * @param \Eix\Core\Settings $settings the data source configuration. Of special
  * consideration is the
  */
 protected function __construct($collectionName, $settings = null)
 {
     if ($settings == null) {
         $settings = Application::getCurrent()->getSettings()->data->sources->imageStore;
     }
     $this->baseLocation = $settings->locations->{$collectionName};
     // Set the collection.
     $this->collection = $collectionName;
 }
Esempio n. 4
0
File: Html.php Progetto: eix/core
 public function __construct(HttpRequest $request = null)
 {
     $this->setContentType(self::CONTENT_TYPE);
     parent::__construct($request);
     // Set the initial title.
     try {
         $this->titleParts = array(Application::getCurrent()->getName());
     } catch (Exception $exception) {
         $this->titleParts = '';
     }
 }
Esempio n. 5
0
File: MongoDB.php Progetto: eix/core
 /**
  * Creates a data source based off a MongoDB database.
  *
  * @param string                   $collectionName the MongoDB collection name.
  * @param \Eix\Core\Settings $settings       the data source configuration.
  */
 protected function __construct($collectionName, $settings = null)
 {
     if ($settings == null) {
         $settings = Application::getCurrent()->getSettings()->data->sources->mongodb;
     }
     // Get a Mongo instance.
     $mongo = self::getConnector($settings);
     // Select the database.
     $database = $mongo->selectDB($settings->databaseName);
     // Select the collection.
     $this->collection = $database->selectCollection($collectionName);
 }
Esempio n. 6
0
File: XslPage.php Progetto: eix/core
 /**
  *
  * @param  type           $templateId
  * @param  type           $data
  * @throws MediaException
  */
 public function __construct($templateId, $data)
 {
     if (empty($templateId)) {
         throw new MediaException('No template has been specified.');
     }
     $this->templateId = $templateId;
     $this->data = $data;
     // An XML document is created to hold data.
     $this->dataDocument = new Library\Dom(Application::getCurrent()->getSettings()->resources->templates->response);
     if (empty(self::$pagesLocation)) {
         self::$pagesLocation = Application::getSettings()->resources->pages->location;
     }
     if (empty(self::$locale)) {
         self::$locale = Application::getCurrent()->getLocale();
     }
 }