public function buildQuickForm() { $config = CRM_Core_Config::singleton(); global $tsLocale; $this->_locales = array_keys($config->languageLimit); // get the part of the database we want to edit and validate it $table = CRM_Utils_Request::retrieve('table', 'String', $this); $field = CRM_Utils_Request::retrieve('field', 'String', $this); $id = CRM_Utils_Request::retrieve('id', 'Int', $this); $this->_structure = CRM_Core_I18n_SchemaStructure::columns(); if (!isset($this->_structure[$table][$field])) { CRM_Core_Error::fatal("{$table}.{$field} is not internationalized."); } $this->addElement('hidden', 'table', $table); $this->addElement('hidden', 'field', $field); $this->addElement('hidden', 'id', $id); $cols = array(); foreach ($this->_locales as $locale) { $cols[] = "{$field}_{$locale} {$locale}"; } $query = 'SELECT ' . implode(', ', $cols) . " FROM {$table} WHERE id = {$id}"; $dao = new CRM_Core_DAO(); $dao->query($query, FALSE); $dao->fetch(); // get html type and attributes for this field $widgets = CRM_Core_I18n_SchemaStructure::widgets(); $widget = $widgets[$table][$field]; // attributes $attributes = array('class' => ''); if (isset($widget['rows'])) { $attributes['rows'] = $widget['rows']; } if (isset($widget['cols'])) { $attributes['cols'] = $widget['cols']; } $required = !empty($widget['required']); if ($widget['type'] == 'RichTextEditor') { $widget['type'] = 'wysiwyg'; $attributes['class'] .= ' collapsed'; } $languages = CRM_Core_I18n::languages(TRUE); foreach ($this->_locales as $locale) { $attr = $attributes; $name = "{$field}_{$locale}"; if ($locale == $tsLocale) { $attr['class'] .= ' default-lang'; } $this->add($widget['type'], $name, $languages[$locale], $attr, $required); $this->_defaults[$name] = $dao->{$locale}; } $this->addDefaultButtons(ts('Save'), 'next', NULL); CRM_Utils_System::setTitle(ts('Languages')); $this->assign('locales', $this->_locales); $this->assign('field', $field); }