Conjunto de cambios 49072ea en sipes para modules_contrib/pathauto/pathauto.admin.inc
- Fecha y hora:
- 26/05/2016 18:10:02 (hace 8 años)
- Branches:
- stable, version-3.0
- Children:
- 2efe680
- Parents:
- cd414e9
- Fichero:
-
- 1 editado
Leyenda
- No modificado
- Añadido
- Eliminado
-
modules_contrib/pathauto/pathauto.admin.inc
r177a560 r49072ea 1 1 <?php 2 // $Id: pathauto.admin.inc,v 1.10.2.7 2010/08/10 03:24:00 davereid Exp $3 2 4 3 /** … … 10 9 11 10 /** 12 * Form builder; Configure the Pathauto system.11 * Form builder; Configure the URL alias patterns. 13 12 * 14 13 * @ingroup forms 15 14 * @see system_settings_form() 16 15 */ 17 function pathauto_admin_settings() { 18 _pathauto_include(); 19 20 // Generate the form - settings applying to all patterns first 21 $form['general'] = array( 22 '#type' => 'fieldset', 23 '#weight' => -20, 24 '#title' => t('General settings'), 25 '#collapsible' => TRUE, 26 '#collapsed' => TRUE, 27 ); 28 29 $form['general']['pathauto_verbose'] = array( 30 '#type' => 'checkbox', 31 '#title' => t('Verbose'), 32 '#default_value' => variable_get('pathauto_verbose', FALSE), 33 '#description' => t('Display alias changes (except during bulk updates).'), 34 ); 35 36 $form['general']['pathauto_separator'] = array( 37 '#type' => 'textfield', 38 '#title' => t('Separator'), 39 '#size' => 1, 40 '#maxlength' => 1, 41 '#default_value' => variable_get('pathauto_separator', '-'), 42 '#description' => t('Character used to separate words in titles. This will replace any spaces and punctuation characters. Using a space or + character can cause unexpected results.'), 43 ); 44 45 $form['general']['pathauto_case'] = array( 46 '#type' => 'radios', 47 '#title' => t('Character case'), 48 '#default_value' => variable_get('pathauto_case', 1), 49 '#options' => array(t('Leave case the same as source token values.'), t('Change to lower case')), 50 ); 51 52 $max_length = _pathauto_get_schema_alias_maxlength(); 53 54 $form['general']['pathauto_max_length'] = array( 55 '#type' => 'textfield', 56 '#title' => t('Maximum alias length'), 57 '#size' => 3, 58 '#maxlength' => 3, 59 '#default_value' => variable_get('pathauto_max_length', 100), 60 '#min_value' => 1, 61 '#max_value' => $max_length, 62 '#description' => t('Maximum length of aliases to generate. 100 is recommended. See <a href="@pathauto-help">Pathauto help</a> for details.', array('@pathauto-help' => url('admin/help/pathauto'))), 63 '#element_validate' => array('_pathauto_validate_numeric_element'), 64 ); 65 66 $form['general']['pathauto_max_component_length'] = array( 67 '#type' => 'textfield', 68 '#title' => t('Maximum component length'), 69 '#size' => 3, 70 '#maxlength' => 3, 71 '#default_value' => variable_get('pathauto_max_component_length', 100), 72 '#min_value' => 1, 73 '#max_value' => $max_length, 74 '#description' => t('Maximum text length of any component in the alias (e.g., [title]). 100 is recommended. See <a href="@pathauto-help">Pathauto help</a> for details.', array('@pathauto-help' => url('admin/help/pathauto'))), 75 '#element_validate' => array('_pathauto_validate_numeric_element'), 76 ); 77 78 $form['general']['pathauto_max_bulk_update'] = array( 79 '#type' => 'textfield', 80 '#title' => t('Maximum number of objects to alias in a bulk update'), 81 '#size' => 4, 82 '#maxlength' => 4, 83 '#default_value' => variable_get('pathauto_max_bulk_update', 50), 84 '#min_value' => 0, 85 '#description' => t('Maximum number of objects of a given type which should be aliased during a bulk update. The default is 50 and the recommended number depends on the speed of your server. If bulk updates "time out" or result in a "white screen" then reduce the number.'), 86 '#element_validate' => array('_pathauto_validate_numeric_element'), 87 ); 88 89 $actions = array( 90 t('Do nothing. Leave the old alias intact.'), 91 t('Create a new alias. Leave the existing alias functioning.'), 92 t('Create a new alias. Delete the old alias.')); 93 94 if (function_exists('path_redirect_save')) { 95 $actions[] = t('Create a new alias. Redirect from old alias.'); 96 } 97 elseif (variable_get('pathauto_update_action', 2) == 3) { 98 // the redirect action is selected, but path_redirect is not enabled 99 // let's set the variable back to the default 100 variable_set('pathauto_update_action', 2); 101 } 102 103 $form['general']['pathauto_update_action'] = array( 104 '#type' => 'radios', 105 '#title' => t('Update action'), 106 '#default_value' => variable_get('pathauto_update_action', 2), 107 '#options' => $actions, 108 '#description' => t('What should pathauto do when updating an existing content item which already has an alias?'), 109 ); 110 111 $form['general']['pathauto_transliterate'] = array( 112 '#type' => 'checkbox', 113 '#title' => t('Transliterate prior to creating alias'), 114 '#default_value' => variable_get('pathauto_transliterate', FALSE), 115 '#description' => t('When a pattern includes certain characters (such as those with accents) should Pathauto attempt to transliterate them into the ASCII-96 alphabet?'), 116 '#disabled' => !_pathauto_get_i18n_file(), 117 ); 118 $i18n_locations = _pathauto_get_i18n_possible_files(); 119 foreach ($i18n_locations as $key => $file) { 120 $i18n_locations[$key] = check_plain($file); 121 if (file_exists($file)) { 122 $i18n_locations[$key] .= ' - <span class="admin-enabled">' . t('File exists') . '</span>'; 123 } 124 else { 125 $i18n_locations[$key] .= ' - <span class="admin-disabled">' . t('Does not exist') . '</span>'; 126 } 127 } 128 $form['general']['pathauto_transliterate']['#description'] .= ' ' . t('Transliteration is determined by the i18n-ascii.txt file in the following possible locations, in order of precedence: !locations', array('!locations' => theme('item_list', $i18n_locations))); 129 if ($form['general']['pathauto_transliterate']['#disabled']) { 130 // Perhaps they've removed the file, set the transliterate option to FALSE 131 variable_set('pathauto_transliterate', FALSE); 132 } 133 134 $form['general']['pathauto_reduce_ascii'] = array( 135 '#type' => 'checkbox', 136 '#title' => t('Reduce strings to letters and numbers from ASCII-96'), 137 '#default_value' => variable_get('pathauto_reduce_ascii', FALSE), 138 '#description' => t('Filters the new alias to only letters and numbers found in the ASCII-96 set.'), 139 ); 140 141 // Default words to ignore 142 $ignore_words = array( 143 'a', 'an', 'as', 'at', 'before', 'but', 'by', 'for', 'from', 'is', 'in', 144 'into', 'like', 'of', 'off', 'on', 'onto', 'per', 'since', 'than', 'the', 145 'this', 'that', 'to', 'up', 'via', 'with', 146 ); 147 $form['general']['pathauto_ignore_words'] = array( 148 '#type' => 'textarea', 149 '#title' => t('Strings to Remove'), 150 '#default_value' => variable_get('pathauto_ignore_words', implode(',', $ignore_words)), 151 '#description' => t('Words to strip out of the URL alias, separated by commas. Do not place punctuation in here and do not use WYSIWYG editors on this field.'), 152 '#wysiwyg' => FALSE, 153 ); 154 155 $form['punctuation'] = array( 156 '#type' => 'fieldset', 157 '#weight' => -10, 158 '#title' => t('Punctuation settings'), '#collapsible' => TRUE, 159 '#collapsed' => TRUE, 160 ); 161 162 $punctuation = pathauto_punctuation_chars(); 163 foreach ($punctuation as $name => $details) { 164 $details['default'] = 0; 165 if ($details['value'] == variable_get('pathauto_separator', '-')) { 166 $details['default'] = 1; 167 } 168 $form['punctuation']['pathauto_punctuation_'. $name] = array( 169 '#type' => 'select', 170 '#title' => $details['name'], 171 '#default_value' => variable_get('pathauto_punctuation_'. $name, $details['default']), 172 '#options' => array( 173 '0' => t('Remove'), 174 '1' => t('Replace by separator'), 175 '2' => t('No action (do not replace)'), 176 ), 177 ); 178 } 16 function pathauto_patterns_form($form_state) { 17 module_load_include('inc', 'pathauto', 'pathauto.pathauto'); 179 18 180 19 // Call the hook on all modules - an array of 'settings' objects is returned … … 185 24 $patterndefault = $settings->patterndefault; 186 25 $groupheader = $settings->groupheader; 187 $supportsfeeds = isset($settings->supportsfeeds) ? $settings->supportsfeeds : NULL;188 variable_set('pathauto_' . $module . '_supportsfeeds', $supportsfeeds);189 26 190 27 $form[$module] = array( … … 192 29 '#title' => $groupheader, 193 30 '#collapsible' => TRUE, 194 '#collapsed' => TRUE,31 '#collapsed' => FALSE, 195 32 ); 196 33 … … 206 43 '#after_build' => array('_pathauto_validate_pattern_element'), 207 44 '#token_types' => array($settings->token_type), 45 '#min_tokens' => 1, 208 46 '#parents' => array($variable), 209 47 ); … … 223 61 '#after_build' => array('_pathauto_validate_pattern_element'), 224 62 '#token_types' => array($settings->token_type), 63 '#min_tokens' => 1, 225 64 '#parents' => array($variable), 226 65 ); … … 237 76 '#description' => t('Use -raw replacements for text to avoid problems with HTML entities.'), 238 77 ); 239 240 // Use the token tree if available.241 $doc = theme('token_tree', array($settings->token_type), FALSE);242 if (empty($doc)) {243 $doc = "<dl>\n";244 foreach ($settings->placeholders as $name => $description) {245 $doc .= '<dt>'. $name .'</dt>';246 $doc .= '<dd>'. $description .'</dd>';247 }248 $doc .= "</dl>\n";249 }250 78 $form[$module]['token_help']['help'] = array( 251 79 '#type' => 'markup', 252 '#value' => $doc, 253 ); 254 255 // If the module supports bulk updates, offer the update action here 256 if ($settings->bulkname) { 257 $variable = 'pathauto_' . $module . '_bulkupdate'; 258 if (variable_get($variable, FALSE)) { 259 variable_set($variable, FALSE); 260 $function = $module . '_pathauto_bulkupdate'; 261 call_user_func($function); 262 } 263 $form[$module][$variable] = array( 264 '#type' => 'checkbox', 265 '#title' => $settings->bulkname, 266 '#default_value' => FALSE, 267 '#description' => $settings->bulkdescr, 268 ); 269 } 270 271 // If the module supports feeds, offer to generate aliases for them 272 if ($supportsfeeds) { 273 $variable = 'pathauto_' . $module . '_applytofeeds'; 274 $current = variable_get($variable, $supportsfeeds); 275 // This checks for the old style from 2.0 and earlier. TODO: At some point we can drop that. 276 if (is_numeric($current)) { 277 $current = $supportsfeeds; 278 } 279 280 $form[$module][$variable] = array( 281 '#type' => 'textfield', 282 '#title' => t('Internal feed alias text (leave blank to disable)'), 283 '#size' => 65, 284 '#maxlength' => 1280, 285 '#default_value' => $current, 286 '#description' => t('The text to use for aliases for RSS feeds. Examples are "0/feed" (used throughout Drupal core) and "feed" (used by some contributed Drupal modules, like Views).'), 287 ); 288 } 289 } 290 291 if (isset($do_index_bulkupdate) && $do_index_bulkupdate) { 292 drupal_set_message(format_plural($indexcount, 293 'Bulk generation of index aliases completed, one alias generated.', 294 'Bulk generation of index aliases completed, @count aliases generated.')); 80 '#value' => theme('token_tree', array($settings->token_type)), 81 ); 82 } 83 84 return system_settings_form($form); 85 } 86 87 /** 88 * Form builder; Configure the Pathauto settings. 89 * 90 * @ingroup forms 91 * @see system_settings_form() 92 */ 93 function pathauto_settings_form() { 94 module_load_include('inc', 'pathauto'); 95 96 $form['pathauto_verbose'] = array( 97 '#type' => 'checkbox', 98 '#title' => t('Verbose'), 99 '#default_value' => variable_get('pathauto_verbose', FALSE), 100 '#description' => t('Display alias changes (except during bulk updates).'), 101 ); 102 103 $form['pathauto_separator'] = array( 104 '#type' => 'textfield', 105 '#title' => t('Separator'), 106 '#size' => 1, 107 '#maxlength' => 1, 108 '#default_value' => variable_get('pathauto_separator', '-'), 109 '#description' => t('Character used to separate words in titles. This will replace any spaces and punctuation characters. Using a space or + character can cause unexpected results.'), 110 ); 111 112 $form['pathauto_case'] = array( 113 '#type' => 'radios', 114 '#title' => t('Character case'), 115 '#default_value' => variable_get('pathauto_case', PATHAUTO_CASE_LOWER), 116 '#options' => array( 117 PATHAUTO_CASE_LEAVE_ASIS => t('Leave case the same as source token values.'), 118 PATHAUTO_CASE_LOWER => t('Change to lower case'), 119 ), 120 ); 121 122 $max_length = _pathauto_get_schema_alias_maxlength(); 123 124 $form['pathauto_max_length'] = array( 125 '#type' => 'textfield', 126 '#title' => t('Maximum alias length'), 127 '#size' => 3, 128 '#maxlength' => 3, 129 '#default_value' => variable_get('pathauto_max_length', 100), 130 '#min_value' => 1, 131 '#max_value' => $max_length, 132 '#description' => t('Maximum length of aliases to generate. 100 is the recommended length. @max is the maximum possible length. See <a href="@pathauto-help">Pathauto help</a> for details.', array('@pathauto-help' => url('admin/help/pathauto'), '@max' => $max_length)), 133 '#element_validate' => array('_pathauto_validate_numeric_element'), 134 ); 135 $form['pathauto_max_component_length'] = array( 136 '#type' => 'textfield', 137 '#title' => t('Maximum component length'), 138 '#size' => 3, 139 '#maxlength' => 3, 140 '#default_value' => variable_get('pathauto_max_component_length', 100), 141 '#min_value' => 1, 142 '#max_value' => $max_length, 143 '#description' => t('Maximum text length of any component in the alias (e.g., [title]). 100 is the recommended length. @max is the maximum possible length. See <a href="@pathauto-help">Pathauto help</a> for details.', array('@pathauto-help' => url('admin/help/pathauto'), '@max' => $max_length)), 144 '#element_validate' => array('_pathauto_validate_numeric_element'), 145 ); 146 147 $form['pathauto_update_action'] = array( 148 '#type' => 'radios', 149 '#title' => t('Update action'), 150 '#default_value' => variable_get('pathauto_update_action', PATHAUTO_UPDATE_ACTION_DELETE), 151 '#options' => array( 152 PATHAUTO_UPDATE_ACTION_NO_NEW => t('Do nothing. Leave the old alias intact.'), 153 PATHAUTO_UPDATE_ACTION_LEAVE => t('Create a new alias. Leave the existing alias functioning.'), 154 PATHAUTO_UPDATE_ACTION_DELETE => t('Create a new alias. Delete the old alias.'), 155 PATHAUTO_UPDATE_ACTION_REDIRECT => t('Create a new alias. Redirect from old alias.'), 156 ), 157 '#description' => t('What should Pathauto do when updating an existing content item which already has an alias?'), 158 ); 159 if (!module_exists('path_redirect')) { 160 // Remove the redirection option if Path redirect is not enabled. 161 unset($form['pathauto_update_action']['#options'][PATHAUTO_UPDATE_ACTION_REDIRECT]); 162 if (variable_get('pathauto_update_action', NULL) == PATHAUTO_UPDATE_ACTION_REDIRECT) { 163 // Fix the current update action variable as well. 164 variable_set('pathauto_update_action', PATHAUTO_UPDATE_ACTION_DELETE); 165 } 166 } 167 168 $form['pathauto_transliterate'] = array( 169 '#type' => 'checkbox', 170 '#title' => t('Transliterate prior to creating alias'), 171 '#default_value' => variable_get('pathauto_transliterate', FALSE), 172 '#description' => t('When a pattern includes certain characters (such as those with accents) should Pathauto attempt to transliterate them into the US-ASCII alphabet? Transliteration is handled by the Transliteration module.'), 173 ); 174 if (!module_exists('transliteration')) { 175 // Remove the redirection option if Transliteration is not enabled. 176 $form['pathauto_transliterate']['#access'] = FALSE; 177 variable_set('pathauto_transliterate', FALSE); 178 } 179 180 $form['pathauto_reduce_ascii'] = array( 181 '#type' => 'checkbox', 182 '#title' => t('Reduce strings to letters and numbers'), 183 '#default_value' => variable_get('pathauto_reduce_ascii', FALSE), 184 '#description' => t('Filters the new alias to only letters and numbers found in the ASCII-96 set.'), 185 ); 186 187 $form['pathauto_ignore_words'] = array( 188 '#type' => 'textarea', 189 '#title' => t('Strings to Remove'), 190 '#default_value' => variable_get('pathauto_ignore_words', PATHAUTO_IGNORE_WORDS), 191 '#description' => t('Words to strip out of the URL alias, separated by commas. Do not use this to remove punctuation.'), 192 '#wysiwyg' => FALSE, 193 ); 194 195 $form['punctuation'] = array( 196 '#type' => 'fieldset', 197 '#title' => t('Punctuation'), 198 '#collapsible' => TRUE, 199 '#collapsed' => TRUE, 200 ); 201 202 $punctuation = pathauto_punctuation_chars(); 203 foreach ($punctuation as $name => $details) { 204 $details['default'] = PATHAUTO_PUNCTUATION_REMOVE; 205 if ($details['value'] == variable_get('pathauto_separator', '-')) { 206 $details['default'] = PATHAUTO_PUNCTUATION_REPLACE; 207 } 208 $form['punctuation']['pathauto_punctuation_' . $name] = array( 209 '#type' => 'select', 210 '#title' => $details['name'] . ' (<code>' . check_plain($details['value']) . '</code>)', 211 '#default_value' => variable_get('pathauto_punctuation_' . $name, $details['default']), 212 '#options' => array( 213 PATHAUTO_PUNCTUATION_REMOVE => t('Remove'), 214 PATHAUTO_PUNCTUATION_REPLACE => t('Replace by separator'), 215 PATHAUTO_PUNCTUATION_DO_NOTHING => t('No action (do not replace)'), 216 ), 217 ); 295 218 } 296 219 … … 317 240 318 241 // Check to see if the required token functions are available. 319 if (!function_exists('token_scan') || !function_exists('token_element_validate _token_context')) {320 drupal_set_message(t('Please make sure you are using the latest version of the Token module.'), ' warning', FALSE);242 if (!function_exists('token_scan') || !function_exists('token_element_validate')) { 243 drupal_set_message(t('Please make sure you are using the latest version of the Token module.'), 'error', FALSE); 321 244 return $element; 322 245 } 323 246 324 // Check for at least one token. 325 $tokens = token_scan($value); 326 if (empty($tokens)) { 327 form_error($element, t('The %name should contain at least one token to ensure unique URL aliases are created.', array('%name' => $element['#title']))); 328 } 329 else { 330 token_element_validate_token_context($element, $form_state); 331 } 247 // Run token validation. 248 $element = token_element_validate($element, $form_state); 332 249 333 250 // Find any non-raw tokens that do have a raw companion token and warn. 334 module_load_include('inc', 'pathauto'); 335 $not_raw_tokens = array(); 336 $raw_tokens = _pathauto_get_raw_tokens(); 337 foreach ($tokens as $token) { 338 if (substr($token, -4) === '-raw') { 339 // Skip raw tokens. 340 continue; 341 } 342 elseif (in_array($token . '-raw', $raw_tokens)) { 343 drupal_set_message(t('You are using the token [%token] which has a raw companion token [%raw_token]. For Pathauto patterns you should use the -raw version of tokens unless you really know what you are doing. See the <a href="@pathauto-help">Pathauto help</a> for more details.', array('%token' => $token, '%raw_token' => $token . '-raw', '@pathauto-help' => url('admin/help/pathauto'))), 'error', FALSE); 251 if (!form_get_errors($element)) { 252 // Skip if there are already errors on this field. 253 module_load_include('inc', 'pathauto'); 254 $not_raw_tokens = array(); 255 $raw_tokens = _pathauto_get_raw_tokens(); 256 foreach (token_scan($value) as $token) { 257 if (substr($token, -4) === '-raw') { 258 // Skip raw tokens. 259 continue; 260 } 261 elseif (in_array($token . '-raw', $raw_tokens)) { 262 drupal_set_message(t('You are using the token [%token] which has a raw companion token [%raw_token]. For Pathauto patterns you should use the -raw version of tokens unless you really know what you are doing. See the <a href="@pathauto-help">Pathauto help</a> for more details.', array('%token' => $token, '%raw_token' => $token . '-raw', '@pathauto-help' => url('admin/help/pathauto'))), 'error', FALSE); 263 } 344 264 } 345 265 } … … 366 286 367 287 /** 368 * Validate pathauto_ admin_settingsform submissions.369 */ 370 function pathauto_ admin_settings_validate($form, &$form_state) {288 * Validate pathauto_settings_form form submissions. 289 */ 290 function pathauto_settings_form_validate($form, &$form_state) { 371 291 module_load_include('inc', 'pathauto'); 372 292 … … 383 303 if ($details['value'] == $separator) { 384 304 $action = $form_state['values']['pathauto_punctuation_' . $name]; 385 if ($action == 0) { 386 drupal_set_message(t('You have configured the @name to be the separator and to be removed when encountered in strings. This can cause problems with your patterns and especially with the catpath and termpath patterns. You should probably set the action for @name to be "replace by separator"', array('@name' => $details['name'])), 'error'); 387 } 388 } 305 if ($action == PATHAUTO_PUNCTUATION_REMOVE) { 306 drupal_set_message(t('You have configured the @name to be the separator and to be removed when encountered in strings. This can cause problems with your patterns and especially with the catpath and termpath patterns. You should probably set the action for @name to be "replace by separator".', array('@name' => $details['name'])), 'error'); 307 } 308 } 309 } 310 } 311 312 /** 313 * Form contructor for path alias bulk update form. 314 * 315 * @see pathauto_bulk_update_form_submit() 316 * @ingroup forms 317 */ 318 function pathauto_bulk_update_form() { 319 $form['#update_callbacks'] = array(); 320 321 $form['update'] = array( 322 '#type' => 'checkboxes', 323 '#title' => t('Select the types of un-aliased paths for which to generate URL aliases'), 324 '#options' => array(), 325 '#default_value' => array(), 326 ); 327 328 $pathauto_settings = module_invoke_all('pathauto', 'settings'); 329 foreach ($pathauto_settings as $settings) { 330 if (!empty($settings->batch_update_callback)) { 331 $form['#update_callbacks'][$settings->batch_update_callback] = $settings; 332 $form['update']['#options'][$settings->batch_update_callback] = $settings->groupheader; 333 } 334 } 335 336 $form['actions']['#weight'] = 100; 337 $form['actions']['submit'] = array( 338 '#type' => 'submit', 339 '#value' => t('Update'), 340 ); 341 342 return $form; 343 } 344 345 /** 346 * Form submit handler for path alias bulk update form. 347 * 348 * @see pathauto_batch_update_form() 349 * @see pathauto_bulk_update_batch_finished() 350 */ 351 function pathauto_bulk_update_form_submit($form, &$form_state) { 352 $batch = array( 353 'title' => t('Bulk updating URL aliases'), 354 'operations' => array( 355 array('pathauto_bulk_update_batch_start', array()), 356 ), 357 'finished' => 'pathauto_bulk_update_batch_finished', 358 'file' => drupal_get_path('module', 'pathauto') . '/pathauto.admin.inc', 359 ); 360 361 foreach ($form_state['values']['update'] as $callback) { 362 if (!empty($callback)) { 363 $settings = $form['#update_callbacks'][$callback]; 364 if (!empty($settings->batch_file)) { 365 $batch['operations'][] = array('pathauto_bulk_update_batch_process', array($callback, $settings)); 366 } 367 else { 368 $batch['operations'][] = array($callback, array()); 369 } 370 } 371 } 372 373 batch_set($batch); 374 } 375 376 /** 377 * Batch callback; count the current number of URL aliases for comparison later. 378 */ 379 function pathauto_bulk_update_batch_start(&$context) { 380 $context['results']['count_before'] = db_result(db_query("SELECT COUNT(*) FROM {url_alias}")); 381 } 382 383 /** 384 * Common batch processing callback for all operations. 385 * 386 * Required to load our include the proper batch file. 387 */ 388 function pathauto_bulk_update_batch_process($callback, $settings, &$context) { 389 if (!empty($settings->batch_file)) { 390 require_once './' . $settings->batch_file; 391 } 392 return $callback($context); 393 } 394 395 /** 396 * Batch finished callback. 397 */ 398 function pathauto_bulk_update_batch_finished($success, $results, $operations) { 399 if ($success) { 400 // Count the current number of URL aliases after the batch is completed 401 // and compare to the count before the batch started. 402 $results['count_after'] = db_result(db_query("SELECT COUNT(*) FROM {url_alias}")); 403 $results['count_changed'] = max($results['count_after'] - $results['count_before'], 0); 404 if ($results['count_changed']) { 405 drupal_set_message(format_plural($results['count_changed'], 'Generated 1 URL alias.', 'Generated @count URL aliases.')); 406 } 407 else { 408 drupal_set_message(t('No new URL aliases to generate.')); 409 } 410 } 411 else { 412 $error_operation = reset($operations); 413 drupal_set_message(t('An error occurred while processing @operation with arguments : @args', array('@operation' => $error_operation[0], '@args' => print_r($error_operation[0], TRUE)))); 389 414 } 390 415 }
Nota: Vea TracChangeset
para ayuda en el uso del visor de conjuntos de cambios.