/** * Converts according to convert() and echos the result. * * @see convert() * * @param mix $param1 - Tree class / Item class / Array. * @param mix $param2 - ORDERING_LIST for items / fieldInformation for tags. * * @return void */ public static function echoConvert($param1, $param2 = null) { if (!headers_sent()) { $front = Zend_Controller_Front::getInstance(); $front->getResponse()->setHeader('Content-Type', 'application/json; charset=utf-8'); } Phprojekt_CompressedSender::send(self::convert($param1, $param2)); }
public function putAction() { if (!($id = $this->_getParam('id', false))) { throw new Zend_Controller_Action_Exception('No id given', 422); } $item = Zend_Json::decode($this->getRequest()->getRawBody()); if (!$item) { throw new Zend_Controller_Action_Exception('No data was received', 400); } if ($item['id'] !== $id) { throw new Zend_Controller_Action_Exception('Can not alter the id of existing items', 501); } unset($item['id']); $model = $this->newModelObject()->find($id); if (!$model) { $this->getResponse()->setHttpResponseCode(404); echo "item with id {$id} not found"; return; } foreach ($item as $property => $value) { $model->{$property} = $value; } $model->save(); Phprojekt_CompressedSender::send(Zend_Json_Encoder::encode($model->toArray())); }
/** * Returns the metadata for this Module's default module. * * Mandatory parameters: * - integer projectId The id of the project that the metadata should be based on. */ public function metadataAction() { $projectId = $this->getRequest()->getParam('projectId', null); $this->_storeCurrentProjectId($projectId); $fieldDefinition = $this->getModelObject()->getInformation()->getFieldDefinition(); Phprojekt_CompressedSender::send(Zend_Json_Encoder::encode($fieldDefinition)); }
private function _send($data) { header('Content-Type: application/javascript'); Phprojekt_CompressedSender::send($data); }