Index: trunk/extensions/QPoll/README |
— | — | @@ -1,4 +1,4 @@ |
2 | | -MediaWiki extension QPoll, version 0.6.3 |
| 2 | +MediaWiki extension QPoll, version 0.6.4 |
3 | 3 | |
4 | 4 | This extension allows to create polls embedded into the wikipages. Every poll |
5 | 5 | may contain a set of the questions of various types. The polls can be "chained" |
Index: trunk/extensions/QPoll/qp_question.php |
— | — | @@ -541,7 +541,7 @@ |
542 | 542 | $this->mType = 'mixedChoice'; |
543 | 543 | break; |
544 | 544 | default : |
545 | | - $this->setState( 'error', wfMsg( 'qp_error_invalid_question_type', htmlentities( $type ) ) ); |
| 545 | + $this->setState( 'error', wfMsg( 'qp_error_invalid_question_type', qp_Setup::entities( $type ) ) ); |
546 | 546 | } |
547 | 547 | } |
548 | 548 | |
— | — | @@ -810,7 +810,7 @@ |
811 | 811 | $inp[ 'type' ] = $inputType; |
812 | 812 | $inp[ 'name' ] = $name; |
813 | 813 | if ( $inputType == 'text' ) { |
814 | | - $inp[ 'value' ] = htmlspecialchars( $text_answer ); |
| 814 | + $inp[ 'value' ] = qp_Setup::specialchars( $text_answer ); |
815 | 815 | if ( $this->textInputStyle != '' ) { |
816 | 816 | $inp[ 'style' ] = $this->textInputStyle; |
817 | 817 | } |
Index: trunk/extensions/QPoll/Excel/Excel_Format.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
34 | 34 | */ |
35 | 35 | |
36 | | -require_once( $qp_ExtDir . '/Excel/PEAR.php' ); |
| 36 | +require_once( qp_Setup::$ExtDir . '/Excel/PEAR.php' ); |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Class for generating Excel XF records (formats) |
Index: trunk/extensions/QPoll/Excel/Excel_Parser.php |
— | — | @@ -93,7 +93,7 @@ |
94 | 94 | define('SPREADSHEET_EXCEL_WRITER_NE', "<>"); |
95 | 95 | |
96 | 96 | |
97 | | -require_once( $qp_ExtDir . '/Excel/PEAR.php' ); |
| 97 | +require_once( qp_Setup::$ExtDir . '/Excel/PEAR.php' ); |
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Class for parsing Excel formulas |
Index: trunk/extensions/QPoll/Excel/Excel_Workbook.php |
— | — | @@ -32,12 +32,12 @@ |
33 | 33 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
34 | 34 | */ |
35 | 35 | |
36 | | -require_once( $qp_ExtDir . '/Excel/Excel_Format.php' ); |
37 | | -require_once( $qp_ExtDir . '/Excel/Excel_BIFFwriter.php' ); |
38 | | -require_once( $qp_ExtDir . '/Excel/Excel_Worksheet.php' ); |
39 | | -require_once( $qp_ExtDir . '/Excel/Excel_Parser.php' ); |
40 | | -require_once( $qp_ExtDir . '/Excel/OLE_PPS_Root.php' ); |
41 | | -require_once( $qp_ExtDir . '/Excel/OLE_PPS_File.php' ); |
| 36 | +require_once( qp_Setup::$ExtDir . '/Excel/Excel_Format.php' ); |
| 37 | +require_once( qp_Setup::$ExtDir . '/Excel/Excel_BIFFwriter.php' ); |
| 38 | +require_once( qp_Setup::$ExtDir . '/Excel/Excel_Worksheet.php' ); |
| 39 | +require_once( qp_Setup::$ExtDir . '/Excel/Excel_Parser.php' ); |
| 40 | +require_once( qp_Setup::$ExtDir . '/Excel/OLE_PPS_Root.php' ); |
| 41 | +require_once( qp_Setup::$ExtDir . '/Excel/OLE_PPS_File.php' ); |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Class for generating Excel Spreadsheets |
— | — | @@ -375,7 +375,7 @@ |
376 | 376 | */ |
377 | 377 | function &addValidator() |
378 | 378 | { |
379 | | - include_once( $qp_ExtDir . '/Excel/Excel_Validator.php' ); |
| 379 | + include_once( qp_Setup::$ExtDir . '/Excel/Excel_Validator.php' ); |
380 | 380 | /* FIXME: check for successful inclusion*/ |
381 | 381 | $valid = new Spreadsheet_Excel_Writer_Validator($this->_parser); |
382 | 382 | return $valid; |
Index: trunk/extensions/QPoll/Excel/OLE.php |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | define('OLE_LONG_INT_SIZE', 4); |
32 | 32 | define('OLE_PPS_SIZE', 0x80); |
33 | 33 | |
34 | | -require_once( $qp_ExtDir . '/Excel/PEAR.php' ); |
| 34 | +require_once( qp_Setup::$ExtDir . '/Excel/PEAR.php' ); |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Array for storing OLE instances that are accessed from |
— | — | @@ -222,7 +222,7 @@ |
223 | 223 | */ |
224 | 224 | function getStream($blockIdOrPps) |
225 | 225 | { |
226 | | - require_once( $qp_ExtDir . '/Excel/OLE_ChainedBlockStream.php' ); |
| 226 | + require_once( qp_Setup::$ExtDir . '/Excel/OLE_ChainedBlockStream.php' ); |
227 | 227 | static $isRegistered = false; |
228 | 228 | if (!$isRegistered) { |
229 | 229 | stream_wrapper_register('ole-chainedblockstream', |
Index: trunk/extensions/QPoll/Excel/OLE_ChainedBlockStream.php |
— | — | @@ -22,8 +22,8 @@ |
23 | 23 | * @since File available since Release 0.6.0 |
24 | 24 | */ |
25 | 25 | |
26 | | -require_once( $qp_ExtDir . '/Excel/PEAR.php' ); |
27 | | -require_once( $qp_ExtDir . '/Excel/OLE.php' ); |
| 26 | +require_once( qp_Setup::$ExtDir . '/Excel/PEAR.php' ); |
| 27 | +require_once( qp_Setup::$ExtDir . '/Excel/OLE.php' ); |
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Stream wrapper for reading data stored in an OLE file. Implements methods |
Index: trunk/extensions/QPoll/Excel/Excel_BIFFwriter.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
34 | 34 | */ |
35 | 35 | |
36 | | -require_once( $qp_ExtDir . '/Excel/PEAR.php' ); |
| 36 | +require_once( qp_Setup::$ExtDir . '/Excel/PEAR.php' ); |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Class for writing Excel BIFF records. |
Index: trunk/extensions/QPoll/Excel/Console_Getopt.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | // |
20 | 20 | // $Id: Getopt.php,v 1.4 2007/06/12 14:58:56 cellog Exp $ |
21 | 21 | |
22 | | -require_once( $qp_ExtDir . '/Excel/PEAR.php' ); |
| 22 | +require_once( qp_Setup::$ExtDir . '/Excel/PEAR.php' ); |
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Command-line options parsing class. |
Index: trunk/extensions/QPoll/Excel/System.php |
— | — | @@ -17,8 +17,8 @@ |
18 | 18 | /** |
19 | 19 | * base class |
20 | 20 | */ |
21 | | -require_once( $qp_ExtDir . '/Excel/PEAR.php' ); |
22 | | -require_once( $qp_ExtDir . '/Excel/Console_Getopt.php' ); |
| 21 | +require_once( qp_Setup::$ExtDir . '/Excel/PEAR.php' ); |
| 22 | +require_once( qp_Setup::$ExtDir . '/Excel/Console_Getopt.php' ); |
23 | 23 | |
24 | 24 | $GLOBALS['_System_temp_files'] = array(); |
25 | 25 | |
Index: trunk/extensions/QPoll/Excel/readme.txt |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | Spreadsheet_Excel_Writer-0.9.1.tgz |
9 | 9 | |
10 | 10 | Nested filename paths are replaced to longer filenames with underscores, because I find deep nesting unhandy. |
11 | | -require_once() and include_once() calls are also corrected relative from $qp_ExtDir extension global variable. |
| 11 | +require_once() and include_once() calls are made relative from qp_Setup::$ExtDir extension's property. |
12 | 12 | |
13 | 13 | Spreadsheet_Excel_Writer-0.9.1 has a bug related to UTF16-LE string cell data encoding. |
14 | 14 | This bug can cause corruption of exported XLS files when non-ASCII set of codes |
Index: trunk/extensions/QPoll/Excel/PEAR.php |
— | — | @@ -763,7 +763,7 @@ |
764 | 764 | } |
765 | 765 | |
766 | 766 | if (PEAR_ZE2) { |
767 | | - include_once( $qp_ExtDir . '/Excel/PEAR5.php' ); |
| 767 | + include_once( qp_Setup::$ExtDir . '/Excel/PEAR5.php' ); |
768 | 768 | } |
769 | 769 | |
770 | 770 | // {{{ _PEAR_call_destructors() |
Index: trunk/extensions/QPoll/Excel/Excel_Worksheet.php |
— | — | @@ -32,8 +32,8 @@ |
33 | 33 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
34 | 34 | */ |
35 | 35 | |
36 | | -require_once( $qp_ExtDir . '/Excel/Excel_Parser.php' ); |
37 | | -require_once( $qp_ExtDir . '/Excel/Excel_BIFFwriter.php' ); |
| 36 | +require_once( qp_Setup::$ExtDir . '/Excel/Excel_Parser.php' ); |
| 37 | +require_once( qp_Setup::$ExtDir . '/Excel/Excel_BIFFwriter.php' ); |
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Class for generating Excel Spreadsheets |
Index: trunk/extensions/QPoll/Excel/Excel_Writer.php |
— | — | @@ -31,8 +31,8 @@ |
32 | 32 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
33 | 33 | */ |
34 | 34 | |
35 | | -require_once( $qp_ExtDir . '/Excel/PEAR.php' ); |
36 | | -require_once( $qp_ExtDir . '/Excel/Excel_Workbook.php' ); |
| 35 | +require_once( qp_Setup::$ExtDir . '/Excel/PEAR.php' ); |
| 36 | +require_once( qp_Setup::$ExtDir . '/Excel/Excel_Workbook.php' ); |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Class for writing Excel Spreadsheets. This class should change COMPLETELY. |
Index: trunk/extensions/QPoll/Excel/OLE_PPS_File.php |
— | — | @@ -20,8 +20,8 @@ |
21 | 21 | // $Id: File.php,v 1.12 2008/02/02 21:00:37 schmidt Exp $ |
22 | 22 | |
23 | 23 | |
24 | | -require_once( $qp_ExtDir . '/Excel/OLE_PPS.php' ); |
25 | | -require_once( $qp_ExtDir . '/Excel/System.php' ); |
| 24 | +require_once( qp_Setup::$ExtDir . '/Excel/OLE_PPS.php' ); |
| 25 | +require_once( qp_Setup::$ExtDir . '/Excel/System.php' ); |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Class for creating File PPS's for OLE containers |
Index: trunk/extensions/QPoll/Excel/OLE_PPS.php |
— | — | @@ -20,8 +20,8 @@ |
21 | 21 | // $Id: PPS.php,v 1.7 2007/02/13 21:00:42 schmidt Exp $ |
22 | 22 | |
23 | 23 | |
24 | | -require_once( $qp_ExtDir . '/Excel/PEAR.php' ); |
25 | | -require_once( $qp_ExtDir . '/Excel/OLE.php' ); |
| 24 | +require_once( qp_Setup::$ExtDir . '/Excel/PEAR.php' ); |
| 25 | +require_once( qp_Setup::$ExtDir . '/Excel/OLE.php' ); |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Class for creating PPS's for OLE containers |
Index: trunk/extensions/QPoll/Excel/OLE_PPS_Root.php |
— | — | @@ -20,8 +20,8 @@ |
21 | 21 | // $Id: Root.php,v 1.10 2008/02/02 21:00:37 schmidt Exp $ |
22 | 22 | |
23 | 23 | |
24 | | -require_once( $qp_ExtDir . '/Excel/OLE_PPS.php' ); |
25 | | -require_once( $qp_ExtDir . '/Excel/System.php' ); |
| 24 | +require_once( qp_Setup::$ExtDir . '/Excel/OLE_PPS.php' ); |
| 25 | +require_once( qp_Setup::$ExtDir . '/Excel/System.php' ); |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Class for creating Root PPS's for OLE containers |
Index: trunk/extensions/QPoll/Excel/Excel_Validator.php |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 | 24 | */ |
25 | 25 | |
26 | | -require_once( $qp_ExtDir . '/Excel/PEAR.php' ); |
| 26 | +require_once( qp_Setup::$ExtDir . '/Excel/PEAR.php' ); |
27 | 27 | |
28 | 28 | // Possible operator types |
29 | 29 | |
Index: trunk/extensions/QPoll/qp_user.php |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | * * Add this line at the end of your LocalSettings.php file : |
30 | 30 | * require_once "$IP/extensions/QPoll/qp_user.php"; |
31 | 31 | * |
32 | | - * @version 0.6.3 |
| 32 | + * @version 0.6.4 |
33 | 33 | * @link http://www.mediawiki.org/wiki/Extension:QPoll |
34 | 34 | * @author QuestPC <questpc@rambler.ru> |
35 | 35 | */ |
— | — | @@ -37,8 +37,6 @@ |
38 | 38 | die( "This file is part of the QPoll extension. It is not a valid entry point.\n" ); |
39 | 39 | } |
40 | 40 | |
41 | | -qp_CheckRequiredClassesAndMethods(); |
42 | | - |
43 | 41 | define( 'QP_CSS_ERROR_COLOR1' , "LightYellow" ); |
44 | 42 | define( 'QP_CSS_ERROR_COLOR2', "#D700D7" ); |
45 | 43 | define( 'QP_CSS_ERROR_STYLE', 'background-color: ' . QP_CSS_ERROR_COLOR1 . ';' ); |
— | — | @@ -48,13 +46,15 @@ |
49 | 47 | |
50 | 48 | define( 'QP_MAX_TEXT_ANSWER_LENGTH', 1024 ); |
51 | 49 | |
| 50 | +qp_Setup::init(); |
| 51 | + |
52 | 52 | /** |
53 | 53 | * Extension's parameters. |
54 | 54 | */ |
55 | 55 | $wgExtensionCredits['parserhook'][] = array( |
56 | 56 | 'path' => __FILE__, |
57 | 57 | 'name' => 'QPoll', |
58 | | - 'version' => '0.6.3', |
| 58 | + 'version' => '0.6.4', |
59 | 59 | 'author' => 'QuestPC', |
60 | 60 | 'url' => 'http://www.mediawiki.org/wiki/Extension:QPoll', |
61 | 61 | 'description' => 'Allows creation of polls', |
— | — | @@ -63,131 +63,196 @@ |
64 | 64 | $wgExtensionCredits['specialpage'][] = array( |
65 | 65 | 'path' => __FILE__, |
66 | 66 | 'name' => 'QPoll results page', |
67 | | - 'version' => '0.6.3', |
| 67 | + 'version' => '0.6.4', |
68 | 68 | 'author' => 'QuestPC', |
69 | 69 | 'url' => 'http://www.mediawiki.org/wiki/Extension:QPoll', |
70 | 70 | 'description' => 'QPoll extension [[Special:PollResults]] page for viewing results of the polls', |
71 | 71 | 'descriptionmsg' => 'qp_desc-sp', |
72 | 72 | ); |
73 | 73 | |
74 | | -/** |
75 | | - * Add this extension to the mediawiki's extensions list. |
76 | | - */ |
77 | | -$qp_ExtDir = str_replace( "\\", "/", dirname(__FILE__) ); // filesys path with windows path fix |
78 | | -$dirs = explode( '/', $qp_ExtDir ); |
79 | | -$qp_top_dir = array_pop( $dirs ); |
80 | | -$qp_ScriptPath = $wgScriptPath . '/extensions' . ( ( $qp_top_dir == 'extensions' ) ? '' : '/' . $qp_top_dir ); // apache virtual path |
| 74 | +class qp_Setup { |
81 | 75 | |
82 | | -$wgExtensionMessagesFiles['QPoll'] = $qp_ExtDir . '/qp_i18n.php'; |
83 | | -$wgAutoloadClasses['PollResults'] = $qp_ExtDir . '/qp_results.php'; |
84 | | -$wgAutoloadClasses['qp_Question'] = $qp_ExtDir . '/qp_question.php'; |
85 | | -$wgAutoloadClasses['qp_QuestionStats'] = $qp_ExtDir . '/qp_question.php'; |
86 | | -$wgAutoloadClasses['qp_PollStore'] = $qp_ExtDir . '/qp_pollstore.php'; |
87 | | -$wgAutoloadClasses['qp_QuestionData'] = $qp_ExtDir . '/qp_pollstore.php'; |
88 | | -$wgAutoloadClasses['qp_QueryPage'] = $qp_ExtDir . '/qp_results.php'; |
89 | | -// TODO: Use the new technique for i18n of special page aliases |
90 | | -$wgSpecialPages['PollResults'] = array('PollResults'); |
| 76 | + static $ExtDir; // filesys path with windows path fix |
| 77 | + static $ScriptPath; // apache virtual path |
| 78 | + static $messagesLoaded = false; // check whether the extension's localized messages are loaded |
| 79 | + static $article; // Article instance we got from hook parameter |
| 80 | + static $user; // User instance we got from hook parameter |
91 | 81 | |
92 | | -if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { |
93 | | - $wgHooks['ParserFirstCallInit'][] = 'wfQPollExtension'; |
94 | | -} else { |
95 | | - die( "QPoll extension requires ParserFirstCallInit hook.\nPlease upgrade your MediaWiki installation first.\n" ); |
96 | | - $wgExtensionFunctions[] = 'wfQPollExtension'; |
97 | | -} |
| 82 | + static function entities( &$s ) { |
| 83 | + return htmlentities( $s, ENT_COMPAT, 'UTF-8' ); |
| 84 | + } |
98 | 85 | |
99 | | -// TODO: Use the new technique for i18n of magic words |
100 | | -$wgHooks['LanguageGetMagic'][] = 'qp_FunctionsHook::languageGetMagic'; |
101 | | -$wgHooks['LoadAllMessages'][] = 'qp_AbstractPoll::loadMessages'; |
| 86 | + static function specialchars( &$s ) { |
| 87 | + return htmlspecialchars( $s, ENT_COMPAT, 'UTF-8' ); |
| 88 | + } |
102 | 89 | |
103 | | -function qp_CheckRequiredClassesAndMethods() { |
104 | | - $required_classes_and_methods = array( |
105 | | - array( "Linker"=>"link" ), |
106 | | - array( "OutputPage"=>"isPrintable" ), |
107 | | - array( "Parser"=>"fetchTemplate" ), |
108 | | - array( "Parser"=>"getTitle" ), |
109 | | - array( "Parser"=>"setHook" ), |
110 | | - array( "Parser"=>"recursiveTagParse" ), |
111 | | - array( "Title"=>"getArticleID" ), |
112 | | - array( "Title"=>"getPrefixedText" ), |
113 | | - array( "Title"=>"makeTitle" ), |
114 | | - array( "Title"=>"makeTitleSafe" ), |
115 | | - array( "Title"=>"newFromID" ) |
116 | | - ); |
117 | | - foreach ( $required_classes_and_methods as &$check ) { |
118 | | - list( $object, $method ) = each( $check ); |
119 | | - if ( !method_exists( $object, $method ) ) { |
120 | | - die( "QPoll extension requires " . $object . "::" . $method . " to be available.<br />\n" . |
121 | | - "Your version of MediaWiki is incompatible with this extension.\n" ); |
| 90 | + static function coreRequirements() { |
| 91 | + $required_classes_and_methods = array( |
| 92 | + array( 'Article'=>'doPurge' ), |
| 93 | + array( 'Linker'=>'link' ), |
| 94 | + array( 'OutputPage'=>'isPrintable' ), |
| 95 | + array( 'Parser'=>'getTitle' ), |
| 96 | + array( 'Parser'=>'setHook' ), |
| 97 | + array( 'Parser'=>'recursiveTagParse' ), |
| 98 | + array( 'ParserCache'=>'getKey' ), |
| 99 | + array( 'ParserCache'=>'singleton' ), |
| 100 | + array( 'Title'=>'getArticleID' ), |
| 101 | + array( 'Title'=>'getPrefixedText' ), |
| 102 | + array( 'Title'=>'makeTitle' ), |
| 103 | + array( 'Title'=>'makeTitleSafe' ), |
| 104 | + array( 'Title'=>'newFromID' ) |
| 105 | + ); |
| 106 | + foreach ( $required_classes_and_methods as &$check ) { |
| 107 | + list( $object, $method ) = each( $check ); |
| 108 | + if ( !method_exists( $object, $method ) ) { |
| 109 | + die( "QPoll extension requires " . $object . "::" . $method . " method to be available.<br />\n" . |
| 110 | + "Your version of MediaWiki is incompatible with this extension.\n" ); |
| 111 | + } |
122 | 112 | } |
| 113 | + if ( !defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { |
| 114 | + die( "QPoll extension requires ParserFirstCallInit hook.\nPlease upgrade your MediaWiki installation first.\n" ); |
| 115 | + } |
123 | 116 | } |
124 | | -} |
125 | 117 | |
126 | | -/** |
127 | | - * Register the extension with the WikiText parser. |
128 | | - */ |
129 | | -function wfQPollExtension() { |
130 | | - global $qp_ScriptPath; |
131 | | - global $wgParser; |
132 | | - global $wgExtensionCredits; |
133 | | - global $wgQPollFunctionsHook; |
134 | | - global $wgContLang; |
135 | | - global $wgJsMimeType, $wgOut; |
136 | | - global $qp_enable_showresults; |
137 | | - # setup proper integer global showresults level |
138 | | - if ( isset( $qp_enable_showresults ) ) { |
139 | | - if ( !is_int( $qp_enable_showresults ) ) { |
140 | | - # convert from older v0.5 boolean value |
141 | | - $qp_enable_showresults = (int) (boolean) $qp_enable_showresults; |
| 118 | + /** |
| 119 | + * Add this extension to the mediawiki's extensions list. |
| 120 | + */ |
| 121 | + static function init() { |
| 122 | + global $wgScriptPath; |
| 123 | + global $wgAutoloadClasses; |
| 124 | + global $wgExtensionMessagesFiles; |
| 125 | + global $wgSpecialPages; |
| 126 | + global $wgHooks; |
| 127 | + self::coreRequirements(); |
| 128 | + self::$ExtDir = str_replace( "\\", "/", dirname(__FILE__) ); |
| 129 | + $dirs = explode( '/', self::$ExtDir ); |
| 130 | + $top_dir = array_pop( $dirs ); |
| 131 | + self::$ScriptPath = $wgScriptPath . '/extensions' . ( ( $top_dir == 'extensions' ) ? '' : '/' . $top_dir ); |
| 132 | + $wgExtensionMessagesFiles['QPoll'] = self::$ExtDir . '/qp_i18n.php'; |
| 133 | + $wgAutoloadClasses['PollResults'] = self::$ExtDir . '/qp_results.php'; |
| 134 | + $wgAutoloadClasses['qp_Question'] = self::$ExtDir . '/qp_question.php'; |
| 135 | + $wgAutoloadClasses['qp_QuestionStats'] = self::$ExtDir . '/qp_question.php'; |
| 136 | + $wgAutoloadClasses['qp_PollStore'] = self::$ExtDir . '/qp_pollstore.php'; |
| 137 | + $wgAutoloadClasses['qp_QuestionData'] = self::$ExtDir . '/qp_pollstore.php'; |
| 138 | + $wgAutoloadClasses['qp_QueryPage'] = self::$ExtDir . '/qp_results.php'; |
| 139 | + // TODO: Use the new technique for i18n of special page aliases |
| 140 | + $wgSpecialPages['PollResults'] = array('PollResults'); |
| 141 | + // TODO: Use the new technique for i18n of magic words |
| 142 | + $wgHooks['LanguageGetMagic'][] = 'qp_Setup::languageGetMagic'; |
| 143 | + $wgHooks['MediaWikiPerformAction'][] = 'qp_Setup::mediaWikiPerformAction'; |
| 144 | + $wgHooks['ParserFirstCallInit'][] = 'qp_Setup::parserFirstCallInit'; |
| 145 | + $wgHooks['LoadAllMessages'][] = 'qp_Setup::loadMessages'; |
| 146 | + } |
| 147 | + |
| 148 | + static function loadMessages() { |
| 149 | + if ( !self::$messagesLoaded ) { |
| 150 | + self::$messagesLoaded = true; |
| 151 | + wfLoadExtensionMessages('QPoll'); |
142 | 152 | } |
143 | | - if ( $qp_enable_showresults < 0 ) { |
| 153 | + return true; |
| 154 | + } |
| 155 | + |
| 156 | + static function ParserFunctionsWords( $lang ) { |
| 157 | + $words = array(); |
| 158 | + $words[ 'en' ] = array( 'qpuserchoice'=>array( 0, 'qpuserchoice' ) ); |
| 159 | + # English is used as a fallback, and the English synonyms are |
| 160 | + # used if a translation has not been provided for a given word |
| 161 | + return ( $lang == 'en' || !array_key_exists( $lang, $words ) ) |
| 162 | + ? $words[ 'en' ] |
| 163 | + : array_merge( $words[ 'en' ], $words[ $lang ] ); |
| 164 | + } |
| 165 | + |
| 166 | + static function languageGetMagic( &$magicWords, $langCode ) { |
| 167 | + foreach( self::ParserFunctionsWords( $langCode ) as $word => $trans ) |
| 168 | + $magicWords [$word ] = $trans; |
| 169 | + return true; |
| 170 | + } |
| 171 | + |
| 172 | + static function clearCache() { |
| 173 | + $parserCache = ParserCache::singleton(); |
| 174 | + $key = $parserCache->getKey( self::$article, self::$user ); |
| 175 | + $parserCache->mMemc->delete( $key ); |
| 176 | + self::$article->doPurge(); |
| 177 | + } |
| 178 | + |
| 179 | + static function mediaWikiPerformAction( $output, $article, $title, $user, $request, $wiki ) { |
| 180 | + global $wgCookiePrefix; |
| 181 | + global $qp_enable_showresults; |
| 182 | + self::$article = $article; |
| 183 | + self::$user = $user; |
| 184 | + # setup proper integer global showresults level |
| 185 | + if ( isset( $qp_enable_showresults ) ) { |
| 186 | + if ( !is_int( $qp_enable_showresults ) ) { |
| 187 | + # convert from older v0.5 boolean value |
| 188 | + $qp_enable_showresults = (int) (boolean) $qp_enable_showresults; |
| 189 | + } |
| 190 | + if ( $qp_enable_showresults < 0 ) { |
| 191 | + $qp_enable_showresults = 0; |
| 192 | + } |
| 193 | + if ( $qp_enable_showresults > 2 ) { |
| 194 | + $qp_enable_showresults = 2; |
| 195 | + } |
| 196 | + } else { |
144 | 197 | $qp_enable_showresults = 0; |
145 | 198 | } |
146 | | - if ( $qp_enable_showresults > 2 ) { |
147 | | - $qp_enable_showresults = 2; |
| 199 | + if ( isset( $_COOKIE[$wgCookiePrefix.'QPoll'] ) ) { |
| 200 | + $request->response()->setCookie( 'QPoll', '', time() - 86400 ); // clear cookie |
| 201 | + self::clearCache(); |
| 202 | + } elseif ( $request->getVal('pollId') !== null ) { |
| 203 | + self::clearCache(); |
148 | 204 | } |
149 | | - } else { |
150 | | - $qp_enable_showresults = 0; |
| 205 | + return true; |
151 | 206 | } |
152 | | - # Ouput the style and the script to the header once for all. |
153 | | - $head = '<style type="text/css">' . "\n"; |
154 | | - $head .= '.qpoll .fatalerror { border: 1px solid gray; padding: 4px; ' . QP_CSS_ERROR_STYLE . ' }' . "\n"; |
155 | | - $head .= '</style>' . "\n"; |
156 | | - $head .= '<script type="' . $wgJsMimeType . '" src="' . $qp_ScriptPath . '/qp_user.js"></script>' . "\n"; |
157 | | - $wgOut->addScript( $head ); |
158 | | - $wgOut->addExtensionStyle( $qp_ScriptPath . '/qp_user.css' ); |
159 | | - if ( $wgContLang->isRTL() ) { |
160 | | - $wgOut->addExtensionStyle( $qp_ScriptPath . '/qp_user_rtl.css' ); |
| 207 | + |
| 208 | + /** |
| 209 | + * Register the extension with the WikiText parser. |
| 210 | + */ |
| 211 | + static function parserFirstCallInit() { |
| 212 | + global $wgParser; |
| 213 | + global $wgExtensionCredits; |
| 214 | + global $wgQPollFunctionsHook; |
| 215 | + global $wgContLang; |
| 216 | + global $wgJsMimeType, $wgOut; |
| 217 | + # Ouput the style and the script to the header once for all. |
| 218 | + $head = '<style type="text/css">' . "\n"; |
| 219 | + $head .= '.qpoll .fatalerror { border: 1px solid gray; padding: 4px; ' . QP_CSS_ERROR_STYLE . ' }' . "\n"; |
| 220 | + $head .= '</style>' . "\n"; |
| 221 | + $head .= '<script type="' . $wgJsMimeType . '" src="' . self::$ScriptPath . '/qp_user.js"></script>' . "\n"; |
| 222 | + $wgOut->addScript( $head ); |
| 223 | + $wgOut->addExtensionStyle( self::$ScriptPath . '/qp_user.css' ); |
| 224 | + if ( $wgContLang->isRTL() ) { |
| 225 | + $wgOut->addExtensionStyle( self::$ScriptPath . '/qp_user_rtl.css' ); |
| 226 | + } |
| 227 | + # setup tag hook |
| 228 | + $wgParser->setHook("qpoll", "qp_Setup::renderPoll"); |
| 229 | + $wgQPollFunctionsHook = new qp_FunctionsHook(); |
| 230 | + # setup function hook |
| 231 | + $wgParser->setFunctionHook( 'qpuserchoice', array( &$wgQPollFunctionsHook, 'qpuserchoice' ), SFH_OBJECT_ARGS ); |
| 232 | + return true; |
161 | 233 | } |
162 | | - # setup tag hook |
163 | | - $wgParser->setHook("qpoll", "qp_RenderPoll"); |
164 | | - $wgQPollFunctionsHook = new qp_FunctionsHook(); |
165 | | - # setup function hook |
166 | | - $wgParser->setFunctionHook( 'qpuserchoice', array( &$wgQPollFunctionsHook, 'qpuserchoice' ), SFH_OBJECT_ARGS ); |
167 | | - return true; |
168 | | -} |
169 | 234 | |
170 | | -/** |
171 | | - * Call the poll parser on an input text. |
172 | | - * |
173 | | - * @param $input Text between <qpoll> and </qpoll> tags, in QPoll syntax. |
174 | | - * @param $argv An array containing any arguments passed to the extension |
175 | | - * @param &$parser The wikitext parser. |
176 | | - * |
177 | | - * @return An HTML poll. |
178 | | - */ |
| 235 | + /** |
| 236 | + * Call the poll parser on an input text. |
| 237 | + * |
| 238 | + * @param $input Text between <qpoll> and </qpoll> tags, in QPoll syntax. |
| 239 | + * @param $argv An array containing any arguments passed to the extension |
| 240 | + * @param &$parser The wikitext parser. |
| 241 | + * |
| 242 | + * @return An HTML poll. |
| 243 | + */ |
179 | 244 | |
180 | | -/* @param $input Text between <qpoll> and </qpoll> tags, in QPoll syntax. */ |
181 | | -function qp_RenderPoll( $input, $argv, $parser ) { |
182 | | - $parser->disableCache(); |
183 | | - if ( array_key_exists( 'address', $argv ) ) { |
184 | | - $qpoll = new qp_PollStats( $argv, $parser ); |
185 | | - } else { |
186 | | - $qpoll = new qp_Poll( $argv, $parser ); |
| 245 | + /* @param $input Text between <qpoll> and </qpoll> tags, in QPoll syntax. */ |
| 246 | + static function renderPoll( $input, $argv, $parser ) { |
| 247 | + if ( array_key_exists( 'address', $argv ) ) { |
| 248 | + $qpoll = new qp_PollStats( $argv, $parser ); |
| 249 | + } else { |
| 250 | + $qpoll = new qp_Poll( $argv, $parser ); |
| 251 | + } |
| 252 | + return $qpoll->parsePoll( $input ); |
187 | 253 | } |
188 | | - return $qpoll->parsePoll( $input ); |
| 254 | + |
189 | 255 | } |
190 | 256 | |
191 | | - |
192 | 257 | /*** |
193 | 258 | * a poll stub which cannot process and render itself |
194 | 259 | * to process and render itself, real Poll should extend this class to implement it's own: |
— | — | @@ -204,8 +269,6 @@ |
205 | 270 | |
206 | 271 | var $parser; // parser for parsing tags content |
207 | 272 | var $username; |
208 | | - // params of tag |
209 | | - var $wikiTag = 'qpoll'; |
210 | 273 | |
211 | 274 | # an ID of the poll on current page (used in declaration/voting mode) |
212 | 275 | var $mPollId = null; |
— | — | @@ -236,6 +299,7 @@ |
237 | 300 | global $qp_enable_showresults; |
238 | 301 | $this->parser = &$parser; |
239 | 302 | $this->mRequest = &$wgRequest; |
| 303 | + $this->mResponse = $wgRequest->response(); |
240 | 304 | # Determine which messages will be used, according to the language. |
241 | 305 | self::loadMessages(); |
242 | 306 | # load current skin |
— | — | @@ -671,11 +735,9 @@ |
672 | 736 | $this->pollStore->setUserVote(); |
673 | 737 | } |
674 | 738 | if ( $this->pollStore->voteDone ) { |
675 | | - # purge itself on successful vote to update the statistics |
676 | | -// $wgArticle->doPurge(); // TODO: does not work. why ? |
677 | | - # redirect to itself, otherwise stats display will not be updated (showresults parameter) |
678 | | - $this->mRequest->response()->header( 'HTTP/1.0 302 Moved Temporarily' ); |
679 | | - $this->mRequest->response()->header( 'Location: ' . $wgTitle->getFullURL() . self::getPollTitleFragment( $this->mPollId ) ); |
| 739 | + $this->mResponse->setcookie( 'QPoll', 'clearCache', time()+20 ); |
| 740 | + $this->mResponse->header( 'HTTP/1.0 302 Found' ); |
| 741 | + $this->mResponse->header( 'Location: ' . $wgTitle->getFullURL() . self::getPollTitleFragment( $this->mPollId ) ); |
680 | 742 | return true; |
681 | 743 | } |
682 | 744 | return $output; |
— | — | @@ -891,7 +953,7 @@ |
892 | 954 | if ( $question->getState() != 'error' ) { |
893 | 955 | # load previous user choice, when it's available and DB header is compatible with parsed header |
894 | 956 | if ( $body === null || !method_exists( $question, $question->mType . 'ParseBody' ) ) { |
895 | | - $question->setState( 'error', wfMsgHtml( 'qp_error_question_not_implemented', htmlentities( $question->mType ) ) ); |
| 957 | + $question->setState( 'error', wfMsgHtml( 'qp_error_question_not_implemented', qp_Setup::entities( $question->mType ) ) ); |
896 | 958 | } else { |
897 | 959 | # parse the categories and spans (metacategories) |
898 | 960 | $question->parseBodyHeader( $body ); |
— | — | @@ -1144,7 +1206,7 @@ |
1145 | 1207 | var $error_message = 'no_such_poll'; |
1146 | 1208 | |
1147 | 1209 | function qpuserchoice( &$parser, $frame, $args ) { |
1148 | | - qp_AbstractPoll::loadMessages(); |
| 1210 | + qp_Setup::loadMessages(); |
1149 | 1211 | $this->frame = &$frame; |
1150 | 1212 | $this->args = &$args; |
1151 | 1213 | if ( isset( $args[ 0 ] ) ) { |
— | — | @@ -1175,7 +1237,7 @@ |
1176 | 1238 | } |
1177 | 1239 | } |
1178 | 1240 | } |
1179 | | - return '<strong class="error">qpuserchoice: ' . wfMsgHTML( 'qp_func_' . $this->error_message, htmlspecialchars( $this->pollAddr ), htmlspecialchars( $this->question_id ), htmlspecialchars( $this->proposal_id ) ) . '</strong>'; |
| 1241 | + return '<strong class="error">qpuserchoice: ' . wfMsgHTML( 'qp_func_' . $this->error_message, qp_Setup::specialchars( $this->pollAddr ), qp_Setup::specialchars( $this->question_id ), qp_Setup::specialchars( $this->proposal_id ) ) . '</strong>'; |
1180 | 1242 | } |
1181 | 1243 | |
1182 | 1244 | function getQuestionData( $qid ) { |
— | — | @@ -1226,24 +1288,8 @@ |
1227 | 1289 | } |
1228 | 1290 | } |
1229 | 1291 | } |
1230 | | - # do not need to use htmlentities because the result is a wikitext (will be escaped by parser) |
| 1292 | + # do not need to use qp_Setup::entities because the result is a wikitext (will be escaped by parser) |
1231 | 1293 | return $result; |
1232 | 1294 | } |
1233 | 1295 | |
1234 | | - static function ParserFunctionsWords( $lang ) { |
1235 | | - $words = array(); |
1236 | | - $words[ 'en' ] = array( 'qpuserchoice'=>array( 0, 'qpuserchoice' ) ); |
1237 | | - # English is used as a fallback, and the English synonyms are |
1238 | | - # used if a translation has not been provided for a given word |
1239 | | - return ( $lang == 'en' || !array_key_exists( $lang, $words ) ) |
1240 | | - ? $words[ 'en' ] |
1241 | | - : array_merge( $words[ 'en' ], $words[ $lang ] ); |
1242 | | - } |
1243 | | - |
1244 | | - static function languageGetMagic( &$magicWords, $langCode ) { |
1245 | | - foreach( qp_FunctionsHook::ParserFunctionsWords( $langCode ) as $word => $trans ) |
1246 | | - $magicWords [$word ] = $trans; |
1247 | | - return true; |
1248 | | - } |
1249 | | - |
1250 | 1296 | } |
Index: trunk/extensions/QPoll/qp_i18n.php |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | * * Add this line at the end of your LocalSettings.php file : |
30 | 30 | * require_once "$IP/extensions/QPoll/qp_user.php"; |
31 | 31 | * |
32 | | - * @version 0.6.3 |
| 32 | + * @version 0.6.4 |
33 | 33 | * @link http://www.mediawiki.org/wiki/Extension:QPoll |
34 | 34 | * @author QuestPC <questpc@rambler.ru> |
35 | 35 | * @addtogroup Extensions |
Index: trunk/extensions/QPoll/INSTALL |
— | — | @@ -1,4 +1,4 @@ |
2 | | -MediaWiki extension QPoll, version 0.6.3 |
| 2 | +MediaWiki extension QPoll, version 0.6.4 |
3 | 3 | |
4 | 4 | * download the latest available version and extract it to your wiki extension directory. |
5 | 5 | * add the following line to LocalSettings.php |
Index: trunk/extensions/QPoll/qp_results.php |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | * * Add this line at the end of your LocalSettings.php file : |
30 | 30 | * require_once "$IP/extensions/QPoll/qp_user.php"; |
31 | 31 | * |
32 | | - * @version 0.6.3 |
| 32 | + * @version 0.6.4 |
33 | 33 | * @link http://www.mediawiki.org/wiki/Extension:QPoll |
34 | 34 | * @author QuestPC <questpc@rambler.ru> |
35 | 35 | */ |
— | — | @@ -53,12 +53,11 @@ |
54 | 54 | // (should be equal to 'http://'.$_SERVER['SERVER_NAME']) |
55 | 55 | global $wgScript; // "/subdirectory/of/wiki/index.php" |
56 | 56 | global $wgUser; |
57 | | - global $qp_ScriptPath; |
58 | 57 | if ( !$wgUser->isAllowed( 'delete' ) ) { |
59 | 58 | $wgOut->permissionRequired('delete'); |
60 | 59 | return; |
61 | 60 | } |
62 | | - $wgOut->addExtensionStyle( $qp_ScriptPath . '/qp_results.css' ); |
| 61 | + $wgOut->addExtensionStyle( qp_Setup::$ScriptPath . '/qp_results.css' ); |
63 | 62 | if ( self::$skin == null ) { |
64 | 63 | self::$skin = $wgUser->getSkin(); |
65 | 64 | } |
— | — | @@ -157,7 +156,6 @@ |
158 | 157 | # @param $db - MediaWiki database object |
159 | 158 | # @return true if tables are found, string with error message otherwise |
160 | 159 | private function checkTables( $db ) { |
161 | | - global $qp_ExtDir; |
162 | 160 | $sql_tables = array( |
163 | 161 | "qp_poll_desc", |
164 | 162 | "qp_question_desc", |
— | — | @@ -178,7 +176,7 @@ |
179 | 177 | } |
180 | 178 | if ( $tablesFound == 0 ) { |
181 | 179 | # no tables were found, initialize the DB completely |
182 | | - $r = $db->sourceFile( $qp_ExtDir . "/qpoll.src" ); |
| 180 | + $r = $db->sourceFile( qp_Setup::$ExtDir . "/qpoll.src" ); |
183 | 181 | if ( $r === true ) { |
184 | 182 | $result = 'Tables were initialized.<br />Please <a href="#" onclick="window.location.reload()">reload</a> this page to view future page edits.'; |
185 | 183 | } else { |
— | — | @@ -211,7 +209,7 @@ |
212 | 210 | $output .= wfMsg( 'qp_browse_to_user', $user_link ) . "<br />\n"; |
213 | 211 | $output .= wfMsg( 'qp_browse_to_poll', $poll_link ) . "<br />\n"; |
214 | 212 | foreach ( $pollStore->Questions as $qkey => &$qdata ) { |
215 | | - $output .= "<br />\n<b>" . $qkey . ".</b> " . htmlentities( $qdata->CommonQuestion ) . "<br />\n"; |
| 213 | + $output .= "<br />\n<b>" . $qkey . ".</b> " . qp_Setup::entities( $qdata->CommonQuestion ) . "<br />\n"; |
216 | 214 | $output .= $this->displayUserQuestionVote( $qdata ); |
217 | 215 | } |
218 | 216 | } |
— | — | @@ -222,7 +220,7 @@ |
223 | 221 | } |
224 | 222 | |
225 | 223 | private function categoryentities( $cat ) { |
226 | | - $cat['name'] = htmlentities( $cat['name'] ); |
| 224 | + $cat['name'] = qp_Setup::entities( $cat['name'] ); |
227 | 225 | return $cat; |
228 | 226 | } |
229 | 227 | |
— | — | @@ -241,9 +239,9 @@ |
242 | 240 | $text_answer = $qdata->ProposalCategoryText[ $propkey ][ $id_key ]; |
243 | 241 | if ( $text_answer != '' ) { |
244 | 242 | if ( strlen( $text_answer ) > 20 ) { |
245 | | - $cell[ 0 ] = array( '__tag'=>'div', 'style'=>'width:10em; height:5em; overflow:auto', 0=>htmlentities( $text_answer ) ); |
| 243 | + $cell[ 0 ] = array( '__tag'=>'div', 'style'=>'width:10em; height:5em; overflow:auto', 0=>qp_Setup::entities( $text_answer ) ); |
246 | 244 | } else { |
247 | | - $cell[ 0 ] = htmlentities( $text_answer ); |
| 245 | + $cell[ 0 ] = qp_Setup::entities( $text_answer ); |
248 | 246 | } |
249 | 247 | } else { |
250 | 248 | $cell[ 0 ] = '+'; |
— | — | @@ -260,7 +258,7 @@ |
261 | 259 | } |
262 | 260 | $row[] = $cell; |
263 | 261 | } |
264 | | - $row[] = array( 0=>htmlentities( $proposal_text ), "style"=>"text-align:left;" ); |
| 262 | + $row[] = array( 0=>qp_Setup::entities( $proposal_text ), "style"=>"text-align:left;" ); |
265 | 263 | $output .= qp_Renderer::displayRow( $row ); |
266 | 264 | } |
267 | 265 | $output .= "</table>\n" . "</div>\n"; |
— | — | @@ -281,7 +279,7 @@ |
282 | 280 | $output .= wfMsg( 'qp_browse_to_poll', $poll_link ) . "<br />\n"; |
283 | 281 | $output .= self::$skin->link( $this->getTitle(), wfMsg( 'qp_export_to_xls' ), array( "style"=>"font-weight:bold;" ), array( 'action'=>'stats_xls', 'id'=>$pid ) ); |
284 | 282 | foreach ( $pollStore->Questions as $qkey => &$qdata ) { |
285 | | - $output .= "<br />\n<b>" . $qkey . ".</b> " . htmlentities( $qdata->CommonQuestion ) . "<br />\n"; |
| 283 | + $output .= "<br />\n<b>" . $qkey . ".</b> " . qp_Setup::entities( $qdata->CommonQuestion ) . "<br />\n"; |
286 | 284 | $output .= $this->displayQuestionStats( $pid, $qdata ); |
287 | 285 | } |
288 | 286 | } |
— | — | @@ -290,7 +288,6 @@ |
291 | 289 | } |
292 | 290 | |
293 | 291 | private function votesToXLS( $pid ) { |
294 | | - global $qp_ExtDir; |
295 | 292 | $output = ""; |
296 | 293 | if ( $pid !== null ) { |
297 | 294 | $pollStore = new qp_PollStore( array( 'from'=>'pid', 'pid'=> $pid ) ); |
— | — | @@ -300,7 +297,7 @@ |
301 | 298 | $pollStore->loadTotals(); |
302 | 299 | $pollStore->calculateStatistics(); |
303 | 300 | try { |
304 | | - require_once( $qp_ExtDir . '/Excel/Excel_Writer.php' ); |
| 301 | + require_once( qp_Setup::$ExtDir . '/Excel/Excel_Writer.php' ); |
305 | 302 | $xls_fname = tempnam( "", ".xls" ); |
306 | 303 | $xls_workbook = new Spreadsheet_Excel_Writer_Workbook( $xls_fname ); |
307 | 304 | $xls_workbook->setVersion( 8 ); |
— | — | @@ -430,7 +427,7 @@ |
431 | 428 | # this proposal has no statistics (no votes) |
432 | 429 | $row = array_fill( 0, count( $qdata->Categories ), '' ); |
433 | 430 | } |
434 | | - $row[] = array( 0=>htmlentities( $proposal_text ), "style"=>"text-align:left;" ); |
| 431 | + $row[] = array( 0=>qp_Setup::entities( $proposal_text ), "style"=>"text-align:left;" ); |
435 | 432 | $output .= qp_Renderer::displayRow( $row ); |
436 | 433 | } |
437 | 434 | $output .= "</table>\n" . "</div>\n"; |
— | — | @@ -647,8 +644,8 @@ |
648 | 645 | function formatResult( $skin, $result ) { |
649 | 646 | global $wgLang, $wgContLang; |
650 | 647 | $poll_title = Title::makeTitle( $result->ns, $result->title, qp_AbstractPoll::getPollTitleFragment( $result->poll_id, '' ) ); |
651 | | - $pagename = htmlspecialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) ); |
652 | | - $pollname = htmlspecialchars( $result->poll_id ); |
| 648 | + $pagename = qp_Setup::specialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) ); |
| 649 | + $pollname = qp_Setup::specialchars( $result->poll_id ); |
653 | 650 | $goto_link = self::$skin->link( $poll_title, wfMsg( 'qp_source_link' ) ); |
654 | 651 | $voice_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_voice_link' . ($this->inverse ? "_inv" : "") ), array(), array( "id"=>intval( $result->pid), "uid"=>$this->uid, "action"=>"uvote" ) ); |
655 | 652 | $link = wfMsg( 'qp_results_line_qupl', $pagename, $pollname, $voice_link ); |
— | — | @@ -688,8 +685,8 @@ |
689 | 686 | function formatResult( $skin, $result ) { |
690 | 687 | global $wgLang, $wgContLang; |
691 | 688 | $poll_title = Title::makeTitle( $result->ns, $result->title, qp_AbstractPoll::getPollTitleFragment( $result->poll_id, '' ) ); |
692 | | - $pagename = htmlspecialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) ); |
693 | | - $pollname = htmlspecialchars( $result->poll_id ); |
| 689 | + $pagename = qp_Setup::specialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) ); |
| 690 | + $pollname = qp_Setup::specialchars( $result->poll_id ); |
694 | 691 | $goto_link = self::$skin->link( $poll_title, wfMsg( 'qp_source_link' ) ); |
695 | 692 | $voices_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_stats_link' ), array(), array( "id"=>intval( $result->pid), "action"=>"stats" ) ); |
696 | 693 | $users_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_users_link' ), array(), array( "id"=>intval( $result->pid), "action"=>"pulist" ) ); |
— | — | @@ -729,8 +726,8 @@ |
730 | 727 | __METHOD__ ); |
731 | 728 | if ( $row = $db->fetchObject( $res ) ) { |
732 | 729 | $poll_title = Title::makeTitle( intval( $row->ns ), $row->title, qp_AbstractPoll::getPollTitleFragment( $row->poll_id, '' ) ); |
733 | | - $pagename = htmlspecialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) ); |
734 | | - $pollname = htmlspecialchars( $row->poll_id ); |
| 730 | + $pagename = qp_Setup::specialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) ); |
| 731 | + $pollname = qp_Setup::specialchars( $row->poll_id ); |
735 | 732 | $goto_link = self::$skin->link( $poll_title, wfMsg( 'qp_source_link' ) ); |
736 | 733 | $spec = wfMsg( 'qp_header_line_qpul', wfMsg( $this->inverse ? 'qp_not_participated_link' : 'qp_users_link'), $pagename, $pollname ); |
737 | 734 | $head[] = PollResults::getPollsLink(); |
— | — | @@ -822,8 +819,8 @@ |
823 | 820 | if ( $pollStore->pid !== null ) { |
824 | 821 | $pollStore->loadQuestions(); |
825 | 822 | $poll_title = Title::makeTitle( intval( $this->ns ), $this->title, qp_AbstractPoll::getPollTitleFragment( $this->poll_id, '' ) ); |
826 | | - $pagename = htmlspecialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) ); |
827 | | - $pollname = htmlspecialchars( $this->poll_id ); |
| 823 | + $pagename = qp_Setup::specialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) ); |
| 824 | + $pollname = qp_Setup::specialchars( $this->poll_id ); |
828 | 825 | $goto_link = self::$skin->link( $poll_title, wfMsg( 'qp_source_link' ) ); |
829 | 826 | $spec = wfMsg( 'qp_header_line_qpul', wfMsg( 'qp_users_link' ), $pagename, $pollname ); |
830 | 827 | $head[] = PollResults::getPollsLink(); |
— | — | @@ -839,7 +836,7 @@ |
840 | 837 | } |
841 | 838 | } |
842 | 839 | if ( $ques_found ) { |
843 | | - $qpa = wfMsg( 'qp_header_line_qucl', $this->question_id, htmlentities( $ques->CommonQuestion ) ); |
| 840 | + $qpa = wfMsg( 'qp_header_line_qucl', $this->question_id, qp_Setup::entities( $ques->CommonQuestion ) ); |
844 | 841 | if ( array_key_exists( $this->cat_id, $ques->Categories ) ) { |
845 | 842 | $categ = &$ques->Categories[ $this->cat_id ]; |
846 | 843 | $proptext = $ques->ProposalText[ $this->proposal_id ]; |
— | — | @@ -847,7 +844,11 @@ |
848 | 845 | if ( array_key_exists( 'spanId', $categ ) ) { |
849 | 846 | $cat_name = wfMsg( 'qp_full_category_name', $cat_name, $ques->CategorySpans[ $categ['spanId'] ]['name'] ); |
850 | 847 | } |
851 | | - $qpa = wfMsg( 'qp_header_line_qucl', $this->question_id, htmlentities( $ques->CommonQuestion ), htmlentities( $proptext ), htmlentities( $cat_name ) ) . '<br />'; |
| 848 | + $qpa = wfMsg( 'qp_header_line_qucl', |
| 849 | + $this->question_id, |
| 850 | + qp_Setup::entities( $ques->CommonQuestion ), |
| 851 | + qp_Setup::entities( $proptext ), |
| 852 | + qp_Setup::entities( $cat_name ) ) . '<br />'; |
852 | 853 | $head[] = array( '__tag'=>'div', 'class'=>'head', 'style'=>'padding-left:2em;', 0=>$qpa ); |
853 | 854 | $link = qp_Renderer::renderHTMLobject( $head ); |
854 | 855 | } |
— | — | @@ -883,7 +884,7 @@ |
884 | 885 | $userTitle = Title::makeTitleSafe( NS_USER, $userName ); |
885 | 886 | $user_link = self::$skin->link( $userTitle, $userName ); |
886 | 887 | $voice_link = self::$skin->link( $this->getTitle(), wfMsg( 'qp_voice_link' . ($this->inverse ? "_inv" : "" ) ), array(), array( "id"=>intval( $this->pid), "uid"=>$uid, "action"=>"uvote" ) ); |
887 | | - $text_answer = ($result->text_answer == '') ? '' : '<i>' . htmlentities( $result->text_answer ) . '</i>'; |
| 888 | + $text_answer = ($result->text_answer == '') ? '' : '<i>' . qp_Setup::entities( $result->text_answer ) . '</i>'; |
888 | 889 | $link = wfMsg( 'qp_results_line_qucl', $user_link, $voice_link, $text_answer ); |
889 | 890 | } |
890 | 891 | return $link; |
Index: trunk/extensions/QPoll/qp_user.js |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | * * Add this line at the end of your LocalSettings.php file : |
29 | 29 | * require_once "$IP/extensions/QPoll/qp_user.php"; |
30 | 30 | * |
31 | | - * @version 0.6.3 |
| 31 | + * @version 0.6.4 |
32 | 32 | * @link http://www.mediawiki.org/wiki/Extension:QPoll |
33 | 33 | * @author QuestPC <questpc@rambler.ru> |
34 | 34 | */ |