function fnCategorySuggestSaveHook($m_isUpload, $m_pageObj)
{
    global $wgContLang;
    # Get localised namespace string:
    $m_catString = $wgContLang->getNsText(NS_CATEGORY);
    # Get some distance from the rest of the content:
    $m_text = "\n";
    #CHECK IF USER HAS SELECTED ANY CATEGORIES
    if ($_POST['txtSelectedCategories']) {
        $arrSelectedCats = explode(';', $_POST['txtSelectedCategories']);
        foreach ($arrSelectedCats as $m_cat) {
            if ($m_cat) {
                $m_cat = Title::capitalize($m_cat, NS_CATEGORY);
                $m_text .= "\n[[" . $m_catString . ":" . trim($m_cat) . "]]";
            }
        }
        # If it is an upload we have to call a different method:
        if ($m_isUpload) {
            $m_pageObj->mUploadDescription .= $m_text;
        } else {
            $m_pageObj->textbox1 .= $m_text;
        }
    }
    # Return to the let MediaWiki do the rest of the work:
    return true;
}
示例#2
0
 function __construct($from)
 {
     parent::__construct();
     $from = str_replace(' ', '_', $from);
     if ($from !== '') {
         $from = Title::capitalize($from, NS_CATEGORY);
         $this->mOffset = $from;
     }
 }
 function __construct(IContextSource $context, $from)
 {
     parent::__construct($context);
     $from = str_replace(' ', '_', $from);
     if ($from !== '') {
         $from = Title::capitalize($from, NS_CATEGORY);
         $this->setOffset($from);
         $this->setIncludeOffset(true);
     }
 }
