예제 #1
0
 /** Clone the options
  * @access public
  * @param string $broadperiod
  * @param array $coinDataFlat
  * @throw Exeption
  */
 public function optionsAddClone($broadperiod, array $coinDataFlat)
 {
     switch ($broadperiod) {
         case 'IRON AGE':
             if (isset($coinDataFlat['denomination'])) {
                 $geographies = new Geography();
                 $geography_options = $geographies->getIronAgeGeographyMenu($coinDataFlat['denomination']);
                 $form->geographyID->addMultiOptions(array(null => 'Choose geographic region', 'Available regions' => $geography_options));
                 $form->geographyID->addValidator('InArray', false, array(array_keys($geography_options)));
             }
             break;
         case 'ROMAN':
             if (isset($coinDataFlat['ruler'])) {
                 $reverses = new RevTypes();
                 $reverse_options = $reverses->getRevTypesForm($coinDataFlat['ruler']);
                 if ($reverse_options) {
                     $form->revtypeID->addMultiOptions(array(null => 'Choose reverse type', 'Available reverses' => $reverse_options));
                 } else {
                     $form->revtypeID->addMultiOptions(array(null => 'No options available'));
                 }
             } else {
                 $form->revtypeID->addMultiOptions(array(null => 'No options available'));
             }
             if (isset($coinDataFlat['ruler']) && $coinDataFlat['ruler'] == 242) {
                 $moneyers = new Moneyers();
                 $moneyer_options = $moneyers->getRepublicMoneyers();
                 $form->moneyer->addMultiOptions(array(null => 'Choose moneyer', 'Available moneyers' => $moneyer_options));
             } else {
                 $form->moneyer->addMultiOptions(array(null => 'No options available'));
             }
             break;
         case 'EARLY MEDIEVAL':
             $types = new MedievalTypes();
             $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler']);
             $form->typeID->addMultiOptions(array(null => 'Choose Early Medieval type', 'Available types' => $type_options));
             break;
         case 'MEDIEVAL':
             $types = new MedievalTypes();
             $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler']);
             $form->typeID->addMultiOptions(array(null => 'Choose Medieval type', 'Available types' => $type_options));
             break;
         case 'POST MEDIEVAL':
             $types = new MedievalTypes();
             $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler']);
             $form->typeID->addMultiOptions(array(null => 'Choose Post Medieval type', 'Available types' => $type_options));
             break;
         default:
             throw new Exception('No period supplied', 500);
     }
 }
 /** 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;
     }
 }