fancy HTML function fancy_design($fname) { global $HTML_PATH, $FANCY_PATH, $LANGUAGE, $LANGUAGES, $counter, $original_index, $publication_date; // Get the contents of the file from $HTML_PATH $content = oneLiner("$HTML_PATH/$fname", true); // CSS file linking $content = preg_replace("|/", '', $content); // Whole page table and backgrounds $wpbegin = '
'; $bnavt = ''; $lnavt = ''; $space = ''; // Navheader backgound $content = preg_replace("/<\\/DIV\\s*>/Us", $wpbegin . '' . $lnavt . '

' . $space . '
', $content); // Navfooter backgound $content = preg_replace("/<\\/DIV\\s*>/Us", '
' . $space . '
', $content); // Fix copyright page fault... if ($fname == "copyright.html") { $content = preg_replace("/&copy;/", "©", $content); $content = preg_replace("/)|", "\\1 ", $content); $content = preg_replace("|( )|", "\\1 ", $content); } // Fix the original manual index to look far better... elseif ($fname == "$original_index") { // Find out manual generation date if (preg_match('|([\\d-]+)
|U', $content, $match)) { $publication_date = $match[1]; } else { $publication_date = 'n/a'; } // Modify the index file to meet our needs preg_match('|CLASS=\"title\"\\s*>(.*)(.*) 

'; $content = preg_replace("/(/Us", "", $content); preg_match('|(.*)|U', $content, $match); $content = preg_replace("|(CLASS=\"title\"\\s+>).*().*((.*)|U", "", $content); } // Print out that new file to $FANCY_PATH $fp = fopen("$FANCY_PATH/$fname", "w"); $content = setDocumentCharset($content, $LANGUAGES[$LANGUAGE]['mime_charset_name']); fputs_wrapper($fp, $content); fclose($fp); // Print out a message to see the progress echo "$FANCY_PATH/$fname ready...\n"; $counter++; } // fancy_design() function end // Convert one file from HTML => fancy HTML using CHtmlParser function fancy_parser_design($fname) { global $HTML_PATH, $FANCY_PATH, $LANGUAGE, $LANGUAGES, $counter, $original_index, $publication_date; global $EHType,$HEType; // Get the contents of the file from $HTML_PATH //TODO: iconv stuff, for when charset element > byte $content = file_get_contents("$HTML_PATH/$fname"); $tree = new CHtmlExtParse($content); // CSS file linking $head = $HEType["head"]; if(isset($tree->EBT[$head][0])) $tree->ATE[$tree->EBT[$head][0]]["chaintoend"] = ''; // Charset: $meta = $HEType["meta"]; if(isset($tree->EBT[$meta])){ for($a=0;$aEBT[$meta]);$a++){ $elem = &$tree->ATE[$tree->EBT[$meta][$a]]; if(isset($elem["http-equiv"]) && $elem["http-equiv"]=="Content-type") $elem["content"] = "text/html; {$LANGUAGES[$LANGUAGE]['mime_charset_name']}"; } } // No margins around $body = $HEType["body"]; if(isset($tree->EBT[$body][0])){ $tree->ATE[$tree->EBT[$body][0]]["TOPMARGIN"] ="0"; $tree->ATE[$tree->EBT[$body][0]]["LEFTMARGIN"] ="0"; } // HR dropout $tmp=0; do{ if($tmp = $tree->get_element_id_by_rule(array("tag"=>"hr","properties"=>array("align","LEFT","width","100%"),"offset"=>($tmp+1)))){ $tree->change_tag_type($tmp,__HTML_FREE_ENGLISH__); } } while($tmp); // Whole page table and backgrounds $wpbegin = '
'; $bnavt = ''; $lnavt = ''; $space = ''; // Navheader backgound if($tmp = $tree->get_element_id_by_rule(array("tag"=>"div","properties"=>array("class","NAVHEADER")))){ $tree->ATE[$tmp]["data"] = "$wpbegin
$bnavt
$lnavt

"; $tree->ATE[$tree->ECE[$tmp]]["data"] = "
$space
"; $tree->ATE[$tmp+1]["cellpadding"] = "3"; $tree->change_tag_type($tmp,__HTML_FREE_ENGLISH__); } // Navfooter backgound if($tmp = $tree->get_element_id_by_rule(array("tag"=>"div","properties"=>array("class","NAVFOOTER")))){ $tree->ATE[$tmp]["data"] = "
$space
{$bnavt}{$lnavt}
"; $tree->ATE[$tree->ECE[$tmp]]["data"] = "
"; $tree->ATE[$tmp+1]["cellpadding"] = "3"; $tree->change_tag_type($tmp,__HTML_FREE_ENGLISH__); } // Fix copyright page fault... if ($fname == "copyright.html") { // it just looks that no more need to fix the copyright. } // Fix the original manual index to look far better... elseif ($fname == "$original_index") { // Find out manual generation date if($tmp = $tree->get_element_id_by_rule(array("tag"=>"p","properties"=>array("class","pubdate")))){ $publication_date = $tree->ATE[$tmp+1]["data"]; } else { $publication_date = 'n/a'; } // Modify the index file to meet our needs $tmp = $tree->get_element_id_by_rule(array("tag"=>"h1","properties"=>array("class","title"))); $tit = isset($tree->ATE[$tmp+2]["data"])?$tree->ATE[$tmp+2]["data"]:""; $tit2 =""; $tmp = $tree->get_element_id_by_rule(array("tag"=>"div","properties"=>array("class","BOOK"))); $tree->ATE[$tmp-1]["chaintoend"] = '

'; /** TODO complete this: $content = preg_replace("/(/Us", "", $content); preg_match('|(.*)|U', $content, $match); $content = preg_replace("|(CLASS=\"title\"\\s+>).*().*((.*)|U", "", $content); /**/ } // Print out that new file to $FANCY_PATH $fp = fopen("$FANCY_PATH/$fname", "w"); $content = $tree->get(); $tree->unsetme(); //TODO: iconv stuff, for when charset element > byte fputs($fp, $content); fclose($fp); // Print out a message to see the progress echo "$FANCY_PATH/$fname ready...\n"; $counter++; } // fancy_parser_design() function end ?>