Ejemplo n.º 1
0
 protected function _complementFileData(array $data, $fileId)
 {
     if ($data[$fileId . 'Name']) {
         /*
         $args = array(
         	Sitengine_Env::PARAM_CONTROLLER => 'attachments',
         	Sitengine_Env::PARAM_FILE => $fileId,
         	Sitengine_Env::PARAM_ID => $data['id']
         );
         $uri  = $this->_newsletterPackage->getDownloadHandler();
         $uri .= Sitengine_Controller_Request_Http::makeNameValueQuery($args);
         */
         /*
         $uri  = $this->_newsletterPackage->getAttachmentFile1OriginalRequestDir();
         $uri .= '/'.$data[$fileId.'Name'];
         */
         #$config = $this->_newsletterPackage->getEnv()->getAmazonConfig('default');
         $key = $this->_configs[$fileId]['prefix'] . '/' . $data[$fileId . 'Name'];
         $uri = Sitengine_Amazon_S3::getUrl($this->_configs[$fileId]['bucket'], $key, '', $this->_configs[$fileId]['cname'], $this->_configs[$fileId]['ssl']);
         require_once 'Sitengine/Mime/Type.php';
         $data[$fileId . 'Path'] = $uri;
         $data[$fileId . 'Uri'] = $uri;
         $data[$fileId . 'IsImage'] = Sitengine_Mime_Type::isImage($data[$fileId . 'Mime']);
         $data[$fileId . 'IsFlash'] = Sitengine_Mime_Type::isFlash($data[$fileId . 'Mime']);
         $data[$fileId . 'SizeKb'] = round($data[$fileId . 'Size'] / 1024);
         if ($data[$fileId . 'IsImage']) {
             $attr = array('src' => $uri, 'width' => $data[$fileId . 'Width'], 'height' => $data[$fileId . 'Height'], 'border' => 0);
             $data[$fileId . 'Tag'] = '<img ';
             foreach ($attr as $k => $v) {
                 $data[$fileId . 'Tag'] .= ' ' . $k . '="' . $v . '"';
             }
             $data[$fileId . 'Tag'] .= ' />';
         }
     }
     return $data;
 }
Ejemplo n.º 2
0
 public function logging($logging = '')
 {
     try {
         require_once 'Sitengine/Amazon/S3/Header.php';
         $header = new Sitengine_Amazon_S3_Header();
         require_once 'Sitengine/Amazon/S3/Authentication.php';
         $authentication = new Sitengine_Amazon_S3_Authentication($this->_connection);
         $verb = $logging ? 'PUT' : 'GET';
         $date = gmdate(Sitengine_Amazon_S3::DATE_FORMAT);
         $md5 = '';
         $mime = '';
         $key = '';
         $query = 'logging';
         $authHeader = $authentication->generateSignature($verb, $md5, $mime, $date, '', '/' . $this->_name . '/?logging');
         $header->setType($verb)->setUrl(Sitengine_Amazon_S3::getUrl($this->_name, $key, $query, $this->_cname, $this->_ssl))->add('Authorization: ' . $authHeader)->add('Date: ' . $date);
         $client = Sitengine_Amazon_S3::getClient($header, $logging);
         $response = $client->request($verb);
         #Sitengine_Debug::print_r($client->getLastRequest());
         require_once 'Sitengine/Amazon/S3/Bucket/Response/Logging.php';
         return new Sitengine_Amazon_S3_Bucket_Response_Logging($client);
     } catch (Exception $exception) {
         require_once 'Sitengine/Amazon/S3/Exception.php';
         throw new Sitengine_Amazon_S3_Exception('head object error', $exception);
     }
 }
Ejemplo n.º 3
0
 public function acl($acl = '')
 {
     try {
         require_once 'Sitengine/Amazon/S3/Header.php';
         $header = new Sitengine_Amazon_S3_Header();
         require_once 'Sitengine/Amazon/S3/Authentication.php';
         $authentication = new Sitengine_Amazon_S3_Authentication($this->_connection);
         $verb = $acl ? 'PUT' : 'GET';
         $date = gmdate(Sitengine_Amazon_S3::DATE_FORMAT);
         $md5 = '';
         $mime = '';
         $query = 'acl';
         $authHeader = $authentication->generateSignature($verb, $md5, $mime, $date, '', '/' . $this->_bucketName . '/' . $this->_key . '?' . $query);
         $header->setType($verb)->setUrl(Sitengine_Amazon_S3::getUrl($this->_bucketName, $this->_key, $query, $this->_cname, $this->_ssl))->add('Authorization: ' . $authHeader)->add('Date: ' . $date);
         $client = Sitengine_Amazon_S3::getClient($header, $acl);
         $response = $client->request($verb);
         require_once 'Sitengine/Amazon/S3/Object/Response/Acl.php';
         return new Sitengine_Amazon_S3_Object_Response_Acl($client);
     } catch (Exception $exception) {
         require_once 'Sitengine/Amazon/S3/Exception.php';
         throw new Sitengine_Amazon_S3_Exception('head object error', $exception);
     }
 }
