Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mage_Downloadable - DOC block update #772

Merged
merged 1 commit into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
* @package Mage_Adminhtml
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Downloadable_Block_Adminhtml_Catalog_Product_Composite_Fieldset_Downloadable
extends Mage_Downloadable_Block_Catalog_Product_Links
class Mage_Downloadable_Block_Adminhtml_Catalog_Product_Composite_Fieldset_Downloadable extends Mage_Downloadable_Block_Catalog_Product_Links
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
* @package Mage_Downloadable
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable
extends Mage_Adminhtml_Block_Widget implements Mage_Adminhtml_Block_Widget_Tab_Interface
class Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable extends Mage_Adminhtml_Block_Widget implements Mage_Adminhtml_Block_Widget_Tab_Interface
{

/**
Expand Down Expand Up @@ -156,13 +155,13 @@ protected function _toHtml()
'title' => Mage::helper('adminhtml')->__('Links'),
'content' => $this->getLayout()->createBlock(
'downloadable/adminhtml_catalog_product_edit_tab_downloadable_links',
'catalog.product.edit.tab.downloadable.links')->toHtml(),
'catalog.product.edit.tab.downloadable.links'
)->toHtml(),
'open' => true,
));

$this->setChild('accordion', $accordion);

return parent::_toHtml();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@
* @category Mage
* @package Mage_Downloadable
* @author Magento Core Team <core@magentocommerce.com>
*
* @method $this setCanEditPrice(bool $value)
* @method bool getCanReadPrice()
* @method $this setCanReadPrice(bool $value)
*/
class Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Links
extends Mage_Uploader_Block_Single
class Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Links extends Mage_Uploader_Block_Single
{
/**
* Purchased Separately Attribute cache
Expand Down Expand Up @@ -151,6 +154,7 @@ public function getIsPriceWebsiteScope()
public function getLinkData()
{
$linkArr = array();
/** @var Mage_Downloadable_Model_Link[] $links */
$links = $this->getProduct()->getTypeInstance(true)->getLinks($this->getProduct());
$priceWebsiteScope = Mage::helper('downloadable')->getIsPriceWebsiteScope();
foreach ($links as $item) {
Expand All @@ -168,7 +172,8 @@ public function getLinkData()
'sort_order' => $item->getSortOrder(),
);
$file = Mage::helper('downloadable/file')->getFilePath(
Mage_Downloadable_Model_Link::getBasePath(), $item->getLinkFile()
Mage_Downloadable_Model_Link::getBasePath(),
$item->getLinkFile()
);

if ($item->getLinkFile() && !is_file($file)) {
Expand All @@ -190,7 +195,8 @@ public function getLinkData()
));
}
$sampleFile = Mage::helper('downloadable/file')->getFilePath(
Mage_Downloadable_Model_Link::getBaseSamplePath(), $item->getSampleFile()
Mage_Downloadable_Model_Link::getBaseSamplePath(),
$item->getSampleFile()
);
if ($item->getSampleFile() && is_file($sampleFile)) {
$tmpLinkItem['sample_file_save'] = array(
Expand Down Expand Up @@ -240,21 +246,21 @@ public function getConfigMaxDownloads()
* Prepare block Layout
*
*/
protected function _prepareLayout()
protected function _prepareLayout()
{
parent::_prepareLayout();
$this->setChild(
'upload_button',
$this->getLayout()->createBlock('adminhtml/widget_button')->addData(array(
'id' => '',
'label' => Mage::helper('adminhtml')->__('Upload Files'),
'type' => 'button',
'onclick' => 'Downloadable.massUploadByType(\'links\');Downloadable.massUploadByType(\'linkssample\')'
'id' => '',
'label' => Mage::helper('adminhtml')->__('Upload Files'),
'type' => 'button',
'onclick' => 'Downloadable.massUploadByType(\'links\');Downloadable.massUploadByType(\'linkssample\')'
))
);
$this->_addElementIdsMapping(array(
'container' => $this->getHtmlId() . '-new',
'delete' => $this->getHtmlId() . '-delete'
'container' => $this->getHtmlId() . '-new',
'delete' => $this->getHtmlId() . '-delete'
));
}

Expand All @@ -271,9 +277,10 @@ public function getUploadButtonHtml()
/**
* Retrive config json
*
* @param string $type
* @return string
*/
public function getConfigJson($type='links')
public function getConfigJson($type = 'links')
{

$this->getUploaderConfig()
Expand All @@ -290,6 +297,7 @@ public function getConfigJson($type='links')
}

/**
* @param string $type
* @return string
*/
public function getBrowseButtonHtml($type = '')
Expand All @@ -306,6 +314,7 @@ public function getBrowseButtonHtml($type = '')


/**
* @param string $type
* @return string
*/
public function getDeleteButtonHtml($type = '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
* @package Mage_Downloadable
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Samples
extends Mage_Uploader_Block_Single
class Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Samples extends Mage_Uploader_Block_Single
{
/**
* Class constructor
Expand Down Expand Up @@ -89,6 +88,7 @@ public function getAddButtonHtml()
public function getSampleData()
{
$samplesArr = array();
/** @var Mage_Downloadable_Model_Sample[] $samples */
$samples = $this->getProduct()->getTypeInstance(true)->getSamples($this->getProduct());
foreach ($samples as $item) {
$tmpSampleItem = array(
Expand All @@ -99,7 +99,8 @@ public function getSampleData()
'sort_order' => $item->getSortOrder(),
);
$file = Mage::helper('downloadable/file')->getFilePath(
Mage_Downloadable_Model_Sample::getBasePath(), $item->getSampleFile()
Mage_Downloadable_Model_Sample::getBasePath(),
$item->getSampleFile()
);
if ($item->getSampleFile() && !is_file($file)) {
Mage::helper('core/file_storage_database')->saveFileToFilesystem($file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


/**
* Sales Order downloadable items name column renderer
*
Expand All @@ -34,7 +33,14 @@
*/
class Mage_Downloadable_Block_Adminhtml_Sales_Items_Column_Downloadable_Name extends Mage_Adminhtml_Block_Sales_Items_Column_Name
{
/**
* @var Mage_Downloadable_Model_Link_Purchased
*/
protected $_purchased = null;

/**
* @return Mage_Downloadable_Model_Link_Purchased
*/
public function getLinks()
{
$this->_purchased = Mage::getModel('downloadable/link_purchased')
Expand All @@ -45,6 +51,9 @@ public function getLinks()
return $this->_purchased;
}

/**
* @return string
*/
public function getLinksTitle()
{
if ($this->_purchased && $this->_purchased->getLinkSectionTitle()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ public function getJsonConfig()
return $coreHelper->jsonEncode($config);
}

/**
* @param Mage_Downloadable_Model_Link $link
* @return string
*/
public function getLinkSamlpeUrl($link)
{
return $this->getUrl('downloadable/download/linkSample', array('link_id' => $link->getId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public function getSamples()
->getSamples($this->getProduct());
}

/**
* @param Mage_Downloadable_Model_Sample $sample
* @return string
*/
public function getSampleUrl($sample)
{
return $this->getUrl('downloadable/download/sample', array('sample_id' => $sample->getId()));
Expand Down
15 changes: 12 additions & 3 deletions app/code/core/Mage/Downloadable/Block/Customer/Products/List.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@
* @category Mage
* @package Mage_Downloadable
* @author Magento Core Team <core@magentocommerce.com>
*
* @method Mage_Downloadable_Model_Resource_Link_Purchased_Item_Collection getItems()
* @method $this setItems(Mage_Downloadable_Model_Resource_Link_Purchased_Item_Collection $value)
* @method Mage_Downloadable_Model_Resource_Link_Purchased_Collection getPurchased()
* @method $this setPurchased(Mage_Downloadable_Model_Resource_Link_Purchased_Collection $value)
* @method string getRefererUrl()
* @method $this setRefererUrl(string $value)
*/
class Mage_Downloadable_Block_Customer_Products_List extends Mage_Core_Block_Template
{

/**
* Class constructor
*/
Expand All @@ -46,6 +52,7 @@ public function __construct()
->addOrder('created_at', 'desc');
$this->setPurchased($purchased);
$purchasedIds = array();
/** @var Mage_Downloadable_Model_Link_Purchased_Item $_item */
foreach ($purchased as $_item) {
$purchasedIds[] = $_item->getId();
}
Expand All @@ -54,7 +61,8 @@ public function __construct()
}
$purchasedItems = Mage::getResourceModel('downloadable/link_purchased_item_collection')
->addFieldToFilter('purchased_id', array('in' => $purchasedIds))
->addFieldToFilter('status',
->addFieldToFilter(
'status',
array(
'nin' => array(
Mage_Downloadable_Model_Link_Purchased_Item::LINK_STATUS_PENDING_PAYMENT,
Expand All @@ -79,6 +87,7 @@ protected function _prepareLayout()
->setCollection($this->getItems());
$this->setChild('pager', $pager);
$this->getItems()->load();
/** @var Mage_Downloadable_Model_Link_Purchased_Item $item */
foreach ($this->getItems() as $item) {
$item->setPurchased($this->getPurchased()->getItemById($item->getPurchasedId()));
}
Expand Down Expand Up @@ -112,6 +121,7 @@ public function getBackUrl()
/**
* Return number of left downloads or unlimited
*
* @param Mage_Downloadable_Model_Link_Purchased_Item $item
* @return string
*/
public function getRemainingDownloads($item)
Expand Down Expand Up @@ -143,5 +153,4 @@ public function getIsOpenInNewWindow()
{
return Mage::getStoreConfigFlag(Mage_Downloadable_Model_Link::XML_PATH_TARGET_NEW_WINDOW);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,24 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


/**
* Downlaodable Sales Order Email items renderer
*
* @category Mage
* @package Mage_Downloadable
* @author Magento Core Team <core@magentocommerce.com>
*
* @method Mage_Downloadable_Model_Link_Purchased_Item getItem()
*/
class Mage_Downloadable_Block_Sales_Order_Email_Items_Downloadable extends Mage_Sales_Block_Order_Email_Items_Default
{
/**
* @var Mage_Downloadable_Model_Link_Purchased
*/
protected $_purchased = null;

/**
* Enter description here...
*
* @return unknown
* @return Mage_Downloadable_Model_Link_Purchased
*/
public function getLinks()
{
Expand All @@ -52,6 +54,9 @@ public function getLinks()
return $this->_purchased;
}

/**
* @return string
*/
public function getLinksTitle()
{
if ($this->_purchased->getLinkSectionTitle()) {
Expand All @@ -60,6 +65,10 @@ public function getLinksTitle()
return Mage::getStoreConfig(Mage_Downloadable_Model_Link::XML_PATH_LINKS_TITLE);
}

/**
* @param Mage_Downloadable_Model_Link_Purchased_Item $item
* @return string
*/
public function getPurchasedLinkUrl($item)
{
return $this->getUrl('downloadable/download/link', array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,24 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


/**
* Downloadable Sales Order Email items renderer
*
* @category Mage
* @package Mage_Downloadable
* @author Magento Core Team <core@magentocommerce.com>
*
* @method Mage_Downloadable_Model_Link_Purchased_Item getItem()
*/
class Mage_Downloadable_Block_Sales_Order_Email_Items_Order_Downloadable extends Mage_Sales_Block_Order_Email_Items_Order_Default
{
/**
* @var Mage_Downloadable_Model_Link_Purchased
*/
protected $_purchased = null;

/**
* Enter description here...
*
* @return unknown
* @return Mage_Downloadable_Model_Link_Purchased
*/
public function getLinks()
{
Expand All @@ -52,6 +54,9 @@ public function getLinks()
return $this->_purchased;
}

/**
* @return mixed
*/
public function getLinksTitle()
{
if ($this->_purchased->getLinkSectionTitle()) {
Expand All @@ -60,6 +65,10 @@ public function getLinksTitle()
return Mage::getStoreConfig(Mage_Downloadable_Model_Link::XML_PATH_LINKS_TITLE);
}

/**
* @param Mage_Downloadable_Model_Link_Purchased_Item $item
* @return string
*/
public function getPurchasedLinkUrl($item)
{
return $this->getUrl('downloadable/download/link', array(
Expand Down
Loading