/**
  * Since there's no UUID for the translations page, just override index
  */
 function index()
 {
     // valid facts for translations (fv_type_multiple)
     $facts = $this->api->query('fact', array('type' => Fact::$FV_TYPE_MULTIPLE));
     $simplified_facts = array();
     foreach ($facts['radix'] as $fact) {
         $simplified_facts[] = array($fact['fact_identifier'], $fact['fact_name']);
     }
     // potential authz
     $fake = new TranslationMap();
     $user = $this->airuser->get_user();
     $authz = array('may_read' => $fake->user_may_read($user), 'may_write' => $fake->user_may_write($user), 'may_manage' => $fake->user_may_manage($user));
     // inline data
     $inline = array('URL' => air2_uri_for('translation'), 'DATA' => $this->api->query('translation', array('type' => 'gender', 'limit' => 18, 'sort' => 'xm_xlate_from asc')), 'PARMS' => array('type' => 'gender'), 'FACTDATA' => $facts, 'FACTS' => $simplified_facts, 'AUTHZ' => $authz);
     // show page
     $title = 'Manage Translations - ' . AIR2_SYSTEM_DISP_NAME;
     $data = $this->airhtml->get_inline($title, 'Translation', $inline);
     $this->response($data);
 }
 /**
  * Check for translations of sf_src_value (text) that with an explicitly
  * set sf_fv_id.
  *
  * @param array   $data
  * @param int     $row
  * @return boolean|string
  */
 public function validate_object($data, $row)
 {
     $errors = array();
     // look for facts
     foreach ($this->mapping as $fact_id => $def) {
         $from = $data[$def['trans_from']];
         $to = $data[$def['trans_to']];
         // if both are set, make sure they don't conflict
         if ($from && strlen($from) && $to && strlen($to)) {
             $fv_id = TranslationMap::find_translation($fact_id, $from);
             if ($fv_id && $fv_id != $to) {
                 $confl = $this->headers[$def['trans_from']] . ' and ' . $this->headers[$def['trans_to']];
                 $errors[] = "(conflicting translated value between {$confl})";
             }
         }
     }
     // combine any errors to return
     if (count($errors) > 0) {
         return "Errors on row {$row}: " . implode(', ', $errors);
     } else {
         return true;
     }
 }
 /**
  * Get facts from row object
  *
  * @param array   $obj    row object
  * @param int     $idx    row index
  * @param array   $fields field mapping def
  * @return array data
  */
 protected function get_facts($obj, $idx, $fields)
 {
     $facts = array();
     // determine if there are any facts to write
     foreach ($this->map_facts as $fid => $mapcols) {
         $sf = array();
         foreach ($mapcols as $colidx => $fldname) {
             $val = $obj[$colidx];
             if ($val && strlen($val)) {
                 $sf[$fldname] = $val;
             }
         }
         // normalize and translate src_value text
         if (isset($sf['sf_src_value'])) {
             $sf['sf_src_value'] = air2_str_clean($sf['sf_src_value']);
             $fv_id = TranslationMap::find_translation($fid, $sf['sf_src_value']);
             if ($fv_id) {
                 $sf['sf_fv_id'] = $fv_id;
             }
         }
         // ignore empty/null facts
         if (count($sf)) {
             $sf['TankSource'] = "TankSource_{$idx}";
             $sf['tf_fact_id'] = $fid;
             $facts["TankFact_{$idx}_{$fid}"] = $sf;
         }
     }
     // return false for no data
     if (count($facts) == 0) {
         return false;
     } else {
         return $facts;
     }
 }