diff --git a/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Cms/Wysiwyg/Images/Content/Uploader.php b/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Cms/Wysiwyg/Images/Content/Uploader.php index 0c163d1..89eab5b 100644 --- a/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Cms/Wysiwyg/Images/Content/Uploader.php +++ b/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Cms/Wysiwyg/Images/Content/Uploader.php @@ -38,7 +38,8 @@ protected function _prepareLayout() $this->setChild( 'cloudinary_ml_button', $this->getLayout()->createBlock('adminhtml/widget_button') - ->addData(array( + ->addData( + array( // Workaround for IE9 'before_html' => sprintf( '
', @@ -53,7 +54,8 @@ protected function _prepareLayout() 'id' => $this->getElementId(self::DEFAULT_CLD_ML_BUTTON_ID_SUFFIX . '_button'), 'label' => Mage::helper('uploader')->__('Add From Cloudinary...'), 'type' => 'button', - )) + ) + ) ); } @@ -82,7 +84,9 @@ public function getCloudinaryMediaLibraryWidgetOptions($multiple = true, $refres if (!($cloudinaryMLoptions = Mage::helper('cloudinary_cloudinary/MediaLibraryHelper')->getCloudinaryMLOptions($multiple, $refresh))) { return null; } - return Mage::helper('core')->jsonEncode(array( + + return Mage::helper('core')->jsonEncode( + array( 'htmlId' => $this->getHtmlId(), 'cldMLid' => self::DEFAULT_CLD_ML_BUTTON_ID_SUFFIX . '_' . $this->getHtmlId(), 'imageUploaderUrl' => $this->getCldImageUploaderUrl(), @@ -95,7 +99,8 @@ public function getCloudinaryMediaLibraryWidgetOptions($multiple = true, $refres 'addTmpExtension' => $this->getAddTmpExtension(), 'cloudinaryMLoptions' => $cloudinaryMLoptions, 'cloudinaryMLshowOptions' => Mage::helper('cloudinary_cloudinary/MediaLibraryHelper')->getCloudinaryMLshowOptions('image'), - )); + ) + ); } /** diff --git a/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Manage.php b/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Manage.php index 9b5f586..915d4cc 100644 --- a/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Manage.php +++ b/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Manage.php @@ -85,6 +85,7 @@ public function getMigrationInfo() if (!$this->hasData('migration_info')) { $this->setData('migration_info', new Varien_Object($this->_migrationTask->getInfo())); } + return $this->getData('migration_info'); } @@ -99,12 +100,14 @@ public function getMigrateButton() return $this->getLayout() ->createBlock('adminhtml/widget_button') - ->setData(array( + ->setData( + array( 'id' => 'cloudinary_migration_start_' . $type, 'label' => $this->helper('adminhtml')->__('Start Migration'), 'disabled' => $type === Cloudinary_Cloudinary_Model_Migration::UPLOAD_MIGRATION_TYPE && $this->allImagesSynced(), 'onclick' => 'openCloudinaryMigrationPopup(\''.$type.'\');' - )) + ) + ) ->toHtml(); } @@ -122,12 +125,14 @@ public function getClearErrorsButton() private function _makeButton($label, $action, $disabled = false) { $button = $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData(array( + ->setData( + array( 'id' => 'cloudinary_migration_start_' . $action, 'label' => $this->helper('adminhtml')->__($label), 'disabled' => $disabled, 'onclick' => "setLocation('{$this->getUrl(sprintf('*/cloudinary/%s/type/%s', $action, $this->getType()))}')" - )); + ) + ); return $button->toHtml(); } diff --git a/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Reset/Edit/Form.php b/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Reset/Edit/Form.php index 11349f5..24ed0f0 100644 --- a/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Reset/Edit/Form.php +++ b/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Reset/Edit/Form.php @@ -20,10 +20,12 @@ protected function _prepareForm() $fieldset = $form->addFieldset('display', array('class' => 'fieldset-wide')); - $fieldset->addField('password', 'password', array( + $fieldset->addField( + 'password', 'password', array( 'name' => 'password', 'label' => Mage::helper('cloudinary_cloudinary')->__('Enter your admin password to confirm reset') - )); + ) + ); return parent::_prepareForm(); } diff --git a/app/code/community/Cloudinary/Cloudinary/Block/Uploader/Multiple.php b/app/code/community/Cloudinary/Cloudinary/Block/Uploader/Multiple.php index 192d3f1..b925ca3 100644 --- a/app/code/community/Cloudinary/Cloudinary/Block/Uploader/Multiple.php +++ b/app/code/community/Cloudinary/Cloudinary/Block/Uploader/Multiple.php @@ -27,7 +27,8 @@ protected function _prepareLayout() $this->setChild( 'cloudinary_ml_button', $this->getLayout()->createBlock('adminhtml/widget_button') - ->addData(array( + ->addData( + array( // Workaround for IE9 'before_html' => sprintf( '
', @@ -42,7 +43,8 @@ protected function _prepareLayout() 'id' => $this->getElementId(self::DEFAULT_CLD_ML_BUTTON_ID_SUFFIX . '_button'), 'label' => Mage::helper('uploader')->__('Add From Cloudinary...'), 'type' => 'button', - )) + ) + ) ); } @@ -71,7 +73,9 @@ public function getCloudinaryMediaLibraryWidgetOptions($multiple = true, $refres if (!($cloudinaryMLoptions = Mage::helper('cloudinary_cloudinary/MediaLibraryHelper')->getCloudinaryMLOptions($multiple, $refresh))) { return null; } - return Mage::helper('core')->jsonEncode(array( + + return Mage::helper('core')->jsonEncode( + array( 'htmlId' => $this->getHtmlId(), 'cldMLid' => self::DEFAULT_CLD_ML_BUTTON_ID_SUFFIX . '_' . $this->getHtmlId(), 'imageUploaderUrl' => $this->getCldImageUploaderUrl(), @@ -84,7 +88,8 @@ public function getCloudinaryMediaLibraryWidgetOptions($multiple = true, $refres 'addTmpExtension' => $this->getAddTmpExtension(), 'cloudinaryMLoptions' => $cloudinaryMLoptions, 'cloudinaryMLshowOptions' => Mage::helper('cloudinary_cloudinary/MediaLibraryHelper')->getCloudinaryMLshowOptions('image'), - )); + ) + ); } /** diff --git a/app/code/community/Cloudinary/Cloudinary/Block/Uploader/Single.php b/app/code/community/Cloudinary/Cloudinary/Block/Uploader/Single.php index 6ad3fa8..fd215a1 100644 --- a/app/code/community/Cloudinary/Cloudinary/Block/Uploader/Single.php +++ b/app/code/community/Cloudinary/Cloudinary/Block/Uploader/Single.php @@ -27,7 +27,8 @@ protected function _prepareLayout() $this->setChild( 'cloudinary_ml_button', $this->getLayout()->createBlock('adminhtml/widget_button') - ->addData(array( + ->addData( + array( // Workaround for IE9 'before_html' => sprintf( '
', @@ -42,7 +43,8 @@ protected function _prepareLayout() 'id' => $this->getElementId(self::DEFAULT_CLD_ML_BUTTON_ID_SUFFIX . '_button'), 'label' => Mage::helper('uploader')->__('Add From Cloudinary...'), 'type' => 'button', - )) + ) + ) ); } @@ -71,7 +73,9 @@ public function getCloudinaryMediaLibraryWidgetOptions($multiple = false, $refre if (!($cloudinaryMLoptions = Mage::helper('cloudinary_cloudinary/MediaLibraryHelper')->getCloudinaryMLOptions($multiple, $refresh))) { return null; } - return Mage::helper('core')->jsonEncode(array( + + return Mage::helper('core')->jsonEncode( + array( 'htmlId' => $this->getHtmlId(), 'cldMLid' => self::DEFAULT_CLD_ML_BUTTON_ID_SUFFIX . '_' . $this->getHtmlId(), 'imageUploaderUrl' => $this->getCldImageUploaderUrl(), @@ -84,7 +88,8 @@ public function getCloudinaryMediaLibraryWidgetOptions($multiple = false, $refre 'addTmpExtension' => $this->getAddTmpExtension(), 'cloudinaryMLoptions' => $cloudinaryMLoptions, 'cloudinaryMLshowOptions' => Mage::helper('cloudinary_cloudinary/MediaLibraryHelper')->getCloudinaryMLshowOptions('image'), - )); + ) + ); } /** diff --git a/app/code/community/Cloudinary/Cloudinary/Helper/Autoloader.php b/app/code/community/Cloudinary/Cloudinary/Helper/Autoloader.php index 6cef1d2..9485407 100644 --- a/app/code/community/Cloudinary/Cloudinary/Helper/Autoloader.php +++ b/app/code/community/Cloudinary/Cloudinary/Helper/Autoloader.php @@ -21,8 +21,7 @@ private function _registerCloudinaryExtensionAutoloader() { spl_autoload_register( function ($className) { - if( - strpos($className, Cloudinary_Cloudinary_Helper_Autoloader::CLOUDINARY_EXTENSION_LIB_PATH . '\\') === 0 || + if(strpos($className, Cloudinary_Cloudinary_Helper_Autoloader::CLOUDINARY_EXTENSION_LIB_PATH . '\\') === 0 || strpos($className, Cloudinary_Cloudinary_Helper_Autoloader::CLOUDINARY_LIB_PATH . '\\') === 0 ) { include_once preg_replace(Cloudinary_Cloudinary_Helper_Autoloader::CONVERT_CLASS_TO_PATH_REGEX, '/', $className) . '.php'; diff --git a/app/code/community/Cloudinary/Cloudinary/Helper/BatchDownloader.php b/app/code/community/Cloudinary/Cloudinary/Helper/BatchDownloader.php index 90bffc1..22544ea 100644 --- a/app/code/community/Cloudinary/Cloudinary/Helper/BatchDownloader.php +++ b/app/code/community/Cloudinary/Cloudinary/Helper/BatchDownloader.php @@ -115,23 +115,27 @@ public function downloadImages() $this->_info["iteration"]++; $this->log('Iteration #' . $this->_info["iteration"]); $this->migrationTask->setBatchCount($this->_info["iteration"]); - $this->saveInfo(array( + $this->saveInfo( + array( "iteration" => $this->_info["iteration"], "resources_count" => 0, "resources_processed" => 0, "resources_downloaded" => 0, "resources_skipped" => 0, "resources_failed" => 0, - )); + ) + ); $response = $this->getResources($this->_info["next_cursor"]); $response->setResourcesCount(count($response->getResources())); - $this->saveInfo(array( + $this->saveInfo( + array( "next_cursor" => $response->getNextCursor(), "more_expected" => ($response->getNextCursor())? true : false, "resources_count" => $this->_info["resources_count"] + $response->getResourcesCount(), "resources_count_total" => $this->_info["resources_count_total"] + $response->getResourcesCount(), - )); + ) + ); if ($response->getResourcesCount() > 0) { $this->log('Found ' . $response->getResourcesCount() . ' image(s) to sync on this round. ' . (($response->getNextCursor()) ? '*More Rounds Expected*' : '*Last Round*')); foreach ($response->getResources() as $i => &$resource) { @@ -174,14 +178,16 @@ public function downloadImages() $res = Cloudinary_Cloudinary_Helper_Data::curlGetContents($remoteFileUrl); if (!$res || $res->getError() || empty(($image = $res->getBody()))) { throw new Mage_Core_Exception( - __('The preview image information is unavailable. Check your connection and try again.') - ); + __('The preview image information is unavailable. Check your connection and try again.') + ); } + $this->log('=== [Processing] Saving...'); Mage::getSingleton('core/file_storage_file')->saveFile(array('filename' => $localFileName, 'content' => $image), true); if (!@file_exists($localFilePath)) { throw new Mage_Core_Exception(__("Image not saved.")); } + $this->log('=== [Processing] Saved.'); $this->saveInfo(array("resources_downloaded" => $this->_info["resources_downloaded"]+1, "resources_downloaded_total" => $this->_info["resources_downloaded_total"]+1)); } @@ -228,13 +234,15 @@ public function downloadImages() */ private function getResources($nextCursor = null) { - $response = $this->api->resources(array( + $response = $this->api->resources( + array( "resource_type" => 'image', "type" => "upload", "prefix" => 'media' . DIRECTORY_SEPARATOR, "max_results" => self::API_REQUEST_MAX_RESULTS, "next_cursor" => $nextCursor, - )); + ) + ); $this->_rateLimitResetAt = $response->rate_limit_reset_at; $this->_rateLimitAllowed = $response->rate_limit_allowed; $this->_rateLimitRemaining = $response->rate_limit_remaining; @@ -255,6 +263,7 @@ private function log($message, $type = 'notice') $this->logger->notice($message); break; } + return $this; } @@ -268,7 +277,7 @@ private function log($message, $type = 'notice') private function validateRemoteFileExtensions($filePath) { $extension = pathinfo($filePath, PATHINFO_EXTENSION); - if (!in_array($extension, ['jpg','jpeg','gif','png'])) { + if (!in_array($extension, array('jpg','jpeg','gif','png'))) { throw new Mage_Core_Exception(__('Disallowed file type.')); } } @@ -290,13 +299,14 @@ private function getCredentialsFromEnvironmentVariable($environmentVariable) if (Cloudinary::config_get('private_cdn')) { $credentials["private_cdn"] = Cloudinary::config_get('private_cdn'); } + return $credentials; } catch (\Exception $e) { throw new Mage_Core_Exception(__(self::CREDENTIALS_CHECK_FAILED)); } } - private function saveInfo(array $info = []) + private function saveInfo(array $info = array()) { $this->_info = array_merge($this->_info, $info); $this->migrationTask->setInfo($this->_info)->save(); diff --git a/app/code/community/Cloudinary/Cloudinary/Helper/Cms/Wysiwyg/Images.php b/app/code/community/Cloudinary/Cloudinary/Helper/Cms/Wysiwyg/Images.php index 2a256ce..32c8c2e 100644 --- a/app/code/community/Cloudinary/Cloudinary/Helper/Cms/Wysiwyg/Images.php +++ b/app/code/community/Cloudinary/Cloudinary/Helper/Cms/Wysiwyg/Images.php @@ -16,10 +16,12 @@ public function getStorageRoot() if (!Mage::getModel('cloudinary_cloudinary/configuration')->isEnabled()) { return parent::getStorageRoot(); } + if (!$this->_storageRoot) { $this->_storageRoot = Mage::getConfig()->getOptions()->getMediaDir() . DS . Mage_Cms_Model_Wysiwyg_Config::IMAGE_DIRECTORY . DS; } + return $this->_storageRoot; } @@ -33,6 +35,7 @@ public function getCurrentUrl() if (!Mage::getModel('cloudinary_cloudinary/configuration')->isEnabled()) { return parent::getCurrentUrl(); } + if (!$this->_currentUrl) { $mediaPath = Mage::getConfig()->getOptions()->getMediaDir(); $path = str_replace($mediaPath, '', $this->getCurrentPath()); @@ -40,6 +43,7 @@ public function getCurrentUrl() $this->_currentUrl = Mage::app()->getStore($this->_storeId)->getBaseUrl('media') . $this->convertPathToUrl($path) . '/'; } + return $this->_currentUrl; } } diff --git a/app/code/community/Cloudinary/Cloudinary/Helper/Config.php b/app/code/community/Cloudinary/Cloudinary/Helper/Config.php index e290cc9..af46681 100644 --- a/app/code/community/Cloudinary/Cloudinary/Helper/Config.php +++ b/app/code/community/Cloudinary/Cloudinary/Helper/Config.php @@ -28,7 +28,7 @@ private function doFlatten($key, $value, array &$output) $this->doFlatten(sprintf('%s/%s', $key, $childKey), $childValue, $output); } } else { - $output[substr($key, 0, -6)] = $value; + $output[substr($key, 0, -6)] = $value; } } } diff --git a/app/code/community/Cloudinary/Cloudinary/Helper/Data.php b/app/code/community/Cloudinary/Cloudinary/Helper/Data.php index 5bb7985..deac865 100644 --- a/app/code/community/Cloudinary/Cloudinary/Helper/Data.php +++ b/app/code/community/Cloudinary/Cloudinary/Helper/Data.php @@ -13,10 +13,12 @@ public static function curlGetContents($url) $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $err = curl_error($ch); curl_close($ch); - return new Varien_Object(array( + return new Varien_Object( + array( "code" => $httpCode, "body" => $result, "error" => $err - )); + ) + ); } } diff --git a/app/code/community/Cloudinary/Cloudinary/Helper/Image.php b/app/code/community/Cloudinary/Cloudinary/Helper/Image.php index ffe375d..51c6157 100644 --- a/app/code/community/Cloudinary/Cloudinary/Helper/Image.php +++ b/app/code/community/Cloudinary/Cloudinary/Helper/Image.php @@ -109,6 +109,7 @@ public function __toString() if (!$this->_configuration->isEnabled()) { return parent::__toString(); } + $image = $this->_imageFactory->build( $this->_getRequestedImageFile(), function () { diff --git a/app/code/community/Cloudinary/Cloudinary/Helper/MediaLibraryHelper.php b/app/code/community/Cloudinary/Cloudinary/Helper/MediaLibraryHelper.php index b6455e9..29e8592 100644 --- a/app/code/community/Cloudinary/Cloudinary/Helper/MediaLibraryHelper.php +++ b/app/code/community/Cloudinary/Cloudinary/Helper/MediaLibraryHelper.php @@ -69,14 +69,21 @@ public function getCloudinaryMLOptions($multiple = false, $refresh = true) if (($this->credentials["username"] = $this->configuration->getAutomaticLoginUser())) { $this->cloudinaryMLoptions["timestamp"] = $this->timestamp; $this->cloudinaryMLoptions["username"] = $this->credentials["username"]; - $this->cloudinaryMLoptions["signature"] = $this->signature = hash('sha256', urldecode(http_build_query([ - 'cloud_name' => $this->credentials['cloud_name'], - 'timestamp' => $this->timestamp, - 'username' => $this->credentials['username'], - ])) . $this->credentials['api_secret']); + $this->cloudinaryMLoptions["signature"] = $this->signature = hash( + 'sha256', urldecode( + http_build_query( + array( + 'cloud_name' => $this->credentials['cloud_name'], + 'timestamp' => $this->timestamp, + 'username' => $this->credentials['username'], + ) + ) + ) . $this->credentials['api_secret'] + ); } } } + if ($this->cloudinaryMLoptions) { $this->cloudinaryMLoptions['multiple'] = $multiple; } @@ -92,13 +99,14 @@ public function getCloudinaryMLOptions($multiple = false, $refresh = true) */ public function getCloudinaryMLshowOptions($resourceType = null, $path = "") { - $options = []; + $options = array(); if ($resourceType || $resourceType) { $options["folder"] = array( "path" => $path, "resource_type" => $resourceType, ); } + return $options; } } diff --git a/app/code/community/Cloudinary/Cloudinary/Helper/ProductGalleryHelper.php b/app/code/community/Cloudinary/Cloudinary/Helper/ProductGalleryHelper.php index 9f9f02c..edbebf4 100644 --- a/app/code/community/Cloudinary/Cloudinary/Helper/ProductGalleryHelper.php +++ b/app/code/community/Cloudinary/Cloudinary/Helper/ProductGalleryHelper.php @@ -8,15 +8,15 @@ class Cloudinary_Cloudinary_Helper_ProductGalleryHelper extends Mage_Core_Helper /** * @var ConfigurationInterface */ - protected $configuration; + protected $_configuration; /** * Cloudinary PG Options * @var array|null */ - protected $cloudinaryPGoptions; + protected $_cloudinaryPGoptions; - const CASTING = [ + protected $_casting = array( 'themeProps_primary' => 'string', 'themeProps_onPrimary' => 'string', 'themeProps_active' => 'string', @@ -39,14 +39,14 @@ class Cloudinary_Cloudinary_Helper_ProductGalleryHelper extends Mage_Core_Helper 'thumbnailProps_selectedBorderWidth' => 'float', 'thumbnailProps_mediaSymbolShape' => 'string', 'indicatorProps_shape' => 'string', - ]; + ); /** * @method __construct */ public function __construct() { - $this->configuration = Mage::getModel('cloudinary_cloudinary/configuration'); + $this->_configuration = Mage::getModel('cloudinary_cloudinary/configuration'); } /** @@ -57,39 +57,44 @@ public function __construct() */ public function getCloudinaryPGOptions($refresh = false, $ignoreDisabled = false) { - if ((is_null($this->cloudinaryPGoptions) || $refresh) && ($ignoreDisabled || ($this->configuration->isEnabled() && $this->configuration->isEnabledProductGallery()))) { - $this->cloudinaryPGoptions = $this->configuration->getProductGalleryAll(); - foreach ($this->cloudinaryPGoptions as $key => $value) { + if ((is_null($this->_cloudinaryPGoptions) || $refresh) && ($ignoreDisabled || ($this->_configuration->isEnabled() && $this->_configuration->isEnabledProductGallery()))) { + $this->_cloudinaryPGoptions = $this->_configuration->getProductGalleryAll(); + foreach ($this->_cloudinaryPGoptions as $key => $value) { //Change casting - if (isset(self::CASTING[$key])) { - \settype($value, self::CASTING[$key]); - $this->cloudinaryPGoptions[$key] = $value; + if (isset($this->_casting[$key])) { + \settype($value, $this->_casting[$key]); + $this->_cloudinaryPGoptions[$key] = $value; } + //Build options hierarchy $path = explode("_", $key); $_path = $path[0]; - if (in_array($_path, ['themeProps','zoomProps','thumbnailProps','indicatorProps'])) { - if (!isset($this->cloudinaryPGoptions[$_path])) { - $this->cloudinaryPGoptions[$_path] = []; + if (in_array($_path, array('themeProps','zoomProps','thumbnailProps','indicatorProps'))) { + if (!isset($this->_cloudinaryPGoptions[$_path])) { + $this->_cloudinaryPGoptions[$_path] = array(); } + array_shift($path); $path = implode("_", $path); - $this->cloudinaryPGoptions[$_path][$path] = $value; - unset($this->cloudinaryPGoptions[$key]); + $this->_cloudinaryPGoptions[$_path][$path] = $value; + unset($this->_cloudinaryPGoptions[$key]); } } - if (isset($this->cloudinaryPGoptions['enabled'])) { - unset($this->cloudinaryPGoptions['enabled']); + + if (isset($this->_cloudinaryPGoptions['enabled'])) { + unset($this->_cloudinaryPGoptions['enabled']); } - if (isset($this->cloudinaryPGoptions['custom_free_params'])) { - $customFreeParams = (array) @json_decode($this->cloudinaryPGoptions['custom_free_params'], true); - $this->cloudinaryPGoptions = array_replace_recursive($this->cloudinaryPGoptions, $customFreeParams); - unset($this->cloudinaryPGoptions['custom_free_params']); + + if (isset($this->_cloudinaryPGoptions['custom_free_params'])) { + $customFreeParams = (array) @json_decode($this->_cloudinaryPGoptions['custom_free_params'], true); + $this->_cloudinaryPGoptions = array_replace_recursive($this->_cloudinaryPGoptions, $customFreeParams); + unset($this->_cloudinaryPGoptions['custom_free_params']); } - $this->cloudinaryPGoptions['cloudName'] = (string)$this->configuration->getCloud(); + + $this->_cloudinaryPGoptions['cloudName'] = (string)$this->_configuration->getCloud(); } - return $this->cloudinaryPGoptions; + return $this->_cloudinaryPGoptions; } /** @@ -97,6 +102,6 @@ public function getCloudinaryPGOptions($refresh = false, $ignoreDisabled = false */ public function canDisplayProductGallery() { - return ($this->configuration->isEnabled() && $this->configuration->isEnabledProductGallery()) ? true : false; + return ($this->_configuration->isEnabled() && $this->_configuration->isEnabledProductGallery()) ? true : false; } } diff --git a/app/code/community/Cloudinary/Cloudinary/Model/AdminProductObserver.php b/app/code/community/Cloudinary/Cloudinary/Model/AdminProductObserver.php index 01c7f96..2989dfa 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/AdminProductObserver.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/AdminProductObserver.php @@ -81,7 +81,7 @@ private function storeFreeTransformFields(array $imageData, Mage_Catalog_Model_P ->setImageName($this->getImageNameForId($id, $mediaImages)) ->setFreeTransformation($freeTransform) ->save(); - $cloudinaryData['transformation'][md5($this->getImageNameForId($id, $mediaImages))] = (string) $freeTransform; + $cloudinaryData['transformation'][hash('sha256', $this->getImageNameForId($id, $mediaImages))] = (string) $freeTransform; } $product->setCloudinaryData(json_encode($cloudinaryData)); @@ -122,6 +122,7 @@ private function getMediaGalleryImages(Mage_Catalog_Model_Product $product) } } } + return $images; } } diff --git a/app/code/community/Cloudinary/Cloudinary/Model/Catalog/Product/Media.php b/app/code/community/Cloudinary/Cloudinary/Model/Catalog/Product/Media.php index dcf4ffc..7cd89c1 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/Catalog/Product/Media.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/Catalog/Product/Media.php @@ -7,10 +7,11 @@ class Cloudinary_Cloudinary_Model_Catalog_Product_Media extends Mage_Core_Model_ public function getProductMediaGallery(Mage_Catalog_Model_Product $product) { $mediaGallery = (array) $product->getData('media_gallery'); - $mediaGallery['images'] = isset($mediaGallery['images'])? $mediaGallery['images'] : []; + $mediaGallery['images'] = isset($mediaGallery['images'])? $mediaGallery['images'] : array(); if (!is_array($mediaGallery['images'])) { $mediaGallery['images'] = (array) @json_decode($mediaGallery['images'], true); } + return $mediaGallery; } diff --git a/app/code/community/Cloudinary/Cloudinary/Model/Catalog/Product/Media/Config.php b/app/code/community/Cloudinary/Cloudinary/Model/Catalog/Product/Media/Config.php index 78e3ae5..043f7d3 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/Catalog/Product/Media/Config.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/Catalog/Product/Media/Config.php @@ -48,9 +48,11 @@ public function getMediaUrl($file) return parent::getMediaUrl($file); } - $image = $this->_imageFactory->build($file, function () use ($file) { + $image = $this->_imageFactory->build( + $file, function () use ($file) { return parent::getMediaUrl($file); - }); + } + ); return $this->_urlGenerator->generateFor( $image, diff --git a/app/code/community/Cloudinary/Cloudinary/Model/Cms/Synchronisation.php b/app/code/community/Cloudinary/Cloudinary/Model/Cms/Synchronisation.php index 6f61118..80ba626 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/Cms/Synchronisation.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/Cms/Synchronisation.php @@ -17,7 +17,8 @@ public function getFilename() return $this->getData('filename'); } - public function getRelativePath(){ + public function getRelativePath() + { return Mage::getModel('cloudinary_cloudinary/configuration')->getMigratedPath($this->getFilename()); } diff --git a/app/code/community/Cloudinary/Cloudinary/Model/Cms/Template/Filter.php b/app/code/community/Cloudinary/Cloudinary/Model/Cms/Template/Filter.php index 56d37f2..d4f6b13 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/Cms/Template/Filter.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/Cms/Template/Filter.php @@ -32,7 +32,9 @@ public function mediaDirective($construction) $image = $this->imageFactory->build( $imagePath, - function() use($construction) { return parent::mediaDirective($construction);} + function() use($construction) { + return parent::mediaDirective($construction); + } ); return $this->urlGenerator->generateFor($image); diff --git a/app/code/community/Cloudinary/Cloudinary/Model/Cms/Wysiwyg/Images/Storage.php b/app/code/community/Cloudinary/Cloudinary/Model/Cms/Wysiwyg/Images/Storage.php index 186337f..14ccccd 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/Cms/Wysiwyg/Images/Storage.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/Cms/Wysiwyg/Images/Storage.php @@ -162,6 +162,7 @@ public function uploadFile($targetPath, $type = null) if ($allowed = $this->getAllowedExtensions($type)) { $uploader->setAllowedExtensions($allowed); } + $uploader->setAllowRenameFiles(true); $uploader->setFilesDispersion(false); $result = $uploader->save($targetPath); diff --git a/app/code/community/Cloudinary/Cloudinary/Model/CollectionCounter.php b/app/code/community/Cloudinary/Cloudinary/Model/CollectionCounter.php index 663b16c..c8b3aa1 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/CollectionCounter.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/CollectionCounter.php @@ -17,6 +17,7 @@ public function count() foreach ($this->_collections as $collection) { $count += $collection->getSize(); } + return $count; } } diff --git a/app/code/community/Cloudinary/Cloudinary/Model/Configuration.php b/app/code/community/Cloudinary/Cloudinary/Model/Configuration.php index a264d9f..ebd92cb 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/Configuration.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/Configuration.php @@ -122,6 +122,7 @@ public function getDefaultTransformation() ->withFetchFormat(FetchFormat::fromString(FetchFormat::FETCH_FORMAT_AUTO)) ->withoutFormat(); } + return $transformation; } @@ -184,6 +185,7 @@ public function validateCredentials() } catch (Exception $e) { Mage::logException($e); } + return false; } @@ -194,6 +196,7 @@ public function getMigratedPath($file) } else { $result = basename($file); } + return $result; } @@ -202,6 +205,7 @@ public function reverseMigratedPathIfNeeded($migratedPath) if ($this->isFolderedMigration()) { return $this->folderTranslator->reverse($migratedPath); } + return $migratedPath; } @@ -250,8 +254,10 @@ public function getEnvironmentVariable() } else { $value = Mage::helper('core')->decrypt(Mage::getStoreConfig(self::CONFIG_PATH_ENVIRONMENT_VARIABLE)); } + $this->environmentVariable = CloudinaryEnvironmentVariable::fromString($value); } + return $this->environmentVariable; } @@ -277,6 +283,7 @@ private function getFetchFormat() if (Mage::getStoreConfigFlag(self::CONFIG_DEFAULT_FETCH_FORMAT)) { return FetchFormat::FETCH_FORMAT_AUTO; } + return ''; } diff --git a/app/code/community/Cloudinary/Cloudinary/Model/Exception/BadFilePathException.php b/app/code/community/Cloudinary/Cloudinary/Model/Exception/BadFilePathException.php index 08abae4..85dc544 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/Exception/BadFilePathException.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/Exception/BadFilePathException.php @@ -1,6 +1,7 @@ absolutePathRegex, $result)) { // the input is absolute, we truncate the magento base dir to get the relative path $result = preg_replace("#^$baseDir#", '', $result); - } else if (preg_match($this->productPathRegex, $result)) { /* the input appears to be a product image, we insert the path to product images relative to magento base dir * (by default /media/catalog/product/ ) */ $catalogMediapath = Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath(); $result = $this->removeMagentoBaseDir($catalogMediapath) . $result; - } else if (preg_match($this->mediaPathRegex, $result)) { // the input appears to be relative to the magento base dir // NOP, the result should be the input - } else { // we just assume the input is relative to the media library, in which case the relative path is "/media/$path" (in defualt case) $result = $this->mediaDir . $result; } + $result .= $baseName; return $result; diff --git a/app/code/community/Cloudinary/Cloudinary/Model/Migration.php b/app/code/community/Cloudinary/Cloudinary/Model/Migration.php index f518eb5..10a0876 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/Migration.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/Migration.php @@ -102,6 +102,7 @@ public function setInfo($info) if (is_array($info) || is_object($info)) { $info = json_encode($info); } + return $this->setData('info', $info); } } diff --git a/app/code/community/Cloudinary/Cloudinary/Model/Observer/ProductGalleryOverride.php b/app/code/community/Cloudinary/Cloudinary/Model/Observer/ProductGalleryOverride.php index c97cfa5..68c72c2 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/Observer/ProductGalleryOverride.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/Observer/ProductGalleryOverride.php @@ -50,8 +50,9 @@ public function execute(Varien_Event_Observer $observer) protected function getHtmlId() { if (!$this->htmlId) { - $this->htmlId = md5(uniqid('', true)); + $this->htmlId = hash('sha256', uniqid('', true)); } + return $this->htmlId; } @@ -71,7 +72,7 @@ protected function getCloudinaryPGOptions($refresh = false, $ignoreDisabled = fa if (is_null($this->cloudinaryPGoptions) || $refresh) { $this->cloudinaryPGoptions = $this->productGalleryHelper->getCloudinaryPGOptions($refresh, $ignoreDisabled); $this->cloudinaryPGoptions['container'] = '#' . $this->getCldPGid(); - $this->cloudinaryPGoptions['mediaAssets'] = []; + $this->cloudinaryPGoptions['mediaAssets'] = array(); if ($galleryAssets = $this->productGalleryBlock->getGalleryImages()) { foreach ($galleryAssets as $key => $_image) { if ($this->productGalleryBlock->isGalleryImageVisible($_image)) { @@ -89,17 +90,19 @@ protected function getCloudinaryPGOptions($refresh = false, $ignoreDisabled = fa } else { $publicId = null; } + if ($publicId) { - $this->cloudinaryPGoptions['mediaAssets'][] = (object)[ + $this->cloudinaryPGoptions['mediaAssets'][] = (object)array( "publicId" => $publicId, "mediaType" => 'image', "transformation" => $transformation, - ]; + ); } } } } } + return Mage::helper('core')->jsonEncode($this->cloudinaryPGoptions); } } diff --git a/app/code/community/Cloudinary/Cloudinary/Model/Resource/Cms/Synchronisation/Collection.php b/app/code/community/Cloudinary/Cloudinary/Model/Resource/Cms/Synchronisation/Collection.php index 729bd03..c594a62 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/Resource/Cms/Synchronisation/Collection.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/Resource/Cms/Synchronisation/Collection.php @@ -42,6 +42,7 @@ public function addTargetDir($value) Mage::getSingleton('core/session')->addError("Couldn't find path " . $value); Mage::register('error_' . $value, true); } + throw $e; } } diff --git a/app/code/community/Cloudinary/Cloudinary/Model/Synchronisation.php b/app/code/community/Cloudinary/Cloudinary/Model/Synchronisation.php index 541c27f..2dbecf3 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/Synchronisation.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/Synchronisation.php @@ -25,6 +25,7 @@ public function getFilename() if (!$this->getValue()) { return null; } + return $this->_baseMediaPath() . $this->getValue(); } diff --git a/app/code/community/Cloudinary/Cloudinary/Model/SynchronizationChecker.php b/app/code/community/Cloudinary/Cloudinary/Model/SynchronizationChecker.php index 6e9f00c..cead3fc 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/SynchronizationChecker.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/SynchronizationChecker.php @@ -57,7 +57,7 @@ private function synchronizationCheck($imageName) */ private function getSynchronizationCacheKeyFromImageName($imageName) { - return sprintf('cloudinary_sync_%s', md5($imageName)); + return sprintf('cloudinary_sync_%s', hash('sha256', $imageName)); } /** diff --git a/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Credentials.php b/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Credentials.php index d9f084e..9f4f256 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Credentials.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Credentials.php @@ -70,6 +70,7 @@ protected function _beforeSave() if (!$rawValue) { throw new Mage_Core_Exception(__(self::CREDENTIALS_CHECK_MISSING)); } + if ($isSaveAllowed) { $this->validate($this->getCredentialsFromEnvironmentVariable($rawValue)); } else { @@ -106,14 +107,15 @@ private function getCredentialsFromEnvironmentVariable($environmentVariable) { try { Cloudinary::config_from_url(str_replace('CLOUDINARY_URL=', '', $environmentVariable)); - $credentials = [ + $credentials = array( "cloud_name" => Cloudinary::config_get('cloud_name'), "api_key" => Cloudinary::config_get('api_key'), "api_secret" => Cloudinary::config_get('api_secret') - ]; + ); if (Cloudinary::config_get('private_cdn')) { $credentials["private_cdn"] = Cloudinary::config_get('private_cdn'); } + return $credentials; } catch (\Exception $e) { throw new Mage_Core_Exception(__(self::CREDENTIALS_CHECK_FAILED)); diff --git a/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Free.php b/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Free.php index f8ab272..72d68b3 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Free.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Free.php @@ -64,16 +64,18 @@ public function validateImageUrl($url, $strict = true) } else { Mage::getSingleton('adminhtml/session')->addError(sprintf(self::ERROR_FORMAT, self::ERROR_DEFAULT)); } + return false; } - if (is_object($response) && ($response->error || !in_array($response->code, [200,301,302]))) { + if (is_object($response) && ($response->error || !in_array($response->code, array(200,301,302)))) { $this->setValue(null); if ($strict) { throw new Mage_Core_Exception($this->formatError($response)); } else { Mage::getSingleton('adminhtml/session')->addError($this->formatError($response)); } + return false; } @@ -110,12 +112,14 @@ public function formatError($response) public function httpRequest($url) { $ch = curl_init(); - curl_setopt_array($ch, [ + curl_setopt_array( + $ch, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => 1, CURLOPT_VERBOSE => 1, CURLOPT_HEADER => 1, - ]); + ) + ); $res = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $err = curl_error($ch); @@ -131,15 +135,16 @@ public function httpRequest($url) } } } + $body = substr($res, $header_size); curl_close($ch); - $response = (object)[ + $response = (object)array( "code" => $httpCode, "body" => $body, "headers" => (array) $headers, "error" => $err - ]; + ); return $response; } diff --git a/app/code/community/Cloudinary/Cloudinary/Model/System/Config/ProductGalleryCustomFreeParams.php b/app/code/community/Cloudinary/Cloudinary/Model/System/Config/ProductGalleryCustomFreeParams.php index 1eeb6d6..e7d0e02 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/System/Config/ProductGalleryCustomFreeParams.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/System/Config/ProductGalleryCustomFreeParams.php @@ -4,14 +4,14 @@ class Cloudinary_Cloudinary_Model_System_Config_ProductGalleryCustomFreeParams e { const BAD_JSON_ERROR_MESSAGE = "Json error on 'Custom free parameters' please correct."; - const JSON_ERRORS = [ + protected $_jsonErrors = array( JSON_ERROR_NONE => 'No error', JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', JSON_ERROR_STATE_MISMATCH => 'State mismatch (invalid or malformed JSON)', JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded', JSON_ERROR_SYNTAX => 'Syntax error', JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded' - ]; + ); /** * @return Mage_Core_Model_Abstract @@ -33,7 +33,7 @@ protected function _beforeSave() $this->setValue('{}'); try { if (json_last_error() !== JSON_ERROR_NONE) { - Mage::getSingleton('adminhtml/session')->addError(self::BAD_JSON_ERROR_MESSAGE . ' (' . self::JSON_ERRORS[json_last_error()] . ')'); + Mage::getSingleton('adminhtml/session')->addError(self::BAD_JSON_ERROR_MESSAGE . ' (' . $this->_jsonErrors[json_last_error()] . ')'); } } catch (\Exception $e) { Mage::getSingleton('adminhtml/session')->addError(self::BAD_JSON_ERROR_MESSAGE); diff --git a/app/code/community/Cloudinary/Cloudinary/Model/Transformation.php b/app/code/community/Cloudinary/Cloudinary/Model/Transformation.php index a577334..c9a8c04 100644 --- a/app/code/community/Cloudinary/Cloudinary/Model/Transformation.php +++ b/app/code/community/Cloudinary/Cloudinary/Model/Transformation.php @@ -48,8 +48,8 @@ public function addFreeformTransformationForImage(Transformation $transformation $transformationString = false; if ($product) { $cloudinaryData = json_decode((string)$product->getCloudinaryData(), true) ?: array(); - if (isset($cloudinaryData['transformation']) && isset($cloudinaryData['transformation'][md5($imageFile)])) { - $transformationString = $cloudinaryData['transformation'][md5($imageFile)]; + if (isset($cloudinaryData['transformation']) && isset($cloudinaryData['transformation'][hash('sha256', $imageFile)])) { + $transformationString = $cloudinaryData['transformation'][hash('sha256', $imageFile)]; } else { $updateProduct = true; $transformationString = $this->cache->loadCache( @@ -61,6 +61,7 @@ function () use ($imageFile) { if (($this->getImageName() === $imageFile) && $this->hasFreeTransformation()) { return $this->getFreeTransformation(); } + return ''; } ); @@ -82,7 +83,7 @@ function () use ($imageFile) { if (isset($updateProduct)) { //$initialEnvironmentInfo = Mage::getSingleton('core/app_emulation')->startEnvironmentEmulation(Mage_Core_Model_App::ADMIN_STORE_ID); - $cloudinaryData['transformation'][md5($imageFile)] = $transformationString; + $cloudinaryData['transformation'][hash('sha256', $imageFile)] = $transformationString; $product->setCloudinaryData(json_encode($cloudinaryData)); $product->getResource()->saveAttribute($product, 'cloudinary_data'); //Mage::getSingleton('core/app_emulation')->stopEnvironmentEmulation($initialEnvironmentInfo); @@ -107,13 +108,14 @@ protected function warmTransformationCache() $transformation->getFreeTransformation() ); } + $this->cache->saveCache(self::TRANSFORM_CACHE_WARM_KEY, '1'); } } private function getTransformCacheKeyFromImageFile($imageFile) { - return sprintf('cloudinary_transform_%s', md5($imageFile)); + return sprintf('cloudinary_transform_%s', hash('sha256', $imageFile)); } /** diff --git a/app/code/community/Cloudinary/Cloudinary/controllers/Adminhtml/CloudinaryajaxController.php b/app/code/community/Cloudinary/Cloudinary/controllers/Adminhtml/CloudinaryajaxController.php index 987ca3a..e776850 100644 --- a/app/code/community/Cloudinary/Cloudinary/controllers/Adminhtml/CloudinaryajaxController.php +++ b/app/code/community/Cloudinary/Cloudinary/controllers/Adminhtml/CloudinaryajaxController.php @@ -78,6 +78,6 @@ private function validate(Cloudinary_Cloudinary_Model_System_Config_Free $model, */ protected function _isAllowed() { - return true; + return parent::_isAllowed(); } } diff --git a/app/code/community/Cloudinary/Cloudinary/controllers/Adminhtml/CloudinaryretrieveimageController.php b/app/code/community/Cloudinary/Cloudinary/controllers/Adminhtml/CloudinaryretrieveimageController.php index 648fbac..bb31545 100644 --- a/app/code/community/Cloudinary/Cloudinary/controllers/Adminhtml/CloudinaryretrieveimageController.php +++ b/app/code/community/Cloudinary/Cloudinary/controllers/Adminhtml/CloudinaryretrieveimageController.php @@ -11,13 +11,15 @@ public function uploadAction() $this->validateRemoteFileExtensions($localUniqFilePath); $this->retrieveRemoteImage($remoteFileUrl, $localUniqFilePath); $localFileFullPath = $this->appendAbsoluteFileSystemPath($localUniqFilePath); - Mage::getSingleton('core/file_validator_image')->setAllowedImageTypes(['jpg','jpeg','gif','png'])->validate($localFileFullPath); + Mage::getSingleton('core/file_validator_image')->setAllowedImageTypes(array('jpg','jpeg','gif','png'))->validate($localFileFullPath); $result = $this->appendResultSaveRemoteImage($localUniqFilePath, $baseTmpMediaPath); - Mage::dispatchEvent('catalog_product_gallery_upload_image_after', array( + Mage::dispatchEvent( + 'catalog_product_gallery_upload_image_after', array( 'result' => $result, 'action' => $this - )); + ) + ); } catch (Exception $e) { $result = array( 'error' => $e->getMessage(), @@ -51,9 +53,11 @@ protected function getBaseTmpMediaPath() } break; } + if (!$baseTmpMediaPath) { throw new Mage_Core_Exception(__("Empty baseTmpMediaPath")); } + return $baseTmpMediaPath; } @@ -70,6 +74,7 @@ protected function getLocalTmpFileName($remoteFileUrl) $localTmpFileName = Varien_File_Uploader::getDispretionPath($localFileName) . DIRECTORY_SEPARATOR . $localFileName; break; } + return $localTmpFileName; } @@ -83,7 +88,7 @@ protected function getLocalTmpFileName($remoteFileUrl) private function validateRemoteFileExtensions($filePath) { $extension = pathinfo($filePath, PATHINFO_EXTENSION); - if (!in_array($extension, ['jpg','jpeg','gif','png'])) { + if (!in_array($extension, array('jpg','jpeg','gif','png'))) { throw new Mage_Core_Exception(__('Disallowed file type.')); } } @@ -99,6 +104,7 @@ protected function appendResultSaveRemoteImage($localUniqFilePath, $baseTmpMedia if (substr($tmpFileName, 0, strlen($baseTmpMediaPath)) == $baseTmpMediaPath) { $tmpFileName = substr($tmpFileName, strlen($baseTmpMediaPath)); } + $result['name'] = basename($localUniqFilePath); $result['type'] = Mage::helper('uploader/file')->getMimeTypeByExtension(@pathinfo($localFileFullPath, PATHINFO_EXTENSION)); $result['error'] = 0; @@ -133,6 +139,7 @@ protected function retrieveRemoteImage($fileUrl, $localFilePath) __('The preview image information is unavailable. Check your connection and try again.') ); } + Mage::getSingleton('core/file_storage_file')->saveFile(array('filename' => $localFilePath, 'content' => $image), true); } @@ -168,6 +175,15 @@ public function getStorage() $storage = Mage::getModel('cms/wysiwyg_images_storage'); Mage::register('storage', $storage); } + return Mage::registry('storage'); } + + /** + * @return bool + */ + protected function _isAllowed() + { + return parent::_isAllowed(); + } } diff --git a/app/code/community/Cloudinary/Cloudinary/etc/config.xml b/app/code/community/Cloudinary/Cloudinary/etc/config.xml index ee58d99..e493e49 100644 --- a/app/code/community/Cloudinary/Cloudinary/etc/config.xml +++ b/app/code/community/Cloudinary/Cloudinary/etc/config.xml @@ -2,7 +2,7 @@ - 3.0.0 + 3.0.2 diff --git a/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/install-0.1.0.php b/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/install-0.1.0.php index 7896529..93b22f3 100644 --- a/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/install-0.1.0.php +++ b/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/install-0.1.0.php @@ -6,17 +6,21 @@ $table = $installer->getConnection() ->newTable($installer->getTable('cloudinary_cloudinary/synchronisation')) - ->addColumn('cloudinary_synchronisation_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( + ->addColumn( + 'cloudinary_synchronisation_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true, - ), 'Cloudinary Synchronisation ID') - ->addColumn('media_gallery_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( + ), 'Cloudinary Synchronisation ID' + ) + ->addColumn( + 'media_gallery_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( 'unsigned' => true, 'nullable' => true, 'default' => null, - ), 'Media Gallery ID') + ), 'Media Gallery ID' + ) ->addColumn('image_name', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255) ->addForeignKey( 'FK_MEDIA_GALLERY_ID_VALUE_ID', diff --git a/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-0.1.0-0.1.1.php b/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-0.1.0-0.1.1.php index 4f427c1..3f08a19 100644 --- a/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-0.1.0-0.1.1.php +++ b/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-0.1.0-0.1.1.php @@ -6,17 +6,21 @@ $table = $installer->getConnection() ->newTable($installer->getTable('cloudinary_cloudinary/migration')) - ->addColumn('cloudinary_migration_id', Varien_Db_Ddl_Table::TYPE_TINYINT, null, array( + ->addColumn( + 'cloudinary_migration_id', Varien_Db_Ddl_Table::TYPE_TINYINT, null, array( 'unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => 1 - ), 'Cloudinary Migration ID') - ->addColumn('started', Varien_Db_Ddl_Table::TYPE_TINYINT, null, array( + ), 'Cloudinary Migration ID' + ) + ->addColumn( + 'started', Varien_Db_Ddl_Table::TYPE_TINYINT, null, array( 'unsigned' => true, 'nullable' => false, 'default' => 0, - ), 'Migration Started'); + ), 'Migration Started' + ); $installer->getConnection()->createTable($table); diff --git a/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-1.1.4-1.1.5.php b/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-1.1.4-1.1.5.php index a17a1d9..0a50e7b 100644 --- a/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-1.1.4-1.1.5.php +++ b/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-1.1.4-1.1.5.php @@ -6,10 +6,12 @@ $table = $installer->getConnection() ->newTable($installer->getTable('cloudinary_cloudinary/migrationError')) - ->addColumn('file_path', Varien_Db_Ddl_Table::TYPE_BINARY, 255, array( + ->addColumn( + 'file_path', Varien_Db_Ddl_Table::TYPE_BINARY, 255, array( 'primary' => true, 'nullable' => false - ), 'File path') + ), 'File path' + ) ->addColumn('message', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255) ->addColumn('code', Varien_Db_Ddl_Table::TYPE_INTEGER, null) ->addColumn('relative_path', Varien_Db_Ddl_Table::TYPE_BINARY, 255) diff --git a/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-2.9.6-2.9.7.php b/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-2.9.6-2.9.7.php index 4c0c99c..758b10e 100644 --- a/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-2.9.6-2.9.7.php +++ b/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-2.9.6-2.9.7.php @@ -4,7 +4,8 @@ $installer = $this; $installer->startSetup(); -$installer->addAttribute('catalog_product', 'cloudinary_data', array( +$installer->addAttribute( + 'catalog_product', 'cloudinary_data', array( 'group' => 'General', 'label' => 'Cloudinary Data', 'input' => 'text', @@ -19,6 +20,7 @@ 'used_in_product_listing' => '1', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'note' => '', -)); + ) +); $installer->endSetup(); diff --git a/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-2.9.8-3.0.0.php b/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-2.9.8-3.0.0.php index 34bc9a3..e8b95ed 100644 --- a/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-2.9.8-3.0.0.php +++ b/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-2.9.8-3.0.0.php @@ -11,34 +11,46 @@ $con->dropTable($table); $table = $con->newTable($table) - ->addColumn('cloudinary_migration_id', Varien_Db_Ddl_Table::TYPE_TINYINT, null, array( + ->addColumn( + 'cloudinary_migration_id', Varien_Db_Ddl_Table::TYPE_TINYINT, null, array( 'unsigned' => true, 'nullable' => false, 'primary' => true, 'auto_increment' => true, - ), 'Cloudinary Migration ID') - ->addColumn('started', Varien_Db_Ddl_Table::TYPE_TINYINT, null, array( + ), 'Cloudinary Migration ID' + ) + ->addColumn( + 'started', Varien_Db_Ddl_Table::TYPE_TINYINT, null, array( 'unsigned' => true, 'nullable' => false, 'default' => 0, - ), 'Migration Started') - ->addColumn('started_at', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array( + ), 'Migration Started' + ) + ->addColumn( + 'started_at', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array( 'comment' => 'The time the migration started', 'nullable' => true, 'default' => '0000-00-00 00:00:00' - ))->addColumn('batch_count', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( - 'comment' => 'Batches run for current migration', - 'nullable' => false, - 'default' => 0 - ))->addColumn('type', Varien_Db_Ddl_Table::TYPE_TEXT, 10, array( - 'comment' => 'Migration Type', - 'nullable' => true, - 'default' => 'upload' - ))->addColumn('info', Varien_Db_Ddl_Table::TYPE_TEXT, null, array( - 'comment' => 'Info', - 'nullable' => true, - //'default' => '[]' - )); + ) + )->addColumn( + 'batch_count', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( + 'comment' => 'Batches run for current migration', + 'nullable' => false, + 'default' => 0 + ) + )->addColumn( + 'type', Varien_Db_Ddl_Table::TYPE_TEXT, 10, array( + 'comment' => 'Migration Type', + 'nullable' => true, + 'default' => 'upload' + ) + )->addColumn( + 'info', Varien_Db_Ddl_Table::TYPE_TEXT, null, array( + 'comment' => 'Info', + 'nullable' => true, + //'default' => '[]' + ) + ); $con->createTable($table); @@ -53,12 +65,14 @@ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE ); -$con->addColumn($installer->getTable('cloudinary_cloudinary/migrationError'), 'type', array( +$con->addColumn( + $installer->getTable('cloudinary_cloudinary/migrationError'), 'type', array( 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, 'nullable' => true, 'length' => 10, 'comment' => 'Migration Type', 'default' => 'upload' -)); + ) +); $installer->endSetup(); diff --git a/app/design/adminhtml/default/default/template/cloudinary/catalog/product/gallery.phtml b/app/design/adminhtml/default/default/template/cloudinary/catalog/product/gallery.phtml index 5609618..c0486e3 100644 --- a/app/design/adminhtml/default/default/template/cloudinary/catalog/product/gallery.phtml +++ b/app/design/adminhtml/default/default/template/cloudinary/catalog/product/gallery.phtml @@ -1,8 +1,8 @@ getImages(); - $imagesData = []; + $imagesData = array(); foreach ($this->getImages() as $image) { - $imagesData[$image->getValueId()] = [ + $imagesData[$image->getValueId()] = array( 'id' => $image->getValueId(), 'label' => $image->getLabel(), 'free_transformation' => $image->getFreeTransformation(), @@ -10,7 +10,7 @@ 'file' => $image->getFile(), 'image_url' => $image->getUrl(), 'error' => false, - ]; + ); } ?>
@@ -23,7 +23,6 @@
isCloudinaryEnabled()): ?> -
@@ -75,7 +74,6 @@ -
  • No product images are available

    diff --git a/app/design/frontend/base/default/template/cloudinary/catalog/product/view/media.phtml b/app/design/frontend/base/default/template/cloudinary/catalog/product/view/media.phtml index 1e29c0c..847892d 100644 --- a/app/design/frontend/base/default/template/cloudinary/catalog/product/view/media.phtml +++ b/app/design/frontend/base/default/template/cloudinary/catalog/product/view/media.phtml @@ -3,13 +3,13 @@ * @var $this Cloudinary_Cloudinary_Block */ ?> - + \n"; } - + function cloudinary_url($source, $options = array()) { return cloudinary_url_internal($source, $options); } @@ -140,10 +140,10 @@ function cloudinary_url_internal($source, &$options = array()) { $options["secure"] = ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) || ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ); } - + return Cloudinary::cloudinary_url($source, $options); } - + function cl_sprite_url($tag, $options = array()) { if (substr($tag, -strlen(".css")) != ".css") { $options["format"] = "css"; @@ -151,7 +151,7 @@ function cl_sprite_url($tag, $options = array()) { $options["type"] = "sprite"; return cloudinary_url_internal($tag, $options); } - + function cl_sprite_tag($tag, $options = array()) { return ""; } @@ -212,7 +212,7 @@ function cl_video_tag($source, $options = array()) { } else { $video_options['poster'] = cl_video_thumbnail_path($source, $options); } - + if (empty($video_options['poster'])) unset($video_options['poster']); @@ -230,7 +230,7 @@ function cl_video_tag($source, $options = array()) { $html .= Cloudinary::html_attrs($video_options ) . '>'; if ($multi_source) { - + foreach($source_types as $source_type) { $transformation = Cloudinary::option_consume($source_transformation, $source_type, array()); $transformation = array_merge($options, $transformation); diff --git a/var/connect/Cloudinary_Cloudinary-3.0.1.tgz b/var/connect/Cloudinary_Cloudinary-3.0.1.tgz deleted file mode 100644 index db78106..0000000 Binary files a/var/connect/Cloudinary_Cloudinary-3.0.1.tgz and /dev/null differ diff --git a/var/connect/Cloudinary_Cloudinary-3.0.2.tgz b/var/connect/Cloudinary_Cloudinary-3.0.2.tgz new file mode 100644 index 0000000..3d10d0f Binary files /dev/null and b/var/connect/Cloudinary_Cloudinary-3.0.2.tgz differ diff --git a/var/connect/Cloudinary_Cloudinary.xml b/var/connect/Cloudinary_Cloudinary.xml index 98b5b21..28c2ada 100644 --- a/var/connect/Cloudinary_Cloudinary.xml +++ b/var/connect/Cloudinary_Cloudinary.xml @@ -1,5 +1,5 @@ <_> - 7WvIiap05SUwQcVH + c9O49n7FRrl1rBOi Cloudinary_Cloudinary community @@ -9,7 +9,7 @@ Cloudinary supercharges your images! Upload images to the cloud, deliver optimized via a fast CDN, perform smart resizing and apply effects. MIT License (MITL) - 3.0.1 + 3.0.2 stable - Match MEQP1 coding standards @@ -41,7 +41,7 @@ - + diff --git a/var/connect/package.xml b/var/connect/package.xml index 39ff139..1f99996 100644 --- a/var/connect/package.xml +++ b/var/connect/package.xml @@ -1,7 +1,7 @@ Cloudinary_Cloudinary - 3.0.1 + 3.0.2 stable MIT License (MITL) community @@ -11,9 +11,9 @@ - Match MEQP1 coding standards Cloudinarycloudinaryaccounts+magento@cloudinary.com - 2019-08-20 - - + 2019-09-02 + + 5.4.07.2.2