Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Downloadable_Adminhtml_Downloadable_FileController
  • Mage_Downloadable_Adminhtml_Downloadable_Product_EditController
  • Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable
  • Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Links
  • Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Samples
  • Mage_Downloadable_Block_Adminhtml_Sales_Items_Column_Downloadable_Name
  • Mage_Downloadable_Block_Catalog_Product_Links
  • Mage_Downloadable_Block_Catalog_Product_Samples
  • Mage_Downloadable_Block_Catalog_Product_View_Type
  • Mage_Downloadable_Block_Checkout_Cart_Item_Renderer
  • Mage_Downloadable_Block_Checkout_Success
  • Mage_Downloadable_Block_Customer_Products_List
  • Mage_Downloadable_Block_Sales_Order_Email_Items_Downloadable
  • Mage_Downloadable_Block_Sales_Order_Email_Items_Order_Downloadable
  • Mage_Downloadable_Block_Sales_Order_Item_Renderer_Downloadable
  • Mage_Downloadable_CustomerController
  • Mage_Downloadable_DownloadController
  • Mage_Downloadable_Helper_Catalog_Product_Configuration
  • Mage_Downloadable_Helper_Data
  • Mage_Downloadable_Helper_Download
  • Mage_Downloadable_Helper_File
  • Mage_Downloadable_Model_CatalogIndex_Data_Downloadable
  • Mage_Downloadable_Model_Link
  • Mage_Downloadable_Model_Link_Api
  • Mage_Downloadable_Model_Link_Api_Uploader
  • Mage_Downloadable_Model_Link_Api_V2
  • Mage_Downloadable_Model_Link_Api_Validator
  • Mage_Downloadable_Model_Link_Purchased
  • Mage_Downloadable_Model_Link_Purchased_Item
  • Mage_Downloadable_Model_Mysql4_Indexer_Price
  • Mage_Downloadable_Model_Mysql4_Link
  • Mage_Downloadable_Model_Mysql4_Link_Collection
  • Mage_Downloadable_Model_Mysql4_Link_Purchased
  • Mage_Downloadable_Model_Mysql4_Link_Purchased_Collection
  • Mage_Downloadable_Model_Mysql4_Link_Purchased_Item
  • Mage_Downloadable_Model_Mysql4_Link_Purchased_Item_Collection
  • Mage_Downloadable_Model_Mysql4_Sample
  • Mage_Downloadable_Model_Mysql4_Sample_Collection
  • Mage_Downloadable_Model_Observer
  • Mage_Downloadable_Model_Product_Price
  • Mage_Downloadable_Model_Product_Type
  • Mage_Downloadable_Model_Resource_Indexer_Price
  • Mage_Downloadable_Model_Resource_Link
  • Mage_Downloadable_Model_Resource_Link_Collection
  • Mage_Downloadable_Model_Resource_Link_Purchased
  • Mage_Downloadable_Model_Resource_Link_Purchased_Collection
  • Mage_Downloadable_Model_Resource_Link_Purchased_Item
  • Mage_Downloadable_Model_Resource_Link_Purchased_Item_Collection
  • Mage_Downloadable_Model_Resource_Sample
  • Mage_Downloadable_Model_Resource_Sample_Collection
  • Mage_Downloadable_Model_Sales_Order_Pdf_Items_Abstract
  • Mage_Downloadable_Model_Sales_Order_Pdf_Items_Creditmemo
  • Mage_Downloadable_Model_Sales_Order_Pdf_Items_Invoice
  • Mage_Downloadable_Model_Sample
  • Mage_Downloadable_Model_System_Config_Source_Contentdisposition
  • Mage_Downloadable_Model_System_Config_Source_Orderitemstatus
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Downloadable
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * Adminhtml catalog product downloadable items tab links section
 29:  *
 30:  * @category    Mage
 31:  * @package     Mage_Downloadable
 32:  * @author      Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Samples
 35:     extends Mage_Adminhtml_Block_Widget
 36: {
 37:     /**
 38:      * Class constructor
 39:      *
 40:      */
 41:     public function __construct()
 42:     {
 43:         parent::__construct();
 44:         $this->setTemplate('downloadable/product/edit/downloadable/samples.phtml');
 45:     }
 46: 
 47:     /**
 48:      * Get model of the product that is being edited
 49:      *
 50:      * @return Mage_Catalog_Model_Product
 51:      */
 52:     public function getProduct()
 53:     {
 54:         return Mage::registry('current_product');
 55:     }
 56: 
 57:     /**
 58:      * Check block is readonly
 59:      *
 60:      * @return boolean
 61:      */
 62:     public function isReadonly()
 63:     {
 64:          return $this->getProduct()->getDownloadableReadonly();
 65:     }
 66: 
 67: 
 68:     /**
 69:      * Retrieve Add Button HTML
 70:      *
 71:      * @return string
 72:      */
 73:     public function getAddButtonHtml()
 74:     {
 75:         $addButton = $this->getLayout()->createBlock('adminhtml/widget_button')
 76:             ->setData(array(
 77:                 'label' => Mage::helper('downloadable')->__('Add New Row'),
 78:                 'id' => 'add_sample_item',
 79:                 'class' => 'add',
 80:             ));
 81:         return $addButton->toHtml();
 82:     }
 83: 
 84:     /**
 85:      * Retrieve samples array
 86:      *
 87:      * @return array
 88:      */
 89:     public function getSampleData()
 90:     {
 91:         $samplesArr = array();
 92:         $samples = $this->getProduct()->getTypeInstance(true)->getSamples($this->getProduct());
 93:         foreach ($samples as $item) {
 94:             $tmpSampleItem = array(
 95:                 'sample_id' => $item->getId(),
 96:                 'title' => $this->escapeHtml($item->getTitle()),
 97:                 'sample_url' => $item->getSampleUrl(),
 98:                 'sample_type' => $item->getSampleType(),
 99:                 'sort_order' => $item->getSortOrder(),
100:             );
101:             $file = Mage::helper('downloadable/file')->getFilePath(
102:                 Mage_Downloadable_Model_Sample::getBasePath(), $item->getSampleFile()
103:             );
104:             if ($item->getSampleFile() && !is_file($file)) {
105:                 Mage::helper('core/file_storage_database')->saveFileToFilesystem($file);
106:             }
107:             if ($item->getSampleFile() && is_file($file)) {
108:                 $tmpSampleItem['file_save'] = array(
109:                     array(
110:                         'file' => $item->getSampleFile(),
111:                         'name' => Mage::helper('downloadable/file')->getFileFromPathFile($item->getSampleFile()),
112:                         'size' => filesize($file),
113:                         'status' => 'old'
114:                     ));
115:             }
116:             if ($this->getProduct() && $item->getStoreTitle()) {
117:                 $tmpSampleItem['store_title'] = $item->getStoreTitle();
118:             }
119:             $samplesArr[] = new Varien_Object($tmpSampleItem);
120:         }
121: 
122:         return $samplesArr;
123:     }
124: 
125:     /**
126:      * Check exists defined samples title
127:      *
128:      * @return bool
129:      */
130:     public function getUsedDefault()
131:     {
132:         return $this->getProduct()->getAttributeDefaultValue('samples_title') === false;
133:     }
134: 
135:     /**
136:      * Retrieve Default samples title
137:      *
138:      * @return string
139:      */
140:     public function getSamplesTitle()
141:     {
142:         return Mage::getStoreConfig(Mage_Downloadable_Model_Sample::XML_PATH_SAMPLES_TITLE);
143:     }
144: 
145:     /**
146:      * Prepare layout
147:      *
148:      */
149:     protected function _prepareLayout()
150:     {
151:         $this->setChild(
152:             'upload_button',
153:             $this->getLayout()->createBlock('adminhtml/widget_button')
154:                 ->addData(array(
155:                     'id'      => '',
156:                     'label'   => Mage::helper('adminhtml')->__('Upload Files'),
157:                     'type'    => 'button',
158:                     'onclick' => 'Downloadable.massUploadByType(\'samples\')'
159:                 ))
160:         );
161:     }
162: 
163:     /**
164:      * Retrieve Upload button HTML
165:      *
166:      * @return string
167:      */
168:     public function getUploadButtonHtml()
169:     {
170:         return $this->getChild('upload_button')->toHtml();
171:     }
172: 
173:     /**
174:      * Retrive config json
175:      *
176:      * @return string
177:      */
178:     public function getConfigJson()
179:     {
180:         $this->getConfig()->setUrl(Mage::getModel('adminhtml/url')
181:             ->addSessionParam()
182:             ->getUrl('*/downloadable_file/upload', array('type' => 'samples', '_secure' => true)));
183:         $this->getConfig()->setParams(array('form_key' => $this->getFormKey()));
184:         $this->getConfig()->setFileField('samples');
185:         $this->getConfig()->setFilters(array(
186:             'all'    => array(
187:                 'label' => Mage::helper('adminhtml')->__('All Files'),
188:                 'files' => array('*.*')
189:             )
190:         ));
191:         $this->getConfig()->setReplaceBrowseWithRemove(true);
192:         $this->getConfig()->setWidth('32');
193:         $this->getConfig()->setHideUploadButton(true);
194:         return Mage::helper('core')->jsonEncode($this->getConfig()->getData());
195:     }
196: 
197:     /**
198:      * Retrive config object
199:      *
200:      * @return Varien_Config
201:      */
202:     public function getConfig()
203:     {
204:         if(is_null($this->_config)) {
205:             $this->_config = new Varien_Object();
206:         }
207: 
208:         return $this->_config;
209:     }
210: }
211: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0