Example #1
0
 /**
  * Add this extension to the mediawiki's extensions list.
  */
 static function init()
 {
     global $wgScriptPath;
     global $wgExtensionMessagesFiles;
     global $wgSpecialPages;
     global $wgHooks;
     global $wgExtraNamespaces, $wgNamespaceProtection;
     global $wgGroupPermissions;
     global $wgDebugLogGroups;
     # local / remote path
     self::$ExtDir = str_replace("\\", "/", dirname(__FILE__));
     $dirs = explode('/', self::$ExtDir);
     $top_dir = array_pop($dirs);
     self::$ScriptPath = $wgScriptPath . '/extensions' . ($top_dir == 'extensions' ? '' : '/' . $top_dir);
     self::$resultsCheckCode = self::entity_decode(self::RESULTS_CHECK_SIGN);
     # language files
     # extension messages
     $wgExtensionMessagesFiles['QPoll'] = self::$ExtDir . '/i18n/qp.i18n.php';
     # localized namespace names
     $wgExtensionMessagesFiles['QPollNamespaces'] = self::$ExtDir . '/i18n/qp.namespaces.php';
     # localized special page titles and magic words.
     $wgExtensionMessagesFiles['QPollAlias'] = self::$ExtDir . '/i18n/qp.alias.php';
     $wgExtensionMessagesFiles['QPollMagic'] = self::$ExtDir . '/i18n/QPoll.i18n.magic.php';
     # extension setup, hooks handling and content transformation
     self::autoLoad(array('qp_user.php' => __CLASS__, 'includes/qp_functionshook.php' => 'qp_FunctionsHook', 'includes/qp_renderer.php' => 'qp_Renderer', 'includes/qp_xlswriter.php' => 'qp_XlsWriter', 'maintenance/qp_schemaupdater.php' => 'qp_SchemaUpdater', 'ctrl/poll/qp_abstractpoll.php' => 'qp_AbstractPoll', 'ctrl/poll/qp_poll.php' => 'qp_Poll', 'ctrl/poll/qp_pollstats.php' => 'qp_PollStats', 'ctrl/question/qp_abstractquestion.php' => 'qp_AbstractQuestion', 'ctrl/question/qp_stubquestion.php' => 'qp_StubQuestion', 'ctrl/question/qp_tabularquestion.php' => 'qp_TabularQuestion', 'ctrl/question/qp_mixedquestion.php' => 'qp_MixedQuestion', 'ctrl/question/qp_textquestion.php' => array('qp_TextQuestionOptions', 'qp_TextQuestion'), 'ctrl/question/qp_questionstats.php' => 'qp_QuestionStats', 'ctrl/qp_propattrs.php' => 'qp_PropAttrs', 'ctrl/qp_interpresult.php' => 'qp_InterpResult', 'view/qp_abstractview.php' => 'qp_AbstractView', 'view/poll/qp_abstractpollview.php' => 'qp_AbstractPollView', 'view/poll/qp_pollview.php' => 'qp_PollView', 'view/poll/qp_pollstatsview.php' => 'qp_PollStatsView', 'view/question/qp_stubquestionview.php' => 'qp_StubQuestionView', 'view/question/qp_tabularquestionview.php' => 'qp_TabularQuestionView', 'view/question/qp_textquestionview.php' => 'qp_TextQuestionView', 'view/question/qp_questionstatsview.php' => 'qp_QuestionStatsView', 'view/proposal/qp_stubquestionproposalview.php' => 'qp_StubQuestionProposalView', 'view/proposal/qp_tabularquestionproposalview.php' => 'qp_TabularQuestionProposalView', 'view/proposal/qp_questionstatsproposalview.php' => 'qp_QuestionStatsProposalView', 'view/proposal/qp_textquestionproposalview.php' => 'qp_TextQuestionProposalView', 'view/results/qp_questiondataresults.php' => 'qp_QuestionDataResults', 'view/results/qp_textquestiondataresults.php' => 'qp_TextQuestionDataResults', 'view/xls/qp_xlspoll.php' => 'qp_XlsPoll', 'view/xls/qp_xlstabularquestion.php' => 'qp_XlsTabularQuestion', 'view/xls/qp_xlstextquestion.php' => 'qp_XlsTextQuestion', 'view/qp_interpresultview.php' => 'qp_InterpResultView', 'model/qp_pollstore.php' => 'qp_PollStore', 'model/cache/qp_pollcache.php' => 'qp_PollCache', 'model/cache/qp_questioncache.php' => 'qp_QuestionCache', 'model/cache/qp_categorycache.php' => 'qp_CategoryCache', 'model/cache/qp_proposalcache.php' => 'qp_ProposalCache', 'model/qp_questiondata.php' => array('qp_QuestionData', 'qp_TextQuestionData'), 'model/qp_question_collection.php' => 'qp_QuestionCollection', 'specials/qp_special.php' => array('qp_SpecialPage', 'qp_QueryPage'), 'specials/qp_results.php' => 'PollResults', 'specials/qp_webinstall.php' => array('qp_WebInstall'), 'interpretation/qp_interpret.php' => 'qp_Interpret', 'interpretation/qp_eval.php' => 'qp_Eval'));
     $wgSpecialPages['PollResults'] = 'PollResults';
     $wgSpecialPages['QPollWebInstall'] = 'qp_WebInstall';
     # instantiating fake instance for PHP < 5.2.3, which does not support 'Class::method' type of callbacks
     $wgHooks['MediaWikiPerformAction'][] = $wgHooks['ParserFirstCallInit'][] = $wgHooks['ParserAfterTidy'][] = $wgHooks['CanonicalNamespaces'][] = new qp_Setup();
     $wgHooks['LoadExtensionSchemaUpdates'][] = new qp_SchemaUpdater();
     if (self::mediaWikiVersionCompare('1.17')) {
         # define namespaces for the interpretation scripts and their talk pages
         # used only for non-localized namespace names in MW < 1.17
         if (!is_array($wgExtraNamespaces)) {
             $wgExtraNamespaces = array();
         }
         foreach (self::$interpNamespaces as $ns_idx => $canonical_name) {
             if (isset($wgExtraNamespaces[$ns_idx])) {
                 die("QPoll requires namespace index {$ns_idx} which is already used by another extension. Either disable another extension or change the namespace index.");
             }
         }
         foreach (self::$interpNamespaces as $ns_idx => $canonical_name) {
             $wgExtraNamespaces[$ns_idx] = $canonical_name;
         }
     }
     foreach (self::$interpNamespaces as $ns_idx => $canonical_name) {
         $wgNamespaceProtection[$ns_idx] = array('editinterpretation');
     }
     # groups which has permission to access poll results by default
     $wgGroupPermissions['sysop']['pollresults'] = true;
     $wgGroupPermissions['bureaucrat']['pollresults'] = true;
     $wgGroupPermissions['polladmin']['pollresults'] = true;
     # groups which can edit interpretation scripts by default
     # please minimize the number of groups as low as you can
     # that is security measure against inserting of malicious code
     # into the source of interpretation scripts
     $wgGroupPermissions['sysop']['editinterpretation'] = true;
     $wgGroupPermissions['bureaucrat']['editinterpretation'] = true;
     $wgDebugLogGroups['qpoll'] = 'qpoll_debug_log.txt';
 }