User talk:Badmadevil: Difference between revisions

m
Line 16:
*some pages have not any task completed, eg. assembler, pike, JoCaml. They are treated as error loading page, rather than display all tasks from Task-list page;
*''unsolved'', there are unknown errors on parsing pages of ''JScript.NET'' & ''Visual Basic.NET'' as DOM. They can be load as DOMDocument (so that it is not a problem of url, eg.wrong encoding of url string), but can't get the required Node by getElementById inside the DOMDoc;
::''fixed'', it is really a problem of wrong encoding, the 'dot' is not properly encoded, and the page loaded I said previously is the create new articles page. It has been fixed. All bugs should has been fixed. -- [[User:Badmadevil|badmadevil]] 12:22, 16 June 2008 (MDT)
*''Usage'', this version need not config, as long as allow_url_fopen is enabled. Place this script in a server (local server or RC Site) some where can be access from www, and that is it.
*Tested with PHP 5.2.1
Line 27 ⟶ 28:
define('ROSETTA', 'http://' . RCHost) ;
 
// 3 version of url prefix, when loading the Specific Language Page,
// they will be tried one by one
define('SafeURL', ROSETTA . '/w/index.php?title=') ;
Line 40 ⟶ 41:
 
$langID = LangId() ;
$IDLang = str_replace('_',' ', rawurldecode($langID)) ;
 
// this control how to access this scrtpt
Line 46 ⟶ 47:
function ScriptURL($langId = NA){
global $langID, $scriptURL ;
if($langId == NA) $langId = $langID ;
return $scriptURL . ($langId == NA ? "" : '?' . rawurlencode($langId)) ;
$langId = str_replace('.', '%252E', $langId) ;
return $scriptURL . ($langId == NA ? "" : '?' . $langId) ;
}
 
Line 59 ⟶ 62:
global $langID ;
$this->id = $id ;
if($isLangFile) {
if($this->langURL(SafeURL)) // try one by one
if($this->langURL(Prefix))
$this->langURL(LastTry) ;
} else {
@$this->loadHTMLFile($url) ;
Line 80 ⟶ 83:
$this->cnt = $this->lnk->length ;
$this->ok = TRUE ;
}
}
}
Line 90 ⟶ 93:
if(@$this->loadHTMLFile($prefix . $langID))
if($this->context = $this->getElementById($this->id))
$FAIL = FALSE ; /*
else {
echo $this->toHTML() ;
exit(-1) ;
}*/
return $FAIL ;
}
 
function toHTML() {
// not need if this script is inside RC site
if(stristr($_SERVER['HTTP_HOST'], RCHost) === FALSE) {
$head = $this->getElementsByTagName("head")->item(0) ;
Line 101 ⟶ 108:
$base->setAttribute("href", ROSETTA) ;
$head->insertBefore($base, $head->firstChild) ;
}
return $this->saveHTML() ;
}
 
Line 112 ⟶ 119:
$alink = $this->lnk->item($i)->getElementsByTagName("a")->item(0) ;
$href = $alink->getAttribute("href") ;
$temp[$href] = TRUE ;
}
// set diff : total tasks - lang's tasks => not completed tasks
Line 126 ⟶ 133:
$hdr = $this->hdr->cloneNode(TRUE) ;
$msg = $this->msg->cloneNode(TRUE) ;
// clear All nodes under $this->context(id)'s node
$context = $this->context ;
$this->context = $context->cloneNode() ; // shallow copy, remove all child
$context->parentNode->replaceChild($this->context, $context) ;
// append hdr, msg back
$this->hdr = $this->context->appendChild($hdr) ;
$this->msg = $this->context->appendChild($msg) ;
// make table
$table = $this->createElement("table") ;
$tr = $this->createElement("tr") ;
for($i = 0 ; $i < 3 ; $i++)
$tr->appendChild($this->createElement("td")) ;
$table->appendChild($tr) ;
$this->context->appendChild($table) ;
// get tds later work with
$xpath = new DOMXPath($this) ;
$this->tds = $xpath->query('table/tr/td', $this->context) ;
// insert a languages list link
$alink = $this->createElement("a", "Other Languages") ;
Line 148 ⟶ 155:
$alink->setAttribute("title", "Not completed tasks by other languages") ;
$style = 'float:right;clear:right;position:relative;top:8px;' .
'background-color:#eec;padding:2px 8px 2px 8px;';
$alink->setAttribute("style", $style) ;
$this->context->insertBefore($alink, $this->hdr) ;
}
}
Line 261 ⟶ 268:
else
$list->hdr->nodeValue = 'Not Completed Tasks by Languages ( "'
. $IDLang . '" hashasn\'t noany task completed oryet page error) ' ;
 
process_list() ;
Line 267 ⟶ 274:
echo $list->toHTML() ;
}
else
echo '
<html><body>
Line 276 ⟶ 283:
</body></html>' ;
}
 
?></php>
|}