Go to the documentation of this file.00001 <?php
00002
00012 class views_handler_area_text extends views_handler_area {
00013
00014 function option_definition() {
00015 $options = parent::option_definition();
00016 $options['content'] = array('default' => '', 'translatable' => TRUE, 'format_key' => 'format');
00017 $options['format'] = array('default' => NULL);
00018 $options['tokenize'] = array('default' => FALSE);
00019 return $options;
00020 }
00021
00022 function options_form(&$form, &$form_state) {
00023 parent::options_form($form, $form_state);
00024
00025 $form['content'] = array(
00026 '#type' => 'text_format',
00027 '#default_value' => $this->options['content'],
00028 '#rows' => 6,
00029 '#format' => isset($this->options['format']) ? $this->options['format'] : filter_default_format(),
00030 '#wysiwyg' => FALSE,
00031 );
00032
00033
00034 $form['tokenize'] = array(
00035 '#type' => 'checkbox',
00036 '#title' => t('Use replacement tokens from the first row'),
00037 '#default_value' => $this->options['tokenize'],
00038 );
00039
00040
00041 $options = array();
00042 foreach ($this->view->display_handler->get_handlers('field') as $field => $handler) {
00043 $options[t('Fields')]["[$field]"] = $handler->ui_name();
00044 }
00045
00046 $count = 0;
00047 foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) {
00048 $options[t('Arguments')]['%' . ++$count] = t('@argument title', array('@argument' => $handler->ui_name()));
00049 $options[t('Arguments')]['!' . $count] = t('@argument input', array('@argument' => $handler->ui_name()));
00050 }
00051
00052 if (!empty($options)) {
00053 $output = '<p>' . t('The following tokens are available. If you would like to have the characters %5B and %5D please use the html entity codes \'%5B\' or \'%5D\' or they will get replaced with empty space.)' . '</p>');
00054 foreach (array_keys($options) as $type) {
00055 if (!empty($options[$type])) {
00056 $items = array();
00057 foreach ($options[$type] as $key => $value) {
00058 $items[] = $key . ' == ' . $value;
00059 }
00060 $output .= theme('item_list',
00061 array(
00062 'items' => $items,
00063 'type' => $type
00064 ));
00065 }
00066 }
00067
00068 $form['token_help'] = array(
00069 '#type' => 'fieldset',
00070 '#title' => t('Replacement patterns'),
00071 '#collapsible' => TRUE,
00072 '#collapsed' => TRUE,
00073 '#value' => $output,
00074 '#id' => 'edit-options-token-help',
00075 '#dependency' => array(
00076 'edit-options-tokenize' => array(1),
00077 ),
00078 '#prefix' => '<div>',
00079 '#suffix' => '</div>',
00080 );
00081 }
00082 }
00083
00084 function options_submit(&$form, &$form_state) {
00085 $form_state['values']['options']['format'] = $form_state['values']['options']['content']['format'];
00086 $form_state['values']['options']['content'] = $form_state['values']['options']['content']['value'];
00087 parent::options_submit($form, $form_state);
00088 }
00089
00090 function render($empty = FALSE) {
00091 $format = isset($this->options['format']) ? $this->options['format'] : filter_default_format();
00092 if (!$empty || !empty($this->options['empty'])) {
00093 return $this->render_textarea($this->options['content'], $format);
00094 }
00095 return '';
00096 }
00097
00101 function render_textarea($value, $format) {
00102 if ($value) {
00103 if ($this->options['tokenize']) {
00104 $value = $this->view->style_plugin->tokenize_value($value, 0);
00105 }
00106 return check_markup($value, $format, '', FALSE);
00107 }
00108 }
00109
00110 }