summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorcatch <catch@35733.no-reply.drupal.org>2012-11-17 21:42:30 +0000
committercatch <catch@35733.no-reply.drupal.org>2012-11-17 21:42:30 +0000
commit198846a800486a8ad85bf028d278d8808ff26040 (patch)
tree62e077974cb38a894f602cd66348188af791a0e3
parentd1400e30a98a1423522354b4b37979ff7f516b16 (diff)
downloaddrupal-198846a800486a8ad85bf028d278d8808ff26040.tar.gz
drupal-198846a800486a8ad85bf028d278d8808ff26040.zip
Issue #1804394 by deviance, Albert Volkman: Convert file.module variables to CMI.
-rw-r--r--core/modules/file/config/file.settings.yml6
-rw-r--r--core/modules/file/file.field.inc5
-rw-r--r--core/modules/file/file.install13
-rw-r--r--core/modules/file/file.module12
4 files changed, 29 insertions, 7 deletions
diff --git a/core/modules/file/config/file.settings.yml b/core/modules/file/config/file.settings.yml
new file mode 100644
index 00000000000..e65227724a2
--- /dev/null
+++ b/core/modules/file/config/file.settings.yml
@@ -0,0 +1,6 @@
+description:
+ type: 'textfield'
+ length: 128
+icon:
+ directory: 'core/modules/file/icons'
+
diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc
index eb568893f10..a43849d4c30 100644
--- a/core/modules/file/file.field.inc
+++ b/core/modules/file/file.field.inc
@@ -427,11 +427,12 @@ function file_field_widget_process($element, &$form_state, $form) {
// Add the description field if enabled.
if (!empty($instance['settings']['description_field']) && $item['fid']) {
+ $config = config('file.settings');
$element['description'] = array(
- '#type' => variable_get('file_description_type', 'textfield'),
+ '#type' => $config->get('description.type'),
'#title' => t('Description'),
'#value' => isset($item['description']) ? $item['description'] : '',
- '#maxlength' => variable_get('file_description_length', 128),
+ '#maxlength' => $config->get('description.length'),
'#description' => t('The description may be used as the label of the link to the file.'),
);
}
diff --git a/core/modules/file/file.install b/core/modules/file/file.install
index ca6e1fdfb2c..27a243825bf 100644
--- a/core/modules/file/file.install
+++ b/core/modules/file/file.install
@@ -232,3 +232,16 @@ function file_requirements($phase) {
return $requirements;
}
+
+/**
+* Converts default_file_main variable to config.
+*
+* @ingroup config_upgrade
+*/
+function file_update_8000() {
+ update_variables_to_config('file.settings', array(
+ 'file_description_type' => 'description.type',
+ 'file_description_length'=>'description.length',
+ 'file_icon_directory'=>'icon.directory',
+ ));
+}
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index b61e52f53a1..fd2b269ad33 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -1231,7 +1231,8 @@ function file_managed_file_pre_render($element) {
* An associative array containing:
* - file: A file object to which the link will be created.
* - icon_directory: (optional) A path to a directory of icons to be used for
- * files. Defaults to the value of the "file_icon_directory" variable.
+ * files. Defaults to the value of the "icon.directory"
+ * variable.
*
* @ingroup themeable
*/
@@ -1270,7 +1271,8 @@ function theme_file_link($variables) {
* An associative array containing:
* - file: A file entity for which to make an icon.
* - icon_directory: (optional) A path to a directory of icons to be used for
- * files. Defaults to the value of the "file_icon_directory" variable.
+ * files. Defaults to the value of the "icon.directory"
+ * variable.
*
* @ingroup themeable
*/
@@ -1290,7 +1292,7 @@ function theme_file_icon($variables) {
* A file entity.
* @param $icon_directory
* (optional) A path to a directory of icons to be used for files. Defaults to
- * the value of the "file_icon_directory" variable.
+ * the value of the "icon.directory" variable.
*
* @return
* A URL string to the icon, or FALSE if an appropriate icon cannot be found.
@@ -1309,7 +1311,7 @@ function file_icon_url(File $file, $icon_directory = NULL) {
* A file entity.
* @param $icon_directory
* (optional) A path to a directory of icons to be used for files. Defaults to
- * the value of the "file_icon_directory" variable.
+ * the value of the "icon.directory" variable.
*
* @return
* A string to the icon as a local path, or FALSE if an appropriate icon could
@@ -1318,7 +1320,7 @@ function file_icon_url(File $file, $icon_directory = NULL) {
function file_icon_path(File $file, $icon_directory = NULL) {
// Use the default set of icons if none specified.
if (!isset($icon_directory)) {
- $icon_directory = variable_get('file_icon_directory', drupal_get_path('module', 'file') . '/icons');
+ $icon_directory = config('file.settings')->get('icon.directory');
}
// If there's an icon matching the exact mimetype, go for it.