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_Adminhtml
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: * Directory contents block for Wysiwyg Images
29: *
30: * @category Mage
31: * @package Mage_Adminhtml
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Content_Files extends Mage_Adminhtml_Block_Template
35: {
36: /**
37: * Files collection object
38: *
39: * @var Varien_Data_Collection_Filesystem
40: */
41: protected $_filesCollection;
42:
43: /**
44: * Prepared Files collection for current directory
45: *
46: * @return Varien_Data_Collection_Filesystem
47: */
48: public function getFiles()
49: {
50: if (! $this->_filesCollection) {
51: $this->_filesCollection = Mage::getSingleton('cms/wysiwyg_images_storage')->getFilesCollection(Mage::helper('cms/wysiwyg_images')->getCurrentPath(), $this->_getMediaType());
52:
53: }
54:
55: return $this->_filesCollection;
56: }
57:
58: /**
59: * Files collection count getter
60: *
61: * @return int
62: */
63: public function getFilesCount()
64: {
65: return $this->getFiles()->count();
66: }
67:
68: /**
69: * File idetifier getter
70: *
71: * @param Varien_Object $file
72: * @return string
73: */
74: public function getFileId(Varien_Object $file)
75: {
76: return $file->getId();
77: }
78:
79: /**
80: * File thumb URL getter
81: *
82: * @param Varien_Object $file
83: * @return string
84: */
85: public function getFileThumbUrl(Varien_Object $file)
86: {
87: return $file->getThumbUrl();
88: }
89:
90: /**
91: * File name URL getter
92: *
93: * @param Varien_Object $file
94: * @return string
95: */
96: public function getFileName(Varien_Object $file)
97: {
98: return $file->getName();
99: }
100:
101: /**
102: * Image file width getter
103: *
104: * @param Varien_Object $file
105: * @return string
106: */
107: public function getFileWidth(Varien_Object $file)
108: {
109: return $file->getWidth();
110: }
111:
112: /**
113: * Image file height getter
114: *
115: * @param Varien_Object $file
116: * @return string
117: */
118: public function getFileHeight(Varien_Object $file)
119: {
120: return $file->getHeight();
121: }
122:
123: /**
124: * File short name getter
125: *
126: * @param Varien_Object $file
127: * @return string
128: */
129: public function getFileShortName(Varien_Object $file)
130: {
131: return $file->getShortName();
132: }
133:
134: public function getImagesWidth()
135: {
136: return Mage::getSingleton('cms/wysiwyg_images_storage')->getConfigData('resize_width');
137: }
138:
139: public function getImagesHeight()
140: {
141: return Mage::getSingleton('cms/wysiwyg_images_storage')->getConfigData('resize_height');
142: }
143:
144: /**
145: * Return current media type based on request or data
146: * @return string
147: */
148: protected function _getMediaType()
149: {
150: if ($this->hasData('media_type')) {
151: return $this->_getData('media_type');
152: }
153: return $this->getRequest()->getParam('type');
154: }
155: }
156: