Example #1
0
 protected function listjsonAction()
 {
     $project = $this->projectService->getProject((int) $this->_getParam('projectid'));
     $features = $project->getFeatures();
     $dummy = new Feature();
     $listFields = $dummy->listFields();
     // format for display
     $asArr = array();
     foreach ($features as $item) {
         $cell = array();
         foreach ($listFields as $name => $display) {
             if (method_exists($item, $name)) {
                 $cell[] = $item->{$name}();
             } else {
                 $cell[] = $item->{$name};
             }
         }
         $row = array('id' => $item->id, 'cell' => $cell);
         $asArr[] = $row;
     }
     $obj = new stdClass();
     $obj->page = ifset($this->_getAllParams(), $this->view->pagerName, 1);
     $obj->total = $this->view->totalCount;
     $obj->rows = $asArr;
     $this->getResponse()->setHeader('Content-type', 'text/x-json');
     $json = Zend_Json::encode($obj);
     echo $json;
 }