| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @file common_version.inc 5 * Stuff needed both by module and drush command. 6 * Functions that need to differ for versions of Drupal. 7 * This file is the default fallback, and covers Drupal 5 and 6. 8 */ 9 10 /** 11 * Run through Drupal's directory creation and checking stuff, 12 * adding a version subfolder for common directories. 13 * 14 * @param $directory 15 * A directory path. Should be either absolute or relative; the latter will 16 * be taken to mean it's inside the Drupal /files directory. 17 * @param $common 18 * Boolean to indicate whether this directory is common across several 19 * Drupal installations. If set, the actual directory used will be a 20 * subdirectory with a version number: eg path/to/dir/6 21 */ 22 function module_builder_create_directory(&$directory, $common = FALSE) { 23 if (substr($directory, 0, 1) == '/') { 24 // absolute path 25 //print 'starts with /'; 26 } 27 else { 28 // Relative, and so assumed to be in Drupal's files folder. 29 // sanity check. need to verify /files exists before we do anything. see http://drupal.org/node/367138 30 $files = file_create_path(); 31 file_check_directory($files, FILE_CREATE_DIRECTORY); 32 $directory = file_create_path($directory); 33 } 34 35 // Note that recursive stuff won't work here! 36 // You really should make sure the dir exists yourself. 37 file_check_directory($directory, FILE_CREATE_DIRECTORY); 38 39 // If the directory is common, append the version number subdir. 40 if ($common) { 41 // $directory has no trailing / at this point: file_check_directory removes it. 42 $directory = $directory . '/' . _module_builder_drupal_major_version(); 43 file_check_directory($directory, FILE_CREATE_DIRECTORY); 44 } 45 } 46 47 /** 48 * A version-independent wrapper for drupal_system_listing(). 49 */ 50 function module_builder_system_listing($mask, $directory, $key = 'name', $min_depth = 1) { 51 $files = drupal_system_listing($mask, $directory, $key, $min_depth); 52 53 // This one is actually only for Drupal 6. 54 // The file object is: 55 // D6 D7 what it actually is 56 // - filename | uri | full path and name 57 // - basename | filename | name with the extension 58 // - name | name | name without the extension 59 // So we copy filename to uri, and then the caller can handle the returned 60 // array as if it were Drupal 7 style. 61 foreach ($files as $file) { 62 $file->uri = $file->filename; 63 } 64 65 return $files; 66 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |