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_Core
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: class Mage_Core_Model_Design_Source_Design extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
29: {
30: protected $_isFullLabel = false;
31:
32: /**
33: * Setter
34: * Add package name to label
35: *
36: * @param boolean $isFullLabel
37: * @return Mage_Core_Model_Design_Source_Design
38: */
39: public function setIsFulllabel($isFullLabel)
40: {
41: $this->_isFullLabel = $isFullLabel;
42: return $this;
43: }
44:
45: /**
46: * Getter
47: *
48: * @return boolean
49: */
50: public function getIsFullLabel()
51: {
52: return $this->_isFullLabel;
53: }
54:
55: /**
56: * Retrieve All Design Theme Options
57: *
58: * @param bool $withEmpty add empty (please select) values to result
59: * @return array
60: */
61: public function getAllOptions($withEmpty = true)
62: {
63: if (is_null($this->_options)) {
64: $design = Mage::getModel('core/design_package')->getThemeList();
65: $options = array();
66: foreach ($design as $package => $themes){
67: $packageOption = array('label' => $package);
68: $themeOptions = array();
69: foreach ($themes as $theme) {
70: $themeOptions[] = array(
71: 'label' => ($this->getIsFullLabel() ? $package . ' / ' : '') . $theme,
72: 'value' => $package . '/' . $theme
73: );
74: }
75: $packageOption['value'] = $themeOptions;
76: $options[] = $packageOption;
77: }
78: $this->_options = $options;
79: }
80: $options = $this->_options;
81: if ($withEmpty) {
82: array_unshift($options, array(
83: 'value'=>'',
84: 'label'=>Mage::helper('core')->__('-- Please Select --'))
85: );
86: }
87: return $options;
88: }
89:
90: /**
91: * Get a text for option value
92: *
93: * @param string|integer $value
94: * @return string
95: */
96: public function getOptionText($value)
97: {
98: $options = $this->getAllOptions(false);
99:
100: return $value;
101: }
102: }
103: