Index: i18nviews/includes/i18nviews.views.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/i18n/i18nviews/includes/Attic/i18nviews.views.inc,v retrieving revision 1.1.2.5 diff -u -p -r1.1.2.5 i18nviews.views.inc --- i18nviews/includes/i18nviews.views.inc 24 Nov 2009 00:06:08 -0000 1.1.2.5 +++ i18nviews/includes/i18nviews.views.inc 24 Nov 2009 20:20:22 -0000 @@ -44,5 +44,14 @@ function i18nviews_views_plugins() { 'path' => $path, ), ), + 'area' => array( + 'i18narea' => array( + 'title' => t('Translatable area'), + 'help' => t('Per languaje area.'), + 'handler' => 'views_plugin_area_i18n', + 'path' => $path, + 'uses options' => TRUE, + ), + ), ); -} \ No newline at end of file +} Index: i18nviews/includes/views_plugin_area_i18n.inc =================================================================== RCS file: i18nviews/includes/views_plugin_area_i18n.inc diff -N i18nviews/includes/views_plugin_area_i18n.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ i18nviews/includes/views_plugin_area_i18n.inc 24 Nov 2009 20:20:22 -0000 @@ -0,0 +1,128 @@ + $lang_name) { + $options['content_'. $lang_code] = ''; + } + + $options['format'] = variable_get('filter_default_format', 1); + } + + function options_form(&$form, &$form_state) { + + // we need to check if header, footer or empty text options exists + // for compatibility with previous versions of views + if (!empty($this->options[$this->type])) { + $default_value = $this->get_option($this->type); + } + + switch ($this->type) { + case 'header': + $description = t('Text to display at the top of the view. May contain an explanation or links or whatever you like. Optional. '); + break; + case 'empty': + $description = t('Text to display if the view has no results. Optional. '); + break; + case 'footer': + $description = t('Text to display at the bottom of the view. May contain an explanation or links or whatever you like. Optional. '); + break; + } + + $form['empty'] = array( + '#type' => 'checkbox', + '#title' => t('Display even if view has no result'), + '#default_value' => $this->options['empty'], + ); + + $langs = locale_language_list(); + foreach ($langs as $lang_code => $lang_name) { + $form['content_title_' . $lang_code] = array( + '#type' => 'fieldset', + '#title' => t('Language: @lang', array('@lang' => $lang_name)), + '#collapsible' => TRUE, + '#collapsed' => $lang_code != 'en', + ); + + $form['content_title_' . $lang_code]['content_' . $lang_code] = array( + '#type' => 'textarea', + '#default_value' => ($default_value)?$default_value:$this->options['content_' . $lang_code], + '#rows' => 6, + '#description' => $description . t('Language: %language', array('%language' => $lang_name)), + ); + + } + + $form['format'] = filter_form($this->options['format']); + } + + function render($empty = FALSE) { + if (!$empty || !empty($this->options['empty'])) { + if (module_exists('locale')) { + global $language; + $content = $this->options['content_'. $language->language]; + } + else { + $content = $this->options['content_en']; + } + return $this->render_textarea($content, $this->options['format']); + } + else { + return ''; + } + } + + /** + * Render a text area, using the proper format. + */ + function render_textarea($value, $format) { + static $formats = array(); + + // Check to make sure the filter format exists; if not, we don't + // display anything. + $format = filter_resolve_format($format); + + if (!array_key_exists($format, $formats)) { + $formats[$format] = db_result(db_query("SELECT name FROM {filter_formats} WHERE format = %d", $format)); + } + + if (!$formats[$format]) { + return; + } + + if ($value) { + return check_markup($value, $format, FALSE); + } + } + + function summary_title() { + $formats = filter_formats(); + return t('Text @format', array('@format' => $formats[$this->options['format']]->name)); + } + + + function options_submit(&$form, &$form_state) { + if (module_exists('locale')) { + $langs = locale_language_list(); + foreach ($langs as $lang_code => $lang_name) { + $form_state['values'][$this->type .'_options']['content_' . $lang_code] = $form_state['values'][$this->type .'_options']['content_title_' . $lang_code]['content_' . $lang_code]; + unset($form_state['values'][$this->type .'_options']['content_title_' . $lang_code]); + } + } + else { + $form_state['values'][$this->type .'_options']['content_en'] = $form_state['values'][$this->type .'_options']['content_title_en']['content_en']; + unset($form_state['values'][$this->type .'_options']['content_title_en']); + } + + $form_state['values'][$this->type .'_options']['format'] = $form_state['values']['format']; + + parent::options_submit($form, $form_state); + } +}