Ejemplo n.º 4
0
 public function complementRow(Sitengine_Blog_Files_Row $row)
 {
     $data = $row->toArray();
     $transcripts = $this->getTranscripts();
     $transcripts->setLanguage($this->_transcript);
     $index = $transcripts->getIndex();
     $default = $transcripts->getDefaultIndex();
     $data['title'] = $data['titleLang' . $index] ? $data['titleLang' . $index] : $data['titleLang' . $default];
     $data['markup'] = $data['markupLang' . $index] ? $data['markupLang' . $index] : $data['markupLang' . $default];
     $data['transcriptMissing'] = !$data['titleLang' . $index];
     require_once 'Sitengine/Amazon/S3.php';
     if ($data[self::FILE1ORIGINAL_ID . 'Name']) {
         /*
         $args = array(
         	Sitengine_Env::PARAM_CONTROLLER => 'files',
         	Sitengine_Env::PARAM_ID => $data['id']
         );
         $uri  = $this->_blogPackage->getDownloadHandler();
         $uri .= Sitengine_Controller_Request_Http::makeNameValueQuery($args);
         */
         #$config = $this->_blogPackage->getEnv()->getAmazonConfig('default');
         $key = $this->_configs[self::FILE1ORIGINAL_ID]['prefix'] . '/' . $data[self::FILE1ORIGINAL_ID . 'Name'];
         $uri = Sitengine_Amazon_S3::getUrl($this->_configs[self::FILE1ORIGINAL_ID]['bucket'], $key, '', $this->_configs[self::FILE1ORIGINAL_ID]['cname'], $this->_configs[self::FILE1ORIGINAL_ID]['ssl']);
         require_once 'Sitengine/Mime/Type.php';
         #$data[self::FILE1ORIGINAL_ID.'Path'] = $this->_blogPackage->getFileFile1OriginalDir().'/'.$data[self::FILE1ORIGINAL_ID.'Name'];
         $data[self::FILE1ORIGINAL_ID . 'Path'] = $uri;
         $data[self::FILE1ORIGINAL_ID . 'Uri'] = $uri;
         $data[self::FILE1ORIGINAL_ID . 'IsImage'] = Sitengine_Mime_Type::isImage($data[self::FILE1ORIGINAL_ID . 'Mime']);
         $data[self::FILE1ORIGINAL_ID . 'IsFlash'] = Sitengine_Mime_Type::isFlash($data[self::FILE1ORIGINAL_ID . 'Mime']);
         $data[self::FILE1ORIGINAL_ID . 'SizeKb'] = round($data[self::FILE1ORIGINAL_ID . 'Size'] / 1024);
         if ($data[self::FILE1ORIGINAL_ID . 'IsImage']) {
             $attr = array('src' => $uri, 'width' => $data[self::FILE1ORIGINAL_ID . 'Width'], 'height' => $data[self::FILE1ORIGINAL_ID . 'Height'], 'border' => 0);
             $data[self::FILE1ORIGINAL_ID . 'Tag'] = '<img ';
             foreach ($attr as $k => $v) {
                 $data[self::FILE1ORIGINAL_ID . 'Tag'] .= ' ' . $k . '="' . $v . '"';
             }
             $data[self::FILE1ORIGINAL_ID . 'Tag'] .= ' />';
         }
     }
     if ($data[self::FILE1THUMBNAIL_ID . 'Name']) {
         /*
         $args = array(
         	Sitengine_Env::PARAM_CONTROLLER => 'files',
         	Sitengine_Env::PARAM_FILE => 'thumb',
         	Sitengine_Env::PARAM_ID => $data['id']
         );
         $uri  = $this->_blogPackage->getDownloadHandler();
         $uri .= Sitengine_Controller_Request_Http::makeNameValueQuery($args);
         */
         $key = $this->_configs[self::FILE1THUMBNAIL_ID]['prefix'] . '/' . $data[self::FILE1THUMBNAIL_ID . 'Name'];
         $uri = Sitengine_Amazon_S3::getUrl($this->_configs[self::FILE1THUMBNAIL_ID]['bucket'], $key, '', $this->_configs[self::FILE1THUMBNAIL_ID]['cname'], $this->_configs[self::FILE1THUMBNAIL_ID]['ssl']);
         require_once 'Sitengine/Mime/Type.php';
         #$data[self::FILE1THUMBNAIL_ID.'Path'] = $this->_blogPackage->getFileFile1ThumbnailDir().'/'.$data[self::FILE1THUMBNAIL_ID.'Name'];
         $data[self::FILE1THUMBNAIL_ID . 'Path'] = $uri;
         $data[self::FILE1THUMBNAIL_ID . 'Uri'] = $uri;
         $data[self::FILE1THUMBNAIL_ID . 'IsImage'] = Sitengine_Mime_Type::isImage($data[self::FILE1THUMBNAIL_ID . 'Mime']);
         $data[self::FILE1THUMBNAIL_ID . 'IsFlash'] = Sitengine_Mime_Type::isFlash($data[self::FILE1THUMBNAIL_ID . 'Mime']);
         $data[self::FILE1THUMBNAIL_ID . 'SizeKb'] = round($data[self::FILE1THUMBNAIL_ID . 'Size'] / 1024);
         if ($data[self::FILE1THUMBNAIL_ID . 'IsImage']) {
             $attr = array('src' => $uri, 'width' => $data[self::FILE1THUMBNAIL_ID . 'Width'], 'height' => $data[self::FILE1THUMBNAIL_ID . 'Height'], 'border' => 0);
             $data[self::FILE1THUMBNAIL_ID . 'Tag'] = '<img ';
             foreach ($attr as $k => $v) {
                 $data[self::FILE1THUMBNAIL_ID . 'Tag'] .= ' ' . $k . '="' . $v . '"';
             }
             $data[self::FILE1THUMBNAIL_ID . 'Tag'] .= ' />';
         }
     }
     return $data;
 }