00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 abstract class Mage_Adminhtml_Helper_Dashboard_Abstract extends Mage_Core_Helper_Data
00036 {
00037
00038
00039
00040
00041
00042 protected $_collection;
00043
00044
00045
00046
00047
00048
00049 protected $_params = array();
00050
00051 public function getCollection()
00052 {
00053 if(is_null($this->_collection)) {
00054 $this->_initCollection();
00055 }
00056 return $this->_collection;
00057 }
00058
00059 abstract protected function _initCollection();
00060
00061
00062
00063
00064
00065
00066 public function getItems()
00067 {
00068 return is_array($this->getCollection()) ? $this->getCollection() : $this->getCollection()->getItems();
00069 }
00070
00071 public function getCount()
00072 {
00073 return sizeof($this->getItems());
00074 }
00075
00076 public function getColumn($index)
00077 {
00078 $result = array();
00079 foreach ($this->getItems() as $item) {
00080 if (is_array($item)) {
00081 if(isset($item[$index])) {
00082 $result[] = $item[$index];
00083 } else {
00084 $result[] = null;
00085 }
00086 } elseif ($item instanceof Varien_Object) {
00087 $result[] = $item->getData($index);
00088 } else {
00089 $result[] = null;
00090 }
00091 }
00092 return $result;
00093 }
00094
00095 public function setParam($name, $value)
00096 {
00097 $this->_params[$name] = $value;
00098 }
00099
00100 public function setParams(array $params)
00101 {
00102 $this->_params = $params;
00103 }
00104
00105 public function getParam($name)
00106 {
00107 if(isset($this->_params[$name])) {
00108 return $this->_params[$name];
00109 }
00110
00111 return null;
00112 }
00113
00114 public function getParams()
00115 {
00116 return $this->_params;
00117 }
00118
00119 }