summaryrefslogtreecommitdiff
path: root/modules/file
diff options
context:
space:
mode:
Diffstat (limited to 'modules/file')
-rw-r--r--modules/file/file.api.php3
-rw-r--r--modules/file/file.css1
-rw-r--r--modules/file/file.field.inc22
-rw-r--r--modules/file/file.info1
-rw-r--r--modules/file/file.install1
-rw-r--r--modules/file/file.js7
-rw-r--r--modules/file/file.module10
-rw-r--r--modules/file/tests/file.test21
-rw-r--r--modules/file/tests/file_module_test.info1
-rw-r--r--modules/file/tests/file_module_test.module1
10 files changed, 32 insertions, 36 deletions
diff --git a/modules/file/file.api.php b/modules/file/file.api.php
index b5cf7931e..76fb98610 100644
--- a/modules/file/file.api.php
+++ b/modules/file/file.api.php
@@ -1,5 +1,4 @@
<?php
-// $Id$
/**
* @file
@@ -42,7 +41,7 @@ function hook_file_download_access($field, $entity_type, $entity) {
*
* @see hook_file_download_access().
*
- * @param &$grants
+ * @param $grants
* An array of grants gathered by hook_file_download_access(). The array is
* keyed by the module that defines the entity type's access control; the
* values are Boolean grant responses for each module.
diff --git a/modules/file/file.css b/modules/file/file.css
index 10d9a899d..aed1a9d34 100644
--- a/modules/file/file.css
+++ b/modules/file/file.css
@@ -1,4 +1,3 @@
-/* $Id$ */
/**
* Managed file element styles.
diff --git a/modules/file/file.field.inc b/modules/file/file.field.inc
index c20fe7741..2af3cb620 100644
--- a/modules/file/file.field.inc
+++ b/modules/file/file.field.inc
@@ -1,5 +1,4 @@
<?php
-// $Id$
/**
* @file
@@ -203,9 +202,9 @@ function file_field_prepare_view($entity_type, $entities, $field, $instances, $l
if (!file_field_displayed($item, $field)) {
unset($items[$id][$delta]);
}
- // Ensure consecutive deltas.
- $items[$id] = array_values($items[$id]);
}
+ // Ensure consecutive deltas.
+ $items[$id] = array_values($items[$id]);
}
}
@@ -448,7 +447,7 @@ function file_field_widget_form(&$form, &$form_state, $field, $instance, $langco
'description' => '',
);
- // Retrieve any values set in $form_state, as will be the case during AJAX
+ // Retrieve any values set in $form_state, as will be the case during Ajax
// rebuilds of this form.
if (isset($form_state['values'])) {
$path = array_merge($element['#field_parents'], array($field['field_name'], $langcode));
@@ -568,14 +567,17 @@ function file_field_widget_upload_validators($field, $instance) {
* A field array.
* @param $instance
* A field instance array.
+ * @param $data
+ * An array of token objects to pass to token_replace().
* @return
* A file directory URI with tokens replaced.
+ *
+ * @see token_replace()
*/
-function file_field_widget_uri($field, $instance, $account = NULL) {
+function file_field_widget_uri($field, $instance, $data = array()) {
$destination = trim($instance['settings']['file_directory'], '/');
// Replace tokens.
- $data = array('user' => isset($account) ? $account : $GLOBALS['user']);
$destination = token_replace($destination, $data);
return $field['settings']['uri_scheme'] . '://' . $destination;
@@ -650,7 +652,7 @@ function file_field_widget_process($element, &$form_state, $form) {
);
}
- // Adjust the AJAX settings so that on upload and remove of any individual
+ // Adjust the Ajax settings so that on upload and remove of any individual
// file, the entire group of file fields is updated together.
if ($field['cardinality'] != 1) {
$parents = array_slice($element['#array_parents'], 0, -1);
@@ -681,7 +683,7 @@ function file_field_widget_process($element, &$form_state, $form) {
/**
* An element #process callback for a group of file_generic fields.
*
- * Adds the weight field to each row so it can be ordered and adds a new AJAX
+ * Adds the weight field to each row so it can be ordered and adds a new Ajax
* wrapper around the entire group so it can be replaced all at once.
*/
function file_field_widget_process_multiple($element, &$form_state, $form) {
@@ -710,7 +712,7 @@ function file_field_widget_process_multiple($element, &$form_state, $form) {
}
}
- // Add a new wrapper around all the elements for AJAX replacement.
+ // Add a new wrapper around all the elements for Ajax replacement.
$element['#prefix'] = '<div id="' . $element['#id'] . '-ajax-wrapper">';
$element['#suffix'] = '</div>';
@@ -770,7 +772,7 @@ function theme_file_widget($variables) {
$element = $variables['element'];
$output = '';
- // The "form-managed-file" class is required for proper AJAX functionality.
+ // The "form-managed-file" class is required for proper Ajax functionality.
$output .= '<div class="file-widget form-managed-file clearfix">';
if ($element['fid']['#value'] != 0) {
// Add the file size after the file name.
diff --git a/modules/file/file.info b/modules/file/file.info
index ac3402266..eda79f96d 100644
--- a/modules/file/file.info
+++ b/modules/file/file.info
@@ -1,4 +1,3 @@
-; $Id$
name = File
description = Defines a file field type.
package = Core
diff --git a/modules/file/file.install b/modules/file/file.install
index c697f87af..47ee4fd00 100644
--- a/modules/file/file.install
+++ b/modules/file/file.install
@@ -1,5 +1,4 @@
<?php
-// $Id$
/**
* @file
diff --git a/modules/file/file.js b/modules/file/file.js
index 15629df5b..1071384f8 100644
--- a/modules/file/file.js
+++ b/modules/file/file.js
@@ -1,11 +1,10 @@
-// $Id$
/**
* @file
* Provides JavaScript additions to the managed file field type.
*
* This file provides progress bar support (if available), popup windows for
- * file previews, and disabling of other file fields during AJAX uploads (which
+ * file previews, and disabling of other file fields during Ajax uploads (which
* prevents separate file fields from accidentally uploading files).
*/
@@ -90,7 +89,7 @@ Drupal.file = Drupal.file || {
disableFields: function (event){
var clickedButton = this;
- // Only disable upload fields for AJAX buttons.
+ // Only disable upload fields for Ajax buttons.
if (!$(clickedButton).hasClass('ajax-processed')) {
return;
}
@@ -105,7 +104,7 @@ Drupal.file = Drupal.file || {
// working with. Filter out fields that are already disabled so that they
// do not get enabled when we re-enable these fields at the end of behavior
// processing. Re-enable in a setTimeout set to a relatively short amount
- // of time (1 second). All the other mousedown handlers (like Drupal's AJAX
+ // of time (1 second). All the other mousedown handlers (like Drupal's Ajax
// behaviors) are excuted before any timeout functions are called, so we
// don't have to worry about the fields being re-enabled too soon.
// @todo If the previous sentence is true, why not set the timeout to 0?
diff --git a/modules/file/file.module b/modules/file/file.module
index 3b6e18580..3e4525119 100644
--- a/modules/file/file.module
+++ b/modules/file/file.module
@@ -1,5 +1,4 @@
<?php
-// $Id$
/**
* @file
@@ -161,7 +160,8 @@ function file_file_download($uri, $field_type = 'file') {
foreach ($field_references as $entity_type => $type_references) {
foreach ($type_references as $id => $reference) {
// Try to load $entity and $field.
- $entity = reset(entity_load($entity_type, array($id)));
+ $entity = entity_load($entity_type, array($id));
+ $entity = reset($entity);
$field = NULL;
if ($entity) {
// Load all fields for that entity.
@@ -221,7 +221,7 @@ function file_file_download($uri, $field_type = 'file') {
}
/**
- * Menu callback; Shared AJAX callback for file uploads and deletions.
+ * Menu callback; Shared Ajax callback for file uploads and deletions.
*
* This rebuilds the form element for a particular field item. As long as the
* form processing is properly encapsulated in the widget element the form
@@ -265,7 +265,7 @@ function file_ajax_upload() {
$form = $form[$parent];
}
- // Add the special AJAX class if a new file was added.
+ // Add the special Ajax class if a new file was added.
if (isset($form['#file_upload_delta']) && $current_file_count < $form['#file_upload_delta']) {
$form[$current_file_count]['#attributes']['class'][] = 'ajax-new-content';
}
@@ -453,7 +453,7 @@ function file_managed_file_process($element, &$form_state, $form) {
);
}
- // Prefix and suffix used for AJAX replacement.
+ // Prefix and suffix used for Ajax replacement.
$element['#prefix'] = '<div id="' . $element['#id'] . '-ajax-wrapper">';
$element['#suffix'] = '</div>';
diff --git a/modules/file/tests/file.test b/modules/file/tests/file.test
index bf74b8b71..ea8c5c67b 100644
--- a/modules/file/tests/file.test
+++ b/modules/file/tests/file.test
@@ -1,9 +1,8 @@
<?php
-// $Id$
/**
* @file
- * Tests file uploading through the File module.
+ * Tests for file.module.
*/
/**
@@ -254,7 +253,7 @@ class FileManagedFileElementTestCase extends FileFieldTestCase {
$this->drupalPost($path . '/' . $last_fid, array(), t('Save'));
$this->assertRaw(t('The file id is %fid.', array('%fid' => $last_fid)), t('Empty submission did not change an existing file.'));
- // Now, test the Upload and Remove buttons, with and without AJAX.
+ // Now, test the Upload and Remove buttons, with and without Ajax.
foreach (array(FALSE, TRUE) as $ajax) {
// Upload, then Submit.
$last_fid_prior = $this->getLastFileId();
@@ -302,7 +301,7 @@ class FileManagedFileElementTestCase extends FileFieldTestCase {
}
/**
- * Test class to test file field widget, single and multi-valued, with and without AJAX, with public and private files.
+ * Test class to test file field widget, single and multi-valued, with and without Ajax, with public and private files.
*/
class FileFieldWidgetTestCase extends FileFieldTestCase {
public static function getInfo() {
@@ -314,7 +313,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase {
}
/**
- * Tests upload and remove buttons, with and without AJAX, for a single-valued File field.
+ * Tests upload and remove buttons, with and without Ajax, for a single-valued File field.
*/
function testSingleValuedWidget() {
// Use 'page' instead of 'article', so that the 'article' image field does
@@ -371,7 +370,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase {
}
/**
- * Tests upload and remove buttons, with and without AJAX, for a multi-valued File field.
+ * Tests upload and remove buttons, with and without Ajax, for a multi-valued File field.
*/
function testMultiValuedWidget() {
// Use 'page' instead of 'article', so that the 'article' image field does
@@ -390,7 +389,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase {
// Visit the node creation form, and upload 3 files. Since the field has
// cardinality of 3, ensure the "Upload" button is displayed until after
// the 3rd file, and after that, isn't displayed.
- // @todo This is only testing a non-AJAX upload, because drupalPostAJAX()
+ // @todo This is only testing a non-Ajax upload, because drupalPostAJAX()
// does not yet emulate jQuery's file upload.
$this->drupalGet("node/add/$type_name");
for ($delta = 0; $delta < 3; $delta++) {
@@ -933,7 +932,7 @@ class FileFieldPathTestCase extends FileFieldTestCase {
// Check the path when used with tokens.
// Change the path to contain multiple token directories.
- $field = $this->updateFileField($field_name, $type_name, array('file_directory' => '[user:uid]/[user:name]'));
+ $field = $this->updateFileField($field_name, $type_name, array('file_directory' => '[current-user:uid]/[current-user:name]'));
// Upload a new file into the token subdirectories.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
@@ -941,6 +940,8 @@ class FileFieldPathTestCase extends FileFieldTestCase {
// Check that the file was uploaded into the subdirectory.
$node = node_load($nid, NULL, TRUE);
$node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0];
+ // Do token replacement using the same user which uploaded the file, not
+ // the user running the test case.
$data = array('user' => $this->admin_user);
$subdirectory = token_replace('[user:uid]/[user:name]', $data);
$this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path with token replacements.', array('%file' => $node_file->uri)));
@@ -1027,7 +1028,7 @@ class FileTokenReplaceTestCase extends FileFieldTestCase {
foreach ($tests as $input => $expected) {
$output = token_replace($input, array('file' => $file), array('language' => $language));
- $this->assertFalse(strcmp($output, $expected), t('Sanitized file token %token replaced.', array('%token' => $input)));
+ $this->assertEqual($output, $expected, t('Sanitized file token %token replaced.', array('%token' => $input)));
}
// Generate and test unsanitized tokens.
@@ -1039,7 +1040,7 @@ class FileTokenReplaceTestCase extends FileFieldTestCase {
foreach ($tests as $input => $expected) {
$output = token_replace($input, array('file' => $file), array('language' => $language, 'sanitize' => FALSE));
- $this->assertFalse(strcmp($output, $expected), t('Unsanitized file token %token replaced.', array('%token' => $input)));
+ $this->assertEqual($output, $expected, t('Unsanitized file token %token replaced.', array('%token' => $input)));
}
}
}
diff --git a/modules/file/tests/file_module_test.info b/modules/file/tests/file_module_test.info
index 50e2bd4b2..8db907b74 100644
--- a/modules/file/tests/file_module_test.info
+++ b/modules/file/tests/file_module_test.info
@@ -1,4 +1,3 @@
-; $Id$
name = File test
description = Provides hooks for testing File module functionality.
package = Core
diff --git a/modules/file/tests/file_module_test.module b/modules/file/tests/file_module_test.module
index 7bccb4a67..ea65981ca 100644
--- a/modules/file/tests/file_module_test.module
+++ b/modules/file/tests/file_module_test.module
@@ -1,5 +1,4 @@
<?php
-// $Id$
/**
* @file