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_Page
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: * Page layouts source
29: *
30: * @category Mage
31: * @package Mage_Page
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Page_Model_Source_Layout
35: {
36:
37: /**
38: * Page layout options
39: *
40: * @var array
41: */
42: protected $_options = null;
43:
44: /**
45: * Default option
46: * @var string
47: */
48: protected $_defaultValue = null;
49:
50: /**
51: * Retrieve page layout options
52: *
53: * @return array
54: */
55: public function getOptions()
56: {
57: if ($this->_options === null) {
58: $this->_options = array();
59: foreach (Mage::getSingleton('page/config')->getPageLayouts() as $layout) {
60: $this->_options[$layout->getCode()] = $layout->getLabel();
61: if ($layout->getIsDefault()) {
62: $this->_defaultValue = $layout->getCode();
63: }
64: }
65: }
66:
67: return $this->_options;
68: }
69:
70: /**
71: * Retrieve page layout options array
72: *
73: * @return array
74: */
75: public function toOptionArray($withEmpty = false)
76: {
77: $options = array();
78:
79: foreach ($this->getOptions() as $value => $label) {
80: $options[] = array(
81: 'label' => $label,
82: 'value' => $value
83: );
84: }
85:
86: if ($withEmpty) {
87: array_unshift($options, array('value'=>'', 'label'=>Mage::helper('page')->__('-- Please Select --')));
88: }
89:
90: return $options;
91: }
92:
93: /**
94: * Default options value getter
95: * @return string
96: */
97: public function getDefaultValue()
98: {
99: $this->getOptions();
100: return $this->_defaultValue;
101: }
102: }
103: