PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/app/code/core/Mage/Downloadable/Model/Link.php

https://bitbucket.org/kdms/sh-magento
PHP | 151 lines | 46 code | 10 blank | 95 comment | 0 complexity | 41a97c1148704677bc5beab58791fdbb MD5 | raw file
  1. <?php
  2. /**
  3. * Magento Enterprise Edition
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Magento Enterprise Edition License
  8. * that is bundled with this package in the file LICENSE_EE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://www.magentocommerce.com/license/enterprise-edition
  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://www.magentocommerce.com/license/enterprise-edition
  25. */
  26. /**
  27. * Downloadable link model
  28. *
  29. * @method Mage_Downloadable_Model_Resource_Link _getResource()
  30. * @method Mage_Downloadable_Model_Resource_Link getResource()
  31. * @method int getProductId()
  32. * @method Mage_Downloadable_Model_Link setProductId(int $value)
  33. * @method int getSortOrder()
  34. * @method Mage_Downloadable_Model_Link setSortOrder(int $value)
  35. * @method int getNumberOfDownloads()
  36. * @method Mage_Downloadable_Model_Link setNumberOfDownloads(int $value)
  37. * @method int getIsShareable()
  38. * @method Mage_Downloadable_Model_Link setIsShareable(int $value)
  39. * @method string getLinkUrl()
  40. * @method Mage_Downloadable_Model_Link setLinkUrl(string $value)
  41. * @method string getLinkFile()
  42. * @method Mage_Downloadable_Model_Link setLinkFile(string $value)
  43. * @method string getLinkType()
  44. * @method Mage_Downloadable_Model_Link setLinkType(string $value)
  45. * @method string getSampleUrl()
  46. * @method Mage_Downloadable_Model_Link setSampleUrl(string $value)
  47. * @method string getSampleFile()
  48. * @method Mage_Downloadable_Model_Link setSampleFile(string $value)
  49. * @method string getSampleType()
  50. * @method Mage_Downloadable_Model_Link setSampleType(string $value)
  51. *
  52. * @category Mage
  53. * @package Mage_Downloadable
  54. * @author Magento Core Team <core@magentocommerce.com>
  55. */
  56. class Mage_Downloadable_Model_Link extends Mage_Core_Model_Abstract
  57. {
  58. const XML_PATH_LINKS_TITLE = 'catalog/downloadable/links_title';
  59. const XML_PATH_DEFAULT_DOWNLOADS_NUMBER = 'catalog/downloadable/downloads_number';
  60. const XML_PATH_TARGET_NEW_WINDOW = 'catalog/downloadable/links_target_new_window';
  61. const XML_PATH_CONFIG_IS_SHAREABLE = 'catalog/downloadable/shareable';
  62. const LINK_SHAREABLE_YES = 1;
  63. const LINK_SHAREABLE_NO = 0;
  64. const LINK_SHAREABLE_CONFIG = 2;
  65. /**
  66. * Initialize resource model
  67. *
  68. */
  69. protected function _construct()
  70. {
  71. $this->_init('downloadable/link');
  72. parent::_construct();
  73. }
  74. /**
  75. * Return link files path
  76. *
  77. * @return string
  78. */
  79. public static function getLinkDir()
  80. {
  81. return Mage::getBaseDir();
  82. }
  83. /**
  84. * Enter description here...
  85. *
  86. * @return Mage_Downloadable_Model_Link
  87. */
  88. protected function _afterSave()
  89. {
  90. $this->getResource()->saveItemTitleAndPrice($this);
  91. return parent::_afterSave();
  92. }
  93. /**
  94. * Retrieve base temporary path
  95. *
  96. * @return string
  97. */
  98. public static function getBaseTmpPath()
  99. {
  100. return Mage::getBaseDir('media') . DS . 'downloadable' . DS . 'tmp' . DS . 'links';
  101. }
  102. /**
  103. * Retrieve Base files path
  104. *
  105. * @return string
  106. */
  107. public static function getBasePath()
  108. {
  109. return Mage::getBaseDir('media') . DS . 'downloadable' . DS . 'files' . DS . 'links';
  110. }
  111. /**
  112. * Retrieve base sample temporary path
  113. *
  114. * @return string
  115. */
  116. public static function getBaseSampleTmpPath()
  117. {
  118. return Mage::getBaseDir('media') . DS . 'downloadable' . DS . 'tmp' . DS . 'link_samples';
  119. }
  120. /**
  121. * Retrieve base sample path
  122. *
  123. * @return string
  124. */
  125. public static function getBaseSamplePath()
  126. {
  127. return Mage::getBaseDir('media') . DS . 'downloadable' . DS . 'files' . DS . 'link_samples';
  128. }
  129. /**
  130. * Retrieve links searchable data
  131. *
  132. * @param int $productId
  133. * @param int $storeId
  134. * @return array
  135. */
  136. public function getSearchableData($productId, $storeId)
  137. {
  138. return $this->_getResource()
  139. ->getSearchableData($productId, $storeId);
  140. }
  141. }