- Patch #380064 by c960657: make file_scan_directory() use save property names as file_load().
parent
b3e36d655c
commit
5d658d0848
|
@ -1395,9 +1395,9 @@ function file_download() {
|
|||
* the provided directory. Defaults to TRUE.
|
||||
* - 'key'
|
||||
* The key to be used for the returned array of files. Possible values are
|
||||
* "filename", for the path starting with $dir, "basename", for the
|
||||
* basename of the file, and "name" for the name of the file without an
|
||||
* extension. Defaults to 'filename'.
|
||||
* 'filepath', for the path starting with $dir, 'filename', for the
|
||||
* basename of the file, and 'name' for the name of the file without an
|
||||
* extension. Defaults to 'filepath'.
|
||||
* - 'min_depth'
|
||||
* Minimum depth of directories to return files from. Defaults to 0.
|
||||
* @param $depth
|
||||
|
@ -1405,8 +1405,8 @@ function file_download() {
|
|||
* should not be passed.
|
||||
* @return
|
||||
* An associative array (keyed on the provided key) of objects with
|
||||
* "filename", "basename", and "name" members corresponding to the
|
||||
* matching files.
|
||||
* 'filepath', 'filename', and 'name' members corresponding to the
|
||||
* matching files.
|
||||
*/
|
||||
function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
|
||||
// Merge in defaults.
|
||||
|
@ -1414,33 +1414,32 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
|
|||
'nomask' => '/(\.\.?|CVS)$/',
|
||||
'callback' => 0,
|
||||
'recurse' => TRUE,
|
||||
'key' => 'filename',
|
||||
'key' => 'filepath',
|
||||
'min_depth' => 0,
|
||||
);
|
||||
|
||||
$options['key'] = (in_array($options['key'], array('filename', 'basename', 'name')) ? $options['key'] : 'filename');
|
||||
$options['key'] = in_array($options['key'], array('filepath', 'filename', 'name')) ? $options['key'] : 'filepath';
|
||||
$files = array();
|
||||
|
||||
if (is_dir($dir) && $handle = opendir($dir)) {
|
||||
while (FALSE !== ($file = readdir($handle))) {
|
||||
if (!preg_match($options['nomask'], $file) && $file[0] != '.') {
|
||||
if (is_dir("$dir/$file") && $options['recurse']) {
|
||||
while (FALSE !== ($filename = readdir($handle))) {
|
||||
if (!preg_match($options['nomask'], $filename) && $filename[0] != '.') {
|
||||
$filepath = "$dir/$filename";
|
||||
if (is_dir($filepath) && $options['recurse']) {
|
||||
// Give priority to files in this folder by merging them in after any subdirectory files.
|
||||
$files = array_merge(file_scan_directory("$dir/$file", $mask, $options, $depth + 1), $files);
|
||||
$files = array_merge(file_scan_directory($filepath, $mask, $options, $depth + 1), $files);
|
||||
}
|
||||
elseif ($depth >= $options['min_depth'] && preg_match($mask, $file)) {
|
||||
elseif ($depth >= $options['min_depth'] && preg_match($mask, $filename)) {
|
||||
// Always use this match over anything already set in $files with the
|
||||
// same $$options['key'].
|
||||
$filename = "$dir/$file";
|
||||
$basename = basename($file);
|
||||
$name = substr($basename, 0, strrpos($basename, '.'));
|
||||
$files[${$options['key']}] = (object) array(
|
||||
$file = (object) array(
|
||||
'filepath' => $filepath,
|
||||
'filename' => $filename,
|
||||
'basename' => $basename,
|
||||
'name' => $name,
|
||||
'name' => pathinfo($filename, PATHINFO_FILENAME),
|
||||
);
|
||||
$key = $options['key'];
|
||||
$files[$file->$key] = $file;
|
||||
if ($options['callback']) {
|
||||
$options['callback']($filename);
|
||||
$options['callback']($filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -216,9 +216,9 @@ function drupal_detect_database_types() {
|
|||
// file for the driver explicitly.
|
||||
|
||||
foreach (file_scan_directory(DRUPAL_ROOT . '/includes/database', '/^[a-z]*$/i', array('recurse' => FALSE)) as $file) {
|
||||
include_once "{$file->filename}/install.inc";
|
||||
include_once "{$file->filename}/database.inc";
|
||||
$drivers[$file->basename] = $file->filename;
|
||||
include_once "{$file->filepath}/install.inc";
|
||||
include_once "{$file->filepath}/database.inc";
|
||||
$drivers[$file->filename] = $file->filepath;
|
||||
}
|
||||
|
||||
foreach ($drivers as $driver => $file) {
|
||||
|
@ -934,7 +934,7 @@ function drupal_check_profile($profile) {
|
|||
// Collect requirement testing results
|
||||
$requirements = array();
|
||||
foreach ($installs as $install) {
|
||||
require_once DRUPAL_ROOT . '/' . $install->filename;
|
||||
require_once DRUPAL_ROOT . '/' . $install->filepath;
|
||||
$function = $install->name. '_requirements';
|
||||
if (function_exists($function)) {
|
||||
$requirements = array_merge($requirements, $function('install'));
|
||||
|
@ -974,7 +974,7 @@ function drupal_check_module($module) {
|
|||
// Include install file
|
||||
$install = drupal_get_install_files(array($module));
|
||||
if (isset($install[$module])) {
|
||||
require_once DRUPAL_ROOT . '/' . $install[$module]->filename;
|
||||
require_once DRUPAL_ROOT . '/' . $install[$module]->filepath;
|
||||
|
||||
// Check requirements
|
||||
$requirements = module_invoke($module, 'requirements', 'install');
|
||||
|
|
|
@ -2675,20 +2675,21 @@ function _locale_batch_build($files, $finished = NULL, $components = array()) {
|
|||
$operations = array();
|
||||
foreach ($files as $file) {
|
||||
// We call _locale_batch_import for every batch operation.
|
||||
$operations[] = array('_locale_batch_import', array($file->filename)); }
|
||||
$batch = array(
|
||||
'operations' => $operations,
|
||||
'title' => $t('Importing interface translations'),
|
||||
'init_message' => $t('Starting import'),
|
||||
'error_message' => $t('Error importing interface translations'),
|
||||
'file' => 'includes/locale.inc',
|
||||
// This is not a batch API construct, but data passed along to the
|
||||
// installer, so we know what did we import already.
|
||||
'#components' => $components,
|
||||
);
|
||||
if (isset($finished)) {
|
||||
$batch['finished'] = $finished;
|
||||
}
|
||||
$operations[] = array('_locale_batch_import', array($file->filepath));
|
||||
}
|
||||
$batch = array(
|
||||
'operations' => $operations,
|
||||
'title' => $t('Importing interface translations'),
|
||||
'init_message' => $t('Starting import'),
|
||||
'error_message' => $t('Error importing interface translations'),
|
||||
'file' => 'includes/locale.inc',
|
||||
// This is not a batch API construct, but data passed along to the
|
||||
// installer, so we know what did we import already.
|
||||
'#components' => $components,
|
||||
);
|
||||
if (isset($finished)) {
|
||||
$batch['finished'] = $finished;
|
||||
}
|
||||
return $batch;
|
||||
}
|
||||
return FALSE;
|
||||
|
|
|
@ -101,41 +101,41 @@ function module_rebuild_cache() {
|
|||
'files' => array(),
|
||||
);
|
||||
|
||||
foreach ($files as $filename => $file) {
|
||||
foreach ($files as $filepath => $file) {
|
||||
// Look for the info file.
|
||||
$file->info = drupal_parse_info_file(dirname($file->filename) . '/' . $file->name . '.info');
|
||||
$file->info = drupal_parse_info_file(dirname($file->filepath) . '/' . $file->name . '.info');
|
||||
|
||||
// Skip modules that don't provide info.
|
||||
if (empty($file->info)) {
|
||||
unset($files[$filename]);
|
||||
unset($files[$filepath]);
|
||||
continue;
|
||||
}
|
||||
// Merge in defaults and save.
|
||||
$files[$filename]->info = $file->info + $defaults;
|
||||
$files[$filepath]->info = $file->info + $defaults;
|
||||
|
||||
// Invoke hook_system_info_alter() to give installed modules a chance to
|
||||
// modify the data in the .info files if necessary.
|
||||
drupal_alter('system_info', $files[$filename]->info, $files[$filename]);
|
||||
drupal_alter('system_info', $files[$filepath]->info, $files[$filepath]);
|
||||
|
||||
// Update the contents of the system table:
|
||||
if (isset($file->status) || (isset($file->old_filename) && $file->old_filename != $file->filename)) {
|
||||
if (isset($file->status) || (isset($file->old_filepath) && $file->old_filepath != $file->filepath)) {
|
||||
db_update('system')
|
||||
->fields(array(
|
||||
'info' => serialize($files[$filename]->info),
|
||||
'info' => serialize($files[$filepath]->info),
|
||||
'name' => $file->name,
|
||||
'filename' => $file->filename))
|
||||
->condition('filename', $file->old_filename)
|
||||
'filename' => $file->filepath))
|
||||
->condition('filename', $file->old_filepath)
|
||||
->execute();
|
||||
}
|
||||
else {
|
||||
// This is a new module.
|
||||
$files[$filename]->status = 0;
|
||||
$files[$filepath]->status = 0;
|
||||
db_insert('system')
|
||||
->fields(array(
|
||||
'name' => $file->name,
|
||||
'info' => serialize($files[$filename]->info),
|
||||
'info' => serialize($files[$filepath]->info),
|
||||
'type' => 'module',
|
||||
'filename' => $file->filename,
|
||||
'filename' => $file->filepath,
|
||||
'status' => 0))
|
||||
->execute();
|
||||
}
|
||||
|
@ -535,7 +535,7 @@ function drupal_required_modules() {
|
|||
$files = drupal_system_listing('/\.info$/', 'modules', 'name', 0);
|
||||
$required = array();
|
||||
foreach ($files as $name => $file) {
|
||||
$info = drupal_parse_info_file($file->filename);
|
||||
$info = drupal_parse_info_file($file->filepath);
|
||||
if (!empty($info) && !empty($info['required']) && $info['required']) {
|
||||
$required[] = $name;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ function _registry_rebuild() {
|
|||
$files = array();
|
||||
foreach (module_rebuild_cache() as $module) {
|
||||
if ($module->status) {
|
||||
$dir = dirname($module->filename);
|
||||
$dir = dirname($module->filepath);
|
||||
foreach ($module->info['files'] as $file) {
|
||||
$files["$dir/$file"] = array('module' => $module->name, 'weight' => $module->weight);
|
||||
}
|
||||
|
|
|
@ -831,7 +831,7 @@ function drupal_find_theme_templates($cache, $extension, $path) {
|
|||
$files = drupal_system_listing($regex, $path, 'name', 0);
|
||||
foreach ($files as $template => $file) {
|
||||
// Ignore sub-theme templates for the current theme.
|
||||
if (strpos($file->filename, str_replace($subtheme_paths, '', $file->filename)) !== 0) {
|
||||
if (strpos($file->filepath, str_replace($subtheme_paths, '', $file->filepath)) !== 0) {
|
||||
continue;
|
||||
}
|
||||
// Chop off the remaining extensions if there are any. $template already
|
||||
|
@ -846,7 +846,7 @@ function drupal_find_theme_templates($cache, $extension, $path) {
|
|||
if (isset($cache[$hook])) {
|
||||
$templates[$hook] = array(
|
||||
'template' => $template,
|
||||
'path' => dirname($file->filename),
|
||||
'path' => dirname($file->filepath),
|
||||
);
|
||||
}
|
||||
// Ensure that the pattern is maintained from base themes to its sub-themes.
|
||||
|
@ -872,7 +872,7 @@ function drupal_find_theme_templates($cache, $extension, $path) {
|
|||
// Put the underscores back in for the hook name and register this pattern.
|
||||
$templates[strtr($file, '-', '_')] = array(
|
||||
'template' => $file,
|
||||
'path' => dirname($files[$match]->filename),
|
||||
'path' => dirname($files[$match]->filepath),
|
||||
'arguments' => $info['arguments'],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -420,7 +420,7 @@ function install_select_profile() {
|
|||
// Don't need to choose profile if only one available.
|
||||
if (sizeof($profiles) == 1) {
|
||||
$profile = array_pop($profiles);
|
||||
require_once $profile->filename;
|
||||
require_once $profile->filepath;
|
||||
return $profile->name;
|
||||
}
|
||||
elseif (sizeof($profiles) > 1) {
|
||||
|
@ -451,7 +451,7 @@ function install_select_profile_form(&$form_state, $profile_files) {
|
|||
$names = array();
|
||||
|
||||
foreach ($profile_files as $profile) {
|
||||
include_once DRUPAL_ROOT . '/' . $profile->filename;
|
||||
include_once DRUPAL_ROOT . '/' . $profile->filepath;
|
||||
|
||||
// Load profile details and store them for later retrieval.
|
||||
$function = $profile->name . '_profile_details';
|
||||
|
|
|
@ -68,7 +68,7 @@ class BlogAPITestCase extends DrupalWebTestCase {
|
|||
|
||||
// Upload file.
|
||||
$file = current($this->drupalGetTestFiles('text'));
|
||||
$file_contents = file_get_contents($file->filename);
|
||||
$file_contents = file_get_contents($file->filepath);
|
||||
$file = array();
|
||||
$file['name'] = $this->randomName() . '.txt';
|
||||
$file['type'] = 'text';
|
||||
|
|
|
@ -593,9 +593,9 @@ class DrupalWebTestCase {
|
|||
// If size is set then remove any files that are not of that size.
|
||||
if ($size !== NULL) {
|
||||
foreach ($files as $file) {
|
||||
$stats = stat($file->filename);
|
||||
$stats = stat($file->filepath);
|
||||
if ($stats['size'] != $size) {
|
||||
unset($files[$file->filename]);
|
||||
unset($files[$file->filepath]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -609,7 +609,7 @@ class DrupalWebTestCase {
|
|||
*/
|
||||
protected function drupalCompareFiles($file1, $file2) {
|
||||
// Determine which file is larger.
|
||||
$compare_size = (filesize($file1->filename) > filesize($file2->filename));
|
||||
$compare_size = (filesize($file1->filepath) > filesize($file2->filepath));
|
||||
if (!$compare_size) {
|
||||
// Both files were the same size, so return whichever one is alphabetically greater.
|
||||
return strnatcmp($file1->name, $file2->name);
|
||||
|
|
|
@ -33,7 +33,7 @@ function simpletest_install() {
|
|||
$original = drupal_get_path('module', 'simpletest') . '/files';
|
||||
$files = file_scan_directory($original, '/(html|image|javascript|php|sql)-.*/');
|
||||
foreach ($files as $file) {
|
||||
file_unmanaged_copy($file->filename, $path . '/' . $file->basename);
|
||||
file_unmanaged_copy($file->filepath, $path);
|
||||
}
|
||||
$generated = TRUE;
|
||||
}
|
||||
|
|
|
@ -465,7 +465,7 @@ function simpletest_get_all_tests() {
|
|||
$tests_directory = $module_path . '/tests';
|
||||
if (is_dir($tests_directory)) {
|
||||
foreach (file_scan_directory($tests_directory, '/\.test$/') as $file) {
|
||||
$files[] = $file->filename;
|
||||
$files[] = $file->filepath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,14 +21,14 @@ function file_test_validator($file, $errors) {
|
|||
* When the function is called with $reset parameter TRUE the cache is cleared
|
||||
* and the results returned.
|
||||
*
|
||||
* @param $file
|
||||
* File object
|
||||
* @param $filepath
|
||||
* File path
|
||||
* @param $reset
|
||||
* Boolean indicating that the stored files should be removed and returned.
|
||||
* @return
|
||||
* An array of all previous $file parameters since $reset was last called.
|
||||
*/
|
||||
function file_test_file_scan_callback($file, $reset = FALSE) {
|
||||
function file_test_file_scan_callback($filepath, $reset = FALSE) {
|
||||
static $files = array();
|
||||
|
||||
if ($reset) {
|
||||
|
@ -37,7 +37,7 @@ function file_test_file_scan_callback($file, $reset = FALSE) {
|
|||
return $ret;
|
||||
}
|
||||
|
||||
$files[] = $file;
|
||||
$files[] = $filepath;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -525,14 +525,14 @@ class FileSaveUploadTest extends FileHookTestCase {
|
|||
$this->drupalLogin($account);
|
||||
|
||||
$this->image = current($this->drupalGetTestFiles('image'));
|
||||
$this->assertTrue(is_file($this->image->filename), t("The file we're going to upload exists."));
|
||||
$this->assertTrue(is_file($this->image->filepath), t("The file we're going to upload exists."));
|
||||
|
||||
$this->maxFidBefore = db_query('SELECT MAX(fid) AS fid FROM {files}')->fetchField();
|
||||
|
||||
// Upload with replace to gurantee there's something there.
|
||||
$edit = array(
|
||||
'file_test_replace' => FILE_EXISTS_REPLACE,
|
||||
'files[file_test_upload]' => realpath($this->image->filename)
|
||||
'files[file_test_upload]' => realpath($this->image->filepath)
|
||||
);
|
||||
$this->drupalPost('file-test/upload', $edit, t('Submit'));
|
||||
$this->assertResponse(200, t('Received a 200 response for posted test file.'));
|
||||
|
@ -559,7 +559,7 @@ class FileSaveUploadTest extends FileHookTestCase {
|
|||
// Upload a second file.
|
||||
$max_fid_before = db_query('SELECT MAX(fid) AS fid FROM {files}')->fetchField();
|
||||
$image2 = current($this->drupalGetTestFiles('image'));
|
||||
$edit = array('files[file_test_upload]' => realpath($image2->filename));
|
||||
$edit = array('files[file_test_upload]' => realpath($image2->filepath));
|
||||
$this->drupalPost('file-test/upload', $edit, t('Submit'));
|
||||
$this->assertResponse(200, t('Received a 200 response for posted test file.'));
|
||||
$this->assertRaw(t('You WIN!'));
|
||||
|
@ -584,7 +584,7 @@ class FileSaveUploadTest extends FileHookTestCase {
|
|||
function testExistingRename() {
|
||||
$edit = array(
|
||||
'file_test_replace' => FILE_EXISTS_RENAME,
|
||||
'files[file_test_upload]' => realpath($this->image->filename)
|
||||
'files[file_test_upload]' => realpath($this->image->filepath)
|
||||
);
|
||||
$this->drupalPost('file-test/upload', $edit, t('Submit'));
|
||||
$this->assertResponse(200, t('Received a 200 response for posted test file.'));
|
||||
|
@ -600,7 +600,7 @@ class FileSaveUploadTest extends FileHookTestCase {
|
|||
function testExistingReplace() {
|
||||
$edit = array(
|
||||
'file_test_replace' => FILE_EXISTS_REPLACE,
|
||||
'files[file_test_upload]' => realpath($this->image->filename)
|
||||
'files[file_test_upload]' => realpath($this->image->filepath)
|
||||
);
|
||||
$this->drupalPost('file-test/upload', $edit, t('Submit'));
|
||||
$this->assertResponse(200, t('Received a 200 response for posted test file.'));
|
||||
|
@ -616,7 +616,7 @@ class FileSaveUploadTest extends FileHookTestCase {
|
|||
function testExistingError() {
|
||||
$edit = array(
|
||||
'file_test_replace' => FILE_EXISTS_ERROR,
|
||||
'files[file_test_upload]' => realpath($this->image->filename)
|
||||
'files[file_test_upload]' => realpath($this->image->filepath)
|
||||
);
|
||||
$this->drupalPost('file-test/upload', $edit, t('Submit'));
|
||||
$this->assertResponse(200, t('Received a 200 response for posted test file.'));
|
||||
|
@ -829,16 +829,16 @@ class FileScanDirectoryTest extends FileTestCase {
|
|||
|
||||
// Check the first file.
|
||||
$file = reset($all_files);
|
||||
$this->assertEqual(key($all_files), $file->filename, t('Correct array key was used for the first returned file.'));
|
||||
$this->assertEqual($file->filename, $this->path . '/javascript-1.txt', t('First file name was set correctly.'));
|
||||
$this->assertEqual($file->basename, 'javascript-1.txt', t('First basename was set correctly'));
|
||||
$this->assertEqual(key($all_files), $file->filepath, t('Correct array key was used for the first returned file.'));
|
||||
$this->assertEqual($file->filepath, $this->path . '/javascript-1.txt', t('First file name was set correctly.'));
|
||||
$this->assertEqual($file->filename, 'javascript-1.txt', t('First basename was set correctly'));
|
||||
$this->assertEqual($file->name, 'javascript-1', t('First name was set correctly.'));
|
||||
|
||||
// Check the second file.
|
||||
$file = next($all_files);
|
||||
$this->assertEqual(key($all_files), $file->filename, t('Correct array key was used for the second returned file.'));
|
||||
$this->assertEqual($file->filename, $this->path . '/javascript-2.script', t('Second file name was set correctly.'));
|
||||
$this->assertEqual($file->basename, 'javascript-2.script', t('Second basename was set correctly'));
|
||||
$this->assertEqual(key($all_files), $file->filepath, t('Correct array key was used for the second returned file.'));
|
||||
$this->assertEqual($file->filepath, $this->path . '/javascript-2.script', t('Second file name was set correctly.'));
|
||||
$this->assertEqual($file->filename, 'javascript-2.script', t('Second basename was set correctly'));
|
||||
$this->assertEqual($file->name, 'javascript-2', t('Second name was set correctly.'));
|
||||
}
|
||||
|
||||
|
@ -879,13 +879,13 @@ class FileScanDirectoryTest extends FileTestCase {
|
|||
function testOptionKey() {
|
||||
// "filename", for the path starting with $dir.
|
||||
$expected = array($this->path . '/javascript-1.txt', $this->path . '/javascript-2.script');
|
||||
$actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'filename')));
|
||||
$actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'filepath')));
|
||||
sort($actual);
|
||||
$this->assertEqual($expected, $actual, t('Returned the correct values for the filename key.'));
|
||||
|
||||
// "basename", for the basename of the file.
|
||||
$expected = array('javascript-1.txt', 'javascript-2.script');
|
||||
$actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'basename')));
|
||||
$actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'filename')));
|
||||
sort($actual);
|
||||
$this->assertEqual($expected, $actual, t('Returned the correct values for the basename key.'));
|
||||
|
||||
|
|
|
@ -1062,7 +1062,8 @@ function system_get_files_database(&$files, $type) {
|
|||
$result = db_query("SELECT filename, name, type, status, schema_version, weight FROM {system} WHERE type = '%s'", $type);
|
||||
while ($file = db_fetch_object($result)) {
|
||||
if (isset($files[$file->name]) && is_object($files[$file->name])) {
|
||||
$file->old_filename = $file->filename;
|
||||
$file->filepath = $file->filename;
|
||||
$file->old_filepath = $file->filepath;
|
||||
foreach ($file as $key => $value) {
|
||||
if (!isset($files[$file->name]) || !isset($files[$file->name]->$key)) {
|
||||
$files[$file->name]->$key = $value;
|
||||
|
@ -1155,7 +1156,8 @@ function _system_theme_data() {
|
|||
$sub_themes = array();
|
||||
// Read info files for each theme
|
||||
foreach ($themes as $key => $theme) {
|
||||
$themes[$key]->info = drupal_parse_info_file($theme->filename) + $defaults;
|
||||
$themes[$key]->filename = $theme->filepath;
|
||||
$themes[$key]->info = drupal_parse_info_file($theme->filepath) + $defaults;
|
||||
|
||||
// Invoke hook_system_info_alter() to give installed modules a chance to
|
||||
// modify the data in the .info files if necessary.
|
||||
|
@ -1165,7 +1167,7 @@ function _system_theme_data() {
|
|||
$sub_themes[] = $key;
|
||||
}
|
||||
if (empty($themes[$key]->info['engine'])) {
|
||||
$filename = dirname($themes[$key]->filename) . '/' . $themes[$key]->name . '.theme';
|
||||
$filename = dirname($themes[$key]->filepath) . '/' . $themes[$key]->name . '.theme';
|
||||
if (file_exists($filename)) {
|
||||
$themes[$key]->owner = $filename;
|
||||
$themes[$key]->prefix = $key;
|
||||
|
@ -1174,7 +1176,7 @@ function _system_theme_data() {
|
|||
else {
|
||||
$engine = $themes[$key]->info['engine'];
|
||||
if (isset($engines[$engine])) {
|
||||
$themes[$key]->owner = $engines[$engine]->filename;
|
||||
$themes[$key]->owner = $engines[$engine]->filepath;
|
||||
$themes[$key]->prefix = $engines[$engine]->name;
|
||||
$themes[$key]->template = TRUE;
|
||||
}
|
||||
|
@ -1184,7 +1186,7 @@ function _system_theme_data() {
|
|||
$pathed_stylesheets = array();
|
||||
foreach ($themes[$key]->info['stylesheets'] as $media => $stylesheets) {
|
||||
foreach ($stylesheets as $stylesheet) {
|
||||
$pathed_stylesheets[$media][$stylesheet] = dirname($themes[$key]->filename) . '/' . $stylesheet;
|
||||
$pathed_stylesheets[$media][$stylesheet] = dirname($themes[$key]->filepath) . '/' . $stylesheet;
|
||||
}
|
||||
}
|
||||
$themes[$key]->info['stylesheets'] = $pathed_stylesheets;
|
||||
|
@ -1192,12 +1194,12 @@ function _system_theme_data() {
|
|||
// Give the scripts proper path information.
|
||||
$scripts = array();
|
||||
foreach ($themes[$key]->info['scripts'] as $script) {
|
||||
$scripts[$script] = dirname($themes[$key]->filename) . '/' . $script;
|
||||
$scripts[$script] = dirname($themes[$key]->filepath) . '/' . $script;
|
||||
}
|
||||
$themes[$key]->info['scripts'] = $scripts;
|
||||
// Give the screenshot proper path information.
|
||||
if (!empty($themes[$key]->info['screenshot'])) {
|
||||
$themes[$key]->info['screenshot'] = dirname($themes[$key]->filename) . '/' . $themes[$key]->info['screenshot'];
|
||||
$themes[$key]->info['screenshot'] = dirname($themes[$key]->filepath) . '/' . $themes[$key]->info['screenshot'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ function _update_process_info_list(&$projects, $list, $project_type) {
|
|||
// which is left alone by tar and correctly set to the time the .info file
|
||||
// was unpacked.
|
||||
if (!isset($file->info['_info_file_ctime'])) {
|
||||
$info_filename = dirname($file->filename) . '/' . $file->name . '.info';
|
||||
$info_filename = dirname($file->filepath) . '/' . $file->name . '.info';
|
||||
$file->info['_info_file_ctime'] = filectime($info_filename);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class UploadTestCase extends DrupalWebTestCase {
|
|||
// Create a node and attempt to attach files.
|
||||
$node = $this->drupalCreateNode();
|
||||
$text_files = $this->drupalGetTestFiles('text');
|
||||
$files = array(current($text_files)->filename, next($text_files)->filename);
|
||||
$files = array(current($text_files)->filepath, next($text_files)->filepath);
|
||||
|
||||
$this->uploadFile($node, $files[0]);
|
||||
$this->uploadFile($node, $files[1]);
|
||||
|
@ -108,17 +108,17 @@ class UploadTestCase extends DrupalWebTestCase {
|
|||
$text_file = current($this->drupalGetTestFiles('text'));
|
||||
// Select a file that's less than the 1MB upload limit so we only test one
|
||||
// limit at a time.
|
||||
$this->uploadFile($node, $text_file->filename, FALSE);
|
||||
$this->uploadFile($node, $text_file->filepath, FALSE);
|
||||
// Test the error message in two steps in case there are additional errors
|
||||
// that change the error message's format.
|
||||
$this->assertRaw(t('The specified file %name could not be uploaded.', array('%name' => $text_file->basename)), t('File %filename was not allowed to be uploaded', array('%filename' => $text_file->filename)));
|
||||
$this->assertRaw(t('The specified file %name could not be uploaded.', array('%name' => $text_file->filename)), t('File %filepath was not allowed to be uploaded', array('%filepath' => $text_file->filepath)));
|
||||
$this->assertRaw(t('Only files with the following extensions are allowed: %files-allowed.', array('%files-allowed' => $settings['upload_extensions'])), t('File extension cited as reason for failure'));
|
||||
|
||||
// Attempt to upload .html file when .html is only extension allowed.
|
||||
$html_files = array_values($this->drupalGetTestFiles('html'));
|
||||
// Use the HTML file with the .html extension, $html_files[0] has a .txt
|
||||
// extension.
|
||||
$html_file = $html_files[1]->filename;
|
||||
$html_file = $html_files[1]->filepath;
|
||||
$this->uploadFile($node, $html_file);
|
||||
$this->assertNoRaw(t('The specified file %name could not be uploaded.', array('%name' => basename($html_file))), t('File '. $html_file . ' was allowed to be uploaded'));
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ class UploadTestCase extends DrupalWebTestCase {
|
|||
*/
|
||||
function testLimit() {
|
||||
$files = $this->drupalGetTestFiles('text', 1310720); // 1 MB.
|
||||
$file = current($files)->filename;
|
||||
$file = current($files)->filepath;
|
||||
|
||||
$admin_user = $this->drupalCreateUser(array('administer site configuration'));
|
||||
$web_user = $this->drupalCreateUser(array('access content', 'edit any page content', 'upload files', 'view uploaded files'));
|
||||
|
|
|
@ -535,7 +535,7 @@ class UserPictureTestCase extends DrupalWebTestCase {
|
|||
$this->drupalLogin($this->user);
|
||||
|
||||
$image = current($this->drupalGetTestFiles('image'));
|
||||
$info = image_get_info($image->filename);
|
||||
$info = image_get_info($image->filepath);
|
||||
|
||||
// Set new variables: invalid dimensions, valid filesize (0 = no limit).
|
||||
$test_dim = ($info['width'] - 10) . 'x' . ($info['height'] - 10);
|
||||
|
@ -569,7 +569,7 @@ class UserPictureTestCase extends DrupalWebTestCase {
|
|||
$this->drupalLogin($this->user);
|
||||
|
||||
$image = current($this->drupalGetTestFiles('image'));
|
||||
$info = image_get_info($image->filename);
|
||||
$info = image_get_info($image->filepath);
|
||||
|
||||
// Set new variables: valid dimensions, invalid filesize.
|
||||
$test_dim = ($info['width'] + 10) . 'x' . ($info['height'] + 10);
|
||||
|
@ -580,9 +580,9 @@ class UserPictureTestCase extends DrupalWebTestCase {
|
|||
$pic_path = $this->saveUserPicture($image);
|
||||
|
||||
// Test that the upload failed and that the correct reason was cited.
|
||||
$text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->basename));
|
||||
$text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->filename));
|
||||
$this->assertRaw($text, t('Upload failed.'));
|
||||
$text = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size(filesize($image->filename)), '%maxsize' => format_size($test_size * 1024)));
|
||||
$text = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size(filesize($image->filepath)), '%maxsize' => format_size($test_size * 1024)));
|
||||
$this->assertRaw($text, t('File size cited as reason for failure.'));
|
||||
|
||||
// Check if file is not uploaded.
|
||||
|
@ -604,7 +604,7 @@ class UserPictureTestCase extends DrupalWebTestCase {
|
|||
$this->drupalLogin($this->user);
|
||||
|
||||
$image = current($this->drupalGetTestFiles('image'));
|
||||
$info = image_get_info($image->filename);
|
||||
$info = image_get_info($image->filepath);
|
||||
|
||||
// Set new variables: invalid dimensions, valid filesize (0 = no limit).
|
||||
$test_dim = ($info['width'] - 10) . 'x' . ($info['height'] - 10);
|
||||
|
@ -614,7 +614,7 @@ class UserPictureTestCase extends DrupalWebTestCase {
|
|||
$pic_path = $this->saveUserPicture($image);
|
||||
|
||||
// Test that the upload failed and that the correct reason was cited.
|
||||
$text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->basename));
|
||||
$text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->filename));
|
||||
$this->assertRaw($text, t('Upload failed.'));
|
||||
$text = t('The image is too large; the maximum dimensions are %dimensions pixels.', array('%dimensions' => $test_dim));
|
||||
$this->assertRaw($text, t('Checking response on invalid image (dimensions).'));
|
||||
|
@ -637,7 +637,7 @@ class UserPictureTestCase extends DrupalWebTestCase {
|
|||
$this->drupalLogin($this->user);
|
||||
|
||||
$image = current($this->drupalGetTestFiles('image'));
|
||||
$info = image_get_info($image->filename);
|
||||
$info = image_get_info($image->filepath);
|
||||
|
||||
// Set new variables: valid dimensions, invalid filesize.
|
||||
$test_dim = ($info['width'] + 10) . 'x' . ($info['height'] + 10);
|
||||
|
@ -648,9 +648,9 @@ class UserPictureTestCase extends DrupalWebTestCase {
|
|||
$pic_path = $this->saveUserPicture($image);
|
||||
|
||||
// Test that the upload failed and that the correct reason was cited.
|
||||
$text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->basename));
|
||||
$text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->filename));
|
||||
$this->assertRaw($text, t('Upload failed.'));
|
||||
$text = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size(filesize($image->filename)), '%maxsize' => format_size($test_size * 1024)));
|
||||
$text = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size(filesize($image->filepath)), '%maxsize' => format_size($test_size * 1024)));
|
||||
$this->assertRaw($text, t('File size cited as reason for failure.'));
|
||||
|
||||
// Check if file is not uploaded.
|
||||
|
@ -669,7 +669,7 @@ class UserPictureTestCase extends DrupalWebTestCase {
|
|||
$this->drupalLogin($this->user);
|
||||
|
||||
$image = current($this->drupalGetTestFiles('image'));
|
||||
$info = image_get_info($image->filename);
|
||||
$info = image_get_info($image->filepath);
|
||||
|
||||
// Set new variables: valid dimensions, valid filesize (0 = no limit).
|
||||
$test_dim = ($info['width'] + 10) . 'x' . ($info['height'] + 10);
|
||||
|
@ -688,10 +688,10 @@ class UserPictureTestCase extends DrupalWebTestCase {
|
|||
}
|
||||
|
||||
function saveUserPicture($image) {
|
||||
$edit = array('files[picture_upload]' => realpath($image->filename));
|
||||
$edit = array('files[picture_upload]' => realpath($image->filepath));
|
||||
$this->drupalPost('user/' . $this->user->uid.'/edit', $edit, t('Save'));
|
||||
|
||||
$img_info = image_get_info($image->filename);
|
||||
$img_info = image_get_info($image->filepath);
|
||||
$picture_dir = variable_get('user_picture_path', 'pictures');
|
||||
$pic_path = file_directory_path() . '/' . $picture_dir . '/picture-' . $this->user->uid . '.' . $img_info['extension'];
|
||||
|
||||
|
|
Loading…
Reference in New Issue