فهرست منبع

try to add support relative paths in the template file by switching the directory temporarily

Ralf S. Engelschall 17 سال پیش
والد
کامیت
18980e86b2
1فایلهای تغییر یافته به همراه26 افزوده شده و 12 حذف شده
  1. 26 12
      drupal/drupal.patch

+ 26 - 12
drupal/drupal.patch

@@ -330,7 +330,7 @@ Index: sites/all/modules/img_assist/img_assist_popup.js
 --- /dev/null	2008-05-02 21:08:21 +0200
 +++ sites/all/modules/img_assist/img_assist_popup.js	2008-05-02 21:05:56 +0200
 @@ -0,0 +1,20 @@
-+/* $Id: drupal.patch,v 1.19 2008/05/29 11:13:43 rse Exp $ */
++/* $Id: drupal.patch,v 1.20 2008/05/30 19:18:50 rse Exp $ */
 +
 +function launch_popup(nid, mw, mh) {
 +	var ox = mw;
@@ -583,26 +583,33 @@ Index: modules/user/user.admin.inc
 
 Index: sites/all/modules/xmlcontent/xmlcontent.module
 --- sites/all/modules/xmlcontent/xmlcontent.module.orig	2007-03-14 22:59:59 +0100
-+++ sites/all/modules/xmlcontent/xmlcontent.module	2008-05-29 13:11:51 +0200
-@@ -39,7 +39,16 @@
++++ sites/all/modules/xmlcontent/xmlcontent.module	2008-05-30 21:13:16 +0200
+@@ -39,8 +39,22 @@
        return t('Allows users to post XML node content and get it transformed through a configured XSLT script');
  
      case 'process':
 -      $xslt_path = drupal_get_path('module', 'xmlcontent'). '/' . variable_get("xmlcontent_xslt_path_$format", '');
+-      return _xmlcontent_transform($text, $xslt_path);
 +      $tpl_path = variable_get("xmlcontent_tpl_path_$format", '');
 +      if ($tpl_path) {
 +          if (substr($tpl_path, 0, 1) != "/")
 +              $tpl_path = drupal_get_path('module', 'xmlcontent') . '/' . $tpl_path;
 +          $tpl = file_get_contents($tpl_path);
 +          $text = preg_replace("/&template_body;/", $text, $tpl);
++          $cwd = getcwd();
++          chdir(preg_replace("/\\/[^\\/]+\$/", "", $tpl_path));
 +      }
 +      $xslt_path = variable_get("xmlcontent_xslt_path_$format", '');
 +      if (substr($xslt_path, 0, 1) != "/")
 +          $xslt_path = drupal_get_path('module', 'xmlcontent') . '/' . $xslt_path;
-       return _xmlcontent_transform($text, $xslt_path);
++      $result = _xmlcontent_transform($text, $xslt_path);
++      if ($tpl_path)
++          chdir($cwd);
++      return $result;
  
      case 'settings':
-@@ -72,7 +81,7 @@
+       return _xmlcontent_filter_settings($format);
+@@ -72,7 +86,7 @@
        }
        // Does the input format of this node use XML Content filter?
        $format = filter_resolve_format($node->format);
@@ -611,7 +618,7 @@ Index: sites/all/modules/xmlcontent/xmlcontent.module
        if ($module != 'xmlcontent') {
          return;
        }
-@@ -83,7 +92,10 @@
+@@ -83,7 +97,10 @@
          return;
        }      
        
@@ -623,7 +630,7 @@ Index: sites/all/modules/xmlcontent/xmlcontent.module
        if (!is_file($schema_path) && ($validation == 'xsd' or $validation == 'rng')) {
          $schema_path = null;
          watchdog( 'xmlcontent', t('Validation required but no schema file'), WATCHDOG_WARNING );
-@@ -93,7 +105,16 @@
+@@ -93,7 +110,23 @@
        libxml_clear_errors();
        libxml_use_internal_errors(true);
  
@@ -635,13 +642,20 @@ Index: sites/all/modules/xmlcontent/xmlcontent.module
 +              $tpl_path = drupal_get_path('module', 'xmlcontent') . '/' . $tpl_path;
 +          $tpl = file_get_contents($tpl_path);
 +          $text = preg_replace("/&template_body;/", $text, $tpl);
++          $cwd = getcwd();
++          chdir(preg_replace("/\\/[^\\/]+\$/", "", $tpl_path));
 +      }
 +
-+      if (!_xmlcontent_validate($text, $validation, $schema_path)) {
++      $result = _xmlcontent_validate($text, $validation, $schema_path);
++
++      if ($tpl_path)
++          chdir($cwd);
++
++      if (!$result) {
          form_set_error('body', t('XML Content: Invalid XML') . libxml_errors_string());
        }
        
-@@ -156,6 +177,13 @@
+@@ -156,6 +189,13 @@
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
@@ -655,7 +669,7 @@ Index: sites/all/modules/xmlcontent/xmlcontent.module
    $form['xmlcontent']["xmlcontent_xslt_path_$format"] = array(
      '#type'    => 'textfield',
      '#title'   => t('XSLT Script File Path'),
-@@ -218,6 +246,8 @@
+@@ -218,6 +258,8 @@
    
    // Load the XML document
    $dom = new DomDocument('1.0', 'UTF-8');
@@ -664,7 +678,7 @@ Index: sites/all/modules/xmlcontent/xmlcontent.module
    $valid = $dom->loadXML($xml);
    if (!$valid) {
      watchdog('xmlcontent', "Invalid XML Content", WATCHDOG_WARNING);
-@@ -227,6 +257,8 @@
+@@ -227,6 +269,8 @@
    // Load the XSLT script
    // TODO: is there a way to cache it, or not necessary
    $xsl = new DomDocument('1.0', 'UTF-8');
@@ -673,7 +687,7 @@ Index: sites/all/modules/xmlcontent/xmlcontent.module
    $xsl->load($path_to_xslt);   
  
    // Create the XSLT processor
-@@ -242,10 +274,8 @@
+@@ -242,10 +286,8 @@
    }
  
    // Transform