Index: trunk/extensions/DynamicPageList/DynamicPageList.php |
— | — | @@ -59,7 +59,7 @@ |
60 | 60 | |
61 | 61 | $wgHooks['LanguageGetMagic'][] = 'ExtDynamicPageList__languageGetMagic'; |
62 | 62 | |
63 | | -$DPLVersion = '1.8.1'; |
| 63 | +$DPLVersion = '1.8.3'; |
64 | 64 | |
65 | 65 | $wgExtensionCredits['parserhook'][] = array( |
66 | 66 | 'path' => __FILE__, |
Index: trunk/extensions/DynamicPageList/DPLSetup.php |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | * addcategories: bug fixed |
29 | 29 | * CATLIST variable defined |
30 | 30 | * @version 0.9.3 |
31 | | - * allow � as an alias for | |
| 31 | + * allow ?as an alias for | |
32 | 32 | * escapelinks= introduced |
33 | 33 | * @version 0.9.4 |
34 | 34 | * allow "-" with categories = |
— | — | @@ -314,8 +314,15 @@ |
315 | 315 | * @version 1.8.1 |
316 | 316 | * bugfix: %DATE% was not expanded when addedit=true and ordermethod=lastedit were chosen |
317 | 317 | * bugfix: allrevisionssince delivered wrong results |
| 318 | + * @version 1.8.2 |
| 319 | + * bugfix: ordermethod=lastedit AND minoredits=exclude produced a SQL error |
| 320 | + |
| 321 | + * bugfix dplcache |
| 322 | + * config switch: respectParserCache |
| 323 | + * date timestamp adapt to user preferences |
| 324 | + * @version 1.8.3 |
| 325 | + * bugfix: URL variable expansion |
318 | 326 | |
319 | | - |
320 | 327 | * ! when making changes here you must update the version field in DynamicPageList.php and DynamicPageListMigration.php ! |
321 | 328 | */ |
322 | 329 | |
— | — | @@ -351,6 +358,8 @@ |
352 | 359 | public static $behavingLikeIntersection = false; // Changes certain default values to comply with Extension:Intersection |
353 | 360 | public static $functionalRichness = 0; // The amount of functionality of DPL that is accesible for the user; |
354 | 361 | // .. to be set by DynamicPageList.php and DynamicPageListMigration.php |
| 362 | + public static $respectParserCache = false; // false = make page dynamic ; true = execute only when parser cache is refreshed |
| 363 | + // .. to be changed in LocalSettings.php |
355 | 364 | |
356 | 365 | /** |
357 | 366 | * Map parameters to possible values. |
— | — | @@ -369,7 +378,9 @@ |
370 | 379 | 'addpagesize' => array('default' => 'false', 'true', 'no', 'yes', '0', '1', 'off', 'on'), |
371 | 380 | 'addpagetoucheddate' => array('default' => 'false', 'true', 'no', 'yes', '0', '1', 'off', 'on'), |
372 | 381 | 'adduser' => array('default' => 'false', 'true', 'no', 'yes', '0', '1', 'off', 'on'), |
373 | | - 'allowcachedresults' => array('default' => 'false', 'true', 'no', 'yes', '0', '1', 'off', 'on', 'yes+warn'), |
| 382 | + |
| 383 | + // default of allowchacheresults depends on behaveasIntersetion and on LopcalSettings ... |
| 384 | + 'allowcachedresults' => array( 'true', 'false', 'no', 'yes', 'yes+warn', '0', '1', 'off', 'on'), |
374 | 385 | /** |
375 | 386 | * search for a page with the same title in another namespace (this is normally the article to a talk page) |
376 | 387 | */ |
— | — | @@ -533,7 +544,7 @@ |
534 | 545 | /** |
535 | 546 | * listseparators is an array of four tags (in html or wiki syntax) which defines the output of DPL |
536 | 547 | * if mode = 'userformat' was specified. |
537 | | - * '\n' or '�' in the input will be interpreted as a newline character. |
| 548 | + * '\n' or '? in the input will be interpreted as a newline character. |
538 | 549 | * '%xxx%' in the input will be replaced by a corresponding value (xxx= PAGE, NR, COUNT etc.) |
539 | 550 | * t1 and t4 are the "outer envelope" for the whole result list, |
540 | 551 | * t2,t3 form an inner envelope around the article name of each entry. |
— | — | @@ -863,6 +874,7 @@ |
864 | 875 | suppresserrors |
865 | 876 | ', |
866 | 877 | 1 => ' |
| 878 | + allowcachedresults |
867 | 879 | execandexit |
868 | 880 | columns |
869 | 881 | debug |
— | — | @@ -899,7 +911,6 @@ |
900 | 912 | addpagesize |
901 | 913 | addpagetoucheddate |
902 | 914 | adduser |
903 | | - allowcachedresults |
904 | 915 | categoriesminmax |
905 | 916 | createdby |
906 | 917 | dominantsection |
— | — | @@ -1146,7 +1157,7 @@ |
1147 | 1158 | $numargs = func_num_args(); |
1148 | 1159 | if ($numargs < 2) { |
1149 | 1160 | $input = "#dpl: no arguments specified"; |
1150 | | - return str_replace('�','<','�pre>�nowiki>'.$input.'�/nowiki>�/pre>'); |
| 1161 | + return str_replace('?,'<','�pre>�nowiki>'.$input.'?nowiki>?pre>'); |
1151 | 1162 | } |
1152 | 1163 | |
1153 | 1164 | // fetch all user-provided arguments (skipping $parser) |
— | — | @@ -1156,7 +1167,7 @@ |
1157 | 1168 | $input .= str_replace("\n","",$p1) ."\n"; |
1158 | 1169 | } |
1159 | 1170 | // for debugging you may want to uncomment the following statement |
1160 | | - // return str_replace('�','<','�pre>�nowiki>'.$input.'�/nowiki>�/pre>'); |
| 1171 | + // return str_replace('?,'<','�pre>�nowiki>'.$input.'?nowiki>?pre>'); |
1161 | 1172 | |
1162 | 1173 | |
1163 | 1174 | // $dump1 = self::dumpParsedRefs($parser,"before DPL func"); |
Index: trunk/extensions/DynamicPageList/DPLMain.php |
— | — | @@ -11,6 +11,9 @@ |
12 | 12 | // The real callback function for converting the input text to wiki text output |
13 | 13 | public static function dynamicPageList( $input, $params, &$parser, &$bReset, $calledInMode ) { |
14 | 14 | |
| 15 | + // Output |
| 16 | + $output = ''; |
| 17 | + |
15 | 18 | error_reporting(E_ALL); |
16 | 19 | |
17 | 20 | global $wgUser, $wgContLang, $wgRequest, $wgRawHtml; |
— | — | @@ -74,16 +77,9 @@ |
75 | 78 | |
76 | 79 | // check parameters which can be set via the URL |
77 | 80 | |
78 | | - if (strpos($input,'{%DPL_')!== false) { |
| 81 | + if (strpos($input,'{%DPL_') >= 0) { |
79 | 82 | for($i=1;$i<=5;$i++) { |
80 | | - $dplArg = $wgRequest->getVal('DPL_arg'.$i,''); |
81 | | - if ($dplArg=='') { |
82 | | - $input=preg_replace('/\{%DPL_arg'.$i.':(.*)%\}/U', '\1' ,$input); |
83 | | - $input=preg_replace('/\{%DPL_arg'.$i.'%\}/U', '\1' ,$input); |
84 | | - } else { |
85 | | - $input=preg_replace('/\{%DPL_arg'.$i.':.*%\}/U ', $dplArg ,$input); |
86 | | - $input=str_replace('{%DPL_arg'.$i.'%}' , $dplArg ,$input); |
87 | | - } |
| 83 | + $input = self::resolveUrlArg($input,'DPL_arg'.$i); |
88 | 84 | } |
89 | 85 | } |
90 | 86 | |
— | — | @@ -94,7 +90,8 @@ |
95 | 91 | $iCount = -1; |
96 | 92 | |
97 | 93 | // commandline parameters like %DPL_offset% are replaced |
98 | | - $input = str_replace('{%DPL_offset%}',$iOffset,$input); |
| 94 | + $input = self::resolveUrlArg($input,'DPL_offset'); |
| 95 | + $input = self::resolveUrlArg($input,'DPL_count'); |
99 | 96 | |
100 | 97 | $originalInput = $input; |
101 | 98 | |
— | — | @@ -126,13 +123,14 @@ |
127 | 124 | // execAndExit |
128 | 125 | $sExecAndExit= ExtDynamicPageList::$options['execandexit']['default']; |
129 | 126 | |
130 | | - // ordermethod, order, mode, userdateformat: |
| 127 | + // ordermethod, order, mode, userdateformat, allowcachedresults: |
131 | 128 | // if we have to behave like Extension:Intersection we use different default values for some commands |
132 | 129 | if (ExtDynamicPageList::$behavingLikeIntersection) { |
133 | 130 | ExtDynamicPageList::$options['ordermethod'] = array('default' => 'categoryadd', 'categoryadd', 'lastedit'); |
134 | 131 | ExtDynamicPageList::$options['order'] = array('default' => 'descending', 'ascending', 'descending'); |
135 | 132 | ExtDynamicPageList::$options['mode'] = array('default' => 'unordered', 'none', 'ordered', 'unordered'); |
136 | 133 | ExtDynamicPageList::$options['userdateformat'] = array('default' => 'Y-m-d: '); |
| 134 | + ExtDynamicPageList::$options['allowcachedresults']['default'] = 'true'; |
137 | 135 | } |
138 | 136 | else { |
139 | 137 | ExtDynamicPageList::$options['ordermethod'] = array('default' => 'title', 'counter', 'size', 'category', 'sortkey', |
— | — | @@ -142,6 +140,7 @@ |
143 | 141 | ExtDynamicPageList::$options['order'] = array('default' => 'ascending', 'ascending', 'descending'); |
144 | 142 | ExtDynamicPageList::$options['mode'] = array('default' => 'unordered', 'category', 'inline', 'none', 'ordered', 'unordered', 'userformat'); |
145 | 143 | ExtDynamicPageList::$options['userdateformat'] = array('default' => 'Y-m-d H:i: '); |
| 144 | + ExtDynamicPageList::$options['allowcachedresults']['default'] = ExtDynamicPageList::$respectParserCache; |
146 | 145 | } |
147 | 146 | $aOrderMethods = array(ExtDynamicPageList::$options['ordermethod']['default']); |
148 | 147 | $sOrder = ExtDynamicPageList::$options['order']['default']; |
— | — | @@ -305,9 +304,6 @@ |
306 | 305 | $sUpdateRules = ExtDynamicPageList::$options['updaterules']['default']; |
307 | 306 | $sDeleteRules = ExtDynamicPageList::$options['deleterules']['default']; |
308 | 307 | |
309 | | - // Output |
310 | | - $output = ''; |
311 | | - |
312 | 308 | |
313 | 309 | // ###### PARSE PARAMETERS ###### |
314 | 310 | |
— | — | @@ -315,10 +311,10 @@ |
316 | 312 | $input = str_replace('»','>',$input); |
317 | 313 | $input = str_replace('«','<',$input); |
318 | 314 | |
319 | | - // use the � as a general alias for | |
| 315 | + // use the � as a general alias for | |
320 | 316 | $input = str_replace('¦','|',$input); // the symbol is utf8-escaped |
321 | 317 | |
322 | | - // the combination '�{' and '}�'will be translated to double curly braces; this allows postponed template execution |
| 318 | + // the combination '�{' and '}�'will be translated to double curly braces; this allows postponed template execution |
323 | 319 | // which is crucial for DPL queries which call other DPL queries |
324 | 320 | $input = str_replace('²{','{{',$input); |
325 | 321 | $input = str_replace('}²','}}',$input); |
— | — | @@ -572,7 +568,7 @@ |
573 | 569 | case 'execandexit': |
574 | 570 | // we offer a possibility to execute a DPL command without querying the database |
575 | 571 | // this is useful if you want to catch the command line parameters DPL_arg1,... etc |
576 | | - return $sArg; |
| 572 | + $sExecAndExit = $sArg; |
577 | 573 | break; |
578 | 574 | |
579 | 575 | |
— | — | @@ -945,7 +941,6 @@ |
946 | 942 | $bSelectionCriteriaFound=true; |
947 | 943 | $bConflictsWithOpenReferences=true; |
948 | 944 | $bAllowCachedResults = true; |
949 | | - $parser->disableCache(false); |
950 | 945 | } |
951 | 946 | break; |
952 | 947 | |
— | — | @@ -1203,7 +1198,6 @@ |
1204 | 1199 | $bAllowCachedResults = true; |
1205 | 1200 | $bWarnCachedResults = true; |
1206 | 1201 | } |
1207 | | - if ($bAllowCachedResults) $parser->disableCache(); |
1208 | 1202 | } |
1209 | 1203 | else |
1210 | 1204 | $output .= $logger->msgWrongParam('allowcachedresults', $sArg); |
— | — | @@ -1445,8 +1439,21 @@ |
1446 | 1440 | // justify limits; |
1447 | 1441 | $iCount = ExtDynamicPageList::$maxResultCount; |
1448 | 1442 | } |
| 1443 | + |
| 1444 | + |
| 1445 | + // disable parser cache if caching is not allowed (which is default for DPL but not for <DynamicPageList>) |
| 1446 | + if ( !$bAllowCachedResults) { |
| 1447 | + $parser->disableCache(); |
| 1448 | + } |
| 1449 | + // place cache warning in resultsheader |
| 1450 | + if ($bWarnCachedResults) $sResultsHeader = '{{DPL Cache Warning}}' . $sResultsHeader; |
1449 | 1451 | |
1450 | 1452 | |
| 1453 | + |
| 1454 | + if ($sExecAndExit != '') return $sExecAndExit; |
| 1455 | + |
| 1456 | + |
| 1457 | + |
1451 | 1458 | // if Caching is desired AND if the cache is up to date: get result from Cache and exit |
1452 | 1459 | |
1453 | 1460 | global $wgUploadDirectory, $wgRequest; |
— | — | @@ -1492,10 +1499,7 @@ |
1493 | 1500 | $iTotalIncludeCatCount = count($aIncludeCategories, COUNT_RECURSIVE) - $iIncludeCatCount; |
1494 | 1501 | $iExcludeCatCount = count($aExcludeCategories); |
1495 | 1502 | $iTotalCatCount = $iTotalIncludeCatCount + $iExcludeCatCount; |
1496 | | - |
1497 | | - // place cache warning in resultsheader |
1498 | | - if ($bWarnCachedResults) $sResultsHeader = '{{DPL Cache Warning}}' . $sResultsHeader; |
1499 | | - |
| 1503 | + |
1500 | 1504 | if ($calledInMode=='tag') { |
1501 | 1505 | // in tag mode 'eliminate' is the same as 'reset' for tpl,cat,img |
1502 | 1506 | if ($bReset[5]) { $bReset[1] = true; $bReset[5] = false; } |
— | — | @@ -1519,7 +1523,8 @@ |
1520 | 1524 | } |
1521 | 1525 | |
1522 | 1526 | |
1523 | | - // ###### CHECKS ON PARAMETERS ###### |
| 1527 | + // ###### CHECKS ON PARAMETERS ###### |
| 1528 | + |
1524 | 1529 | // too many categories! |
1525 | 1530 | if ( ($iTotalCatCount > ExtDynamicPageList::$maxCategoryCount) && (!ExtDynamicPageList::$allowUnlimitedCategories) ) |
1526 | 1531 | return $output . $logger->escapeMsg(DPL_i18n::FATAL_TOOMANYCATS, ExtDynamicPageList::$maxCategoryCount); |
— | — | @@ -1723,16 +1728,19 @@ |
1724 | 1729 | // deleted because of conflict with revsion-parameters |
1725 | 1730 | $sSqlCond_page_rev = ' AND '.$sPageTable.'.page_id=rev.rev_page AND rev.rev_timestamp=( SELECT MIN(rev_aux.rev_timestamp) FROM ' . $sRevisionTable . ' AS rev_aux WHERE rev_aux.rev_page=rev.rev_page )'; |
1726 | 1731 | break; |
| 1732 | + case 'pagetouched': |
| 1733 | + $sSqlPage_touched = ", $sPageTable.page_touched as page_touched"; |
| 1734 | + break; |
1727 | 1735 | case 'lastedit': |
1728 | | - if ($bAddUser) { |
| 1736 | + if (ExtDynamicPageList::$behavingLikeIntersection) { |
| 1737 | + $sSqlPage_touched = ", $sPageTable.page_touched as page_touched"; |
| 1738 | + } |
| 1739 | + else { |
1729 | 1740 | $sSqlRevisionTable = $sRevisionTable . ' AS rev, '; |
1730 | 1741 | $sSqlRev_timestamp = ', rev_timestamp'; |
1731 | 1742 | // deleted because of conflict with revision-parameters |
1732 | 1743 | $sSqlCond_page_rev = ' AND '.$sPageTable.'.page_id=rev.rev_page AND rev.rev_timestamp=( SELECT MAX(rev_aux.rev_timestamp) FROM ' . $sRevisionTable . ' AS rev_aux WHERE rev_aux.rev_page=rev.rev_page )'; |
1733 | 1744 | } |
1734 | | - else { |
1735 | | - $sSqlPage_touched = ", $sPageTable.page_touched as page_touched"; |
1736 | | - } |
1737 | 1745 | break; |
1738 | 1746 | case 'sortkey': |
1739 | 1747 | // We need the namespaces with strictly positive indices (DPL allowed namespaces, except the first one: Main). |
— | — | @@ -2040,7 +2048,7 @@ |
2041 | 2049 | $sSqlPage_counter = ", $sPageTable.page_counter as page_counter"; |
2042 | 2050 | if ($bAddPageSize) |
2043 | 2051 | $sSqlPage_size = ", $sPageTable.page_len as page_len"; |
2044 | | - if ($bAddPageTouchedDate) |
| 2052 | + if ($bAddPageTouchedDate && $sSqlPage_touched=='') |
2045 | 2053 | $sSqlPage_touched = ", $sPageTable.page_touched as page_touched"; |
2046 | 2054 | if ($bAddUser || $bAddAuthor || $bAddLastEditor || $sSqlRevisionTable != '') |
2047 | 2055 | $sSqlRev_user = ', rev_user, rev_user_text'; |
— | — | @@ -2262,7 +2270,9 @@ |
2263 | 2271 | $sSqlWhere .= 'rev_timestamp'; |
2264 | 2272 | break; |
2265 | 2273 | case 'lastedit': |
2266 | | - $sSqlWhere .= 'page_touched'; |
| 2274 | + // extension:intersection used to sort by page_touched although the field is called 'lastedit' |
| 2275 | + if (ExtDynamicPageList::$behavingLikeIntersection) $sSqlWhere .= 'page_touched'; |
| 2276 | + else $sSqlWhere .= 'rev_timestamp'; |
2267 | 2277 | break; |
2268 | 2278 | case 'pagetouched': |
2269 | 2279 | $sSqlWhere .= 'page_touched'; |
— | — | @@ -2363,7 +2373,10 @@ |
2364 | 2374 | } |
2365 | 2375 | } |
2366 | 2376 | |
2367 | | - |
| 2377 | + |
| 2378 | + // find user's time correction |
| 2379 | + $timeCorrection = self::getTimeCorrection($wgUser); |
| 2380 | + |
2368 | 2381 | $iArticle = 0; |
2369 | 2382 | |
2370 | 2383 | while( $row = $dbr->fetchObject ( $res ) ) { |
— | — | @@ -2473,6 +2486,11 @@ |
2474 | 2487 | elseif ($bAddFirstCategoryDate) $dplArticle->mDate = $row->cl_timestamp; |
2475 | 2488 | elseif ($bAddEditDate && isset($row->rev_timestamp)) $dplArticle->mDate = $row->rev_timestamp; |
2476 | 2489 | elseif ($bAddEditDate && isset($row->page_touched)) $dplArticle->mDate = $row->page_touched; |
| 2490 | + |
| 2491 | + // time zone adjustment |
| 2492 | + if ($dplArticle->mDate!='') { |
| 2493 | + $dplArticle->mDate= date('YmdHis',strtotime($dplArticle->mDate)-$timeCorrection); |
| 2494 | + } |
2477 | 2495 | |
2478 | 2496 | if ($dplArticle->mDate!='' && $sUserDateFormat!='') { |
2479 | 2497 | // we apply the userdateformat |
— | — | @@ -2488,7 +2506,7 @@ |
2489 | 2507 | |
2490 | 2508 | //USER/AUTHOR(S) |
2491 | 2509 | // because we are going to do a recursive parse at the end of the output phase |
2492 | | - // we have to generate wiki syntax for linking to a user�s homepage |
| 2510 | + // we have to generate wiki syntax for linking to a user�s homepage |
2493 | 2511 | if($bAddUser || $bAddAuthor || $bAddLastEditor || $sLastRevisionBefore.$sAllRevisionsBefore.$sFirstRevisionSince.$sAllRevisionsSince != '') { |
2494 | 2512 | $dplArticle->mUserLink = '[[User:'.$row->rev_user_text.'|'.$row->rev_user_text.']]'; |
2495 | 2513 | $dplArticle->mUser = $row->rev_user_text; |
— | — | @@ -2652,7 +2670,7 @@ |
2653 | 2671 | ExtDynamicPageList::$createdLinks[3][$imgid] = $imgid; |
2654 | 2672 | } |
2655 | 2673 | } |
2656 | | - |
| 2674 | + |
2657 | 2675 | return $output; |
2658 | 2676 | |
2659 | 2677 | } |
— | — | @@ -2756,5 +2774,27 @@ |
2757 | 2775 | return false; |
2758 | 2776 | } |
2759 | 2777 | |
| 2778 | + private static function getTimeCorrection($user) { |
| 2779 | + $i=strtotime('20000101 00:00:00'); |
| 2780 | + $corr = $user->getOption('timecorrection','00:00').':00'; |
| 2781 | + if ($corr[0]=='-') { |
| 2782 | + return strtotime('20000101 '.substr($corr,1)) - $i; |
| 2783 | + } |
| 2784 | + else { |
| 2785 | + return $i - strtotime('20000101 '.$corr); |
| 2786 | + } |
| 2787 | + } |
| 2788 | + |
| 2789 | + private static function resolveUrlArg($input,$arg) { |
| 2790 | + global $wgRequest; |
| 2791 | + $dplArg = $wgRequest->getVal($arg,''); |
| 2792 | + if ($dplArg=='') { |
| 2793 | + $input=preg_replace('/\{%'.$arg.':(.*)%\}/U', '\1' ,$input); |
| 2794 | + return str_replace('{%'.$arg.'%}', '' ,$input); |
| 2795 | + } else { |
| 2796 | + $input=preg_replace('/\{%'.$arg.':.*%\}/U ', $dplArg ,$input); |
| 2797 | + return str_replace('{%'.$arg.'%}' , $dplArg ,$input); |
| 2798 | + } |
| 2799 | + } |
2760 | 2800 | } |
2761 | 2801 | |
Index: trunk/extensions/DynamicPageList/DynamicPageListMigration.php |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | |
42 | 42 | $wgHooks['LanguageGetMagic'][] = 'ExtDynamicPageList__languageGetMagic'; |
43 | 43 | |
44 | | -$DPLVersion = '1.8.1'; |
| 44 | +$DPLVersion = '1.8.3'; |
45 | 45 | |
46 | 46 | $wgExtensionCredits['parserhook'][] = array( |
47 | 47 | 'path' => __FILE__, |