drupal-module-misc/drupal-module-misc.patch

Tue, 28 Aug 2012 18:28:55 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 28 Aug 2012 18:28:55 +0200
changeset 531
e3f92ea19d16
child 532
e5f1af644b30
permissions
-rw-r--r--

Import package vendor original specs for necessary manipulations.

michael@531 1
michael@531 2 Activate the Drupal glue code for the FCKeditor filemanager.
michael@531 3
michael@531 4 Index: sites/all/modules/fckeditor/fckeditor/editor/filemanager/connectors/php/config.php
michael@531 5 --- sites/all/modules/fckeditor/fckeditor/editor/filemanager/connectors/php/config.php.orig 2008-03-25 16:28:24 +0100
michael@531 6 +++ sites/all/modules/fckeditor/fckeditor/editor/filemanager/connectors/php/config.php 2008-05-02 23:02:23 +0200
michael@531 7 @@ -39,6 +39,9 @@
michael@531 8 // Attention: The above 'UserFilesPath' must point to the same directory.
michael@531 9 $Config['UserFilesAbsolutePath'] = '' ;
michael@531 10
michael@531 11 +// activate Drupal glue code for filemanager
michael@531 12 +require_once "../../../../../filemanager.config.php";
michael@531 13 +
michael@531 14 // Due to security issues with Apache modules, it is recommended to leave the
michael@531 15 // following setting enabled.
michael@531 16 $Config['ForceSingleExtension'] = true ;
michael@531 17
michael@531 18 -----------------------------------------------------------------------------
michael@531 19
michael@531 20 1. Fix content validation in "xmlcontent" module in case
michael@531 21 one has enabled multiple filters on a particular input format.
michael@531 22 2. Additionally, allow absolute paths to support .xsd/.xsl files
michael@531 23 in arbitrary directories.
michael@531 24 3. Finally, do not create a new DOM and output it as XML. Instead directly
michael@531 25 output the transformed XML in order to get rid of the <?xml...?> declaration.
michael@531 26 4. Additionally, support an optional XML content template (mainly
michael@531 27 for loading ENTITY definitions which cannot be done via XSD and XSLT)
michael@531 28
michael@531 29 Index: sites/all/modules/xmlcontent/xmlcontent.module
michael@531 30 --- sites/all/modules/xmlcontent/xmlcontent.module.orig 2007-03-14 22:59:59 +0100
michael@531 31 +++ sites/all/modules/xmlcontent/xmlcontent.module 2008-05-30 21:13:16 +0200
michael@531 32 @@ -39,8 +39,22 @@
michael@531 33 return t('Allows users to post XML node content and get it transformed through a configured XSLT script');
michael@531 34
michael@531 35 case 'process':
michael@531 36 - $xslt_path = drupal_get_path('module', 'xmlcontent'). '/' . variable_get("xmlcontent_xslt_path_$format", '');
michael@531 37 - return _xmlcontent_transform($text, $xslt_path);
michael@531 38 + $tpl_path = variable_get("xmlcontent_tpl_path_$format", '');
michael@531 39 + if ($tpl_path) {
michael@531 40 + if (substr($tpl_path, 0, 1) != "/")
michael@531 41 + $tpl_path = drupal_get_path('module', 'xmlcontent') . '/' . $tpl_path;
michael@531 42 + $tpl = file_get_contents($tpl_path);
michael@531 43 + $text = preg_replace("/&template_body;/", $text, $tpl);
michael@531 44 + $cwd = getcwd();
michael@531 45 + chdir(preg_replace("/\\/[^\\/]+\$/", "", $tpl_path));
michael@531 46 + }
michael@531 47 + $xslt_path = variable_get("xmlcontent_xslt_path_$format", '');
michael@531 48 + if (substr($xslt_path, 0, 1) != "/")
michael@531 49 + $xslt_path = drupal_get_path('module', 'xmlcontent') . '/' . $xslt_path;
michael@531 50 + $result = _xmlcontent_transform($text, $xslt_path);
michael@531 51 + if ($tpl_path)
michael@531 52 + chdir($cwd);
michael@531 53 + return $result;
michael@531 54
michael@531 55 case 'settings':
michael@531 56 return _xmlcontent_filter_settings($format);
michael@531 57 @@ -72,7 +86,7 @@
michael@531 58 }
michael@531 59 // Does the input format of this node use XML Content filter?
michael@531 60 $format = filter_resolve_format($node->format);
michael@531 61 - $module = db_result(db_query('SELECT module FROM {filters} WHERE format = %d', $format));
michael@531 62 + $module = db_result(db_query("SELECT module FROM {filters} WHERE format = %d AND module = 'xmlcontent'", $format));
michael@531 63 if ($module != 'xmlcontent') {
michael@531 64 return;
michael@531 65 }
michael@531 66 @@ -83,7 +97,10 @@
michael@531 67 return;
michael@531 68 }
michael@531 69
michael@531 70 - $schema_path = drupal_get_path('module', 'xmlcontent'). '/' . variable_get("xmlcontent_schema_path_$format",'');
michael@531 71 + $schema_path = variable_get("xmlcontent_schema_path_$format", '');
michael@531 72 + if (substr($schema_path, 0, 1) != "/")
michael@531 73 + $schema_path = drupal_get_path('module', 'xmlcontent') . '/' . $schema_path;
michael@531 74 +
michael@531 75 if (!is_file($schema_path) && ($validation == 'xsd' or $validation == 'rng')) {
michael@531 76 $schema_path = null;
michael@531 77 watchdog( 'xmlcontent', t('Validation required but no schema file'), WATCHDOG_WARNING );
michael@531 78 @@ -93,7 +110,23 @@
michael@531 79 libxml_clear_errors();
michael@531 80 libxml_use_internal_errors(true);
michael@531 81
michael@531 82 - if (!_xmlcontent_validate($node->body, $validation, $schema_path)) {
michael@531 83 + $text = $node->body;
michael@531 84 + $tpl_path = variable_get("xmlcontent_tpl_path_$format", '');
michael@531 85 + if ($tpl_path) {
michael@531 86 + if (substr($tpl_path, 0, 1) != "/")
michael@531 87 + $tpl_path = drupal_get_path('module', 'xmlcontent') . '/' . $tpl_path;
michael@531 88 + $tpl = file_get_contents($tpl_path);
michael@531 89 + $text = preg_replace("/&template_body;/", $text, $tpl);
michael@531 90 + $cwd = getcwd();
michael@531 91 + chdir(preg_replace("/\\/[^\\/]+\$/", "", $tpl_path));
michael@531 92 + }
michael@531 93 +
michael@531 94 + $result = _xmlcontent_validate($text, $validation, $schema_path);
michael@531 95 +
michael@531 96 + if ($tpl_path)
michael@531 97 + chdir($cwd);
michael@531 98 +
michael@531 99 + if (!$result) {
michael@531 100 form_set_error('body', t('XML Content: Invalid XML') . libxml_errors_string());
michael@531 101 }
michael@531 102
michael@531 103 @@ -156,6 +189,13 @@
michael@531 104 '#collapsible' => TRUE,
michael@531 105 '#collapsed' => FALSE,
michael@531 106 );
michael@531 107 + $form['xmlcontent']["xmlcontent_tpl_path_$format"] = array(
michael@531 108 + '#type' => 'textfield',
michael@531 109 + '#title' => t('Optional XML Template File Path'),
michael@531 110 + '#default_value' => variable_get("xmlcontent_tpl_path_$format", ''),
michael@531 111 + '#field_prefix' => drupal_get_path('module', 'xmlcontent'). '/',
michael@531 112 + '#description' => t('The file path to the optional XML template, wrapper around the XML content before processing.'),
michael@531 113 + );
michael@531 114 $form['xmlcontent']["xmlcontent_xslt_path_$format"] = array(
michael@531 115 '#type' => 'textfield',
michael@531 116 '#title' => t('XSLT Script File Path'),
michael@531 117 @@ -218,6 +258,8 @@
michael@531 118
michael@531 119 // Load the XML document
michael@531 120 $dom = new DomDocument('1.0', 'UTF-8');
michael@531 121 + $dom->resolveExternals = true;
michael@531 122 + $dom->substituteEntities = true;
michael@531 123 $valid = $dom->loadXML($xml);
michael@531 124 if (!$valid) {
michael@531 125 watchdog('xmlcontent', "Invalid XML Content", WATCHDOG_WARNING);
michael@531 126 @@ -227,6 +269,8 @@
michael@531 127 // Load the XSLT script
michael@531 128 // TODO: is there a way to cache it, or not necessary
michael@531 129 $xsl = new DomDocument('1.0', 'UTF-8');
michael@531 130 + $xsl->resolveExternals = true;
michael@531 131 + $xsl->substituteEntities = true;
michael@531 132 $xsl->load($path_to_xslt);
michael@531 133
michael@531 134 // Create the XSLT processor
michael@531 135 @@ -242,10 +286,8 @@
michael@531 136 }
michael@531 137
michael@531 138 // Transform
michael@531 139 - $newdom = $proc->transformToDoc($dom);
michael@531 140 -
michael@531 141 - // Return the output as XML text (in fact subset of XHTML, depending on the XSLT script)
michael@531 142 - return $newdom->saveXML();
michael@531 143 + $xml = $proc->transformToXML($dom);
michael@531 144 + return $xml;
michael@531 145 }
michael@531 146
michael@531 147
michael@531 148 -----------------------------------------------------------------------------
michael@531 149
michael@531 150 Fix upgrading in "simplefeed" module if PostgreSQL is used.
michael@531 151 Fix modules as Drupal 6.2 does not provide db_num_rows() anymore.
michael@531 152
michael@531 153 Index: sites/all/modules/simplefeed/simplefeed.install
michael@531 154 --- sites/all/modules/simplefeed/simplefeed.install.orig 2008-06-11 07:22:28 +0200
michael@531 155 +++ sites/all/modules/simplefeed/simplefeed.install 2008-06-14 15:09:53 +0200
michael@531 156 @@ -31,8 +31,17 @@
michael@531 157
michael@531 158 function simplefeed_update_2() {
michael@531 159 $ret = array();
michael@531 160 - $ret[] = update_sql("ALTER TABLE {simplefeed_feed} DROP INDEX url");
michael@531 161 - $ret[] = update_sql("ALTER TABLE {simplefeed_feed} CHANGE url url text");
michael@531 162 + switch ($GLOBALS['db_type']) {
michael@531 163 + case 'mysql':
michael@531 164 + case 'mysqli':
michael@531 165 + $ret[] = update_sql("ALTER TABLE {simplefeed_feed} DROP INDEX url");
michael@531 166 + $ret[] = update_sql("ALTER TABLE {simplefeed_feed} CHANGE url url text");
michael@531 167 + break;
michael@531 168 + case 'pgsql':
michael@531 169 + $ret[] = update_sql("DROP INDEX {simplefeed_feed}_url_idx");
michael@531 170 + $ret[] = update_sql("ALTER TABLE {simplefeed_feed} ALTER COLUMN url TYPE text");
michael@531 171 + break;
michael@531 172 + }
michael@531 173 return $ret;
michael@531 174 }
michael@531 175
michael@531 176 Index: sites/all/modules/simplefeed/simplefeed_item.install
michael@531 177 --- sites/all/modules/simplefeed/simplefeed_item.install.orig 2008-06-11 07:22:28 +0200
michael@531 178 +++ sites/all/modules/simplefeed/simplefeed_item.install 2008-06-14 16:23:01 +0200
michael@531 179 @@ -60,8 +62,18 @@
michael@531 180
michael@531 181 function simplefeed_item_update_3() {
michael@531 182 $ret = array();
michael@531 183 - $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} CHANGE url url text");
michael@531 184 - $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} CHANGE iid iid varchar(32) NOT NULL");
michael@531 185 + switch ($GLOBALS['db_type']) {
michael@531 186 + case 'mysql':
michael@531 187 + case 'mysqli':
michael@531 188 + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} CHANGE url url text");
michael@531 189 + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} CHANGE iid iid varchar(32) NOT NULL");
michael@531 190 + break;
michael@531 191 + case 'pgsql':
michael@531 192 + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} ALTER COLUMN url TYPE text");
michael@531 193 + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} ALTER COLUMN iid TYPE VARCHAR(32)");
michael@531 194 + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} ALTER COLUMN iid SET NOT NULL");
michael@531 195 + break;
michael@531 196 + }
michael@531 197 return $ret;
michael@531 198 }
michael@531 199
michael@531 200 -----------------------------------------------------------------------------
michael@531 201
michael@531 202 Fix helpers module for PostgreSQL usage.
michael@531 203
michael@531 204 Index: sites/all/modules/helpers/helpers_database.module
michael@531 205 --- sites/all/modules/helpers/helpers_database.module.orig 2008-04-23 04:38:34 +0200
michael@531 206 +++ sites/all/modules/helpers/helpers_database.module 2008-06-16 18:06:41 +0200
michael@531 207 @@ -16,7 +16,7 @@
michael@531 208 *
michael@531 209 * NOTE: This is open code - do not put a function declaration on it.
michael@531 210 */
michael@531 211 - $db_types = array('mysql', 'mysqli', 'postgres');
michael@531 212 + $db_types = array('mysql', 'mysqli', 'pgsql');
michael@531 213 $dbtype = $GLOBALS['db_type'];
michael@531 214 if (in_array($dbtype, $db_types)) {
michael@531 215 // Using include because the site may not be using this so we don't want a fatal error.
michael@531 216 Index: sites/all/modules/helpers/includes/dra_pgsql.inc
michael@531 217 --- sites/all/modules/helpers/includes/dra_pgsql.inc.orig 2008-06-16 17:49:43 +0200
michael@531 218 +++ sites/all/modules/helpers/includes/dra_pgsql.inc 2008-06-16 18:05:19 +0200
michael@531 219 @@ -0,0 +1,40 @@
michael@531 220 +<?php
michael@531 221 +/* $Id */
michael@531 222 + /**
michael@531 223 + * Return a result array from the previous query. PostgreSql version.
michael@531 224 + * This is very handy for building an option list for a form element.
michael@531 225 + *
michael@531 226 + * @param $result
michael@531 227 + * A database query result resource, as returned from db_query().
michael@531 228 + * @return
michael@531 229 + * The resulting array or FALSE.
michael@531 230 + * If the query contains -- the result array would be
michael@531 231 + * 0 columns (bool)FALSE
michael@531 232 + * 1 column value => value
michael@531 233 + * 2 columns 1st value => 2nd value
michael@531 234 + * 3 or more 1st value => array(2nd value, 3rd value, ...)
michael@531 235 + */
michael@531 236 +function db_result_array($result) {
michael@531 237 + $array = array();
michael@531 238 + while ($row = pg_fetch_array($result, NULL, PGSQL_NUM)) {
michael@531 239 + $y = count($row);
michael@531 240 + switch ($y) {
michael@531 241 + case 0:
michael@531 242 + drupal_set_message(t('Db_result_array found no columns in the result set.'), 'error');
michael@531 243 + return false;
michael@531 244 +
michael@531 245 + case 1:
michael@531 246 + $array[$row[0]] = $row[0];
michael@531 247 + break;
michael@531 248 +
michael@531 249 + case 2:
michael@531 250 + $array[$row[0]] = $row[1];
michael@531 251 + break;
michael@531 252 +
michael@531 253 + default:
michael@531 254 + $array[$row[0]] = array_slice($row, 1);
michael@531 255 + break;
michael@531 256 + }
michael@531 257 + }
michael@531 258 + return $array;
michael@531 259 +}
michael@531 260
michael@531 261 -----------------------------------------------------------------------------
michael@531 262
michael@531 263 Fix PostgreSQL usage.
michael@531 264
michael@531 265 Index: sites/all/modules/nodeupdates/nodeupdates.install
michael@531 266 --- sites/all/modules/nodeupdates/nodeupdates.install.orig 2007-12-31 15:11:57 +0100
michael@531 267 +++ sites/all/modules/nodeupdates/nodeupdates.install 2008-06-18 18:00:08 +0200
michael@531 268 @@ -15,10 +15,10 @@
michael@531 269
michael@531 270 case 'pgsql':
michael@531 271 db_query("CREATE TABLE {nodeupdates} (
michael@531 272 - nid integer(10) NOT NULL default '0',
michael@531 273 + nid integer NOT NULL default '0',
michael@531 274 title varchar(128) NOT NULL default '',
michael@531 275 - message longtext NOT NULL default '',
michael@531 276 - timestamp integer(11) NOT NULL default '0'
michael@531 277 + message text NOT NULL default '',
michael@531 278 + timestamp integer NOT NULL default '0'
michael@531 279 )");
michael@531 280 break;
michael@531 281 }
michael@531 282
michael@531 283 -----------------------------------------------------------------------------
michael@531 284
michael@531 285 Since PHP 5.3 calling functions with objects and having the function
michael@531 286 declare the object parameter as a reference causes a run-time error.
michael@531 287 The "call-by-reference" indicator "&" has to be removed from parameters
michael@531 288 which are known to be passed as objects (by reference).
michael@531 289
michael@531 290 Index: sites/all/modules/diff/diff.module
michael@531 291 --- sites/all/modules/diff/diff.module.orig 2010-08-12 18:34:08.000000000 +0200
michael@531 292 +++ sites/all/modules/diff/diff.module 2010-08-13 14:18:26.000000000 +0200
michael@531 293 @@ -87,7 +87,7 @@
michael@531 294 /**
michael@531 295 * Implementation of hook_menu_alter().
michael@531 296 */
michael@531 297 -function diff_menu_alter(&$callbacks) {
michael@531 298 +function diff_menu_alter($callbacks) {
michael@531 299 // Overwrite the default 'Revisions' page
michael@531 300 $callbacks['node/%node/revisions']['page callback'] = 'diff_diffs_overview';
michael@531 301 $callbacks['node/%node/revisions']['module'] = 'diff';
michael@531 302 @@ -133,7 +133,7 @@
michael@531 303 /**
michael@531 304 * Implementation of hook_nodeapi().
michael@531 305 */
michael@531 306 -function diff_nodeapi(&$node, $op, $teaser, $page) {
michael@531 307 +function diff_nodeapi($node, $op, $teaser, $page) {
michael@531 308 if ($page && $op == 'view' && user_access('view revisions') && variable_get('show_diff_inline_'. $node->type, FALSE)) {
michael@531 309 // Ugly but cheap way to check that we are viewing a node's revision page.
michael@531 310 if (arg(2) === 'revisions' && arg(3) === $node->vid) {
michael@531 311 @@ -149,7 +149,7 @@
michael@531 312 /**
michael@531 313 * Implementation of hook_form_alter().
michael@531 314 */
michael@531 315 -function diff_form_alter(&$form, $form_state, $form_id) {
michael@531 316 +function diff_form_alter($form, $form_state, $form_id) {
michael@531 317 if (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id) {
michael@531 318 // Add a 'View changes' button on the node edit form.
michael@531 319 if (variable_get('show_preview_changes_'. $form['type']['#value'], TRUE) && $form['nid']['#value'] > 0) {
michael@531 320 @@ -194,7 +194,7 @@
michael@531 321 /**
michael@531 322 * Callback if 'View changes' is pressed.
michael@531 323 */
michael@531 324 -function diff_node_form_build_preview_changes($form, &$form_state) {
michael@531 325 +function diff_node_form_build_preview_changes($form, $form_state) {
michael@531 326 module_load_include('inc', 'diff', 'diff.pages');
michael@531 327 $node = node_form_submit_build_node($form, $form_state);
michael@531 328
michael@531 329 @@ -323,7 +323,7 @@
michael@531 330 /**
michael@531 331 * Form submission handler for diff_inline_form() for JS-disabled clients.
michael@531 332 */
michael@531 333 -function diff_inline_form_submit(&$form, &$form_state) {
michael@531 334 +function diff_inline_form_submit($form, $form_state) {
michael@531 335 if (isset($form_state['values']['revision'], $form_state['values']['node'])) {
michael@531 336 $node = $form_state['values']['node'];
michael@531 337 $vid = $form_state['values']['revision'];
michael@531 338

mercurial