Ejemplo n.º 1
0
 /**
  * Check amazon S3 settings 
  * 
  * @return void
  */
 protected function checkAmazonS3Settings()
 {
     $config = \XLite\Core\Config::getInstance()->CDev->AmazonS3Images;
     if (!function_exists('curl_init')) {
         \XLite\Core\TopMessage::addError('This module uses PHP\'s cURL functions which are disabled on your web server');
     } elseif ($config->access_key && $config->secret_key && !\XLite\Module\CDev\AmazonS3Images\Core\S3::getInstance()->isValid()) {
         \XLite\Core\TopMessage::addWarning('Connection to Amazon S3 failed.' . ' Check whether the AWS Access key и AWS Secret key specified in the module settings are correct.');
     }
 }
Ejemplo n.º 2
0
 /**
  * Get S3 client
  * 
  * @return \XLite\Module\CDev\AmazonS3Images\Core\S3
  */
 protected function getS3()
 {
     if (!isset($this->s3)) {
         $this->s3 = \XLite\Module\CDev\AmazonS3Images\Core\S3::getInstance();
         if (!$this->s3->isValid()) {
             $this->s3 = false;
         }
     }
     return $this->s3;
 }
Ejemplo n.º 3
0
 /**
  * Check if field is valid and (if needed) set an error message
  *
  * @param array  $data    Current section data
  * @param string $section Current section name
  *
  * @return void
  */
 protected function validateFields(array $data, $section)
 {
     parent::validateFields($data, $section);
     if ('default' == $section && \XLite::getController() instanceof \XLite\Controller\Admin\Module && 'CDev\\AmazonS3Images' == $this->getModule()->getActualName() && !$this->errorMessages) {
         $vars = array();
         foreach ($data[self::SECTION_PARAM_FIELDS] as $field) {
             $vars[$field->getName()] = $field->getValue();
         }
         $client = \XLite\Module\CDev\AmazonS3Images\Core\S3::getInstance();
         if (!empty($vars['access_key']) && !empty($vars['secret_key']) && !empty($vars['bucket']) && !$client->checkSettings($vars['access_key'], $vars['secret_key'], $vars['bucket'])) {
             $this->addErrorMessage('access_key', 'Connection to Amazon S3 failed.' . ' Check whether the AWS Access key и AWS Secret key specified in the module settings are correct.', $data);
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * Check if widget is visible
  *
  * @return boolean
  */
 protected function isVisible()
 {
     return parent::isVisible() && 'CDev\\AmazonS3Images' == $this->getModule()->getActualName() && \XLite\Module\CDev\AmazonS3Images\Core\S3::getInstance()->isValid();
 }
Ejemplo n.º 5
0
 /**
  * Check step valid state
  *
  * @return boolean
  */
 protected function isStepValid()
 {
     return parent::isStepValid() && \XLite\Module\CDev\AmazonS3Images\Core\S3::getInstance()->isValid();
 }