User talk:Badmadevil: Difference between revisions

m
→‎Not Implemented Tasks by Language: updated, query string handling changed
m (→‎Not Implemented Tasks by Language: add links for navigation, some minor changes)
m (→‎Not Implemented Tasks by Language: updated, query string handling changed)
Line 25:
<php><?php
// may be need to enable allow_url_fopen, or change it to local file path
define('RCHost' , 'www.rosettacode.org') ;
define('ROSETTA', 'http://' . RCHost) ;
define('Prefix', ROSETTA . '/wiki/Category:') ;
define('TaskURL', Prefix . 'Solutions_by_Programming_Task') ;
define('ListURL', Prefix . 'Solutions_by_Programming_Language') ;
 
define('PAGENAMELANGID', 'PAGENAMELANGID') ; // if use as a query string key-value pair
define('NA', 'NotAvaliable') ;
 
$subfix = "" ;
$langID = LangId() ;
$IDLang = myDecode(myDecode($langID)) ;
// $langID has been encoded 2 time so that C++ not mistaken with C
$IDLang = myDecode(myDecode($langID)) ;
 
// this control how to access this scrtpt
$scriptURL = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['URL'] ;
 
function ScriptURL($langId){
global $langIDscriptURL, $scriptURL subfix;
return $scriptURL . ($langId == NA ? "" : '?' . myEncode($langId)) ;
if($langId == NA)
$tail = strlen($subfix) == 0 ? '' : '?' . $subfix ;
else {
$tail = strlen($subfix) == 0 ? '' : '&' . $subfix ;
return $scriptURL . ($langIdtail == NA '?' "". :LANGID . '?=' . myEncode($langId)) . $tail ;
}
return $scriptURL . $tail ;
}
function pageUrl($page) {
global $subfix;
$tail = strlen($subfix) == 0 ? '' : '?' . $subfix ;
return Prefix . $page . $tail ;
}
function myEncode($s) { return str_replace('.', '%252E', rawurlencode($s)) ; }
function myDecode($s) { return str_replace('_', ' ' , rawurldecode($s)) ; }
 
function LangId(){
global $subfix ;
$langId = NA ;
if(count($_GET_SERVER['QUERY_STRING']) > 0) {
parse_str($_SERVER['QUERY_STRING'], $query) ;
if(array_key_exists(PAGENAMELANGID, $_GETquery) && strlen($_GETquery[PAGENAMELANGID]) > 0)
$langId = $_GETquery[PAGENAMELANGID] ;
else {
else
$keys = array_keys($_GET) ;
foreach($query as $key => $value)
if(count($keys) > 0 && strlen($keys[0]) > 0) $langId = $keys[0] ;
if(strlen($value) == 0) {
}
$query[LANGID] = $key ;
$langId = $key ;
unset($query[$key]) ;
break ;
}
if(array_key_exists(LANGID, $query))
unset($query[LANGID]) ;
$subfix = http_build_query($query) ;
}
return myEncode($langId) ;
}
 
Line 67 ⟶ 90:
global $langID ;
if($url == $langID) {
if(!@$this->loadHTMLFile($this->url = Prefix . pageURL($langID)))
if(!@$this->loadHTMLFile($this->url = Prefix . pageURL(myDecode($langID))))
$this->ok = FALSE ;
if($this->ok) $this->context = $this->getElementById($id) ;
Line 155 ⟶ 178:
for($i = 0 ; $i < $lang->tds->length ; $i++) {
$td = $lang->tds->item($i) ;
$td->setAttribute("width", intval(100/$lang->tds->length) . "33%") ;
$td->setAttribute("valign", "top") ;
$ul = NULL ;
Line 214 ⟶ 237:
$lang = new Page($langID, 'mw-pages') ;
if($lang->ok) {
$task = new Page(pageURL(TaskURL), 'mw-pages') ;
if($task->ok)
$lang->prepare($task->lnk) ;
Line 222 ⟶ 245:
if($langID != NA && $lang->ok && $task->ok) {
linkText($lang->hdr, 'Not Completed Tasks by ', $lang->url, $IDLang, NULL) ;
linkText($lang->hdr, ' ( ', $scriptURLScriptURL(NA), 'Other Languages', ' ) ') ;
 
process_task() ;
echo $lang->toHTML() ;
} else {
$list = new Page(pageURL(ListURL), 'mw-subcategories') ;
if($list->ok) {
if($langID == NA)
Line 249 ⟶ 272:
?></php>
|}
Hope it can be a temporary solution. -- [[User:Badmadevil|badmadevil]] 0612:0133, 1622 June 2008 (MDTUTC)