1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: class Mage_Adminhtml_Block_Dashboard extends Mage_Adminhtml_Block_Template
28: {
29: protected $_locale;
30:
31: 32: 33:
34: const XML_PATH_ENABLE_CHARTS = 'admin/dashboard/enable_charts';
35:
36: public function __construct()
37: {
38: parent::__construct();
39: $this->setTemplate('dashboard/index.phtml');
40:
41: }
42:
43: protected function _prepareLayout()
44: {
45: $this->setChild('lastOrders',
46: $this->getLayout()->createBlock('adminhtml/dashboard_orders_grid')
47: );
48:
49: $this->setChild('totals',
50: $this->getLayout()->createBlock('adminhtml/dashboard_totals')
51: );
52:
53: $this->setChild('sales',
54: $this->getLayout()->createBlock('adminhtml/dashboard_sales')
55: );
56:
57: $this->setChild('lastSearches',
58: $this->getLayout()->createBlock('adminhtml/dashboard_searches_last')
59: );
60:
61: $this->setChild('topSearches',
62: $this->getLayout()->createBlock('adminhtml/dashboard_searches_top')
63: );
64:
65: if (Mage::getStoreConfig(self::XML_PATH_ENABLE_CHARTS)) {
66: $block = $this->getLayout()->createBlock('adminhtml/dashboard_diagrams');
67: } else {
68: $block = $this->getLayout()->createBlock('adminhtml/template')
69: ->setTemplate('dashboard/graph/disabled.phtml')
70: ->setConfigUrl($this->getUrl('adminhtml/system_config/edit', array('section'=>'admin')));
71: }
72: $this->setChild('diagrams', $block);
73:
74: $this->setChild('grids',
75: $this->getLayout()->createBlock('adminhtml/dashboard_grids')
76: );
77:
78: parent::_prepareLayout();
79: }
80:
81: public function getSwitchUrl()
82: {
83: if ($url = $this->getData('switch_url')) {
84: return $url;
85: }
86: return $this->getUrl('*/*/*', array('_current'=>true, 'period'=>null));
87: }
88: }
89: