├── lib
└── CloudinaryExtension
│ ├── vendor
│ ├── cloudinary
│ │ └── cloudinary_php
│ │ │ ├── tests
│ │ │ ├── .htaccess
│ │ │ ├── logo.png
│ │ │ ├── docx.docx
│ │ │ ├── favicon.ico
│ │ │ ├── Cache
│ │ │ │ └── Storage
│ │ │ │ │ └── DummyCacheStorage.php
│ │ │ ├── CloudinaryFieldTest.php
│ │ │ ├── ConfigTest.php
│ │ │ └── HttpClientTest.php
│ │ │ ├── samples
│ │ │ ├── basic
│ │ │ │ ├── .gitignore
│ │ │ │ ├── lake.jpg
│ │ │ │ ├── pizza.jpg
│ │ │ │ └── settings.php.sample
│ │ │ ├── PhotoAlbum
│ │ │ │ ├── .gitignore
│ │ │ │ ├── files
│ │ │ │ │ └── .htaccess
│ │ │ │ ├── settings.php.sample
│ │ │ │ ├── autoloader.php
│ │ │ │ ├── upload_complete.php
│ │ │ │ ├── upload_backend.php
│ │ │ │ ├── style.css
│ │ │ │ └── main.php
│ │ │ └── README.md
│ │ │ ├── .htaccess
│ │ │ ├── .gitignore
│ │ │ ├── src
│ │ │ ├── Error.php
│ │ │ ├── Api
│ │ │ │ ├── Error.php
│ │ │ │ ├── NotFound.php
│ │ │ │ ├── BadRequest.php
│ │ │ │ ├── NotAllowed.php
│ │ │ │ ├── RateLimited.php
│ │ │ │ ├── AlreadyExists.php
│ │ │ │ ├── GeneralError.php
│ │ │ │ ├── AuthorizationRequired.php
│ │ │ │ └── Response.php
│ │ │ ├── Cache
│ │ │ │ ├── Storage
│ │ │ │ │ ├── KeyValueStorage.php
│ │ │ │ │ └── FileSystemKeyValueStorage.php
│ │ │ │ └── Adapter
│ │ │ │ │ └── CacheAdapter.php
│ │ │ ├── Utils
│ │ │ │ └── Singleton.php
│ │ │ ├── CloudinaryField.php
│ │ │ ├── Search.php
│ │ │ └── PreloadedFile.php
│ │ │ ├── phpunit.php
│ │ │ ├── .travis.yml
│ │ │ ├── phpcs.xml
│ │ │ ├── phpunit.xml.dist
│ │ │ ├── composer.json
│ │ │ ├── LICENSE.txt
│ │ │ └── autoload.php
│ ├── composer
│ │ ├── autoload_psr4.php
│ │ ├── autoload_namespaces.php
│ │ ├── autoload_files.php
│ │ ├── LICENSE
│ │ ├── installed.json
│ │ ├── autoload_real.php
│ │ └── autoload_classmap.php
│ └── autoload.php
│ ├── composer.json
│ ├── Exception
│ ├── ApiError.php
│ ├── InvalidCredentials.php
│ ├── FileExists.php
│ └── MigrationError.php
│ ├── ImageInterface.php
│ ├── Security
│ ├── EnvironmentVariable.php
│ ├── Key.php
│ ├── Secret.php
│ ├── ConsoleUrl.php
│ ├── ApiSignature.php
│ ├── SignedConsoleUrl.php
│ └── CloudinaryEnvironmentVariable.php
│ ├── Image
│ ├── SynchronizationChecker.php
│ ├── Synchronizable.php
│ ├── Transformation
│ │ ├── Dpr.php
│ │ ├── Quality.php
│ │ ├── Gravity.php
│ │ ├── FetchFormat.php
│ │ ├── Freeform.php
│ │ ├── Crop.php
│ │ └── Dimensions.php
│ ├── LocalImage.php
│ ├── ImageFactory.php
│ └── Transformation.php
│ ├── Migration
│ ├── SynchronizedMediaRepository.php
│ ├── Task.php
│ ├── Logger.php
│ └── Queue.php
│ ├── FolderTranslator.php
│ ├── UploadResponseValidator.php
│ ├── SynchroniseAssetsRepositoryInterface.php
│ ├── ImageProvider.php
│ ├── Cloud.php
│ ├── CredentialValidator.php
│ ├── AutoUploadMapping
│ ├── Configuration.php
│ └── RequestProcessor.php
│ ├── Credentials.php
│ ├── ConfigurationBuilder.php
│ ├── ConfigurationInterface.php
│ ├── ValidateRemoteUrlRequest.php
│ ├── UploadConfig.php
│ ├── Image.php
│ ├── UrlGenerator.php
│ ├── composer.lock
│ └── CloudinaryImageManager.php
├── var
└── connect
│ └── Cloudinary_Cloudinary-3.1.1.tgz
├── app
├── code
│ └── community
│ │ └── Cloudinary
│ │ └── Cloudinary
│ │ ├── Block
│ │ └── Adminhtml
│ │ │ ├── Log
│ │ │ └── Grid.php
│ │ │ ├── Manage
│ │ │ └── Grid.php
│ │ │ ├── Page
│ │ │ └── Menu.php
│ │ │ ├── Reset
│ │ │ ├── Edit.php
│ │ │ └── Edit
│ │ │ │ └── Form.php
│ │ │ ├── Catalog
│ │ │ └── Product
│ │ │ │ └── Edit
│ │ │ │ └── Tab.php
│ │ │ ├── System
│ │ │ └── Config
│ │ │ │ ├── Form
│ │ │ │ └── Free.php
│ │ │ │ └── Signup.php
│ │ │ └── Log.php
│ │ ├── Model
│ │ ├── Exception
│ │ │ └── BadFilePathException.php
│ │ ├── Resource
│ │ │ ├── Migration.php
│ │ │ ├── Migration
│ │ │ │ └── Collection.php
│ │ │ ├── Transformation
│ │ │ │ └── Collection.php
│ │ │ ├── MigrationError
│ │ │ │ └── Collection.php
│ │ │ ├── Synchronisation.php
│ │ │ ├── MigrationError.php
│ │ │ ├── Transformation.php
│ │ │ ├── Media
│ │ │ │ └── Collection.php
│ │ │ └── Synchronisation
│ │ │ │ └── Collection.php
│ │ ├── System
│ │ │ └── Config
│ │ │ │ ├── HexColor.php
│ │ │ │ ├── Source
│ │ │ │ ├── Dropdown
│ │ │ │ │ ├── Dpr.php
│ │ │ │ │ ├── Gravity.php
│ │ │ │ │ └── Quality.php
│ │ │ │ └── ProductGallery
│ │ │ │ │ ├── ZoomTrigger.php
│ │ │ │ │ ├── Transition.php
│ │ │ │ │ ├── ZoomType.php
│ │ │ │ │ ├── Navigation.php
│ │ │ │ │ ├── IndicatorsShape.php
│ │ │ │ │ ├── CarouselStyle.php
│ │ │ │ │ ├── ThumbnailsSelectedStyle.php
│ │ │ │ │ ├── CarouselLocation.php
│ │ │ │ │ ├── ZoomViewerPosition.php
│ │ │ │ │ ├── ThumbnailsMediaSymbolShape.php
│ │ │ │ │ ├── ThumbnailsNavigationShape.php
│ │ │ │ │ ├── ThumbnailsSelectedBorderPosition.php
│ │ │ │ │ └── AspectRatio.php
│ │ │ │ └── ProductGalleryCustomFreeParams.php
│ │ ├── Observer
│ │ │ ├── Autoload.php
│ │ │ ├── System.php
│ │ │ ├── Product.php
│ │ │ └── Config.php
│ │ ├── CollectionCounter.php
│ │ ├── Cms
│ │ │ ├── Synchronisation.php
│ │ │ ├── Uploader.php
│ │ │ ├── Template
│ │ │ │ └── Filter.php
│ │ │ └── Adminhtml
│ │ │ │ └── Template
│ │ │ │ └── Filter.php
│ │ ├── Cache.php
│ │ ├── Catalog
│ │ │ ├── Product
│ │ │ │ ├── Image.php
│ │ │ │ ├── Media.php
│ │ │ │ └── Media
│ │ │ │ │ └── Config.php
│ │ │ └── Template
│ │ │ │ └── Filter.php
│ │ ├── Synchronisation.php
│ │ ├── SynchronisedMediaUnifier.php
│ │ ├── AutoUploadMapping
│ │ │ └── Configuration.php
│ │ ├── MigrationError.php
│ │ ├── Cron.php
│ │ ├── SynchronizationChecker.php
│ │ ├── Image.php
│ │ ├── Logger.php
│ │ └── Migration.php
│ │ ├── data
│ │ └── cloudinary_setup
│ │ │ └── data-upgrade-0.1.0-0.1.1.php
│ │ ├── sql
│ │ └── cloudinary_setup
│ │ │ ├── upgrade-2.1.0-2.5.0.php
│ │ │ ├── upgrade-2.6.0-2.7.0.php
│ │ │ ├── upgrade-2.8.2-2.8.4.php
│ │ │ ├── upgrade-1.1.5-1.1.6.php
│ │ │ ├── upgrade-2.5.0-2.6.0.php
│ │ │ ├── upgrade-1.1.3-1.1.4.php
│ │ │ ├── upgrade-2.7.0-2.8.0.php
│ │ │ ├── upgrade-1.1.4-1.1.5.php
│ │ │ ├── upgrade-0.1.0-0.1.1.php
│ │ │ ├── upgrade-2.0.0-2.1.0.php
│ │ │ ├── upgrade-2.9.6-2.9.7.php
│ │ │ ├── install-0.1.0.php
│ │ │ └── upgrade-2.9.8-3.0.0.php
│ │ ├── controllers
│ │ └── Adminhtml
│ │ │ ├── CloudinaryproductController.php
│ │ │ ├── CloudinaryresetController.php
│ │ │ └── CloudinaryajaxController.php
│ │ └── Helper
│ │ ├── Console.php
│ │ ├── Data.php
│ │ ├── Cron.php
│ │ ├── Config.php
│ │ ├── Cms
│ │ └── Wysiwyg
│ │ │ └── Images.php
│ │ ├── Reset.php
│ │ └── Autoloader.php
├── design
│ ├── adminhtml
│ │ └── default
│ │ │ └── default
│ │ │ └── template
│ │ │ └── cloudinary
│ │ │ ├── system
│ │ │ └── config
│ │ │ │ └── signup.phtml
│ │ │ ├── log.phtml
│ │ │ └── media
│ │ │ └── uploader.phtml
│ └── frontend
│ │ └── base
│ │ └── default
│ │ ├── layout
│ │ └── cloudinary
│ │ │ └── cloudinary.xml
│ │ └── template
│ │ └── cloudinary
│ │ └── catalog
│ │ └── product
│ │ └── view
│ │ └── media.phtml
└── etc
│ └── modules
│ └── Cloudinary_Cloudinary.xml
├── modman
├── LICENSE.txt
└── README.md
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/tests/.htaccess:
--------------------------------------------------------------------------------
1 | deny from all
2 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/samples/basic/.gitignore:
--------------------------------------------------------------------------------
1 | settings.php
2 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/samples/PhotoAlbum/.gitignore:
--------------------------------------------------------------------------------
1 | settings.php
2 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/samples/PhotoAlbum/files/.htaccess:
--------------------------------------------------------------------------------
1 | deny from all
2 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "require": {
3 | "cloudinary/cloudinary_php": "^1.16"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/.htaccess:
--------------------------------------------------------------------------------
1 |
2 | deny from all
3 |
4 |
--------------------------------------------------------------------------------
/var/connect/Cloudinary_Cloudinary-3.1.1.tgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudinary/cloudinary_magento/HEAD/var/connect/Cloudinary_Cloudinary-3.1.1.tgz
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Log/Grid.php:
--------------------------------------------------------------------------------
1 | saveConfig('cloudinary/cloud/cloudinary_enabled', '0', 'default', 0);
4 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/samples/basic/pizza.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudinary/cloudinary_magento/HEAD/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/samples/basic/pizza.jpg
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/ImageInterface.php:
--------------------------------------------------------------------------------
1 | Haven't got a Cloudinary account? Sign up here!
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/composer/autoload_psr4.php:
--------------------------------------------------------------------------------
1 | startSetup();
7 |
8 | $installer->endSetup();
9 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-2.6.0-2.7.0.php:
--------------------------------------------------------------------------------
1 | startSetup();
7 |
8 | $installer->endSetup();
9 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/autoload.php:
--------------------------------------------------------------------------------
1 | 'my_cloud_name',
5 | 'api_key' => 'my_api_key',
6 | 'api_secret' => 'my_api_secret'
7 | ));
8 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/src/Api/BadRequest.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | true
6 | community
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Migration/SynchronizedMediaRepository.php:
--------------------------------------------------------------------------------
1 | $vendorDir . '/cloudinary/cloudinary_php/src/Helpers.php',
10 | );
11 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Resource/Migration.php:
--------------------------------------------------------------------------------
1 | _init('cloudinary_cloudinary/migration', 'cloudinary_migration_id');
9 | }
10 |
11 | }
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Resource/Migration/Collection.php:
--------------------------------------------------------------------------------
1 | _init('cloudinary_cloudinary/migration');
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-2.8.2-2.8.4.php:
--------------------------------------------------------------------------------
1 | startSetup();
6 |
7 | $installer->run("DELETE FROM core_config_data WHERE path LIKE 'cloudinary/%' AND scope != 'default';");
8 |
9 | $installer->endSetup();
10 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Resource/Transformation/Collection.php:
--------------------------------------------------------------------------------
1 | _init('cloudinary_cloudinary/transformation');
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Resource/MigrationError/Collection.php:
--------------------------------------------------------------------------------
1 | _init('cloudinary_cloudinary/migrationError');
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/samples/PhotoAlbum/settings.php.sample:
--------------------------------------------------------------------------------
1 | 'my_cloud_name',
4 | 'api_key' => '123456789012345',
5 | 'api_secret' => 'abcdefghijklmnopqrstuvwxyz1'
6 | ));
7 |
8 | R::setup('mysql:host=my_database.mydomain.com;dbname=photo_album', 'username', 'password');
9 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Resource/Synchronisation.php:
--------------------------------------------------------------------------------
1 | _init('cloudinary_cloudinary/synchronisation', 'cloudinary_synchronisation_id');
9 | }
10 |
11 |
12 | }
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Resource/MigrationError.php:
--------------------------------------------------------------------------------
1 | _init('cloudinary_cloudinary/migrationError', 'file_path');
8 | $this->_isPkAutoIncrement = false;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Migration/Logger.php:
--------------------------------------------------------------------------------
1 | _init('cloudinary_cloudinary/transformation', 'image_name');
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/System/Config/HexColor.php:
--------------------------------------------------------------------------------
1 | setValue('#' . preg_replace('/#/', '', $this->getValue()));
12 | return parent::_beforeSave();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/UploadResponseValidator.php:
--------------------------------------------------------------------------------
1 | startSetup();
6 |
7 | $installer->getConnection()->addIndex(
8 | $installer->getTable('cloudinary_synchronisation'),
9 | $installer->getIdxName('cloudinary_synchronisation', array('image_name')),
10 | array('image_name')
11 | );
12 |
13 | $installer->endSetup();
14 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/ImageProvider.php:
--------------------------------------------------------------------------------
1 | key = (string)$key;
13 | }
14 |
15 | public static function fromString($aKey)
16 | {
17 | return new Key($aKey);
18 | }
19 |
20 | public function __toString()
21 | {
22 | return $this->key;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Observer/System.php:
--------------------------------------------------------------------------------
1 | register();
12 |
13 | return $event;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Image/Transformation/Dpr.php:
--------------------------------------------------------------------------------
1 | value = $value;
12 | }
13 |
14 | public static function fromString($value)
15 | {
16 | return new Dpr($value);
17 | }
18 |
19 | public function __toString()
20 | {
21 | return $this->value;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/controllers/Adminhtml/CloudinaryproductController.php:
--------------------------------------------------------------------------------
1 | loadLayout();
8 | $this->renderLayout();
9 | }
10 |
11 | /**
12 | * @return bool
13 | */
14 | protected function _isAllowed()
15 | {
16 | return true;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Security/Secret.php:
--------------------------------------------------------------------------------
1 | secret = (string)$secret;
13 | }
14 |
15 | public static function fromString($aSecret)
16 | {
17 | return new Secret($aSecret);
18 | }
19 |
20 | public function __toString()
21 | {
22 | return $this->secret;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Cloud.php:
--------------------------------------------------------------------------------
1 | cloudName = (string)$cloudName;
14 | }
15 |
16 | public static function fromName($aCloudName)
17 | {
18 | return new Cloud($aCloudName);
19 | }
20 |
21 | public function __toString()
22 | {
23 | return $this->cloudName;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Image/Transformation/Quality.php:
--------------------------------------------------------------------------------
1 | value = $value;
12 | }
13 |
14 | public static function fromString($value)
15 | {
16 | return new Quality($value);
17 | }
18 |
19 | public function __toString()
20 | {
21 | return $this->value;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Source/Dropdown/Dpr.php:
--------------------------------------------------------------------------------
1 | '1.0',
10 | 'label' => '1.0',
11 | ),
12 | array(
13 | 'value' => '2.0',
14 | 'label' => '2.0',
15 | ),
16 | );
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Source/ProductGallery/ZoomTrigger.php:
--------------------------------------------------------------------------------
1 | 'click',
10 | 'label' => 'Click',
11 | ),
12 | array(
13 | 'value' => 'hover',
14 | 'label' => 'Hover',
15 | ),
16 | );
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/CredentialValidator.php:
--------------------------------------------------------------------------------
1 | validate();
16 |
17 | }
18 | }
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-2.5.0-2.6.0.php:
--------------------------------------------------------------------------------
1 | startSetup();
7 |
8 | $currentConfig = Mage::getStoreConfig('cloudinary/setup/cloudinary_enabled');
9 |
10 | if (is_null($currentConfig)) {
11 | $legacyConfig = Mage::getStoreConfig('cloudinary/cloud/cloudinary_enabled');
12 | Mage::getModel('core/config')->saveConfig('cloudinary/setup/cloudinary_enabled', $legacyConfig)->reinit();
13 | }
14 |
15 | $installer->endSetup();
16 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Helper/Console.php:
--------------------------------------------------------------------------------
1 | getCredentials()
14 | );
15 | }
16 | }
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Resource/Media/Collection.php:
--------------------------------------------------------------------------------
1 | _init('catalog/product_attribute_backend_media');
9 | }
10 |
11 | public function uniqueImageCount()
12 | {
13 | $table = $this->getMainTable();
14 | $query = "select count(distinct value) from $table";
15 |
16 | return $this->getConnection()->query($query)->fetchColumn();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Image/Transformation/Gravity.php:
--------------------------------------------------------------------------------
1 | value = $value;
12 | }
13 |
14 | public function __toString()
15 | {
16 | return $this->value;
17 | }
18 |
19 | public static function fromString($value)
20 | {
21 | return new Gravity($value);
22 | }
23 |
24 | public static function null()
25 | {
26 | return new Gravity(null);
27 | }
28 | }
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/design/frontend/base/default/layout/cloudinary/cloudinary.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | ]]>
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Image/LocalImage.php:
--------------------------------------------------------------------------------
1 | localPathGenerator = $localPathGenerator;
19 | }
20 |
21 | public function __toString()
22 | {
23 | return call_user_func($this->localPathGenerator);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Security/ConsoleUrl.php:
--------------------------------------------------------------------------------
1 | consoleUrl = self::CLOUDINARY_CONSOLE_BASE_URL . $path;
15 | }
16 |
17 | public static function fromPath($path)
18 | {
19 | return new ConsoleUrl($path);
20 | }
21 |
22 | public function __toString()
23 | {
24 | return $this->consoleUrl;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/CollectionCounter.php:
--------------------------------------------------------------------------------
1 | _collections[] = $collection;
10 |
11 | return $this;
12 | }
13 |
14 | public function count()
15 | {
16 | $count = 0;
17 | foreach ($this->_collections as $collection) {
18 | $count += $collection->getSize();
19 | }
20 |
21 | return $count;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/AutoUploadMapping/Configuration.php:
--------------------------------------------------------------------------------
1 | 'none',
10 | 'label' => 'None',
11 | ),
12 | array(
13 | 'value' => 'fade',
14 | 'label' => 'Fade',
15 | ),
16 | array(
17 | 'value' => 'slide',
18 | 'label' => 'Slide',
19 | ),
20 | );
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/design/frontend/base/default/template/cloudinary/catalog/product/view/media.phtml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
17 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Security/ApiSignature.php:
--------------------------------------------------------------------------------
1 | apiSignature = Cloudinary::api_sign_request($params, (string) $secret);
15 | }
16 |
17 | public static function fromSecretAndParams(Secret $secret, array $params = array())
18 | {
19 | return new ApiSignature($secret, $params);
20 | }
21 |
22 | public function __toString()
23 | {
24 | return $this->apiSignature;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Source/ProductGallery/ZoomType.php:
--------------------------------------------------------------------------------
1 | 'inline',
10 | 'label' => 'Inline',
11 | ),
12 | array(
13 | 'value' => 'flyout',
14 | 'label' => 'Flyout',
15 | ),
16 | array(
17 | 'value' => 'popup',
18 | 'label' => 'Popup',
19 | ),
20 | );
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Source/ProductGallery/Navigation.php:
--------------------------------------------------------------------------------
1 | 'none',
10 | 'label' => 'None',
11 | ),
12 | array(
13 | 'value' => 'always',
14 | 'label' => 'Always',
15 | ),
16 | array(
17 | 'value' => 'mouseover',
18 | 'label' => 'Mouseover',
19 | ),
20 | );
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Source/ProductGallery/IndicatorsShape.php:
--------------------------------------------------------------------------------
1 | 'round',
10 | 'label' => 'Round',
11 | ),
12 | array(
13 | 'value' => 'square',
14 | 'label' => 'Square',
15 | ),
16 | array(
17 | 'value' => 'radius',
18 | 'label' => 'Radius',
19 | ),
20 | );
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-1.1.3-1.1.4.php:
--------------------------------------------------------------------------------
1 | startSetup();
6 |
7 | $conn = $installer->getConnection();
8 | $synchronizationTable = $installer->getTable('cloudinary_cloudinary/synchronisation');
9 |
10 | $options = array(
11 | 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
12 | 'length' => 255,
13 | 'comment' => 'The name with which the image can be found in the product related media gallery table'
14 | );
15 |
16 | $result = $conn->addColumn($synchronizationTable, 'media_gallery_value', $options);
17 |
18 | $installer->endSetup();
19 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Image/Transformation/FetchFormat.php:
--------------------------------------------------------------------------------
1 | value = $value;
14 | }
15 |
16 | public static function auto()
17 | {
18 | return self::fromString(self::FETCH_FORMAT_AUTO);
19 | }
20 |
21 | public static function fromString($value)
22 | {
23 | return new FetchFormat($value);
24 | }
25 |
26 | public function __toString()
27 | {
28 | return $this->value;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Source/ProductGallery/CarouselStyle.php:
--------------------------------------------------------------------------------
1 | 'none',
10 | 'label' => 'None',
11 | ),
12 | array(
13 | 'value' => 'thumbnails',
14 | 'label' => 'Thumbnails',
15 | ),
16 | array(
17 | 'value' => 'indicators',
18 | 'label' => 'Indicators',
19 | ),
20 | );
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Source/ProductGallery/ThumbnailsSelectedStyle.php:
--------------------------------------------------------------------------------
1 | 'border',
10 | 'label' => 'Border',
11 | ),
12 | array(
13 | 'value' => 'gradient',
14 | 'label' => 'Gradient',
15 | ),
16 | array(
17 | 'value' => 'all',
18 | 'label' => 'All',
19 | ),
20 | );
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Page/Menu.php:
--------------------------------------------------------------------------------
1 | _buildMenuArray();
9 | return $this->_addCloudinaryMediaLibraryUrlToMenu($menuArray);
10 | }
11 |
12 | private function _addCloudinaryMediaLibraryUrlToMenu($menuArray)
13 | {
14 | $menuArray['cloudinary_cloudinary']['children']['console']['click'] = sprintf(
15 | "window.open('%s')",
16 | Mage::helper('cloudinary_cloudinary/console')->getMediaLibraryUrl()
17 | );
18 | return $menuArray;
19 | }
20 |
21 | }
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/phpcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | cloudinary_php coding standard
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | src
22 | tests
23 |
24 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Credentials.php:
--------------------------------------------------------------------------------
1 | key = $key;
18 | $this->secret = $secret;
19 | }
20 |
21 | public static function fromKeyAndSecret(Key $key,Secret $secret)
22 | {
23 | return new Credentials($key, $secret);
24 | }
25 |
26 | public function getKey()
27 | {
28 | return $this->key;
29 | }
30 |
31 | public function getSecret()
32 | {
33 | return $this->secret;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/modman:
--------------------------------------------------------------------------------
1 | app/code/community/Cloudinary/Cloudinary app/code/community/Cloudinary/Cloudinary
2 | app/design/adminhtml/default/default/layout/cloudinary app/design/adminhtml/default/default/layout/cloudinary
3 | app/design/adminhtml/default/default/template/cloudinary app/design/adminhtml/default/default/template/cloudinary
4 | app/design/frontend/base/default/layout/cloudinary app/design/frontend/base/default/layout/cloudinary
5 | app/design/frontend/base/default/template/cloudinary app/design/frontend/base/default/template/cloudinary
6 | app/etc/modules/Cloudinary_Cloudinary.xml app/etc/modules/Cloudinary_Cloudinary.xml
7 | js/cloudinary js/cloudinary
8 | lib/CloudinaryExtension lib/CloudinaryExtension
9 | skin/adminhtml/default/default/images/cloudinary skin/adminhtml/default/default/images/cloudinary
10 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Source/ProductGallery/CarouselLocation.php:
--------------------------------------------------------------------------------
1 | 'top',
10 | 'label' => 'Top',
11 | ),
12 | array(
13 | 'value' => 'right',
14 | 'label' => 'Right',
15 | ),
16 | array(
17 | 'value' => 'left',
18 | 'label' => 'Left',
19 | ),
20 | array(
21 | 'value' => 'bottom',
22 | 'label' => 'Bottom',
23 | ),
24 | );
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Reset/Edit.php:
--------------------------------------------------------------------------------
1 | _blockGroup = 'cloudinary_cloudinary';
10 | $this->_controller = 'adminhtml_reset';
11 | $this->_headerText = Mage::helper('cloudinary_cloudinary')->__('Reset all Cloudinary module data');
12 | $this->setTemplate('cloudinary/reset.phtml');
13 |
14 | $this->updateButton('save', 'label', 'Reset all Cloudinary data');
15 | $this->updateButton('save', 'area', 'footer');
16 | $this->updateButton('save', 'onclick', 'openCloudinaryResetConfirmation();');
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Source/ProductGallery/ZoomViewerPosition.php:
--------------------------------------------------------------------------------
1 | 'top',
10 | 'label' => 'Top',
11 | ),
12 | array(
13 | 'value' => 'right',
14 | 'label' => 'Right',
15 | ),
16 | array(
17 | 'value' => 'left',
18 | 'label' => 'Left',
19 | ),
20 | array(
21 | 'value' => 'bottom',
22 | 'label' => 'Bottom',
23 | ),
24 | );
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Source/ProductGallery/ThumbnailsMediaSymbolShape.php:
--------------------------------------------------------------------------------
1 | 'none',
10 | 'label' => 'None',
11 | ),
12 | array(
13 | 'value' => 'round',
14 | 'label' => 'Round',
15 | ),
16 | array(
17 | 'value' => 'square',
18 | 'label' => 'Square',
19 | ),
20 | array(
21 | 'value' => 'radius',
22 | 'label' => 'Radius',
23 | ),
24 | );
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Image/Transformation/Freeform.php:
--------------------------------------------------------------------------------
1 | urlParameters = $urlParameters;
19 | }
20 |
21 | /**
22 | * @param string $value
23 | * @return Freeform
24 | */
25 | public static function fromString($value)
26 | {
27 | return new Freeform($value);
28 | }
29 |
30 | /**
31 | * @return string
32 | */
33 | public function __toString()
34 | {
35 | return $this->urlParameters;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Helper/Data.php:
--------------------------------------------------------------------------------
1 | $httpCode,
19 | "body" => $result,
20 | "error" => $err
21 | )
22 | );
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Helper/Cron.php:
--------------------------------------------------------------------------------
1 | isInitialising($migration) && ($migration->timeElapsed() > $cronIntervalInSeconds));
13 | }
14 |
15 | /**
16 | * @param Cloudinary_Cloudinary_Model_Migration $migration
17 | * @return bool
18 | */
19 | public function isInitialising(Cloudinary_Cloudinary_Model_Migration $migration)
20 | {
21 | return $migration->hasStarted() && !$migration->hasProgress();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-2.7.0-2.8.0.php:
--------------------------------------------------------------------------------
1 | startSetup();
6 |
7 | $table = $installer->getConnection()
8 | ->newTable($installer->getTable('cloudinary_cloudinary/transformation'))
9 | ->addColumn(
10 | 'image_name',
11 | Varien_Db_Ddl_Table::TYPE_VARCHAR,
12 | 255,
13 | array(
14 | 'nullable' => false,
15 | 'primary' => true
16 | ),
17 | 'Relative image path'
18 | )
19 | ->addColumn(
20 | 'free_transformation',
21 | Varien_Db_Ddl_Table::TYPE_VARCHAR,
22 | 255,
23 | array(),
24 | 'Free transformation'
25 | );
26 |
27 | $installer->getConnection()->createTable($table);
28 |
29 | $installer->endSetup();
30 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/ConfigurationBuilder.php:
--------------------------------------------------------------------------------
1 | configuration = $configuration;
15 | }
16 |
17 | public function build()
18 | {
19 | $config = [
20 | "cloud_name" => (string)$this->configuration->getCloud(),
21 | "api_key" => (string)$this->configuration->getCredentials()->getKey(),
22 | "api_secret" => (string)$this->configuration->getCredentials()->getSecret()
23 | ];
24 |
25 | if ($this->configuration->getCdnSubdomainStatus()) {
26 | $config['cdn_subdomain'] = true;
27 | }
28 | return $config;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Catalog/Product/Edit/Tab.php:
--------------------------------------------------------------------------------
1 | __('Cloudinary');
13 | }
14 |
15 | public function getTabTitle()
16 | {
17 | return $this->__('Cloudinary');
18 | }
19 |
20 | public function isHidden()
21 | {
22 | return false;
23 | }
24 |
25 | public function getTabUrl()
26 | {
27 | return $this->getUrl('*/cloudinaryproduct/gallery', array('_current' => true));
28 | }
29 |
30 | public function getTabClass()
31 | {
32 | return 'ajax';
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-1.1.4-1.1.5.php:
--------------------------------------------------------------------------------
1 | startSetup();
6 |
7 | $table = $installer->getConnection()
8 | ->newTable($installer->getTable('cloudinary_cloudinary/migrationError'))
9 | ->addColumn(
10 | 'file_path', Varien_Db_Ddl_Table::TYPE_BINARY, 255, array(
11 | 'primary' => true,
12 | 'nullable' => false
13 | ), 'File path'
14 | )
15 | ->addColumn('message', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255)
16 | ->addColumn('code', Varien_Db_Ddl_Table::TYPE_INTEGER, null)
17 | ->addColumn('relative_path', Varien_Db_Ddl_Table::TYPE_BINARY, 255)
18 | ->addColumn('timestamp', Varien_Db_Ddl_Table::TYPE_DATETIME, null);
19 |
20 | $installer->getConnection()->createTable($table);
21 |
22 | $installer->endSetup();
23 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/System/Config/Form/Free.php:
--------------------------------------------------------------------------------
1 | setTemplate('cloudinary/system/config/free.phtml');
9 | }
10 |
11 | public function ajaxSampleSecretKey()
12 | {
13 | return Mage::getModel('adminhtml/url')->getSecretKey('cloudinaryajax', 'sample');
14 | }
15 |
16 | /**
17 | * Get the button and scripts contents
18 | *
19 | * @param Varien_Data_Form_Element_Abstract $element
20 | * @return string
21 | */
22 | protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
23 | {
24 | return sprintf('%s%s', $element->getElementHtml(), $this->_toHtml());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-0.1.0-0.1.1.php:
--------------------------------------------------------------------------------
1 | startSetup();
6 |
7 | $table = $installer->getConnection()
8 | ->newTable($installer->getTable('cloudinary_cloudinary/migration'))
9 | ->addColumn(
10 | 'cloudinary_migration_id', Varien_Db_Ddl_Table::TYPE_TINYINT, null, array(
11 | 'unsigned' => true,
12 | 'nullable' => false,
13 | 'primary' => true,
14 | 'default' => 1
15 | ), 'Cloudinary Migration ID'
16 | )
17 | ->addColumn(
18 | 'started', Varien_Db_Ddl_Table::TYPE_TINYINT, null, array(
19 | 'unsigned' => true,
20 | 'nullable' => false,
21 | 'default' => 0,
22 | ), 'Migration Started'
23 | );
24 |
25 | $installer->getConnection()->createTable($table);
26 |
27 | $installer->endSetup();
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-2.0.0-2.1.0.php:
--------------------------------------------------------------------------------
1 | startSetup();
7 |
8 | $conn = $installer->getConnection();
9 | $table = $installer->getTable('cloudinary_cloudinary/migration');
10 |
11 | $conn->addColumn(
12 | $table,
13 | 'started_at',
14 | array(
15 | 'type' => Varien_Db_Ddl_Table::TYPE_DATETIME,
16 | 'comment' => 'The time the migration started',
17 | 'nullable' => true,
18 | 'default' => '0000-00-00 00:00:00'
19 | )
20 | );
21 |
22 | $conn->addColumn(
23 | $table,
24 | 'batch_count',
25 | array(
26 | 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
27 | 'comment' => 'Batches run for current migration',
28 | 'nullable' => false,
29 | 'default' => 0
30 | )
31 | );
32 |
33 | $installer->endSetup();
34 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/src/Api/Response.php:
--------------------------------------------------------------------------------
1 | rate_limit_reset_at = strtotime($response->headers["X-FeatureRateLimit-Reset"]);
23 | $this->rate_limit_allowed = intval($response->headers["X-FeatureRateLimit-Limit"]);
24 | $this->rate_limit_remaining = intval($response->headers["X-FeatureRateLimit-Remaining"]);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Source/ProductGallery/ThumbnailsNavigationShape.php:
--------------------------------------------------------------------------------
1 | 'none',
10 | 'label' => 'None',
11 | ),
12 | array(
13 | 'value' => 'round',
14 | 'label' => 'Round',
15 | ),
16 | array(
17 | 'value' => 'square',
18 | 'label' => 'Square',
19 | ),
20 | array(
21 | 'value' => 'radius',
22 | 'label' => 'Radius',
23 | ),
24 | array(
25 | 'value' => 'rectangle',
26 | 'label' => 'Rectangle',
27 | ),
28 | );
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/System/Config/Signup.php:
--------------------------------------------------------------------------------
1 | setTemplate('cloudinary/system/config/signup.phtml');
12 | parent::_construct();
13 | }
14 |
15 | public function render(Varien_Data_Form_Element_Abstract $element)
16 | {
17 | if (!$this->_environmentVariableIsPresentInConfig()) {
18 | return $this->toHtml();
19 | }
20 | }
21 |
22 | private function _environmentVariableIsPresentInConfig()
23 | {
24 | return Mage::helper('core')->decrypt(
25 | Mage::getStoreConfig(Configuration::CONFIG_PATH_ENVIRONMENT_VARIABLE)
26 | );
27 | }
28 | }
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Helper/Config.php:
--------------------------------------------------------------------------------
1 | doFlatten($key, $value, $output);
15 |
16 | return $output;
17 | }
18 |
19 | /**
20 | * @param string $key
21 | * @param array|string $value
22 | * @param array $output
23 | */
24 | private function doFlatten($key, $value, array &$output)
25 | {
26 | if (is_array($value)) {
27 | foreach ($value as $childKey => $childValue) {
28 | $this->doFlatten(sprintf('%s/%s', $key, $childKey), $childValue, $output);
29 | }
30 | } else {
31 | $output[substr($key, 0, -6)] = $value;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-2.9.6-2.9.7.php:
--------------------------------------------------------------------------------
1 | startSetup();
6 |
7 | $installer->addAttribute(
8 | 'catalog_product', 'cloudinary_data', array(
9 | 'group' => 'General',
10 | 'label' => 'Cloudinary Data',
11 | 'input' => 'text',
12 | 'type' => 'text',
13 | 'required' => 0,
14 | 'visible_on_front' => 0,
15 | 'filterable' => 0,
16 | 'searchable' => 0,
17 | 'comparable' => 0,
18 | 'user_defined' => 0,
19 | 'is_configurable' => 0,
20 | 'used_in_product_listing' => '1',
21 | 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
22 | 'note' => '',
23 | )
24 | );
25 |
26 | $installer->endSetup();
27 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Cms/Synchronisation.php:
--------------------------------------------------------------------------------
1 | _init('cloudinary_cloudinary/synchronisation');
13 | }
14 |
15 | public function getFilename()
16 | {
17 | return $this->getData('filename');
18 | }
19 |
20 | public function getRelativePath()
21 | {
22 | return Mage::getModel('cloudinary_cloudinary/configuration')->getMigratedPath($this->getFilename());
23 | }
24 |
25 | public function tagAsSynchronized()
26 | {
27 | $this->setData('media_gallery_id', null);
28 | $this->setData('cloudinary_synchronisation_id', null);
29 | $this->setData('image_name', $this->getRelativePath());
30 |
31 | $this->save();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
16 |
17 |
18 |
19 | tests
20 |
21 |
22 |
23 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Security/SignedConsoleUrl.php:
--------------------------------------------------------------------------------
1 | time(), "mode" => "check");
15 | $params["signature"] = (string)ApiSignature::fromSecretAndParams($credentials->getSecret(), $params);
16 | $params["api_key"] = (string)$credentials->getKey();
17 | $query = http_build_query($params);
18 |
19 | $this->signedConsoleUrl = (string)$url . '?' . $query;
20 | }
21 |
22 | public static function fromConsoleUrlAndCredentials(ConsoleUrl $url, Credentials $credentials)
23 | {
24 | return new SignedConsoleUrl($url, $credentials);
25 | }
26 |
27 | public function __toString()
28 | {
29 | return $this->signedConsoleUrl;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Image/Transformation/Crop.php:
--------------------------------------------------------------------------------
1 | value = $value;
17 | }
18 |
19 | public static function fromString($value)
20 | {
21 | return new Crop($value);
22 | }
23 |
24 | public static function pad()
25 | {
26 | return new Crop(self::PAD);
27 | }
28 |
29 | public static function lpad()
30 | {
31 | return new Crop(self::LPAD);
32 | }
33 |
34 | public static function fit()
35 | {
36 | return new Crop(self::FIT);
37 | }
38 |
39 | public static function limit()
40 | {
41 | return new Crop(self::LIMIT);
42 | }
43 |
44 | public function __toString()
45 | {
46 | return $this->value;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright 2018 Cloudinary
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Log.php:
--------------------------------------------------------------------------------
1 | _blockGroup = 'cloudinary_cloudinary';
8 | $this->_controller = 'adminhtml_log';
9 | $this->_headerText = Mage::helper('cloudinary_cloudinary')->__('Logs');
10 |
11 | parent::__construct();
12 | }
13 |
14 | /**
15 | * @param int $bytes
16 | * @param int $precision
17 | * @return string
18 | */
19 | public function formatBytes($bytes, $precision = 2)
20 | {
21 | if ($bytes <= 0) {
22 | return '0 Bytes';
23 | }
24 |
25 | $base = log((int)$bytes, 1024);
26 | $suffixes = array('Bytes', 'KB', 'MB', 'GB', 'TB');
27 |
28 | return sprintf(
29 | '%s %s',
30 | round(pow(1024, $base - floor($base)), $precision),
31 | $suffixes[floor($base)]
32 | );
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Reset/Edit/Form.php:
--------------------------------------------------------------------------------
1 | 'edit_form',
13 | 'action' => $this->getUrl('*/*/save'),
14 | 'method' => 'post',
15 | )
16 | );
17 |
18 | $form->setUseContainer(true);
19 | $this->setForm($form);
20 |
21 | $fieldset = $form->addFieldset('display', array('class' => 'fieldset-wide'));
22 |
23 | $fieldset->addField(
24 | 'password', 'password', array(
25 | 'name' => 'password',
26 | 'label' => Mage::helper('cloudinary_cloudinary')->__('Enter your admin password to confirm reset')
27 | )
28 | );
29 |
30 | return parent::_prepareForm();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Cache.php:
--------------------------------------------------------------------------------
1 | mageCache = Mage::app()->getCacheInstance();
13 | }
14 |
15 | public function isEnabled()
16 | {
17 | return $this->mageCache->canUse(self::CACHE_NAME);
18 | }
19 |
20 | public function saveCache($key, $value)
21 | {
22 | $this->mageCache->save($value, $key, array(self::CACHE_TAG));
23 | }
24 |
25 | public function loadCache($key, callable $uncachedCall = null)
26 | {
27 | $value = $this->isEnabled()
28 | ? $this->mageCache->load($key)
29 | : false;
30 |
31 | if ($value === false && !is_null($uncachedCall)) {
32 | $value = $uncachedCall();
33 | $this->saveCache($key, $value);
34 | }
35 |
36 | return $value;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Catalog/Product/Image.php:
--------------------------------------------------------------------------------
1 | _imageFactory = new ImageFactory(
17 | Mage::getModel('cloudinary_cloudinary/configuration'),
18 | Mage::getModel('cloudinary_cloudinary/synchronizationChecker')
19 | );
20 |
21 | return parent::__construct();
22 | }
23 |
24 | public function getUrl()
25 | {
26 | return (string) $this->_imageFactory->build(
27 | $this->_newFile,
28 | function () {
29 | return parent::getUrl();
30 | }
31 | );
32 | }
33 |
34 | public function getKeepFrameState()
35 | {
36 | return $this->_keepFrame;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Exception/MigrationError.php:
--------------------------------------------------------------------------------
1 | message = sprintf('%s%s', $this->message, $suffix);
27 | }
28 |
29 | /**
30 | * @return Image
31 | */
32 | public function getImage()
33 | {
34 | return $this->image;
35 | }
36 |
37 | /**
38 | * @param Image $image
39 | * @param string $message
40 | * @throws MigrationError
41 | */
42 | public static function throwWith(Image $image, $message = '')
43 | {
44 | $exception = new static($message ?: static::DEFAULT_MESSAGE);
45 | $exception->image = $image;
46 | throw $exception;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "cloudinary/cloudinary_php",
3 | "version": "1.16.0",
4 | "description": "Cloudinary PHP SDK",
5 | "keywords": ["cloudinary", "sdk", "cloud", "image management", "cdn"],
6 | "type": "library",
7 | "homepage": "https://github.com/cloudinary/cloudinary_php",
8 | "license": "MIT",
9 | "authors": [
10 | {
11 | "name": "Cloudinary",
12 | "homepage": "https://github.com/cloudinary/cloudinary_php/graphs/contributors"
13 | }
14 | ],
15 | "require": {
16 | "php": ">=5.4.0",
17 | "ext-curl": "*",
18 | "ext-json": "*"
19 | },
20 | "require-dev": {
21 | "phpunit/phpunit": "4.8.*"
22 | },
23 | "support": {
24 | "email": "info@cloudinary.com",
25 | "issues": "https://github.com/cloudinary/cloudinary_php/issues"
26 | },
27 | "autoload": {
28 | "classmap": ["src"],
29 | "files": ["src/Helpers.php"]
30 | },
31 | "autoload-dev": {
32 | "psr-4": { "Cloudinary\\Test\\": "tests/" },
33 | "files": ["tests/TestHelper.php"]
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/composer/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Copyright (c) Nils Adermann, Jordi Boggiano
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is furnished
9 | to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 |
22 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Cloudinary
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Source/ProductGallery/ThumbnailsSelectedBorderPosition.php:
--------------------------------------------------------------------------------
1 | 'top',
10 | 'label' => 'Top',
11 | ),
12 | array(
13 | 'value' => 'bottom',
14 | 'label' => 'Bottom',
15 | ),
16 | array(
17 | 'value' => 'left',
18 | 'label' => 'Left',
19 | ),
20 | array(
21 | 'value' => 'right',
22 | 'label' => 'Right',
23 | ),
24 | array(
25 | 'value' => 'top-bottom',
26 | 'label' => 'Top-Bottom',
27 | ),
28 | array(
29 | 'value' => 'left-right',
30 | 'label' => 'Left-Right',
31 | ),
32 | array(
33 | 'value' => 'all',
34 | 'label' => 'All',
35 | ),
36 | );
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/samples/PhotoAlbum/upload_complete.php:
--------------------------------------------------------------------------------
1 | $_POST['public_id'],
13 | 'version' => $_POST['version'],
14 | );
15 |
16 | $calculated_signature = \Cloudinary::api_sign_request($to_sign, $api_secret);
17 |
18 | if ($existing_signature == $calculated_signature) {
19 | # Create a model record using the data received (best practice is to save locally
20 | # only data needed for reaching the image on Cloudinary - public_id and version;
21 | # and fields that might be needed for your application (e.g.,), width, height)
22 | \PhotoAlbum\create_photo_model($_POST);
23 | } else {
24 | error_log("Received signature verification failed (" .
25 | $existing_signature . " != " . $calculated_signature . "). data: " .
26 | \PhotoAlbum\ret_var_dump($_POST));
27 | }
28 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/src/Cache/Storage/KeyValueStorage.php:
--------------------------------------------------------------------------------
1 | _init('cloudinary_cloudinary/synchronisation');
11 | }
12 |
13 | public function tagAsSynchronized()
14 | {
15 | $this->setData('image_name', $this->getRelativePath());
16 | $this->setData('media_gallery_id', $this['value_id']);
17 | $this->setData('media_gallery_value', $this['value']);
18 | $this->unsetData('value_id');
19 |
20 | $this->save();
21 | }
22 |
23 | public function getFilename()
24 | {
25 | if (!$this->getValue()) {
26 | return null;
27 | }
28 |
29 | return $this->_baseMediaPath() . $this->getValue();
30 | }
31 |
32 |
33 | public function getRelativePath()
34 | {
35 | return Mage::getModel('cloudinary_cloudinary/configuration')
36 | ->getMigratedPath($this->getFilename());
37 | }
38 |
39 | private function _baseMediaPath()
40 | {
41 | return Mage::getModel('catalog/product_media_config')->getBaseMediaPath();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/install-0.1.0.php:
--------------------------------------------------------------------------------
1 | startSetup();
6 |
7 | $table = $installer->getConnection()
8 | ->newTable($installer->getTable('cloudinary_cloudinary/synchronisation'))
9 | ->addColumn(
10 | 'cloudinary_synchronisation_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
11 | 'identity' => true,
12 | 'unsigned' => true,
13 | 'nullable' => false,
14 | 'primary' => true,
15 | ), 'Cloudinary Synchronisation ID'
16 | )
17 | ->addColumn(
18 | 'media_gallery_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
19 | 'unsigned' => true,
20 | 'nullable' => true,
21 | 'default' => null,
22 | ), 'Media Gallery ID'
23 | )
24 | ->addColumn('image_name', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255)
25 | ->addForeignKey(
26 | 'FK_MEDIA_GALLERY_ID_VALUE_ID',
27 | 'media_gallery_id',
28 | $installer->getTable('catalog_product_entity_media_gallery'),
29 | 'value_id',
30 | Varien_Db_Ddl_Table::ACTION_CASCADE,
31 | Varien_Db_Ddl_Table::ACTION_CASCADE
32 | );
33 | $installer->getConnection()->createTable($table);
34 |
35 | $installer->endSetup();
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/tests/Cache/Storage/DummyCacheStorage.php:
--------------------------------------------------------------------------------
1 | width = is_null($width) ? null : (int) round($width);
14 | $this->height = is_null($height) ? null : (int) round($height);
15 | }
16 |
17 | public function getWidth()
18 | {
19 | return $this->width;
20 | }
21 |
22 | public function getHeight()
23 | {
24 | return $this->height;
25 | }
26 |
27 | public static function square($length)
28 | {
29 | return new Dimensions($length, $length);
30 | }
31 |
32 | public static function squareMissingDimension(Dimensions $dimensions)
33 | {
34 | if (!$dimensions->getWidth()) {
35 | return Dimensions::square($dimensions->getHeight());
36 | } else if (!$dimensions->getHeight()) {
37 | return Dimensions::square($dimensions->getWidth());
38 | }
39 | return $dimensions;
40 | }
41 |
42 | public static function fromWidthAndHeight($width, $height)
43 | {
44 | return new Dimensions($width, $height);
45 | }
46 |
47 | public static function null()
48 | {
49 | return new Dimensions(null, null);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/ConfigurationInterface.php:
--------------------------------------------------------------------------------
1 | migrationTask = $migrationTask;
26 | $this->synchronizedMediaRepository = $synchronizedMediaRepository;
27 | $this->logger = $logger;
28 | $this->batchUploader = $batchUploader;
29 | }
30 |
31 | public function process()
32 | {
33 | if ($this->migrationTask->hasBeenStopped()) {
34 | return;
35 | }
36 |
37 | $images = $this->synchronizedMediaRepository->findUnsynchronisedImages();
38 |
39 | if (!$images) {
40 | $this->logger->notice(self::MESSAGE_COMPLETE);
41 | $this->migrationTask->stop();
42 | } else {
43 | $this->logger->notice(self::MESSAGE_PROCESSING);
44 | $this->batchUploader->uploadImages($images);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/samples/PhotoAlbum/upload_backend.php:
--------------------------------------------------------------------------------
1 | "backend_photo_album",
9 | "public_id" => $orig_name,
10 | ));
11 |
12 | unlink($file_path);
13 | error_log("Upload result: " . \PhotoAlbum\ret_var_dump($result));
14 | \PhotoAlbum\create_photo_model($result);
15 | return $result;
16 | }
17 |
18 | $files = $_FILES["files"];
19 | $files = is_array($files) ? $files : array( $files );
20 | $files_data = array();
21 | foreach ($files["tmp_name"] as $index => $value) {
22 | array_push($files_data, create_photo($value, $files["name"][$index]));
23 | }
24 |
25 | ?>
26 |
27 |
28 |
29 | Upload succeeded!
30 |
31 |
32 |
33 | Your photo has been uploaded sucessfully!
34 | Upload details:
35 |
40 |
41 | "fill" ))); ?>
42 |
43 | Back to list...
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/tests/CloudinaryFieldTest.php:
--------------------------------------------------------------------------------
1 | "test123",
20 | "secure_distribution" => null,
21 | "private_cdn" => false,
22 | "cname" => null));
23 | }
24 |
25 | public function testCloudinaryUrlFromCloudinaryField()
26 | {
27 | // [/][/][v/][.][#]
28 |
29 | // should use cloud_name from config
30 | $result = Cloudinary::cloudinary_url(new CloudinaryField('test'));
31 | $this->assertEquals('http://res.cloudinary.com/test123/image/upload/test', $result);
32 |
33 | // should ignore signature
34 | $result = Cloudinary::cloudinary_url(new CloudinaryField('test#signature'));
35 | $this->assertEquals('http://res.cloudinary.com/test123/image/upload/test', $result);
36 |
37 | $result = Cloudinary::cloudinary_url(new CloudinaryField('rss/imgt/v123/test.jpg'));
38 | $this->assertEquals('http://res.cloudinary.com/test123/rss/imgt/v123/test.jpg', $result);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Image/ImageFactory.php:
--------------------------------------------------------------------------------
1 | configuration = $configuration;
29 | $this->synchronizationChecker = $synchronizationChecker;
30 | }
31 |
32 | /**
33 | * @param $imagePath
34 | * @return Image
35 | */
36 | public function build($imagePath, callable $localPathGenerator)
37 | {
38 | $migratedPath = $this->configuration->getMigratedPath($imagePath);
39 |
40 | if ($this->configuration->isEnabled() && $this->synchronizationChecker->isSynchronized($migratedPath)) {
41 | return Image::fromPath($imagePath, $migratedPath);
42 | } else {
43 | return new LocalImage($localPathGenerator);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Security/CloudinaryEnvironmentVariable.php:
--------------------------------------------------------------------------------
1 | environmentVariable = (string)$environmentVariable;
17 | try {
18 | Cloudinary::config_from_url(str_replace('CLOUDINARY_URL=', '', $environmentVariable));
19 | } catch (\Exception $e){
20 | throw new \CloudinaryExtension\Exception\InvalidCredentials('Cloudinary config creation from environment variable failed');
21 | }
22 | }
23 |
24 | public static function fromString($environmentVariable)
25 | {
26 | return new CloudinaryEnvironmentVariable($environmentVariable);
27 | }
28 |
29 | public function getCloud()
30 | {
31 | return Cloud::fromName(Cloudinary::config_get('cloud_name'));
32 | }
33 |
34 | public function getCredentials()
35 | {
36 | return Credentials::fromKeyAndSecret(
37 | Key::fromString(Cloudinary::config_get('api_key')),
38 | Secret::fromString(Cloudinary::config_get('api_secret'))
39 | );
40 | }
41 |
42 | public function __toString()
43 | {
44 | return $this->environmentVariable;
45 | }
46 |
47 | }
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/ValidateRemoteUrlRequest.php:
--------------------------------------------------------------------------------
1 | curlHandler = curl_init($url);
13 | $this->setCurlOptions();
14 | }
15 |
16 | public function validate()
17 | {
18 | $result = $this->execute();
19 |
20 | if ($result->responseCode == 200 && is_null($result->error)) {
21 | return true;
22 | }
23 | return false;
24 | }
25 |
26 | private function execute()
27 | {
28 | curl_exec($this->curlHandler);
29 |
30 | $result = new \stdClass();
31 | $result->responseCode = $this->getResponseCode();
32 | $result->error = $this->getErrorMessage();
33 |
34 | curl_close($this->curlHandler);
35 |
36 | return $result;
37 | }
38 |
39 | private function getResponseCode()
40 | {
41 | return curl_getinfo($this->curlHandler, CURLINFO_HTTP_CODE);
42 | }
43 |
44 | private function getErrorMessage()
45 | {
46 | return curl_errno($this->curlHandler) ? curl_error($this->curlHandler) : null;
47 | }
48 |
49 | private function setCurlOptions()
50 | {
51 | curl_setopt($this->curlHandler, CURLOPT_HEADER, 1);
52 | curl_setopt($this->curlHandler, CURLOPT_FAILONERROR, 1);
53 | curl_setopt($this->curlHandler, CURLOPT_RETURNTRANSFER, 1);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Cms/Uploader.php:
--------------------------------------------------------------------------------
1 | isEnabled() && !empty($result['path']) && !empty($result['file'])) {
17 | $imageProvider = CloudinaryImageProvider::fromConfiguration($configuration);
18 |
19 | $fullPath = rtrim($result['path'], '/') . DIRECTORY_SEPARATOR . $result['file'];
20 | $relativePath = $configuration->isFolderedMigration() ? $configuration->getMigratedPath($fullPath) : '';
21 |
22 | $image = Image::fromPath($fullPath, $relativePath);
23 | $imageProvider->upload($image);
24 |
25 | Mage::getModel('cloudinary_cloudinary/logger')->notice(sprintf(self::UPLOAD_MESSAGE, $relativePath));
26 |
27 | $this->_trackSynchronisation((string)$image);
28 | }
29 |
30 | return $this;
31 | }
32 |
33 | private function _trackSynchronisation($fileName)
34 | {
35 | Mage::getModel('cloudinary_cloudinary/cms_synchronisation')
36 | ->setFilename($fileName)
37 | ->tagAsSynchronized();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/design/adminhtml/default/default/template/cloudinary/log.phtml:
--------------------------------------------------------------------------------
1 | formatBytes($logSizeInBytes);
4 |
5 | ?>
6 |
7 |
16 |
17 |
18 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | | Cloudinary logging enabled |
28 | |
29 |
30 |
31 |
32 | | Cloudinary logfile name |
33 | |
34 |
35 |
36 |
37 | | Cloudinary logfile size |
38 | |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
50 |
51 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Source/Dropdown/Gravity.php:
--------------------------------------------------------------------------------
1 | '',
10 | 'label' => 'Magento\'s Default',
11 | ),
12 | array(
13 | 'value' => 'north_west',
14 | 'label' => 'North West',
15 | ),
16 | array(
17 | 'value' => 'north',
18 | 'label' => 'North',
19 | ),
20 | array(
21 | 'value' => 'north_east',
22 | 'label' => 'North East',
23 | ),
24 | array(
25 | 'value' => 'east',
26 | 'label' => 'East',
27 | ),
28 | array(
29 | 'value' => 'center',
30 | 'label' => 'Center',
31 | ),
32 | array(
33 | 'value' => 'west',
34 | 'label' => 'West',
35 | ),
36 | array(
37 | 'value' => 'south_west',
38 | 'label' => 'South West',
39 | ),
40 | array(
41 | 'value' => 'south',
42 | 'label' => 'South',
43 | ),
44 | array(
45 | 'value' => 'south_east',
46 | 'label' => 'South East',
47 | ),
48 | );
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Source/Dropdown/Quality.php:
--------------------------------------------------------------------------------
1 | '',
10 | 'label' => 'Magento\'s Default',
11 | ),
12 | array(
13 | 'value' => '20',
14 | 'label' => '20%',
15 | ),
16 | array(
17 | 'value' => '30',
18 | 'label' => '30%',
19 | ),
20 | array(
21 | 'value' => '40',
22 | 'label' => '40%',
23 | ),
24 | array(
25 | 'value' => '50',
26 | 'label' => '50%',
27 | ),
28 | array(
29 | 'value' => '60',
30 | 'label' => '60%',
31 | ),
32 | array(
33 | 'value' => '70',
34 | 'label' => '70%',
35 | ),
36 | array(
37 | 'value' => '80',
38 | 'label' => '80%',
39 | ),
40 | array(
41 | 'value' => '90',
42 | 'label' => '90%',
43 | ),
44 | array(
45 | 'value' => '100',
46 | 'label' => '100%',
47 | ),
48 | array(
49 | 'value' => 'auto',
50 | 'label' => 'Auto',
51 | ),
52 | );
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Cms/Template/Filter.php:
--------------------------------------------------------------------------------
1 | imageFactory = new ImageFactory(
17 | $configuration,
18 | Mage::getModel('cloudinary_cloudinary/synchronizationChecker')
19 | );
20 |
21 | $this->urlGenerator = new UrlGenerator(
22 | $configuration,
23 | CloudinaryImageProvider::fromConfiguration($configuration)
24 | );
25 |
26 | parent::__construct();
27 | }
28 |
29 | public function mediaDirective($construction)
30 | {
31 | $imagePath = $this->getImagePath($construction[2]);
32 |
33 | $image = $this->imageFactory->build(
34 | $imagePath,
35 | function() use($construction) {
36 | return parent::mediaDirective($construction);
37 | }
38 | );
39 |
40 | return $this->urlGenerator->generateFor($image);
41 | }
42 |
43 | private function getImagePath($directiveParams)
44 | {
45 | $params = $this->_getIncludeParameters($directiveParams);
46 | return $params['url'];
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/UploadConfig.php:
--------------------------------------------------------------------------------
1 | useFilename = $useFilename;
32 | $this->uniqueFilename = $uniqueFilename;
33 | $this->overwrite = $overwrite;
34 | }
35 |
36 | public static function fromBooleanValues($useFilename, $uniqueFilename, $overwrite)
37 | {
38 | return new UploadConfig($useFilename, $uniqueFilename, $overwrite);
39 | }
40 |
41 | /**
42 | * @return boolean
43 | */
44 | public function useFilename()
45 | {
46 | return $this->useFilename;
47 | }
48 |
49 | /**
50 | * @return boolean
51 | */
52 | public function uniqueFilename()
53 | {
54 | return $this->uniqueFilename;
55 | }
56 |
57 | /**
58 | * @return boolean
59 | */
60 | public function overwrite()
61 | {
62 | return $this->overwrite;
63 | }
64 |
65 | public function toArray()
66 | {
67 | return [
68 | "use_filename" => $this->useFilename,
69 | "unique_filename" => $this->uniqueFilename,
70 | "overwrite" => $this->overwrite,
71 | ] ;
72 | }
73 | }
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Image.php:
--------------------------------------------------------------------------------
1 | imagePath = $imagePath;
16 | $this->relativePath = $relativePath;
17 | $this->pathInfo = pathinfo($this->imagePath);
18 | }
19 |
20 | public static function fromPath($imagePath, $relativePath = '')
21 | {
22 | return new Image($imagePath, $relativePath);
23 | }
24 |
25 | public function __toString()
26 | {
27 | return $this->imagePath;
28 | }
29 |
30 | public function getRelativePath()
31 | {
32 | return $this->relativePath;
33 | }
34 |
35 | public function getRelativeFolder()
36 | {
37 | $result = dirname($this->getRelativePath());
38 | return $result == '.' ? '' : $result;
39 | }
40 |
41 | public function getId()
42 | {
43 | return sprintf(
44 | '%s%s',
45 | $this->relativePath ? ($this->getRelativeFolder() . DIRECTORY_SEPARATOR) : '',
46 | $this->pathInfo['basename']
47 | );
48 | }
49 |
50 | public function getIdWithoutExtension()
51 | {
52 | return sprintf(
53 | '%s%s',
54 | $this->relativePath ? ($this->getRelativeFolder() . DIRECTORY_SEPARATOR) : '',
55 | $this->pathInfo['filename']
56 | );
57 | }
58 |
59 | public function getExtension()
60 | {
61 | return $this->pathInfo['extension'];
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/tests/ConfigTest.php:
--------------------------------------------------------------------------------
1 | assertArrayHasKey('foo', \Cloudinary::config());
14 | $this->assertArrayHasKey('bar', \Cloudinary::config()['foo']);
15 | $this->assertEquals('value', \Cloudinary::config()['foo']['bar']);
16 | }
17 |
18 | public function test_cloudinary_url_valid_scheme()
19 | {
20 | $cloudinary_url = 'cloudinary://123456789012345:ALKJdjklLJAjhkKJ45hBK92baj3@test';
21 |
22 | \Cloudinary::config_from_url($cloudinary_url);
23 | }
24 |
25 | public function test_cloudinary_url_invalid_scheme()
26 | {
27 | $cloudinary_urls = [
28 | 'CLOUDINARY_URL=cloudinary://123456789012345:ALKJdjklLJAjhkKJ45hBK92baj3@test',
29 | 'https://123456789012345:ALKJdjklLJAjhkKJ45hBK92baj3@test',
30 | '://123456789012345:ALKJdjklLJAjhkKJ45hBK92baj3@test',
31 | ' '
32 | ];
33 |
34 | foreach ($cloudinary_urls as $cloudinary_url) {
35 | try {
36 | \Cloudinary::config_from_url($cloudinary_url);
37 | $this->fail('InvalidArgumentException was not thrown');
38 | } catch (\InvalidArgumentException $e) {
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/src/CloudinaryField.php:
--------------------------------------------------------------------------------
1 | identifier = $identifier;
21 | }
22 |
23 | public function __toString()
24 | {
25 | return (string)explode('#', $this->identifier())[0];
26 | }
27 |
28 | public function identifier()
29 | {
30 | return $this->identifier;
31 | }
32 |
33 | public function url($options = array())
34 | {
35 | if (!$this->identifier) {
36 | // TODO: Error?
37 | return null;
38 | }
39 |
40 | return cloudinary_url($this, $options);
41 | }
42 |
43 | public function upload($file, $options = array())
44 | {
45 | $options['return_error'] = false;
46 | $ret = Uploader::upload($file, $options);
47 | $preloaded = new PreloadedFile(\Cloudinary::signed_preloaded_image($ret));
48 | $this->identifier = $preloaded->extended_identifier();
49 | }
50 |
51 | public function delete()
52 | {
53 | $options['return_error'] = false;
54 | Uploader::destroy($this->identifier);
55 | unset($this->identifier);
56 | }
57 |
58 | public function verify()
59 | {
60 | $preloaded = new PreloadedFile($this->identifier);
61 | return $preloaded->is_valid();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/System/Config/Source/ProductGallery/AspectRatio.php:
--------------------------------------------------------------------------------
1 | 'square',
10 | 'label' => 'Square',
11 | ),
12 | array(
13 | 'value' => '1:1',
14 | 'label' => '1:1',
15 | ),
16 | array(
17 | 'value' => '3:4',
18 | 'label' => '3:4',
19 | ),
20 | array(
21 | 'value' => '4:3',
22 | 'label' => '4:3',
23 | ),
24 | array(
25 | 'value' => '4:6',
26 | 'label' => '4:6',
27 | ),
28 | array(
29 | 'value' => '6:4',
30 | 'label' => '6:4',
31 | ),
32 | array(
33 | 'value' => '5:7',
34 | 'label' => '5:7',
35 | ),
36 | array(
37 | 'value' => '7:5',
38 | 'label' => '7:5',
39 | ),
40 | array(
41 | 'value' => '5:8',
42 | 'label' => '5:8',
43 | ),
44 | array(
45 | 'value' => '8:5',
46 | 'label' => '8:5',
47 | ),
48 | array(
49 | 'value' => '9:16',
50 | 'label' => '9:16',
51 | ),
52 | array(
53 | 'value' => '16:9',
54 | 'label' => '16:9',
55 | ),
56 | );
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Helper/Cms/Wysiwyg/Images.php:
--------------------------------------------------------------------------------
1 | isEnabled()) {
17 | return parent::getStorageRoot();
18 | }
19 |
20 | if (!$this->_storageRoot) {
21 | $this->_storageRoot = Mage::getConfig()->getOptions()->getMediaDir()
22 | . DS . Mage_Cms_Model_Wysiwyg_Config::IMAGE_DIRECTORY . DS;
23 | }
24 |
25 | return $this->_storageRoot;
26 | }
27 |
28 | /**
29 | * Return URL based on current selected directory or root directory for startup
30 | *
31 | * @return string
32 | */
33 | public function getCurrentUrl()
34 | {
35 | if (!Mage::getModel('cloudinary_cloudinary/configuration')->isEnabled()) {
36 | return parent::getCurrentUrl();
37 | }
38 |
39 | if (!$this->_currentUrl) {
40 | $mediaPath = Mage::getConfig()->getOptions()->getMediaDir();
41 | $path = str_replace($mediaPath, '', $this->getCurrentPath());
42 | $path = trim($path, DS);
43 | $this->_currentUrl = Mage::app()->getStore($this->_storeId)->getBaseUrl('media') .
44 | $this->convertPathToUrl($path) . '/';
45 | }
46 |
47 | return $this->_currentUrl;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Helper/Reset.php:
--------------------------------------------------------------------------------
1 | truncateCollection('cloudinary_cloudinary/synchronisation');
10 | $this->truncateCollection('cloudinary_cloudinary/migrationError');
11 | $this->truncateCollection('cloudinary_cloudinary/transformation');
12 | $this->removeConfigurationData();
13 | $this->removeMigration();
14 | $this->clearConfigCache();
15 | }
16 |
17 | /**
18 | * @param string $collectionName
19 | */
20 | private function truncateCollection($collectionName)
21 | {
22 | $collection = Mage::getModel($collectionName)->getCollection();
23 | return $collection->getConnection()->query(sprintf('TRUNCATE %s', $collection->getMainTable()));
24 | }
25 |
26 | private function removeConfigurationData()
27 | {
28 | $resource = Mage::getSingleton('core/resource');
29 | $write = $resource->getConnection('core_write');
30 | $table = $resource->getTableName('core/config_data');
31 | $write->delete($table, array('path LIKE (?)' => 'cloudinary/%'));
32 | }
33 |
34 | private function removeMigration()
35 | {
36 | Mage::getModel('cloudinary_cloudinary/migration')
37 | ->load(Cloudinary_Cloudinary_Model_Migration::CLOUDINARY_MIGRATION_ID)
38 | ->delete();
39 | }
40 |
41 | private function clearConfigCache()
42 | {
43 | Mage::app()->getCacheInstance()->cleanType(self::CONFIG_CACHE);
44 | Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => self::CONFIG_CACHE));
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/UrlGenerator.php:
--------------------------------------------------------------------------------
1 | configuration = $configuration;
29 | $this->imageProvider = $imageProvider;
30 | }
31 |
32 | /**
33 | * @param ImageInterface $image
34 | * @param Transformation $transformation
35 | *
36 | * @return string
37 | */
38 | public function generateFor(ImageInterface $image, Transformation $transformation = null)
39 | {
40 | if ($image instanceof LocalImage) {
41 | return (string)$image;
42 | }
43 |
44 | return (string)$this->imageProvider->retrieveTransformed(
45 | $image,
46 | $transformation ?: $this->configuration->getDefaultTransformation()
47 | );
48 | }
49 |
50 | /**
51 | * @param Image $image
52 | * @param Dimensions $dimensions
53 | *
54 | * @return string
55 | */
56 | public function generateWithDimensions(ImageInterface $image, Dimensions $dimensions)
57 | {
58 | $transformation = $this->configuration->getDefaultTransformation();
59 |
60 | return $this->generateFor($image, $transformation->withDimensions($dimensions));
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/composer/installed.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "cloudinary/cloudinary_php",
4 | "version": "1.16.0",
5 | "version_normalized": "1.16.0.0",
6 | "source": {
7 | "type": "git",
8 | "url": "https://github.com/cloudinary/cloudinary_php.git",
9 | "reference": "e33619e48ea8fa0350c007d640777091bfa4fdbc"
10 | },
11 | "dist": {
12 | "type": "zip",
13 | "url": "https://api.github.com/repos/cloudinary/cloudinary_php/zipball/e33619e48ea8fa0350c007d640777091bfa4fdbc",
14 | "reference": "e33619e48ea8fa0350c007d640777091bfa4fdbc",
15 | "shasum": ""
16 | },
17 | "require": {
18 | "ext-curl": "*",
19 | "ext-json": "*",
20 | "php": ">=5.4.0"
21 | },
22 | "require-dev": {
23 | "phpunit/phpunit": "4.8.*"
24 | },
25 | "time": "2019-11-28T15:57:33+00:00",
26 | "type": "library",
27 | "installation-source": "dist",
28 | "autoload": {
29 | "classmap": [
30 | "src"
31 | ],
32 | "files": [
33 | "src/Helpers.php"
34 | ]
35 | },
36 | "notification-url": "https://packagist.org/downloads/",
37 | "license": [
38 | "MIT"
39 | ],
40 | "authors": [
41 | {
42 | "name": "Cloudinary",
43 | "homepage": "https://github.com/cloudinary/cloudinary_php/graphs/contributors"
44 | }
45 | ],
46 | "description": "Cloudinary PHP SDK",
47 | "homepage": "https://github.com/cloudinary/cloudinary_php",
48 | "keywords": [
49 | "cdn",
50 | "cloud",
51 | "cloudinary",
52 | "image management",
53 | "sdk"
54 | ]
55 | }
56 | ]
57 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/samples/PhotoAlbum/style.css:
--------------------------------------------------------------------------------
1 | body { font-family: Helvetica, Arial, sans-serif; color: #333; margin: 10px; width: 960px }
2 | #posterframe { position: absolute; right: 10px; top: 10px; }
3 | h1 { color: #0e2953; font-size: 18px; }
4 | h2 { color: #666; font-size: 16px; }
5 | p { font-size: 14px; line-height: 18px; }
6 | #logo { height: 51px; width: 241px; }
7 | a { color: #0b63b6 }
8 |
9 | .upload_link { display: block; color: #000; border: 1px solid #aaa; background-color: #e0e0e0;
10 | font-size: 18px; padding: 5px 10px; width: 150px; margin: 10px 0 20px 0;
11 | font-weight: bold; text-align: center; }
12 |
13 | .photo { margin: 10px; padding: 10px; border-bottom: 2px solid #ccc; }
14 | .photo .thumbnail { margin-top: 10px; display: block; max-width: 200px; }
15 | .toggle_info { margin-top: 10px; font-weight: bold; color: #e62401; display: block; }
16 | .thumbnail_holder { height: 182px; margin-bottom: 5px; margin-right: 10px; }
17 | .info td, .uploaded_info td { font-size: 12px }
18 | .note { margin: 20px 0}
19 |
20 | .more_info, .show_more_info .less_info { display: none; }
21 | .show_more_info .more_info, .less_info { display: inline-block; }
22 | .inline { display: inline-block; }
23 | td { vertical-align: top; padding-right: 5px; }
24 |
25 | #backend_upload, #direct_upload { padding: 20px 20px; margin: 20px 0;
26 | border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; }
27 |
28 | #backend_upload h1, #direct_upload h1 { margin: 0 0 15px 0; }
29 |
30 | .back_link { font-weight: bold; display: block; font-size: 16px; margin: 10px 0; }
31 | #direct_upload { position: relative; min-height: 90px}
32 | .status { position: absolute; top: 20px; left: 500px; text-align: center; border: 1px solid #aaa;
33 | padding: 10px; width: 200px }
34 |
35 | .uploaded_info { margin: 10px}
36 | .uploaded_info .image { margin: 5px 0 }
37 | .uploaded_info td { padding-right: 10px }
38 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/AutoUploadMapping/RequestProcessor.php:
--------------------------------------------------------------------------------
1 | configuration = $configuration;
28 | $this->apiClient = $apiClient;
29 | }
30 |
31 | /**
32 | * @param string $folder
33 | * @param string $url
34 | * @param bool $force
35 | * @return bool
36 | */
37 | public function handle($folder, $url, $force = false)
38 | {
39 | if ($this->configuration->isActive() == $this->configuration->getRequestState() && !$force) {
40 | return true;
41 | }
42 |
43 | if ($this->configuration->getRequestState() == Configuration::ACTIVE) {
44 | return $this->handleActiveRequest($folder, $url);
45 | }
46 |
47 | $this->configuration->setState(Configuration::INACTIVE);
48 |
49 | return true;
50 | }
51 |
52 | /**
53 | * @param string $folder
54 | * @param string $url
55 | * @return bool
56 | */
57 | private function handleActiveRequest($folder, $url)
58 | {
59 | $result = $this->apiClient->prepareMapping($folder, $url);
60 |
61 | if ($result) {
62 | $this->configuration->setState(Configuration::ACTIVE);
63 | } else {
64 | $this->configuration->setRequestState(Configuration::INACTIVE);
65 | }
66 |
67 | return $result;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/controllers/Adminhtml/CloudinaryresetController.php:
--------------------------------------------------------------------------------
1 | loadLayout();
12 |
13 | $this->_title($this->__('Reset Cloudinary'));
14 | $this->_setActiveMenu('cloudinary_cloudinary/reset');
15 |
16 | $this->renderLayout();
17 | }
18 |
19 | public function saveAction()
20 | {
21 | $formPassword = $this->getRequest()->getPost('password');
22 | $userPassword = Mage::getSingleton('admin/session')
23 | ->getUser()
24 | ->getPassword();
25 |
26 | if ($this->_validateFormKey() && Mage::helper('core')->validateHash($formPassword, $userPassword)) {
27 | $this->removeModuleData();
28 | $this->_getSession()->addSuccess(self::RESET_SUCCESS_MESSSAGE1 . self::RESET_SUCCESS_MESSSAGE2);
29 | } else {
30 | $this->_getSession()->addError(self::RESET_ERROR_MESSAGE);
31 | }
32 |
33 | return $this->_redirect('*/cloudinaryreset');
34 | }
35 |
36 | private function removeModuleData()
37 | {
38 | Mage::helper('cloudinary_cloudinary/reset')->removeModuleData();
39 | Mage::getModel('cloudinary_cloudinary/logger')->notice(
40 | self::RESET_SUCCESS_MESSSAGE1 . self::RESET_SUCCESS_MESSSAGE2
41 | );
42 | }
43 |
44 | /**
45 | * @return bool
46 | */
47 | protected function _isAllowed()
48 | {
49 | return Mage::getSingleton('admin/session')->isAllowed('cloudinary_cloudinary/reset');
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/SynchronisedMediaUnifier.php:
--------------------------------------------------------------------------------
1 | _synchronisedMediaRepositories = $synchronisedMediaRepositories;
19 | }
20 |
21 | /**
22 | * @param int $limit
23 | * @return [Cloudinary_Cloudinary_Model_Synchronisation]
24 | */
25 | public function findUnsynchronisedImages($limit = 200)
26 | {
27 | return array_slice($this->findUnlimitedUnsynchronisedImages(), 0, $limit);
28 | }
29 |
30 | /**
31 | * @return [Cloudinary_Cloudinary_Model_Synchronisation]
32 | */
33 | private function findUnlimitedUnsynchronisedImages()
34 | {
35 | return array_reduce(
36 | $this->_synchronisedMediaRepositories,
37 | function($carry, $synchronisedMediaRepository) {
38 | return array_merge($carry, $synchronisedMediaRepository->findUnsynchronisedImages());
39 | },
40 | array()
41 | );
42 | }
43 |
44 | /**
45 | * @return [Cloudinary_Cloudinary_Model_Synchronisation]
46 | */
47 | public function findOrphanedSynchronisedImages()
48 | {
49 | return array_reduce(
50 | $this->_synchronisedMediaRepositories,
51 | function($carry, $synchronisedMediaRepository) {
52 | return array_merge($carry, $synchronisedMediaRepository->findOrphanedSynchronisedImages());
53 | },
54 | array()
55 | );
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Magento 1 [Cloudinary](https://www.cloudinary.com/) Module
2 |
3 | Magento 1 module for integration with Cloudinary.
4 |
5 | **⚠️ PLEASE NOTE:** Magento 1 reached end-of-life in June 2020. Accordingly, the Cloudinary Magento 1 extension is no longer available and will not receive updates.
6 |
7 | ---
8 |
9 | ## Install From Magento Admin (Using Magento Connect Manager)
10 | 1. Log into your Magento admin panel & navigate to System > Magento Connect > Magento Connect Manager.
11 | 2. Under "Direct package file upload", upload the package file that's included in this repository (var/connect/Cloudinary_Cloudinary-\*.tgz).
12 | 3. Install the package...
13 |
14 | ## Install Manually
15 | 1. Download & copy/drag the directories `app`, `lib` & `skin` into your Magento 1 root dir.
16 | 2. Clear cache from Magento admin panel or by running `rm -rf var/cache/* var/full_page_cache/*` under your Magento 1 root dir.
17 |
18 | ## Install Using Modman
19 | 1. If you don't have modman installed, install it first according to the [official instructions](https://github.com/colinmollenhour/modman#installation) & then follow the [instructions for Magento users](https://github.com/colinmollenhour/modman#magento-users).
20 | 2. cd into your Magento 1 root dir & run `modman init` (in case you haven't done it already).
21 | 3. Under your Magento 1 root dir, run `modman clone Cloudinary_Cloudinary https://github.com/cloudinary/cloudinary_magento`
22 | 4. Clear cache from Magento admin panel or by running `rm -rf var/cache/* var/full_page_cache/*` under your Magento 1 root dir.
23 |
24 | ## Update Using Modman
25 | 1. Under your Magento 1 root dir, run `modman update Cloudinary_Cloudinary`
26 | 2. Clear cache from Magento admin panel or by running `rm -rf var/cache/* var/full_page_cache/*` under your Magento 1 root dir.
27 |
28 | ---
29 |
30 | https://www.cloudinary.com/
31 |
32 | Copyright © 2018 Cloudinary. All rights reserved.
33 |
34 | 
35 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/System/Config/ProductGalleryCustomFreeParams.php:
--------------------------------------------------------------------------------
1 | 'No error',
9 | JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
10 | JSON_ERROR_STATE_MISMATCH => 'State mismatch (invalid or malformed JSON)',
11 | JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded',
12 | JSON_ERROR_SYNTAX => 'Syntax error',
13 | JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded'
14 | );
15 |
16 | /**
17 | * @return Mage_Core_Model_Abstract
18 | */
19 | protected function _beforeSave()
20 | {
21 | $rawValue = $this->getValue();
22 |
23 | parent::_beforeSave();
24 |
25 | //Clear config cache
26 | Mage::app()->getCacheInstance()->cleanType("config");
27 | Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => "config"));
28 | Mage::getConfig()->reinit();
29 |
30 | if ($rawValue) {
31 | $data = @json_decode($rawValue);
32 | if ($data === null || $data === false) {
33 | $this->setValue('{}');
34 | try {
35 | if (json_last_error() !== JSON_ERROR_NONE) {
36 | Mage::getSingleton('adminhtml/session')->addError(self::BAD_JSON_ERROR_MESSAGE . ' (' . $this->_jsonErrors[json_last_error()] . ')');
37 | }
38 | } catch (\Exception $e) {
39 | Mage::getSingleton('adminhtml/session')->addError(self::BAD_JSON_ERROR_MESSAGE);
40 | }
41 | } else {
42 | $this->setValue(json_encode((object)$data));
43 | }
44 | } else {
45 | $this->setValue('{}');
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/samples/PhotoAlbum/main.php:
--------------------------------------------------------------------------------
1 | 'jpg', 'height' => 150, 'width' => 150, 'class' => 'thumbnail inline');
20 |
21 | // Helper functions
22 | function ret_var_dump($var)
23 | {
24 | ob_start();
25 | var_dump($var);
26 | return ob_get_clean();
27 | }
28 |
29 | function array_to_table($array)
30 | {
31 | $saved_error_reporting = error_reporting(0);
32 | echo '';
33 | foreach ($array as $key => $value) {
34 | if ($key != 'class') {
35 | if ($key == 'url' || $key == 'secure_url') {
36 | $display_value = '"' . $value . '"';
37 | } else {
38 | $display_value = json_encode($value);
39 | }
40 | echo "| {$key}: | {$display_value} |
";
41 | }
42 | }
43 | echo '
';
44 | error_reporting($saved_error_reporting);
45 | }
46 |
47 | function create_photo_model($options = array())
48 | {
49 | $photo = \R::dispense('photo');
50 |
51 | foreach ($options as $key => $value) {
52 | if ($key != 'tags') {
53 | $photo->{$key} = $value;
54 | }
55 | }
56 |
57 | # Add metadata we want to keep:
58 | $photo->moderated = false;
59 | $photo->created_at = (array_key_exists('created_at', $photo) ?
60 | \DateTime::createFromFormat(\DateTime::ISO8601, $photo->created_at) :
61 | \R::isoDateTime());
62 |
63 | \R::store($photo);
64 | }
65 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/AutoUploadMapping/Configuration.php:
--------------------------------------------------------------------------------
1 | setStoreConfigFlag(self::STATE_PATH, $state);
24 | }
25 |
26 | /**
27 | * @return bool
28 | */
29 | public function getRequestState()
30 | {
31 | return Mage::getStoreConfigFlag(self::REQUEST_PATH);
32 | }
33 |
34 | /**
35 | * @param bool $state
36 | */
37 | public function setRequestState($state)
38 | {
39 | $this->setStoreConfigFlag(self::REQUEST_PATH, $state);
40 | }
41 |
42 | /**
43 | * @param string $configPath
44 | * @param bool $state
45 | */
46 | private function setStoreConfigFlag($configPath, $state)
47 | {
48 | $state = $state ? 1 : 0;
49 | $this->updatePersistentConfig($configPath, $state);
50 | $this->updateCacheConfig($configPath, $state);
51 | }
52 |
53 | /**
54 | * @param string $path
55 | * @param bool $state
56 | */
57 | private function updatePersistentConfig($path, $state)
58 | {
59 | Mage::getModel('core/config')->saveConfig($path, $state)->reinit();
60 | }
61 |
62 | /**
63 | * @param string $path
64 | * @param bool $state
65 | */
66 | private function updateCacheConfig($path, $state)
67 | {
68 | Mage::app()->getStore()->getConfig($path);
69 | Mage::app()->getStore()->setConfig($path, $state);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Cms/Adminhtml/Template/Filter.php:
--------------------------------------------------------------------------------
1 | imageFactory = new ImageFactory(
24 | $configuration,
25 | Mage::getModel('cloudinary_cloudinary/synchronizationChecker')
26 | );
27 |
28 | $this->urlGenerator = new UrlGenerator(
29 | $configuration,
30 | CloudinaryImageProvider::fromConfiguration($configuration)
31 | );
32 |
33 | parent::__construct();
34 | }
35 |
36 | /**
37 | * @param array $construction
38 | * @return string
39 | */
40 | public function mediaDirective($construction)
41 | {
42 | if (ini_get('allow_url_fopen')) {
43 | $image = $this->imageFactory->build(
44 | $this->imagePath($construction),
45 | function () use ($construction) {
46 | return parent::mediaDirective($construction);
47 | }
48 | );
49 |
50 | return $this->urlGenerator->generateFor($image);
51 | }
52 |
53 | return parent::mediaDirective($construction);
54 | }
55 |
56 | /**
57 | * @param array $construction
58 | * @return string
59 | */
60 | protected function imagePath(array $construction)
61 | {
62 | $params = $this->_getIncludeParameters($construction[2]);
63 |
64 | if (!isset($params['url'])) {
65 | Mage::throwException('Undefined url parameter for media directive.');
66 | }
67 |
68 | return $params['url'];
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/MigrationError.php:
--------------------------------------------------------------------------------
1 | _init('cloudinary_cloudinary/migrationError');
11 | }
12 |
13 | /**
14 | * @param \CloudinaryExtension\Exception\MigrationError $e
15 | */
16 | public static function saveFromException(\CloudinaryExtension\Exception\MigrationError $e, $type = Cloudinary_Cloudinary_Model_Migration::UPLOAD_MIGRATION_TYPE)
17 | {
18 | $image = $e->getImage();
19 | $filePath = (string)$image;
20 |
21 | $entry = Mage::getModel('cloudinary_cloudinary/migrationError');
22 | $entry->setFilePath($filePath);
23 |
24 | $entry->setRelativePath($image->getRelativePath());
25 | $entry->setMessage($e->getMessage());
26 | $entry->setCode($e->getCode());
27 | $entry->setTimestamp(time());
28 | $entry->setType($type);
29 |
30 | $entry->save();
31 | }
32 |
33 | /**
34 | * @param \Exception $e
35 | */
36 | public static function saveFromNormalException(\Exception $e, $type = Cloudinary_Cloudinary_Model_Migration::UPLOAD_MIGRATION_TYPE)
37 | {
38 | $entry = Mage::getModel('cloudinary_cloudinary/migrationError');
39 | $entry->setMessage($e->getMessage());
40 | $entry->setCode($e->getCode());
41 | $entry->setTimestamp(time());
42 | $entry->setType($type);
43 | $entry->save();
44 | }
45 |
46 | /**
47 | * @param Cloudinary_Cloudinary_Model_Synchronisation $orphanImage
48 | * @return $this
49 | */
50 | public function orphanRemoved(Cloudinary_Cloudinary_Model_Synchronisation $orphanImage)
51 | {
52 | $this->setFilePath($orphanImage->getImageName());
53 | $this->setRelativePath($orphanImage->getImageName());
54 | $this->setMessage(sprintf(self::REMOVE_ORPHAN_MESSAGE, $orphanImage->getImageName()));
55 | $this->setTimestamp(time());
56 | return $this;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/src/Cache/Adapter/CacheAdapter.php:
--------------------------------------------------------------------------------
1 | register();
13 | }
14 |
15 | public function uploadMigration()
16 | {
17 | $migrationTask = Mage::getModel('cloudinary_cloudinary/migration')
18 | ->loadType(Cloudinary_Cloudinary_Model_Migration::UPLOAD_MIGRATION_TYPE)
19 | ->recordBatchProgress();
20 |
21 | $batchUploader = new BatchUploader(
22 | CloudinaryImageProvider::fromConfiguration(
23 | Mage::getModel('cloudinary_cloudinary/configuration')
24 | ),
25 | $migrationTask,
26 | Mage::getModel('cloudinary_cloudinary/logger'),
27 | null,
28 | function (\Exception $e) {
29 | if ($e instanceof MigrationError) {
30 | Cloudinary_Cloudinary_Model_MigrationError::saveFromException($e, Cloudinary_Cloudinary_Model_Migration::UPLOAD_MIGRATION_TYPE);
31 | }
32 | }
33 | );
34 |
35 | $combinedMediaRepository = new Cloudinary_Cloudinary_Model_SynchronisedMediaUnifier(
36 | array(
37 | Mage::getResourceModel('cloudinary_cloudinary/synchronisation_collection'),
38 | Mage::getResourceModel('cloudinary_cloudinary/cms_synchronisation_collection')
39 | )
40 | );
41 |
42 | $migrationQueue = new \CloudinaryExtension\Migration\Queue(
43 | $migrationTask,
44 | $combinedMediaRepository,
45 | $batchUploader,
46 | Mage::getModel('cloudinary_cloudinary/logger')
47 | );
48 |
49 | $migrationQueue->process();
50 |
51 | return $this;
52 | }
53 |
54 | public function downloadMigration()
55 | {
56 | Mage::helper('cloudinary_cloudinary/BatchDownloader')->downloadImages();
57 |
58 | return $this;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/src/Search.php:
--------------------------------------------------------------------------------
1 | query_hash = array(
13 | 'sort_by' => array(),
14 | 'aggregate' => array(),
15 | 'with_field' => array(),
16 | );
17 | }
18 |
19 | public function expression($value)
20 | {
21 | $this->query_hash['expression'] = $value;
22 |
23 | return $this;
24 | }
25 |
26 | public function max_results($value)
27 | {
28 | $this->query_hash['max_results'] = $value;
29 |
30 | return $this;
31 | }
32 |
33 | public function next_cursor($value)
34 | {
35 | $this->query_hash['next_cursor'] = $value;
36 |
37 | return $this;
38 | }
39 |
40 | public function sort_by($field_name, $dir = 'desc')
41 | {
42 | array_push($this->query_hash['sort_by'], array($field_name => $dir));
43 |
44 | return $this;
45 | }
46 |
47 | public function aggregate($value)
48 | {
49 | array_push($this->query_hash['aggregate'], $value);
50 |
51 | return $this;
52 | }
53 |
54 | public function with_field($value)
55 | {
56 | array_push($this->query_hash['with_field'], $value);
57 |
58 | return $this;
59 | }
60 |
61 | public function as_array()
62 | {
63 | return array_filter(
64 | $this->query_hash,
65 | function ($value) {
66 | return ((is_array($value) && !empty($value)) || ($value != null));
67 | }
68 | );
69 | }
70 |
71 | public function execute($options = array())
72 | {
73 | $api = new Api();
74 | $uri = array('resources/search');
75 | $options = array_merge($options, array('content_type' => 'application/json'));
76 | $method = 'post';
77 |
78 | return $api->call_api($method, $uri, $this->as_array(), $options);
79 | }
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Resource/Synchronisation/Collection.php:
--------------------------------------------------------------------------------
1 | _init('cloudinary_cloudinary/synchronisation');
13 | }
14 |
15 | private function _getResource()
16 | {
17 | return parent::getResource();
18 | }
19 |
20 | protected function _getConnection()
21 | {
22 | $resource = $this->_getResource();
23 |
24 | return $resource->getReadConnection();
25 | }
26 |
27 | protected function _getMainTable()
28 | {
29 | $resource = $this->_getResource();
30 |
31 | return $resource->getMainTable();
32 | }
33 |
34 | public function findUnsynchronisedImages($limit = 100)
35 | {
36 | $tableName = Mage::getSingleton('core/resource')->getTableName('cloudinary_cloudinary/catalog_media_gallery');
37 | $syncedImagesQuery = $this->getQueryForSyncedImageNames();
38 |
39 | $select = $this->getSelect();
40 |
41 | $select
42 | ->joinRight($tableName, 'value_id=media_gallery_id', '*')
43 | ->group('value')
44 | ->order('value')
45 | ->where("cloudinary_synchronisation_id is null and value not in ($syncedImagesQuery)")
46 | ->limit($limit);
47 |
48 | return $this->getItems();
49 | }
50 |
51 | /**
52 | * basically returns with all product image's media_gallery stored name which has been synced
53 | *
54 | * @return Varien_Db_Select
55 | */
56 | private function getQueryForSyncedImageNames()
57 | {
58 | $select = clone $this->getSelect();
59 | $select->reset(Zend_Db_Select::COLUMNS);
60 | $select->where('media_gallery_value is not null');
61 | return $select->columns('media_gallery_value');
62 | }
63 |
64 | /**
65 | * Only applicable for cms instance
66 | * @return [Cloudinary_Cloudinary_Model_Synchronisation]
67 | */
68 | public function findOrphanedSynchronisedImages()
69 | {
70 | return array();
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Catalog/Product/Media.php:
--------------------------------------------------------------------------------
1 | getData('media_gallery');
10 | $mediaGallery['images'] = isset($mediaGallery['images'])? $mediaGallery['images'] : array();
11 | if (!is_array($mediaGallery['images'])) {
12 | $mediaGallery['images'] = (array) @json_decode($mediaGallery['images'], true);
13 | }
14 |
15 | return $mediaGallery;
16 | }
17 |
18 | public function newImagesForProduct(Mage_Catalog_Model_Product $product)
19 | {
20 | $this->_setNewImages($this->getProductMediaGallery($product));
21 | return $this->_getNewImages($product);
22 | }
23 |
24 | private function _setNewImages(array $mediaGallery)
25 | {
26 | $this->_newImages = array();
27 | foreach ($mediaGallery['images'] as $image) {
28 | if (array_key_exists('new_file', $image)) {
29 | $this->_newImages[] = $image['new_file'];
30 | }
31 | }
32 | }
33 |
34 | private function _getNewImages(Mage_Catalog_Model_Product $product)
35 | {
36 | $product->load('media_gallery');
37 | $mediaGallery = $this->getProductMediaGallery($product);
38 | return array_filter($mediaGallery['images'], array($this, '_isImageInArray'));
39 | }
40 |
41 | private function _isImageInArray($toFilter)
42 | {
43 | return is_array($toFilter) && array_key_exists('file', $toFilter) && in_array($toFilter['file'], $this->_newImages);
44 | }
45 |
46 | public function removedImagesForProduct(Mage_Catalog_Model_Product $product)
47 | {
48 | return $this->_getRemovedImages($this->getProductMediaGallery($product));
49 | }
50 |
51 | private function _getRemovedImages(array $mediaGallery)
52 | {
53 | return array_filter($mediaGallery['images'], array($this, '_isImageRemoved'));
54 | }
55 |
56 | private function _isImageRemoved($toFilter)
57 | {
58 | return is_array($toFilter) && array_key_exists('removed', $toFilter) && $toFilter['removed'] === 1;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/design/adminhtml/default/default/template/cloudinary/media/uploader.phtml:
--------------------------------------------------------------------------------
1 |
27 |
32 |
33 |
34 | getCldMLButtonHtml(); ?>
35 | getBrowseButtonHtml(); ?>
36 | getUploadButtonHtml(); ?>
37 |
38 |
39 |
40 |
41 |
{{name}} {{size}}
42 |
getDeleteButtonHtml() ?>
43 |
44 |
45 |
46 |
47 |
56 | getChildHtml('additional_scripts'); ?>
57 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Observer/Product.php:
--------------------------------------------------------------------------------
1 | isEnabled()) {
17 | $cloudinaryImage = Mage::getModel('cloudinary_cloudinary/image');
18 |
19 | foreach ($this->getImagesToUpload($event->getProduct()) as $image) {
20 | $cloudinaryImage->upload($image);
21 | }
22 | }
23 | }
24 |
25 | /**
26 | * @param Varien_Event_Observer $event
27 | */
28 | public function deleteImagesFromCloudinary(Varien_Event_Observer $event)
29 | {
30 | /** @var ConfigurationInterface $configuration */
31 | $configuration = Mage::getModel('cloudinary_cloudinary/configuration');
32 |
33 | if (!$configuration->isEnabled()) {
34 | return;
35 | }
36 |
37 | $imageProvider = CloudinaryImageProvider::fromConfiguration($configuration);
38 |
39 | foreach ($this->getImagesToDelete($event->getProduct()) as $image) {
40 | $migratedPath = $configuration->isFolderedMigration() ? $configuration->getMigratedPath($image['file']) : '';
41 | $imageProvider->delete(Image::fromPath($image['file'], ltrim($migratedPath, '/')));
42 | Mage::getModel('cloudinary_cloudinary/logger')->notice(sprintf(self::DELETE_MESSAGE, $image['file']));
43 | }
44 | }
45 |
46 | /**
47 | * @param Product $product
48 | * @return array
49 | */
50 | private function getImagesToUpload(Product $product)
51 | {
52 | return Mage::getModel('cloudinary_cloudinary/catalog_product_media')->newImagesForProduct($product);
53 | }
54 |
55 | /**
56 | * @param Product $product
57 | * @return array
58 | */
59 | private function getImagesToDelete(Product $product)
60 | {
61 | $productMedia = Mage::getModel('cloudinary_cloudinary/catalog_product_media');
62 | return $productMedia->removedImagesForProduct($product);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Catalog/Template/Filter.php:
--------------------------------------------------------------------------------
1 |
14 | * @todo Needs to be reimplemented to get rid of the copypasted methods
15 | */
16 | class Cloudinary_Cloudinary_Model_Catalog_Template_Filter extends Mage_Catalog_Model_Template_Filter
17 | {
18 | /**
19 | * @var ImageFactory
20 | */
21 | private $imageFactory;
22 |
23 | /**
24 | * @var UrlGenerator
25 | */
26 | private $urlGenerator;
27 |
28 | /**
29 | * @var Configuration
30 | */
31 | private $configuration;
32 |
33 | public function __construct()
34 | {
35 | $this->configuration = Mage::getModel('cloudinary_cloudinary/configuration');
36 | if ($this->configuration->isEnabled()) {
37 | $this->imageFactory = new ImageFactory(
38 | $this->configuration,
39 | Mage::getModel('cloudinary_cloudinary/synchronizationChecker')
40 | );
41 |
42 | $this->urlGenerator = new UrlGenerator(
43 | $this->configuration,
44 | CloudinaryImageProvider::fromConfiguration($this->configuration)
45 | );
46 | }
47 | }
48 |
49 | /**
50 | * Retrieve media file URL directive
51 | *
52 | * @param array $construction
53 | * @return string
54 | * @see Mage_Core_Model_Email_Template_Filter::mediaDirective() method has been copypasted
55 | */
56 | public function mediaDirective($construction)
57 | {
58 | if (!$this->configuration->isEnabled()) {
59 | return parent::mediaDirective($construction);
60 | }
61 |
62 | $imagePath = $this->getImagePath($construction[2]);
63 |
64 | $image = $this->imageFactory->build(
65 | $imagePath,
66 | function () use ($construction) {
67 | return parent::mediaDirective($construction);
68 | }
69 | );
70 |
71 | return $this->urlGenerator->generateFor($image);
72 | }
73 |
74 | private function getImagePath($directiveParams)
75 | {
76 | $params = $this->_getIncludeParameters($directiveParams);
77 | return $params['url'];
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/SynchronizationChecker.php:
--------------------------------------------------------------------------------
1 | hasAutoUploadMapping()) {
18 | return true;
19 | }
20 |
21 | /**
22 | * @var Cloudinary_Cloudinary_Model_Cache $cache
23 | */
24 | $cache = Mage::getSingleton('cloudinary_cloudinary/cache');
25 |
26 | if ($cache->isEnabled()) {
27 | return $this->cachedSynchronizationCheck($cache, $imageName);
28 | }
29 |
30 | return $this->synchronizationCheck($imageName);
31 | }
32 |
33 | /**
34 | * @return bool
35 | */
36 | private function hasAutoUploadMapping()
37 | {
38 | return Mage::getModel('cloudinary_cloudinary/autoUploadMapping_configuration')->isActive();
39 | }
40 |
41 | /**
42 | * @param $imageName
43 | * @return bool
44 | */
45 | private function synchronizationCheck($imageName)
46 | {
47 | $coll = Mage::getModel('cloudinary_cloudinary/synchronisation')->getCollection();
48 | $table = $coll->getMainTable();
49 | // case sensitive check
50 | $query = "select count(*) from $table where binary image_name = '$imageName' limit 1";
51 | return $coll->getConnection()->query($query)->fetchColumn() > 0;
52 | }
53 |
54 | /**
55 | * @param string $imageName
56 | * @return string
57 | */
58 | private function getSynchronizationCacheKeyFromImageName($imageName)
59 | {
60 | return sprintf('cloudinary_sync_%s', hash('sha256', $imageName));
61 | }
62 |
63 | /**
64 | * @param Cloudinary_Cloudinary_Model_Cache $cache
65 | * @param string $imageName
66 | * @return bool
67 | */
68 | private function cachedSynchronizationCheck(Cloudinary_Cloudinary_Model_Cache $cache, $imageName)
69 | {
70 | return $cache->loadCache(
71 | $this->getSynchronizationCacheKeyFromImageName($imageName),
72 | function () use ($imageName) {
73 | return $this->synchronizationCheck($imageName) ? '1' : '0';
74 | }
75 | ) === '1' ? true : false;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Catalog/Product/Media/Config.php:
--------------------------------------------------------------------------------
1 | _configuration = Mage::getModel('cloudinary_cloudinary/configuration');
27 |
28 | if ($this->_configuration->isEnabled()) {
29 | $this->_imageFactory = new ImageFactory(
30 | $this->_configuration,
31 | Mage::getModel('cloudinary_cloudinary/synchronizationChecker')
32 | );
33 |
34 | $this->_urlGenerator = new UrlGenerator(
35 | $this->_configuration,
36 | CloudinaryImageProvider::fromConfiguration($this->_configuration)
37 | );
38 | }
39 | }
40 |
41 | /**
42 | * @param string $file relative image filepath
43 | * @return string
44 | */
45 | public function getMediaUrl($file)
46 | {
47 | if (!$this->_configuration->isEnabled()) {
48 | return parent::getMediaUrl($file);
49 | }
50 |
51 | $image = $this->_imageFactory->build(
52 | $file, function () use ($file) {
53 | return parent::getMediaUrl($file);
54 | }
55 | );
56 |
57 | return $this->_urlGenerator->generateFor(
58 | $image,
59 | Mage::getModel('cloudinary_cloudinary/transformation')->transformationForImage($file)
60 | );
61 | }
62 |
63 | /**
64 | * @param string $file relative image filepath
65 | * @return string
66 | */
67 | public function getTmpMediaUrl($file)
68 | {
69 | //Comment this line & uncomment the next paragraph if you insist on using cloudinary for tmp media images
70 | return parent::getTmpMediaUrl($file);
71 | /*
72 | $file = DS . ltrim($this->getBaseTmpMediaUrlAddition(), DS) . $file;
73 | $image = $this->_imageFactory->build($file, function() use($file) { return parent::getTmpMediaUrl($file); });
74 | return $this->_urlGenerator->generateFor($image);
75 | */
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Helper/Autoloader.php:
--------------------------------------------------------------------------------
1 | _deregisterVarienAutoloaders();
15 | $this->_registerCloudinaryAutoloader();
16 | $this->_registerCloudinaryExtensionAutoloader();
17 | $this->_reregisterVarienAutoloaders();
18 | }
19 |
20 | private function _registerCloudinaryExtensionAutoloader()
21 | {
22 | spl_autoload_register(
23 | function ($className) {
24 | if(strpos($className, Cloudinary_Cloudinary_Helper_Autoloader::CLOUDINARY_EXTENSION_LIB_PATH . '\\') === 0 ||
25 | strpos($className, Cloudinary_Cloudinary_Helper_Autoloader::CLOUDINARY_LIB_PATH . '\\') === 0
26 | ) {
27 | include_once preg_replace(Cloudinary_Cloudinary_Helper_Autoloader::CONVERT_CLASS_TO_PATH_REGEX, '/', $className) . '.php';
28 | }
29 | }
30 | );
31 |
32 | return $this;
33 | }
34 |
35 | private function _registerCloudinaryAutoloader()
36 | {
37 | $libFolder = Mage::getBaseDir('lib');
38 |
39 | spl_autoload_register(
40 | function ($className) use ($libFolder) {
41 | if($className === Cloudinary_Cloudinary_Helper_Autoloader::CLOUDINARY_LIB_PATH) {
42 | foreach(new GlobIterator($libFolder . DS . Cloudinary_Cloudinary_Helper_Autoloader::CLOUDINARY_LIB_PATH . DS . '*.php') as $phpFile) {
43 | include_once $phpFile;
44 | }
45 | }
46 | }
47 | );
48 |
49 | return $this;
50 | }
51 |
52 | private function _deregisterVarienAutoloaders()
53 | {
54 | $this->_originalAutoloaders = array();
55 |
56 | foreach (spl_autoload_functions() as $callback) {
57 | if (is_array($callback) && $callback[0] instanceof Varien_Autoload) {
58 | $this->_originalAutoloaders[] = $callback;
59 | spl_autoload_unregister($callback);
60 | }
61 | }
62 | }
63 |
64 | private function _reregisterVarienAutoloaders()
65 | {
66 | foreach ($this->_originalAutoloaders as $autoloader) {
67 | spl_autoload_register($autoloader);
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/sql/cloudinary_setup/upgrade-2.9.8-3.0.0.php:
--------------------------------------------------------------------------------
1 | startSetup();
7 |
8 | $con = $installer->getConnection();
9 | $table = $installer->getTable('cloudinary_cloudinary/migration');
10 |
11 | $con->dropTable($table);
12 |
13 | $table = $con->newTable($table)
14 | ->addColumn(
15 | 'cloudinary_migration_id', Varien_Db_Ddl_Table::TYPE_TINYINT, null, array(
16 | 'unsigned' => true,
17 | 'nullable' => false,
18 | 'primary' => true,
19 | 'auto_increment' => true,
20 | ), 'Cloudinary Migration ID'
21 | )
22 | ->addColumn(
23 | 'started', Varien_Db_Ddl_Table::TYPE_TINYINT, null, array(
24 | 'unsigned' => true,
25 | 'nullable' => false,
26 | 'default' => 0,
27 | ), 'Migration Started'
28 | )
29 | ->addColumn(
30 | 'started_at', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
31 | 'comment' => 'The time the migration started',
32 | 'nullable' => true,
33 | 'default' => '0000-00-00 00:00:00'
34 | )
35 | )->addColumn(
36 | 'batch_count', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
37 | 'comment' => 'Batches run for current migration',
38 | 'nullable' => false,
39 | 'default' => 0
40 | )
41 | )->addColumn(
42 | 'type', Varien_Db_Ddl_Table::TYPE_TEXT, 10, array(
43 | 'comment' => 'Migration Type',
44 | 'nullable' => true,
45 | 'default' => 'upload'
46 | )
47 | )->addColumn(
48 | 'info', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
49 | 'comment' => 'Info',
50 | 'nullable' => true,
51 | //'default' => '[]'
52 | )
53 | );
54 |
55 | $con->createTable($table);
56 |
57 | $con->addIndex(
58 | $installer->getTable('cloudinary_cloudinary/migration'),
59 | $installer->getIdxName(
60 | 'cloudinary_cloudinary/migration',
61 | array('type'),
62 | Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
63 | ),
64 | array('type'),
65 | Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
66 | );
67 |
68 | $con->addColumn(
69 | $installer->getTable('cloudinary_cloudinary/migrationError'), 'type', array(
70 | 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
71 | 'nullable' => true,
72 | 'length' => 10,
73 | 'comment' => 'Migration Type',
74 | 'default' => 'upload'
75 | )
76 | );
77 |
78 | $installer->endSetup();
79 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/composer.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_readme": [
3 | "This file locks the dependencies of your project to a known state",
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5 | "This file is @generated automatically"
6 | ],
7 | "content-hash": "3265de913ba9de963f729a4f0be09a73",
8 | "packages": [
9 | {
10 | "name": "cloudinary/cloudinary_php",
11 | "version": "1.16.0",
12 | "source": {
13 | "type": "git",
14 | "url": "https://github.com/cloudinary/cloudinary_php.git",
15 | "reference": "e33619e48ea8fa0350c007d640777091bfa4fdbc"
16 | },
17 | "dist": {
18 | "type": "zip",
19 | "url": "https://api.github.com/repos/cloudinary/cloudinary_php/zipball/e33619e48ea8fa0350c007d640777091bfa4fdbc",
20 | "reference": "e33619e48ea8fa0350c007d640777091bfa4fdbc",
21 | "shasum": ""
22 | },
23 | "require": {
24 | "ext-curl": "*",
25 | "ext-json": "*",
26 | "php": ">=5.4.0"
27 | },
28 | "require-dev": {
29 | "phpunit/phpunit": "4.8.*"
30 | },
31 | "type": "library",
32 | "autoload": {
33 | "classmap": [
34 | "src"
35 | ],
36 | "files": [
37 | "src/Helpers.php"
38 | ]
39 | },
40 | "notification-url": "https://packagist.org/downloads/",
41 | "license": [
42 | "MIT"
43 | ],
44 | "authors": [
45 | {
46 | "name": "Cloudinary",
47 | "homepage": "https://github.com/cloudinary/cloudinary_php/graphs/contributors"
48 | }
49 | ],
50 | "description": "Cloudinary PHP SDK",
51 | "homepage": "https://github.com/cloudinary/cloudinary_php",
52 | "keywords": [
53 | "cdn",
54 | "cloud",
55 | "cloudinary",
56 | "image management",
57 | "sdk"
58 | ],
59 | "time": "2019-11-28T15:57:33+00:00"
60 | }
61 | ],
62 | "packages-dev": [],
63 | "aliases": [],
64 | "minimum-stability": "stable",
65 | "stability-flags": [],
66 | "prefer-stable": false,
67 | "prefer-lowest": false,
68 | "platform": [],
69 | "platform-dev": []
70 | }
71 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/src/PreloadedFile.php:
--------------------------------------------------------------------------------
1 | resource_type = $matches[1];
31 | $this->type = $matches[2];
32 | $this->version = $matches[3];
33 | $this->filename = $matches[4];
34 | $this->signature = $matches[5];
35 | $public_id_and_format = $this->split_format($this->filename);
36 | $this->public_id = $public_id_and_format[0];
37 | $this->format = $public_id_and_format[1];
38 | }
39 |
40 | public function is_valid()
41 | {
42 | $public_id = $this->resource_type == 'raw' ? $this->filename : $this->public_id;
43 | $expected_signature = \Cloudinary::api_sign_request(
44 | array(
45 | "public_id" => $public_id,
46 | "version" => $this->version,
47 | ),
48 | \Cloudinary::config_get("api_secret")
49 | );
50 |
51 | return $this->signature == $expected_signature;
52 | }
53 |
54 | protected function split_format($identifier)
55 | {
56 | $last_dot = strrpos($identifier, '.');
57 |
58 | if ($last_dot === false) {
59 | return array($identifier, null);
60 | }
61 | $public_id = substr($identifier, 0, $last_dot);
62 | $format = substr($identifier, $last_dot + 1);
63 |
64 | return array($public_id, $format);
65 | }
66 |
67 | public function identifier()
68 | {
69 | return "v{$this->version}/{$this->filename}";
70 | }
71 |
72 | public function extended_identifier()
73 | {
74 | return "{$this->resource_type}/{$this->type}/{$this->identifier()}";
75 | }
76 |
77 | public function __toString()
78 | {
79 | return "{$this->resource_type}/{$this->type}/v{$this->version}/{$this->filename}#{$this->signature}";
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Observer/Config.php:
--------------------------------------------------------------------------------
1 | getCacheInstance()->cleanType("config");
26 | Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => "config"));
27 | Mage::getConfig()->reinit();
28 |
29 | if (!Mage::getModel('cloudinary_cloudinary/configuration')->isEnabled()) {
30 | return $this;
31 | }
32 |
33 | if (!$this->autoUploadRequestProcessor()->handle('media', Mage::getBaseUrl('media'), true)) {
34 | Mage::getSingleton('adminhtml/session')->addError(self::AUTO_UPLOAD_SETUP_FAIL_MESSAGE);
35 | Mage::getModel('cloudinary_cloudinary/logger')->error(self::AUTO_UPLOAD_SETUP_FAIL_MESSAGE);
36 | } else {
37 | $isActive = Mage::getModel('cloudinary_cloudinary/autoUploadMapping_configuration')->isActive();
38 | Mage::getModel('cloudinary_cloudinary/logger')->notice(
39 | sprintf(self::AUTO_UPLOAD_SETUP_SUCCESS_MESSAGE, $isActive ? 'On' : 'Off')
40 | );
41 | }
42 | }
43 |
44 | /**
45 | * @return RequestProcessor
46 | */
47 | private function autoUploadRequestProcessor()
48 | {
49 | return new RequestProcessor(
50 | Mage::getModel('cloudinary_cloudinary/autoUploadMapping_configuration'),
51 | ApiClient::fromConfiguration(Mage::getModel('cloudinary_cloudinary/configuration'))
52 | );
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/samples/README.md:
--------------------------------------------------------------------------------
1 | # Cloudinary PHP Sample Project
2 |
3 | Included in this folder are two sample projects for demonstrating the common Cloudinary's usage in PHP.
4 |
5 | *Note: PHP 5.3+ is required.*
6 |
7 | ## Installation
8 |
9 | The cloudinary_php package is ready to be used as-is in your Apache server. (other servers are also supported, but the access restrictions set in .htaccess might not work).
10 | As described in cloudinary\_php main README.md file, you have to set up your Cloudinary credentials either by passing it as the `CLOUDINARY_URL` environment variable or calling Cloudinary::config().
11 | Each sample tries to include `settings.php` (`Config/CloudinaryPrivate.php` for PhotoAlbumCake) for configuration data - you can use the included `settings.php.sample` as a basis for such file.
12 |
13 | ## Basic sample
14 |
15 | This sample is a synchronous script that shows the upload process from local file, remote URL, with different transformations and options.
16 |
17 | You can access it through http://YOUR\_SERVER/PATH\_TO\_CLOUDINARY\_PHP/samples/basic/basic.php
18 |
19 | Another option is available if you are using PHP 5.4 or higher.
20 |
21 | First install the library:
22 |
23 | ```bash
24 | php composer.phar dump-autoload --optimize
25 | ```
26 |
27 | Then run the basic sample:
28 |
29 | ```bash
30 | php -S localhost:8001 -t samples/basic
31 | ```
32 |
33 | Then you can simply browse to: [http://localhost:8001/basic.php](http://localhost:8001/basic.php)
34 |
35 | ## Photo Album
36 |
37 | A simple web application that allows you to uploads photos, maintain a database with references to them, list them with their metadata, and display them using various cloud-based transformations.
38 |
39 | Make sure to first create a MySQL database (e.g., `create database photo_album`). Then edit `settings.php` to have the correct database details. For example:
40 |
41 | R::setup('mysql:host=127.0.0.1;dbname=photo_album', 'my_db_user', 'my_db_password');
42 |
43 | You can access it through http://YOUR\_SERVER/PATH\_TO\_CLOUDINARY\_PHP/samples/PhotoAlbum/list.php
44 |
45 | Another option is available if you are using PHP 5.4 or higher.
46 |
47 | First install the library:
48 |
49 | ```bash
50 | php composer.phar dump-autoload --optimize
51 | ```
52 |
53 | Then run the basic sample:
54 |
55 | ```bash
56 | php -S localhost:8001 -t samples/PhotoAlbum
57 | ```
58 |
59 | Then you can simply browse to: [http://localhost:8001/list.php](http://localhost:8001/list.php)
60 |
61 | ## Photo Album Cake
62 |
63 | See the [Cloudinary CakePHP project](https://github.com/cloudinary/cloudinary_cake_php/tree/master/samples).
64 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/composer/autoload_real.php:
--------------------------------------------------------------------------------
1 | = 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27 | if ($useStaticLoader) {
28 | require_once __DIR__ . '/autoload_static.php';
29 |
30 | call_user_func(\Composer\Autoload\ComposerStaticInit5c25c0b3ade6fd5d8c71f7583081bcfe::getInitializer($loader));
31 | } else {
32 | $map = require __DIR__ . '/autoload_namespaces.php';
33 | foreach ($map as $namespace => $path) {
34 | $loader->set($namespace, $path);
35 | }
36 |
37 | $map = require __DIR__ . '/autoload_psr4.php';
38 | foreach ($map as $namespace => $path) {
39 | $loader->setPsr4($namespace, $path);
40 | }
41 |
42 | $classMap = require __DIR__ . '/autoload_classmap.php';
43 | if ($classMap) {
44 | $loader->addClassMap($classMap);
45 | }
46 | }
47 |
48 | $loader->register(true);
49 |
50 | if ($useStaticLoader) {
51 | $includeFiles = Composer\Autoload\ComposerStaticInit5c25c0b3ade6fd5d8c71f7583081bcfe::$files;
52 | } else {
53 | $includeFiles = require __DIR__ . '/autoload_files.php';
54 | }
55 | foreach ($includeFiles as $fileIdentifier => $file) {
56 | composerRequire5c25c0b3ade6fd5d8c71f7583081bcfe($fileIdentifier, $file);
57 | }
58 |
59 | return $loader;
60 | }
61 | }
62 |
63 | function composerRequire5c25c0b3ade6fd5d8c71f7583081bcfe($fileIdentifier, $file)
64 | {
65 | if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66 | require $file;
67 |
68 | $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/controllers/Adminhtml/CloudinaryajaxController.php:
--------------------------------------------------------------------------------
1 | _validateSecretKey()) {
12 | throw new Exception('Incorrect security key');
13 | }
14 |
15 | $freeTransform = $this->getRequest()->getParam('free');
16 | $freeModel = Mage::getModel('cloudinary_cloudinary/system_config_free');
17 | $url = $freeModel->sampleImageUrl($freeModel->defaultTransform($freeTransform));
18 | $this->validate($freeModel, $url);
19 | $this->jsonResponse(
20 | 200,
21 | array('url' => $url)
22 | );
23 | } catch (\Exception $e) {
24 | $this->jsonResponse(401, array('error' => $e->getMessage()));
25 | }
26 | }
27 |
28 | public function imageAction()
29 | {
30 | try {
31 | $freeModel = Mage::getModel('cloudinary_cloudinary/system_config_free');
32 |
33 | $url = $freeModel->namedImageUrl(
34 | $this->getRequest()->getParam('image'),
35 | $freeModel->defaultTransform($this->getRequest()->getParam('free'))
36 | );
37 |
38 | $this->validate($freeModel, $url);
39 |
40 | $this->jsonResponse(
41 | 200,
42 | array('url' => $url)
43 | );
44 | } catch (\Exception $e) {
45 | $this->jsonResponse(401, array('error' => $e->getMessage()));
46 | }
47 | }
48 |
49 | /**
50 | * @param int $code
51 | * @param array $payload
52 | */
53 | private function jsonResponse($code, array $payload)
54 | {
55 | $this->getResponse()
56 | ->clearHeaders()
57 | ->setHeader('Content-type', 'application/json')
58 | ->setHttpResponseCode($code)
59 | ->setBody(Mage::helper('core')->jsonEncode($payload));
60 | }
61 |
62 | /**
63 | * @param Cloudinary_Cloudinary_Model_System_Config_Free $model
64 | * @param string $url
65 | * @throws Exception
66 | */
67 | private function validate(Cloudinary_Cloudinary_Model_System_Config_Free $model, $url)
68 | {
69 | if (!$model->hasAccountConfigured()) {
70 | throw new \Exception('Cloudinary credentials required');
71 | }
72 |
73 | $model->validateImageUrl($url);
74 | }
75 |
76 | /**
77 | * @return bool
78 | */
79 | protected function _isAllowed()
80 | {
81 | return parent::_isAllowed();
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Image.php:
--------------------------------------------------------------------------------
1 | _imageFullPathFromImageDetails($imageDetails);
20 | $relativePath = $configuration->isFolderedMigration() ? $configuration->getMigratedPath($fullPath) : '';
21 |
22 | $imageProvider->upload(Image::fromPath($fullPath, $relativePath));
23 |
24 | Mage::getModel('cloudinary_cloudinary/logger')->notice(sprintf(self::UPLOAD_MESSAGE, $relativePath));
25 |
26 | Mage::getModel('cloudinary_cloudinary/synchronisation')
27 | ->setValueId($imageDetails['value_id'])
28 | ->setValue($imageDetails['file'])
29 | ->tagAsSynchronized();
30 | }
31 |
32 | /**
33 | * @param array $imageDetails
34 | * @return string
35 | * @throws Cloudinary_Cloudinary_Model_Exception_BadFilePathException
36 | */
37 | private function _imageFullPathFromImageDetails(array $imageDetails)
38 | {
39 | return $this->_getMediaBasePath() . $this->_getImageDetailFromKey($imageDetails, 'file');
40 | }
41 |
42 | /**
43 | * @param array $imageDetails
44 | * @param string $key
45 | * @return string
46 | * @throws Cloudinary_Cloudinary_Model_Exception_BadFilePathException
47 | */
48 | private function _getImageDetailFromKey(array $imageDetails, $key)
49 | {
50 | if (!array_key_exists($key, $imageDetails)) {
51 | throw new BadFilePathException("Invalid image data structure. Missing " . $key);
52 | }
53 |
54 | return $imageDetails[$key];
55 | }
56 |
57 | /**
58 | * @return string
59 | */
60 | private function _getMediaBasePath()
61 | {
62 | return Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath();
63 | }
64 |
65 | /**
66 | * @param string $imagePath
67 | * @return string
68 | */
69 | public function getUrl($imagePath)
70 | {
71 | $imageProvider = CloudinaryImageProvider::fromConfiguration(
72 | Mage::getModel('cloudinary_cloudinary/configuration')
73 | );
74 |
75 | return (string)$imageProvider->transformImage(Cloudinary_Cloudinary_Helper_Image::newApiImage($imagePath));
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Logger.php:
--------------------------------------------------------------------------------
1 | log($message, Zend_Log::WARN);
17 | }
18 |
19 | /**
20 | * @param string $message
21 | * @param array $context
22 | */
23 | public function notice($message, array $context = array())
24 | {
25 | $this->log($message, Zend_Log::NOTICE);
26 | }
27 |
28 | /**
29 | * @param string $message
30 | * @param array $context
31 | */
32 | public function error($message, array $context = array())
33 | {
34 | $this->log($message, Zend_Log::ERR);
35 | }
36 |
37 | /**
38 | * @param string $message
39 | */
40 | public function debugLog($message)
41 | {
42 | if (Mage::getIsDeveloperMode()){
43 | Mage::log($this->getSignature() . $message . "\n", 1, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['class']);
44 | }
45 | }
46 |
47 | /**
48 | * @param string $message
49 | * @param string $type
50 | */
51 | private function log($message, $type)
52 | {
53 | if ($this->isActive()) {
54 | Mage::log(
55 | sprintf(self::MESSAGE_FORMAT, $message),
56 | $type,
57 | $this->filename(),
58 | self::IGNORE_GLOBAL_LOG_FLAG
59 | );
60 | }
61 | }
62 |
63 | /**
64 | * @return bool
65 | */
66 | public function isActive()
67 | {
68 | return Mage::getModel('cloudinary_cloudinary/configuration')->hasLoggingActive();
69 | }
70 |
71 | /**
72 | * @return string|null
73 | */
74 | public function filename()
75 | {
76 | $filename = preg_replace(
77 | self::ALPHANUM_REGEX,
78 | '',
79 | Mage::getModel('cloudinary_cloudinary/configuration')->getLoggingFilename()
80 | );
81 |
82 | return $filename ? sprintf('%s.log', $filename) : null;
83 | }
84 |
85 | /**
86 | * Add extra information to a log entry: class and funcion name from which the log is called
87 | * @return string
88 | */
89 | public static function getSignature()
90 | {
91 | $parentTrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2];
92 | $logSignature = sprintf(self::SIGNATURE_TEMPLATE, $parentTrace['class'], $parentTrace['function']);
93 | return $logSignature;
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/composer/autoload_classmap.php:
--------------------------------------------------------------------------------
1 | $vendorDir . '/cloudinary/cloudinary_php/src/Cloudinary.php',
10 | 'CloudinaryField' => $vendorDir . '/cloudinary/cloudinary_php/src/CloudinaryField.php',
11 | 'Cloudinary\\Api' => $vendorDir . '/cloudinary/cloudinary_php/src/Api.php',
12 | 'Cloudinary\\Api\\AlreadyExists' => $vendorDir . '/cloudinary/cloudinary_php/src/Api/AlreadyExists.php',
13 | 'Cloudinary\\Api\\AuthorizationRequired' => $vendorDir . '/cloudinary/cloudinary_php/src/Api/AuthorizationRequired.php',
14 | 'Cloudinary\\Api\\BadRequest' => $vendorDir . '/cloudinary/cloudinary_php/src/Api/BadRequest.php',
15 | 'Cloudinary\\Api\\Error' => $vendorDir . '/cloudinary/cloudinary_php/src/Api/Error.php',
16 | 'Cloudinary\\Api\\GeneralError' => $vendorDir . '/cloudinary/cloudinary_php/src/Api/GeneralError.php',
17 | 'Cloudinary\\Api\\NotAllowed' => $vendorDir . '/cloudinary/cloudinary_php/src/Api/NotAllowed.php',
18 | 'Cloudinary\\Api\\NotFound' => $vendorDir . '/cloudinary/cloudinary_php/src/Api/NotFound.php',
19 | 'Cloudinary\\Api\\RateLimited' => $vendorDir . '/cloudinary/cloudinary_php/src/Api/RateLimited.php',
20 | 'Cloudinary\\Api\\Response' => $vendorDir . '/cloudinary/cloudinary_php/src/Api/Response.php',
21 | 'Cloudinary\\AuthToken' => $vendorDir . '/cloudinary/cloudinary_php/src/AuthToken.php',
22 | 'Cloudinary\\Cache\\Adapter\\CacheAdapter' => $vendorDir . '/cloudinary/cloudinary_php/src/Cache/Adapter/CacheAdapter.php',
23 | 'Cloudinary\\Cache\\Adapter\\KeyValueCacheAdapter' => $vendorDir . '/cloudinary/cloudinary_php/src/Cache/Adapter/KeyValueCacheAdapter.php',
24 | 'Cloudinary\\Cache\\ResponsiveBreakpointsCache' => $vendorDir . '/cloudinary/cloudinary_php/src/Cache/ResponsiveBreakpointsCache.php',
25 | 'Cloudinary\\Cache\\Storage\\FileSystemKeyValueStorage' => $vendorDir . '/cloudinary/cloudinary_php/src/Cache/Storage/FileSystemKeyValueStorage.php',
26 | 'Cloudinary\\Cache\\Storage\\KeyValueStorage' => $vendorDir . '/cloudinary/cloudinary_php/src/Cache/Storage/KeyValueStorage.php',
27 | 'Cloudinary\\Error' => $vendorDir . '/cloudinary/cloudinary_php/src/Error.php',
28 | 'Cloudinary\\HttpClient' => $vendorDir . '/cloudinary/cloudinary_php/src/HttpClient.php',
29 | 'Cloudinary\\PreloadedFile' => $vendorDir . '/cloudinary/cloudinary_php/src/PreloadedFile.php',
30 | 'Cloudinary\\Search' => $vendorDir . '/cloudinary/cloudinary_php/src/Search.php',
31 | 'Cloudinary\\SignatureVerifier' => $vendorDir . '/cloudinary/cloudinary_php/src/SignatureVerifier.php',
32 | 'Cloudinary\\Uploader' => $vendorDir . '/cloudinary/cloudinary_php/src/Uploader.php',
33 | 'Cloudinary\\Utils\\Singleton' => $vendorDir . '/cloudinary/cloudinary_php/src/Utils/Singleton.php',
34 | );
35 |
--------------------------------------------------------------------------------
/app/code/community/Cloudinary/Cloudinary/Model/Migration.php:
--------------------------------------------------------------------------------
1 | _init('cloudinary_cloudinary/migration');
13 | }
14 |
15 | /**
16 | * @return bool
17 | */
18 | public function loadType($type = self::UPLOAD_MIGRATION_TYPE)
19 | {
20 | $col = $this->getCollection()->addFieldToFilter('type', $type)->setPageSize(1);
21 | return $col->count() ? $col->getFirstItem() : $this->setType($type);
22 | }
23 |
24 | /**
25 | * @return bool
26 | */
27 | public function hasStarted()
28 | {
29 | return (bool) $this->getStarted();
30 | }
31 |
32 | /**
33 | * @return bool
34 | */
35 | public function hasBeenStopped()
36 | {
37 | $this->load($this->getId());
38 | return (bool) $this->getStarted() == 0;
39 | }
40 |
41 | public function stop()
42 | {
43 | $this->setStarted(0);
44 | $this->save();
45 | }
46 |
47 | public function start()
48 | {
49 | $this->setStarted(1);
50 | $this->setStartedAt($this->_dateNow());
51 | $this->setBatchCount(0);
52 | $this->setInfo('[]');
53 | $this->save();
54 | }
55 |
56 | public function recordBatchProgress()
57 | {
58 | if ($this->hasStarted()) {
59 | $this->setBatchCount($this->getBatchCount() + 1)->save();
60 | }
61 |
62 | return $this;
63 | }
64 |
65 | /**
66 | * @return bool
67 | */
68 | public function hasProgress()
69 | {
70 | return $this->getBatchCount() > 0;
71 | }
72 |
73 | /**
74 | * @return int
75 | */
76 | public function timeElapsed()
77 | {
78 | $calendar = Mage::getModel('core/date');
79 | return $calendar->timestamp($this->_dateNow()) - $calendar->timestamp($this->getStartedAt());
80 | }
81 |
82 | /**
83 | * @return string
84 | */
85 | private function _dateNow()
86 | {
87 | return Mage::getModel('core/date')->date('Y/m/d H:i:s');
88 | }
89 |
90 | public function getInfo()
91 | {
92 | $info = $this->getData('info');
93 | if (is_array($info) || is_object($info)) {
94 | return $info;
95 | } else {
96 | return (array) @json_decode($info, true);
97 | }
98 | }
99 |
100 | public function setInfo($info)
101 | {
102 | if (is_array($info) || is_object($info)) {
103 | $info = json_encode($info);
104 | }
105 |
106 | return $this->setData('info', $info);
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/CloudinaryImageManager.php:
--------------------------------------------------------------------------------
1 | cloudinaryImageProvider = $cloudinaryImageProvider;
40 | $this->synchronisationRepository = $synchronisationRepository;
41 | }
42 |
43 | /**
44 | * @param Image $image
45 | * @param OutputInterface|null $output
46 | * @throws \Exception
47 | */
48 | public function uploadAndSynchronise(Image $image, OutputInterface $output = null, $retryAttempt = 0)
49 | {
50 | try {
51 | $this->report($output, sprintf(self::MESSAGE_UPLOADING_IMAGE, $image));
52 | $this->cloudinaryImageProvider->upload($image);
53 | } catch (FileExists $e) {
54 | $this->report($output, sprintf(self::MESSAGE_UPLOADED_EXISTS, $image));
55 | } catch (\Exception $e) {
56 | if ($retryAttempt < self::MAXIMUM_RETRY_ATTEMPTS) {
57 | $retryAttempt++;
58 | $this->report($output, sprintf(self::MESSAGE_RETRY, $e->getMessage(), $retryAttempt));
59 | usleep(rand(10, 1000) * 1000);
60 | $this->uploadAndSynchronise($image, $output, $retryAttempt);
61 | return;
62 | }
63 |
64 | throw $e;
65 | }
66 |
67 | $this->synchronisationRepository->saveAsSynchronized($image->getRelativePath());
68 | }
69 |
70 | /**
71 | * @param Image $image
72 | */
73 | public function removeAndUnSynchronise(Image $image)
74 | {
75 | $this->cloudinaryImageProvider->delete($image);
76 | $this->synchronisationRepository->removeSynchronised($image->getRelativePath());
77 | }
78 |
79 | /**
80 | * @param OutputInterface|null $output
81 | * @param string $message
82 | */
83 | private function report(OutputInterface $output = null, $message = '')
84 | {
85 | if ($output) {
86 | $output->writeln($message);
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/Image/Transformation.php:
--------------------------------------------------------------------------------
1 | crop = 'lpad';
28 | $this->flags = [];
29 | }
30 |
31 | public function withGravity(Gravity $gravity)
32 | {
33 | $this->gravity = $gravity;
34 | $this->crop = ((string)$gravity) ? 'crop' : 'lpad';
35 | return $this;
36 | }
37 |
38 | public function withDimensions(Dimensions $dimensions)
39 | {
40 | $this->dimensions = $dimensions;
41 | return $this;
42 | }
43 |
44 | public function withCrop(Crop $crop)
45 | {
46 | $this->crop = $crop;
47 | return $this;
48 | }
49 |
50 | public function withFetchFormat(FetchFormat $fetchFormat)
51 | {
52 | $this->fetchFormat = $fetchFormat;
53 | return $this;
54 | }
55 |
56 | public function withQuality(Quality $quality)
57 | {
58 | $this->quality = $quality;
59 | return $this;
60 | }
61 |
62 | public function withDpr(Dpr $dpr)
63 | {
64 | $this->dpr = $dpr;
65 | return $this;
66 | }
67 |
68 | public function withFreeform(Freeform $freeform, $append = true)
69 | {
70 | $this->freeform = trim(($append) ? $this->freeform . "," . $freeform : $freeform, ",");
71 | return $this;
72 | }
73 |
74 | public function addFlags(array $flags = [])
75 | {
76 | $this->flags += $flags;
77 | return $this;
78 | }
79 |
80 | public static function builder()
81 | {
82 | return new Transformation();
83 | }
84 |
85 | public function build()
86 | {
87 | return [
88 | ['raw_transformation' => (string)$this->freeform],
89 | [
90 | 'fetch_format' => (string)$this->fetchFormat,
91 | 'quality' => (string)$this->quality ?: null,
92 | 'crop' => (string)$this->crop,
93 | 'gravity' => (string)$this->gravity ?: null,
94 | 'width' => $this->dimensions ? $this->dimensions->getWidth() : null,
95 | 'height' => $this->dimensions ? $this->dimensions->getHeight() : null,
96 | 'dpr' => (string)$this->dpr,
97 | 'flags' => $this->flags
98 | ]
99 | ];
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/tests/HttpClientTest.php:
--------------------------------------------------------------------------------
1 | self::$http_client_test_id]);
32 | }
33 |
34 | public static function tearDownAfterClass()
35 | {
36 | if (!Cloudinary::config_get("api_secret")) {
37 | self::fail("You need to configure the cloudinary api for the tests to work.");
38 | }
39 |
40 | $api = new Cloudinary\Api();
41 |
42 | try {
43 | $api->delete_resources([self::$http_client_test_id]);
44 | } catch (\Exception $e) {
45 | }
46 | }
47 |
48 | public function setUp()
49 | {
50 | $this->httpClient = new HttpClient();
51 | }
52 |
53 |
54 | /**
55 | * @throws Error
56 | */
57 | public function testHttpClientGetJSON()
58 | {
59 | $json_options = ['width'=> 'auto:breakpoints:json'];
60 | $json_url = Cloudinary::cloudinary_url(self::$http_client_test_id, $json_options);
61 | $json = $this->httpClient->getJSON($json_url);
62 |
63 | $this->assertArrayHasKey('breakpoints', $json);
64 | $this->assertTrue(is_array($json['breakpoints']));
65 | }
66 |
67 | /**
68 | * Should throw Cloudinary\Error on invalid or non JSON reponse
69 | */
70 | public function testHttpClientGetJSONNonJSON()
71 | {
72 | $url = Cloudinary::cloudinary_url(self::$http_client_test_id);
73 |
74 | $message = "";
75 |
76 | try {
77 | $this->httpClient->getJSON($url);
78 | $this->fail("Cloudinary\Error expected");
79 | } catch (Cloudinary\Error $e) {
80 | $message = $e->getMessage();
81 | }
82 |
83 | self::assertStringStartsWith("Error parsing server response", $message);
84 | }
85 |
86 | /**
87 | * Should throw Cloudinary\Error on invalid or non existing URL
88 | */
89 | public function testHttpClientGetJSONInvalidURL()
90 | {
91 | $url = Cloudinary::cloudinary_url(self::$http_client_test_id . '_non_existing');
92 |
93 | $message = "";
94 |
95 | try {
96 | $this->httpClient->getJSON($url);
97 | $this->fail("Cloudinary\Error expected");
98 | } catch (Cloudinary\Error $e) {
99 | $message = $e->getMessage();
100 | }
101 |
102 | self::assertStringStartsWith("Server returned unexpected status code", $message);
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/lib/CloudinaryExtension/vendor/cloudinary/cloudinary_php/src/Cache/Storage/FileSystemKeyValueStorage.php:
--------------------------------------------------------------------------------
1 | rootPath = $rootPath;
38 | }
39 |
40 | /**
41 | * {@inheritdoc}
42 | */
43 | public function get($key)
44 | {
45 | if (!$this->exists($key)) {
46 | return null;
47 | }
48 |
49 | return file_get_contents($this->getKeyFullPath($key));
50 | }
51 |
52 | /**
53 | * {@inheritdoc}
54 | */
55 | public function set($key, $value)
56 | {
57 | $bytesWritten = file_put_contents($this->getKeyFullPath($key), $value);
58 |
59 | if ($bytesWritten === false) {
60 | return false;
61 | }
62 |
63 | return true;
64 | }
65 |
66 | /**
67 | * {@inheritdoc}
68 | */
69 | public function delete($key)
70 | {
71 | if (!$this->exists($key)) {
72 | return true;
73 | }
74 |
75 | return unlink($this->getKeyFullPath($key));
76 | }
77 |
78 | /**
79 | * {@inheritdoc}
80 | */
81 | public function clear()
82 | {
83 | $success = true;
84 |
85 | $cacheItems = new GlobIterator($this->rootPath . DIRECTORY_SEPARATOR . "*" . self::$itemExt);
86 |
87 | if (!$cacheItems->count()) {
88 | return true;
89 | }
90 |
91 | foreach ($cacheItems as $itemPath) {
92 | if (!unlink($itemPath)) {
93 | $success = false;
94 | }
95 | }
96 |
97 | return $success;
98 | }
99 |
100 | /**
101 | * Generate the file path for the $key.
102 | *
103 | * @param string $key
104 | *
105 | * @return string The absolute path of the value file associated with the $key.
106 | */
107 | private function getKeyFullPath($key)
108 | {
109 | return $this->rootPath . DIRECTORY_SEPARATOR . $key . self::$itemExt;
110 | }
111 |
112 | /**
113 | * Indicate whether key exists
114 | *
115 | * @param string $key
116 | *
117 | * @return bool True if the file for the given $key exists.
118 | */
119 | private function exists($key)
120 | {
121 | return file_exists($this->getKeyFullPath($key));
122 | }
123 | }
124 |
--------------------------------------------------------------------------------