/** * @param $resourceLoader ResourceLoader * @param $request WebRequest */ public function __construct($resourceLoader, WebRequest $request) { global $wgDefaultSkin, $wgResourceLoaderDebug; $this->resourceLoader = $resourceLoader; $this->request = $request; // Interpret request // List of modules $modules = $request->getVal('modules'); $this->modules = $modules ? self::expandModuleNames($modules) : array(); // Various parameters $this->skin = $request->getVal('skin'); $this->user = $request->getVal('user'); $this->debug = $request->getFuzzyBool('debug', $wgResourceLoaderDebug); $this->only = $request->getVal('only'); $this->version = $request->getVal('version'); // Wikia - change begin - @author: wladek $this->sassParams = array(); foreach ($request->getValues() as $key => $value) { if (startsWith($key, 'sass_')) { $this->sassParams[substr($key, strlen('sass_'))] = $value; } } ksort($this->sassParams); // Wikia - change end $skinnames = Skin::getSkinNames(); // If no skin is specified, or we don't recognize the skin, use the default skin if (!$this->skin || !isset($skinnames[$this->skin])) { $this->skin = $wgDefaultSkin; } }
function getReplacedQuery($replacements) { $values = $this->request->getValues(); foreach ($replacements as $k => $v) { $values[$k] = $v; } return $values; }
/** * Initialize instance variables from request and create an Upload handler * * @param WebRequest $request The request to extract variables from */ protected function loadRequest($request) { global $wgUser, $wgMaxUploadFiles; // let's make the parent happy wfSuppressWarnings(); $_FILES['wpUploadFile'] = $_FILES['wpUploadFile0']; wfRestoreWarnings(); // Guess the desired name from the filename if not provided $this->mDesiredDestNames = array(); $this->mUploads = array(); // deal with session keys, if we have some pick the first one, for now $vals = $request->getValues(); $fromsession = false; foreach ($vals as $k => $v) { if (preg_match("@^wpSessionKey@", $k)) { $request->setVal('wpSessionKey', $v); $fromsession = true; $filenum = preg_replace("@wpSessionKey@", '', $k); $request->setVal('wpDestFile', $request->getVal('wpDestFile' . $filenum)); $up = UploadBase::createFromRequest($request); $this->mUploads[] = $up; $this->mDesiredDestNames[] = $request->getVal('wpDestFile' . $filenum); } } parent::loadRequest($request); $this->mUploadClicked = $request->wasPosted() && ($request->getCheck('wpUpload') || $request->getCheck('wpUploadIgnoreWarning')); if (!$fromsession) { for ($i = 0; $i < $wgMaxUploadFiles; $i++) { $this->mDesiredDestNames[$i] = $request->getText('wpDestFile' . $i); if (!$this->mDesiredDestNames[$i] && $request->getFileName('wpUploadFile' . $i) !== null) { $this->mDesiredDestNames[$i] = $request->getFileName('wpUploadFile' . $i); } wfSuppressWarnings(); $request->setVal('wpUploadFile', $_FILES['wpUploadFile' . $i]); wfRestoreWarnings(); $request->setVal('wpDestFile', $request->getVal('wpDestFile' . $i)); move_uploaded_file('wpUploadFile' . $i, 'wpUploadFile'); wfSuppressWarnings(); $_FILES['wpUploadFile'] = $_FILES['wpUploadFile' . $i]; wfRestoreWarnings(); $up = UploadBase::createFromRequest($request); if ($up) { $this->mUploads[] = $up; } } } $this->mDesiredDestName = $this->mDesiredDestNames[0]; $this->mUpload = $this->mUploads[0]; }
private function process(WebRequest &$request, OutputPage &$output) { global $wgLinkTitlesTimeLimit; // Start the stopwatch $startTime = microtime(true); // Connect to the database $dbr = wfGetDB(DB_SLAVE); // Fetch the start index and max number of records from the POST // request. $postValues = $request->getValues(); // Convert the start index to an integer; this helps preventing // SQL injection attacks via forged POST requests. $start = intval($postValues['s']); // If an end index was given, we don't need to query the database if (array_key_exists('e', $postValues)) { $end = intval($postValues['e']); } else { // No end index was given. Therefore, count pages now. $end = $this->countPages($dbr); } array_key_exists('r', $postValues) ? $reloads = $postValues['r'] : ($reloads = 0); // Retrieve page names from the database. $res = $dbr->select('page', 'page_title', array('page_namespace = 0'), __METHOD__, array('LIMIT' => 999999999, 'OFFSET' => $start)); // Iterate through the pages; break if a time limit is exceeded. foreach ($res as $row) { $curTitle = $row->page_title; LinkTitles::processPage($curTitle, $this->getContext()); $start += 1; // Check if the time limit is exceeded if (microtime(true) - $startTime > $wgLinkTitlesTimeLimit) { break; } } $this->addProgressInfo($output, $curTitle, $start, $end); // If we have not reached the last page yet, produce code to reload // the extension's special page. if ($start < $end) { $reloads += 1; // Build a form with hidden values and output JavaScript code that // immediately submits the form in order to continue the process. $output->addHTML($this->getReloaderForm($request->getRequestURL(), $start, $end, $reloads)); } else { $this->addCompletedInfo($output, $start, $end, $reloads); } }