You are here

function finder_wizard_finder_ui_alter in Finder 7.2

Implements hook_finder_ui_alter().

File

modules/finder_wizard/finder_wizard.module, line 21
The Finder page module.

Code

function finder_wizard_finder_ui_alter(&$data, $finder) {
  foreach ($finder->elements as $element) {
    if ($element->element == 'page') {

      // Disable the find button config.
      $data['items']['find_button']['#item']['#value'] = t('Disabled by <em>Wizard page</em> element');
      $data['items']['find_button']['#form']['settings'] = array(
        '#markup' => t('Disabled by <em>Wizard page</em> element'),
      );

      // Force the find button to be enabled (we will replace it on the day).
      $finder->settings['find_button'] = TRUE;

      // Create a 'pages' group.
      $data['groups'][1]['finder_wizard'] = t('Wizard pages');

      // Set a default for the next button text.
      if (!isset($finder->settings['finder_wizard_next_text'])) {
        $finder->settings['finder_wizard_next_text'] = t('Next') . ' »';
      }

      // Add config for the next button text.
      $data['items']['finder_wizard_next_text'] = array(
        '#group' => 'finder_wizard',
        '#item' => array(
          '#title' => t('Next button'),
          '#value' => $finder
            ->setting('finder_wizard_next_text') ? $finder
            ->setting('finder_wizard_next_text') : t('No'),
        ),
        '#form' => array(
          'settings' => array(
            'finder_wizard_next_text' => array(
              '#type' => 'textfield',
              '#title' => t('Next button text'),
              '#default_value' => $finder
                ->setting('finder_wizard_next_text'),
              '#description' => t('Text to display on the next button.'),
            ),
          ),
        ),
      );

      // Set a default for the back button.
      if (!isset($finder->settings['finder_wizard_back'])) {
        $finder->settings['finder_wizard_back'] = TRUE;
      }

      // Set a default for the back button text.
      if (!isset($finder->settings['finder_wizard_back_text'])) {
        $finder->settings['finder_wizard_back_text'] = '« ' . t('Back');
      }

      // Add config for the back button text.
      $data['items']['finder_wizard_back'] = array(
        '#group' => 'finder_wizard',
        '#item' => array(
          '#title' => t('Back button'),
          '#value' => $finder
            ->setting('finder_wizard_back') ? $finder
            ->setting('finder_wizard_back_text') : t('No'),
        ),
        '#form' => array(
          'settings' => array(
            'finder_wizard_back' => array(
              '#type' => 'checkbox',
              '#title' => t('Use the <em>Back button</em>'),
              '#default_value' => $finder
                ->setting('finder_wizard_back'),
            ),
            'finder_wizard_back_text' => array(
              '#type' => 'textfield',
              '#title' => t('Back button text'),
              '#default_value' => $finder
                ->setting('finder_wizard_back_text'),
              '#description' => t('Text to display on the back button.'),
              '#process' => array(
                'ctools_dependent_process',
              ),
              '#dependency' => array(
                'edit-settings-finder-wizard-back' => array(
                  1,
                ),
              ),
            ),
          ),
        ),
      );

      // Set a default for the back button text.
      if (!isset($finder->settings['finder_wizard_hide_disabled'])) {
        $finder->settings['finder_wizard_hide_disabled'] = FALSE;
      }

      // Add config for hiding disabled buttons.
      $data['items']['finder_wizard_hide_disabled'] = array(
        '#group' => 'finder_wizard',
        '#item' => array(
          '#title' => t('Hide disabled buttons'),
          '#value' => $finder
            ->setting('finder_wizard_hide_disabled') ? t('Yes') : t('No'),
        ),
        '#form' => array(
          'settings' => array(
            'finder_wizard_hide_disabled' => array(
              '#type' => 'checkbox',
              '#title' => t('Hide disabled buttons'),
              '#default_value' => $finder
                ->setting('finder_wizard_hide_disabled'),
              '#description' => t('Hiding disabled buttons may cause other buttons to change in position between pages, it is best to use CSS instead.'),
            ),
          ),
        ),
      );

      // Add some settings to URL parameters.
      if (!isset($finder->settings['finder_wizard_url_page'])) {
        $finder->settings['finder_wizard_url_page'] = 'page';
      }
      $data['items']['url']['#form']['settings']['finder_wizard_url_page'] = array(
        '#type' => 'textfield',
        '#title' => t('Wizard page key'),
        '#default_value' => $finder
          ->setting('finder_wizard_url_page'),
        '#description' => t('Used to indicate which page the finder is on.  Make sure this is simple enough to be used in a URL without problems.'),
        '#required' => TRUE,
        '#process' => array(
          'ctools_dependent_process',
        ),
        '#dependency' => array(
          'radio:settings[url]' => array(
            'enabled',
          ),
        ),
        '#translatable' => FALSE,
        '#maxlength' => 32,
        '#size' => 30,
      );
      if (!isset($finder->settings['finder_wizard_url_results'])) {
        $finder->settings['finder_wizard_url_results'] = '_results';
      }
      $data['items']['url']['#form']['settings']['finder_wizard_url_results'] = array(
        '#type' => 'textfield',
        '#title' => t('Wizard results page value'),
        '#default_value' => $finder
          ->setting('finder_wizard_url_results'),
        '#description' => t('Used to indicate the page is the results page.  Make sure this is simple enough to be used in a URL without problems.'),
        '#required' => TRUE,
        '#process' => array(
          'ctools_dependent_process',
        ),
        '#dependency' => array(
          'radio:settings[url]' => array(
            'enabled',
          ),
        ),
        '#translatable' => FALSE,
        '#maxlength' => 32,
        '#size' => 30,
      );
      break;
    }
  }
}