public function editAction() { $id = $this->_request->getParam('id'); $itemPage = new CMS_Content_Item_Page($id); $pageForm = new Form_PageForm(); $pageForm->setAction('/page/edit'); if ($this->getRequest()->isPost()) { if ($pageForm->isValid($_POST)) { $itemPage->name = $pageForm->getValue('name'); $itemPage->headline = $pageForm->getValue('headline'); $itemPage->description = $pageForm->getValue('description'); $itemPage->content = $pageForm->getValue('content'); if ($pageForm->image->isUploaded()) { $pageForm->image->receive(); $itemPage->image = '/images/upload/' . basename($pageForm->image->getFileName()); } // save the content item $itemPage->save(); return $this->_forward('list'); } } $pageForm->populate($itemPage->toArray()); // create the image preview $imagePreview = $pageForm->createElement('image', 'image_preview'); // element options $imagePreview->setLabel('Preview Image: '); $imagePreview->setAttrib('style', 'width:200px;height:auto;'); // add the element to the form $imagePreview->setOrder(4); $imagePreview->setImage($itemPage->image); $pageForm->addElement($imagePreview); $this->view->form = $pageForm; }
public function updatePage($apiKey, $id, $name, $headline, $description, $content) { if (!$this->_validateKey($apiKey)) { return array('error' => 'invalid api key', 'status' => false); } // open the page $itemPage = new CMS_Content_Item_Page($id); // update it $itemPage->name = $name; $itemPage->headline = $headline; $itemPage->description = $description; $itemPage->content = $content; // save the content item $itemPage->save(); // return the page as an array, which Zend_Rest will convert into the XML response return $itemPage->toArray(); }