I receive this error when trying to import filters previously created.

I tried to strip out filters from the XML and import one at a time- but at no avail.

If anyone has any thoughts please let me know!

Code pasted below.

<?xml version="1.0" standalone="yes"?>
<customfilter>
  <filterset name="Phrase Search" cache="1">
    <description></description>
    <tips>
      <short><![CDATA[]]></short>
      <long><![CDATA[]]></long>
    </tips>
    <filters>
      <filter name="CV" matches="0" func="0" weight="0">
        <description><![CDATA[]]></description>
        <pattern><![CDATA[/\[\[CV\]\]/i]]></pattern>
        <replacement><![CDATA[[[Example CV Resume Template|CV]]]]></replacement>
      </filter>
      <filter name="resume" matches="0" func="0" weight="0">
        <description><![CDATA[]]></description>
        <pattern><![CDATA[/\[\[resume\]\]/i]]></pattern>
        <replacement><![CDATA[[[Example CV Resume Template|resume]]]]></replacement>
      </filter>
      <filter name="audit" matches="0" func="0" weight="0">
        <description><![CDATA[]]></description>
        <pattern><![CDATA[/\[\[audit\]\]/i]]></pattern>
        <replacement><![CDATA[[[Audit & Assurance|audit]]]]></replacement>
      </filter>
      <filter name="accounting" matches="0" func="0" weight="0">
        <description><![CDATA[]]></description>
        <pattern><![CDATA[/\[\[accounting\]\]/i]]></pattern>
        <replacement><![CDATA[[[Accountancy & Professional Services|accounting]]]]></replacement>
      </filter>
      <filter name="Consulting" matches="0" func="0" weight="0">
        <description><![CDATA[]]></description>
        <pattern><![CDATA[/\[\[consulting\]\]/i]]></pattern>
        <replacement><![CDATA[[[management consulting|consulting]]]]></replacement>
      </filter>
    </filters>
  </filterset>
  <filterset name="Wiki post parse filters" cache="1">
    <description>Do section edits</description>
    <tips>
      <short><![CDATA[]]></short>
      <long><![CDATA[]]></long>
    </tips>
    <filters>
      <filter name="Section Edits" matches="0" func="1" weight="0">
        <description><![CDATA[]]></description>
        <pattern><![CDATA[/<h\d(.*)>(.*)<\/h\d>/i]]></pattern>
        <replacement><![CDATA[foreach ($matches as &$match)

{

$nid=arg(1);

$link="";



//if($nid && is_int($nid) && node_access('update', $nid))

if($nid>0)

{

$link="<span class=\"editlink\">[<a href=\"/node/$nid/edit\">Edit</a>]</span>";

}

return $match . $link;

//return $match;

}]]></replacement>
      </filter>
    </filters>
  </filterset>
  <filterset name="Wiki Pre-Parse Filters" cache="1">
    <description>Fetch any transclusions.</description>
    <tips>
      <short><![CDATA[]]></short>
      <long><![CDATA[]]></long>
    </tips>
    <filters>
      <filter name="Transclusions" matches="0" func="1" weight="0">
        <description><![CDATA[]]></description>
        <pattern><![CDATA[/{{.*}}/i]]></pattern>
        <replacement><![CDATA[foreach ($matches as &$match) {

$title=str_replace("_"," ",$match);

$all_params=substr($title,2,strlen($title)-4);

$pointer=strpos($all_params,"|");

$bp=substr($all_params,0,$pointer);

if($bp)

{

$title = $bp;

}else {

$title=$all_params;

}

$char_one=substr($title,0,1);

if($char_one==':'){

$title=substr($title,1);

$template=false;

} else {

$template = true;

}

/*$vars=explode('|',$all_params);

print_r($vars);*/

$node = node_load(array('title' => $title));

if(!$node) return $match;

return $node->body;

}]]></replacement>
      </filter>
      <filter name="Make h1 h2" matches="0" func="1" weight="0">
        <description><![CDATA[]]></description>
        <pattern><![CDATA[/[^=]=[\w|:| &]+=[^=]/i]]></pattern>
        <replacement><![CDATA[foreach ($matches as &$match) {

/*$output = "=" . $match . "=";

echo $match;

return $output;*/

return $match;

}]]></replacement>
      </filter>
      <filter name="boxtip" matches="0" func="0" weight="0">
        <description><![CDATA[]]></description>
        <pattern><![CDATA[/<boxtip>/i]]></pattern>
        <replacement><![CDATA[<nowiki>

<table class="wikitable">

<tr>

<td>

<img width=75px height=75px src="/images/lightbulb.png">

</td>

<td>

</nowiki>]]></replacement>
      </filter>
      <filter name="floatbox" matches="0" func="0" weight="0">
        <description><![CDATA[]]></description>
        <pattern><![CDATA[/<floatbox>/i]]></pattern>
        <replacement><![CDATA[<nowiki>

<table class="infobox vcard" style="width: 25em; text-align: left; font-size: 90%;">

<tr>

<td>

</nowiki>]]></replacement>
      </filter>
      <filter name="boxtip-close" matches="0" func="0" weight="0">
        <description><![CDATA[]]></description>
        <pattern><![CDATA[/<\/boxtip>/i]]></pattern>
        <replacement><![CDATA[<nowiki>

</td>

</tr>

</table>

</nowiki>]]></replacement>
      </filter>
      <filter name="floatbox close" matches="0" func="0" weight="0">
        <description><![CDATA[]]></description>
        <pattern><![CDATA[/<\/floatbox>/i]]></pattern>
        <replacement><![CDATA[<nowiki>

</td>

</tr>

</table>

</nowiki>]]></replacement>
      </filter>
    </filters>
  </filterset>
</customfilter>
CommentFileSizeAuthor
#7 customfilter.zip19.93 KBchrism2671

Comments

avpaderno’s picture

Category: bug » support

It's not actually a bug.
The format used to export / import the filters is changed, and it's not compatible with the XML format previously used. The code used is similar to the code used by other modules to import / export their data.

The code you are trying to import could also not work on branch 2.x; what the previous code saved in $vars needs to be saved in $customfilter, which is an object of class CustomFilter. Also, there is a property that contains a duplicate of the node object for which the filter is called for ($customfilter->node). In future releases of the module, CustomFilter will implement some utility methods.

avpaderno’s picture

Title: "The import data is not valid import text." » Imported data from previous version of the module is not considered valid import data
chrism2671’s picture

What version do I need to install to be compatible with this XML, rather than the new format?

avpaderno’s picture

Actually, the new format is used in both the branches I am developing.

chrism2671’s picture

Sorry that's not what I mean- which old version does support this code? I would prefer to reinstall the old version until I have time to implement the new version.

avpaderno’s picture

It's what I mean; in all the files you can download there is the code I developed. This is because the previous maintainer has not created any official releases, but only development snapshots that have been overridden by my code.

chrism2671’s picture

StatusFileSize
new19.93 KB

For all those interested, here is a D6 version that supports the old XML format.

avpaderno’s picture

Status: Active » Fixed

I am setting this report as fixed because it already got an answer.

avpaderno’s picture

As a side note, the import / export functions are not thought to be used to back up the module settings, but rather for allowing the exchange of custom filters between users.

I think I could add this note on the project page.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.