? .project
Index: modules/image/image.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/image/image.admin.inc,v
retrieving revision 1.14
diff -u -p -r1.14 image.admin.inc
--- modules/image/image.admin.inc 16 Oct 2009 00:52:46 -0000 1.14
+++ modules/image/image.admin.inc 26 Oct 2009 21:33:28 -0000
@@ -36,7 +36,7 @@ function image_style_list() {
* @see image_style_name_validate()
*/
function image_style_form($form, &$form_state, $style) {
- $title = t('Edit %name style', array('%name' => $style['name']));
+ $title = t('Edit style %name', array('%name' => $style['name']));
drupal_set_title($title, PASS_THROUGH);
// Adjust this form for styles that must be overridden to edit.
@@ -46,6 +46,21 @@ function image_style_form($form, &$form_
drupal_set_message(t('This image style is currently being provided by a module. Click the "Override defaults" button to change its settings.'), 'warning');
}
+ // Build settings for machine readable name generation.
+ $js_settings = array(
+ 'type' => 'setting',
+ 'data' => array(
+ 'machineReadableValue' => array(
+ 'label' => array(
+ 'text' => t('Machine name'),
+ 'target' => 'name',
+ 'searchPattern' => '[^a-z0-9\\-_]+',
+ 'replaceToken' => '_',
+ ),
+ ),
+ ),
+ );
+
$form_state['image_style'] = $style;
$form['#tree'] = TRUE;
$form['#attached']['css'][drupal_get_path('module', 'image') . '/image.admin.css'] = array('preprocess' => FALSE);
@@ -62,7 +77,7 @@ function image_style_form($form, &$form_
if ($style['storage'] & IMAGE_STORAGE_MODULE) {
$form['name'] = array(
'#type' => 'item',
- '#title' => t('Image style name'),
+ '#title' => t('Image style machine readable name'),
'#markup' => $style['name'],
'#description' => t('This image style is being provided by %module module and may not be renamed.', array('%module' => $style['module'])),
);
@@ -71,11 +86,34 @@ function image_style_form($form, &$form_
$form['name'] = array(
'#type' => 'textfield',
'#size' => '64',
- '#title' => t('Image style name'),
+ '#title' => t('Image style machine readable name'),
'#default_value' => $style['name'],
- '#description' => t('The name is used in URLs for generated images. Use only lowercase alphanumeric characters, underscores (_), and hyphens (-).'),
+ '#description' => t('The machine readable name is used in URLs for generated images. Use only lowercase alphanumeric characters, underscores (_), and hyphens (-).'),
'#element_validate' => array('image_style_name_validate'),
'#required' => TRUE,
+ '#attached' => array(
+ 'js' => array(drupal_get_path('module', 'system') . '/system.js', $js_settings),
+ ),
+ );
+ }
+ // Allow the real name of the style to be changed, but only if this style is
+ // editable (overridden default style or custom style).
+ if ($editable) {
+ $form['label'] = array(
+ '#type' => 'textfield',
+ '#size' => 64,
+ '#title' => t('Image style display name'),
+ '#default_value' => $style['label'],
+ '#description' => t('Enter the display name for this preset. This name is used in listings of image styles.'),
+ '#field_suffix' => ' ',
+ );
+ }
+ else {
+ $form['label'] = array(
+ '#type' => 'item',
+ '#title' => t('Image style display name'),
+ '#markup' => $style['label'],
+ '#description' => t('This image style is being provided by %module module and may not be renamed.', array('%module' => $style['module'])),
);
}
@@ -197,6 +235,9 @@ function image_style_form_submit($form,
if (isset($form_state['values']['name']) && $style['name'] != $form_state['values']['name']) {
$style['name'] = $form_state['values']['name'];
}
+ if (isset($form_state['values']['label']) && $style['label'] != $form_state['values']['label']) {
+ $style['label'] = $form_state['values']['label'];
+ }
// Update image effect weights.
if (!empty($form_state['values']['effects'])) {
@@ -224,14 +265,40 @@ function image_style_form_submit($form,
* @see image_style_name_validate()
*/
function image_style_add_form($form, &$form_state) {
+ // Build settings for machine readable name generation.
+ $js_settings = array(
+ 'type' => 'setting',
+ 'data' => array(
+ 'machineReadableValue' => array(
+ 'label' => array(
+ 'text' => t('Machine readable name'),
+ 'target' => 'name',
+ 'searchPattern' => '[^a-z0-9\\-_]+',
+ 'replaceToken' => '_',
+ ),
+ ),
+ ),
+ );
+
$form['name'] = array(
'#type' => 'textfield',
'#size' => '64',
- '#title' => t('Style name'),
+ '#title' => t('Image style machine readable name'),
'#default_value' => '',
'#description' => t('The name is used in URLs for generated images. Use only lowercase alphanumeric characters, underscores (_), and hyphens (-).'),
'#element_validate' => array('image_style_name_validate'),
'#required' => TRUE,
+ '#attached' => array(
+ 'js' => array(drupal_get_path('module', 'system') . '/system.js', $js_settings),
+ ),
+ );
+ $form['label'] = array(
+ '#type' => 'textfield',
+ '#size' => 64,
+ '#title' => t('Image style display name'),
+ '#default_value' => '',
+ '#description' => t('Enter the display name for this preset. This name is used in listings of image styles.'),
+ '#field_suffix' => ' ',
);
$form['submit'] = array(
@@ -246,7 +313,10 @@ function image_style_add_form($form, &$f
* Submit handler for adding a new image style.
*/
function image_style_add_form_submit($form, &$form_state) {
- $style = array('name' => $form_state['values']['name']);
+ $style = array(
+ 'name' => $form_state['values']['name'],
+ 'label' => $form_state['values']['label'],
+ );
$style = image_style_save($style);
drupal_set_message(t('Style %name was created.', array('%name' => $style['name'])));
$form_state['redirect'] = 'admin/config/media/image-styles/edit/' . $style['name'];
@@ -633,7 +703,7 @@ function theme_image_style_list($variabl
$rows = array();
foreach ($styles as $style) {
$row = array();
- $row[] = l($style['name'], 'admin/config/media/image-styles/edit/' . $style['name']);
+ $row[] = l($style['label'], 'admin/config/media/image-styles/edit/' . $style['name']);
$link_attributes = array(
'attributes' => array(
'class' => array('image-style-link'),
Index: modules/image/image.field.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/image/image.field.inc,v
retrieving revision 1.2
diff -u -p -r1.2 image.field.inc
--- modules/image/image.field.inc 17 Oct 2009 02:14:52 -0000 1.2
+++ modules/image/image.field.inc 26 Oct 2009 21:33:29 -0000
@@ -431,17 +431,17 @@ function image_field_formatter_info() {
foreach (image_styles() as $style) {
$formatters['image__' . $style['name']] = array(
- 'label' => t('Image "@style"', array('@style' => $style['name'])),
+ 'label' => t('Image "@style"', array('@style' => $style['label'])),
'field types' => array('image'),
'theme' => array('function' => 'theme_field_formatter_image'),
);
$formatters['image_link_content__' . $style['name']] = array(
- 'label' => t('Image "@style" linked to content', array('@style' => $style['name'])),
+ 'label' => t('Image "@style" linked to content', array('@style' => $style['label'])),
'field types' => array('image'),
'theme' => array('function' => 'theme_field_formatter_image_link_content'),
);
$formatters['image_link_file__' . $style['name']] = array(
- 'label' => t('Image "@style" linked to file', array('@style' => $style['name'])),
+ 'label' => t('Image "@style" linked to file', array('@style' => $style['label'])),
'field types' => array('image'),
'theme' => array('function' => 'theme_field_formatter_image_link_file'),
);
Index: modules/image/image.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/image/image.install,v
retrieving revision 1.3
diff -u -p -r1.3 image.install
--- modules/image/image.install 10 Sep 2009 06:38:18 -0000 1.3
+++ modules/image/image.install 26 Oct 2009 21:33:29 -0000
@@ -43,11 +43,18 @@ function image_schema() {
'not null' => TRUE,
),
'name' => array(
- 'description' => 'The style name.',
+ 'description' => 'The styles machine readable name.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
+ 'label' => array(
+ 'description' => 'The style name.',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => FALSE,
+ 'default' => '',
+ ),
),
'primary key' => array('isid'),
'indexes' => array(
Index: modules/image/image.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/image/image.module,v
retrieving revision 1.24
diff -u -p -r1.24 image.module
--- modules/image/image.module 23 Oct 2009 22:24:15 -0000 1.24
+++ modules/image/image.module 26 Oct 2009 21:33:31 -0000
@@ -323,6 +323,7 @@ function image_image_default_styles() {
$styles = array();
$styles['thumbnail'] = array(
+ 'label' => 'Thumbnail (100x100)',
'effects' => array(
array(
'name' => 'image_scale',
@@ -333,6 +334,7 @@ function image_image_default_styles() {
);
$styles['medium'] = array(
+ 'label' => 'Medium (220x220)',
'effects' => array(
array(
'name' => 'image_scale',
@@ -343,6 +345,7 @@ function image_image_default_styles() {
);
$styles['large'] = array(
+ 'label' => 'Large (640x640)',
'effects' => array(
array(
'name' => 'image_scale',
@@ -394,6 +397,7 @@ function image_styles() {
$module_styles = module_invoke($module, 'image_default_styles');
foreach ($module_styles as $style_name => $style) {
$style['name'] = $style_name;
+ $style['label'] = ($style['label'] == '') ? $style['name'] : $style['label'];
$style['module'] = $module;
$style['storage'] = IMAGE_STORAGE_DEFAULT;
foreach ($style['effects'] as $ieid => $effect) {
@@ -409,12 +413,14 @@ function image_styles() {
// Select all the user-defined styles.
$user_styles = db_select('image_styles', NULL, array('fetch' => PDO::FETCH_ASSOC))
->fields('image_styles')
+ ->orderBy('label')
->orderBy('name')
->execute()
->fetchAllAssoc('name', PDO::FETCH_ASSOC);
// Allow the user styles to override the module styles.
foreach ($user_styles as $style_name => $style) {
+ $style['label'] = ($style['label'] == '') ? $style['name'] : $style['label'];
$style['module'] = NULL;
$style['storage'] = IMAGE_STORAGE_NORMAL;
$style['effects'] = image_style_effects($style);
@@ -468,6 +474,11 @@ function image_style_load($name = NULL,
}
}
+ if (isset($style)) {
+ if ($style['label'] == '') {
+ $style['label'] = $style['name'];
+ }
+ }
// Restrict to the specific type of flag. This bitwise operation basically
// states "if the storage is X, then allow".
if (isset($style) && (!isset($include) || ($style['storage'] & (int) $include))) {
@@ -571,7 +582,9 @@ function image_style_options($include_em
if ($include_empty && !empty($styles)) {
$options[''] = t('');
}
- $options = array_merge($options, drupal_map_assoc(array_keys($styles)));
+ foreach ($styles as $name => $style) {
+ $options[$name] = $style['label'];
+ }
if (empty($options)) {
$options[''] = t('No defined styles');
}