You are here

function superfish_styles in Superfish 7

Same name and namespace in other branches
  1. 6 superfish.module \superfish_styles()

Get a list of CSS files that can be used for styles.

3 calls to superfish_styles()
superfish_block_configure in ./superfish.module
Implements hook_block_configure().
superfish_block_validate in ./superfish.module
Validation function for the block configuration form.
superfish_block_view in ./superfish.module
Implements hook_block_view().

File

./superfish.module, line 1689
Enables the use of jQuery Superfish plugin for Drupal menus.

Code

function superfish_styles($display = 'list', $style = NULL) {
  $output = '';
  $directory = superfish_get_path('superfish') . '/style';
  $files = file_exists($directory) ? file_scan_directory($directory, '/.*\\.css$/', array(
    'key' => 'name',
  )) : '';
  if ($display == 'list') {
    $output = array(
      'none' => '- ' . t('None') . ' -',
    );
    if (is_array($files)) {
      foreach ($files as $file) {
        $output[$file->name] = drupal_ucfirst($file->name);
      }
    }
    natcasesort($output);
  }
  if ($display == 'path' && $style) {
    if (isset($files[$style])) {
      $output = array(
        $files[$style]->uri => array(
          'type' => 'file',
          'weight' => 500,
        ),
      );
    }
    else {
      watchdog('page not found', 'Cannot find the required files for the Superfish \'%style\' style.', array(
        '%style' => $style,
      ), WATCHDOG_WARNING);
      $output = '';
    }
  }
  return $output;
}