/[drupal]/contributions/modules/word2web/word2web.module
ViewVC logotype

Diff of /contributions/modules/word2web/word2web.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.5, Thu Jul 24 15:30:15 2008 UTC revision 1.6, Thu Jul 24 15:33:12 2008 UTC
# Line 2  Line 2 
2    
3  /*  /*
4   * Author   : Tom MacWright, Young Hahn   * Author   : Tom MacWright, Young Hahn
5   * Revision : $Id:$   * Revision : $Id$
6   */   */
7    
8  /**  /**
# Line 147  function _word2web_insert_images($nid, $ Line 147  function _word2web_insert_images($nid, $
147    $node = node_load($nid);    $node = node_load($nid);
148    set_error_handler("_word2web_suppress_errors");    set_error_handler("_word2web_suppress_errors");
149    $html = new DOMDocument();    $html = new DOMDocument();
150    $html->loadHTML($node->body);    $html->loadXML($node->body);
151    $images = $html->getElementsByTagName("image");    $images = $html->getElementsByTagName("image");
152    $i = 0;    $i = 0;
153    foreach ($images as $im) {    foreach ($images as $im) {
# Line 206  function word2web_image_upload_message($ Line 206  function word2web_image_upload_message($
206    }    }
207    restore_error_handler();    restore_error_handler();
208    if ($i > 0) {    if ($i > 0) {
209      drupal_set_message(l(t('!num images in this !type need to be uploaded.', array('!type' => $node->type, '!num' => $i)), 'node/'. $node->nid .'/manage_images'), 'error');      drupal_set_message(l(t('!num '.format_plural($i, 'image', 'images').' in this !type need to be uploaded.', array('!type' => $node->type, '!num' => $i)), 'node/'. $node->nid .'/manage_images'), 'error');
210    }    }
211  }  }
212    
# Line 234  function word2web_nodeapi(&$node, $op) { Line 234  function word2web_nodeapi(&$node, $op) {
234          if ($matches[1] == 'windows-1256') {          if ($matches[1] == 'windows-1256') {
235            $html_raw = iconv('windows-1256', 'utf-8', $html_raw);            $html_raw = iconv('windows-1256', 'utf-8', $html_raw);
236          }          }
237            if ($matches[1] == 'windows-1252') {
238              $html_raw = iconv('windows-1252', 'utf-8', $html_raw);
239            }
240          $html = new DOMDocument();          $html = new DOMDocument();
241          $html->loadHTML($html_raw);          $html->loadHTML($html_raw);
242          $images = $html->getElementsByTagName("img");          $images = $html->getElementsByTagName("img");
# Line 321  function _word2web_get_images($c) { Line 323  function _word2web_get_images($c) {
323    
324  function word2web_manual($html_raw) {  function word2web_manual($html_raw) {
325    $html_raw = _word2web_convert_chr($html_raw);    $html_raw = _word2web_convert_chr($html_raw);
326      preg_match('/charset=([\w-]+)/', $html_raw, $matches);
327    
328      if ($matches[1] == 'windows-1256') {
329          $html_raw = iconv('windows-1256', 'utf-8', $html_raw);
330        }
331      if ($matches[1] == 'windows-1252') {
332          $html_raw = iconv('windows-1252', 'utf-8', $html_raw);
333        }
334    $path = drupal_get_path('module', 'word2web');    $path = drupal_get_path('module', 'word2web');
335    set_error_handler('_word2web_suppress_errors');    set_error_handler('_word2web_suppress_errors');
336    $html = $html_raw;    $html = $html_raw;
# Line 328  function word2web_manual($html_raw) { Line 338  function word2web_manual($html_raw) {
338    "<addr class='image' $2>-</addr>",    "<addr class='image' $2>-</addr>",
339    $html_raw);    $html_raw);
340    
   if ($matches[1] == 'windows-1256') {  
     $html_raw = iconv('windows-1256', 'utf-8', $html_raw);  
   }  
341    //preg_match('/charset=([\w-]+)/', $html_raw, $matches);    //preg_match('/charset=([\w-]+)/', $html_raw, $matches);
342    // This step apparently cleans up the XML a little.    // This step apparently cleans up the XML a little.
343    $html = new DOMDocument();    $html = new DOMDocument();
# Line 342  function word2web_manual($html_raw) { Line 349  function word2web_manual($html_raw) {
349    // Convert from the charset it says it is into UTF-8    // Convert from the charset it says it is into UTF-8
350    //$html = iconv($matches[1], "UTF-8//IGNORE", $html);    //$html = iconv($matches[1], "UTF-8//IGNORE", $html);
351    $html = iconv("UTF-8", "UTF-8//IGNORE", $html);    $html = iconv("UTF-8", "UTF-8//IGNORE", $html);
352            $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
353    // Actually run the xsl transformations    // Actually run the xsl transformations
354    $html = _word2web_xslt_transform($html, $path .'/empty.xsl');    $html = _word2web_xslt_transform($html, $path .'/empty.xsl');
355    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.2