-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from cloudinary/v3.0.1
V3.0.1
- Loading branch information
Showing
55 changed files
with
3,042 additions
and
361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
app/code/community/Cloudinary/Cloudinary/Block/Adminhtml/Catalog/Product/Edit/Tab.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 156 additions & 0 deletions
156
...e/community/Cloudinary/Cloudinary/Block/Adminhtml/Cms/Wysiwyg/Images/Content/Uploader.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
<?php | ||
|
||
class Cloudinary_Cloudinary_Block_Adminhtml_Cms_Wysiwyg_Images_Content_Uploader extends Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Content_Uploader | ||
{ | ||
/** | ||
* Default browse button ID suffix | ||
*/ | ||
const DEFAULT_CLD_ML_BUTTON_ID_SUFFIX = 'cld_ml'; | ||
|
||
/** | ||
* Template used for uploader | ||
* | ||
* @var string | ||
*/ | ||
protected $_template = 'cloudinary/media/uploader.phtml'; | ||
|
||
/** | ||
* Render block HTML | ||
* | ||
* @return string | ||
*/ | ||
protected function _toHtml() | ||
{ | ||
$this->setTemplate('cloudinary/media/uploader.phtml'); | ||
return parent::_toHtml(); | ||
} | ||
|
||
/** | ||
* Prepare layout, create buttons, set front-end elements ids | ||
* | ||
* @return Mage_Core_Block_Abstract | ||
*/ | ||
protected function _prepareLayout() | ||
{ | ||
parent::_prepareLayout(); | ||
|
||
if (Mage::getModel('cloudinary_cloudinary/configuration')->isEnabled()) { | ||
$this->setChild( | ||
'cloudinary_ml_button', | ||
$this->getLayout()->createBlock('adminhtml/widget_button') | ||
->addData(array( | ||
// Workaround for IE9 | ||
'before_html' => sprintf( | ||
'<div style="display:inline-block;" id="%s">', | ||
$this->getElementId(self::DEFAULT_CLD_ML_BUTTON_ID_SUFFIX) | ||
), | ||
'after_html' => '</div> | ||
<script type="text/javascript"> | ||
//<![CDATA[ | ||
var ' . self::DEFAULT_CLD_ML_BUTTON_ID_SUFFIX . '_instance_' . $this->getHtmlId() . ' = new CloudinaryMediaLibrary(' . $this->getCloudinaryMediaLibraryWidgetOptions() . '); | ||
//]]> | ||
</script>', | ||
'id' => $this->getElementId(self::DEFAULT_CLD_ML_BUTTON_ID_SUFFIX . '_button'), | ||
'label' => Mage::helper('uploader')->__('Add From Cloudinary...'), | ||
'type' => 'button', | ||
)) | ||
); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Get CLD ML button html | ||
* | ||
* @return string | ||
*/ | ||
public function getCldMLButtonHtml() | ||
{ | ||
return $this->getChildHtml('cloudinary_ml_button'); | ||
} | ||
|
||
/** | ||
* Get Cloudinary media library widget options | ||
* | ||
* @param bool $multiple Allow multiple | ||
* @param bool $refresh Refresh options | ||
* @return string | ||
*/ | ||
public function getCloudinaryMediaLibraryWidgetOptions($multiple = true, $refresh = false) | ||
{ | ||
if (!($cloudinaryMLoptions = Mage::helper('cloudinary_cloudinary/MediaLibraryHelper')->getCloudinaryMLOptions($multiple, $refresh))) { | ||
return null; | ||
} | ||
return Mage::helper('core')->jsonEncode(array( | ||
'htmlId' => $this->getHtmlId(), | ||
'cldMLid' => self::DEFAULT_CLD_ML_BUTTON_ID_SUFFIX . '_' . $this->getHtmlId(), | ||
'imageUploaderUrl' => $this->getCldImageUploaderUrl(), | ||
'buttonSelector' => '#' . $this->getElementId(self::DEFAULT_CLD_ML_BUTTON_ID_SUFFIX . '_button'), | ||
'triggerSelector' => $this->getTriggerSelector(), | ||
'triggerEvent' => $this->getTriggerEvent(), | ||
'callbackHandler' => $this->getCallbackHandler(), | ||
'callbackHandlerMethod' => $this->getCallbackHandlerMethod(), | ||
'useDerived' => $this->getUseDerived(), | ||
'addTmpExtension' => $this->getAddTmpExtension(), | ||
'cloudinaryMLoptions' => $cloudinaryMLoptions, | ||
'cloudinaryMLshowOptions' => Mage::helper('cloudinary_cloudinary/MediaLibraryHelper')->getCloudinaryMLshowOptions('image'), | ||
)); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getCldImageUploaderUrl() | ||
{ | ||
return Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('*/cloudinaryretrieveimage/upload', array('type' => 'wysiwyg_image')); | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
protected function getAddTmpExtension() | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
protected function getUseDerived() | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
protected function getTriggerEvent() | ||
{ | ||
return 'addItem'; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
protected function getTriggerSelector() | ||
{ | ||
return 'triggerSelector'; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
protected function getCallbackHandler() | ||
{ | ||
return 'window.MediabrowserInstance'; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
protected function getCallbackHandlerMethod() | ||
{ | ||
return 'selectFolder'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.