You are here

function views_slideshow_settings in Views Slideshow 5

Implement hook_settings

1 string reference to 'views_slideshow_settings'
views_slideshow_menu in ./views_slideshow.module
Implement hook_menu

File

./views_slideshow.module, line 56

Code

function views_slideshow_settings() {
  if (!module_exists('hoverintent')) {
    drupal_set_message(t('You may experience better performance with your slide shows if you install the !hoverintent module.', array(
      '!hoverintent' => l(t('hoverIntent'), 'http://drupal.org/project/hoverintent'),
    )));
  }
  $form = array();
  $form['views_slideshow_default_mode'] = array(
    '#type' => 'select',
    '#title' => t('Global slideshow mode'),
    '#default_value' => variable_get('views_slideshow_default_mode', VIEWS_SLIDESHOW_DEFAULT_MODE),
    '#options' => array(
      VIEWS_SLIDESHOW_MODE_SINGLE_FRAME => t('single frame'),
      VIEWS_SLIDESHOW_MODE_THUMBNAIL_HOVER => t('thumbnail hover'),
    ),
    '#description' => t('This will set the type of slideshow to display for views. When set as \'single frame\', a single element will be displayed, with node teasers fading and and out to the next node in order. When set as \'thumbnail hover\', all the teasers will be displayed in a list, followed by a larger element displaying the full node view -- the slideshow will either rotate through the elements using the timer, and/or with a mouse-over event.'),
  );
  if (module_exists('jcarousel')) {
    $form['views_slideshow_default_mode']['#options'][VIEWS_SLIDESHOW_MODE_JCAROUSEL] = t('jcarousel');
    $form['views_slideshow_default_mode']['#description'] .= t(' Jcarousel.');
    $form['jcarousel'] = array(
      '#type' => 'fieldset',
      '#title' => t('jCarousel options'),
      '#collapsible' => TRUE,
    );
    $form['jcarousel']['views_slideshow_jcarousel_skin'] = array(
      '#type' => 'textfield',
      '#title' => t('jCarousel skin'),
      '#default_value' => variable_get('views_slideshow_jcarousel_skin', VIEWS_SLIDESHOW_JCAROUSEL_SKIN_DEFAULT),
      '#description' => t('This is the skin to use when using jCarousel. If it is any other than the default of %tango, you\'ll need to create your own %skin file in a directory of that name in the %directory folder. It would need to designate a class of %class to apply to the created list, such as %sample-class in %skin in the %sample-dir folder.', array(
        '%tango' => VIEWS_SLIDESHOW_JCAROUSEL_SKIN_DEFAULT,
        '%skin' => 'skin.css',
        '%directory' => drupal_get_path('module', 'jcarousel') . "/skins/[SKIN]",
        '%class' => '.jcarousel-skin-[SKIN]',
        '%sample-class' => '.jcarousel-skin-tango',
        '%sample-dir' => drupal_get_path('module', 'jcarousel') . "/skins/tango",
      )),
    );
    $form['jcarousel']['views_slideshow_jcarousel_vertical'] = array(
      '#type' => 'checkbox',
      '#title' => t('jCarousel vertical slideshow'),
      '#default_value' => variable_get('views_slideshow_jcarousel_vertical', VIEWS_SLIDESHOW_JCAROUSEL_VERTICAL_DEFAULT),
      '#description' => t('If checked, a slideshow will be shown vertically, when using jCarousel.'),
    );
  }
  else {
    $form['jcarousel'] = array(
      '#type' => 'item',
      '#title' => t('jCarousel slideshow'),
      '#description' => t('If you have the !jcarousel module installed, you will have more slideshow options available, such as buttons, vertical slideshows, and skins. All these options are available anyway, although may require some customization. The !jcarousel module simply offers more functionality out of the box.', array(
        '!jcarousel' => l(t('jCarousel'), 'http://drupal.org/project/jcarousel'),
      )),
    );
  }

  // TODO: remove this when/if jcarousel support is added. also add instructions to developer
  unset($form['jcarousel']);
  $form['views_slideshow_default_hover_breakout'] = array(
    '#type' => 'select',
    '#title' => t('Global hover breakout'),
    '#default_value' => variable_get('views_slideshow_default_hover_breakout', VIEWS_SLIDESHOW_DEFAULT_HOVER_BREAKOUT),
    '#options' => array(
      VIEWS_SLIDESHOW_HOVER_BREAKOUT_TEASER => 'teaser',
      VIEWS_SLIDESHOW_HOVER_BREAKOUT_FULL => 'full node',
    ),
    '#description' => t('When using the \'thumbnail hover\' mode, a larger element will be created below a list of nodes, to display the node currently in focus (either by rotation or mouse-over). This option will select whether those nodes will be displayed as a teaser or full node in this element. It is ignored when in \'single frame\' mode.'),
  );
  $form['views_slideshow_default_teasers_last'] = array(
    '#type' => 'checkbox',
    '#title' => t('Global teaser placed last in hover breakout mode'),
    '#default_value' => variable_get('views_slideshow_default_teasers_last', VIEWS_SLIDESHOW_DEFAULT_TEASERS_LAST),
    '#description' => t('If checked, then when a slideshow is in the Hover Breakout mode, the teasers will be displayed after the main image. Otherwise, they will appear first.'),
  );
  $form['views_slideshow_default_timer_delay'] = array(
    '#type' => 'textfield',
    '#title' => t('Global slideshow timer delay'),
    '#default_value' => variable_get('views_slideshow_default_timer_delay', VIEWS_SLIDESHOW_DEFAULT_TIMER_DELAY),
    '#description' => t('Set this to the number of miliseconds you wish each slide to delay before showing the next slide of a view.'),
  );
  $form['views_slideshow_default_sort_order'] = array(
    '#type' => 'select',
    '#title' => t('Global slideshow sort order'),
    '#default_value' => variable_get('views_slideshow_default_sort_order', VIEWS_SLIDESHOW_DEFAULT_SORT_ORDER),
    '#options' => array(
      VIEWS_SLIDESHOW_SORT_REVERSE => t('reverse'),
      VIEWS_SLIDESHOW_SORT_RANDOM => t('random'),
      VIEWS_SLIDESHOW_SORT_FORWARD => t('forward'),
    ),
    '#description' => t('This determines the order that selected nodes of a view will be displayed in the slideshow.'),
  );
  $form['views_slideshow_default_fade'] = array(
    '#type' => 'select',
    '#title' => t('Global slideshow fade'),
    '#default_value' => variable_get('views_slideshow_default_fade', VIEWS_SLIDESHOW_DEFAULT_FADE),
    '#options' => array(
      '1' => t('true'),
      '0' => t('false'),
    ),
    '#description' => t('If true, then slides will fade into the next slide of the view. Otherwise, they will transition instantly, and the following values will be ignored.'),
  );
  $form['views_slideshow_default_fade_speed'] = array(
    '#type' => 'select',
    '#title' => t('Global slideshow fade speed'),
    '#default_value' => variable_get('views_slideshow_default_fade_speed', VIEWS_SLIDESHOW_DEFAULT_FADE_SPEED),
    '#options' => array(
      VIEWS_SLIDESHOW_FADE_SPEED_SLOW => t('slow'),
      VIEWS_SLIDESHOW_FADE_SPEED_NORMAL => t('normal'),
      VIEWS_SLIDESHOW_FADE_SPEED_FAST => t('fast'),
    ),
    '#description' => t('This determines how quickly a slide fades into the next slide.'),
  );
  $form['views_slideshow_default_fade_value'] = array(
    '#type' => 'textfield',
    '#title' => t('Global slideshow fade value'),
    '#default_value' => variable_get('views_slideshow_default_fade_value', VIEWS_SLIDESHOW_DEFAULT_FADE_VALUE),
    '#description' => t('Set this to a decimal between 0 and 1. Slides will fade to this opacity before fading into the next slide.'),
  );
  $form['helpfield'] = array(
    '#type' => 'fieldset',
    '#title' => t('Individual view slideshow configuration'),
    '#collapsible' => true,
    '#collapsed' => true,
  );
  $form['helpfield']['help'] = array(
    '#type' => 'item',
    '#value' => t('Currently, there is no way in the Views UI administration screens to set the previous options for a certain view.
      Until Views 2.0 is released, if you wish to override a global setting for a particular view slideshow, you\'ll need to manually
      set the value(s) in the Argument Handling Code of the Arguments section of the view.
      For instance, you might specify $view->slideshow[\'sort_order\'] = VIEWS_SLIDESHOW_SORT_RANDOM for a random slideshow,
      $view->slideshow[\'fade_value\'] = 0.5 to fade out nodes half-way, or $view->slideshow[\'timer_delay\'] = 2000 for a delay of two seconds.
      Allowed values:
      <ul>
        <li>$view->slideshow[\'mode\']
        <ul>
          <li>VIEWS_SLIDESHOW_MODE_SINGLE_FRAME (\'' . VIEWS_SLIDESHOW_MODE_SINGLE_FRAME . '\'):
            the slideshow will be displayed in single frame mode
          <li>VIEWS_SLIDESHOW_MODE_THUMBNAIL_HOVER (\'' . VIEWS_SLIDESHOW_MODE_THUMBNAIL_HOVER . '\'):
            the slideshow will be displayed in thumbnail hover mode
        </ul>
        <li>$view->slideshow[\'teasers_last\']
        <ul>
          <li>TRUE or FALSE; Only applies when the mode is VIEWS_SLIDESHOW_MODE_THUMBNAIL_HOVER.
            If TRUE, then teasers will be displayed before the main image. Otherwise, they will appear later in the HTML.
        </ul>
        <li>$view->slideshow[\'timer_delay\']
        <ul>
          <li>This value should be between 0 and the number of miliseconds you wish to delay.
        </ul>
        <li>$view->slideshow[\'sort_order\']
        <ul>
          <li>VIEWS_SLIDESHOW_SORT_REVERSE (' . VIEWS_SLIDESHOW_SORT_REVERSE . '): reverse order
          <li>VIEWS_SLIDESHOW_SORT_RANDOM (' . VIEWS_SLIDESHOW_SORT_RANDOM . '): random order
          <li>VIEWS_SLIDESHOW_SORT_FORWARD (' . VIEWS_SLIDESHOW_SORT_FORWARD . '): forward order
        </ul>
        <li>$view->slideshow[\'fade\']
        <ul>
          <li>true or false: if false, the slideshow will change instantly, and the values for fade_speed and fade_value will be ignored.
        </ul>
        <li>$view->slideshow[\'fade_speed\']
        <ul>
          <li>VIEWS_SLIDESHOW_FADE_SPEED_SLOW (\'' . VIEWS_SLIDESHOW_FADE_SPEED_SLOW . '\')
          <li>VIEWS_SLIDESHOW_FADE_SPEED_NORMAL (\'' . VIEWS_SLIDESHOW_FADE_SPEED_NORMAL . '\')
          <li>VIEWS_SLIDESHOW_FADE_SPEED_FAST (\'' . VIEWS_SLIDESHOW_FADE_SPEED_FAST . '\')
        </ul>
        <li>$view->slideshow[\'fade_value\']
        <ul>
          <li>a decimal value between 0 and 1, to determine how much to fade a slide.
        </ul>
      </ul>'),
  );
  return system_settings_form($form);
}