danielebarchiesi@4: array( danielebarchiesi@4: 'element_type' => array('default' => 'h3'), danielebarchiesi@4: 'class' => array('default' => 'title'), danielebarchiesi@4: ), danielebarchiesi@4: ); danielebarchiesi@4: danielebarchiesi@4: // List option definition. danielebarchiesi@4: $options['list'] = array( danielebarchiesi@4: 'contains' => array( danielebarchiesi@4: 'element_type' => array('default' => ''), danielebarchiesi@4: 'class' => array('default' => ''), danielebarchiesi@4: ), danielebarchiesi@4: ); danielebarchiesi@4: danielebarchiesi@4: // Row option definition. danielebarchiesi@4: $options['row'] = array( danielebarchiesi@4: 'contains' => array( danielebarchiesi@4: 'element_type' => array('default' => 'div'), danielebarchiesi@4: 'class' => array('default' => ''), danielebarchiesi@4: 'first_class' => array('default' => 'first'), danielebarchiesi@4: 'last_class' => array('default' => 'last'), danielebarchiesi@4: 'last_every_nth' => array('default' => '0'), danielebarchiesi@4: 'striping_classes' => array('default' => 'odd even'), danielebarchiesi@4: ), danielebarchiesi@4: ); danielebarchiesi@4: danielebarchiesi@4: return $options; danielebarchiesi@4: } danielebarchiesi@4: danielebarchiesi@4: /** danielebarchiesi@4: * Render the given style. danielebarchiesi@4: */ danielebarchiesi@4: function options_form(&$form, &$form_state) { danielebarchiesi@4: parent::options_form($form, $form_state); danielebarchiesi@4: danielebarchiesi@4: // Group options. danielebarchiesi@4: $form['group'] = array( danielebarchiesi@4: '#type' => 'fieldset', danielebarchiesi@4: '#title' => t('Grouping title'), danielebarchiesi@4: '#description' => t('If using groups, the view will insert the grouping’s title field.'), danielebarchiesi@4: '#attributes' => array( danielebarchiesi@4: 'class' => 'clear-block', danielebarchiesi@4: ), danielebarchiesi@4: ); danielebarchiesi@4: $form['group']['element_type'] = array( danielebarchiesi@4: '#prefix' => '
', danielebarchiesi@4: '#suffix' => '
', danielebarchiesi@4: '#title' => t('Element'), danielebarchiesi@4: '#type' => 'textfield', danielebarchiesi@4: '#size' => '10', danielebarchiesi@4: '#default_value' => $this->options['group']['element_type'], danielebarchiesi@4: ); danielebarchiesi@4: $form['group']['class'] = array( danielebarchiesi@4: '#prefix' => '
', danielebarchiesi@4: '#suffix' => '
', danielebarchiesi@4: '#title' => t('Class attribute'), danielebarchiesi@4: '#type' => 'textfield', danielebarchiesi@4: '#size' => '30', danielebarchiesi@4: '#default_value' => $this->options['group']['class'], danielebarchiesi@4: ); danielebarchiesi@4: danielebarchiesi@4: // List options. danielebarchiesi@4: $form['list'] = array( danielebarchiesi@4: '#type' => 'fieldset', danielebarchiesi@4: '#title' => t('List'), danielebarchiesi@4: '#description' => t('If the output should be a HTML list, select the element and class attribute. The row element should also be set to %li.', array('%li' => 'li')), danielebarchiesi@4: '#attributes' => array( danielebarchiesi@4: 'class' => 'clear-block', danielebarchiesi@4: ), danielebarchiesi@4: ); danielebarchiesi@4: $form['list']['element_type'] = array( danielebarchiesi@4: '#prefix' => '
', danielebarchiesi@4: '#suffix' => '
', danielebarchiesi@4: '#type' => 'radios', danielebarchiesi@4: '#title' => t('List type'), danielebarchiesi@4: '#options' => array( danielebarchiesi@4: '' => t('None'), danielebarchiesi@4: 'ul' => t('Unordered list'), danielebarchiesi@4: 'ol' => t('Ordered list'), danielebarchiesi@4: 'dl' => t('Definition list'), danielebarchiesi@4: ), danielebarchiesi@4: '#default_value' => $this->options['list']['element_type'], danielebarchiesi@4: ); danielebarchiesi@4: $form['list']['class'] = array( danielebarchiesi@4: '#prefix' => '
', danielebarchiesi@4: '#suffix' => '
', danielebarchiesi@4: '#title' => t('Class attribute'), danielebarchiesi@4: '#type' => 'textfield', danielebarchiesi@4: '#size' => '30', danielebarchiesi@4: '#default_value' => $this->options['list']['class'], danielebarchiesi@4: ); danielebarchiesi@4: danielebarchiesi@4: // Row options. danielebarchiesi@4: $form['row'] = array( danielebarchiesi@4: '#type' => 'fieldset', danielebarchiesi@4: '#title' => t('Row'), danielebarchiesi@4: '#attributes' => array( danielebarchiesi@4: 'class' => 'clear-block', danielebarchiesi@4: ), danielebarchiesi@4: ); danielebarchiesi@4: $form['row']['element_type'] = array( danielebarchiesi@4: '#prefix' => '
', danielebarchiesi@4: '#suffix' => '
', danielebarchiesi@4: '#title' => t('Element'), danielebarchiesi@4: '#type' => 'textfield', danielebarchiesi@4: '#size' => '10', danielebarchiesi@4: '#default_value' => $this->options['row']['element_type'], danielebarchiesi@4: ); danielebarchiesi@4: $form['row']['class'] = array( danielebarchiesi@4: '#prefix' => '
', danielebarchiesi@4: '#suffix' => '
', danielebarchiesi@4: '#title' => t('Class attribute'), danielebarchiesi@4: '#type' => 'textfield', danielebarchiesi@4: '#size' => '30', danielebarchiesi@4: '#default_value' => $this->options['row']['class'], danielebarchiesi@4: '#description' => t('Insert a %hash where you want row enumeration.', array('%hash' => '#')), danielebarchiesi@4: ); danielebarchiesi@4: danielebarchiesi@4: // First and last class options. danielebarchiesi@4: $form['row']['first_last'] = array( danielebarchiesi@4: '#type' => 'fieldset', danielebarchiesi@4: '#title' => t('First and last classes'), danielebarchiesi@4: // The #parents attribute must be set to avoid another array layer around danielebarchiesi@4: // the group of FIRST/LAST class attribute options. danielebarchiesi@4: '#parents' => array('style_options', 'row'), danielebarchiesi@4: '#description' => t('If the %last_every_nth option is empty or zero, the %first_class and %last_class are added once to only the first and last rows in the pager set. If this option is greater than 1, these classes are added to every nth row, which may be useful for grid layouts where the initial and final unit’s lateral margins must be 0.', array( danielebarchiesi@4: '%last_every_nth' => 'FIRST/LAST every nth', danielebarchiesi@4: '%first_class' => 'FIRST class attribute', danielebarchiesi@4: '%last_class' => 'LAST class attribute', danielebarchiesi@4: ) danielebarchiesi@4: ), danielebarchiesi@4: '#attributes' => array( danielebarchiesi@4: 'class' => 'clear-block', danielebarchiesi@4: ), danielebarchiesi@4: ); danielebarchiesi@4: $form['row']['first_last']['last_every_nth'] = array( danielebarchiesi@4: '#type' => 'textfield', danielebarchiesi@4: '#size' => '10', danielebarchiesi@4: '#title' => t('FIRST/LAST every nth'), danielebarchiesi@4: '#default_value' => $this->options['row']['last_every_nth'], danielebarchiesi@4: ); danielebarchiesi@4: $form['row']['first_last']['first_class'] = array( danielebarchiesi@4: '#prefix' => '
', danielebarchiesi@4: '#suffix' => '
', danielebarchiesi@4: '#title' => t('FIRST class attribute'), danielebarchiesi@4: '#type' => 'textfield', danielebarchiesi@4: '#size' => '30', danielebarchiesi@4: '#default_value' => $this->options['row']['first_class'], danielebarchiesi@4: ); danielebarchiesi@4: $form['row']['first_last']['last_class'] = array( danielebarchiesi@4: '#prefix' => '
', danielebarchiesi@4: '#suffix' => '
', danielebarchiesi@4: '#title' => t('LAST class attribute'), danielebarchiesi@4: '#type' => 'textfield', danielebarchiesi@4: '#size' => '30', danielebarchiesi@4: '#default_value' => $this->options['row']['last_class'], danielebarchiesi@4: ); danielebarchiesi@4: danielebarchiesi@4: // Striping class options. danielebarchiesi@4: $form['row']['striping_classes'] = array( danielebarchiesi@4: '#title' => t('Striping class attributes'), danielebarchiesi@4: '#type' => 'textfield', danielebarchiesi@4: '#size' => '30', danielebarchiesi@4: '#default_value' => $this->options['row']['striping_classes'], danielebarchiesi@4: '#description' => t('One striping class attribute is applied to each row. Separate multiple attributes with a space.'), danielebarchiesi@4: ); danielebarchiesi@4: danielebarchiesi@4: // Get a list of the available fields for token replacement. danielebarchiesi@4: $options = array(); danielebarchiesi@4: foreach ($this->view->display_handler->get_handlers('field') as $field => $handler) { danielebarchiesi@4: $options[t('Fields')]["[$field]"] = $handler->ui_name(); danielebarchiesi@4: } danielebarchiesi@4: danielebarchiesi@4: // Default text. danielebarchiesi@4: $output = t('