function wfSpecialWithoutinterwiki()
{
    global $wgRequest, $wgContLang;
    list($limit, $offset) = wfCheckLimits();
    // Only searching the mainspace anyway
    $prefix = Title::capitalize($wgRequest->getVal('prefix'), NS_MAIN);
    $wip = new WithoutInterwikiPage();
    $wip->setPrefix($prefix);
    $wip->doQuery($offset, $limit);
}
 /**
  * Does quick normalisation of message name so that in can be looked from the
  * database.
  * @param string $message Name of the message
  * @param string $code Language code in lower case and with dash as delimiter
  * @param int $ns Namespace constant
  * @return string The normalised title as a string.
  */
 public static function title($message, $code, $ns = NS_MEDIAWIKI)
 {
     // Cache some amount of titles for speed.
     static $cache = array();
     $key = $ns . ':' . $message;
     if (!isset($cache[$key])) {
         $cache[$key] = Title::capitalize($message, $ns);
     }
     if ($code) {
         return $cache[$key] . '/' . $code;
     } else {
         return $cache[$key];
     }
 }
 function execute($par)
 {
     $this->prefix = Title::capitalize($this->getRequest()->getVal('prefix', $par), NS_MAIN);
     parent::execute($par);
 }
 /**
  * Check for non fatal problems with the file.
  *
  * This should not assume that mTempPath is set.
  *
  * @return Array of warnings
  */
 public function checkWarnings()
 {
     global $wgLang;
     wfProfileIn(__METHOD__);
     $warnings = array();
     $localFile = $this->getLocalFile();
     $filename = $localFile->getName();
     /**
      * Check whether the resulting filename is different from the desired one,
      * but ignore things like ucfirst() and spaces/underscore things
      */
     $comparableName = str_replace(' ', '_', $this->mDesiredDestName);
     $comparableName = Title::capitalize($comparableName, NS_FILE);
     if ($this->mDesiredDestName != $filename && $comparableName != $filename) {
         $warnings['badfilename'] = $filename;
         // Debugging for bug 62241
         wfDebugLog('upload', "Filename: '{$filename}', mDesiredDestName: '{$this->mDesiredDestName}', comparableName: '{$comparableName}'");
     }
     // Check whether the file extension is on the unwanted list
     global $wgCheckFileExtensions, $wgFileExtensions;
     if ($wgCheckFileExtensions) {
         $extensions = array_unique($wgFileExtensions);
         if (!$this->checkFileExtension($this->mFinalExtension, $extensions)) {
             $warnings['filetype-unwanted-type'] = array($this->mFinalExtension, $wgLang->commaList($extensions), count($extensions));
         }
     }
     global $wgUploadSizeWarning;
     if ($wgUploadSizeWarning && $this->mFileSize > $wgUploadSizeWarning) {
         $warnings['large-file'] = array($wgUploadSizeWarning, $this->mFileSize);
     }
     if ($this->mFileSize == 0) {
         $warnings['emptyfile'] = true;
     }
     $exists = self::getExistsWarning($localFile);
     if ($exists !== false) {
         $warnings['exists'] = $exists;
     }
     // Check dupes against existing files
     $hash = $this->getTempFileSha1Base36();
     $dupes = RepoGroup::singleton()->findBySha1($hash);
     $title = $this->getTitle();
     // Remove all matches against self
     foreach ($dupes as $key => $dupe) {
         if ($title->equals($dupe->getTitle())) {
             unset($dupes[$key]);
         }
     }
     if ($dupes) {
         $warnings['duplicate'] = $dupes;
     }
     // Check dupes against archives
     $archivedImage = new ArchivedFile(null, 0, "{$hash}.{$this->mFinalExtension}");
     if ($archivedImage->getID() > 0) {
         if ($archivedImage->userCan(File::DELETED_FILE)) {
             $warnings['duplicate-archive'] = $archivedImage->getName();
         } else {
             $warnings['duplicate-archive'] = '';
         }
     }
     wfProfileOut(__METHOD__);
     return $warnings;
 }
 /**
  * Normalizes and splits a title string.
  *
  * This function removes illegal characters, splits off the interwiki and
  * namespace prefixes, sets the other forms, and canonicalizes
  * everything.
  *
  * @todo this method is only exposed as a temporary measure to ease refactoring.
  * It was copied with minimal changes from Title::secureAndSplit().
  *
  * @todo This method should be split up and an appropriate interface
  * defined for use by the Title class.
  *
  * @param string $text
  * @param int $defaultNamespace
  *
  * @throws MalformedTitleException If $text is not a valid title string.
  * @return array A mapp with the fields 'interwiki', 'fragment', 'namespace',
  *         'user_case_dbkey', and 'dbkey'.
  */
 public function splitTitleString($text, $defaultNamespace = NS_MAIN)
 {
     $dbkey = str_replace(' ', '_', $text);
     # Initialisation
     $parts = array('interwiki' => '', 'local_interwiki' => false, 'fragment' => '', 'namespace' => $defaultNamespace, 'dbkey' => $dbkey, 'user_case_dbkey' => $dbkey);
     # Strip Unicode bidi override characters.
     # Sometimes they slip into cut-n-pasted page titles, where the
     # override chars get included in list displays.
     $dbkey = preg_replace('/\\xE2\\x80[\\x8E\\x8F\\xAA-\\xAE]/S', '', $dbkey);
     # Clean up whitespace
     # Note: use of the /u option on preg_replace here will cause
     # input with invalid UTF-8 sequences to be nullified out in PHP 5.2.x,
     # conveniently disabling them.
     $dbkey = preg_replace('/[ _\\xA0\\x{1680}\\x{180E}\\x{2000}-\\x{200A}\\x{2028}\\x{2029}\\x{202F}\\x{205F}\\x{3000}]+/u', '_', $dbkey);
     $dbkey = trim($dbkey, '_');
     if (strpos($dbkey, UtfNormal\Constants::UTF8_REPLACEMENT) !== false) {
         # Contained illegal UTF-8 sequences or forbidden Unicode chars.
         throw new MalformedTitleException('title-invalid-utf8', $text);
     }
     $parts['dbkey'] = $dbkey;
     # Initial colon indicates main namespace rather than specified default
     # but should not create invalid {ns,title} pairs such as {0,Project:Foo}
     if ($dbkey !== '' && ':' == $dbkey[0]) {
         $parts['namespace'] = NS_MAIN;
         $dbkey = substr($dbkey, 1);
         # remove the colon but continue processing
         $dbkey = trim($dbkey, '_');
         # remove any subsequent whitespace
     }
     if ($dbkey == '') {
         throw new MalformedTitleException('title-invalid-empty', $text);
     }
     # Namespace or interwiki prefix
     $prefixRegexp = "/^(.+?)_*:_*(.*)\$/S";
     do {
         $m = array();
         if (preg_match($prefixRegexp, $dbkey, $m)) {
             $p = $m[1];
             if (($ns = $this->language->getNsIndex($p)) !== false) {
                 # Ordinary namespace
                 $dbkey = $m[2];
                 $parts['namespace'] = $ns;
                 # For Talk:X pages, check if X has a "namespace" prefix
                 if ($ns == NS_TALK && preg_match($prefixRegexp, $dbkey, $x)) {
                     if ($this->language->getNsIndex($x[1])) {
                         # Disallow Talk:File:x type titles...
                         throw new MalformedTitleException('title-invalid-talk-namespace', $text);
                     } elseif (Interwiki::isValidInterwiki($x[1])) {
                         // TODO: get rid of global state!
                         # Disallow Talk:Interwiki:x type titles...
                         throw new MalformedTitleException('title-invalid-talk-namespace', $text);
                     }
                 }
             } elseif (Interwiki::isValidInterwiki($p)) {
                 # Interwiki link
                 $dbkey = $m[2];
                 $parts['interwiki'] = $this->language->lc($p);
                 # Redundant interwiki prefix to the local wiki
                 foreach ($this->localInterwikis as $localIW) {
                     if (0 == strcasecmp($parts['interwiki'], $localIW)) {
                         if ($dbkey == '') {
                             # Empty self-links should point to the Main Page, to ensure
                             # compatibility with cross-wiki transclusions and the like.
                             $mainPage = Title::newMainPage();
                             return array('interwiki' => $mainPage->getInterwiki(), 'local_interwiki' => true, 'fragment' => $mainPage->getFragment(), 'namespace' => $mainPage->getNamespace(), 'dbkey' => $mainPage->getDBkey(), 'user_case_dbkey' => $mainPage->getUserCaseDBKey());
                         }
                         $parts['interwiki'] = '';
                         # local interwikis should behave like initial-colon links
                         $parts['local_interwiki'] = true;
                         # Do another namespace split...
                         continue 2;
                     }
                 }
                 # If there's an initial colon after the interwiki, that also
                 # resets the default namespace
                 if ($dbkey !== '' && $dbkey[0] == ':') {
                     $parts['namespace'] = NS_MAIN;
                     $dbkey = substr($dbkey, 1);
                 }
             }
             # If there's no recognized interwiki or namespace,
             # then let the colon expression be part of the title.
         }
         break;
     } while (true);
     $fragment = strstr($dbkey, '#');
     if (false !== $fragment) {
         $parts['fragment'] = str_replace('_', ' ', substr($fragment, 1));
         $dbkey = substr($dbkey, 0, strlen($dbkey) - strlen($fragment));
         # remove whitespace again: prevents "Foo_bar_#"
         # becoming "Foo_bar_"
         $dbkey = preg_replace('/_*$/', '', $dbkey);
     }
     # Reject illegal characters.
     $rxTc = self::getTitleInvalidRegex();
     $matches = array();
     if (preg_match($rxTc, $dbkey, $matches)) {
         throw new MalformedTitleException('title-invalid-characters', $text, array($matches[0]));
     }
     # Pages with "/./" or "/../" appearing in the URLs will often be un-
     # reachable due to the way web browsers deal with 'relative' URLs.
     # Also, they conflict with subpage syntax.  Forbid them explicitly.
     if (strpos($dbkey, '.') !== false && ($dbkey === '.' || $dbkey === '..' || strpos($dbkey, './') === 0 || strpos($dbkey, '../') === 0 || strpos($dbkey, '/./') !== false || strpos($dbkey, '/../') !== false || substr($dbkey, -2) == '/.' || substr($dbkey, -3) == '/..')) {
         throw new MalformedTitleException('title-invalid-relative', $text);
     }
     # Magic tilde sequences? Nu-uh!
     if (strpos($dbkey, '~~~') !== false) {
         throw new MalformedTitleException('title-invalid-magic-tilde', $text);
     }
     # Limit the size of titles to 255 bytes. This is typically the size of the
     # underlying database field. We make an exception for special pages, which
     # don't need to be stored in the database, and may edge over 255 bytes due
     # to subpage syntax for long titles, e.g. [[Special:Block/Long name]]
     $maxLength = $parts['namespace'] != NS_SPECIAL ? 255 : 512;
     if (strlen($dbkey) > $maxLength) {
         throw new MalformedTitleException('title-invalid-too-long', $text, array(Message::numParam($maxLength)));
     }
     # Normally, all wiki links are forced to have an initial capital letter so [[foo]]
     # and [[Foo]] point to the same place.  Don't force it for interwikis, since the
     # other site might be case-sensitive.
     $parts['user_case_dbkey'] = $dbkey;
     if ($parts['interwiki'] === '') {
         $dbkey = Title::capitalize($dbkey, $parts['namespace']);
     }
     # Can't make a link to a namespace alone... "empty" local links can only be
     # self-links with a fragment identifier.
     if ($dbkey == '' && $parts['interwiki'] === '') {
         if ($parts['namespace'] != NS_MAIN) {
             throw new MalformedTitleException('title-invalid-empty', $text);
         }
     }
     // Allow IPv6 usernames to start with '::' by canonicalizing IPv6 titles.
     // IP names are not allowed for accounts, and can only be referring to
     // edits from the IP. Given '::' abbreviations and caps/lowercaps,
     // there are numerous ways to present the same IP. Having sp:contribs scan
     // them all is silly and having some show the edits and others not is
     // inconsistent. Same for talk/userpages. Keep them normalized instead.
     if ($parts['namespace'] == NS_USER || $parts['namespace'] == NS_USER_TALK) {
         $dbkey = IP::sanitizeIP($dbkey);
     }
     // Any remaining initial :s are illegal.
     if ($dbkey !== '' && ':' == $dbkey[0]) {
         throw new MalformedTitleException('title-invalid-leading-colon', $text);
     }
     # Fill fields
     $parts['dbkey'] = $dbkey;
     return $parts;
 }
    } else {
        $languageFixups = $uwDefaultLanguageFixups;
    }
    // Use LinkBatch to make this a little bit more faster.
    // It works because $title->exists (below) will use LinkCache.
    $linkBatch = new LinkBatch();
    foreach ($baseLangs as $code => $name) {
        $fixedCode = array_key_exists($code, $languageFixups) ? $languageFixups[$code] : $code;
        if (is_string($fixedCode) && $fixedCode !== '') {
            $title = Title::makeTitle(NS_TEMPLATE, Title::capitalize($fixedCode, NS_TEMPLATE));
            $linkBatch->addObj($title);
        }
    }
    $linkBatch->execute();
    // Then, check that there's a template for each one.
    foreach ($baseLangs as $code => $name) {
        $fixedCode = array_key_exists($code, $languageFixups) ? $languageFixups[$code] : $code;
        if (is_string($fixedCode) && $fixedCode !== '') {
            $title = Title::makeTitle(NS_TEMPLATE, Title::capitalize($fixedCode, NS_TEMPLATE));
            if ($title->exists()) {
                // If there is, then it's in the final picks!
                $uwLanguages[$code] = $name;
            }
        }
    }
    // Sort the list by the language name
    natsort($uwLanguages);
    // Cache the list for 1 day
    $wgMemc->set($cacheKey, $uwLanguages, 60 * 60 * 24);
}
return array('debug' => false, 'enableLicensePreference' => true, 'campaignSquidMaxAge' => 10 * 60, 'campaignExpensiveStatsEnabled' => true, 'campaignStatsMaxAge' => 60, 'campaignCTACampaignTemplate' => 'uploadCampaign:$1', 'fileExtensions' => $wgCheckFileExtensions ? $wgFileExtensions : null, 'flickrApiUrl' => 'https://api.flickr.com/services/rest/?', 'flickrApiKey' => 'aeefff139445d825d4460796616f9349', 'flickrBlacklistPage' => '', 'autoAdd' => array('categories' => array(), 'wikitext' => ''), 'missingCategoriesWikiText' => '', 'display' => array('headerLabel' => '', 'thanksLabel' => '', 'labelPickImage' => '', 'noticeExistingImage' => '', 'noticeUpdateDelay' => ''), 'tutorial' => array('skip' => false, 'template' => 'Licensing_tutorial_$1.svg', 'width' => 720, 'helpdeskCoords' => '27, 1319, 691, 1384'), 'trackingCategory' => array('all' => 'Uploaded with UploadWizard', 'campaign' => 'Uploaded via Campaign:$1'), 'fields' => array(array('wikitext' => '', 'label' => '', 'maxLength' => 25, 'initialValue' => '', 'required' => false, 'type' => "text", 'options' => array())), 'defaults' => array('categories' => array(), 'description' => ''), 'uwLanguages' => empty($uwLanguages) ? array('en' => 'English') : $uwLanguages, 'licenses' => array('cc-by-sa-4.0' => array('msg' => 'mwe-upwiz-license-cc-by-sa-4.0', 'icons' => array('cc-by', 'cc-sa'), 'url' => '//creativecommons.org/licenses/by-sa/4.0/', 'languageCodePrefix' => 'deed.'), 'cc-by-sa-3.0' => array('msg' => 'mwe-upwiz-license-cc-by-sa-3.0', 'icons' => array('cc-by', 'cc-sa'), 'url' => '//creativecommons.org/licenses/by-sa/3.0/', 'languageCodePrefix' => 'deed.'), 'cc-by-sa-3.0-gfdl' => array('msg' => 'mwe-upwiz-license-cc-by-sa-3.0-gfdl', 'templates' => array('GFDL', 'cc-by-sa-3.0'), 'icons' => array('cc-by', 'cc-sa')), 'cc-by-sa-3.0-at' => array('msg' => 'mwe-upwiz-license-cc-by-sa-3.0-at', 'templates' => array('cc-by-sa-3.0-at'), 'icons' => array('cc-by', 'cc-sa'), 'url' => '//creativecommons.org/licenses/by-sa/3.0/at/', 'languageCodePrefix' => 'deed.'), 'cc-by-sa-3.0-de' => array('msg' => 'mwe-upwiz-license-cc-by-sa-3.0-de', 'templates' => array('cc-by-sa-3.0-de'), 'icons' => array('cc-by', 'cc-sa'), 'url' => '//creativecommons.org/licenses/by-sa/3.0/de/', 'languageCodePrefix' => 'deed.'), 'cc-by-sa-3.0-ee' => array('msg' => 'mwe-upwiz-license-cc-by-sa-3.0-ee', 'templates' => array('cc-by-sa-3.0-ee'), 'icons' => array('cc-by', 'cc-sa'), 'url' => '//creativecommons.org/licenses/by-sa/3.0/ee/', 'languageCodePrefix' => 'deed.'), 'cc-by-sa-3.0-es' => array('msg' => 'mwe-upwiz-license-cc-by-sa-3.0-es', 'templates' => array('cc-by-sa-3.0-es'), 'icons' => array('cc-by', 'cc-sa'), 'url' => '//creativecommons.org/licenses/by-sa/3.0/es/', 'languageCodePrefix' => 'deed.'), 'cc-by-sa-3.0-hr' => array('msg' => 'mwe-upwiz-license-cc-by-sa-3.0-hr', 'templates' => array('cc-by-sa-3.0-hr'), 'icons' => array('cc-by', 'cc-sa'), 'url' => '//creativecommons.org/licenses/by-sa/3.0/hr/', 'languageCodePrefix' => 'deed.'), 'cc-by-sa-3.0-lu' => array('msg' => 'mwe-upwiz-license-cc-by-sa-3.0-lu', 'templates' => array('cc-by-sa-3.0-lu'), 'icons' => array('cc-by', 'cc-sa'), 'url' => '//creativecommons.org/licenses/by-sa/3.0/lu/', 'languageCodePrefix' => 'deed.'), 'cc-by-sa-3.0-nl' => array('msg' => 'mwe-upwiz-license-cc-by-sa-3.0-nl', 'templates' => array('cc-by-sa-3.0-nl'), 'icons' => array('cc-by', 'cc-sa'), 'url' => '//creativecommons.org/licenses/by-sa/3.0/nl/', 'languageCodePrefix' => 'deed.'), 'cc-by-sa-3.0-no' => array('msg' => 'mwe-upwiz-license-cc-by-sa-3.0-no', 'templates' => array('cc-by-sa-3.0-no'), 'icons' => array('cc-by', 'cc-sa'), 'url' => '//creativecommons.org/licenses/by-sa/3.0/no/', 'languageCodePrefix' => 'deed.'), 'cc-by-sa-3.0-pl' => array('msg' => 'mwe-upwiz-license-cc-by-sa-3.0-pl', 'templates' => array('cc-by-sa-3.0-pl'), 'icons' => array('cc-by', 'cc-sa'), 'url' => '//creativecommons.org/licenses/by-sa/3.0/pl/', 'languageCodePrefix' => 'deed.'), 'cc-by-sa-3.0-ro' => array('msg' => 'mwe-upwiz-license-cc-by-sa-3.0-ro', 'templates' => array('cc-by-sa-3.0-ro'), 'icons' => array('cc-by', 'cc-sa'), 'url' => '//creativecommons.org/licenses/by-sa/3.0/ro/', 'languageCodePrefix' => 'deed.'), 'cc-by-4.0' => array('msg' => 'mwe-upwiz-license-cc-by-4.0', 'icons' => array('cc-by'), 'url' => '//creativecommons.org/licenses/by/4.0/', 'languageCodePrefix' => 'deed.'), 'cc-by-3.0' => array('msg' => 'mwe-upwiz-license-cc-by-3.0', 'icons' => array('cc-by'), 'url' => '//creativecommons.org/licenses/by/3.0/', 'languageCodePrefix' => 'deed.'), 'cc-zero' => array('msg' => 'mwe-upwiz-license-cc-zero', 'icons' => array('cc-zero'), 'url' => '//creativecommons.org/publicdomain/zero/1.0/', 'languageCodePrefix' => 'deed.'), 'own-pd' => array('msg' => 'mwe-upwiz-license-own-pd', 'icons' => array('cc-zero'), 'templates' => array('cc-zero')), 'cc-by-sa-2.5' => array('msg' => 'mwe-upwiz-license-cc-by-sa-2.5', 'icons' => array('cc-by', 'cc-sa'), 'url' => '//creativecommons.org/licenses/by-sa/2.5/', 'languageCodePrefix' => 'deed.'), 'cc-by-2.5' => array('msg' => 'mwe-upwiz-license-cc-by-2.5', 'icons' => array('cc-by'), 'url' => '//creativecommons.org/licenses/by/2.5/', 'languageCodePrefix' => 'deed.'), 'cc-by-sa-2.0' => array('msg' => 'mwe-upwiz-license-cc-by-sa-2.0', 'icons' => array('cc-by', 'cc-sa'), 'url' => '//creativecommons.org/licenses/by-sa/2.0/', 'languageCodePrefix' => 'deed.'), 'cc-by-2.0' => array('msg' => 'mwe-upwiz-license-cc-by-2.0', 'icons' => array('cc-by'), 'url' => '//creativecommons.org/licenses/by/2.0/', 'languageCodePrefix' => 'deed.'), 'fal' => array('msg' => 'mwe-upwiz-license-fal', 'templates' => array('FAL')), 'pd-old-100' => array('msg' => 'mwe-upwiz-license-pd-old-100', 'templates' => array('PD-old-100')), 'pd-old' => array('msg' => 'mwe-upwiz-license-pd-old', 'templates' => array('PD-old')), 'pd-art' => array('msg' => 'mwe-upwiz-license-pd-art', 'templates' => array('PD-Art')), 'pd-us' => array('msg' => 'mwe-upwiz-license-pd-us', 'templates' => array('PD-US')), 'pd-usgov' => array('msg' => 'mwe-upwiz-license-pd-usgov', 'templates' => array('PD-USGov')), 'pd-usgov-nasa' => array('msg' => 'mwe-upwiz-license-pd-usgov-nasa', 'templates' => array('PD-USGov-NASA')), 'pd-ineligible' => array('msg' => 'mwe-upwiz-license-pd-ineligible'), 'pd-textlogo' => array('msg' => 'mwe-upwiz-license-pd-textlogo', 'templates' => array('trademarked', 'PD-textlogo')), 'attribution' => array('msg' => 'mwe-upwiz-license-attribution'), 'gfdl' => array('msg' => 'mwe-upwiz-license-gfdl', 'templates' => array('GFDL')), 'none' => array('msg' => 'mwe-upwiz-license-none', 'templates' => array('subst:uwl')), 'custom' => array('msg' => 'mwe-upwiz-license-custom', 'templates' => array('subst:Custom license marker added by UW'), 'url' => wfMessage('mwe-upwiz-license-custom-url')->parse())), 'licenseCategory' => 'License tags', 'licenseTagFilters' => array('self'), 'licensing' => array('defaultType' => 'choice', 'ownWorkDefault' => 'choice', 'ownWork' => array('type' => 'or', 'template' => 'self', 'licenses' => array('cc-by-sa-4.0', 'cc-by-sa-3.0', 'cc-by-4.0', 'cc-by-3.0', 'cc-zero')), 'thirdParty' => array('type' => 'or', 'licenseGroups' => array(array('head' => 'mwe-upwiz-license-cc-head', 'subhead' => 'mwe-upwiz-license-cc-subhead', 'licenses' => array('cc-by-sa-4.0', 'cc-by-sa-3.0', 'cc-by-sa-2.5', 'cc-by-4.0', 'cc-by-3.0', 'cc-by-2.5', 'cc-zero')), array('head' => 'mwe-upwiz-license-flickr-head', 'subhead' => 'mwe-upwiz-license-flickr-subhead', 'prependTemplates' => array('flickrreview'), 'licenses' => array('cc-by-sa-2.0', 'cc-by-2.0', 'pd-usgov')), array('head' => 'mwe-upwiz-license-public-domain-usa-head', 'subhead' => 'mwe-upwiz-license-public-domain-usa-subhead', 'licenses' => array('pd-us', 'pd-art')), array('head' => 'mwe-upwiz-license-usgov-head', 'licenses' => array('pd-usgov', 'pd-usgov-nasa')), array('head' => 'mwe-upwiz-license-custom-head', 'special' => 'custom', 'licenses' => array('custom')), array('head' => 'mwe-upwiz-license-none-head', 'licenses' => array('none'))))), 'thumbnailWidth' => 100, 'thumbnailMaxHeight' => 100, 'largeThumbnailWidth' => 500, 'largeThumbnailMaxHeight' => 500, 'maxAuthorLength' => 10000, 'minAuthorLength' => 1, 'maxSourceLength' => 10000, 'minSourceLength' => 5, 'maxTitleLength' => 500, 'minTitleLength' => 5, 'maxDescriptionLength' => 10000, 'minDescriptionLength' => 5, 'maxOtherInformationLength' => 10000, 'maxSimultaneousConnections' => 3, 'maxUploads' => 50, 'maxPhpUploadSize' => min(wfShorthandToInteger(ini_get('upload_max_filesize')), wfShorthandToInteger(ini_get('post_max_size'))), 'maxMwUploadSize' => $wgMaxUploadSize, 'minCustomLicenseLength' => 6, 'maxCustomLicenseLength' => 10000, 'languageTemplateFixups' => $uwDefaultLanguageFixups, 'enableFirefogg' => true, 'transcodeExtensionList' => array('avi', 'asf', 'asx', 'wmv', 'wmx', 'dv', 'rm', 'ra', '3gp', 'mkv', 'mp4', 'm4v', 'mov', 'qt', 'mpeg', 'mpeg2', 'mp2', 'mpg', 'mts'), 'firefoggEncodeSettings' => array('maxSize' => '1920x1080', 'videoQuality' => 7, 'audioQuality' => 3, 'noUpscaling' => 'true', 'videoCodec' => 'vp8'), 'feedbackPage' => '', 'bugList' => 'https://phabricator.wikimedia.org/tag/MediaWiki-extensions-UploadWizard', 'altUploadForm' => '', 'useTitleBlacklistApi' => array_key_exists('titleblacklist', $wgAPIModules), 'blacklistIssuesPage' => '', 'enableFormData' => true, 'enableMultiFileSelect' => true, 'enableChunked' => false, 'chunkSize' => 5 * 1024 * 1024, 'copyMetadataFeature' => true, 'enableMultipleFiles' => true);
示例#10
0
 /**
  * Check for non fatal problems with the file
  *
  * @return Array of warnings
  */
 public function checkWarnings()
 {
     $warnings = array();
     $localFile = $this->getLocalFile();
     $filename = $localFile->getName();
     $n = strrpos($filename, '.');
     /**
      * Check whether the resulting filename is different from the desired one,
      * but ignore things like ucfirst() and spaces/underscore things
      */
     $comparableName = str_replace(' ', '_', $this->mDesiredDestName);
     $comparableName = Title::capitalize($comparableName, NS_FILE);
     if ($this->mDesiredDestName != $filename && $comparableName != $filename) {
         $warnings['badfilename'] = $filename;
     }
     // Check whether the file extension is on the unwanted list
     global $wgCheckFileExtensions, $wgFileExtensions;
     if ($wgCheckFileExtensions) {
         if (!$this->checkFileExtension($this->mFinalExtension, $wgFileExtensions)) {
             $warnings['filetype-unwanted-type'] = $this->mFinalExtension;
         }
     }
     global $wgUploadSizeWarning;
     if ($wgUploadSizeWarning && $this->mFileSize > $wgUploadSizeWarning) {
         $warnings['large-file'] = $wgUploadSizeWarning;
     }
     if ($this->mFileSize == 0) {
         $warnings['emptyfile'] = true;
     }
     $exists = self::getExistsWarning($localFile);
     if ($exists !== false) {
         $warnings['exists'] = $exists;
     }
     // Check dupes against existing files
     $hash = File::sha1Base36($this->mTempPath);
     $dupes = RepoGroup::singleton()->findBySha1($hash);
     $title = $this->getTitle();
     // Remove all matches against self
     foreach ($dupes as $key => $dupe) {
         if ($title->equals($dupe->getTitle())) {
             unset($dupes[$key]);
         }
     }
     if ($dupes) {
         $warnings['duplicate'] = $dupes;
     }
     // Check dupes against archives
     $archivedImage = new ArchivedFile(null, 0, "{$hash}.{$this->mFinalExtension}");
     if ($archivedImage->getID() > 0) {
         $warnings['duplicate-archive'] = $archivedImage->getName();
     }
     return $warnings;
 }
 function execute($par)
 {
     global $wgRequest;
     $this->prefix = Title::capitalize($wgRequest->getVal('prefix', $par), NS_MAIN);
     parent::execute($par);
 }
 protected function preQueryUsers($users)
 {
     $lb = new LinkBatch();
     foreach ($users as $user => $count) {
         $user = Title::capitalize($user, NS_USER);
         $lb->add(NS_USER, $user);
         $lb->add(NS_USER_TALK, $user);
     }
     $lb->execute();
 }
