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.

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

mercurial