Add additional fields to this display in order to get any available replacement patterns.

'); danielebarchiesi@4: // We have some options, so make a list. danielebarchiesi@4: if (!empty($options)) { danielebarchiesi@4: $output = t('

The following replacement patterns are available for this display. Use the pattern shown on the left to display the value indicated on the right.

'); danielebarchiesi@4: foreach (array_keys($options) as $type) { danielebarchiesi@4: if (!empty($options[$type])) { danielebarchiesi@4: $items = array(); danielebarchiesi@4: foreach ($options[$type] as $key => $value) { danielebarchiesi@4: $items[] = $key . ' == ' . $value; danielebarchiesi@4: } danielebarchiesi@4: $output .= theme('item_list', $items, $type); danielebarchiesi@4: } danielebarchiesi@4: } danielebarchiesi@4: } danielebarchiesi@4: danielebarchiesi@4: $form['row']['alter'] = array( danielebarchiesi@4: '#type' => 'markup', danielebarchiesi@4: '#value' => '
' . t('Replacement patterns') . '' . $output . '
', danielebarchiesi@4: ); danielebarchiesi@4: } danielebarchiesi@4: danielebarchiesi@4: /** danielebarchiesi@4: * Validate the options form. danielebarchiesi@4: */ danielebarchiesi@4: function options_validate(&$form, &$form_state) { danielebarchiesi@4: parent::options_validate($form, $form_state); danielebarchiesi@4: // TODO: validate that the elements and classes are valid HTML. This is not danielebarchiesi@4: // a substitute for output filtering. danielebarchiesi@4: } danielebarchiesi@4: }