Greetings!

As some of you may have noticed, the Nadmin Studio content
editor causes font and mark-up issues when used together with
some versions of MS Office (including Office XP).

The following script goes through the topic tree and cleans
all <FONT> tags and Office XP XML crud from topics and articles.
User running the script requires ownership of the topics in
order to be able to run the updates.

----------------
<h1>Removing MS induced crud</h1>

<p>
By <a href="mailto:[EMAIL PROTECTED]";>Eero af Heurlin</a> from 
<a href="http://www.nemein.com/";>Nemein</a>
</p>

<?php

function walk_topics_and_articles($id) {
          $topic=mgd_get_topic($id);
          echo "Debug: Processing topic: $topic->name: ";
          $old_description=$topic->description;
          $topic->description=nuke_crud($topic->description);
          if ($old_description != $topic->description) $update=1;
          if ($update==1) {
          $topic->update(); echo mgd_errstr(mgd_errno()); echo "<br>\n";
          } else { echo "<br>\n"; }
          unset ($old_description, $update);
          $articlelist=mgd_list_topic_articles($id);
          if ($articlelist) {
             while ($articlelist->fetch()) {
                   if ($article->approved) { $approve=1; } else { 
$approve=""; }
                   $article=mgd_get_article($articlelist->id);
                   echo "&nbsp;&nbsp; Processing article: 
$article->title: ";
                   $old_abstract=$article->abstract;
                   $article->abstract=nuke_crud($article->abstract);
                   if ($old_abstract != $article->abstract) $update=1;
                   $old_content=$article->content;
                   $article->content=nuke_crud($article->content);
                   if ($old_content != $article->content) $update=1;
                   if ($update==1) {
                   $article->update(); echo mgd_errstr(mgd_errno()); 
echo "<br>\n";
                   } else  { echo "<br>\n"; }
                   if ($approve==1) mgd_approve_article($article->id);
                   unset ($update, $old_content, $old_abstract);
             }
          }
          $subtopics=mgd_list_topics($id);
          if ($subtopics) {
             while ($subtopics->fetch()) {
                   walk_topics_and_articles($subtopics->id);
             }
          }
}

function nuke_crud($string) {
          //Remove all parameters from P,B,DIV,SPAN tags that contain 
strings "mso", "navigointipaa1" or "windowtext"
 
$ret=eregi_replace('<([PB]|DIV|SPAN)[^>]*(mso|navigointipaa1|windowtext)+[^>]*>', 
"<\\1>", $string);
          //Remove <O:P> and <FONT> tags
          $ret=eregi_replace("(</?o:p>)|(</?font[^>]*>)", "", $ret);

   return $ret;
}

if ($confirm==1) {
$root_topics=mgd_list_topics(0);
if ($root_topics) {
    while ($root_topics->fetch()) {
          walk_topics_and_articles($root_topics->id);
    }
}
} else { ?>
<p>You need to confirm that you wish to start, set confirm to 1 in the 
query parameters</p>
<? } ?>
------------------

/Bergie

-- 
Henri Bergius                           [EMAIL PROTECTED]
Consultant Partner                      Tel: +358-20-198 6032
Nemein Solutions Oy                     http://www.nemein.com

Nadmin Studio and Midgard support at 0600-1-2552 available for Finnish
customers.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to