You are here

function flysystem_menu in Flysystem 7

Implements hook_menu().

File

./flysystem.module, line 14
Provides access to various filesystem backends using Flysystem.

Code

function flysystem_menu() {
  $items = array();
  $items['_flysystem/%'] = array(
    'title' => 'Flysystem file download',
    'page callback' => 'file_download',
    'page arguments' => array(
      1,
    ),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  $items['admin/config/media/file-system/settings'] = array(
    'title' => 'Settings',
    'file path' => drupal_get_path('module', 'system'),
    'weight' => -10,
    'type' => MENU_DEFAULT_LOCAL_TASK,
  );
  $items['admin/config/media/file-system/flysystem'] = array(
    'title' => 'Flysystem',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'flysystem_config_form',
    ),
    'access arguments' => array(
      'administer flysystem',
    ),
    'file' => 'flysystem.admin.inc',
    'type' => MENU_LOCAL_TASK,
  );
  if (module_exists('image')) {
    $items['_flysystem/%/styles/%image_style'] = array(
      'title' => 'Generate image style',
      'page callback' => 'image_style_deliver',
      'page arguments' => array(
        3,
      ),
      'access callback' => TRUE,
      'type' => MENU_CALLBACK,
    );
    if (flysystem_dependencies_check()) {
      foreach (variable_get('flysystem', array()) as $scheme => $conf) {
        $plugin = flysystem_factory()
          ->getPlugin($scheme);
        if ($plugin instanceof Local && ($public_path = $plugin
          ->getPublicPath())) {
          $items[$public_path . '/styles/%image_style'] = array(
            'title' => 'Generate image style',
            'page callback' => 'image_style_deliver',
            'page arguments' => array(
              count(explode('/', $public_path)) + 1,
            ),
            'access callback' => TRUE,
            'type' => MENU_CALLBACK,
          );
        }
      }
    }
  }
  return $items;
}