getDefault() == $lang ) $dblang =''; $dblang= strtr($lang,'-','_'); VmConfig::$vmlang = $dblang; $id = vRequest::getInt('id',0); $viewKey = vRequest::getCmd('editView'); // TODO temp trick for vendor if ($viewKey == 'vendor') $id = 1 ; $tables = array ('category' =>'categories','product' =>'products','manufacturer' =>'manufacturers','manufacturercategories' =>'manufacturercategories','vendor' =>'vendors', 'paymentmethod' =>'paymentmethods', 'shipmentmethod' =>'shipmentmethods'); if ( !array_key_exists($viewKey, $tables) ) { $json['msg'] ="Invalid view ". $viewKey; echo json_encode($json); jExit(); } $tableName = '#__virtuemart_'.$tables[$viewKey].'_'.$dblang; $m = VmModel::getModel('coupon'); $table = $m->getTable($tables[$viewKey]); //Todo create method to load lang fields only $table->load($id); $vs = $table->loadFieldValues(); $lf = $table->getTranslatableFields(); $json['fields'] = array(); foreach($lf as $v){ if(isset($vs[$v])){ $json['fields'][$v] = $vs[$v]; } } //if ($json['fields'] = $db->loadAssoc()) { if ($table->getLoaded()) { $json['structure'] = 'filled' ; $json['msg'] = vmText::_('COM_VIRTUEMART_SELECTED_LANG').':'.$lang; } else { $db =vFactory::getDbo(); $json['structure'] = 'empty' ; $db->setQuery('SHOW COLUMNS FROM '.$tableName); $tableDescribe = $db->loadAssocList(); array_shift($tableDescribe); $fields=array(); foreach ($tableDescribe as $key =>$val) $fields[$val['Field']] = $val['Field'] ; $json['fields'] = $fields; $json['msg'] = vmText::sprintf('COM_VIRTUEMART_LANG_IS_EMPTY',$lang ,vmText::_('COM_VIRTUEMART_'.strtoupper( $viewKey)) ) ; } echo vmJsApi::safe_json_encode($json); jExit(); } } //pure php no tag