Example #1
0
 public function getMainMenu()
 {
     $modulesDb = new Application_Model_DbTable_Module();
     $modules = $modulesDb->fetchAll();
     $mainmenu = array();
     foreach ($modules as $module) {
         if ($module->active && $module->menu) {
             $data = Zend_Json::decode($module->menu);
             foreach ($data as $key => $value) {
                 if (isset($mainmenu[$key]['childs'])) {
                     foreach ($value['childs'] as $ordering => $child) {
                         $mainmenu[$key]['childs'][$ordering] = $child;
                     }
                 } else {
                     $mainmenu[$key] = $value;
                 }
             }
         }
     }
     foreach ($mainmenu as $key => $value) {
         if (isset($value['childs'])) {
             ksort($mainmenu[$key]['childs']);
         }
     }
     return $mainmenu;
 }
Example #2
0
 /**
  * Find all modules
  * @param array $criteria
  *
  * @return array
  */
 public function fetchAll($criteria = array())
 {
     /* @var $select Zend_Db_Select*/
     $select = $this->_dbTable->select();
     $select->setIntegrityCheck(false)->from(array('m' => 'module'), array('m.*'));
     if (isset($criteria['application_id'])) {
         $select->where('m.application_id = ?', $criteria['application_id']);
     }
     //echo $select->__toString();
     $resultSet = $this->_dbTable->fetchAll($select);
     if (0 == count($resultSet)) {
         return false;
     }
     $modules = array();
     foreach ($resultSet as $row) {
         $module = new Application_Model_Module();
         $this->_rowToModule($row, $module);
         $modules[] = $module;
     }
     return $modules;
 }