Location: PHPKode > projects > PhpWebDesk > phpWebDesk/templates/html2wml.inc.php
<?php
//
// phpWebDesk template [generation 2]
//

// HTML to WML

// Remember, $body is the text.

require_once "functions.inc.php";

// !Doctype strip

while(stristr($content,"<!doctype"))  {
    $start=stripos($content, "<!doctype");
    $end=stripos($content, ">")+1;
    $tochop=substr($content, $start, ($end-$start));
    $content = stri_replace($tochop, "", $content);
}

// Simple replacements

$itags['header'] = "<html>";
$itags['title_s'] = "<head><title>";                                    
$itags['title_f'] = "</title></head>";                                  
$itags['bold_s'] = "<b>";
$itags['bold_f'] = "</b>";
$itags['italic_s'] = "<i>";                                            
$itags['italic_f'] = "</i>";
$itags['underl_s'] = "<u>";                                              
$itags['underl_f'] = "</u>";
$itags['newline'] = "<br>";   
$itags['footer'] = "</html>";

$otags['header'] = "<?xml version=\"1.0\"?"."><!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\"><wml>"; // Top of page
$otags['title_s'] = "<card title=\"";                                         
$otags['title_f'] = "\">";                                        
$otags['bold_s'] = "<b>";                                                    
$otags['bold_f'] = "</b>";
$otags['italic_s'] = "<i>";                                                 
$otags['italic_f'] = "</i>";
$otags['underl_s'] = "<u>";                                              
$otags['underl_f'] = "</u>";
$otags['newline'] = "<br />";
$otags['footer'] = "</card></wml>";

foreach($itags as $tempr => $tag) {
    $content = stri_replace($tag, $otags[$tempr], $content);
}

// Complex replacements

// Images - gotta have a /> on the end (well, in theory)
#$imagepointer = 0;
#while(stristr(substr($content, $imagepointer),"<image"))  {
#    $start=stristr(substr($content, $imagepointer),"<image")+$imagepointer
#    $end=stripos(substr($content, $imageendpointer), ">");
#    $content=substr_replace($content, "/", $end, 0);
#    $imagepointer+=(1+$end);
#}

Return current item: PhpWebDesk