示例#13
0
 /**
  * Check for non fatal problems with the file.
  *
  * This should not assume that mTempPath is set.
  *
  * @return array Array of warnings
  */
 public function checkWarnings()
 {
     global $wgLang;
     $warnings = [];
     $localFile = $this->getLocalFile();
     $localFile->load(File::READ_LATEST);
     $filename = $localFile->getName();
     /**
      * Check whether the resulting filename is different from the desired one,
      * but ignore things like ucfirst() and spaces/underscore things
      */
     $comparableName = str_replace(' ', '_', $this->mDesiredDestName);
     $comparableName = Title::capitalize($comparableName, NS_FILE);
     if ($this->mDesiredDestName != $filename && $comparableName != $filename) {
         $warnings['badfilename'] = $filename;
     }
     // Check whether the file extension is on the unwanted list
     global $wgCheckFileExtensions, $wgFileExtensions;
     if ($wgCheckFileExtensions) {
         $extensions = array_unique($wgFileExtensions);
         if (!$this->checkFileExtension($this->mFinalExtension, $extensions)) {
             $warnings['filetype-unwanted-type'] = [$this->mFinalExtension, $wgLang->commaList($extensions), count($extensions)];
         }
     }
     global $wgUploadSizeWarning;
     if ($wgUploadSizeWarning && $this->mFileSize > $wgUploadSizeWarning) {
         $warnings['large-file'] = [$wgUploadSizeWarning, $this->mFileSize];
     }
     if ($this->mFileSize == 0) {
         $warnings['empty-file'] = true;
     }
     $hash = $this->getTempFileSha1Base36();
     $exists = self::getExistsWarning($localFile);
     if ($exists !== false) {
         $warnings['exists'] = $exists;
         // check if file is an exact duplicate of current file version
         if ($hash === $localFile->getSha1()) {
             $warnings['no-change'] = $localFile;
         }
         // check if file is an exact duplicate of older versions of this file
         $history = $localFile->getHistory();
         foreach ($history as $oldFile) {
             if ($hash === $oldFile->getSha1()) {
                 $warnings['duplicate-version'][] = $oldFile;
             }
         }
     }
     if ($localFile->wasDeleted() && !$localFile->exists()) {
         $warnings['was-deleted'] = $filename;
     }
     // Check dupes against existing files
     $dupes = RepoGroup::singleton()->findBySha1($hash);
     $title = $this->getTitle();
     // Remove all matches against self
     foreach ($dupes as $key => $dupe) {
         if ($title->equals($dupe->getTitle())) {
             unset($dupes[$key]);
         }
     }
     if ($dupes) {
         $warnings['duplicate'] = $dupes;
     }
     // Check dupes against archives
     $archivedFile = new ArchivedFile(null, 0, '', $hash);
     if ($archivedFile->getID() > 0) {
         if ($archivedFile->userCan(File::DELETED_FILE)) {
             $warnings['duplicate-archive'] = $archivedFile->getName();
         } else {
             $warnings['duplicate-archive'] = '';
         }
     }
     return $warnings;
 }