echo "Generating CRM_Core_I18n_SchemaStructure...\n";
$columns = array();
$indices = array();
+ $widgets = array();
foreach ($this->tables as $table) {
if ($table['localizable']) {
$columns[$table['name']] = array();
+ $widgets[$table['name']] = array();
}
else {
continue;
foreach ($table['fields'] as $field) {
if ($field['localizable']) {
$columns[$table['name']][$field['name']] = $field['sqlType'];
+ $widgets[$table['name']][$field['name']] = $field['widget'];
}
}
if (isset($table['index'])) {
$template->assign('columns', $columns);
$template->assign('indices', $indices);
+ $template->assign('widgets', $widgets);
$template->run('schema_structure.tpl', $this->config->phpCodePath . "/CRM/Core/I18n/SchemaStructure.php");
}
}
}
}
+
+ // in multilingual context popup, we need extra information to create appropriate widget
+ if ($fieldXML->localizable) {
+ if (isset($fieldXML->html)) {
+ $field['widget'] = (array) $fieldXML->html;
+ }
+ else {
+ // default
+ $field['widget'] = array('type' => 'Text');
+ }
+ if (isset($fieldXML->required)) {
+ $field['widget']['required'] = $this->value('required', $fieldXML);
+ }
+ }
+
$field['pseudoconstant'] = $this->value('pseudoconstant', $fieldXML);
if (!empty($field['pseudoconstant'])) {
//ok this is a bit long-winded but it gets there & is consistent with above approach
'labelColumn',
// Non-translated machine name for programmatic lookup. Defaults to 'name' if that column exists
'nameColumn',
- // Where clause snippet (will be joined to the rest of the query with AND operator)
+ // Where clause snippet (will be joined to the rest of the query with AND operator)
'condition',
// callback funtion incase of static arrays
'callback',
$dao->query($query, FALSE);
$dao->fetch();
- // we want TEXTAREAs for long fields and INPUTs for short ones
- $this->_structure[$table][$field] == 'text' ? $type = 'textarea' : $type = 'text';
+ // get html type and attributes for this field
+ $widgets = CRM_Core_I18n_SchemaStructure::widgets();
+ $widget = $widgets[$table][$field];
+ // attributes
+ $attributes = array('css' => '');
+ if (isset($widget['rows'])) {
+ $attributes['rows'] = $widget['rows'];
+ }
+ if (isset($widget['cols'])) {
+ $attributes['cols'] = $widget['cols'];
+ }
+ // FIXME: should have this
+ $required = !empty($widget['required']);
+
$languages = CRM_Core_I18n::languages(TRUE);
foreach ($this->_locales as $locale) {
- $this->addElement($type, "{$field}_{$locale}", $languages[$locale], array('class' => 'huge huge12' . ($locale == $tsLocale ? ' default-lang' : '')));
- $this->_defaults["{$field}_{$locale}"] = $dao->$locale;
+ $name = "{$field}_{$locale}";
+ if ($locale == $tsLocale) {
+ $attributes['class'] .= ' default-lang';
+ }
+ if ($widget['type'] == 'RichTextEditor') {
+ $attributes['click_wysiwyg'] = TRUE;
+ $this->addWysiwyg($name, $languages[$locale], $attributes, $required);
+ }
+ else {
+ $this->add($widget['type'], $name, $languages[$locale], $attributes, $required);
+ }
+
+ $this->_defaults[$name] = $dao->$locale;
}
$this->addDefaultButtons(ts('Save'), 'next', NULL);
<title>Contribution Page Introduction Text</title>
<type>text</type>
<html>
- <type>TextArea</type>
+ <type>RichTextEditor</type>
<rows>6</rows>
<cols>50</cols>
</html>
<title>Thank-you Text</title>
<type>text</type>
<html>
- <type>TextArea</type>
+ <type>RichTextEditor</type>
<rows>8</rows>
<cols>60</cols>
</html>
<title>Thank-you Footer</title>
<type>text</type>
<html>
- <type>TextArea</type>
+ <type>RichTextEditor</type>
<rows>8</rows>
<cols>60</cols>
</html>
<title>Footer Text</title>
<type>text</type>
<html>
- <type>TextArea</type>
+ <type>RichTextEditor</type>
<rows>6</rows>
<cols>50</cols>
</html>
{rdelim}
return $result;
{rdelim}
+ static function &widgets()
+ {ldelim}
+ static $result = null;
+ if (!$result) {ldelim}
+ $result = array(
+ {foreach from=$widgets key=table item=columns}
+ '{$table}' => array(
+ {foreach from=$columns key=column item=widget}
+ '{$column}' => array(
+ {foreach from=$widget key=name item=value}
+ '{$name}' => "{$value}",
+ {/foreach}
+ ),
+ {/foreach}
+ ),
+ {/foreach}
+ );
+ {rdelim}
+ return $result;
+ {rdelim}
{rdelim}