コード例 #1
0
 /** A function to get RRC types for moneyers as json
  * @access public
  * @return mixed
  */
 public function rrctypesAction()
 {
     if ($this->getParam('term', false)) {
         $moneyer = new Moneyers();
         $nomismaID = $moneyer->fetchRow($moneyer->select()->where('id = ?', $this->getParam('term')))->nomismaID;
         $nomisma = new Nomisma();
         $types = $nomisma->getRRCDropdowns($nomismaID);
         if ($types) {
             $response = $types;
         } else {
             $response = array(array('id' => null, 'term' => 'No options available'));
         }
     } else {
         $response = array(array('id' => null, 'term' => 'No moneyer specified'));
     }
     echo Zend_Json::encode($response);
 }
コード例 #2
0
 /** add and clone last record
  * @access public
  * @param string $broadperiod
  * @param array $coinDataFlat
  * @return void
  */
 public function optionsAddClone($broadperiod, array $coinDataFlat)
 {
     $coinDataFlat = $coinDataFlat[0];
     switch ($broadperiod) {
         case 'IRON AGE':
             if (array_key_exists('denomination', $coinDataFlat)) {
                 $geographies = new Geography();
                 $geography_options = $geographies->getIronAgeGeographyMenu($coinDataFlat['denomination']);
                 $this->_view->form->geographyID->addMultiOptions(array(null => 'Choose geographic region', 'Available regions' => $geography_options));
                 $this->_view->form->geographyID->addValidator('InArray', false, array(array_keys($geography_options)));
             }
             break;
         case 'ROMAN':
             if (array_key_exists('ruler_id', $coinDataFlat)) {
                 if (!is_null($coinDataFlat['ruler_id'])) {
                     $rulers = new Rulers();
                     $identifier = $rulers->fetchRow($rulers->select()->where('id = ?', $coinDataFlat['ruler_id']));
                     if ($identifier) {
                         $nomisma = $identifier->nomismaID;
                         $rrcTypes = new Nomisma();
                         $this->_view->form->ricID->addMultiOptions(array(null => 'Choose RIC type', 'Available RIC types' => $rrcTypes->getRICDropdownsFlat($nomisma)));
                     }
                 }
                 $reverses = new RevTypes();
                 $reverse_options = $reverses->getRevTypesForm($coinDataFlat['ruler_id']);
                 if ($reverse_options) {
                     $this->_view->form->revtypeID->addMultiOptions(array(null => 'Choose reverse type', 'Available reverses' => $reverse_options));
                     $this->_view->form->revtypeID->setRegisterInArrayValidator(false);
                 } else {
                     $this->_view->form->revtypeID->addMultiOptions(array(null => 'No options available'));
                     $this->_view->form->revtypeID->setRegisterInArrayValidator(false);
                 }
             } else {
                 $this->_view->form->revtypeID->addMultiOptions(array(null => 'No options available'));
                 $this->_view->form->revtypeID->setRegisterInArrayValidator(false);
             }
             if (array_key_exists('ruler_id', $coinDataFlat) && $coinDataFlat['ruler_id'] == '242') {
                 $moneyers = new Moneyers();
                 $moneyer_options = $moneyers->getRepublicMoneyers();
                 $this->_view->form->moneyer->addMultiOptions(array(null => 'Choose moneyer', 'Available moneyers' => $moneyer_options));
                 if (array_key_exists('moneyer', $coinDataFlat)) {
                     if (!is_null($coinDataFlat['moneyer'])) {
                         $identifier = $moneyers->fetchRow($moneyers->select()->where('id = ?', $coinDataFlat['moneyer']));
                         if ($identifier) {
                             $nomisma = $identifier->nomismaID;
                             $rrcTypes = new Nomisma();
                             $this->_view->form->rrcID->addMultiOptions(array(null => 'Choose RRC type', 'Available RRC types' => $rrcTypes->getRRCDropdownsFlat($nomisma)));
                         }
                     }
                 }
             } else {
                 $this->_view->form->moneyer->addMultiOptions(array(null => 'No options available'));
             }
             break;
         case 'EARLY MEDIEVAL':
             if (array_key_exists('ruler_id', $coinDataFlat)) {
                 $types = new MedievalTypes();
                 $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler_id']);
                 $this->_view->form->typeID->addMultiOptions(array(null => 'Choose Early Medieval type', 'Available types' => $type_options));
             }
             break;
         case 'MEDIEVAL':
             if (array_key_exists('ruler_id', $coinDataFlat)) {
                 $types = new MedievalTypes();
                 $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler_id']);
                 $this->_view->form->typeID->addMultiOptions(array(null => 'Choose Medieval type', 'Available types' => $type_options));
             }
             break;
         case 'POST MEDIEVAL':
             if (array_key_exists('ruler_id', $coinDataFlat)) {
                 $types = new MedievalTypes();
                 $type_options = $types->getMedievalTypeToRulerMenu((int) $coinDataFlat['ruler_id']);
                 $this->_view->form->typeID->addMultiOptions(array(null => 'Choose Post Medieval type', 'Available types' => $type_options));
             }
             break;
         default:
             return false;
     }
 }
コード例 #3
0
 /** Edit a moneyer on the system
  * @access public
  * @return void
  */
 public function editmoneyerAction()
 {
     if ($this->_getparam('id', false)) {
         $form = new MoneyerForm();
         $form->submit->setLabel('Update details');
         $this->view->form = $form;
         if ($this->getRequest()->isPost()) {
             if ($form->isValid($this->_request->getPost())) {
                 $coins = new Moneyers();
                 $where = array();
                 $where[] = $coins->getAdapter()->quoteInto('id = ?', (int) $this->getParam('id'));
                 $coins->update($form->getValues(), $where);
                 $this->getFlash()->addMessage('Moneyer updated');
                 $this->redirect('/admin/numismatics/moneyers');
             } else {
                 $form->populate($form->getValues());
             }
         } else {
             $id = (int) $this->_request->getParam('id', 0);
             if ($id > 0) {
                 $coins = new Moneyers();
                 $moneyer = $coins->fetchRow('id =' . (int) $id);
                 if (count($moneyer)) {
                     $form->populate($moneyer->toArray());
                 } else {
                     throw new Pas_Exception_Param($this->_nothingFound);
                 }
             }
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParameter, 404);
     }
 }