コード例 #1
0
ファイル: ResourceLoader.php プロジェクト: richhl/kalturaCE
 /**
  * Post process request uses globals and mediaWiki configuration to
  * validate classes and generate request key
  */
 function postProcRequestVars()
 {
     global $wgContLanguageCode, $wgResourceLoaderNamedPaths, $wgStyleVersion;
     // Set debug flag
     if (isset($_GET['debug']) && $_GET['debug'] == 'true' || isset($wgEnableScriptDebug) && $wgEnableScriptDebug == true) {
         $this->debug = true;
     }
     // Set the urid. Be sure to escape it as it goes into our JS output.
     if (isset($_GET['urid']) && $_GET['urid'] != '') {
         $this->urid = htmlspecialchars($_GET['urid']);
     } else {
         // Just give it the current style sheet ID:
         // NOTE: read the svn version number
         $this->urid = $wgStyleVersion;
     }
     // Get the language code (if not provided use the "default" language
     if (isset($_GET['uselang']) && $_GET['uselang'] != '') {
         // Strip any non alphaNumeric or dash characters from the language code:
         $this->langCode = preg_replace("/[^A-Za-z\\-_]/", '', $_GET['uselang']);
     } else {
         //set English as default
         $this->langCode = 'en';
     }
     $this->langCode = self::checkForCommonsLanguageFormHack($this->langCode);
     $reqClassList = false;
     if (isset($_GET['class']) && $_GET['class'] != '') {
         $reqClassList = explode(',', $_GET['class']);
         self::$rawClassList = $_GET['class'];
     }
     // Check for the requested classes
     if ($reqClassList) {
         // sanitize the Resource list and populate namedFileList
         foreach ($reqClassList as $reqClass) {
             if (trim($reqClass) != '') {
                 if (substr($reqClass, 0, 3) == 'WT:') {
                     $doAddWT = false;
                     // Check for special case '-' resource for user-generated JS
                     if (substr($reqClass, 3, 1) == '-') {
                         $doAddWT = true;
                     } else {
                         if (strtolower(substr($reqClass, -3)) == '.js') {
                             //make sure its a valid wikipage before doing processing
                             $t = Title::newFromDBkey(substr($reqClass, 3));
                             if ($t->exists() && ($t->getNamespace() == NS_MEDIAWIKI || $t->getNamespace() == NS_USER)) {
                                 $doAddWT = true;
                             }
                         }
                     }
                     if ($doAddWT) {
                         $this->namedFileList[$reqClass] = true;
                         $this->requestKey .= $reqClass;
                         $this->jsvarurl = true;
                     }
                     continue;
                 }
                 $reqClass = preg_replace("/[^A-Za-z0-9_\\-\\.]/", '', $reqClass);
                 $filePath = self::getPathFromClass($reqClass);
                 if (!$filePath) {
                     $this->errorMsg .= 'Requested class: ' . xml::escapeJsString($reqClass) . ' not found' . "\n";
                 } else {
                     $this->namedFileList[$reqClass] = $filePath;
                     $this->requestKey .= $reqClass;
                 }
             }
         }
     }
     // Add the language code to the requestKey:
     $this->requestKey .= '_' . $wgContLanguageCode;
     // Add the unique rid
     $this->requestKey .= $this->urid;
 }