/** * setWFVariables * * add all default variables into city_variables table * * @author Krzysztof Krzyzaniak <*****@*****.**> * @author Piotr Molski <*****@*****.**> * @access private * */ private function setWFVariables() { // WF Variables containter $this->mWFSettingVars = array(); $this->mWFSettingVars['wgSitename'] = $this->mNewWiki->sitename; $this->mWFSettingVars['wgLogo'] = self::DEFAULT_WIKI_LOGO; $this->mWFSettingVars['wgUploadPath'] = $this->mNewWiki->images_url; $this->mWFSettingVars['wgUploadDirectory'] = $this->mNewWiki->images_dir; $this->mWFSettingVars['wgDBname'] = $this->mNewWiki->dbname; $this->mWFSettingVars['wgLocalInterwiki'] = $this->mNewWiki->sitename; $this->mWFSettingVars['wgLanguageCode'] = $this->mNewWiki->language; $this->mWFSettingVars['wgServer'] = rtrim($this->mNewWiki->url, "/"); $this->mWFSettingVars['wgFavicon'] = self::DEFAULT_WIKI_FAVICON; $this->mWFSettingVars['wgEnableEditEnhancements'] = true; $this->mWFSettingVars['wgEnableSectionEdit'] = true; // rt#60223: colon allowed in sitename, breaks project namespace if (mb_strpos($this->mWFSettingVars['wgSitename'], ':') !== false) { $this->mWFSettingVars['wgMetaNamespace'] = str_replace(array(':', ' '), array('', '_'), $this->mWFSettingVars['wgSitename']); } if (self::ACTIVE_CLUSTER) { wfGetLBFactory()->sectionsByDB[$this->mNewWiki->dbname] = $this->mWFSettingVars['wgDBcluster'] = self::ACTIVE_CLUSTER; } switch ($this->mType) { case "answers": $this->mWFSettingVars['wgRateLimits'] = array('move' => array('ip' => array(0 => 1, 1 => 300), 'newbie' => array(0 => 6, 1 => 300), 'user' => array(0 => 15, 1 => 300))); $this->mWFSettingVars['wgGroupPermissionsLocal'] = '*|move|1,*|createaccount|1,user|createaccount|0,sysop|createaccount|0'; $this->mWFSettingVars['wgDefaultTheme'] = 'sapphire'; $this->mWFSettingVars['wgEnableAnswers'] = true; $this->mWFSettingVars['wgEnableCategoryBlueLinks'] = true; $this->mWFSettingVars['AutoFriendOnRegisterUsername'] = $this->mNewWiki->founderName; $this->mWFSettingVars['wgEnableRandomInCategoryExt'] = true; $this->mWFSettingVars['wgEnableMagicAnswer'] = false; $this->mWFSettingVars['wgUseNewAnswersSkin'] = true; $this->mWFSettingVars['wgAdslot_LEFT_NAV_205x400'] = "Null"; $this->mWFSettingVars['wgEnableAnswersMonacoWidget'] = false; $this->mWFSettingVars['wgEnableMagicAnswer'] = false; $this->mWFSettingVars['wgEnableCategoryHubsExt'] = false; $this->mWFSettingVars['wgEnableEditingTipsExt'] = false; $this->mWFSettingVars['wgAdslot_HOME_LEFT_SKYSCRAPER_1'] = "Null"; $mapArray = array("ar" => true, "he" => true, "ja" => true, "th" => true, "zh" => true); if (Wikia::langToSomethingMap($mapArray, $this->mNewWiki->language, false)) { $this->mWFSettingVars['wgDisableAnswersShortQuestionsRedirect'] = true; } break; default: break; } $oRes = $this->mDBw->select("city_variables_pool", array("cv_id, cv_name"), array("cv_name in ('" . implode("', '", array_keys($this->mWFSettingVars)) . "')"), __METHOD__); $this->mWFVars = array(); while ($oRow = $this->mDBw->fetchObject($oRes)) { $this->mWFVars[$oRow->cv_name] = $oRow->cv_id; } $this->mDBw->freeResult($oRes); foreach ($this->mWFSettingVars as $variable => $value) { /** * first, get id of variable */ $cv_id = 0; if (isset($this->mWFVars[$variable])) { $cv_id = $this->mWFVars[$variable]; } /** * then, insert value for wikia */ if (!empty($cv_id)) { $this->mDBw->insert("city_variables", array("cv_value" => serialize($value), "cv_city_id" => $this->mNewWiki->city_id, "cv_variable_id" => $cv_id), __METHOD__); } } }
function WidgetAnswers($id, $params) { global $IP, $wgTitle, $wgUser, $wgSitename, $wgContentNamespaces, $wgAnswersURLs; wfProfileIn(__METHOD__); # TODO: should be handled directly in WidgetFramework, probably Draw/DrawOne method global $wgLanguageCode, $wgAvailableAnswersLang; if (empty($wgAvailableAnswersLang) || !in_array($wgLanguageCode, $wgAvailableAnswersLang) && !in_array(preg_replace("/-.*\$/", "", $wgLanguageCode), $wgAvailableAnswersLang)) { wfProfileOut(__METHOD__); return ''; } global $wgEnableAnswersMonacoWidget; if (empty($wgEnableAnswersMonacoWidget)) { wfProfileOut(__METHOD__); return ''; } global $wgExtensionMessagesFiles; if (empty($wgExtensionMessagesFiles['Answers'])) { global $IP; $wgExtensionMessagesFiles['Answers'] = "{$IP}/../answers/Answers.i18n.php"; } // This HTML for the Ask a Question is used for both logged in and logged out users // but in different place - top or the bottom of the widget $ask_a_question = htmlspecialchars(wfMsgForContent("ask_a_question-widget")); $askform = <<<EOD <form method="get" action="" onsubmit="return false" name="ask_form" class="ask_form"> \t<input type="text" value="{$ask_a_question}" class="answers_ask_field"/> </form> EOD; $output = '<div class="widget_answers_note">' . wfMsgForContent('answers_widget_user_note') . '</div>'; $output .= '<div style="padding: 7px;"><b>' . wfMsgForContent('recent_asked_questions') . '</b></div>'; $apiparams = array('smaxage' => 300, 'maxage' => 300, 'callback' => 'WidgetAnswers_load', 'format' => 'json', 'action' => 'query', 'list' => 'categoriesonanswers', 'coatitle' => $wgSitename, 'coalimit' => '5'); global $wgWidgetAnswersForceCategory; if (!empty($wgWidgetAnswersForceCategory)) { $apiparams = array('smaxage' => 300, 'maxage' => 300, 'callback' => 'WidgetAnswers_load2', 'format' => 'json', 'action' => 'query', 'list' => 'categorymembers', 'cmtitle' => $wgWidgetAnswersForceCategory, 'cmlimit' => '5', 'cmnamespace' => 0, 'cmprop' => 'title|timestamp', 'cmsort' => 'timestamp', 'cmdir' => 'desc'); } # if($wgUser->getGlobalPreference('language') != 'en') { // waiting for international logic phase Future (v 2.0) # $domain = $wgUser->getGlobalPreference('language'); # } else { $domain = Wikia::langToSomethingMap($wgAnswersURLs, $wgLanguageCode, "{$wgLanguageCode}.answers.wikia.com"); # } global $wgWidgetAnswersForceDomain; if (!empty($wgWidgetAnswersForceDomain)) { $domain = $wgWidgetAnswersForceDomain; } $url = 'http://' . $domain . '/api.php?' . http_build_query($apiparams); $no_questions = wfMsgForContent("answers_widget_no_questions"); $no_questions = Xml::encodeJsVar($no_questions); global $wgWidgetAnswersForceCategoryForAsk; if (!empty($wgWidgetAnswersForceCategoryForAsk)) { $category = $wgWidgetAnswersForceCategoryForAsk; if ("-" == $category) { $category = ""; } } else { $category = $wgSitename; } $category = addcslashes($category, "'"); $output .= <<<EOD <script type="text/javascript">/*<![CDATA[*/ var ask_a_question_msg = "{$ask_a_question}"; if(typeof WidgetAnswers_html == 'undefined') var WidgetAnswers_html = ''; var WidgetAnswers_domain = '{$domain}'; var WidgetAnswers_category = '{$category}'; var WidgetAnswers_url = '{$url}'; var node = jQuery('#{$id}_content').children('div:last'); if(WidgetAnswers_html == '') { \tjQuery.getScript(WidgetAnswers_url, function() { \t\tif(WidgetAnswers_html != '') node.append('<ul>' + WidgetAnswers_html + '</ul>'); \t\telse node.html({$no_questions}); \t}); } else node.append('<ul>' + WidgetAnswers_html + '</ul>'); /*]]>*/</script> EOD; $output .= $askform; wfProfileOut(__METHOD__); return $output; }
public function setWFVariables() { global $wgExternalSharedDB; $dbw = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB); # central $WFSettingsVars = array('wgSitename' => $this->mWikiData["title"], 'wgLogo' => '$wgUploadPath/b/bc/Wiki.png', 'wgUploadPath' => $this->mWikiData["images_url"], 'wgUploadDirectory' => $this->mWikiData["images_dir"], 'wgDBname' => $this->mWikiData["dbname"], 'wgLocalInterwiki' => $this->mWikiData["title"], 'wgLanguageCode' => $this->mWikiData["language"], 'wgServer' => rtrim($this->mWikiData["url"], "/"), 'wgFavicon' => '$wgUploadPath/6/64/Favicon.ico', 'wgEnableEditEnhancements' => true, 'wgEnableSectionEdit' => true); // rt#60223: colon allowed in sitename, breaks project namespace if (mb_strpos($WFSettingsVars['wgSitename'], ':') !== false) { $WFSettingsVars['wgMetaNamespace'] = str_replace(array(':', ' '), array('', '_'), $WFSettingsVars['wgSitename']); } if (self::ACTIVE_CLUSTER) { $WFSettingsVars["wgDBcluster"] = self::ACTIVE_CLUSTER; wfGetLBFactory()->sectionsByDB[$this->mWikiData["dbname"]] = self::ACTIVE_CLUSTER; } switch ($this->mType) { case "answers": $WFSettingsVars["wgRateLimits"] = array('move' => array('ip' => array(0 => 1, 1 => 300), 'newbie' => array(0 => 6, 1 => 300), 'user' => array(0 => 15, 1 => 300))); $WFSettingsVars["wgGroupPermissionsLocal"] = '*|move|1,*|createaccount|1,user|createaccount|0,sysop|createaccount|0'; $WFSettingsVars["wgDefaultTheme"] = 'sapphire'; $WFSettingsVars["wgEnableAnswers"] = true; $WFSettingsVars["wgEnableCategoryBlueLinks"] = true; $WFSettingsVars["wgEnableRandomInCategoryExt"] = true; $WFSettingsVars["wgEnableMagicAnswer"] = false; $WFSettingsVars["wgUseNewAnswersSkin"] = true; $WFSettingsVars["wgAdslot_LEFT_NAV_205x400"] = "Null"; $WFSettingsVars["wgEnableAnswersMonacoWidget"] = false; $WFSettingsVars["wgEnableMagicAnswer"] = false; $WFSettingsVars["wgEnableCategoryHubsExt"] = false; $WFSettingsVars["wgEnableEditingTipsExt"] = false; $WFSettingsVars["wgAdslot_HOME_LEFT_SKYSCRAPER_1"] = "Null"; if (Wikia::langToSomethingMap(array("ar" => true, "he" => true, "ja" => true, "th" => true, "zh" => true), $this->mWikiData["language"], false)) { $WFSettingsVars["wgDisableAnswersShortQuestionsRedirect"] = true; } break; default: break; } $oRes = $dbw->select("city_variables_pool", array("cv_id, cv_name"), array("cv_name in ('" . implode("', '", array_keys($WFSettingsVars)) . "')"), __METHOD__); $WFVariables = array(); while ($oRow = $dbw->fetchObject($oRes)) { $WFVariables[$oRow->cv_name] = $oRow->cv_id; } $dbw->freeResult($oRes); foreach ($WFSettingsVars as $variable => $value) { /** * first, get id of variable */ $cv_id = 0; if (isset($WFVariables[$variable])) { $cv_id = $WFVariables[$variable]; } /** * then, insert value for wikia */ if (!empty($cv_id)) { $dbw->insert("city_variables", array("cv_value" => serialize($value), "cv_city_id" => $this->mWikiId, "cv_variable_id" => $cv_id), __METHOD__); } } }