[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/module_builder/includes/ -> common_version_7.inc (source)

   1  <?php
   2  
   3  /**
   4   * @file common_version_7.inc
   5   *   Stuff needed both by module and drush command.
   6   *   Functions that need to differ for versions of Drupal.
   7   */
   8  
   9  /**
  10   * Run through Drupal's directory creation and checking stuff, 
  11   * adding a version subfolder for common directories.
  12   *
  13   * @param $directory
  14   *  A directory path. Should be either absolute or relative; the latter will
  15   *  be taken to mean it's inside the Drupal /files directory.
  16   * @param $common
  17   *  Boolean to indicate whether this directory is common across several 
  18   *  Drupal installations. If set, the actual directory used will be a
  19   *  subdirectory with a version number: eg path/to/dir/6
  20   */
  21  function module_builder_create_directory(&$directory, $common = FALSE) {
  22    if (substr($directory, 0, 1) == '/') {
  23      // absolute path
  24      //print 'starts with /'; 
  25    }
  26    else {
  27      // Relative, and so assumed to be in Drupal's files folder: prepend this to
  28      // the given directory.
  29      $directory = 'public://' . $directory;
  30    }
  31  
  32    // If the directory is common, append the version number subdir.
  33    if ($common) {
  34      // There may or may not be a trailing slash: trim to make sure.
  35      $directory = rtrim($directory, '/');
  36      $directory = $directory . '/' . _module_builder_drupal_major_version();  
  37    }
  38  
  39    $status = file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
  40    // @todo: check $status for errors
  41  }
  42  
  43  /**
  44   * A version-independent wrapper for drupal_system_listing().
  45   */
  46  function module_builder_system_listing($mask, $directory, $key = 'name', $min_depth = 1) {
  47    $mask = "/$mask/";
  48    return drupal_system_listing($mask, $directory, $key, $min_depth);
  49  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7