Exemple #1
0
 /** Create the institution
  * @todo perhaps move out to another class
  * @param type $inst
  * @return string
  */
 public function institution($inst)
 {
     if (!is_null($inst)) {
         $institutions = new Institutions();
         $where = array();
         $where[] = $institutions->getAdapter()->quoteInto('institution = ?', $inst);
         $institution = $institutions->fetchRow($where);
         if (!is_null($institution)) {
             return $institution->description;
         }
     } else {
         return 'The Portable Antiquities Scheme';
     }
 }
 /** Edit an institution
  * @access public
  * @return void
  */
 public function editAction()
 {
     $form = new InstitutionForm();
     $form->details->setLegend('Edit institution details: ');
     $this->view->form = $form;
     if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) {
         if ($form->isValid($form->getValues())) {
             $where = array();
             $where[] = $this->_institutions->getAdapter()->quoteInto('id = ?', $this->getParam('id'));
             $this->_institutions->update($form->getValues(), $where);
             $this->getFlash()->addMessage($form->getValue('institution') . '\'s details updated.');
             $this->redirect($this->_redirectUrl . 'institutions/');
         } else {
             $form->populate($form->getValues());
         }
     } else {
         // find id is expected in $params['id']
         $id = (int) $this->_request->getParam('id', 0);
         if ($id > 0) {
             $this->view->inst = $this->_institutions->fetchRow('id=' . $id)->toArray();
             $form->populate($this->_institutions->fetchRow('id=' . $id)->toArray());
         }
     }
 }