@@ -9,19 +9,19 @@ discard block |
||
| 9 | 9 | * Implementation of hook_menu(). |
| 10 | 10 | */ |
| 11 | 11 | function wysiwyg_menu() { |
| 12 | - $items['admin/settings/wysiwyg'] = array( |
|
| 12 | + $items['admin/settings/wysiwyg'] = array( |
|
| 13 | 13 | 'title' => 'Wysiwyg profiles', |
| 14 | 14 | 'page callback' => 'drupal_get_form', |
| 15 | 15 | 'page arguments' => array('wysiwyg_profile_overview'), |
| 16 | 16 | 'description' => 'Configure client-side editors.', |
| 17 | 17 | 'access arguments' => array('administer filters'), |
| 18 | 18 | 'file' => 'wysiwyg.admin.inc', |
| 19 | - ); |
|
| 20 | - $items['admin/settings/wysiwyg/profile'] = array( |
|
| 19 | + ); |
|
| 20 | + $items['admin/settings/wysiwyg/profile'] = array( |
|
| 21 | 21 | 'title' => 'List', |
| 22 | 22 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
| 23 | - ); |
|
| 24 | - $items['admin/settings/wysiwyg/profile/%wysiwyg_profile/edit'] = array( |
|
| 23 | + ); |
|
| 24 | + $items['admin/settings/wysiwyg/profile/%wysiwyg_profile/edit'] = array( |
|
| 25 | 25 | 'title' => 'Edit', |
| 26 | 26 | 'page callback' => 'drupal_get_form', |
| 27 | 27 | 'page arguments' => array('wysiwyg_profile_form', 4), |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | 'tab_root' => 'admin/settings/wysiwyg/profile', |
| 31 | 31 | 'tab_parent' => 'admin/settings/wysiwyg/profile/%wysiwyg_profile', |
| 32 | 32 | 'type' => MENU_LOCAL_TASK, |
| 33 | - ); |
|
| 34 | - $items['admin/settings/wysiwyg/profile/%wysiwyg_profile/delete'] = array( |
|
| 33 | + ); |
|
| 34 | + $items['admin/settings/wysiwyg/profile/%wysiwyg_profile/delete'] = array( |
|
| 35 | 35 | 'title' => 'Remove', |
| 36 | 36 | 'page callback' => 'drupal_get_form', |
| 37 | 37 | 'page arguments' => array('wysiwyg_profile_delete_confirm', 4), |
@@ -41,15 +41,15 @@ discard block |
||
| 41 | 41 | 'tab_parent' => 'admin/settings/wysiwyg/profile/%wysiwyg_profile', |
| 42 | 42 | 'type' => MENU_LOCAL_TASK, |
| 43 | 43 | 'weight' => 10, |
| 44 | - ); |
|
| 45 | - $items['wysiwyg/%'] = array( |
|
| 44 | + ); |
|
| 45 | + $items['wysiwyg/%'] = array( |
|
| 46 | 46 | 'page callback' => 'wysiwyg_dialog', |
| 47 | 47 | 'page arguments' => array(1), |
| 48 | 48 | 'access arguments' => array('access content'), |
| 49 | 49 | 'type' => MENU_CALLBACK, |
| 50 | 50 | 'file' => 'wysiwyg.dialog.inc', |
| 51 | - ); |
|
| 52 | - return $items; |
|
| 51 | + ); |
|
| 52 | + return $items; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -59,37 +59,37 @@ discard block |
||
| 59 | 59 | * @see template_preprocess_page(), theme.inc |
| 60 | 60 | */ |
| 61 | 61 | function wysiwyg_theme() { |
| 62 | - return array( |
|
| 62 | + return array( |
|
| 63 | 63 | 'wysiwyg_profile_overview' => array( |
| 64 | - 'arguments' => array('form' => NULL), |
|
| 64 | + 'arguments' => array('form' => NULL), |
|
| 65 | 65 | ), |
| 66 | 66 | 'wysiwyg_admin_button_table' => array( |
| 67 | - 'arguments' => array('form' => NULL), |
|
| 67 | + 'arguments' => array('form' => NULL), |
|
| 68 | 68 | ), |
| 69 | 69 | 'wysiwyg_dialog_page' => array( |
| 70 | - 'arguments' => array('content' => NULL, 'show_messages' => TRUE), |
|
| 71 | - 'file' => 'wysiwyg.dialog.inc', |
|
| 72 | - 'template' => 'wysiwyg-dialog-page', |
|
| 70 | + 'arguments' => array('content' => NULL, 'show_messages' => TRUE), |
|
| 71 | + 'file' => 'wysiwyg.dialog.inc', |
|
| 72 | + 'template' => 'wysiwyg-dialog-page', |
|
| 73 | 73 | ), |
| 74 | - ); |
|
| 74 | + ); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * Implementation of hook_help(). |
| 79 | 79 | */ |
| 80 | 80 | function wysiwyg_help($path, $arg) { |
| 81 | - switch ($path) { |
|
| 81 | + switch ($path) { |
|
| 82 | 82 | case 'admin/settings/wysiwyg': |
| 83 | 83 | $output = '<p>' . t('A Wysiwyg profile is associated with an input format. A Wysiwyg profile defines which client-side editor is loaded with a particular input format, what buttons or themes are enabled for the editor, how the editor is displayed, and a few other editor-specific functions.') . '</p>'; |
| 84 | - return $output; |
|
| 85 | - } |
|
| 84 | + return $output; |
|
| 85 | + } |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Clear wysiwyg cache on admin/build/modules form. |
| 90 | 90 | */ |
| 91 | 91 | function wysiwyg_form_system_modules_alter(&$form, $form_state) { |
| 92 | - wysiwyg_profile_load_all(TRUE); |
|
| 92 | + wysiwyg_profile_load_all(TRUE); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -104,11 +104,11 @@ discard block |
||
| 104 | 104 | * @see wysiwyg_process_form() |
| 105 | 105 | */ |
| 106 | 106 | function wysiwyg_form_alter(&$form, &$form_state) { |
| 107 | - $form['#after_build'][] = 'wysiwyg_process_form'; |
|
| 108 | - // Teaser splitter is unconditionally removed and NOT supported. |
|
| 109 | - if (isset($form['body_field'])) { |
|
| 107 | + $form['#after_build'][] = 'wysiwyg_process_form'; |
|
| 108 | + // Teaser splitter is unconditionally removed and NOT supported. |
|
| 109 | + if (isset($form['body_field'])) { |
|
| 110 | 110 | unset($form['body_field']['teaser_js']); |
| 111 | - } |
|
| 111 | + } |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -123,53 +123,53 @@ discard block |
||
| 123 | 123 | * @see wysiwyg_elements(), filter_form() |
| 124 | 124 | */ |
| 125 | 125 | function wysiwyg_process_form(&$form) { |
| 126 | - // Iterate over element children; resetting array keys to access last index. |
|
| 127 | - if ($children = array_values(element_children($form))) { |
|
| 126 | + // Iterate over element children; resetting array keys to access last index. |
|
| 127 | + if ($children = array_values(element_children($form))) { |
|
| 128 | 128 | foreach ($children as $index => $item) { |
| 129 | - $element = &$form[$item]; |
|
| 129 | + $element = &$form[$item]; |
|
| 130 | 130 | |
| 131 | - // filter_form() always uses the key 'format'. We need a type-agnostic |
|
| 132 | - // match to prevent false positives. Also, there must have been at least |
|
| 133 | - // one element on this level. |
|
| 134 | - if (($item === 'format' || $item === 'signature_format') && $index > 0) { |
|
| 131 | + // filter_form() always uses the key 'format'. We need a type-agnostic |
|
| 132 | + // match to prevent false positives. Also, there must have been at least |
|
| 133 | + // one element on this level. |
|
| 134 | + if (($item === 'format' || $item === 'signature_format') && $index > 0) { |
|
| 135 | 135 | // Make sure we either match a input format selector or input format |
| 136 | 136 | // guidelines (displayed if user has access to one input format only). |
| 137 | 137 | if ((isset($element['#type']) && $element['#type'] == 'fieldset') || isset($element['format']['guidelines'])) { |
| 138 | - // The element before this element is the target form field. |
|
| 139 | - $field = &$form[$children[$index - 1]]; |
|
| 138 | + // The element before this element is the target form field. |
|
| 139 | + $field = &$form[$children[$index - 1]]; |
|
| 140 | 140 | |
| 141 | - // Allow modules to programmatically enforce no client-side editor by |
|
| 142 | - // setting the #wysiwyg property to FALSE. |
|
| 143 | - if (isset($field['#wysiwyg']) && !$field['#wysiwyg']) { |
|
| 141 | + // Allow modules to programmatically enforce no client-side editor by |
|
| 142 | + // setting the #wysiwyg property to FALSE. |
|
| 143 | + if (isset($field['#wysiwyg']) && !$field['#wysiwyg']) { |
|
| 144 | 144 | // A 'format' element should not have any child elements that may |
| 145 | 145 | // need processing, so it should be safe to skip the recursion that |
| 146 | 146 | // happens at the end of this function, and move on to the next |
| 147 | 147 | // element on the same level. |
| 148 | 148 | continue; |
| 149 | - } |
|
| 150 | - |
|
| 151 | - // If this textarea is #resizable and we will load at least one |
|
| 152 | - // editor, then only load the behavior and let the 'none' editor |
|
| 153 | - // attach/detach it to avoid hi-jacking the UI. Due to our CSS class |
|
| 154 | - // parsing, we can add arbitrary parameters for each input format. |
|
| 155 | - // The #resizable property will be removed below, if at least one |
|
| 156 | - // profile has been loaded. |
|
| 157 | - $extra_class = ''; |
|
| 158 | - if (!empty($field['#resizable'])) { |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + // If this textarea is #resizable and we will load at least one |
|
| 152 | + // editor, then only load the behavior and let the 'none' editor |
|
| 153 | + // attach/detach it to avoid hi-jacking the UI. Due to our CSS class |
|
| 154 | + // parsing, we can add arbitrary parameters for each input format. |
|
| 155 | + // The #resizable property will be removed below, if at least one |
|
| 156 | + // profile has been loaded. |
|
| 157 | + $extra_class = ''; |
|
| 158 | + if (!empty($field['#resizable'])) { |
|
| 159 | 159 | $extra_class = ' wysiwyg-resizable-1'; |
| 160 | 160 | drupal_add_js('misc/textarea.js'); |
| 161 | - } |
|
| 162 | - |
|
| 163 | - // Determine the available input formats. The last child element is a |
|
| 164 | - // link to "More information about formatting options". When only one |
|
| 165 | - // input format is displayed, we also have to remove formatting |
|
| 166 | - // guidelines, stored in the child 'format'. |
|
| 167 | - $formats = element_children($element); |
|
| 168 | - array_pop($formats); |
|
| 169 | - if (($key = array_search('format', $formats)) !== FALSE) { |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + // Determine the available input formats. The last child element is a |
|
| 164 | + // link to "More information about formatting options". When only one |
|
| 165 | + // input format is displayed, we also have to remove formatting |
|
| 166 | + // guidelines, stored in the child 'format'. |
|
| 167 | + $formats = element_children($element); |
|
| 168 | + array_pop($formats); |
|
| 169 | + if (($key = array_search('format', $formats)) !== FALSE) { |
|
| 170 | 170 | unset($formats[$key]); |
| 171 | - } |
|
| 172 | - foreach ($formats as $format) { |
|
| 171 | + } |
|
| 172 | + foreach ($formats as $format) { |
|
| 173 | 173 | // Default to 'none' editor (Drupal's default behaviors). |
| 174 | 174 | $editor = 'none'; |
| 175 | 175 | $status = 1; |
@@ -177,51 +177,51 @@ discard block |
||
| 177 | 177 | // Fetch the profile associated to this input format. |
| 178 | 178 | $profile = wysiwyg_get_profile($format); |
| 179 | 179 | if ($profile) { |
| 180 | - $loaded = TRUE; |
|
| 181 | - $editor = $profile->editor; |
|
| 182 | - $status = (int) wysiwyg_user_get_status($profile); |
|
| 183 | - if (isset($profile->settings['show_toggle'])) { |
|
| 180 | + $loaded = TRUE; |
|
| 181 | + $editor = $profile->editor; |
|
| 182 | + $status = (int) wysiwyg_user_get_status($profile); |
|
| 183 | + if (isset($profile->settings['show_toggle'])) { |
|
| 184 | 184 | $toggle = (int) $profile->settings['show_toggle']; |
| 185 | - } |
|
| 186 | - // Check editor theme (and reset it if not/no longer available). |
|
| 187 | - $theme = wysiwyg_get_editor_themes($profile, (isset($profile->settings['theme']) ? $profile->settings['theme'] : '')); |
|
| 188 | - |
|
| 189 | - // Add plugin settings (first) for this input format. |
|
| 190 | - wysiwyg_add_plugin_settings($profile); |
|
| 191 | - // Add profile settings for this input format. |
|
| 192 | - wysiwyg_add_editor_settings($profile, $theme); |
|
| 185 | + } |
|
| 186 | + // Check editor theme (and reset it if not/no longer available). |
|
| 187 | + $theme = wysiwyg_get_editor_themes($profile, (isset($profile->settings['theme']) ? $profile->settings['theme'] : '')); |
|
| 188 | + |
|
| 189 | + // Add plugin settings (first) for this input format. |
|
| 190 | + wysiwyg_add_plugin_settings($profile); |
|
| 191 | + // Add profile settings for this input format. |
|
| 192 | + wysiwyg_add_editor_settings($profile, $theme); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | // Use a prefix/suffix for a single input format, or attach to input |
| 196 | 196 | // format selector radio buttons. |
| 197 | 197 | if (isset($element['format']['guidelines'])) { |
| 198 | - $element['format']['guidelines']['#prefix'] = '<div class="wysiwyg wysiwyg-format-' . $format . ' wysiwyg-editor-' . $editor . ' wysiwyg-field-' . $field['#id'] . ' wysiwyg-status-' . $status . ' wysiwyg-toggle-' . $toggle . $extra_class . '">'; |
|
| 199 | - $element['format']['guidelines']['#suffix'] = '</div>'; |
|
| 200 | - // Edge-case: Default format contains no input filters. |
|
| 201 | - if (empty($element['format']['guidelines']['#value'])) { |
|
| 198 | + $element['format']['guidelines']['#prefix'] = '<div class="wysiwyg wysiwyg-format-' . $format . ' wysiwyg-editor-' . $editor . ' wysiwyg-field-' . $field['#id'] . ' wysiwyg-status-' . $status . ' wysiwyg-toggle-' . $toggle . $extra_class . '">'; |
|
| 199 | + $element['format']['guidelines']['#suffix'] = '</div>'; |
|
| 200 | + // Edge-case: Default format contains no input filters. |
|
| 201 | + if (empty($element['format']['guidelines']['#value'])) { |
|
| 202 | 202 | $element['format']['guidelines']['#value'] = ' '; |
| 203 | - } |
|
| 203 | + } |
|
| 204 | 204 | } |
| 205 | 205 | else { |
| 206 | - $element[$format]['#attributes']['class'] = (isset($element[$format]['#attributes']['class']) ? $element[$format]['#attributes']['class'] . ' ' : ''); |
|
| 207 | - $element[$format]['#attributes']['class'] .= 'wysiwyg wysiwyg-format-' . $format . ' wysiwyg-editor-' . $editor . ' wysiwyg-field-' . $field['#id'] . ' wysiwyg-status-' . $status . ' wysiwyg-toggle-' . $toggle . $extra_class; |
|
| 206 | + $element[$format]['#attributes']['class'] = (isset($element[$format]['#attributes']['class']) ? $element[$format]['#attributes']['class'] . ' ' : ''); |
|
| 207 | + $element[$format]['#attributes']['class'] .= 'wysiwyg wysiwyg-format-' . $format . ' wysiwyg-editor-' . $editor . ' wysiwyg-field-' . $field['#id'] . ' wysiwyg-status-' . $status . ' wysiwyg-toggle-' . $toggle . $extra_class; |
|
| 208 | + } |
|
| 208 | 209 | } |
| 209 | - } |
|
| 210 | 210 | |
| 211 | - // If we loaded at least one editor, then the 'none' editor will |
|
| 212 | - // handle resizable textareas instead of core. |
|
| 213 | - if (isset($loaded) && !empty($field['#resizable'])) { |
|
| 211 | + // If we loaded at least one editor, then the 'none' editor will |
|
| 212 | + // handle resizable textareas instead of core. |
|
| 213 | + if (isset($loaded) && !empty($field['#resizable'])) { |
|
| 214 | 214 | $field['#resizable'] = FALSE; |
| 215 | - } |
|
| 215 | + } |
|
| 216 | 216 | } |
| 217 | 217 | // If this element is 'format', do not recurse further. |
| 218 | 218 | continue; |
| 219 | - } |
|
| 220 | - // Recurse into children. |
|
| 221 | - wysiwyg_process_form($element); |
|
| 219 | + } |
|
| 220 | + // Recurse into children. |
|
| 221 | + wysiwyg_process_form($element); |
|
| 222 | + } |
|
| 222 | 223 | } |
| 223 | - } |
|
| 224 | - return $form; |
|
| 224 | + return $form; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -239,12 +239,12 @@ discard block |
||
| 239 | 239 | * @see wysiwyg_load_editor(), wysiwyg_get_editor() |
| 240 | 240 | */ |
| 241 | 241 | function wysiwyg_get_profile($format) { |
| 242 | - if ($profile = wysiwyg_profile_load($format)) { |
|
| 242 | + if ($profile = wysiwyg_profile_load($format)) { |
|
| 243 | 243 | if (wysiwyg_load_editor($profile)) { |
| 244 | - return $profile; |
|
| 244 | + return $profile; |
|
| 245 | + } |
|
| 245 | 246 | } |
| 246 | - } |
|
| 247 | - return FALSE; |
|
| 247 | + return FALSE; |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -259,82 +259,82 @@ discard block |
||
| 259 | 259 | * @see wysiwyg_get_profile() |
| 260 | 260 | */ |
| 261 | 261 | function wysiwyg_load_editor($profile) { |
| 262 | - static $settings_added; |
|
| 263 | - static $loaded = array(); |
|
| 262 | + static $settings_added; |
|
| 263 | + static $loaded = array(); |
|
| 264 | 264 | |
| 265 | - $name = $profile->editor; |
|
| 266 | - // Library files must be loaded only once. |
|
| 267 | - if (!isset($loaded[$name])) { |
|
| 265 | + $name = $profile->editor; |
|
| 266 | + // Library files must be loaded only once. |
|
| 267 | + if (!isset($loaded[$name])) { |
|
| 268 | 268 | // Load editor. |
| 269 | 269 | $editor = wysiwyg_get_editor($name); |
| 270 | 270 | if ($editor) { |
| 271 | - // Determine library files to load. |
|
| 272 | - // @todo Allow to configure the library/execMode to use. |
|
| 273 | - if (isset($profile->settings['library']) && isset($editor['libraries'][$profile->settings['library']])) { |
|
| 271 | + // Determine library files to load. |
|
| 272 | + // @todo Allow to configure the library/execMode to use. |
|
| 273 | + if (isset($profile->settings['library']) && isset($editor['libraries'][$profile->settings['library']])) { |
|
| 274 | 274 | $library = $profile->settings['library']; |
| 275 | 275 | $files = $editor['libraries'][$library]['files']; |
| 276 | - } |
|
| 277 | - else { |
|
| 276 | + } |
|
| 277 | + else { |
|
| 278 | 278 | // Fallback to the first defined library by default (external libraries can change). |
| 279 | 279 | $library = key($editor['libraries']); |
| 280 | 280 | $files = array_shift($editor['libraries']); |
| 281 | 281 | $files = $files['files']; |
| 282 | - } |
|
| 283 | - foreach ($files as $file => $options) { |
|
| 282 | + } |
|
| 283 | + foreach ($files as $file => $options) { |
|
| 284 | 284 | if (is_array($options)) { |
| 285 | - $options += array('type' => 'module', 'scope' => 'header', 'defer' => FALSE, 'cache' => TRUE, 'preprocess' => TRUE); |
|
| 286 | - drupal_add_js($editor['library path'] . '/' . $file, $options['type'], $options['scope'], $options['defer'], $options['cache'], $options['preprocess']); |
|
| 285 | + $options += array('type' => 'module', 'scope' => 'header', 'defer' => FALSE, 'cache' => TRUE, 'preprocess' => TRUE); |
|
| 286 | + drupal_add_js($editor['library path'] . '/' . $file, $options['type'], $options['scope'], $options['defer'], $options['cache'], $options['preprocess']); |
|
| 287 | 287 | } |
| 288 | 288 | else { |
| 289 | - drupal_add_js($editor['library path'] . '/' . $options); |
|
| 289 | + drupal_add_js($editor['library path'] . '/' . $options); |
|
| 290 | 290 | } |
| 291 | - } |
|
| 292 | - // If editor defines an additional load callback, invoke it. |
|
| 293 | - // @todo Isn't the settings callback sufficient? |
|
| 294 | - if (isset($editor['load callback']) && function_exists($editor['load callback'])) { |
|
| 291 | + } |
|
| 292 | + // If editor defines an additional load callback, invoke it. |
|
| 293 | + // @todo Isn't the settings callback sufficient? |
|
| 294 | + if (isset($editor['load callback']) && function_exists($editor['load callback'])) { |
|
| 295 | 295 | $editor['load callback']($editor, $library); |
| 296 | - } |
|
| 297 | - // Load JavaScript integration files for this editor. |
|
| 298 | - $files = array(); |
|
| 299 | - if (isset($editor['js files'])) { |
|
| 296 | + } |
|
| 297 | + // Load JavaScript integration files for this editor. |
|
| 298 | + $files = array(); |
|
| 299 | + if (isset($editor['js files'])) { |
|
| 300 | 300 | $files = $editor['js files']; |
| 301 | - } |
|
| 302 | - foreach ($files as $file) { |
|
| 301 | + } |
|
| 302 | + foreach ($files as $file) { |
|
| 303 | 303 | drupal_add_js($editor['js path'] . '/' . $file); |
| 304 | - } |
|
| 305 | - // Load CSS stylesheets for this editor. |
|
| 306 | - $files = array(); |
|
| 307 | - if (isset($editor['css files'])) { |
|
| 304 | + } |
|
| 305 | + // Load CSS stylesheets for this editor. |
|
| 306 | + $files = array(); |
|
| 307 | + if (isset($editor['css files'])) { |
|
| 308 | 308 | $files = $editor['css files']; |
| 309 | - } |
|
| 310 | - foreach ($files as $file) { |
|
| 309 | + } |
|
| 310 | + foreach ($files as $file) { |
|
| 311 | 311 | drupal_add_css($editor['css path'] . '/' . $file); |
| 312 | - } |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - drupal_add_js(array('wysiwyg' => array( |
|
| 314 | + drupal_add_js(array('wysiwyg' => array( |
|
| 315 | 315 | 'configs' => array($editor['name'] => array('global' => array( |
| 316 | - // @todo Move into (global) editor settings. |
|
| 317 | - // If JS compression is enabled, at least TinyMCE is unable to determine |
|
| 318 | - // its own base path and exec mode since it can't find the script name. |
|
| 319 | - 'editorBasePath' => base_path() . $editor['library path'], |
|
| 320 | - 'execMode' => $library, |
|
| 316 | + // @todo Move into (global) editor settings. |
|
| 317 | + // If JS compression is enabled, at least TinyMCE is unable to determine |
|
| 318 | + // its own base path and exec mode since it can't find the script name. |
|
| 319 | + 'editorBasePath' => base_path() . $editor['library path'], |
|
| 320 | + 'execMode' => $library, |
|
| 321 | 321 | ))), |
| 322 | - )), 'setting'); |
|
| 322 | + )), 'setting'); |
|
| 323 | 323 | |
| 324 | - $loaded[$name] = TRUE; |
|
| 324 | + $loaded[$name] = TRUE; |
|
| 325 | 325 | } |
| 326 | 326 | else { |
| 327 | - $loaded[$name] = FALSE; |
|
| 327 | + $loaded[$name] = FALSE; |
|
| 328 | + } |
|
| 328 | 329 | } |
| 329 | - } |
|
| 330 | 330 | |
| 331 | - // Add basic Wysiwyg settings if any editor has been added. |
|
| 332 | - if (!isset($settings_added) && $loaded[$name]) { |
|
| 331 | + // Add basic Wysiwyg settings if any editor has been added. |
|
| 332 | + if (!isset($settings_added) && $loaded[$name]) { |
|
| 333 | 333 | drupal_add_js(array('wysiwyg' => array( |
| 334 | - 'configs' => array(), |
|
| 335 | - 'plugins' => array(), |
|
| 336 | - 'disable' => t('Disable rich-text'), |
|
| 337 | - 'enable' => t('Enable rich-text'), |
|
| 334 | + 'configs' => array(), |
|
| 335 | + 'plugins' => array(), |
|
| 336 | + 'disable' => t('Disable rich-text'), |
|
| 337 | + 'enable' => t('Enable rich-text'), |
|
| 338 | 338 | )), 'setting'); |
| 339 | 339 | |
| 340 | 340 | $path = drupal_get_path('module', 'wysiwyg'); |
@@ -355,26 +355,26 @@ discard block |
||
| 355 | 355 | drupal_add_js($path . '/wysiwyg.js', 'module', 'footer'); |
| 356 | 356 | |
| 357 | 357 | $settings_added = TRUE; |
| 358 | - } |
|
| 358 | + } |
|
| 359 | 359 | |
| 360 | - return $loaded[$name]; |
|
| 360 | + return $loaded[$name]; |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
| 364 | 364 | * Add editor settings for a given input format. |
| 365 | 365 | */ |
| 366 | 366 | function wysiwyg_add_editor_settings($profile, $theme) { |
| 367 | - static $formats = array(); |
|
| 367 | + static $formats = array(); |
|
| 368 | 368 | |
| 369 | - if (!isset($formats[$profile->format])) { |
|
| 369 | + if (!isset($formats[$profile->format])) { |
|
| 370 | 370 | $config = wysiwyg_get_editor_config($profile, $theme); |
| 371 | 371 | // drupal_to_js() does not properly convert numeric array keys, so we need |
| 372 | 372 | // to use a string instead of the format id. |
| 373 | 373 | if ($config) { |
| 374 | - drupal_add_js(array('wysiwyg' => array('configs' => array($profile->editor => array('format' . $profile->format => $config)))), 'setting'); |
|
| 374 | + drupal_add_js(array('wysiwyg' => array('configs' => array($profile->editor => array('format' . $profile->format => $config)))), 'setting'); |
|
| 375 | 375 | } |
| 376 | 376 | $formats[$profile->format] = TRUE; |
| 377 | - } |
|
| 377 | + } |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | /** |
@@ -402,86 +402,86 @@ discard block |
||
| 402 | 402 | * and simplify this entire function. |
| 403 | 403 | */ |
| 404 | 404 | function wysiwyg_add_plugin_settings($profile) { |
| 405 | - static $plugins = array(); |
|
| 406 | - static $processed_plugins = array(); |
|
| 407 | - static $processed_formats = array(); |
|
| 405 | + static $plugins = array(); |
|
| 406 | + static $processed_plugins = array(); |
|
| 407 | + static $processed_formats = array(); |
|
| 408 | 408 | |
| 409 | - // Each input format must only processed once. |
|
| 410 | - // @todo ...as long as we do not have multiple profiles per format. |
|
| 411 | - if (isset($processed_formats[$profile->format])) { |
|
| 409 | + // Each input format must only processed once. |
|
| 410 | + // @todo ...as long as we do not have multiple profiles per format. |
|
| 411 | + if (isset($processed_formats[$profile->format])) { |
|
| 412 | 412 | return; |
| 413 | - } |
|
| 414 | - $processed_formats[$profile->format] = TRUE; |
|
| 413 | + } |
|
| 414 | + $processed_formats[$profile->format] = TRUE; |
|
| 415 | 415 | |
| 416 | - $editor = wysiwyg_get_editor($profile->editor); |
|
| 416 | + $editor = wysiwyg_get_editor($profile->editor); |
|
| 417 | 417 | |
| 418 | - // Collect native plugins for this editor provided via hook_wysiwyg_plugin() |
|
| 419 | - // and Drupal plugins provided via hook_wysiwyg_include_directory(). |
|
| 420 | - if (!array_key_exists($editor['name'], $plugins)) { |
|
| 418 | + // Collect native plugins for this editor provided via hook_wysiwyg_plugin() |
|
| 419 | + // and Drupal plugins provided via hook_wysiwyg_include_directory(). |
|
| 420 | + if (!array_key_exists($editor['name'], $plugins)) { |
|
| 421 | 421 | $plugins[$editor['name']] = wysiwyg_get_plugins($editor['name']); |
| 422 | - } |
|
| 422 | + } |
|
| 423 | 423 | |
| 424 | - // Nothing to do, if there are no plugins. |
|
| 425 | - if (empty($plugins[$editor['name']])) { |
|
| 424 | + // Nothing to do, if there are no plugins. |
|
| 425 | + if (empty($plugins[$editor['name']])) { |
|
| 426 | 426 | return; |
| 427 | - } |
|
| 427 | + } |
|
| 428 | 428 | |
| 429 | - // Determine name of proxy plugin for Drupal plugins. |
|
| 430 | - $proxy = (isset($editor['proxy plugin']) ? key($editor['proxy plugin']) : ''); |
|
| 429 | + // Determine name of proxy plugin for Drupal plugins. |
|
| 430 | + $proxy = (isset($editor['proxy plugin']) ? key($editor['proxy plugin']) : ''); |
|
| 431 | 431 | |
| 432 | - // Process native editor plugins. |
|
| 433 | - if (isset($editor['plugin settings callback'])) { |
|
| 432 | + // Process native editor plugins. |
|
| 433 | + if (isset($editor['plugin settings callback'])) { |
|
| 434 | 434 | // @todo Require PHP 5.1 in 3.x and use array_intersect_key(). |
| 435 | 435 | $profile_plugins_native = array(); |
| 436 | 436 | foreach ($plugins[$editor['name']] as $plugin => $meta) { |
| 437 | - // Skip Drupal plugins (handled below). |
|
| 438 | - if ($plugin === $proxy) { |
|
| 437 | + // Skip Drupal plugins (handled below). |
|
| 438 | + if ($plugin === $proxy) { |
|
| 439 | 439 | continue; |
| 440 | - } |
|
| 441 | - // Only keep native plugins that are enabled in this profile. |
|
| 442 | - if (isset($profile->settings['buttons'][$plugin])) { |
|
| 440 | + } |
|
| 441 | + // Only keep native plugins that are enabled in this profile. |
|
| 442 | + if (isset($profile->settings['buttons'][$plugin])) { |
|
| 443 | 443 | $profile_plugins_native[$plugin] = $meta; |
| 444 | - } |
|
| 444 | + } |
|
| 445 | 445 | } |
| 446 | 446 | // Invoke the editor's plugin settings callback, so it can populate the |
| 447 | 447 | // settings for native external plugins with required values. |
| 448 | 448 | $settings_native = call_user_func($editor['plugin settings callback'], $editor, $profile, $profile_plugins_native); |
| 449 | 449 | |
| 450 | 450 | if ($settings_native) { |
| 451 | - drupal_add_js(array('wysiwyg' => array('plugins' => array('format' . $profile->format => array('native' => $settings_native)))), 'setting'); |
|
| 451 | + drupal_add_js(array('wysiwyg' => array('plugins' => array('format' . $profile->format => array('native' => $settings_native)))), 'setting'); |
|
| 452 | + } |
|
| 452 | 453 | } |
| 453 | - } |
|
| 454 | 454 | |
| 455 | - // Process Drupal plugins. |
|
| 456 | - if ($proxy && isset($editor['proxy plugin settings callback'])) { |
|
| 455 | + // Process Drupal plugins. |
|
| 456 | + if ($proxy && isset($editor['proxy plugin settings callback'])) { |
|
| 457 | 457 | $profile_plugins_drupal = array(); |
| 458 | 458 | foreach (wysiwyg_get_all_plugins() as $plugin => $meta) { |
| 459 | - if (isset($profile->settings['buttons'][$proxy][$plugin])) { |
|
| 459 | + if (isset($profile->settings['buttons'][$proxy][$plugin])) { |
|
| 460 | 460 | // JavaScript and plugin-specific settings for Drupal plugins must be |
| 461 | 461 | // loaded and processed only once. Plugin information is cached |
| 462 | 462 | // statically to pass it to the editor's proxy plugin settings callback. |
| 463 | 463 | if (!isset($processed_plugins[$proxy][$plugin])) { |
| 464 | - $profile_plugins_drupal[$plugin] = $processed_plugins[$proxy][$plugin] = $meta; |
|
| 465 | - // Load the Drupal plugin's JavaScript. |
|
| 466 | - drupal_add_js($meta['js path'] . '/' . $meta['js file']); |
|
| 467 | - // Add plugin-specific settings. |
|
| 468 | - if (isset($meta['settings'])) { |
|
| 464 | + $profile_plugins_drupal[$plugin] = $processed_plugins[$proxy][$plugin] = $meta; |
|
| 465 | + // Load the Drupal plugin's JavaScript. |
|
| 466 | + drupal_add_js($meta['js path'] . '/' . $meta['js file']); |
|
| 467 | + // Add plugin-specific settings. |
|
| 468 | + if (isset($meta['settings'])) { |
|
| 469 | 469 | drupal_add_js(array('wysiwyg' => array('plugins' => array('drupal' => array($plugin => $meta['settings'])))), 'setting'); |
| 470 | - } |
|
| 470 | + } |
|
| 471 | 471 | } |
| 472 | 472 | else { |
| 473 | - $profile_plugins_drupal[$plugin] = $processed_plugins[$proxy][$plugin]; |
|
| 473 | + $profile_plugins_drupal[$plugin] = $processed_plugins[$proxy][$plugin]; |
|
| 474 | + } |
|
| 474 | 475 | } |
| 475 | - } |
|
| 476 | 476 | } |
| 477 | 477 | // Invoke the editor's proxy plugin settings callback, so it can populate |
| 478 | 478 | // the settings for Drupal plugins with custom, required values. |
| 479 | 479 | $settings_drupal = call_user_func($editor['proxy plugin settings callback'], $editor, $profile, $profile_plugins_drupal); |
| 480 | 480 | |
| 481 | 481 | if ($settings_drupal) { |
| 482 | - drupal_add_js(array('wysiwyg' => array('plugins' => array('format' . $profile->format => array('drupal' => $settings_drupal)))), 'setting'); |
|
| 482 | + drupal_add_js(array('wysiwyg' => array('plugins' => array('format' . $profile->format => array('drupal' => $settings_drupal)))), 'setting'); |
|
| 483 | + } |
|
| 483 | 484 | } |
| 484 | - } |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -499,28 +499,28 @@ discard block |
||
| 499 | 499 | * was given. |
| 500 | 500 | */ |
| 501 | 501 | function wysiwyg_get_editor_themes(&$profile, $selected_theme = NULL) { |
| 502 | - static $themes = array(); |
|
| 502 | + static $themes = array(); |
|
| 503 | 503 | |
| 504 | - if (!isset($themes[$profile->editor])) { |
|
| 504 | + if (!isset($themes[$profile->editor])) { |
|
| 505 | 505 | $editor = wysiwyg_get_editor($profile->editor); |
| 506 | 506 | if (isset($editor['themes callback']) && function_exists($editor['themes callback'])) { |
| 507 | - $themes[$editor['name']] = $editor['themes callback']($editor, $profile); |
|
| 507 | + $themes[$editor['name']] = $editor['themes callback']($editor, $profile); |
|
| 508 | 508 | } |
| 509 | 509 | // Fallback to 'default' otherwise. |
| 510 | 510 | else { |
| 511 | - $themes[$editor['name']] = array('default'); |
|
| 511 | + $themes[$editor['name']] = array('default'); |
|
| 512 | + } |
|
| 512 | 513 | } |
| 513 | - } |
|
| 514 | 514 | |
| 515 | - // Check optional $selected_theme argument, if given. |
|
| 516 | - if (isset($selected_theme)) { |
|
| 515 | + // Check optional $selected_theme argument, if given. |
|
| 516 | + if (isset($selected_theme)) { |
|
| 517 | 517 | // If the passed theme name does not exist, use the first available. |
| 518 | 518 | if (!in_array($selected_theme, $themes[$profile->editor])) { |
| 519 | - $selected_theme = $profile->settings['theme'] = $themes[$profile->editor][0]; |
|
| 519 | + $selected_theme = $profile->settings['theme'] = $themes[$profile->editor][0]; |
|
| 520 | + } |
|
| 520 | 521 | } |
| 521 | - } |
|
| 522 | 522 | |
| 523 | - return isset($selected_theme) ? $selected_theme : $themes[$profile->editor]; |
|
| 523 | + return isset($selected_theme) ? $selected_theme : $themes[$profile->editor]; |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | /** |
@@ -533,42 +533,42 @@ discard block |
||
| 533 | 533 | * An array for each plugin. |
| 534 | 534 | */ |
| 535 | 535 | function wysiwyg_get_plugins($editor_name) { |
| 536 | - $plugins = array(); |
|
| 537 | - if (!empty($editor_name)) { |
|
| 536 | + $plugins = array(); |
|
| 537 | + if (!empty($editor_name)) { |
|
| 538 | 538 | $editor = wysiwyg_get_editor($editor_name); |
| 539 | 539 | // Add internal editor plugins. |
| 540 | 540 | if (isset($editor['plugin callback']) && function_exists($editor['plugin callback'])) { |
| 541 | - $plugins = $editor['plugin callback']($editor); |
|
| 541 | + $plugins = $editor['plugin callback']($editor); |
|
| 542 | 542 | } |
| 543 | 543 | // Add editor plugins provided via hook_wysiwyg_plugin(). |
| 544 | 544 | $plugins = array_merge($plugins, module_invoke_all('wysiwyg_plugin', $editor['name'], $editor['installed version'])); |
| 545 | 545 | // Add API plugins provided by Drupal modules. |
| 546 | 546 | // @todo We need to pass the filepath to the plugin icon for Drupal plugins. |
| 547 | 547 | if (isset($editor['proxy plugin'])) { |
| 548 | - $plugins += $editor['proxy plugin']; |
|
| 549 | - $proxy = key($editor['proxy plugin']); |
|
| 550 | - foreach (wysiwyg_get_all_plugins() as $plugin_name => $info) { |
|
| 548 | + $plugins += $editor['proxy plugin']; |
|
| 549 | + $proxy = key($editor['proxy plugin']); |
|
| 550 | + foreach (wysiwyg_get_all_plugins() as $plugin_name => $info) { |
|
| 551 | 551 | $plugins[$proxy]['buttons'][$plugin_name] = $info['title']; |
| 552 | - } |
|
| 552 | + } |
|
| 553 | + } |
|
| 553 | 554 | } |
| 554 | - } |
|
| 555 | - return $plugins; |
|
| 555 | + return $plugins; |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | /** |
| 559 | 559 | * Return an array of initial editor settings for a Wysiwyg profile. |
| 560 | 560 | */ |
| 561 | 561 | function wysiwyg_get_editor_config($profile, $theme) { |
| 562 | - $editor = wysiwyg_get_editor($profile->editor); |
|
| 563 | - $settings = array(); |
|
| 564 | - if (!empty($editor['settings callback']) && function_exists($editor['settings callback'])) { |
|
| 562 | + $editor = wysiwyg_get_editor($profile->editor); |
|
| 563 | + $settings = array(); |
|
| 564 | + if (!empty($editor['settings callback']) && function_exists($editor['settings callback'])) { |
|
| 565 | 565 | $settings = $editor['settings callback']($editor, $profile->settings, $theme); |
| 566 | 566 | |
| 567 | 567 | // Allow other modules to alter the editor settings for this format. |
| 568 | 568 | $context = array('editor' => $editor, 'profile' => $profile, 'theme' => $theme); |
| 569 | 569 | drupal_alter('wysiwyg_editor_settings', $settings, $context); |
| 570 | - } |
|
| 571 | - return $settings; |
|
| 570 | + } |
|
| 571 | + return $settings; |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | /** |
@@ -581,106 +581,106 @@ discard block |
||
| 581 | 581 | * An array containing CSS files, including proper base path. |
| 582 | 582 | */ |
| 583 | 583 | function wysiwyg_get_css() { |
| 584 | - static $files; |
|
| 584 | + static $files; |
|
| 585 | 585 | |
| 586 | - if (isset($files)) { |
|
| 586 | + if (isset($files)) { |
|
| 587 | 587 | return $files; |
| 588 | - } |
|
| 589 | - // In node form previews, the theme has not been initialized yet. |
|
| 590 | - if (!empty($_POST)) { |
|
| 588 | + } |
|
| 589 | + // In node form previews, the theme has not been initialized yet. |
|
| 590 | + if (!empty($_POST)) { |
|
| 591 | 591 | init_theme(); |
| 592 | - } |
|
| 592 | + } |
|
| 593 | 593 | |
| 594 | - $files = array(); |
|
| 595 | - foreach (drupal_add_css() as $media => $css) { |
|
| 594 | + $files = array(); |
|
| 595 | + foreach (drupal_add_css() as $media => $css) { |
|
| 596 | 596 | if ($media != 'print') { |
| 597 | - foreach ($css['theme'] as $filepath => $preprocess) { |
|
| 597 | + foreach ($css['theme'] as $filepath => $preprocess) { |
|
| 598 | 598 | if (file_exists($filepath)) { |
| 599 | - $files[] = base_path() . $filepath; |
|
| 599 | + $files[] = base_path() . $filepath; |
|
| 600 | + } |
|
| 600 | 601 | } |
| 601 | - } |
|
| 602 | 602 | } |
| 603 | - } |
|
| 604 | - return $files; |
|
| 603 | + } |
|
| 604 | + return $files; |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | /** |
| 608 | 608 | * Load profile for a given input format. |
| 609 | 609 | */ |
| 610 | 610 | function wysiwyg_profile_load($format) { |
| 611 | - static $profiles; |
|
| 611 | + static $profiles; |
|
| 612 | 612 | |
| 613 | - if (!isset($profiles) || !array_key_exists($format, $profiles)) { |
|
| 613 | + if (!isset($profiles) || !array_key_exists($format, $profiles)) { |
|
| 614 | 614 | $profiles = wysiwyg_profile_load_all(); |
| 615 | - } |
|
| 615 | + } |
|
| 616 | 616 | |
| 617 | - return (isset($profiles[$format]) ? $profiles[$format] : FALSE); |
|
| 617 | + return (isset($profiles[$format]) ? $profiles[$format] : FALSE); |
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | /** |
| 621 | 621 | * Load all profiles. |
| 622 | 622 | */ |
| 623 | 623 | function wysiwyg_profile_load_all($reset = FALSE) { |
| 624 | - static $profiles; |
|
| 624 | + static $profiles; |
|
| 625 | 625 | |
| 626 | - if ($reset || !isset($profiles)) { |
|
| 626 | + if ($reset || !isset($profiles)) { |
|
| 627 | 627 | $profiles = array(); |
| 628 | 628 | if (!$reset && ($cache = cache_get('wysiwyg:profiles', 'cache')) && is_array($cache->data)) { |
| 629 | - $profiles = $cache->data; |
|
| 630 | - return $profiles; |
|
| 629 | + $profiles = $cache->data; |
|
| 630 | + return $profiles; |
|
| 631 | 631 | } |
| 632 | 632 | // If Exportables and CTools are installed, use their API to load both |
| 633 | 633 | // wysiwyg profiles from code and from the database |
| 634 | 634 | if (module_exists('ctools') && module_exists('exportables')) { |
| 635 | - if (exportables_api_version('2.0') && ctools_api_version('1.7')) { |
|
| 635 | + if (exportables_api_version('2.0') && ctools_api_version('1.7')) { |
|
| 636 | 636 | $input_formats = exportables_load_all('input_formats'); |
| 637 | 637 | ctools_include('export'); |
| 638 | 638 | $ctools_profiles = ctools_export_load_object('wysiwyg'); |
| 639 | 639 | // Wysiwyg module still use numeric ids as keys |
| 640 | 640 | foreach ($ctools_profiles as $machine_name => $profile) { |
| 641 | - $profile->format = $input_formats[$machine_name]; |
|
| 642 | - $profiles[$profile->format] = $profile; |
|
| 641 | + $profile->format = $input_formats[$machine_name]; |
|
| 642 | + $profiles[$profile->format] = $profile; |
|
| 643 | + } |
|
| 643 | 644 | } |
| 644 | - } |
|
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | // DB profiles will always override Features profiles from flat files. |
| 648 | 648 | $result = db_query('SELECT format, editor, settings FROM {wysiwyg}'); |
| 649 | 649 | while ($profile = db_fetch_object($result)) { |
| 650 | - if (!isset($profiles[$profile->format])) { |
|
| 650 | + if (!isset($profiles[$profile->format])) { |
|
| 651 | 651 | $profile->settings = unserialize($profile->settings); |
| 652 | 652 | $profiles[$profile->format] = $profile; |
| 653 | - } |
|
| 653 | + } |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | drupal_alter('wysiwyg_load_profiles', $profiles); |
| 657 | 657 | cache_set('wysiwyg:profiles', $profiles); |
| 658 | - } |
|
| 658 | + } |
|
| 659 | 659 | |
| 660 | - return $profiles; |
|
| 660 | + return $profiles; |
|
| 661 | 661 | } |
| 662 | - /** |
|
| 663 | - * Wysiwyg profiles list callback. |
|
| 664 | - */ |
|
| 662 | + /** |
|
| 663 | + * Wysiwyg profiles list callback. |
|
| 664 | + */ |
|
| 665 | 665 | function wysiwyg_profile_list() { |
| 666 | - $profiles = wysiwyg_profile_load_all(TRUE); |
|
| 667 | - $filter_formats = filter_formats(); |
|
| 668 | - $list = array(); |
|
| 669 | - foreach ($profiles as $profile) { |
|
| 666 | + $profiles = wysiwyg_profile_load_all(TRUE); |
|
| 667 | + $filter_formats = filter_formats(); |
|
| 668 | + $list = array(); |
|
| 669 | + foreach ($profiles as $profile) { |
|
| 670 | 670 | $list[$profile->machine] = t('@format (@editor)', array('@editor' => $profile->editor, '@format' => $filter_formats[$profile->format]->name)); |
| 671 | - } |
|
| 672 | - return $list; |
|
| 671 | + } |
|
| 672 | + return $list; |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | /** |
| 676 | 676 | * Remove a profile from the database. |
| 677 | 677 | */ |
| 678 | 678 | function wysiwyg_profile_delete($wysiwyg) { |
| 679 | - if (!isset($wysiwyg->format)) { |
|
| 679 | + if (!isset($wysiwyg->format)) { |
|
| 680 | 680 | $input_formats = exportables_load_all('input_formats'); |
| 681 | 681 | $wysiwyg->format = $input_formats[$wysiwyg->machine]; |
| 682 | - } |
|
| 683 | - db_query("DELETE FROM {wysiwyg} WHERE format = %d", $wysiwyg->format); |
|
| 682 | + } |
|
| 683 | + db_query("DELETE FROM {wysiwyg} WHERE format = %d", $wysiwyg->format); |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | |
@@ -689,68 +689,68 @@ discard block |
||
| 689 | 689 | * Implementation of hook_user(). |
| 690 | 690 | */ |
| 691 | 691 | function wysiwyg_user($op, &$edit, $account, $category = NULL) { |
| 692 | - if ($op == 'form' && $category == 'account') { |
|
| 692 | + if ($op == 'form' && $category == 'account') { |
|
| 693 | 693 | $user_formats = filter_formats(); |
| 694 | 694 | $options = array(); |
| 695 | 695 | $options_default = array(); |
| 696 | 696 | foreach (wysiwyg_profile_load_all() as $format => $profile) { |
| 697 | - // Only show profiles that have user_choose enabled. |
|
| 698 | - if (!empty($profile->settings['user_choose']) && isset($user_formats[$format])) { |
|
| 697 | + // Only show profiles that have user_choose enabled. |
|
| 698 | + if (!empty($profile->settings['user_choose']) && isset($user_formats[$format])) { |
|
| 699 | 699 | $options[$format] = check_plain($user_formats[$format]->name); |
| 700 | 700 | if (wysiwyg_user_get_status($profile, $account)) { |
| 701 | - $options_default[] = $format; |
|
| 701 | + $options_default[] = $format; |
|
| 702 | + } |
|
| 702 | 703 | } |
| 703 | - } |
|
| 704 | 704 | } |
| 705 | 705 | if (!empty($options)) { |
| 706 | - $form['wysiwyg']['wysiwyg_status'] = array( |
|
| 706 | + $form['wysiwyg']['wysiwyg_status'] = array( |
|
| 707 | 707 | '#type' => 'checkboxes', |
| 708 | 708 | '#title' => t('Text formats enabled for rich-text editing'), |
| 709 | 709 | '#options' => $options, |
| 710 | 710 | '#default_value' => $options_default, |
| 711 | - ); |
|
| 712 | - return $form; |
|
| 711 | + ); |
|
| 712 | + return $form; |
|
| 713 | 713 | } |
| 714 | - } |
|
| 715 | - elseif ($op == 'insert' || $op == 'update') { |
|
| 714 | + } |
|
| 715 | + elseif ($op == 'insert' || $op == 'update') { |
|
| 716 | 716 | if (isset($edit['wysiwyg_status'])) { |
| 717 | - db_query("DELETE FROM {wysiwyg_user} WHERE uid = %d", $account->uid); |
|
| 718 | - foreach ($edit['wysiwyg_status'] as $format => $status) { |
|
| 717 | + db_query("DELETE FROM {wysiwyg_user} WHERE uid = %d", $account->uid); |
|
| 718 | + foreach ($edit['wysiwyg_status'] as $format => $status) { |
|
| 719 | 719 | db_query("INSERT INTO {wysiwyg_user} (uid, format, status) VALUES (%d, %d, %d)", array( |
| 720 | - $account->uid, |
|
| 721 | - $format, |
|
| 722 | - (int) (bool) $status, |
|
| 720 | + $account->uid, |
|
| 721 | + $format, |
|
| 722 | + (int) (bool) $status, |
|
| 723 | 723 | )); |
| 724 | - } |
|
| 724 | + } |
|
| 725 | + } |
|
| 725 | 726 | } |
| 726 | - } |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | function wysiwyg_user_get_status($profile, $account = NULL) { |
| 730 | - global $user; |
|
| 730 | + global $user; |
|
| 731 | 731 | |
| 732 | - if (!isset($account)) { |
|
| 732 | + if (!isset($account)) { |
|
| 733 | 733 | $account = $user; |
| 734 | - } |
|
| 734 | + } |
|
| 735 | 735 | |
| 736 | - // Default wysiwyg editor status information is only required on forms, so we |
|
| 737 | - // do not pre-emptively load and attach this information on every user_load(). |
|
| 738 | - if (!isset($account->wysiwyg_status)) { |
|
| 736 | + // Default wysiwyg editor status information is only required on forms, so we |
|
| 737 | + // do not pre-emptively load and attach this information on every user_load(). |
|
| 738 | + if (!isset($account->wysiwyg_status)) { |
|
| 739 | 739 | $account->wysiwyg_status = array(); |
| 740 | 740 | $result = db_query("SELECT format, status FROM {wysiwyg_user} WHERE uid = %d", $account->uid); |
| 741 | 741 | while ($row = db_fetch_object($result)) { |
| 742 | - $account->wysiwyg_status[$row->format] = $row->status; |
|
| 742 | + $account->wysiwyg_status[$row->format] = $row->status; |
|
| 743 | + } |
|
| 743 | 744 | } |
| 744 | - } |
|
| 745 | 745 | |
| 746 | - if (!empty($profile->settings['user_choose']) && isset($account->wysiwyg_status[$profile->format])) { |
|
| 746 | + if (!empty($profile->settings['user_choose']) && isset($account->wysiwyg_status[$profile->format])) { |
|
| 747 | 747 | $status = $account->wysiwyg_status[$profile->format]; |
| 748 | - } |
|
| 749 | - else { |
|
| 748 | + } |
|
| 749 | + else { |
|
| 750 | 750 | $status = isset($profile->settings['default']) ? $profile->settings['default'] : TRUE; |
| 751 | - } |
|
| 751 | + } |
|
| 752 | 752 | |
| 753 | - return (bool) $status; |
|
| 753 | + return (bool) $status; |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | /** |
@@ -772,110 +772,110 @@ discard block |
||
| 772 | 772 | * installed properly. |
| 773 | 773 | */ |
| 774 | 774 | function wysiwyg_get_editor($name) { |
| 775 | - $editors = wysiwyg_get_all_editors(); |
|
| 776 | - return isset($editors[$name]) && $editors[$name]['installed'] ? $editors[$name] : FALSE; |
|
| 775 | + $editors = wysiwyg_get_all_editors(); |
|
| 776 | + return isset($editors[$name]) && $editors[$name]['installed'] ? $editors[$name] : FALSE; |
|
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | /** |
| 780 | 780 | * Compile a list holding all supported editors including installed editor version information. |
| 781 | 781 | */ |
| 782 | 782 | function wysiwyg_get_all_editors() { |
| 783 | - static $editors; |
|
| 783 | + static $editors; |
|
| 784 | 784 | |
| 785 | - if (isset($editors)) { |
|
| 785 | + if (isset($editors)) { |
|
| 786 | 786 | return $editors; |
| 787 | - } |
|
| 787 | + } |
|
| 788 | 788 | |
| 789 | - $editors = wysiwyg_load_includes('editors', 'editor'); |
|
| 790 | - foreach ($editors as $editor => $properties) { |
|
| 789 | + $editors = wysiwyg_load_includes('editors', 'editor'); |
|
| 790 | + foreach ($editors as $editor => $properties) { |
|
| 791 | 791 | // Fill in required properties. |
| 792 | 792 | $editors[$editor] += array( |
| 793 | - 'title' => '', |
|
| 794 | - 'vendor url' => '', |
|
| 795 | - 'download url' => '', |
|
| 796 | - 'editor path' => wysiwyg_get_path($editors[$editor]['name']), |
|
| 797 | - 'library path' => wysiwyg_get_path($editors[$editor]['name']), |
|
| 798 | - 'libraries' => array(), |
|
| 799 | - 'version callback' => NULL, |
|
| 800 | - 'themes callback' => NULL, |
|
| 801 | - 'settings callback' => NULL, |
|
| 802 | - 'plugin callback' => NULL, |
|
| 803 | - 'plugin settings callback' => NULL, |
|
| 804 | - 'versions' => array(), |
|
| 805 | - 'js path' => $editors[$editor]['path'] . '/js', |
|
| 806 | - 'css path' => $editors[$editor]['path'] . '/css', |
|
| 793 | + 'title' => '', |
|
| 794 | + 'vendor url' => '', |
|
| 795 | + 'download url' => '', |
|
| 796 | + 'editor path' => wysiwyg_get_path($editors[$editor]['name']), |
|
| 797 | + 'library path' => wysiwyg_get_path($editors[$editor]['name']), |
|
| 798 | + 'libraries' => array(), |
|
| 799 | + 'version callback' => NULL, |
|
| 800 | + 'themes callback' => NULL, |
|
| 801 | + 'settings callback' => NULL, |
|
| 802 | + 'plugin callback' => NULL, |
|
| 803 | + 'plugin settings callback' => NULL, |
|
| 804 | + 'versions' => array(), |
|
| 805 | + 'js path' => $editors[$editor]['path'] . '/js', |
|
| 806 | + 'css path' => $editors[$editor]['path'] . '/css', |
|
| 807 | 807 | ); |
| 808 | 808 | // Check whether library is present. |
| 809 | 809 | if (!($editors[$editor]['installed'] = file_exists($editors[$editor]['library path']))) { |
| 810 | - continue; |
|
| 810 | + continue; |
|
| 811 | 811 | } |
| 812 | 812 | // Detect library version. |
| 813 | 813 | if (function_exists($editors[$editor]['version callback'])) { |
| 814 | - $editors[$editor]['installed version'] = $editors[$editor]['version callback']($editors[$editor]); |
|
| 814 | + $editors[$editor]['installed version'] = $editors[$editor]['version callback']($editors[$editor]); |
|
| 815 | 815 | } |
| 816 | 816 | if (empty($editors[$editor]['installed version'])) { |
| 817 | - $editors[$editor]['error'] = t('The version of %editor could not be detected.', array('%editor' => $properties['title'])); |
|
| 818 | - $editors[$editor]['installed'] = FALSE; |
|
| 819 | - continue; |
|
| 817 | + $editors[$editor]['error'] = t('The version of %editor could not be detected.', array('%editor' => $properties['title'])); |
|
| 818 | + $editors[$editor]['installed'] = FALSE; |
|
| 819 | + continue; |
|
| 820 | 820 | } |
| 821 | 821 | // Determine to which supported version the installed version maps. |
| 822 | 822 | ksort($editors[$editor]['versions']); |
| 823 | 823 | $version = 0; |
| 824 | 824 | foreach ($editors[$editor]['versions'] as $supported_version => $version_properties) { |
| 825 | - if (version_compare($editors[$editor]['installed version'], $supported_version, '>=')) { |
|
| 825 | + if (version_compare($editors[$editor]['installed version'], $supported_version, '>=')) { |
|
| 826 | 826 | $version = $supported_version; |
| 827 | - } |
|
| 827 | + } |
|
| 828 | 828 | } |
| 829 | 829 | if (!$version) { |
| 830 | - $editors[$editor]['error'] = t('The installed version %version of %editor is not supported.', array('%version' => $editors[$editor]['installed version'], '%editor' => $editors[$editor]['title'])); |
|
| 831 | - $editors[$editor]['installed'] = FALSE; |
|
| 832 | - continue; |
|
| 830 | + $editors[$editor]['error'] = t('The installed version %version of %editor is not supported.', array('%version' => $editors[$editor]['installed version'], '%editor' => $editors[$editor]['title'])); |
|
| 831 | + $editors[$editor]['installed'] = FALSE; |
|
| 832 | + continue; |
|
| 833 | 833 | } |
| 834 | 834 | // Apply library version specific definitions and overrides. |
| 835 | 835 | $editors[$editor] = array_merge($editors[$editor], $editors[$editor]['versions'][$version]); |
| 836 | 836 | unset($editors[$editor]['versions']); |
| 837 | - } |
|
| 838 | - return $editors; |
|
| 837 | + } |
|
| 838 | + return $editors; |
|
| 839 | 839 | } |
| 840 | 840 | |
| 841 | 841 | /** |
| 842 | 842 | * Invoke hook_wysiwyg_plugin() in all modules. |
| 843 | 843 | */ |
| 844 | 844 | function wysiwyg_get_all_plugins() { |
| 845 | - static $plugins; |
|
| 845 | + static $plugins; |
|
| 846 | 846 | |
| 847 | - if (isset($plugins)) { |
|
| 847 | + if (isset($plugins)) { |
|
| 848 | 848 | return $plugins; |
| 849 | - } |
|
| 849 | + } |
|
| 850 | 850 | |
| 851 | - $plugins = wysiwyg_load_includes('plugins', 'plugin'); |
|
| 852 | - foreach ($plugins as $name => $properties) { |
|
| 851 | + $plugins = wysiwyg_load_includes('plugins', 'plugin'); |
|
| 852 | + foreach ($plugins as $name => $properties) { |
|
| 853 | 853 | $plugin = &$plugins[$name]; |
| 854 | 854 | // Fill in required/default properties. |
| 855 | 855 | $plugin += array( |
| 856 | - 'title' => $plugin['name'], |
|
| 857 | - 'vendor url' => '', |
|
| 858 | - 'js path' => $plugin['path'] . '/' . $plugin['name'], |
|
| 859 | - 'js file' => $plugin['name'] . '.js', |
|
| 860 | - 'css path' => $plugin['path'] . '/' . $plugin['name'], |
|
| 861 | - 'css file' => $plugin['name'] . '.css', |
|
| 862 | - 'icon path' => $plugin['path'] . '/' . $plugin['name'] . '/images', |
|
| 863 | - 'icon file' => $plugin['name'] . '.png', |
|
| 864 | - 'dialog path' => $plugin['name'], |
|
| 865 | - 'dialog settings' => array(), |
|
| 866 | - 'settings callback' => NULL, |
|
| 867 | - 'settings form callback' => NULL, |
|
| 856 | + 'title' => $plugin['name'], |
|
| 857 | + 'vendor url' => '', |
|
| 858 | + 'js path' => $plugin['path'] . '/' . $plugin['name'], |
|
| 859 | + 'js file' => $plugin['name'] . '.js', |
|
| 860 | + 'css path' => $plugin['path'] . '/' . $plugin['name'], |
|
| 861 | + 'css file' => $plugin['name'] . '.css', |
|
| 862 | + 'icon path' => $plugin['path'] . '/' . $plugin['name'] . '/images', |
|
| 863 | + 'icon file' => $plugin['name'] . '.png', |
|
| 864 | + 'dialog path' => $plugin['name'], |
|
| 865 | + 'dialog settings' => array(), |
|
| 866 | + 'settings callback' => NULL, |
|
| 867 | + 'settings form callback' => NULL, |
|
| 868 | 868 | ); |
| 869 | 869 | // Fill in default settings. |
| 870 | 870 | $plugin['settings'] += array( |
| 871 | - 'path' => base_path() . $plugin['path'] . '/' . $plugin['name'], |
|
| 871 | + 'path' => base_path() . $plugin['path'] . '/' . $plugin['name'], |
|
| 872 | 872 | ); |
| 873 | 873 | // Check whether library is present. |
| 874 | 874 | if (!($plugin['installed'] = file_exists($plugin['js path'] . '/' . $plugin['js file']))) { |
| 875 | - continue; |
|
| 875 | + continue; |
|
| 876 | + } |
|
| 876 | 877 | } |
| 877 | - } |
|
| 878 | - return $plugins; |
|
| 878 | + return $plugins; |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | /** |
@@ -891,26 +891,26 @@ discard block |
||
| 891 | 891 | * @see wysiwyg_get_directories(), _wysiwyg_process_include() |
| 892 | 892 | */ |
| 893 | 893 | function wysiwyg_load_includes($type = 'editors', $hook = 'editor', $file = NULL) { |
| 894 | - // Determine implementations. |
|
| 895 | - $directories = wysiwyg_get_directories($type); |
|
| 896 | - $directories['wysiwyg'] = drupal_get_path('module', 'wysiwyg') . '/' . $type; |
|
| 897 | - $file_list = array(); |
|
| 898 | - foreach ($directories as $module => $path) { |
|
| 894 | + // Determine implementations. |
|
| 895 | + $directories = wysiwyg_get_directories($type); |
|
| 896 | + $directories['wysiwyg'] = drupal_get_path('module', 'wysiwyg') . '/' . $type; |
|
| 897 | + $file_list = array(); |
|
| 898 | + foreach ($directories as $module => $path) { |
|
| 899 | 899 | $file_list[$module] = drupal_system_listing("$file" . '.inc$', $path, 'name', 0); |
| 900 | - } |
|
| 900 | + } |
|
| 901 | 901 | |
| 902 | - // Load implementations. |
|
| 903 | - $info = array(); |
|
| 904 | - foreach (array_filter($file_list) as $module => $files) { |
|
| 902 | + // Load implementations. |
|
| 903 | + $info = array(); |
|
| 904 | + foreach (array_filter($file_list) as $module => $files) { |
|
| 905 | 905 | foreach ($files as $file) { |
| 906 | - include_once './' . $file->filename; |
|
| 907 | - $result = _wysiwyg_process_include($module, $module . '_' . $file->name, dirname($file->filename), $hook); |
|
| 908 | - if (is_array($result)) { |
|
| 906 | + include_once './' . $file->filename; |
|
| 907 | + $result = _wysiwyg_process_include($module, $module . '_' . $file->name, dirname($file->filename), $hook); |
|
| 908 | + if (is_array($result)) { |
|
| 909 | 909 | $info = array_merge($info, $result); |
| 910 | - } |
|
| 910 | + } |
|
| 911 | 911 | } |
| 912 | - } |
|
| 913 | - return $info; |
|
| 912 | + } |
|
| 913 | + return $info; |
|
| 914 | 914 | } |
| 915 | 915 | |
| 916 | 916 | /** |
@@ -927,20 +927,20 @@ discard block |
||
| 927 | 927 | * @ingroup libraries |
| 928 | 928 | */ |
| 929 | 929 | function wysiwyg_get_path($library, $base_path = FALSE) { |
| 930 | - static $libraries; |
|
| 930 | + static $libraries; |
|
| 931 | 931 | |
| 932 | - if (!isset($libraries)) { |
|
| 932 | + if (!isset($libraries)) { |
|
| 933 | 933 | $libraries = wysiwyg_get_libraries(); |
| 934 | - } |
|
| 935 | - if (!isset($libraries[$library])) { |
|
| 934 | + } |
|
| 935 | + if (!isset($libraries[$library])) { |
|
| 936 | 936 | // Most often, external libraries can be shared across multiple sites. |
| 937 | 937 | return 'sites/all/libraries/' . $library; |
| 938 | - } |
|
| 938 | + } |
|
| 939 | 939 | |
| 940 | - $path = ($base_path ? base_path() : ''); |
|
| 941 | - $path .= $libraries[$library]; |
|
| 940 | + $path = ($base_path ? base_path() : ''); |
|
| 941 | + $path .= $libraries[$library]; |
|
| 942 | 942 | |
| 943 | - return $path; |
|
| 943 | + return $path; |
|
| 944 | 944 | } |
| 945 | 945 | |
| 946 | 946 | /** |
@@ -960,55 +960,55 @@ discard block |
||
| 960 | 960 | * @ingroup libraries |
| 961 | 961 | */ |
| 962 | 962 | function wysiwyg_get_libraries() { |
| 963 | - global $profile; |
|
| 964 | - |
|
| 965 | - // When this function is called during Drupal's initial installation process, |
|
| 966 | - // the name of the profile that is about to be installed is stored in the |
|
| 967 | - // global $profile variable. At all other times, the regular system variable |
|
| 968 | - // contains the name of the current profile, and we can call variable_get() |
|
| 969 | - // to determine the profile. |
|
| 970 | - if (!isset($profile)) { |
|
| 963 | + global $profile; |
|
| 964 | + |
|
| 965 | + // When this function is called during Drupal's initial installation process, |
|
| 966 | + // the name of the profile that is about to be installed is stored in the |
|
| 967 | + // global $profile variable. At all other times, the regular system variable |
|
| 968 | + // contains the name of the current profile, and we can call variable_get() |
|
| 969 | + // to determine the profile. |
|
| 970 | + if (!isset($profile)) { |
|
| 971 | 971 | $profile = variable_get('install_profile', 'default'); |
| 972 | - } |
|
| 972 | + } |
|
| 973 | 973 | |
| 974 | - $directory = 'libraries'; |
|
| 975 | - $searchdir = array(); |
|
| 976 | - $config = conf_path(); |
|
| 974 | + $directory = 'libraries'; |
|
| 975 | + $searchdir = array(); |
|
| 976 | + $config = conf_path(); |
|
| 977 | 977 | |
| 978 | - // The 'profiles' directory contains pristine collections of modules and |
|
| 979 | - // themes as organized by a distribution. It is pristine in the same way |
|
| 980 | - // that /modules is pristine for core; users should avoid changing anything |
|
| 981 | - // there in favor of sites/all or sites/<domain> directories. |
|
| 982 | - if (file_exists("profiles/$profile/$directory")) { |
|
| 978 | + // The 'profiles' directory contains pristine collections of modules and |
|
| 979 | + // themes as organized by a distribution. It is pristine in the same way |
|
| 980 | + // that /modules is pristine for core; users should avoid changing anything |
|
| 981 | + // there in favor of sites/all or sites/<domain> directories. |
|
| 982 | + if (file_exists("profiles/$profile/$directory")) { |
|
| 983 | 983 | $searchdir[] = "profiles/$profile/$directory"; |
| 984 | - } |
|
| 984 | + } |
|
| 985 | 985 | |
| 986 | - // Always search sites/all/*. |
|
| 987 | - $searchdir[] = 'sites/all/' . $directory; |
|
| 986 | + // Always search sites/all/*. |
|
| 987 | + $searchdir[] = 'sites/all/' . $directory; |
|
| 988 | 988 | |
| 989 | - // Also search sites/<domain>/*. |
|
| 990 | - if (file_exists("$config/$directory")) { |
|
| 989 | + // Also search sites/<domain>/*. |
|
| 990 | + if (file_exists("$config/$directory")) { |
|
| 991 | 991 | $searchdir[] = "$config/$directory"; |
| 992 | - } |
|
| 992 | + } |
|
| 993 | 993 | |
| 994 | - // Retrieve list of directories. |
|
| 995 | - // @todo Core: Allow to scan for directories. |
|
| 996 | - $directories = array(); |
|
| 997 | - $nomask = array('CVS'); |
|
| 998 | - foreach ($searchdir as $dir) { |
|
| 994 | + // Retrieve list of directories. |
|
| 995 | + // @todo Core: Allow to scan for directories. |
|
| 996 | + $directories = array(); |
|
| 997 | + $nomask = array('CVS'); |
|
| 998 | + foreach ($searchdir as $dir) { |
|
| 999 | 999 | if (is_dir($dir) && $handle = opendir($dir)) { |
| 1000 | - while (FALSE !== ($file = readdir($handle))) { |
|
| 1000 | + while (FALSE !== ($file = readdir($handle))) { |
|
| 1001 | 1001 | if (!in_array($file, $nomask) && $file[0] != '.') { |
| 1002 | - if (is_dir("$dir/$file")) { |
|
| 1002 | + if (is_dir("$dir/$file")) { |
|
| 1003 | 1003 | $directories[$file] = "$dir/$file"; |
| 1004 | - } |
|
| 1004 | + } |
|
| 1005 | + } |
|
| 1005 | 1006 | } |
| 1006 | - } |
|
| 1007 | - closedir($handle); |
|
| 1007 | + closedir($handle); |
|
| 1008 | + } |
|
| 1008 | 1009 | } |
| 1009 | - } |
|
| 1010 | 1010 | |
| 1011 | - return $directories; |
|
| 1011 | + return $directories; |
|
| 1012 | 1012 | } |
| 1013 | 1013 | |
| 1014 | 1014 | /** |
@@ -1024,14 +1024,14 @@ discard block |
||
| 1024 | 1024 | * @see wysiwyg_load_includes(), _wysiwyg_process_include() |
| 1025 | 1025 | */ |
| 1026 | 1026 | function wysiwyg_get_directories($plugintype) { |
| 1027 | - $directories = array(); |
|
| 1028 | - foreach (module_implements('wysiwyg_include_directory') as $module) { |
|
| 1027 | + $directories = array(); |
|
| 1028 | + foreach (module_implements('wysiwyg_include_directory') as $module) { |
|
| 1029 | 1029 | $result = module_invoke($module, 'wysiwyg_include_directory', $plugintype); |
| 1030 | 1030 | if (isset($result) && is_string($result)) { |
| 1031 | - $directories[$module] = drupal_get_path('module', $module) . '/' . $result; |
|
| 1031 | + $directories[$module] = drupal_get_path('module', $module) . '/' . $result; |
|
| 1032 | 1032 | } |
| 1033 | - } |
|
| 1034 | - return $directories; |
|
| 1033 | + } |
|
| 1034 | + return $directories; |
|
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | 1037 | /** |
@@ -1045,22 +1045,22 @@ discard block |
||
| 1045 | 1045 | * The name of the hook being invoked. |
| 1046 | 1046 | */ |
| 1047 | 1047 | function _wysiwyg_process_include($module, $identifier, $path, $hook) { |
| 1048 | - $function = $identifier . '_' . $hook; |
|
| 1049 | - if (!function_exists($function)) { |
|
| 1048 | + $function = $identifier . '_' . $hook; |
|
| 1049 | + if (!function_exists($function)) { |
|
| 1050 | 1050 | return NULL; |
| 1051 | - } |
|
| 1052 | - $result = $function(); |
|
| 1053 | - if (!isset($result) || !is_array($result)) { |
|
| 1051 | + } |
|
| 1052 | + $result = $function(); |
|
| 1053 | + if (!isset($result) || !is_array($result)) { |
|
| 1054 | 1054 | return NULL; |
| 1055 | - } |
|
| 1055 | + } |
|
| 1056 | 1056 | |
| 1057 | - // Fill in defaults. |
|
| 1058 | - foreach ($result as $editor => $properties) { |
|
| 1057 | + // Fill in defaults. |
|
| 1058 | + foreach ($result as $editor => $properties) { |
|
| 1059 | 1059 | $result[$editor]['module'] = $module; |
| 1060 | 1060 | $result[$editor]['name'] = $editor; |
| 1061 | 1061 | $result[$editor]['path'] = $path; |
| 1062 | - } |
|
| 1063 | - return $result; |
|
| 1062 | + } |
|
| 1063 | + return $result; |
|
| 1064 | 1064 | } |
| 1065 | 1065 | |
| 1066 | 1066 | /** |
@@ -1079,12 +1079,12 @@ discard block |
||
| 1079 | 1079 | * installed. |
| 1080 | 1080 | */ |
| 1081 | 1081 | function wysiwyg_features_api() { |
| 1082 | - $return = array(); |
|
| 1083 | - if (module_exists('exportables') && module_exists('ctools')) { |
|
| 1082 | + $return = array(); |
|
| 1083 | + if (module_exists('exportables') && module_exists('ctools')) { |
|
| 1084 | 1084 | module_load_include('inc', 'features', 'includes/features.ctools'); |
| 1085 | 1085 | $return = ctools_component_features_api('wysiwyg'); |
| 1086 | - } |
|
| 1087 | - return $return; |
|
| 1086 | + } |
|
| 1087 | + return $return; |
|
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | 1090 | /** |
@@ -1094,10 +1094,10 @@ discard block |
||
| 1094 | 1094 | */ |
| 1095 | 1095 | function wysiwyg_features_export($data, &$export, $module_name = '') { |
| 1096 | 1096 | |
| 1097 | - $return = ctools_component_features_export('wysiwyg', $data, $export, $module_name); |
|
| 1098 | - $export['dependencies']['exportables'] = 'exportables'; |
|
| 1097 | + $return = ctools_component_features_export('wysiwyg', $data, $export, $module_name); |
|
| 1098 | + $export['dependencies']['exportables'] = 'exportables'; |
|
| 1099 | 1099 | |
| 1100 | - return $return; |
|
| 1100 | + return $return; |
|
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | /** |
@@ -9,25 +9,25 @@ discard block |
||
| 9 | 9 | * Menu callback; Output a wysiwyg plugin dialog page. |
| 10 | 10 | */ |
| 11 | 11 | function wysiwyg_dialog($plugin, $instance) { |
| 12 | - $plugins = wysiwyg_get_all_plugins(); |
|
| 13 | - if (!isset($plugins[$plugin])) { |
|
| 12 | + $plugins = wysiwyg_get_all_plugins(); |
|
| 13 | + if (!isset($plugins[$plugin])) { |
|
| 14 | 14 | return drupal_access_denied(); |
| 15 | - } |
|
| 16 | - $callback = $plugin . '_wysiwyg_dialog'; |
|
| 17 | - if (!function_exists($callback)) { |
|
| 15 | + } |
|
| 16 | + $callback = $plugin . '_wysiwyg_dialog'; |
|
| 17 | + if (!function_exists($callback)) { |
|
| 18 | 18 | return drupal_not_found(); |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - // Suppress admin menu. |
|
| 22 | - module_invoke('admin_menu', 'suppress'); |
|
| 23 | - // Add editor instance id to Drupal.settings. |
|
| 24 | - $settings = array( |
|
| 21 | + // Suppress admin menu. |
|
| 22 | + module_invoke('admin_menu', 'suppress'); |
|
| 23 | + // Add editor instance id to Drupal.settings. |
|
| 24 | + $settings = array( |
|
| 25 | 25 | 'plugin' => $plugin, |
| 26 | 26 | 'instance' => $instance, |
| 27 | - ); |
|
| 28 | - drupal_add_js(array('wysiwyg' => $settings), 'setting'); |
|
| 27 | + ); |
|
| 28 | + drupal_add_js(array('wysiwyg' => $settings), 'setting'); |
|
| 29 | 29 | |
| 30 | - echo theme('wysiwyg_dialog_page', $callback($instance)); |
|
| 30 | + echo theme('wysiwyg_dialog_page', $callback($instance)); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -38,26 +38,26 @@ discard block |
||
| 38 | 38 | * @see template_preprocess() |
| 39 | 39 | */ |
| 40 | 40 | function template_preprocess_wysiwyg_dialog_page(&$variables) { |
| 41 | - // Construct page title |
|
| 42 | - $head_title = array(strip_tags(drupal_get_title()), variable_get('site_name', 'Drupal')); |
|
| 41 | + // Construct page title |
|
| 42 | + $head_title = array(strip_tags(drupal_get_title()), variable_get('site_name', 'Drupal')); |
|
| 43 | 43 | |
| 44 | - $variables['head_title'] = implode(' | ', $head_title); |
|
| 45 | - $variables['base_path'] = base_path(); |
|
| 46 | - $variables['front_page'] = url(); |
|
| 47 | - // @todo Would a breadcrumb make sense / possible at all? |
|
| 48 | - // $variables['breadcrumb'] = theme('breadcrumb', drupal_get_breadcrumb()); |
|
| 49 | - $variables['head'] = drupal_get_html_head(); |
|
| 50 | - $variables['help'] = theme('help'); |
|
| 51 | - $variables['language'] = $GLOBALS['language']; |
|
| 52 | - $variables['language']->dir = $GLOBALS['language']->direction ? 'rtl' : 'ltr'; |
|
| 53 | - $variables['messages'] = $variables['show_messages'] ? theme('status_messages') : ''; |
|
| 54 | - $variables['site_name'] = (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : ''); |
|
| 55 | - $variables['css'] = drupal_add_css(); |
|
| 56 | - $variables['styles'] = drupal_get_css(); |
|
| 57 | - $variables['scripts'] = drupal_get_js(); |
|
| 58 | - $variables['tabs'] = theme('menu_local_tasks'); |
|
| 59 | - $variables['title'] = drupal_get_title(); |
|
| 60 | - // Closure should be filled last. |
|
| 61 | - $variables['closure'] = theme('closure'); |
|
| 44 | + $variables['head_title'] = implode(' | ', $head_title); |
|
| 45 | + $variables['base_path'] = base_path(); |
|
| 46 | + $variables['front_page'] = url(); |
|
| 47 | + // @todo Would a breadcrumb make sense / possible at all? |
|
| 48 | + // $variables['breadcrumb'] = theme('breadcrumb', drupal_get_breadcrumb()); |
|
| 49 | + $variables['head'] = drupal_get_html_head(); |
|
| 50 | + $variables['help'] = theme('help'); |
|
| 51 | + $variables['language'] = $GLOBALS['language']; |
|
| 52 | + $variables['language']->dir = $GLOBALS['language']->direction ? 'rtl' : 'ltr'; |
|
| 53 | + $variables['messages'] = $variables['show_messages'] ? theme('status_messages') : ''; |
|
| 54 | + $variables['site_name'] = (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : ''); |
|
| 55 | + $variables['css'] = drupal_add_css(); |
|
| 56 | + $variables['styles'] = drupal_get_css(); |
|
| 57 | + $variables['scripts'] = drupal_get_js(); |
|
| 58 | + $variables['tabs'] = theme('menu_local_tasks'); |
|
| 59 | + $variables['title'] = drupal_get_title(); |
|
| 60 | + // Closure should be filled last. |
|
| 61 | + $variables['closure'] = theme('closure'); |
|
| 62 | 62 | } |
| 63 | 63 | |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | * plugin meta-information as values. |
| 37 | 37 | */ |
| 38 | 38 | function hook_wysiwyg_plugin($editor, $version) { |
| 39 | - switch ($editor) { |
|
| 39 | + switch ($editor) { |
|
| 40 | 40 | case 'tinymce': |
| 41 | 41 | if ($version > 3) { |
| 42 | 42 | return array( |
| 43 | - 'myplugin' => array( |
|
| 43 | + 'myplugin' => array( |
|
| 44 | 44 | // A URL to the plugin's homepage. |
| 45 | 45 | 'url' => 'http://drupal.org/project/img_assist', |
| 46 | 46 | // The full path to the native editor plugin, no trailing slash. |
@@ -54,19 +54,19 @@ discard block |
||
| 54 | 54 | // match the corresponding JavaScript implementation. The value is |
| 55 | 55 | // is displayed on the editor configuration form only. |
| 56 | 56 | 'buttons' => array( |
| 57 | - 'img_assist' => t('Image Assist'), |
|
| 57 | + 'img_assist' => t('Image Assist'), |
|
| 58 | 58 | ), |
| 59 | 59 | // A list of editor extensions provided by this native plugin. |
| 60 | 60 | // Extensions are not displayed as buttons and touch the editor's |
| 61 | 61 | // internals, so you should know what you are doing. |
| 62 | 62 | 'extensions' => array( |
| 63 | - 'imce' => t('IMCE'), |
|
| 63 | + 'imce' => t('IMCE'), |
|
| 64 | 64 | ), |
| 65 | 65 | // A list of global, native editor configuration settings to |
| 66 | 66 | // override. To be used rarely and only when required. |
| 67 | 67 | 'options' => array( |
| 68 | - 'file_browser_callback' => 'imceImageBrowser', |
|
| 69 | - 'inline_styles' => TRUE, |
|
| 68 | + 'file_browser_callback' => 'imceImageBrowser', |
|
| 69 | + 'inline_styles' => TRUE, |
|
| 70 | 70 | ), |
| 71 | 71 | // Boolean whether the editor needs to load this plugin. When TRUE, |
| 72 | 72 | // the editor will automatically load the plugin based on the 'path' |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | 'internal' => TRUE, |
| 82 | 82 | // TinyMCE-specific: Additional HTML elements to allow in the markup. |
| 83 | 83 | 'extended_valid_elements' => array( |
| 84 | - 'img[class|src|border=0|alt|title|width|height|align|name|style]', |
|
| 84 | + 'img[class|src|border=0|alt|title|width|height|align|name|style]', |
|
| 85 | + ), |
|
| 85 | 86 | ), |
| 86 | - ), |
|
| 87 | 87 | ); |
| 88 | - } |
|
| 89 | - break; |
|
| 90 | - } |
|
| 88 | + } |
|
| 89 | + break; |
|
| 90 | + } |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -101,12 +101,12 @@ discard block |
||
| 101 | 101 | * Wysiwyg module. |
| 102 | 102 | */ |
| 103 | 103 | function hook_wysiwyg_include_directory($type) { |
| 104 | - switch ($type) { |
|
| 104 | + switch ($type) { |
|
| 105 | 105 | case 'plugins': |
| 106 | 106 | // You can just return $type, if you place your Wysiwyg plugins into a |
| 107 | 107 | // sub-directory named 'plugins'. |
| 108 | 108 | return $type; |
| 109 | - } |
|
| 109 | + } |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * Meta information about the buttons provided by this plugin. |
| 137 | 137 | */ |
| 138 | 138 | function hook_INCLUDE_plugin() { |
| 139 | - $plugins['awesome'] = array( |
|
| 139 | + $plugins['awesome'] = array( |
|
| 140 | 140 | // The plugin's title; defaulting to its internal name ('awesome'). |
| 141 | 141 | 'title' => t('Awesome plugin'), |
| 142 | 142 | // The (vendor) homepage of this plugin; defaults to ''. |
@@ -165,11 +165,11 @@ discard block |
||
| 165 | 165 | ), |
| 166 | 166 | // TinyMCE-specific: Additional HTML elements to allow in the markup. |
| 167 | 167 | 'extended_valid_elements' => array( |
| 168 | - 'tag1[attribute1|attribute2]', |
|
| 169 | - 'tag2[attribute3|attribute4]', |
|
| 168 | + 'tag1[attribute1|attribute2]', |
|
| 169 | + 'tag2[attribute3|attribute4]', |
|
| 170 | 170 | ), |
| 171 | - ); |
|
| 172 | - return $plugins; |
|
| 171 | + ); |
|
| 172 | + return $plugins; |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -196,11 +196,11 @@ discard block |
||
| 196 | 196 | * - theme: The name of the editor theme/skin. |
| 197 | 197 | */ |
| 198 | 198 | function hook_wysiwyg_editor_settings_alter(&$settings, $context) { |
| 199 | - // Each editor has its own collection of native settings that may be extended |
|
| 200 | - // or overridden. Please consult the respective official vendor documentation |
|
| 201 | - // for details. |
|
| 202 | - if ($context['profile']->editor == 'tinymce') { |
|
| 199 | + // Each editor has its own collection of native settings that may be extended |
|
| 200 | + // or overridden. Please consult the respective official vendor documentation |
|
| 201 | + // for details. |
|
| 202 | + if ($context['profile']->editor == 'tinymce') { |
|
| 203 | 203 | // Supported values to JSON data types. |
| 204 | 204 | $settings['cleanup_on_startup'] = TRUE; |
| 205 | - } |
|
| 205 | + } |
|
| 206 | 206 | } |
@@ -17,14 +17,14 @@ |
||
| 17 | 17 | * Implementation of hook_menu(). |
| 18 | 18 | */ |
| 19 | 19 | function forum_tweaks_menu() { |
| 20 | - // Note that this comes straight out of the Advanced Forum module. As such, |
|
| 21 | - // it should be removed should said module be added at a future point in time |
|
| 22 | - $items['community/forum/%/read'] = array( |
|
| 20 | + // Note that this comes straight out of the Advanced Forum module. As such, |
|
| 21 | + // it should be removed should said module be added at a future point in time |
|
| 22 | + $items['community/forum/%/read'] = array( |
|
| 23 | 23 | 'access callback' => 'forum_tweaks_markasread_access', |
| 24 | 24 | 'page arguments' => array(2), |
| 25 | 25 | 'page callback' => 'forum_tweaks_markasread', |
| 26 | 26 | 'type' => MENU_CALLBACK, |
| 27 | 27 | 'file' => 'includes/mark-read.inc', |
| 28 | - ); |
|
| 29 | - return $items; |
|
| 28 | + ); |
|
| 29 | + return $items; |
|
| 30 | 30 | } |
@@ -13,31 +13,31 @@ discard block |
||
| 13 | 13 | * Either fill a $links array or return a string version of the link to mark read. |
| 14 | 14 | */ |
| 15 | 15 | function forum_tweaks_get_mark_read_link($tid = 0, &$links = array()) { |
| 16 | - if (forum_tweaks_markasread_access() && !in_array($tid, variable_get('forum_containers', array()))) { |
|
| 16 | + if (forum_tweaks_markasread_access() && !in_array($tid, variable_get('forum_containers', array()))) { |
|
| 17 | 17 | if ($tid) { |
| 18 | - $links['mark-read']['title'] = t('Mark all topics read'); |
|
| 19 | - $links['mark-read']['href'] = "community/forum/{$tid}/read"; |
|
| 18 | + $links['mark-read']['title'] = t('Mark all topics read'); |
|
| 19 | + $links['mark-read']['href'] = "community/forum/{$tid}/read"; |
|
| 20 | 20 | |
| 21 | - return l(t('Mark all topics read') . '<span class="image-replace"></span>', "forum/markasread/$tid", array('html' => TRUE)); |
|
| 21 | + return l(t('Mark all topics read') . '<span class="image-replace"></span>', "forum/markasread/$tid", array('html' => TRUE)); |
|
| 22 | 22 | } |
| 23 | 23 | else { |
| 24 | - $links['mark-read']['title'] = t('Mark all forums read'); |
|
| 25 | - $links['mark-read']['href'] = "community/forum/0/read"; |
|
| 24 | + $links['mark-read']['title'] = t('Mark all forums read'); |
|
| 25 | + $links['mark-read']['href'] = "community/forum/0/read"; |
|
| 26 | 26 | |
| 27 | - return l(t('Mark all forums read') . '<span class="image-replace"></span>', "forum/markasread", array('html' => TRUE)); |
|
| 27 | + return l(t('Mark all forums read') . '<span class="image-replace"></span>', "forum/markasread", array('html' => TRUE)); |
|
| 28 | + } |
|
| 28 | 29 | } |
| 29 | - } |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * Marks all posts in forums or in a given forum as read by the current user. |
| 34 | 34 | */ |
| 35 | 35 | function forum_tweaks_markasread($current_forum_id = 0) { |
| 36 | - global $user; |
|
| 36 | + global $user; |
|
| 37 | 37 | |
| 38 | - // See if we're on a forum or on the forum overview |
|
| 39 | - // Path will be /forum/markasread or /forum/markasread/tid |
|
| 40 | - if ($current_forum_id) { |
|
| 38 | + // See if we're on a forum or on the forum overview |
|
| 39 | + // Path will be /forum/markasread or /forum/markasread/tid |
|
| 40 | + if ($current_forum_id) { |
|
| 41 | 41 | // Delete the current history entries so already visited nodes get updated. |
| 42 | 42 | $sql = "DELETE h |
| 43 | 43 | FROM {history} AS h |
@@ -58,26 +58,26 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | // Readpath integration |
| 60 | 60 | if (module_exists('readpath')) { |
| 61 | - readpath_clear_readpath(); |
|
| 61 | + readpath_clear_readpath(); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | drupal_set_message(t('All content in this forum has been marked as read')); |
| 65 | 65 | drupal_goto('community/forum/' . $current_forum_id); |
| 66 | - } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - // We are on the forum overview, requesting all forums be marked read |
|
| 69 | - $forum_vocabulary_id = variable_get('forum_nav_vocabulary', ''); |
|
| 68 | + // We are on the forum overview, requesting all forums be marked read |
|
| 69 | + $forum_vocabulary_id = variable_get('forum_nav_vocabulary', ''); |
|
| 70 | 70 | |
| 71 | - // Delete the current history entries so already visited nodes get updated. |
|
| 72 | - $sql = "DELETE h |
|
| 71 | + // Delete the current history entries so already visited nodes get updated. |
|
| 72 | + $sql = "DELETE h |
|
| 73 | 73 | FROM {history} AS h |
| 74 | 74 | INNER JOIN {term_node} AS tn ON (h.nid = tn.nid) |
| 75 | 75 | INNER JOIN {term_data} AS td ON (td.tid = tn.tid) |
| 76 | 76 | WHERE h.uid = %d AND td.vid = %d"; |
| 77 | - db_query($sql, $user->uid, $forum_vocabulary_id); |
|
| 77 | + db_query($sql, $user->uid, $forum_vocabulary_id); |
|
| 78 | 78 | |
| 79 | - // Update the history table with all forum nodes newer than the cutoff. |
|
| 80 | - $sql = "INSERT INTO {history} (uid, nid, timestamp) |
|
| 79 | + // Update the history table with all forum nodes newer than the cutoff. |
|
| 80 | + $sql = "INSERT INTO {history} (uid, nid, timestamp) |
|
| 81 | 81 | SELECT DISTINCT %d, n.nid, %d |
| 82 | 82 | FROM {node} AS n |
| 83 | 83 | INNER JOIN {term_node} AS tn ON n.nid=tn.nid |
@@ -85,12 +85,12 @@ discard block |
||
| 85 | 85 | INNER JOIN {term_data} AS td ON tn.tid = td.tid |
| 86 | 86 | WHERE (n.changed > %d OR ncs.last_comment_timestamp > %d) AND td.vid = %d"; |
| 87 | 87 | |
| 88 | - $args = array($user->uid, time(), NODE_NEW_LIMIT, NODE_NEW_LIMIT, $forum_vocabulary_id); |
|
| 88 | + $args = array($user->uid, time(), NODE_NEW_LIMIT, NODE_NEW_LIMIT, $forum_vocabulary_id); |
|
| 89 | 89 | |
| 90 | - db_query($sql, $args); |
|
| 90 | + db_query($sql, $args); |
|
| 91 | 91 | |
| 92 | - drupal_set_message(t('All forum content has been marked as read')); |
|
| 93 | - drupal_goto('community/forum'); |
|
| 92 | + drupal_set_message(t('All forum content has been marked as read')); |
|
| 93 | + drupal_goto('community/forum'); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -101,6 +101,6 @@ discard block |
||
| 101 | 101 | * cached and re-used for other users. |
| 102 | 102 | */ |
| 103 | 103 | function forum_tweaks_markasread_access() { |
| 104 | - global $user; |
|
| 105 | - return user_access('access content') && $user->uid; |
|
| 104 | + global $user; |
|
| 105 | + return user_access('access content') && $user->uid; |
|
| 106 | 106 | } |
@@ -2,38 +2,38 @@ discard block |
||
| 2 | 2 | // $Id: bbcode.module,v 1.50 2008/02/07 14:05:30 naudefj Exp $ |
| 3 | 3 | |
| 4 | 4 | function bbcode_help($section) { |
| 5 | - if ($section == 'admin/modules#description') |
|
| 5 | + if ($section == 'admin/modules#description') |
|
| 6 | 6 | return t('Allow the use of BBCode in your posts.'); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | function bbcode_filter_tips($delta, $format, $long = false) { |
| 10 | - if ($long) { |
|
| 10 | + if ($long) { |
|
| 11 | 11 | include_once(drupal_get_path('module', 'bbcode') .'/bbcode-help.inc'); |
| 12 | 12 | return _bbcode_filter_tip(); |
| 13 | - } |
|
| 14 | - else { |
|
| 13 | + } |
|
| 14 | + else { |
|
| 15 | 15 | # D5: $output = t('You can use !BBCode tags in the text.', array('!BBCode' => l(t('BBCode'), "filter/tips/$format", NULL, NULL, 'filter-bbcode-' . $delta))); |
| 16 | 16 | $output = t('You can use !BBCode (opens in new window) tags in the text.', |
| 17 | - array( |
|
| 17 | + array( |
|
| 18 | 18 | '!BBCode' => l(t('BBCode'), "filter/tips/$format", |
| 19 | 19 | array( |
| 20 | - 'fragment' => 'filter-bbcode-' . $delta, |
|
| 21 | - 'attributes' => |
|
| 22 | - array( |
|
| 23 | - 'target'=>'_blank', |
|
| 24 | - 'rel'=>'noopener noreferrer', |
|
| 25 | - ), |
|
| 20 | + 'fragment' => 'filter-bbcode-' . $delta, |
|
| 21 | + 'attributes' => |
|
| 22 | + array( |
|
| 23 | + 'target'=>'_blank', |
|
| 24 | + 'rel'=>'noopener noreferrer', |
|
| 25 | + ), |
|
| 26 | 26 | )) |
| 27 | - )); |
|
| 27 | + )); |
|
| 28 | 28 | if (variable_get("bbcode_make_links_$format", FALSE)) { |
| 29 | - $output .= ' '. t('URLs will automatically be converted to links.'); |
|
| 29 | + $output .= ' '. t('URLs will automatically be converted to links.'); |
|
| 30 | 30 | } |
| 31 | 31 | return $output; |
| 32 | - } |
|
| 32 | + } |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | function bbcode_filter($op, $delta = 0, $format = -1, $text = '') { |
| 36 | - switch ($op) { |
|
| 36 | + switch ($op) { |
|
| 37 | 37 | case 'list': |
| 38 | 38 | return array(0 => t('BBCode')); |
| 39 | 39 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | case 'process': |
| 44 | 44 | include_once(drupal_get_path('module', 'bbcode') .'/bbcode-filter.inc'); |
| 45 | - if (variable_get("bbcode_debug_$format", 0)) { |
|
| 45 | + if (variable_get("bbcode_debug_$format", 0)) { |
|
| 46 | 46 | $timing_start = explode(' ', microtime()); |
| 47 | 47 | $ret = _bbcode_filter_process($text, $format); |
| 48 | 48 | $timing_stop = explode(' ', microtime()); |
@@ -50,99 +50,99 @@ discard block |
||
| 50 | 50 | $elapsed += $timing_stop[0] - $timing_start[0]; |
| 51 | 51 | $ret .= '<hr />'. l('BBCode', "filter/tips/$format") .' parsed on '.date('r').'<br />Execution time: '.$elapsed.' seconds.<hr />'; |
| 52 | 52 | return $ret; |
| 53 | - } |
|
| 54 | - else |
|
| 53 | + } |
|
| 54 | + else |
|
| 55 | 55 | return _bbcode_filter_process($text, $format); |
| 56 | 56 | |
| 57 | 57 | case 'settings': |
| 58 | 58 | $form = array(); |
| 59 | - $form['bbcode_filter'] = array( |
|
| 59 | + $form['bbcode_filter'] = array( |
|
| 60 | 60 | '#type' => 'fieldset', |
| 61 | 61 | '#title' => t('BBCode filter'), |
| 62 | 62 | '#collapsible' => TRUE, |
| 63 | 63 | '#collapsed' => FALSE); |
| 64 | - $form['bbcode_filter']["bbcode_make_links_$format"] = array( |
|
| 64 | + $form['bbcode_filter']["bbcode_make_links_$format"] = array( |
|
| 65 | 65 | '#type' => 'select', |
| 66 | 66 | '#title' => t('Convert addresses to links'), |
| 67 | 67 | '#default_value' => variable_get("bbcode_make_links_$format", 1), |
| 68 | 68 | '#options' => array(t('Disabled'), t('Enabled')), |
| 69 | 69 | '#description' => t('Turn web and e-mail addresses into clickable links. This is useful if content authors do not explicitly mark addresses as links with [url] and [email] tags.')); |
| 70 | - $form['bbcode_filter']["bbcode_filter_nofollow_$format"] = array( |
|
| 70 | + $form['bbcode_filter']["bbcode_filter_nofollow_$format"] = array( |
|
| 71 | 71 | '#type' => 'select', |
| 72 | 72 | '#title' => t('Spam link deterrent'), |
| 73 | 73 | '#default_value' => variable_get("bbcode_filter_nofollow_$format", 0), |
| 74 | 74 | '#options' => array(t('Disabled'), t('Enabled')), |
| 75 | 75 | '#description' => t('If enabled, BBCode will add rel="nofollow" to all links, as a measure to reduce the effectiveness of spam links. Note: this will also prevent valid links from being followed by search engines, therefore it is likely most effective when enabled for anonymous users.')); |
| 76 | - $form['bbcode_filter']["bbcode_encode_mailto_$format"] = array( |
|
| 76 | + $form['bbcode_filter']["bbcode_encode_mailto_$format"] = array( |
|
| 77 | 77 | '#type' => 'select', |
| 78 | 78 | '#title' => t('Email address encoding'), |
| 79 | 79 | '#default_value' => variable_get("bbcode_encode_mailto_$format", 1), |
| 80 | 80 | '#options' => array(t('Disabled'), t('Enabled')), |
| 81 | 81 | '#description' => t('Whether to encode email addresses with javascript. With this method you will have clickable mailto links, but it will be a bit harder for spam robots to collect them.')); |
| 82 | - $form['bbcode_filter']["bbcode_paragraph_breaks_$format"] = array( |
|
| 82 | + $form['bbcode_filter']["bbcode_paragraph_breaks_$format"] = array( |
|
| 83 | 83 | '#type' => 'select', |
| 84 | 84 | '#title' => t('Smart paragraph and line breaks'), |
| 85 | 85 | '#default_value' => variable_get("bbcode_paragraph_breaks_$format", 2), |
| 86 | 86 | '#options' => array(t('Disabled'), t('Line breaks only'), t('Line and paragraph breaks')), |
| 87 | 87 | '#description' => t('Add line and paragraph breaks to text, excluding text in preformatted code blocks. If you disable this option, you need to enable Drupal\'s "Line break converter". Don\'t use both together!')); |
| 88 | - $form['bbcode_filter']["bbcode_debug_$format"] = array( |
|
| 88 | + $form['bbcode_filter']["bbcode_debug_$format"] = array( |
|
| 89 | 89 | '#type' => 'select', |
| 90 | 90 | '#title' => t('Print debugging info'), |
| 91 | 91 | '#default_value' => variable_get("bbcode_debug_$format", 0), |
| 92 | 92 | '#options' => array(t('Disabled'), t('Enabled')), |
| 93 | 93 | '#description' => t('Print BBCode parse date and execution time. This option should be disabled on production sites. You may need to clear the cache after changing this option.')); |
| 94 | - return $form; |
|
| 94 | + return $form; |
|
| 95 | 95 | |
| 96 | 96 | default: |
| 97 | 97 | return $text; |
| 98 | - } |
|
| 98 | + } |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /* hook_quicktags_alter |
| 102 | 102 | * Alter icons if the quicktags module is enabled |
| 103 | 103 | */ |
| 104 | 104 | function bbcode_quicktags_alter($items) { |
| 105 | - $path = base_path() . drupal_get_path('module','quicktags') .'/'; |
|
| 106 | - $items['ed_italic'] = array( |
|
| 107 | - 'name' => 'italic', |
|
| 108 | - 'prefix' => '[i]', |
|
| 109 | - 'suffix' => '[/i]', |
|
| 110 | - 'accesskey' => 'i', |
|
| 111 | - 'weight' => 10, |
|
| 112 | - 'icon' => $path .'ed_italic.png', |
|
| 105 | + $path = base_path() . drupal_get_path('module','quicktags') .'/'; |
|
| 106 | + $items['ed_italic'] = array( |
|
| 107 | + 'name' => 'italic', |
|
| 108 | + 'prefix' => '[i]', |
|
| 109 | + 'suffix' => '[/i]', |
|
| 110 | + 'accesskey' => 'i', |
|
| 111 | + 'weight' => 10, |
|
| 112 | + 'icon' => $path .'ed_italic.png', |
|
| 113 | 113 | ); |
| 114 | - $items['ed_bold'] = array( |
|
| 115 | - 'name' => 'bold', |
|
| 116 | - 'prefix' => '[b]', |
|
| 117 | - 'suffix' => '[/b]', |
|
| 118 | - 'accesskey' => 'b', |
|
| 119 | - 'weight' => 20, |
|
| 120 | - 'icon' => $path .'ed_bold.png', |
|
| 114 | + $items['ed_bold'] = array( |
|
| 115 | + 'name' => 'bold', |
|
| 116 | + 'prefix' => '[b]', |
|
| 117 | + 'suffix' => '[/b]', |
|
| 118 | + 'accesskey' => 'b', |
|
| 119 | + 'weight' => 20, |
|
| 120 | + 'icon' => $path .'ed_bold.png', |
|
| 121 | 121 | ); |
| 122 | - $items['ed_code'] = array( |
|
| 123 | - 'name' => 'code', |
|
| 124 | - 'prefix' =>'[code]', |
|
| 125 | - 'suffix' => '[/code]', |
|
| 126 | - 'accesskey' => 'c', |
|
| 127 | - 'weight' => 30, |
|
| 128 | - 'icon' => $path .'ed_code.png', |
|
| 122 | + $items['ed_code'] = array( |
|
| 123 | + 'name' => 'code', |
|
| 124 | + 'prefix' =>'[code]', |
|
| 125 | + 'suffix' => '[/code]', |
|
| 126 | + 'accesskey' => 'c', |
|
| 127 | + 'weight' => 30, |
|
| 128 | + 'icon' => $path .'ed_code.png', |
|
| 129 | 129 | ); |
| 130 | - $items['ed_block'] = array( |
|
| 131 | - 'name' => 'quote', |
|
| 132 | - 'prefix' =>'[quote]', |
|
| 133 | - 'suffix' => '[/quote]', |
|
| 134 | - 'accesskey' => 'q', |
|
| 135 | - 'weight' => 40, |
|
| 136 | - 'icon' => $path .'ed_block.png', |
|
| 130 | + $items['ed_block'] = array( |
|
| 131 | + 'name' => 'quote', |
|
| 132 | + 'prefix' =>'[quote]', |
|
| 133 | + 'suffix' => '[/quote]', |
|
| 134 | + 'accesskey' => 'q', |
|
| 135 | + 'weight' => 40, |
|
| 136 | + 'icon' => $path .'ed_block.png', |
|
| 137 | 137 | ); |
| 138 | - $items['ed_link'] = array( |
|
| 139 | - 'name' => 'link', |
|
| 140 | - 'prefix' =>'[url=http://]', |
|
| 141 | - 'suffix' => '[/url]', |
|
| 142 | - 'accesskey' => 'l', |
|
| 143 | - 'weight' => 50, |
|
| 144 | - 'icon' => $path .'ed_link.png', |
|
| 138 | + $items['ed_link'] = array( |
|
| 139 | + 'name' => 'link', |
|
| 140 | + 'prefix' =>'[url=http://]', |
|
| 141 | + 'suffix' => '[/url]', |
|
| 142 | + 'accesskey' => 'l', |
|
| 143 | + 'weight' => 50, |
|
| 144 | + 'icon' => $path .'ed_link.png', |
|
| 145 | 145 | ); |
| 146 | - return $items; |
|
| 146 | + return $items; |
|
| 147 | 147 | } |
| 148 | 148 | |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | // $Id: bbcode-help.inc,v 1.8 2007/01/28 21:18:45 naudefj Exp $ |
| 3 | 3 | |
| 4 | 4 | function _bbcode_filter_tip() { |
| 5 | - return t("<a id=\"filter-bbcode\"></a><h2>BBCode Guide</h2> |
|
| 5 | + return t("<a id=\"filter-bbcode\"></a><h2>BBCode Guide</h2> |
|
| 6 | 6 | |
| 7 | 7 | <p> |
| 8 | 8 | BBCode allows you to specify formatting rules for your text, |
@@ -9,10 +9,10 @@ |
||
| 9 | 9 | * Implementation of hook_wysiwyg_editor_settings_alter(). |
| 10 | 10 | */ |
| 11 | 11 | function wysiwyg_tweaks_wysiwyg_editor_settings_alter(&$settings, $context) { |
| 12 | - if ($context['profile']->editor == 'tinymce') { |
|
| 12 | + if ($context['profile']->editor == 'tinymce') { |
|
| 13 | 13 | $settings['browser_spellcheck'] = TRUE; |
| 14 | 14 | $settings['gecko_spellcheck'] = TRUE; |
| 15 | 15 | // Any init setting taking a string, boolean, number, or an array/object |
| 16 | 16 | // holding those types can be overridden/forced here. |
| 17 | - } |
|
| 17 | + } |
|
| 18 | 18 | } |
@@ -29,46 +29,46 @@ discard block |
||
| 29 | 29 | * Create an array of default values for a field type. |
| 30 | 30 | */ |
| 31 | 31 | function content_field_default_values($field_type) { |
| 32 | - $field_types = _content_field_types(); |
|
| 33 | - $module = $field_types[$field_type]['module']; |
|
| 32 | + $field_types = _content_field_types(); |
|
| 33 | + $module = $field_types[$field_type]['module']; |
|
| 34 | 34 | |
| 35 | - $field = array( |
|
| 35 | + $field = array( |
|
| 36 | 36 | 'module' => $module, |
| 37 | 37 | 'type' => $field_type, |
| 38 | 38 | 'active' => 0, |
| 39 | - ); |
|
| 39 | + ); |
|
| 40 | 40 | |
| 41 | - if (module_exists($module)) { |
|
| 41 | + if (module_exists($module)) { |
|
| 42 | 42 | $field['active'] = 1; |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - $field['columns'] = (array) module_invoke($module, 'field_settings', 'database columns', $field); |
|
| 46 | - // Ensure columns always default to NULL values. |
|
| 47 | - foreach ($field['columns'] as $column_name => $column) { |
|
| 45 | + $field['columns'] = (array) module_invoke($module, 'field_settings', 'database columns', $field); |
|
| 46 | + // Ensure columns always default to NULL values. |
|
| 47 | + foreach ($field['columns'] as $column_name => $column) { |
|
| 48 | 48 | $field['columns'][$column_name]['not null'] = FALSE; |
| 49 | - } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - $field['required'] = 0; |
|
| 52 | - $field['multiple'] = 0; |
|
| 53 | - $field['db_storage'] = CONTENT_DB_STORAGE_PER_CONTENT_TYPE; |
|
| 51 | + $field['required'] = 0; |
|
| 52 | + $field['multiple'] = 0; |
|
| 53 | + $field['db_storage'] = CONTENT_DB_STORAGE_PER_CONTENT_TYPE; |
|
| 54 | 54 | |
| 55 | - // Make sure field settings all have an index in the array. |
|
| 56 | - $setting_names = (array) module_invoke($module, 'field_settings', 'save', $field); |
|
| 57 | - drupal_alter('field_settings', $setting_names, 'save', $field); |
|
| 58 | - foreach ($setting_names as $setting) { |
|
| 55 | + // Make sure field settings all have an index in the array. |
|
| 56 | + $setting_names = (array) module_invoke($module, 'field_settings', 'save', $field); |
|
| 57 | + drupal_alter('field_settings', $setting_names, 'save', $field); |
|
| 58 | + foreach ($setting_names as $setting) { |
|
| 59 | 59 | $field[$setting] = NULL; |
| 60 | - } |
|
| 61 | - return $field; |
|
| 60 | + } |
|
| 61 | + return $field; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * Create an array of default values for a field instance. |
| 66 | 66 | */ |
| 67 | 67 | function content_instance_default_values($field_name, $type_name, $widget_type) { |
| 68 | - $widget_types = _content_widget_types(); |
|
| 69 | - $module = $widget_types[$widget_type]['module']; |
|
| 68 | + $widget_types = _content_widget_types(); |
|
| 69 | + $module = $widget_types[$widget_type]['module']; |
|
| 70 | 70 | |
| 71 | - $widget = array( |
|
| 71 | + $widget = array( |
|
| 72 | 72 | 'field_name' => $field_name, |
| 73 | 73 | 'type_name' => $type_name, |
| 74 | 74 | 'weight' => 0, |
@@ -78,101 +78,101 @@ discard block |
||
| 78 | 78 | 'widget_module' => $module, |
| 79 | 79 | 'display_settings' => array(), |
| 80 | 80 | 'widget_settings' => array(), |
| 81 | - ); |
|
| 81 | + ); |
|
| 82 | 82 | |
| 83 | - if (module_exists($module)) { |
|
| 83 | + if (module_exists($module)) { |
|
| 84 | 84 | $widget['widget_active'] = 1; |
| 85 | - } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - $settings_names = array_merge(array('label'), array_keys(content_build_modes())); |
|
| 88 | - $widget['display_settings'] = array(); |
|
| 89 | - foreach ($settings_names as $name) { |
|
| 87 | + $settings_names = array_merge(array('label'), array_keys(content_build_modes())); |
|
| 88 | + $widget['display_settings'] = array(); |
|
| 89 | + foreach ($settings_names as $name) { |
|
| 90 | 90 | $widget['display_settings'][$name]['format'] = ($name == 'label') ? 'above' : 'default'; |
| 91 | 91 | $widget['display_settings'][$name]['exclude'] = 0; |
| 92 | - } |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - // Make sure widget settings all have an index in the array. |
|
| 95 | - $settings_names = (array) module_invoke($module, 'widget_settings', 'save', $widget); |
|
| 96 | - drupal_alter('widget_settings', $settings_names, 'save', $widget); |
|
| 97 | - $widget['widget_settings'] = array(); |
|
| 98 | - foreach ($settings_names as $name) { |
|
| 94 | + // Make sure widget settings all have an index in the array. |
|
| 95 | + $settings_names = (array) module_invoke($module, 'widget_settings', 'save', $widget); |
|
| 96 | + drupal_alter('widget_settings', $settings_names, 'save', $widget); |
|
| 97 | + $widget['widget_settings'] = array(); |
|
| 98 | + foreach ($settings_names as $name) { |
|
| 99 | 99 | $widget['widget_settings'][$name] = NULL; |
| 100 | - } |
|
| 101 | - return $widget; |
|
| 100 | + } |
|
| 101 | + return $widget; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | 105 | * Expand field info to create field => widget info. |
| 106 | 106 | */ |
| 107 | 107 | function content_field_instance_expand($field) { |
| 108 | - if (isset($field['widget'])) { |
|
| 108 | + if (isset($field['widget'])) { |
|
| 109 | 109 | return $field; |
| 110 | - } |
|
| 111 | - $field['widget'] = !empty($field['widget_settings']) ? $field['widget_settings'] : array(); |
|
| 112 | - $field['widget']['label'] = !empty($field['label']) ? $field['label'] : $field['field_name']; |
|
| 113 | - $field['widget']['weight'] = !empty($field['weight']) ? $field['weight'] : 0; |
|
| 114 | - $field['widget']['description'] = !empty($field['description']) ? $field['description'] : ''; |
|
| 110 | + } |
|
| 111 | + $field['widget'] = !empty($field['widget_settings']) ? $field['widget_settings'] : array(); |
|
| 112 | + $field['widget']['label'] = !empty($field['label']) ? $field['label'] : $field['field_name']; |
|
| 113 | + $field['widget']['weight'] = !empty($field['weight']) ? $field['weight'] : 0; |
|
| 114 | + $field['widget']['description'] = !empty($field['description']) ? $field['description'] : ''; |
|
| 115 | 115 | |
| 116 | - if (!empty($field['widget_type'])) { |
|
| 116 | + if (!empty($field['widget_type'])) { |
|
| 117 | 117 | $field['widget']['type'] = $field['widget_type']; |
| 118 | 118 | $widget_types = _content_widget_types(); |
| 119 | 119 | $field['widget']['module'] = isset($widget_types[$field['widget_type']]['module']) ? $widget_types[$field['widget_type']]['module'] : $field['widget_module']; |
| 120 | - } |
|
| 121 | - elseif (!empty($field['widget_module'])) { |
|
| 120 | + } |
|
| 121 | + elseif (!empty($field['widget_module'])) { |
|
| 122 | 122 | $field['widget']['module'] = $field['widget_module']; |
| 123 | - } |
|
| 124 | - |
|
| 125 | - unset($field['widget_type']); |
|
| 126 | - unset($field['weight']); |
|
| 127 | - unset($field['label']); |
|
| 128 | - unset($field['description']); |
|
| 129 | - unset($field['widget_module']); |
|
| 130 | - unset($field['widget_settings']); |
|
| 131 | - |
|
| 132 | - // If content.module is handling the default value, |
|
| 133 | - // initialize $widget_settings with default values, |
|
| 134 | - if (isset($field['default_value']) && isset($field['default_value_php']) && |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + unset($field['widget_type']); |
|
| 126 | + unset($field['weight']); |
|
| 127 | + unset($field['label']); |
|
| 128 | + unset($field['description']); |
|
| 129 | + unset($field['widget_module']); |
|
| 130 | + unset($field['widget_settings']); |
|
| 131 | + |
|
| 132 | + // If content.module is handling the default value, |
|
| 133 | + // initialize $widget_settings with default values, |
|
| 134 | + if (isset($field['default_value']) && isset($field['default_value_php']) && |
|
| 135 | 135 | content_callback('widget', 'default value', $field) == CONTENT_CALLBACK_DEFAULT) { |
| 136 | 136 | $field['widget']['default_value'] = !empty($field['default_value']) ? $field['default_value'] : NULL; |
| 137 | 137 | $field['widget']['default_value_php'] = !empty($field['default_value_php']) ? $field['default_value_php'] : NULL; |
| 138 | 138 | unset($field['default_value']); |
| 139 | 139 | unset($field['default_value_php']); |
| 140 | - } |
|
| 141 | - return $field; |
|
| 140 | + } |
|
| 141 | + return $field; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * Collapse field info from field => widget to flattened form values. |
| 146 | 146 | */ |
| 147 | 147 | function content_field_instance_collapse($field) { |
| 148 | - if (!isset($field['widget'])) { |
|
| 148 | + if (!isset($field['widget'])) { |
|
| 149 | 149 | return $field; |
| 150 | - } |
|
| 151 | - $field['widget_settings'] = !empty($field['widget']) ? $field['widget'] : array(); |
|
| 152 | - $field['widget_type'] = !empty($field['widget']['type']) ? $field['widget']['type'] : ''; |
|
| 153 | - $field['weight'] = !empty($field['widget']['weight']) ? $field['widget']['weight'] : 0; |
|
| 154 | - $field['label'] = !empty($field['widget']['label']) ? $field['widget']['label'] : $field['field_name']; |
|
| 155 | - $field['description'] = !empty($field['widget']['description']) ? $field['widget']['description'] : ''; |
|
| 156 | - $field['type_name'] = !empty($field['type_name']) ? $field['type_name'] : ''; |
|
| 157 | - |
|
| 158 | - if (!empty($field['widget']['module'])) { |
|
| 150 | + } |
|
| 151 | + $field['widget_settings'] = !empty($field['widget']) ? $field['widget'] : array(); |
|
| 152 | + $field['widget_type'] = !empty($field['widget']['type']) ? $field['widget']['type'] : ''; |
|
| 153 | + $field['weight'] = !empty($field['widget']['weight']) ? $field['widget']['weight'] : 0; |
|
| 154 | + $field['label'] = !empty($field['widget']['label']) ? $field['widget']['label'] : $field['field_name']; |
|
| 155 | + $field['description'] = !empty($field['widget']['description']) ? $field['widget']['description'] : ''; |
|
| 156 | + $field['type_name'] = !empty($field['type_name']) ? $field['type_name'] : ''; |
|
| 157 | + |
|
| 158 | + if (!empty($field['widget']['module'])) { |
|
| 159 | 159 | $widget_module = $field['widget']['module']; |
| 160 | - } |
|
| 161 | - elseif (!empty($field['widget']['type'])) { |
|
| 160 | + } |
|
| 161 | + elseif (!empty($field['widget']['type'])) { |
|
| 162 | 162 | $widget_types = _content_widget_types(); |
| 163 | 163 | $widget_module = $widget_types[$field['widget']['type']]['module']; |
| 164 | - } |
|
| 165 | - else { |
|
| 164 | + } |
|
| 165 | + else { |
|
| 166 | 166 | $widget_module = ''; |
| 167 | - } |
|
| 168 | - $field['widget_module'] = $widget_module; |
|
| 169 | - unset($field['widget_settings']['type']); |
|
| 170 | - unset($field['widget_settings']['weight']); |
|
| 171 | - unset($field['widget_settings']['label']); |
|
| 172 | - unset($field['widget_settings']['description']); |
|
| 173 | - unset($field['widget_settings']['module']); |
|
| 174 | - unset($field['widget']); |
|
| 175 | - return $field; |
|
| 167 | + } |
|
| 168 | + $field['widget_module'] = $widget_module; |
|
| 169 | + unset($field['widget_settings']['type']); |
|
| 170 | + unset($field['widget_settings']['weight']); |
|
| 171 | + unset($field['widget_settings']['label']); |
|
| 172 | + unset($field['widget_settings']['description']); |
|
| 173 | + unset($field['widget_settings']['module']); |
|
| 174 | + unset($field['widget']); |
|
| 175 | + return $field; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -208,15 +208,15 @@ discard block |
||
| 208 | 208 | * @see menu_rebuild() |
| 209 | 209 | */ |
| 210 | 210 | function content_field_instance_create($field, $rebuild = TRUE) { |
| 211 | - include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc'); |
|
| 211 | + include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc'); |
|
| 212 | 212 | |
| 213 | - $form_values = $field; |
|
| 214 | - $field = content_field_instance_expand($field); |
|
| 213 | + $form_values = $field; |
|
| 214 | + $field = content_field_instance_expand($field); |
|
| 215 | 215 | |
| 216 | - // If there are prior instances, fill out missing values from the prior values, |
|
| 217 | - // otherwise get missing values from default values. |
|
| 218 | - $prior_instances = content_field_instance_read(array('field_name' => $field['field_name'])); |
|
| 219 | - if (!empty($prior_instances) && is_array($prior_instances)) { |
|
| 216 | + // If there are prior instances, fill out missing values from the prior values, |
|
| 217 | + // otherwise get missing values from default values. |
|
| 218 | + $prior_instances = content_field_instance_read(array('field_name' => $field['field_name'])); |
|
| 219 | + if (!empty($prior_instances) && is_array($prior_instances)) { |
|
| 220 | 220 | $prev_field = content_field_instance_expand($prior_instances[0]); |
| 221 | 221 | |
| 222 | 222 | // Weight, label, and description may have been forced into the $field |
@@ -226,72 +226,72 @@ discard block |
||
| 226 | 226 | $field['widget']['weight'] = isset($form_values['weight']) ? $form_values['weight'] : $prev_field['widget']['weight']; |
| 227 | 227 | $field['widget']['label'] = isset($form_values['label']) ? $form_values['label'] : $prev_field['widget']['label']; |
| 228 | 228 | $field['widget']['description'] = isset($form_values['description']) ? $form_values['description'] : $prev_field['widget']['description']; |
| 229 | - } |
|
| 230 | - else { |
|
| 229 | + } |
|
| 230 | + else { |
|
| 231 | 231 | $prev_field = array('widget' => array()); |
| 232 | - } |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - // If we have a field type, we can build default values for this field type. |
|
| 235 | - $default_values = array('widget' => array()); |
|
| 236 | - if (isset($field['type'])) { |
|
| 234 | + // If we have a field type, we can build default values for this field type. |
|
| 235 | + $default_values = array('widget' => array()); |
|
| 236 | + if (isset($field['type'])) { |
|
| 237 | 237 | $default_values = content_field_default_values($field['type']); |
| 238 | 238 | $default_instance_values = content_instance_default_values($field['field_name'], $field['type_name'], $field['widget']['type']); |
| 239 | 239 | $default_values = content_field_instance_expand(array_merge($default_values, $default_instance_values)); |
| 240 | - } |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | - // Merge default values, previous values, and current values to create |
|
| 243 | - // a complete field array. |
|
| 244 | - $widget = array_merge($default_values['widget'], $prev_field['widget'], $field['widget']); |
|
| 245 | - $field = array_merge($default_values, $prev_field, $field); |
|
| 246 | - $field['widget'] = $widget; |
|
| 242 | + // Merge default values, previous values, and current values to create |
|
| 243 | + // a complete field array. |
|
| 244 | + $widget = array_merge($default_values['widget'], $prev_field['widget'], $field['widget']); |
|
| 245 | + $field = array_merge($default_values, $prev_field, $field); |
|
| 246 | + $field['widget'] = $widget; |
|
| 247 | 247 | |
| 248 | - // Make sure we know what module to invoke for field info. |
|
| 249 | - if (empty($field['module']) && !empty($field['type'])) { |
|
| 248 | + // Make sure we know what module to invoke for field info. |
|
| 249 | + if (empty($field['module']) && !empty($field['type'])) { |
|
| 250 | 250 | $field_types = _content_field_types(); |
| 251 | 251 | $field['module'] = $field_types[$field['type']]['module']; |
| 252 | - } |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | - // The storage type may need to be updated. |
|
| 255 | - $field['db_storage'] = content_storage_type($field); |
|
| 254 | + // The storage type may need to be updated. |
|
| 255 | + $field['db_storage'] = content_storage_type($field); |
|
| 256 | 256 | |
| 257 | - // Get a fresh copy of the column information whenever a field is created. |
|
| 258 | - $field['columns'] = (array) module_invoke($field['module'], 'field_settings', 'database columns', $field); |
|
| 257 | + // Get a fresh copy of the column information whenever a field is created. |
|
| 258 | + $field['columns'] = (array) module_invoke($field['module'], 'field_settings', 'database columns', $field); |
|
| 259 | 259 | |
| 260 | - if (empty($prev_field['widget']) || $prior_instances < 1) { |
|
| 260 | + if (empty($prev_field['widget']) || $prior_instances < 1) { |
|
| 261 | 261 | // If this is the first instance, create the field. |
| 262 | 262 | $field['db_storage'] = $field['multiple'] > 0 ? CONTENT_DB_STORAGE_PER_FIELD : CONTENT_DB_STORAGE_PER_CONTENT_TYPE; |
| 263 | 263 | _content_field_write($field, 'create'); |
| 264 | - } |
|
| 265 | - elseif (!empty($prev_field['widget']) && $prev_field['db_storage'] == CONTENT_DB_STORAGE_PER_CONTENT_TYPE && count($prior_instances) > 0) { |
|
| 264 | + } |
|
| 265 | + elseif (!empty($prev_field['widget']) && $prev_field['db_storage'] == CONTENT_DB_STORAGE_PER_CONTENT_TYPE && count($prior_instances) > 0) { |
|
| 266 | 266 | // If the database storage has changed, update the field and previous instances. |
| 267 | 267 | $field['db_storage'] = CONTENT_DB_STORAGE_PER_FIELD; |
| 268 | 268 | |
| 269 | 269 | foreach ($prior_instances as $instance) { |
| 270 | - $new_instance = $instance; |
|
| 271 | - $new_instance['db_storage'] = CONTENT_DB_STORAGE_PER_FIELD; |
|
| 270 | + $new_instance = $instance; |
|
| 271 | + $new_instance['db_storage'] = CONTENT_DB_STORAGE_PER_FIELD; |
|
| 272 | 272 | |
| 273 | - // Invoke hook_content_fieldapi(). |
|
| 274 | - module_invoke_all('content_fieldapi', 'update instance', $new_instance); |
|
| 273 | + // Invoke hook_content_fieldapi(). |
|
| 274 | + module_invoke_all('content_fieldapi', 'update instance', $new_instance); |
|
| 275 | 275 | |
| 276 | - content_alter_schema($instance, $new_instance); |
|
| 276 | + content_alter_schema($instance, $new_instance); |
|
| 277 | + } |
|
| 277 | 278 | } |
| 278 | - } |
|
| 279 | 279 | |
| 280 | - // Invoke hook_content_fieldapi(). |
|
| 281 | - module_invoke_all('content_fieldapi', 'create instance', $field); |
|
| 280 | + // Invoke hook_content_fieldapi(). |
|
| 281 | + module_invoke_all('content_fieldapi', 'create instance', $field); |
|
| 282 | 282 | |
| 283 | - // Update the field and the instance with the latest values. |
|
| 284 | - _content_field_write($field, 'update'); |
|
| 285 | - _content_field_instance_write($field, 'create'); |
|
| 283 | + // Update the field and the instance with the latest values. |
|
| 284 | + _content_field_write($field, 'update'); |
|
| 285 | + _content_field_instance_write($field, 'create'); |
|
| 286 | 286 | |
| 287 | - content_alter_schema(array(), $field); |
|
| 287 | + content_alter_schema(array(), $field); |
|
| 288 | 288 | |
| 289 | - if ($rebuild) { |
|
| 289 | + if ($rebuild) { |
|
| 290 | 290 | content_clear_type_cache(TRUE); |
| 291 | 291 | menu_rebuild(); |
| 292 | - } |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - return $field; |
|
| 294 | + return $field; |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
@@ -319,44 +319,44 @@ discard block |
||
| 319 | 319 | * @see menu_rebuild() |
| 320 | 320 | */ |
| 321 | 321 | function content_field_instance_update($field, $rebuild = TRUE) { |
| 322 | - include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc'); |
|
| 322 | + include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc'); |
|
| 323 | 323 | |
| 324 | - // Ensure the field description is in the 'expanded' form. |
|
| 325 | - $field = content_field_instance_expand($field); |
|
| 324 | + // Ensure the field description is in the 'expanded' form. |
|
| 325 | + $field = content_field_instance_expand($field); |
|
| 326 | 326 | |
| 327 | - // Get the previous value from the table. |
|
| 328 | - $previous = content_field_instance_read(array('field_name' => $field['field_name'], 'type_name' => $field['type_name'])); |
|
| 329 | - $prev_field = array_pop($previous); |
|
| 327 | + // Get the previous value from the table. |
|
| 328 | + $previous = content_field_instance_read(array('field_name' => $field['field_name'], 'type_name' => $field['type_name'])); |
|
| 329 | + $prev_field = array_pop($previous); |
|
| 330 | 330 | |
| 331 | - // Create a complete field array by merging the previous and current values, |
|
| 332 | - // letting the current values overwrite the previous ones. |
|
| 333 | - $widget = array_merge($prev_field['widget'], $field['widget']); |
|
| 334 | - $field = array_merge($prev_field, $field); |
|
| 335 | - $field['widget'] = $widget; |
|
| 331 | + // Create a complete field array by merging the previous and current values, |
|
| 332 | + // letting the current values overwrite the previous ones. |
|
| 333 | + $widget = array_merge($prev_field['widget'], $field['widget']); |
|
| 334 | + $field = array_merge($prev_field, $field); |
|
| 335 | + $field['widget'] = $widget; |
|
| 336 | 336 | |
| 337 | - // Make sure we know what module to invoke for field info. |
|
| 338 | - if (empty($field['module']) && !empty($field['type'])) { |
|
| 337 | + // Make sure we know what module to invoke for field info. |
|
| 338 | + if (empty($field['module']) && !empty($field['type'])) { |
|
| 339 | 339 | $field_types = _content_field_types(); |
| 340 | 340 | $field['module'] = $field_types[$field['type']]['module']; |
| 341 | - } |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | - // The storage type may need to be updated. |
|
| 344 | - $field['db_storage'] = content_storage_type($field); |
|
| 343 | + // The storage type may need to be updated. |
|
| 344 | + $field['db_storage'] = content_storage_type($field); |
|
| 345 | 345 | |
| 346 | - // Changes in field values may affect columns, or column |
|
| 347 | - // information may have changed, get a fresh copy. |
|
| 348 | - $field['columns'] = (array) module_invoke($field['module'], 'field_settings', 'database columns', $field); |
|
| 346 | + // Changes in field values may affect columns, or column |
|
| 347 | + // information may have changed, get a fresh copy. |
|
| 348 | + $field['columns'] = (array) module_invoke($field['module'], 'field_settings', 'database columns', $field); |
|
| 349 | 349 | |
| 350 | - // If the database storage has changed, update the field and previous instances. |
|
| 351 | - $prior_instances = content_field_instance_read(array('field_name' => $field['field_name'])); |
|
| 350 | + // If the database storage has changed, update the field and previous instances. |
|
| 351 | + $prior_instances = content_field_instance_read(array('field_name' => $field['field_name'])); |
|
| 352 | 352 | |
| 353 | - if ($prev_field['db_storage'] == CONTENT_DB_STORAGE_PER_CONTENT_TYPE && count($prior_instances) > 1) { |
|
| 353 | + if ($prev_field['db_storage'] == CONTENT_DB_STORAGE_PER_CONTENT_TYPE && count($prior_instances) > 1) { |
|
| 354 | 354 | // Update the field's data storage. |
| 355 | 355 | $field['db_storage'] = CONTENT_DB_STORAGE_PER_FIELD; |
| 356 | 356 | |
| 357 | 357 | // Update the schema for prior instances to adapt to the change in db storage. |
| 358 | 358 | foreach ($prior_instances as $instance) { |
| 359 | - if ($instance['type_name'] != $field['type_name']) { |
|
| 359 | + if ($instance['type_name'] != $field['type_name']) { |
|
| 360 | 360 | $new_instance = $instance; |
| 361 | 361 | $new_instance['db_storage'] = CONTENT_DB_STORAGE_PER_FIELD; |
| 362 | 362 | |
@@ -364,30 +364,30 @@ discard block |
||
| 364 | 364 | module_invoke_all('content_fieldapi', 'update instance', $new_instance); |
| 365 | 365 | |
| 366 | 366 | content_alter_schema($instance, $new_instance); |
| 367 | - } |
|
| 367 | + } |
|
| 368 | + } |
|
| 368 | 369 | } |
| 369 | - } |
|
| 370 | 370 | |
| 371 | - // Invoke hook_content_fieldapi(). |
|
| 372 | - module_invoke_all('content_fieldapi', 'update instance', $field); |
|
| 371 | + // Invoke hook_content_fieldapi(). |
|
| 372 | + module_invoke_all('content_fieldapi', 'update instance', $field); |
|
| 373 | 373 | |
| 374 | - // Update the field and the instance with the latest values. |
|
| 375 | - _content_field_write($field, 'update'); |
|
| 376 | - _content_field_instance_write($field, 'update'); |
|
| 374 | + // Update the field and the instance with the latest values. |
|
| 375 | + _content_field_write($field, 'update'); |
|
| 376 | + _content_field_instance_write($field, 'update'); |
|
| 377 | 377 | |
| 378 | - content_alter_schema($prev_field, $field); |
|
| 378 | + content_alter_schema($prev_field, $field); |
|
| 379 | 379 | |
| 380 | - if ($rebuild) { |
|
| 380 | + if ($rebuild) { |
|
| 381 | 381 | content_clear_type_cache(TRUE); |
| 382 | 382 | |
| 383 | 383 | // The label is in the menu tree, so we need a menu rebuild |
| 384 | 384 | // if the label changes. |
| 385 | 385 | if ($prev_field['widget']['label'] != $field['widget']['label']) { |
| 386 | - menu_rebuild(); |
|
| 386 | + menu_rebuild(); |
|
| 387 | + } |
|
| 387 | 388 | } |
| 388 | - } |
|
| 389 | 389 | |
| 390 | - return $field; |
|
| 390 | + return $field; |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | /** |
@@ -397,30 +397,30 @@ discard block |
||
| 397 | 397 | * The field array to process. |
| 398 | 398 | */ |
| 399 | 399 | function _content_field_write($field, $op = 'update') { |
| 400 | - // Rearrange the data to create the global_settings array. |
|
| 401 | - $field['global_settings'] = array(); |
|
| 402 | - $setting_names = (array) module_invoke($field['module'], 'field_settings', 'save', $field); |
|
| 403 | - drupal_alter('field_settings', $setting_names, 'save', $field); |
|
| 400 | + // Rearrange the data to create the global_settings array. |
|
| 401 | + $field['global_settings'] = array(); |
|
| 402 | + $setting_names = (array) module_invoke($field['module'], 'field_settings', 'save', $field); |
|
| 403 | + drupal_alter('field_settings', $setting_names, 'save', $field); |
|
| 404 | 404 | |
| 405 | - foreach ($setting_names as $setting) { |
|
| 405 | + foreach ($setting_names as $setting) { |
|
| 406 | 406 | // Unlike _content_field_instance_write() and 'widget_settings', 'global_settings' |
| 407 | 407 | // is never preexisting, so we take no particular precautions here. |
| 408 | 408 | $field['global_settings'][$setting] = isset($field[$setting]) ? $field[$setting] : ''; |
| 409 | 409 | unset($field[$setting]); |
| 410 | - } |
|
| 411 | - // 'columns' is a reserved word in MySQL4, so our column is named 'db_columns'. |
|
| 412 | - $field['db_columns'] = $field['columns']; |
|
| 410 | + } |
|
| 411 | + // 'columns' is a reserved word in MySQL4, so our column is named 'db_columns'. |
|
| 412 | + $field['db_columns'] = $field['columns']; |
|
| 413 | 413 | |
| 414 | - switch ($op) { |
|
| 414 | + switch ($op) { |
|
| 415 | 415 | case 'create': |
| 416 | 416 | drupal_write_record(content_field_tablename(), $field); |
| 417 | - break; |
|
| 417 | + break; |
|
| 418 | 418 | case 'update': |
| 419 | 419 | drupal_write_record(content_field_tablename(), $field, 'field_name'); |
| 420 | - break; |
|
| 421 | - } |
|
| 422 | - unset($field['db_columns']); |
|
| 423 | - return $field; |
|
| 420 | + break; |
|
| 421 | + } |
|
| 422 | + unset($field['db_columns']); |
|
| 423 | + return $field; |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | /** |
@@ -430,32 +430,32 @@ discard block |
||
| 430 | 430 | * The field array to process. |
| 431 | 431 | */ |
| 432 | 432 | function _content_field_instance_write($field, $op = 'update') { |
| 433 | - // Collapse the field => widget format, so that the values to be saved by |
|
| 434 | - // drupal_write_record are on top-level. |
|
| 435 | - $field = content_field_instance_collapse($field); |
|
| 436 | - |
|
| 437 | - // Rearrange the data to create the widget_settings array. |
|
| 438 | - $setting_names = (array) module_invoke($field['widget_module'], 'widget_settings', 'save', $field); |
|
| 439 | - drupal_alter('widget_settings', $setting_names, 'save', $field); |
|
| 440 | - foreach ($setting_names as $setting) { |
|
| 433 | + // Collapse the field => widget format, so that the values to be saved by |
|
| 434 | + // drupal_write_record are on top-level. |
|
| 435 | + $field = content_field_instance_collapse($field); |
|
| 436 | + |
|
| 437 | + // Rearrange the data to create the widget_settings array. |
|
| 438 | + $setting_names = (array) module_invoke($field['widget_module'], 'widget_settings', 'save', $field); |
|
| 439 | + drupal_alter('widget_settings', $setting_names, 'save', $field); |
|
| 440 | + foreach ($setting_names as $setting) { |
|
| 441 | 441 | // In some cases (when the updated $field was originally read from |
| 442 | 442 | // the db, as opposed to gathered from the values of a form), the values |
| 443 | 443 | // are already in the right place, we take care to not wipe them. |
| 444 | 444 | if (isset($field[$setting])) { |
| 445 | - $field['widget_settings'][$setting] = $field[$setting]; |
|
| 446 | - unset($field[$setting]); |
|
| 445 | + $field['widget_settings'][$setting] = $field[$setting]; |
|
| 446 | + unset($field[$setting]); |
|
| 447 | + } |
|
| 447 | 448 | } |
| 448 | - } |
|
| 449 | 449 | |
| 450 | - switch ($op) { |
|
| 450 | + switch ($op) { |
|
| 451 | 451 | case 'create': |
| 452 | 452 | drupal_write_record(content_instance_tablename(), $field); |
| 453 | - break; |
|
| 453 | + break; |
|
| 454 | 454 | case 'update': |
| 455 | 455 | drupal_write_record(content_instance_tablename(), $field, array('field_name', 'type_name')); |
| 456 | - break; |
|
| 457 | - } |
|
| 458 | - return $field; |
|
| 456 | + break; |
|
| 457 | + } |
|
| 458 | + return $field; |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | /** |
@@ -473,30 +473,30 @@ discard block |
||
| 473 | 473 | * The field arrays. |
| 474 | 474 | */ |
| 475 | 475 | function content_field_instance_read($param = NULL, $include_inactive = FALSE) { |
| 476 | - $cond = array(); |
|
| 477 | - $args = array(); |
|
| 478 | - if (is_array($param)) { |
|
| 476 | + $cond = array(); |
|
| 477 | + $args = array(); |
|
| 478 | + if (is_array($param)) { |
|
| 479 | 479 | // Turn the conditions into a query. |
| 480 | 480 | foreach ($param as $key => $value) { |
| 481 | - $cond[] = 'nfi.'. db_escape_string($key) ." = '%s'"; |
|
| 482 | - $args[] = $value; |
|
| 481 | + $cond[] = 'nfi.'. db_escape_string($key) ." = '%s'"; |
|
| 482 | + $args[] = $value; |
|
| 483 | + } |
|
| 483 | 484 | } |
| 484 | - } |
|
| 485 | - if (!$include_inactive) { |
|
| 485 | + if (!$include_inactive) { |
|
| 486 | 486 | $cond[] = 'nf.active = 1'; |
| 487 | 487 | $cond[] = 'nfi.widget_active = 1'; |
| 488 | - } |
|
| 489 | - $where = $cond ? ' WHERE '. implode(' AND ', $cond) : ''; |
|
| 488 | + } |
|
| 489 | + $where = $cond ? ' WHERE '. implode(' AND ', $cond) : ''; |
|
| 490 | 490 | |
| 491 | - $db_result = db_query("SELECT * FROM {". content_instance_tablename() ."} nfi ". |
|
| 491 | + $db_result = db_query("SELECT * FROM {". content_instance_tablename() ."} nfi ". |
|
| 492 | 492 | " JOIN {". content_field_tablename() ."} nf ON nfi.field_name = nf.field_name ". |
| 493 | 493 | "$where ORDER BY nfi.weight ASC, nfi.label ASC", $args); |
| 494 | 494 | |
| 495 | - $fields = array(); |
|
| 496 | - while ($instance = db_fetch_array($db_result)) { |
|
| 495 | + $fields = array(); |
|
| 496 | + while ($instance = db_fetch_array($db_result)) { |
|
| 497 | 497 | // Unserialize arrays. |
| 498 | 498 | foreach (array('widget_settings', 'display_settings', 'global_settings', 'db_columns') as $key) { |
| 499 | - $instance[$key] = (!empty($instance[$key])) ? (array) unserialize($instance[$key]) : array(); |
|
| 499 | + $instance[$key] = (!empty($instance[$key])) ? (array) unserialize($instance[$key]) : array(); |
|
| 500 | 500 | } |
| 501 | 501 | // 'columns' is a reserved word in MySQL4, so our column is named 'db_columns'. |
| 502 | 502 | $instance['columns'] = $instance['db_columns']; |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | |
| 505 | 505 | // Unfold 'global_settings'. |
| 506 | 506 | foreach ($instance['global_settings'] as $key => $value) { |
| 507 | - $instance[$key] = $value; |
|
| 507 | + $instance[$key] = $value; |
|
| 508 | 508 | } |
| 509 | 509 | unset($instance['global_settings']); |
| 510 | 510 | |
@@ -515,8 +515,8 @@ discard block |
||
| 515 | 515 | // Invoke hook_content_fieldapi(). |
| 516 | 516 | module_invoke_all('content_fieldapi', 'read instance', $field); |
| 517 | 517 | $fields[] = $field; |
| 518 | - } |
|
| 519 | - return $fields; |
|
| 518 | + } |
|
| 519 | + return $fields; |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | /** |
@@ -544,26 +544,26 @@ discard block |
||
| 544 | 544 | * @see menu_rebuild() |
| 545 | 545 | */ |
| 546 | 546 | function content_field_instance_delete($field_name, $type_name, $rebuild = TRUE) { |
| 547 | - include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc'); |
|
| 547 | + include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc'); |
|
| 548 | 548 | |
| 549 | - // Get the previous field value. |
|
| 550 | - $field = array_pop(content_field_instance_read(array('field_name' => $field_name, 'type_name' => $type_name))); |
|
| 549 | + // Get the previous field value. |
|
| 550 | + $field = array_pop(content_field_instance_read(array('field_name' => $field_name, 'type_name' => $type_name))); |
|
| 551 | 551 | |
| 552 | - // Invoke hook_content_fieldapi(). |
|
| 553 | - module_invoke_all('content_fieldapi', 'delete instance', $field); |
|
| 552 | + // Invoke hook_content_fieldapi(). |
|
| 553 | + module_invoke_all('content_fieldapi', 'delete instance', $field); |
|
| 554 | 554 | |
| 555 | - db_query("DELETE FROM {". content_instance_tablename() . |
|
| 555 | + db_query("DELETE FROM {". content_instance_tablename() . |
|
| 556 | 556 | "} WHERE field_name = '%s' AND type_name = '%s'", $field['field_name'], $field['type_name']); |
| 557 | 557 | |
| 558 | - // If no instances remain, delete the field entirely. |
|
| 559 | - $instances = content_field_instance_read(array('field_name' => $field_name)); |
|
| 560 | - if (sizeof($instances) < 1) { |
|
| 558 | + // If no instances remain, delete the field entirely. |
|
| 559 | + $instances = content_field_instance_read(array('field_name' => $field_name)); |
|
| 560 | + if (sizeof($instances) < 1) { |
|
| 561 | 561 | db_query("DELETE FROM {". content_field_tablename() ."} WHERE field_name = '%s'", $field['field_name']); |
| 562 | 562 | content_alter_schema($field, array()); |
| 563 | - } |
|
| 564 | - // If only one instance remains, we may need to change the database |
|
| 565 | - // representation for this field. |
|
| 566 | - elseif (sizeof($instances) == 1 && !($field['multiple'])) { |
|
| 563 | + } |
|
| 564 | + // If only one instance remains, we may need to change the database |
|
| 565 | + // representation for this field. |
|
| 566 | + elseif (sizeof($instances) == 1 && !($field['multiple'])) { |
|
| 567 | 567 | // Multiple-valued fields are always stored per-field-type. |
| 568 | 568 | $instance = $instances[0]; |
| 569 | 569 | $new_instance = $instance; |
@@ -571,23 +571,23 @@ discard block |
||
| 571 | 571 | _content_field_write($new_instance, 'update'); |
| 572 | 572 | |
| 573 | 573 | content_alter_schema($instance, $new_instance); |
| 574 | - } |
|
| 574 | + } |
|
| 575 | 575 | |
| 576 | - // If the deleted instance was the last field for the content type, |
|
| 577 | - // we drop the per-type table. We also consider possibly inactive fields. |
|
| 578 | - if (!content_field_instance_read(array('type_name' => $field['type_name']), TRUE)) { |
|
| 576 | + // If the deleted instance was the last field for the content type, |
|
| 577 | + // we drop the per-type table. We also consider possibly inactive fields. |
|
| 578 | + if (!content_field_instance_read(array('type_name' => $field['type_name']), TRUE)) { |
|
| 579 | 579 | $base_tablename = _content_tablename($field['type_name'], CONTENT_DB_STORAGE_PER_CONTENT_TYPE); |
| 580 | 580 | if (db_table_exists($base_tablename)) { |
| 581 | - db_drop_table($ret, $base_tablename); |
|
| 581 | + db_drop_table($ret, $base_tablename); |
|
| 582 | + } |
|
| 582 | 583 | } |
| 583 | - } |
|
| 584 | 584 | |
| 585 | - if ($rebuild) { |
|
| 585 | + if ($rebuild) { |
|
| 586 | 586 | content_clear_type_cache(TRUE); |
| 587 | 587 | menu_rebuild(); |
| 588 | - } |
|
| 588 | + } |
|
| 589 | 589 | |
| 590 | - return $field; |
|
| 590 | + return $field; |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | /** |
@@ -596,18 +596,18 @@ discard block |
||
| 596 | 596 | * @param string $module |
| 597 | 597 | */ |
| 598 | 598 | function content_module_delete($module) { |
| 599 | - // Delete the field data. |
|
| 600 | - // If content module has been uninstalled first, all tables |
|
| 601 | - // have already been dropped, and running that code will raise errors. |
|
| 602 | - if (db_table_exists(content_instance_tablename())) { |
|
| 599 | + // Delete the field data. |
|
| 600 | + // If content module has been uninstalled first, all tables |
|
| 601 | + // have already been dropped, and running that code will raise errors. |
|
| 602 | + if (db_table_exists(content_instance_tablename())) { |
|
| 603 | 603 | $results = db_query("SELECT field_name, type_name FROM {". content_instance_tablename() ."} WHERE widget_module = '%s'", $module); |
| 604 | 604 | while ($field = db_fetch_array($results)) { |
| 605 | - content_field_instance_delete($field['field_name'], $field['type_name'], FALSE); |
|
| 605 | + content_field_instance_delete($field['field_name'], $field['type_name'], FALSE); |
|
| 606 | 606 | } |
| 607 | 607 | // Force the caches and static arrays to update to the new info. |
| 608 | 608 | content_clear_type_cache(TRUE); |
| 609 | 609 | menu_rebuild(); |
| 610 | - } |
|
| 610 | + } |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | /** |
@@ -621,8 +621,8 @@ discard block |
||
| 621 | 621 | * content_clear_type_cache() can do its job properly. |
| 622 | 622 | */ |
| 623 | 623 | function content_type_create($info) { |
| 624 | - node_get_types(NULL, NULL, TRUE); |
|
| 625 | - content_clear_type_cache(TRUE); |
|
| 624 | + node_get_types(NULL, NULL, TRUE); |
|
| 625 | + content_clear_type_cache(TRUE); |
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | /** |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | * value supplied by hook_node_type() |
| 633 | 633 | */ |
| 634 | 634 | function content_type_update($info) { |
| 635 | - if (!empty($info->old_type) && $info->old_type != $info->type) { |
|
| 635 | + if (!empty($info->old_type) && $info->old_type != $info->type) { |
|
| 636 | 636 | // Rename the content type in all fields that use changed content type. |
| 637 | 637 | db_query("UPDATE {". content_instance_tablename() ."} SET type_name='%s' WHERE type_name='%s'", array($info->type, $info->old_type)); |
| 638 | 638 | |
@@ -641,23 +641,23 @@ discard block |
||
| 641 | 641 | $old_name = _content_tablename($old_type['type'], CONTENT_DB_STORAGE_PER_CONTENT_TYPE); |
| 642 | 642 | $new_name = _content_tablename($info->type, CONTENT_DB_STORAGE_PER_CONTENT_TYPE); |
| 643 | 643 | if (db_table_exists($old_name)) { |
| 644 | - $ret = array(); |
|
| 645 | - db_rename_table($ret, $old_name, $new_name); |
|
| 646 | - watchdog('content', 'Content fields table %old_name has been renamed to %new_name and field instances have been updated.', array( |
|
| 644 | + $ret = array(); |
|
| 645 | + db_rename_table($ret, $old_name, $new_name); |
|
| 646 | + watchdog('content', 'Content fields table %old_name has been renamed to %new_name and field instances have been updated.', array( |
|
| 647 | 647 | '%old_name' => $old_name, '%new_name' => $new_name)); |
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | // Rename the variable storing weights for non-CCK fields. |
| 651 | 651 | if ($extra = variable_get('content_extra_weights_'. $info->old_type, array())) { |
| 652 | - variable_set('content_extra_weights_'. $info->type, $extra); |
|
| 653 | - variable_del('content_extra_weights_'. $info->old_type); |
|
| 652 | + variable_set('content_extra_weights_'. $info->type, $extra); |
|
| 653 | + variable_del('content_extra_weights_'. $info->old_type); |
|
| 654 | + } |
|
| 654 | 655 | } |
| 655 | - } |
|
| 656 | 656 | |
| 657 | - // Reset all content type info. |
|
| 658 | - // Menu needs to be rebuilt as well, but node types need to be rebuilt first. |
|
| 659 | - // node_type_form_submit() takes care of this. |
|
| 660 | - content_clear_type_cache(TRUE); |
|
| 657 | + // Reset all content type info. |
|
| 658 | + // Menu needs to be rebuilt as well, but node types need to be rebuilt first. |
|
| 659 | + // node_type_form_submit() takes care of this. |
|
| 660 | + content_clear_type_cache(TRUE); |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | /** |
@@ -672,24 +672,24 @@ discard block |
||
| 672 | 672 | * |
| 673 | 673 | */ |
| 674 | 674 | function content_type_delete($info) { |
| 675 | - // Don't delete data for content-types defined by disabled modules. |
|
| 676 | - if (!empty($info->disabled)) { |
|
| 675 | + // Don't delete data for content-types defined by disabled modules. |
|
| 676 | + if (!empty($info->disabled)) { |
|
| 677 | 677 | return; |
| 678 | - } |
|
| 678 | + } |
|
| 679 | 679 | |
| 680 | - // TODO : What about inactive fields ? |
|
| 681 | - // Currently, content_field_instance_delete doesn't work on those... |
|
| 682 | - $fields = content_field_instance_read(array('type_name' => $info->type)); |
|
| 683 | - foreach ($fields as $field) { |
|
| 680 | + // TODO : What about inactive fields ? |
|
| 681 | + // Currently, content_field_instance_delete doesn't work on those... |
|
| 682 | + $fields = content_field_instance_read(array('type_name' => $info->type)); |
|
| 683 | + foreach ($fields as $field) { |
|
| 684 | 684 | content_field_instance_delete($field['field_name'], $info->type, FALSE); |
| 685 | - } |
|
| 686 | - $table = _content_tablename($info->type, CONTENT_DB_STORAGE_PER_CONTENT_TYPE); |
|
| 687 | - if (db_table_exists($table)) { |
|
| 685 | + } |
|
| 686 | + $table = _content_tablename($info->type, CONTENT_DB_STORAGE_PER_CONTENT_TYPE); |
|
| 687 | + if (db_table_exists($table)) { |
|
| 688 | 688 | $ret = array(); |
| 689 | 689 | db_drop_table($ret, $table); |
| 690 | 690 | watchdog('content', 'The content fields table %name has been deleted.', array('%name' => $table)); |
| 691 | - } |
|
| 692 | - // Menu needs to be rebuilt as well, but node types need to be rebuilt first. |
|
| 693 | - // node_type_form_submit() takes care of this. |
|
| 694 | - content_clear_type_cache(TRUE); |
|
| 691 | + } |
|
| 692 | + // Menu needs to be rebuilt as well, but node types need to be rebuilt first. |
|
| 693 | + // node_type_form_submit() takes care of this. |
|
| 694 | + content_clear_type_cache(TRUE); |
|
| 695 | 695 | } |