Extension talk:DynamicPageList (Wikimedia)/de

Moin!

Ich betreibe die MediaWiki-Version: 1.5.7. Die DynamicPageList2 hat bei mir einen Fehler ausgeworfen. Deshalb habe ich diese ("alte") DynamicPageList für mich geringfügig erweitert:


 * Caching ausgeschaltet


 * Sortierung nach Titel
 * Neuer Parameterwert: ordermethod=title


 * Zusatz des Datums der letzten Änderung (hinten dran in Klammern)
 * Neuer Parameter: addpagetoucheddate=true|false (default=false)

--Nicolas 18:30, 3 May 2006 (UTC)

function DynamicPageList( $input ) { global $wgUser; global $wgLang; global $wgContLang; global $wgDLPminCategories, $wgDLPmaxCategories,$wgDLPMinResultCount, $wgDLPMaxResultCount; global $wgDLPAllowUnlimitedResults, $wgDLPAllowUnlimitedCategories; $aParams = array; $bCountSet = false; $sStartList = ''; $sEndList = ''; $sStartItem = ''; $sEndItem = ''; $sOrderMethod = 'categoryadd'; $sOrder = 'descending'; $sRedirects = 'exclude'; $bNamespace = false; $iNamespace = 0; $bSuppressErrors = false; $bShowNamespace = true; $bAddFirstCategoryDate = false; $bAddPageTouchedDate = false; $aCategories = array; $aExcludeCategories = array; $aParams = explode("\n", $input); $parser = new Parser; // INVALIDATE CACHE $parser->disableCache; foreach($aParams as $sParam) {     $aParam = explode("=", $sParam); if( count( $aParam ) < 2 ) continue; $sType = trim($aParam[0]); $sArg = trim($aParam[1]); if ($sType == 'category') {       $title = Title::newFromText( $parser->transformMsg($sArg, null) ); if( is_null( $title ) ) continue; $aCategories[] = $title; }     else if ($sType == 'notcategory') {       $title = Title::newFromText( $parser->transformMsg($sArg, null) ); if( is_null( $title ) ) continue; $aExcludeCategories[] = $title; }     else if ('namespace' == $sType) {       $ns = $wgContLang->getNsIndex($sArg); if (NULL != $ns) { 	 $iNamespace = $ns; $bNamespace = true; } 	else { 	 $iNamespace = intval($sArg); if ($iNamespace >= 0) { 	   $bNamespace = true; } 	 else { 	   $bNamespace = false; } 	}     }      else if ('count' == $sType) {       //ensure that $iCount is a number; $iCount = IntVal( $sArg ); $bCountSet = true; }     else if ('mode' == $sType) { 	switch ($sArg) { 	case 'none': $sStartList = ''; $sEndList = ''; $sStartItem = ''; $sEndItem = ' '; break; case 'ordered': $sStartList = ''; $sEndList = ''; $sStartItem = ''; $sEndItem = ''; break; case 'unordered': default: $sStartList = ''; $sEndList = ''; $sStartItem = ''; $sEndItem = ''; break; }     }      else if ('order' == $sType) {       switch ($sArg) { 	case 'ascending': $sOrder = 'ascending'; break; case 'descending': default: $sOrder = 'descending'; break; }     }      else if ('ordermethod' == $sType) { 	switch ($sArg) {        case 'title': $sOrderMethod = 'title'; break; case 'lastedit': $sOrderMethod = 'lastedit'; break; case 'categoryadd': default: $sOrderMethod = 'categoryadd'; break; }     }      else if ('redirects' == $sType) {     	switch ($sArg) {     	case 'include': $sRedirects = 'include'; break; case 'only': $sRedirects = 'only'; break; case 'exclude': default: $sRedirects = 'exclude'; break; }     }      else if ('suppresserrors' == $sType) { 	if ('true' == $sArg) $bSuppressErrors = true; else $bSuppressErrors = false; }     else if ('addfirstcategorydate' == $sType) {       if ('true' == $sArg) $bAddFirstCategoryDate = true; else $bAddFirstCategoryDate = false; }      else if ('addpagetoucheddate' == $sType) {                                                 if ('true' == $sArg) $bAddPageTouchedDate = true; else $bAddPageTouchedDate = false; }                                                else if ('shownamespace' == $sType) { 	if ('false' == $sArg) $bShowNamespace = false; else $bShowNamespace = true; }   }    $iCatCount = count($aCategories); $iExcludeCatCount = count($aExcludeCategories); $iTotalCatCount = $iCatCount + $iExcludeCatCount; if ($iCatCount < 1 && false == $bNamespace) {     if (false == $bSuppressErrors) return htmlspecialchars( wfMsg( 'dynamicpagelist_noincludecats' ) ); // "!!no included categories!!"; else return ''; }   if ($iTotalCatCount < $wgDLPminCategories) {     if (false == $bSuppressErrors) return htmlspecialchars( wfMsg( 'dynamicpagelist_toofewcats' ) ); // "!!too few categories!!"; else return ''; }   if ( $iTotalCatCount > $wgDLPmaxCategories && !$wgDLPAllowUnlimitedCategories ) {     if (false == $bSuppressErrors) return htmlspecialchars( wfMsg( 'dynamicpagelist_toomanycats' ) ); // "!!too many categories!!"; else return ''; }   if ($bCountSet) {     if ($iCount < $wgDLPMinResultCount) $iCount = $wgDLPMinResultCount; if ($iCount > $wgDLPMaxResultCount) $iCount = $wgDLPMaxResultCount; }   else {     if (!$wgDLPAllowUnlimitedResults) {       $iCount = $wgDLPMaxResultCount; $bCountSet = true; }   }    //disallow showing date if the query doesn't have an inclusion category parameter if ($iCatCount < 1) $bAddFirstCategoryDate = false; //build the SQL query $dbr =& wfGetDB( DB_SLAVE ); $sPageTable = $dbr->tableName( 'page' ); $categorylinks = $dbr->tableName( 'categorylinks' ); // Original SQL: // $sSqlSelectFrom = "SELECT page_namespace, page_title, c1.cl_timestamp FROM $sPageTable"; $sSqlSelectFrom = "SELECT page_namespace, page_title, c1.cl_timestamp, page_touched FROM $sPageTable"; if (true == $bNamespace) $sSqlWhere = ' WHERE page_namespace='.$iNamespace.' '; else $sSqlWhere = ' WHERE 1=1 '; switch ($sRedirects) {     case 'only': $sSqlWhere .= ' AND page_is_redirect = 1 '; break; case 'exclude': $sSqlWhere .= ' AND page_is_redirect = 0 '; break; }   $iCurrentTableNumber = 0; for ($i = 0; $i < $iCatCount; $i++) { $sSqlSelectFrom .= " INNER JOIN $categorylinks AS c". ($iCurrentTableNumber+1); $sSqlSelectFrom .= ' ON page_id = c'.($iCurrentTableNumber+1).'.cl_from'; $sSqlSelectFrom .= ' AND c'.($iCurrentTableNumber+1).'.cl_to='. $dbr->addQuotes( $aCategories[$i]->getDbKey ); $iCurrentTableNumber++; }   for ($i = 0; $i < $iExcludeCatCount; $i++) { $sSqlSelectFrom .= " LEFT OUTER JOIN $categorylinks AS c". ($iCurrentTableNumber+1); $sSqlSelectFrom .= ' ON page_id = c'.($iCurrentTableNumber+1).'.cl_from'; $sSqlSelectFrom .= ' AND c'.($iCurrentTableNumber+1).'.cl_to='. $dbr->addQuotes( $aExcludeCategories[$i]->getDbKey ); $sSqlWhere .= ' AND c'.($iCurrentTableNumber+1).'.cl_to IS NULL'; $iCurrentTableNumber++; }    switch ($sOrderMethod) {                                                     case 'lastedit': $sSqlWhere .= ' ORDER BY page_touched '; break; case 'title': $sSqlWhere .= ' ORDER BY page_title '; break; case 'categoryadd': $sSqlWhere .= ' ORDER BY c1.cl_timestamp '; break; }                                                 /* Original was: if ('lastedit' == $sOrderMethod) $sSqlWhere .= ' ORDER BY page_touched '; else $sSqlWhere .= ' ORDER BY c1.cl_timestamp '; */   if ('descending' == $sOrder) $sSqlOrder = 'DESC'; else $sSqlOrder = 'ASC'; $sSqlWhere .= $sSqlOrder; if ($bCountSet) {     $sSqlWhere .= ' LIMIT '. $iCount; }   //DEBUG: output SQL query //$output .= 'QUERY: ['. $sSqlSelectFrom. $sSqlWhere. "] ";       // process the query $res = $dbr->query($sSqlSelectFrom . $sSqlWhere); $sk =& $wgUser->getSkin; if ($dbr->numRows( $res ) == 0) {     if (false == $bSuppressErrors) return htmlspecialchars( wfMsg( 'dynamicpagelist_noresults' ) ); else return ''; }   //start unordered list $output .= $sStartList. "\n"; //process results of query, outputing equivalent of Article</li> for each result, //or something similar if the list uses other startlist/endlist while ($row = $dbr->fetchObject( $res ) ) { $title = Title::makeTitle( $row->page_namespace, $row->page_title); $output .= $sStartItem; if (true == $bAddFirstCategoryDate) $output .= $wgLang->date($row->cl_timestamp). ': ';     if (true == $bShowNamespace) $output .= $sk->makeKnownLinkObj($title); else $output .= $sk->makeKnownLinkObj($title, htmlspecialchars($title->getText)); if (true == $bAddPageTouchedDate) $output .= ' (' . $wgLang->date($row->page_touched) . ')'; $output .= $sEndItem. "\n"; }
 * Die Änderungen / Ergänzungen sind hier grün hinterlegt:

Hallo, wo kann man denn Hilfe zum Einbinden der Extension finden? Denn wenn ich in meiner LocalSettings die Zeile  einfüge, erhalte ich nur eine weiße Seite und das Wiki ist dann leider nicht mehr da.

Cutting
How can i change the cutmethod of the dpl-generated list? Usually it's list by " * ", but i prefer this: · --89.217.82.113 16:52, 21 November 2010 (UTC)