Index: trunk/extensions/DynamicPageList/DynamicPageList2.php |
— | — | @@ -282,7 +282,16 @@ |
283 | 283 | * CATBULLETS variable |
284 | 284 | * @version 1.7.6 |
285 | 285 | * error correction: non existing array index 0 when trying to includematch content in a non-existing chapter (near #3887) |
286 | | - * |
| 286 | + * @version 1.7.7 |
| 287 | + * configuration switch allows to run DPL from protected pages only (ExtDynamicPageList2::$options['RunFromProtectedPagesOnly']) |
| 288 | + * @version 1.7.8 |
| 289 | + * allow html/wiki comments within template parameter assignments (include statement, line 540ff of DynamicPageList2Include.php) |
| 290 | + * accept include=* together with table= |
| 291 | + * Bugfix: %PAGES% was wrong (showing total pages in some cases |
| 292 | + * Bugfix: labeled section inclusion did not work because content was automatically truncated to a length of zero |
| 293 | + * added minrevisions & maxrevisions |
| 294 | + * @version 1.7.9 |
| 295 | + * ... |
287 | 296 | * ! when making changes here you must update the VERSION constant at the beginning of class ExtDynamicPageList2 ! |
288 | 297 | */ |
289 | 298 | |
— | — | @@ -299,9 +308,10 @@ |
300 | 309 | $wgHooks['LanguageGetMagic'][] = 'ExtDynamicPageList2__languageGetMagic'; |
301 | 310 | |
302 | 311 | $wgExtensionCredits['parserhook'][] = array( |
303 | | - 'path' => __FILE__, |
304 | | - 'name' => 'DynamicPageList2', |
305 | | - 'author' => array( "[http://en.wikinews.org/wiki/User:IlyaHaykinson IlyaHaykinson]", "[http://en.wikinews.org/wiki/User:Amgine Amgine]", "[http://de.wikipedia.org/wiki/Benutzer:Unendlich Unendlich]", "[http://meta.wikimedia.org/wiki/User:Dangerman Cyril Dangerville]", "[http://de.wikipedia.org/wiki/Benutzer:Algorithmix Algorithmix]" ), |
| 312 | + 'name' => 'DynamicPageList', |
| 313 | + 'author' => '[http://en.wikinews.org/wiki/User:IlyaHaykinson IlyaHaykinson], [http://en.wikinews.org/wiki/User:Amgine Amgine],' |
| 314 | + .'[http://de.wikipedia.org/wiki/Benutzer:Unendlich Unendlich], [http://meta.wikimedia.org/wiki/User:Dangerman Cyril Dangerville], ' |
| 315 | + .'[http://de.wikipedia.org/wiki/Benutzer:Algorithmix Algorithmix]', |
306 | 316 | 'url' => 'http://www.mediawiki.org/wiki/Extension:DynamicPageList', |
307 | 317 | 'description' => 'a highly flexible report generator for MediaWikis - manual and examples: see [http://semeb.com/dpldemo]', |
308 | 318 | 'version' => ExtDynamicPageList2::VERSION |
— | — | @@ -320,7 +330,7 @@ |
321 | 331 | |
322 | 332 | class ExtDynamicPageList2 |
323 | 333 | { |
324 | | - const VERSION = '1.7.6'; // current version |
| 334 | + const VERSION = '1.7.8'; // current version |
325 | 335 | |
326 | 336 | /** |
327 | 337 | * Extension options |
— | — | @@ -689,6 +699,11 @@ |
690 | 700 | */ |
691 | 701 | 'allrevisionssince' => array('default' => '', 'pattern' => '#^[-./:0-9]+$#'), |
692 | 702 | /** |
| 703 | + * Minimum/Maximum number of revisions required |
| 704 | + */ |
| 705 | + 'minrevisions' => array('default' => '', 'pattern' => '/^\d*$/'), |
| 706 | + 'maxrevisions' => array('default' => '', 'pattern' => '/^\d*$/'), |
| 707 | + /** |
693 | 708 | * noresultsheader / footer is some wiki text which will be output (instead of a warning message) |
694 | 709 | * if the result set is empty; setting 'noresultsheader' to something like ' ' will suppress |
695 | 710 | * the warning about empty result set. |
— | — | @@ -792,6 +807,10 @@ |
793 | 808 | 'titlemaxlength' => array('default' => '', 'pattern' => '/^\d*$/') |
794 | 809 | ); |
795 | 810 | |
| 811 | + // Note: If you add a line like the followin to your LocalSetings.php, DPL will only run from protected pages |
| 812 | + // ExtDynamicPageList2::$options['RunFromProtectedPagesOnly'] = "<small><i>Extension DPL (warning): current configuration allows execution from protected pages only.</i></small>"; |
| 813 | + |
| 814 | + |
796 | 815 | public static $debugMinLevels = array(); |
797 | 816 | public static $createdLinks; // the links created by DPL are collected here; |
798 | 817 | // they can be removed during the final ouput |
— | — | @@ -1110,7 +1129,13 @@ |
1111 | 1130 | $localParser = new Parser(); |
1112 | 1131 | $pOptions = $parser->mOptions; |
1113 | 1132 | $pTitle = $parser->mTitle; |
1114 | | - |
| 1133 | + |
| 1134 | + // check if DPL shall only be executed from protected pages |
| 1135 | + if (array_key_exists('RunFromProtectedPagesOnly',self::$options) && |
| 1136 | + self::$options['RunFromProtectedPagesOnly']==true && !($parser->mTitle->isProtected('edit'))) { |
| 1137 | + return (self::$options['RunFromProtectedPagesOnly']); |
| 1138 | + } |
| 1139 | + |
1115 | 1140 | // get database access |
1116 | 1141 | $dbr =& wfGetDB( DB_SLAVE ); |
1117 | 1142 | $sPageTable = $dbr->tableName( 'page' ); |
— | — | @@ -1169,7 +1194,12 @@ |
1170 | 1195 | $sAllRevisionsBefore = self::$options['allrevisionsbefore']['default']; |
1171 | 1196 | $sFirstRevisionSince = self::$options['firstrevisionsince']['default']; |
1172 | 1197 | $sAllRevisionsSince = self::$options['allrevisionssince']['default']; |
1173 | | - |
| 1198 | + |
| 1199 | + $_sMinRevisions = self::$options['minrevisions']['default']; |
| 1200 | + $iMinRevisions = ($_sMinRevisions == '') ? NULL: intval($_sMinRevisions); |
| 1201 | + $_sMaxRevisions = self::$options['maxrevisions']['default']; |
| 1202 | + $iMaxRevisions = ($_sMaxRevisions == '') ? NULL: intval($_sMaxRevisions); |
| 1203 | + |
1174 | 1204 | $sRedirects = self::$options['redirects']['default']; |
1175 | 1205 | |
1176 | 1206 | $bSuppressErrors = self::argBoolean(self::$options['suppresserrors']['default']); |
— | — | @@ -1221,7 +1251,7 @@ |
1222 | 1252 | |
1223 | 1253 | |
1224 | 1254 | $aSecLabels = array(); |
1225 | | - if($bIncPage && $_incpage != '*') $aSecLabels = explode(',', $_incpage); |
| 1255 | + if($bIncPage) $aSecLabels = explode(',', $_incpage); |
1226 | 1256 | $aSecLabelsMatch = array(); |
1227 | 1257 | $aSecLabelsNotMatch = array(); |
1228 | 1258 | $bIncParsed = false; // default is to match raw parameters |
— | — | @@ -1718,7 +1748,22 @@ |
1719 | 1749 | else // wrong value |
1720 | 1750 | $output .= $logger->msgWrongParam($sType, $sArg); |
1721 | 1751 | break; |
| 1752 | + case 'minrevisions': |
| 1753 | + //ensure that $iMinRevisions is a number |
| 1754 | + if( preg_match(self::$options['minrevisions']['pattern'], $sArg) ) |
| 1755 | + $iMinRevisions = ($sArg == '') ? NULL: intval($sArg); |
| 1756 | + else // wrong value |
| 1757 | + $output .= $logger->msgWrongParam('minrevisions', $sArg); |
| 1758 | + break; |
| 1759 | + case 'maxrevisions': |
| 1760 | + //ensure that $iMaxRevisions is a number |
| 1761 | + if( preg_match(self::$options['maxrevisions']['pattern'], $sArg) ) |
| 1762 | + $iMaxRevisions = ($sArg == '') ? NULL: intval($sArg); |
| 1763 | + else // wrong value |
| 1764 | + $output .= $logger->msgWrongParam('maxrevisions', $sArg); |
| 1765 | + break; |
1722 | 1766 | |
| 1767 | + |
1723 | 1768 | case 'openreferences': |
1724 | 1769 | if( in_array($sArg, self::$options['openreferences']) ) |
1725 | 1770 | $acceptOpenReferences = self::argBoolean($sArg); |
— | — | @@ -1855,7 +1900,7 @@ |
1856 | 1901 | case 'include': |
1857 | 1902 | case 'includepage': |
1858 | 1903 | $bIncPage = $sArg !== ''; |
1859 | | - if($bIncPage && $sArg != '*') |
| 1904 | + if($bIncPage) |
1860 | 1905 | $aSecLabels= explode(',', $sArg); |
1861 | 1906 | break; |
1862 | 1907 | |
— | — | @@ -2928,6 +2973,13 @@ |
2929 | 2974 | // page_id=rev_page (if revision table required) |
2930 | 2975 | $sSqlWhere .= $sSqlCond_page_rev; |
2931 | 2976 | |
| 2977 | + if ($iMinRevisions != NULL) { |
| 2978 | + $sSqlWhere .= " and ((select count(rev_aux2.rev_page) from revision as rev_aux2 where rev_aux2.rev_page=page.page_id) >= $iMinRevisions)"; |
| 2979 | + } |
| 2980 | + if ($iMaxRevisions != NULL) { |
| 2981 | + $sSqlWhere .= " and ((select count(rev_aux3.rev_page) from revision as rev_aux3 where rev_aux3.rev_page=page.page_id) <= $iMaxRevisions)"; |
| 2982 | + } |
| 2983 | + |
2932 | 2984 | // count(all categories) <= max no of categories |
2933 | 2985 | $sSqlWhere .= $sSqlCond_MaxCat; |
2934 | 2986 | |
— | — | @@ -3258,14 +3310,14 @@ |
3259 | 3311 | $dpl2result = $dpl->getText(); |
3260 | 3312 | $header=''; |
3261 | 3313 | if ($sOneResultHeader != '' && $rowcount==1) { |
3262 | | - $header = str_replace('%PAGES%',1,$sOneResultHeader); |
| 3314 | + $header = str_replace('%TOTALPAGES%',$rowcount,str_replace('%PAGES%',1,$sOneResultHeader)); |
3263 | 3315 | } else if ($rowcount==0) { |
3264 | 3316 | if ($sNoResultsHeader != '') $output .= str_replace( '\n', "\n", str_replace( "¶", "\n", $sNoResultsHeader)); |
3265 | 3317 | if ($sNoResultsFooter != '') $output .= str_replace( '\n', "\n", str_replace( "¶", "\n", $sNoResultsFooter)); |
3266 | 3318 | if ($sNoResultsHeader == '' && $sNoResultsFooter == '') $output .= $logger->escapeMsg(DPL2_i18n::WARN_NORESULTS); |
3267 | 3319 | } |
3268 | 3320 | else { |
3269 | | - if ($sResultsHeader != '') $header = str_replace('%TOTALPAGES%',$rowcount,str_replace('%PAGES%',$rowcount,$sResultsHeader)); |
| 3321 | + if ($sResultsHeader != '') $header = str_replace('%TOTALPAGES%',$rowcount,str_replace('%PAGES%',$dpl->getRowCount(),$sResultsHeader)); |
3270 | 3322 | } |
3271 | 3323 | $header = str_replace( '\n', "\n", str_replace( "¶", "\n", $header )); |
3272 | 3324 | $header = str_replace('%VERSION%', self::VERSION,$header); |
— | — | @@ -3785,6 +3837,7 @@ |
3786 | 3838 | $rBody=''; |
3787 | 3839 | // the following statement caused a problem with multiple columns: $this->filteredCount = 0; |
3788 | 3840 | for ($i = $iStart; $i < $iStart+$iCount; $i++) { |
| 3841 | + |
3789 | 3842 | $article = $this->mArticles[$i]; |
3790 | 3843 | $pagename = $article->mTitle->getPrefixedText(); |
3791 | 3844 | if ($this->mEscapeLinks && ($article->mNamespace==14 || $article->mNamespace==6) ) { |
— | — | @@ -3796,7 +3849,7 @@ |
3797 | 3850 | |
3798 | 3851 | if ($this->mIncPage) { |
3799 | 3852 | $matchFailed=false; |
3800 | | - if(empty($this->mIncSecLabels)) { // include whole article |
| 3853 | + if(empty($this->mIncSecLabels) || $this->mIncSecLabels[0]=='*') { // include whole article |
3801 | 3854 | $title = $article->mTitle->getPrefixedText(); |
3802 | 3855 | if ($mode->name == 'userformat') $incwiki = ''; |
3803 | 3856 | else $incwiki = '<br/>'; |
— | — | @@ -3823,7 +3876,13 @@ |
3824 | 3877 | } |
3825 | 3878 | else { |
3826 | 3879 | // append full text to output |
3827 | | - $incwiki .= $text; |
| 3880 | + if (array_key_exists('0',$mode->sSectionTags)){ |
| 3881 | + $incwiki .= $this->substTagParm($mode->sSectionTags[0], $pagename, $article,$this->filteredCount, $iTitleMaxLen); |
| 3882 | + $pieces = array(0=>$text); |
| 3883 | + $this->formatSingleItems(&$pieces, 0); |
| 3884 | + $incwiki .= $pieces[0]; |
| 3885 | + } |
| 3886 | + else $incwiki .= $text; |
3828 | 3887 | } |
3829 | 3888 | } |
3830 | 3889 | else { |
— | — | @@ -4002,7 +4061,7 @@ |
4003 | 4062 | if($article->mUserLink != '') $rBody .= ' . . [[User:' . $article->mUser .'|'.$article->mUser.']]'; |
4004 | 4063 | if($article->mContributor != '')$rBody .= ' . . [[User:' . $article->mContributor .'|'.$article->mContributor." $article->mContrib]]"; |
4005 | 4064 | |
4006 | | - if( !empty($article->mCategoryLinks) ) $rBody .= ' . . <small>' . wfMsg('categories') . ': ' . $wgLang->pipeList( $article->mCategoryLinks ) . '</small>'; |
| 4065 | + if( !empty($article->mCategoryLinks) ) $rBody .= ' . . <small>' . wfMsg('categories') . ': ' . implode(' | ', $article->mCategoryLinks) . '</small>'; |
4007 | 4066 | } |
4008 | 4067 | |
4009 | 4068 | // add included contents |
Index: trunk/extensions/DynamicPageList/DynamicPageList2Include.php |
— | — | @@ -82,6 +82,10 @@ |
83 | 83 | * allow % within included template parameters |
84 | 84 | * @version 1.7.3 |
85 | 85 | * %SECTION% can now be used within multiseseparators (see includeHeading) |
| 86 | + * @version 1.7.8 |
| 87 | + * allow html/wiki comments within template parameter assignments (include statement, line 540ff of DynamicPageList2Include.php) |
| 88 | + * @version 1.7.9 |
| 89 | + * bug fix (near line #150): section inclusion did not work because all content was truncated to 0 bytes |
86 | 90 | |
87 | 91 | */ |
88 | 92 | |
— | — | @@ -125,12 +129,14 @@ |
126 | 130 | private static function parse($parser, $title, $text, $part1, $skiphead=0, $recursionCheck=true, $maxLength=-1, $link='', $trim=false) |
127 | 131 | { |
128 | 132 | global $wgVersion; |
129 | | - |
| 133 | + |
130 | 134 | // if someone tries something like<section begin=blah>lst only</section> |
131 | 135 | // text, may as well do the right thing. |
132 | 136 | $text = str_replace('</section>', '', $text); |
133 | | - |
| 137 | + |
| 138 | + |
134 | 139 | if (self::open($parser, $part1)) { |
| 140 | + |
135 | 141 | |
136 | 142 | //Handle recursion here, so we can break cycles. Although we can't do |
137 | 143 | //feature detection here, r18473 was only a few weeks before the |
— | — | @@ -141,7 +147,7 @@ |
142 | 148 | self::close($parser, $part1); |
143 | 149 | } |
144 | 150 | |
145 | | - if ($maxLength>=0) { |
| 151 | + if ($maxLength>0) { |
146 | 152 | $text = self::limitTranscludedText($text,$maxLength,$link); |
147 | 153 | } |
148 | 154 | if ($trim) return trim($text); |
— | — | @@ -230,7 +236,7 @@ |
231 | 237 | } |
232 | 238 | $any=false; |
233 | 239 | $pat = self::createSectionPattern($sec,$to,$any); |
234 | | - |
| 240 | + |
235 | 241 | preg_match_all( $pat, $text, $m, PREG_PATTERN_ORDER); |
236 | 242 | |
237 | 243 | foreach ($m[2] as $nr=>$piece) { |
— | — | @@ -541,9 +547,9 @@ |
542 | 548 | // named parameter |
543 | 549 | $exParmQuote = str_replace('/','\/',$exParm); |
544 | 550 | foreach ($parms as $parm) { |
545 | | - if (!preg_match("/^\s*$exParmQuote\s*=/",$parm)) continue; |
| 551 | + if (!preg_match("/^\s*$exParmQuote\s*(<!--.*-->)*\s*=/",$parm)) continue; |
546 | 552 | $found=true; |
547 | | - $output[$n] .= $dpl->formatTemplateArg(preg_replace("/^$exParmQuote\s*=\s*/","",$parm),$dplNr,$exParmKey,$firstCall,$maxlen); |
| 553 | + $output[$n] .= $dpl->formatTemplateArg(preg_replace("/^$exParmQuote\s*(<!--.*-->)*\s*=\s*/","",$parm),$dplNr,$exParmKey,$firstCall,$maxlen); |
548 | 554 | break; |
549 | 555 | } |
550 | 556 | } |