00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Mage_Downloadable 00023 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 /** 00028 * Downloadable link model 00029 * 00030 * @category Mage 00031 * @package Mage_Downloadable 00032 * @author Magento Core Team <core@magentocommerce.com> 00033 */ 00034 class Mage_Downloadable_Model_Link extends Mage_Core_Model_Abstract 00035 { 00036 const XML_PATH_LINKS_TITLE = 'catalog/downloadable/links_title'; 00037 const XML_PATH_DEFAULT_DOWNLOADS_NUMBER = 'catalog/downloadable/downloads_number'; 00038 const XML_PATH_TARGET_NEW_WINDOW = 'catalog/downloadable/links_target_new_window'; 00039 const XML_PATH_CONFIG_IS_SHAREABLE = 'catalog/downloadable/shareable'; 00040 00041 const LINK_SHAREABLE_YES = 1; 00042 const LINK_SHAREABLE_NO = 0; 00043 const LINK_SHAREABLE_CONFIG = 2; 00044 00045 /** 00046 * Initialize resource model 00047 * 00048 */ 00049 protected function _construct() 00050 { 00051 $this->_init('downloadable/link'); 00052 parent::_construct(); 00053 } 00054 00055 /** 00056 * Return link files path 00057 * 00058 * @return string 00059 */ 00060 public static function getLinkDir() 00061 { 00062 return Mage::getBaseDir(); 00063 } 00064 00065 /** 00066 * Enter description here... 00067 * 00068 * @return Mage_Downloadable_Model_Link 00069 */ 00070 protected function _afterSave() 00071 { 00072 $this->getResource()->saveItemTitleAndPrice($this); 00073 return parent::_afterSave(); 00074 } 00075 00076 /** 00077 * Retrieve base temporary path 00078 * 00079 * @return string 00080 */ 00081 public static function getBaseTmpPath() 00082 { 00083 return Mage::getBaseDir('media') . DS . 'downloadable' . DS . 'tmp' . DS . 'links'; 00084 } 00085 00086 /** 00087 * Retrieve Base files path 00088 * 00089 * @return string 00090 */ 00091 public static function getBasePath() 00092 { 00093 return Mage::getBaseDir('media') . DS . 'downloadable' . DS . 'files' . DS . 'links'; 00094 } 00095 00096 /** 00097 * Retrieve base sample temporary path 00098 * 00099 * @return string 00100 */ 00101 public static function getBaseSampleTmpPath() 00102 { 00103 return Mage::getBaseDir('media') . DS . 'downloadable' . DS . 'tmp' . DS . 'link_samples'; 00104 } 00105 00106 /** 00107 * Retrieve base sample path 00108 * 00109 * @return string 00110 */ 00111 public static function getBaseSamplePath() 00112 { 00113 return Mage::getBaseDir('media') . DS . 'downloadable' . DS . 'files' . DS . 'link_samples'; 00114 } 00115 00116 /** 00117 * Retrieve links searchable data 00118 * 00119 * @param int $productId 00120 * @param int $storeId 00121 * @return array 00122 */ 00123 public function getSearchableData($productId, $storeId) 00124 { 00125 return $this->_getResource() 00126 ->getSearchableData($productId, $storeId); 00127 } 00128 }