コード例 #1
0
 function execute($query)
 {
     global $wgOut;
     wfProfileIn('SpecialURIResolver::execute (SMW)');
     if (is_null($query) || trim($query) === '') {
         if (stristr($_SERVER['HTTP_ACCEPT'], 'RDF')) {
             $wgOut->redirect(SpecialPage::getTitleFor('ExportRDF')->getFullURL(array('stats' => '1')), '303');
         } else {
             $this->setHeaders();
             $wgOut->addHTML('<p>' . wfMessage('smw_uri_doc', 'http://www.w3.org/2001/tag/issues.html#httpRange-14')->parse() . '</p>');
         }
     } else {
         $query = SMWExporter::decodeURI($query);
         $query = str_replace('_', '%20', $query);
         $query = urldecode($query);
         $title = Title::newFromText($query);
         // In case the title doesn't exists throw an error page
         if ($title === null) {
             $wgOut->showErrorPage('badtitle', 'badtitletext');
         } else {
             $wgOut->redirect(stristr($_SERVER['HTTP_ACCEPT'], 'RDF') ? SpecialPage::getTitleFor('ExportRDF', $title->getPrefixedText())->getFullURL(array('xmlmime' => 'rdf')) : $title->getFullURL(), '303');
         }
     }
     wfProfileOut('SpecialURIResolver::execute (SMW)');
 }
コード例 #2
0
ファイル: SpecialTags.php プロジェクト: eFFemeer/seizamcore
 function doTagRow($tag, $hitcount)
 {
     static $sk = null, $doneTags = array();
     if (!$sk) {
         $sk = $this->getSkin();
     }
     if (in_array($tag, $doneTags)) {
         return '';
     }
     global $wgLang;
     $newRow = '';
     $newRow .= Xml::tags('td', null, Xml::element('tt', null, $tag));
     $disp = ChangeTags::tagDescription($tag);
     $disp .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), wfMsgHtml('tags-edit')) . ')';
     $newRow .= Xml::tags('td', null, $disp);
     $msg = wfMessage("tag-{$tag}-description");
     $desc = !$msg->exists() ? '' : $msg->parse();
     $desc .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), wfMsgHtml('tags-edit')) . ')';
     $newRow .= Xml::tags('td', null, $desc);
     $hitcount = wfMsgExt('tags-hitcount', array('parsemag'), $wgLang->formatNum($hitcount));
     $hitcount = $sk->link(SpecialPage::getTitleFor('Recentchanges'), $hitcount, array(), array('tagfilter' => $tag));
     $newRow .= Xml::tags('td', null, $hitcount);
     $doneTags[] = $tag;
     return Xml::tags('tr', null, $newRow) . "\n";
 }
コード例 #3
0
ファイル: ApiErrorFormatterTest.php プロジェクト: foxlog/wiki
 /**
  * @covers ApiErrorFormatter_BackCompat
  */
 public function testErrorFormatterBC()
 {
     $mainpagePlain = wfMessage('mainpage')->useDatabase(false)->plain();
     $parensPlain = wfMessage('parentheses', 'foobar')->useDatabase(false)->plain();
     $result = new ApiResult(8388608);
     $formatter = new ApiErrorFormatter_BackCompat($result);
     $formatter->addWarning('string', 'mainpage');
     $formatter->addError('err', 'mainpage');
     $this->assertSame(array('error' => array('code' => 'mainpage', 'info' => $mainpagePlain), 'warnings' => array('string' => array('warnings' => $mainpagePlain, ApiResult::META_CONTENT => 'warnings')), ApiResult::META_TYPE => 'assoc'), $result->getResultData(), 'Simple test');
     $result->reset();
     $formatter->addWarning('foo', 'mainpage');
     $formatter->addWarning('foo', 'mainpage');
     $formatter->addWarning('foo', array('parentheses', 'foobar'));
     $msg1 = wfMessage('mainpage');
     $formatter->addWarning('message', $msg1);
     $msg2 = new ApiMessage('mainpage', 'overriddenCode', array('overriddenData' => true));
     $formatter->addWarning('messageWithData', $msg2);
     $formatter->addError('errWithData', $msg2);
     $this->assertSame(array('error' => array('code' => 'overriddenCode', 'info' => $mainpagePlain, 'overriddenData' => true), 'warnings' => array('messageWithData' => array('warnings' => $mainpagePlain, ApiResult::META_CONTENT => 'warnings'), 'message' => array('warnings' => $mainpagePlain, ApiResult::META_CONTENT => 'warnings'), 'foo' => array('warnings' => "{$mainpagePlain}\n{$parensPlain}", ApiResult::META_CONTENT => 'warnings')), ApiResult::META_TYPE => 'assoc'), $result->getResultData(), 'Complex test');
     $result->reset();
     $status = Status::newGood();
     $status->warning('mainpage');
     $status->warning('parentheses', 'foobar');
     $status->warning($msg1);
     $status->warning($msg2);
     $status->error('mainpage');
     $status->error('parentheses', 'foobar');
     $formatter->addMessagesFromStatus('status', $status);
     $this->assertSame(array('error' => array('code' => 'parentheses', 'info' => $parensPlain), 'warnings' => array('status' => array('warnings' => "{$mainpagePlain}\n{$parensPlain}", ApiResult::META_CONTENT => 'warnings')), ApiResult::META_TYPE => 'assoc'), $result->getResultData(), 'Status test');
     $I = ApiResult::META_INDEXED_TAG_NAME;
     $this->assertSame(array(array('type' => 'error', 'message' => 'mainpage', 'params' => array($I => 'param')), array('type' => 'error', 'message' => 'parentheses', 'params' => array('foobar', $I => 'param')), $I => 'error'), $formatter->arrayFromStatus($status, 'error'), 'arrayFromStatus test for error');
     $this->assertSame(array(array('type' => 'warning', 'message' => 'mainpage', 'params' => array($I => 'param')), array('type' => 'warning', 'message' => 'parentheses', 'params' => array('foobar', $I => 'param')), array('message' => 'mainpage', 'params' => array($I => 'param'), 'type' => 'warning'), array('message' => 'mainpage', 'params' => array($I => 'param'), 'type' => 'warning'), $I => 'warning'), $formatter->arrayFromStatus($status, 'warning'), 'arrayFromStatus test for warning');
 }
 public function execute($params = false)
 {
     $sEditLinkText = wfMessage('bs-widget-edit')->text();
     $oTitle = Title::makeTitle(NS_USER, RequestContext::getMain()->getUser()->getName() . '/Widgetbar');
     $sEditLink = Linker::link($oTitle, Html::rawElement('span', array(), $sEditLinkText), array('id' => 'bs-widgetbar-edit', 'class' => 'icon-pencil clearfix'), array('action' => 'edit', 'preload' => ''));
     $aOut = array();
     $aOut[] = '<div id="bs-widget-container" >';
     $aOut[] = '  <div class="icon-plus" id="bs-widget-tab" title="' . wfMessage('bs-widget-container-tooltip')->text() . '" tabindex="100">[+/-]</div>';
     $aOut[] = '  <div id="bs-flyout">';
     $aOut[] = '    <h4 id="bs-flyout-heading">' . wfMessage('bs-widget-flyout-heading')->text() . '</h4>';
     $aOut[] = '    <div id="bs-flyout-content">';
     $aOut[] = '      <div id="bs-flyout-content-widgets">';
     $aOut[] = '        <h4 id="bs-flyout-content-widgets-header">' . wfMessage("bs-widget-flyout-heading")->plain() . $sEditLink . '</h4>';
     foreach ($this->_mWidgets as $oWidgetView) {
         if ($oWidgetView instanceof ViewWidget) {
             $aOut[] = $oWidgetView->execute();
         } else {
             wfDebug(__METHOD__ . ': Invalid widget.');
         }
     }
     $aOut[] = '      </div>';
     $aOut[] = '    </div>';
     $aOut[] = '  </div>';
     $aOut[] = '</div>';
     return implode("\n", $aOut);
 }
コード例 #5
0
ファイル: LogFormatter.php プロジェクト: Rikuforever/wiki
 static function formatLogEntry($type, $action, $title, $sk, $parameters)
 {
     $msg = "lqt-log-action-{$action}";
     switch ($action) {
         case 'merge':
             if ($parameters[0]) {
                 $msg = 'lqt-log-action-merge-across';
             } else {
                 $msg = 'lqt-log-action-merge-down';
             }
             break;
         case 'move':
             $smt = new SpecialMoveThread();
             $rightsCheck = $smt->checkUserRights($parameters[1] instanceof Title ? $parameters[1] : Title::newFromText($parameters[1]), $parameters[0] instanceof Title ? $parameters[0] : Title::newFromText($parameters[0]));
             if ($rightsCheck === true) {
                 $parameters[] = Message::rawParam(Linker::link(SpecialPage::getTitleFor('MoveThread', $title), wfMessage('revertmove')->text(), array(), array('dest' => $parameters[0])));
             } else {
                 $parameters[] = '';
             }
             break;
         default:
             // Give grep a chance to find the usages:
             // lqt-log-action-move, lqt-log-action-split, lqt-log-action-subjectedit,
             // lqt-log-action-resort, lqt-log-action-signatureedit
             $msg = "lqt-log-action-{$action}";
             break;
     }
     array_unshift($parameters, $title->getPrefixedText());
     $html = wfMessage($msg, $parameters);
     if ($sk === null) {
         return StringUtils::delimiterReplace('<', '>', '', $html->inContentLanguage()->parse());
     }
     return $html->parse();
 }
コード例 #6
0
function wfRelationshipRequestResponse($response, $requestId)
{
    global $wgUser;
    $out = '';
    $rel = new UserRelationship($wgUser->getName());
    if ($rel->verifyRelationshipRequest($requestId) == true) {
        $request = $rel->getRequest($requestId);
        $user_name_from = $request[0]['user_name_from'];
        $user_id_from = User::idFromName($user_name_from);
        $rel_type = strtolower($request[0]['type']);
        $response = isset($_POST['response']) ? $_POST['response'] : $response;
        $rel->updateRelationshipRequestStatus($requestId, intval($response));
        $avatar = new wAvatar($user_id_from, 'l');
        $avatar_img = $avatar->getAvatarURL();
        if ($response == 1) {
            $rel->addRelationship($requestId);
            $out .= "<div class=\"relationship-action red-text\">\n\t\t\t\t{$avatar_img}" . wfMessage("ur-requests-added-message-{$rel_type}", $user_name_from)->escaped() . '<div class="cleared"></div>
			</div>';
        } else {
            $out .= "<div class=\"relationship-action red-text\">\n\t\t\t\t{$avatar_img}" . wfMessage("ur-requests-reject-message-{$rel_type}", $user_name_from)->escaped() . '<div class="cleared"></div>
			</div>';
        }
        $rel->deleteRequest($requestId);
    }
    return $out;
}
コード例 #7
0
ファイル: AddResource.php プロジェクト: n0g/AddResource
function efAddResourceSpecialPage($template, $links)
{
    global $wgTitle, $wgRequest, $wgUser, $wgAddResourceTab;
    // return if we are not on the right special page
    if (!$wgTitle->isSpecial('AddResource')) {
        return true;
    }
    // parse subpage-part. We cannot use $wgTitle->getSubpage() because the
    // special namespaces doesn't have real subpages
    $prefixedText = $wgTitle->getPrefixedText();
    if (strpos($prefixedText, '/') === FALSE) {
        return true;
        // no page given
    }
    $parts = explode('/', $prefixedText);
    $pageName = $parts[count($parts) - 1];
    $title = Title::newFromText($pageName)->getSubjectPage();
    $talkTitle = $title->getTalkPage();
    // Get AddResource URL:
    $resourceCount = getResourceCount($title);
    $resourcesUrl = getResourcesUrl($title);
    $resourcesText = getResourceTabText($resourceCount);
    $resourcesClass = $resourceCount > 0 ? 'is_resources' : 'new is_resources';
    $head = array($title->getNamespaceKey('') => array('class' => $title->exists() ? null : 'new', 'text' => $title->getText(), 'href' => $title->getLocalUrl()), 'resources' => array('class' => $resourcesClass, 'text' => $resourcesText, 'href' => $resourcesUrl));
    $tail = array($title->getNamespaceKey('') . '_talk' => array('class' => $talkTitle->exists() ? null : 'new', 'text' => wfMessage('Talk')->text(), 'href' => $talkTitle->getLocalUrl()));
    $resourceCount = getResourceCount($title);
    $links['namespaces'] = array_merge($head, $links['namespaces'], $tail);
    $links['namespaces']['special']['text'] = '+';
    return true;
}
コード例 #8
0
 protected function getTypeProperties($typeLabel)
 {
     global $wgRequest, $smwgTypePagingLimit;
     if ($smwgTypePagingLimit <= 0) {
         return '';
     }
     // not too useful, but we comply to this request
     $from = $wgRequest->getVal('from');
     $until = $wgRequest->getVal('until');
     $typeValue = SMWDataValueFactory::newTypeIDValue('__typ', $typeLabel);
     if (!$typeValue->isValid()) {
         return $this->msg('smw-special-types-no-such-type')->escaped();
     }
     $store = smwfGetStore();
     $options = SMWPageLister::getRequestOptions($smwgTypePagingLimit, $from, $until);
     $diWikiPages = $store->getPropertySubjects(new SMWDIProperty('_TYPE'), $typeValue->getDataItem(), $options);
     if (!$options->ascending) {
         $diWikiPages = array_reverse($diWikiPages);
     }
     $result = '';
     if (count($diWikiPages) > 0) {
         $pageLister = new SMWPageLister($diWikiPages, null, $smwgTypePagingLimit, $from, $until);
         $title = $this->getTitleFor('Types', $typeLabel);
         $title->setFragment('#SMWResults');
         // Make navigation point to the result list.
         $navigation = $pageLister->getNavigationLinks($title);
         $resultNumber = min($smwgTypePagingLimit, count($diWikiPages));
         $typeName = $typeValue->getLongWikiText();
         $result .= "<a name=\"SMWResults\"></a><div id=\"mw-pages\">\n" . '<h2>' . wfMessage('smw_type_header', $typeName)->text() . "</h2>\n<p>" . wfMsgExt('smw_typearticlecount', array('parsemag'), $resultNumber) . "</p>\n" . $navigation . $pageLister->formatList() . $navigation . "\n</div>";
     }
     return $result;
 }
コード例 #9
0
 public function logFeedback($params, $itemId)
 {
     $title = SpecialPage::getTitleFor('FeedbackDashboard', $itemId);
     $reason = wfMessage('moodbar-log-reason')->params($params['type'], $params['comment'])->text();
     $log = new LogPage('moodbar');
     $log->addEntry('feedback', $title, $reason);
 }
 /**
  * Render message box with system messages, e.g. errors or already logged-in notices
  *
  * @param string $action The type of action the page is used for ('login' or 'signup')
  * @param bool $register Whether the user can register an account
  */
 protected function renderMessageHtml($action, $register = false)
 {
     $msgBox = '';
     // placeholder for displaying any login-related system messages (eg errors)
     $message = $this->data['message'];
     $messageType = $this->data['messagetype'];
     // FIXME: Migrate this to a server-side Mustache template
     // If there is a system message (error, warning, or success) display that
     if ($message && $messageType) {
         $msgBox .= Html::openElement('div', array('class' => $messageType . 'box'));
         $msgBox .= $message;
         $msgBox .= Html::closeElement('div');
         // Render already logged-in notice
     } elseif ($this->data['loggedin']) {
         $msg = $register ? 'mobile-frontend-userlogin-loggedin-register' : 'userlogin-loggedin';
         $msgBox .= Html::openElement('div', array('class' => 'warningbox'));
         $msgBox .= wfMessage($msg)->params($this->data['loggedinuser'])->parse();
         $msgBox .= Html::closeElement('div');
         // Show default welcome message
     } else {
         // The warningbox class is used more for informational purposes than actual warnings.
         $msgBox .= Html::openElement('div', array('class' => 'warningbox'));
         $headerMsg = wfMessage('mobile-frontend-generic-login')->parse();
         $msgBox .= Html::element('strong', array(), $headerMsg);
         $msgBox .= Html::element('br');
         $msgBox .= wfMessage("mobile-frontend-generic-{$action}-action")->plain();
         $msgBox .= Html::closeElement('div');
         $msgBox .= $this->getLogoHtml();
     }
     echo $msgBox;
 }
コード例 #11
0
ファイル: SRF_Boilerplate.php プロジェクト: Tjorriemorrie/app
 /**
  * @see SMWResultPrinter::getResultText
  *
  * @param SMWQueryResult $result
  * @param $outputMode
  *
  * @return string
  */
 protected function getResultText(SMWQueryResult $result, $outputMode)
 {
     // Data processing
     // It is advisable to separate data processing from output logic
     $data = $this->getResultData($result, $outputMode);
     // Check if the data processing returned any results otherwise just bailout
     if ($data === array()) {
         // Add an error message to return method
         return $result->addErrors(array(wfMessage('srf-no-results')->inContentLanguage()->text()));
     } else {
         // Add options if needed to format the output
         // $outputMode can be specified as
         // SMW_OUTPUT_HTML
         // SMW_OUTPUT_FILE
         // SMW_OUTPUT_WIKI
         // For implementing template support this options has to be set but if you
         // manipulate data via jQuery/JavaScript it is less likely that you need
         // this option since templates will influence how wiki text is parsed
         // but will have no influence in how a HTML representation is altered
         // $this->hasTemplates = true;
         $options = array('mode' => $outputMode);
         // Return formatted results
         return $this->getFormatOutput($data, $options);
     }
 }
コード例 #12
0
 public function requireLoginAnonProvider()
 {
     $lang = 'en';
     $expected1 = wfMessage('exception-nologin-text')->inLanguage($lang)->text();
     $expected2 = wfMessage('about')->inLanguage($lang)->text();
     return array(array($expected1, null, null), array($expected2, 'about', null), array($expected2, 'about', 'about'));
 }
コード例 #13
0
ファイル: PS_GeneratePages.php プロジェクト: whysasse/kmwiki
    function execute($category)
    {
        global $wgUser, $wgRequest, $wgOut, $wgPageSchemasHandlerClasses;
        if (!$wgUser->isAllowed('generatepages')) {
            $wgOut->permissionRequired('generatepages');
            return;
        }
        $this->setHeaders();
        $param = $wgRequest->getText('param');
        if (!empty($param) && !empty($category)) {
            // Generate the pages!
            $this->generatePages($param, $wgRequest->getArray('page'));
            $text = Html::element('p', null, wfMessage('ps-generatepages-success')->parse());
            $wgOut->addHTML($text);
            return true;
        }
        if ($category == "") {
            // No category listed.
            // TODO - show an error message.
            return true;
        }
        // Standard "generate pages" form, with category name set.
        // Check for a valid category, with a page schema defined.
        $pageSchemaObj = new PSSchema($category);
        if (!$pageSchemaObj->isPSDefined()) {
            $text = Html::element('p', null, wfMessage('ps-generatepages-noschema')->parse());
            $wgOut->addHTML($text);
            return true;
        }
        $text = Html::element('p', null, wfMessage('ps-generatepages-desc')->parse()) . "\n";
        $text .= '<form method="post">';
        $text .= Html::input('param', $category, 'hidden') . "\n";
        $text .= '<div id="ps_check_all_check_none">
		<input type="button" id="ps_check_all" value="' . wfMessage('powersearch-toggleall')->parse() . '" />
		<input type="button" id="ps_check_none" value="' . wfMessage('powersearch-togglenone')->parse() . '" />
		</div><br/>';
        $wgOut->addModules('ext.pageschemas.generatepages');
        // This hook will set an array of strings, with each value
        // as a title of a page to be created.
        $pageList = array();
        foreach ($wgPageSchemasHandlerClasses as $psHandlerClass) {
            $pagesFromHandler = call_user_func(array($psHandlerClass, "getPagesToGenerate"), $pageSchemaObj);
            foreach ($pagesFromHandler as $page) {
                $pageList[] = $page;
            }
        }
        foreach ($pageList as $page) {
            if (!$page instanceof Title) {
                continue;
            }
            $pageName = PageSchemas::titleString($page);
            $text .= Html::input('page[]', $pageName, 'checkbox', array('checked' => true));
            $text .= "\n" . Linker::link($page) . "<br />\n";
        }
        $text .= "<br />\n";
        $text .= Html::input(null, wfMessage('generatepages')->parse(), 'submit');
        $text .= "\n</form>";
        $wgOut->addHTML($text);
        return true;
    }
コード例 #14
0
 /**
  * Prepare data output
  *
  * @since 1.8
  *
  * @param array $data label => value
  */
 protected function getFormatOutput(array $data)
 {
     static $statNr = 0;
     $chartID = 'jqplot-' . $this->params['charttype'] . '-' . ++$statNr;
     $this->isHTML = true;
     // Prepare data objects
     if (in_array($this->params['charttype'], array('bar', 'line'))) {
         // Parse bar relevant data
         $dataObject = $this->prepareBarData($data);
     } elseif (in_array($this->params['charttype'], array('pie', 'donut'))) {
         //Parse pie/donut relevant data
         $dataObject = $this->preparePieData($data);
     } else {
         // Return with an error
         return Html::rawElement('span', array('class' => "error"), wfMessage('srf-error-missing-layout')->inContentLanguage()->text());
     }
     // Encode data objects
     $requireHeadItem = array($chartID => FormatJson::encode($dataObject));
     SMWOutputs::requireHeadItem($chartID, Skin::makeVariablesScript($requireHeadItem));
     // Processing placeholder
     $processing = SRFUtils::htmlProcessingElement($this->isHTML);
     // Ensure right conversion
     $width = strstr($this->params['width'], "%") ? $this->params['width'] : $this->params['width'] . 'px';
     // Chart/graph placeholder
     $chart = Html::rawElement('div', array('id' => $chartID, 'class' => 'container', 'style' => "display:none; width: {$width}; height: {$this->params['height']}px;"), null);
     // Beautify class selector
     $class = $this->params['charttype'] ? '-' . $this->params['charttype'] : '';
     $class = $this->params['class'] ? $class . ' ' . $this->params['class'] : $class . ' jqplot-common';
     // Chart/graph wrappper
     return Html::rawElement('div', array('class' => 'srf-jqplot' . $class), $processing . $chart);
 }
 /**
  * @since 2.3
  *
  * @param string $value
  *
  * @return Description
  * @throws InvalidArgumentException
  */
 public function deserialize($value)
 {
     if (!is_string($value)) {
         throw new InvalidArgumentException('value needs to be a string');
     }
     if ($value === '') {
         $this->addError(wfMessage('smw_novalues')->text());
         return new ThingDescription();
     }
     $subdescriptions = array();
     $values = $this->dataValue->getValuesFromString($value);
     $valueIndex = 0;
     // index in value array
     $propertyIndex = 0;
     // index in property list
     foreach ($this->dataValue->getPropertyDataItems() as $diProperty) {
         // stop if there are no values left
         if (!is_array($values) || !array_key_exists($valueIndex, $values)) {
             break;
         }
         $description = $this->getDescriptionForProperty($diProperty, $values, $valueIndex, $propertyIndex);
         if ($description !== null) {
             $subdescriptions[] = $description;
         }
         ++$propertyIndex;
     }
     if ($subdescriptions === array()) {
         $this->addError(wfMessage('smw_novalues')->text());
     }
     return $this->getDescriptionFor($subdescriptions);
 }
コード例 #16
0
ファイル: SF_EnumInput.php プロジェクト: whysasse/kmwiki
 public static function getParameters()
 {
     $params = parent::getParameters();
     $params = array_merge($params, self::getValuesParameters());
     $params[] = array('name' => 'show on select', 'type' => 'string', 'description' => wfMessage('sf_forminputs_showonselect')->text());
     return $params;
 }
コード例 #17
0
 private function getList()
 {
     $data = array();
     $result = $this->getResult();
     $gadgets = Gadget::loadStructuredList();
     foreach ($gadgets as $category => $list) {
         if (!$this->neededNames || isset($this->neededNames[$category])) {
             $row = array();
             if (isset($this->props['name'])) {
                 $row['name'] = $category;
             }
             if ($category !== "") {
                 if (isset($this->props['title'])) {
                     $row['desc'] = wfMessage("gadget-section-{$category}")->parse();
                 }
             }
             if (isset($this->props['members'])) {
                 $row['members'] = count($list);
             }
             $data[] = $row;
         }
     }
     $result->setIndexedTagName($data, 'category');
     $result->addValue('query', $this->getModuleName(), $data);
 }
コード例 #18
0
 public function addNewAccountMailPassword()
 {
     $u = $this->addNewAccountInternal();
     if ($u == null) {
         return false;
     }
     // reset password
     $tempUser = TempUser::getTempUserFromName($this->mUsername);
     $tempUser->setPassword('');
     $tempUser->updateData();
     $u = $tempUser->mapTempUserToUser(false, $u);
     // add log
     $userLoginHelper = F::build('UserLoginHelper');
     $userLoginHelper->addNewUserLogEntry($u, true);
     // mail temporary password
     $emailTextTemplate = F::app()->renderView("UserLogin", "GeneralMail", array('language' => $u->getOption('language'), 'type' => 'account-creation-email'));
     $result = $this->mailPasswordInternal($u, false, 'usersignup-account-creation-email-subject', 'usersignup-account-creation-email-body', $emailTextTemplate);
     if (!$result->isGood()) {
         $this->mainLoginForm(wfMessage('userlogin-error-mail-error', $result->getMessage())->parse());
         return false;
     } else {
         $this->mainLoginForm(wfMsgExt('usersignup-account-creation-email-sent', array('parseinline'), $this->mEmail, $this->username), 'success');
         return $u;
     }
 }
コード例 #19
0
 function __construct($params)
 {
     $params += array('require-match' => false);
     parent::__construct($params);
     if (array_key_exists('autocomplete-messages', $this->mParams)) {
         foreach ($this->mParams['autocomplete-messages'] as $key => $value) {
             $key = $this->msg($key)->plain();
             $this->autocomplete[$key] = strval($value);
         }
     } elseif (array_key_exists('autocomplete', $this->mParams)) {
         foreach ($this->mParams['autocomplete'] as $key => $value) {
             $this->autocomplete[$key] = strval($value);
         }
     }
     if (!is_array($this->autocomplete) || !$this->autocomplete) {
         throw new MWException('HTMLAutoCompleteSelectField called without any autocompletions');
     }
     $this->getOptions();
     if ($this->mOptions && !in_array('other', $this->mOptions, true)) {
         if (isset($params['other-message'])) {
             $msg = wfMessage($params['other-message'])->text();
         } elseif (isset($params['other'])) {
             $msg = $params['other'];
         } else {
             $msg = wfMessage('htmlform-selectorother-other')->text();
         }
         $this->mOptions[$msg] = 'other';
     }
 }
コード例 #20
0
 public function testNonParseForInvokedMessageParse()
 {
     $parserData = $this->getMockBuilder('\\SMW\\ParserData')->disableOriginalConstructor()->getMock();
     $parserData->expects($this->never())->method('getSemanticData');
     $this->applicationFactory->registerObject('ParserData', $parserData);
     wfMessage('properties')->parse();
 }
コード例 #21
0
ファイル: Logger.php プロジェクト: hexmode/DynamicPageList
 /**
  * Get a message, with optional parameters
  * Parameters from user input must be escaped for HTML *before* passing to this function
  *
  * @access	public
  * @param	integer	Message ID
  * @return	string
  */
 public function msg()
 {
     $args = func_get_args();
     $errorId = array_shift($args);
     $errorLevel = floor($errorId / 1000);
     $errorMessageId = $errorId % 1000;
     if (\DynamicPageListHooks::getDebugLevel() >= $errorLevel) {
         if (\DynamicPageListHooks::isLikeIntersection()) {
             if ($errorId == \DynamicPageListHooks::FATAL_TOOMANYCATS) {
                 $text = wfMessage('intersection_toomanycats', $args)->text();
             } elseif ($errorId == \DynamicPageListHooks::FATAL_TOOFEWCATS) {
                 $text = wfMessage('intersection_toofewcats', $args)->text();
             } elseif ($errorId == \DynamicPageListHooks::WARN_NORESULTS) {
                 $text = wfMessage('intersection_noresults', $args)->text();
             } elseif ($errorId == \DynamicPageListHooks::FATAL_NOSELECTION) {
                 $text = wfMessage('intersection_noincludecats', $args)->text();
             }
         }
         if (empty($text)) {
             $text = wfMessage('dpl_log_' . $errorMessageId, $args)->text();
         }
         $this->buffer[] = '<p>Extension:DynamicPageList (DPL), version ' . DPL_VERSION . ': ' . $text . '</p>';
     }
     return false;
 }
 public function get_controller($_INPUT)
 {
     $return = array();
     if (isset($_INPUT['request'])) {
         if ($this->get_request() == $_INPUT['request']) {
             if ($this->set_annuity($_INPUT)) {
                 if (empty($_INPUT['value'])) {
                     $return['formulae'] = $this->get_solution();
                     return $return;
                 } else {
                     $return['formulae'] = $this->get_interest_rate();
                     return $return;
                 }
             } else {
                 $return['warning'] = wfMessage('fm-exception-setting-annuity')->text();
                 return $return;
             }
         }
     } else {
         $render = new CT1_Render();
         $return['form'] = $render->get_render_form($this->get_calculator(array("delta", "escalation_delta")));
         return $return;
     }
     return $return;
 }
 /**
  * @since 2.4
  *
  * @param string $value
  *
  * @return Description
  * @throws InvalidArgumentException
  */
 public function deserialize($value)
 {
     if (!is_string($value)) {
         throw new InvalidArgumentException('Value needs to be a string');
     }
     if ($value === '') {
         $this->addError(wfMessage('smw_novalues')->text());
         return new ThingDescription();
     }
     $subdescriptions = array();
     list($text, $languageCode) = $this->dataValue->getValuesFromString($value);
     foreach ($this->dataValue->getPropertyDataItems() as $property) {
         // If the DVFeature doesn't require a language code to be present then
         // allow to skip it as conjunctive condition when it is empty
         if ($languageCode === '' && $property->getKey() === '_LCODE' && !$this->dataValue->isEnabledFeature(SMW_DV_MLTV_LCODE)) {
             continue;
         }
         $value = $property->getKey() === '_LCODE' ? $languageCode : $text;
         $comparator = SMW_CMP_EQ;
         $this->prepareValue($value, $comparator);
         // Directly use the DI instead of going through the DVFactory to
         // avoid having ~zh-* being validated when building a DV
         // If one of the values is empty use, ? so queries can be arbitrary
         // in respect of the query condition
         $dataValue = DataValueFactory::getInstance()->newDataValueByItem(new DIBlob($value === '' ? '?' : $value), $property, false, $this->dataValue->getContextPage());
         if (!$dataValue->isValid()) {
             $this->addError($dataValue->getErrors());
             continue;
         }
         $subdescriptions[] = $this->newSubdescription($dataValue, $comparator);
     }
     return $this->getFinalDescriptionFor($subdescriptions);
 }
コード例 #24
0
 public function index()
 {
     $title = Title::newFromText('Version', NS_SPECIAL);
     $popts = ParserOptions::newFromContext(RequestContext::getMain());
     $this->wg->Title = $title;
     $this->specialPage->setHeaders();
     $softwareListPrepped = array();
     foreach ($this->version->getSoftwareList() as $key => $val) {
         $softwareListPrepped[$this->wg->Parser->parse($key, $title, $popts)->getText()] = $this->wg->Parser->parse($val, $title, $popts)->getText();
     }
     $this->setVal('copyRightAndAuthorList', $this->wg->Parser->parse($this->version->getCopyrightAndAuthorList(), $title, $popts)->getText());
     $this->setVal('softwareInformation', $this->wg->Parser->parse($this->version->softwareInformation(), $title, $popts)->getText());
     $this->setVal('extensionCredit', $this->wg->Parser->parse($this->version->getExtensionCredits(), $title, $popts)->getText());
     $this->setVal('ip', str_replace('--', ' - ', htmlspecialchars($this->getContext()->getRequest()->getIP())));
     $this->setVal('wikiaCodeMessage', wfMessage('wikia-version-code')->escaped());
     $this->setVal('wikiaCodeVersion', $this->version->getWikiaCodeVersion());
     $this->setVal('wikiaConfigMessage', wfMessage('wikia-version-config')->escaped());
     $this->setVal('wikiaConfigVersion', $this->version->getWikiaConfigVersion());
     $this->setVal('versionLicenseMessage', wfMessage('version-license')->escaped());
     $this->setVal('versionLicenseInfoMessage', wfMessage('version-license-info')->parse());
     $this->setVal('versionSoftwareMessage', wfMessage('version-software')->escaped());
     $this->setVal('versionSoftwareProductMessage', wfMessage('version-software-product')->escaped());
     $this->setVal('versionSoftwareVersionMessage', wfMessage('version-software-version')->escaped());
     $this->setVal('versionSoftwareList', $softwareListPrepped);
 }
コード例 #25
0
 public function execute()
 {
     # get the current user.
     $context = $this->createContext();
     $user = $context->getUser();
     $params = $this->extractRequestParams();
     $action = $params['action'];
     // check the blacklist, the same way tbhooks does it.
     //
     // Some places check createpage, while others check create.
     // As it stands, upload does createpage, but normalize both
     // to the same action, to stop future similar bugs.
     if ($action === 'createpage' || $action === 'createtalk') {
         $action = 'create';
     }
     $title = Title::newFromText($params['title']);
     if (!$title) {
         $this->dieUsageMsg(array('invalidtitle', $params['title']));
     }
     $blacklisted = TitleBlacklist::singleton()->userCannot($title, $user, $action);
     if ($blacklisted instanceof TitleBlacklistEntry) {
         // this title is blacklisted.
         $result = array(htmlspecialchars($blacklisted->getRaw()), htmlspecialchars($params['title']));
         $res = $this->getResult();
         $res->addValue('titleblacklist', 'result', 'blacklisted');
         // this is hardcoded to 'edit' in Titleblacklist.hooks.php, duplicating that.
         $message = $blacklisted->getErrorMessage('edit');
         $res->addValue('titleblacklist', 'reason', wfMessage($message, $result)->text());
         $res->addValue('titleblacklist', 'message', $message);
         $res->addValue('titleblacklist', 'line', htmlspecialchars($blacklisted->getRaw()));
     } else {
         // not blacklisted
         $this->getResult()->addValue('titleblacklist', 'result', 'ok');
     }
 }
コード例 #26
0
 function execute($par)
 {
     /**
      * Some satellite ISPs use broken precaching schemes that log people out straight after
      * they're logged in (bug 17790). Luckily, there's a way to detect such requests.
      */
     if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '&amp;') !== false) {
         wfDebug("Special:Userlogout request {$_SERVER['REQUEST_URI']} looks suspicious, denying.\n");
         throw new HttpError(400, wfMessage('suspicious-userlogout'), wfMessage('loginerror'));
     }
     $this->setHeaders();
     $this->outputHeader();
     $user = $this->getUser();
     $oldName = $user->getName();
     $user->logout();
     $out = $this->getOutput();
     $out->addWikiMsg('logouttext');
     // Hook.
     $injected_html = '';
     wfRunHooks('UserLogoutComplete', array(&$user, &$injected_html, $oldName));
     $out->addHTML($injected_html);
     $mReturnTo = $this->getRequest()->getVal('returnto');
     $mReturnToQuery = $this->getRequest()->getVal('returntoquery');
     $title = Title::newFromText($mReturnTo);
     if (!empty($title)) {
         $mResolvedReturnTo = strtolower(array_shift(SpecialPageFactory::resolveAlias($title->getDBKey())));
         if (in_array($mResolvedReturnTo, array('userlogout', 'signup', 'connect'))) {
             $titleObj = Title::newMainPage();
             $mReturnTo = $titleObj->getText();
             $mReturnToQuery = '';
         }
     }
     $out->returnToMain(false, $mReturnTo, $mReturnToQuery);
 }
コード例 #27
0
ファイル: ReCaptcha.php プロジェクト: Tjorriemorrie/app
/**
 * Make sure the keys are defined.
 *
 * @throws Exception
 */
function efReCaptcha()
{
    $wg = F::app()->wg;
    if ($wg->ReCaptchaPublicKey == '' || $wg->ReCaptchaPrivateKey == '') {
        throw new Exception(wfMessage('recaptcha-misconfigured')->escaped());
    }
}
コード例 #28
0
 public function execute()
 {
     $params = $this->extractRequestParams();
     $action = $params['action'];
     $override = true;
     if (isset($params['nooverride'])) {
         $override = false;
     }
     // createtalk and createpage are useless as they're treated exactly like create
     if ($action === 'createpage' || $action === 'createtalk') {
         $action = 'create';
     }
     $title = Title::newFromText($params['title']);
     if (!$title) {
         $this->dieUsageMsg(array('invalidtitle', $params['title']));
     }
     $blacklisted = TitleBlacklist::singleton()->userCannot($title, $this->getUser(), $action, $override);
     if ($blacklisted instanceof TitleBlacklistEntry) {
         // this title is blacklisted.
         $result = array(htmlspecialchars($blacklisted->getRaw()), htmlspecialchars($params['title']));
         $res = $this->getResult();
         $res->addValue('titleblacklist', 'result', 'blacklisted');
         // there aren't any messages for create(talk|page), using edit for those instead
         $message = $blacklisted->getErrorMessage($action !== 'create' ? $action : 'edit');
         $res->addValue('titleblacklist', 'reason', wfMessage($message, $result)->text());
         $res->addValue('titleblacklist', 'message', $message);
         $res->addValue('titleblacklist', 'line', htmlspecialchars($blacklisted->getRaw()));
     } else {
         // not blacklisted
         $this->getResult()->addValue('titleblacklist', 'result', 'ok');
     }
 }
コード例 #29
0
ファイル: Line.php プロジェクト: MapsMD/mediawikiMaps
 /**
  * Filling property 'coordinates'
  * @global string $egMultiMaps_CoordinatesSeparator
  * @param string $coordinates
  * @param string $service Name of map service
  * @return boolean
  */
 protected function parseCoordinates($coordinates, $service = null)
 {
     global $egMultiMaps_CoordinatesSeparator;
     $array = explode($egMultiMaps_CoordinatesSeparator, $coordinates);
     if ($service == 'leaflet' && count($array) == 1) {
         $value = $array[0];
         $coord = Geocoders::getCoordinates($value, $service, array('polygon' => true));
         if ($coord !== false && is_array($coord['polygon'])) {
             $this->coordinates = $coord['polygon'];
         } else {
             $this->errormessages[] = \wfMessage('multimaps-unable-parse-coordinates', $value)->escaped();
             return false;
         }
     } else {
         foreach ($array as $value) {
             $point = new Point();
             if ($point->parse($value, $service)) {
                 $this->coordinates[] = $point;
             } else {
                 $this->errormessages[] = \wfMessage('multimaps-unable-parse-coordinates', $value)->escaped();
                 return false;
             }
         }
     }
     return true;
 }
    public static function getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args)
    {
        global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect;
        $className = $is_mandatory ? 'mandatoryField' : 'createboxInput';
        if (array_key_exists('class', $other_args)) {
            $className .= ' ' . $other_args['class'];
        }
        $input_id = "input_{$sfgFieldNum}";
        $disabled_text = $is_disabled ? 'disabled' : '';
        if (array_key_exists('show on select', $other_args)) {
            $className .= ' sfShowIfCheckedCheckbox';
            $div_id = key($other_args['show on select']);
            $sfgShowOnSelect[$input_id] = $div_id;
        }
        // Can show up here either as an array or a string, depending on
        // whether it came from user input or a wiki page
        if (is_array($cur_value)) {
            $checked_str = array_key_exists('value', $cur_value) && $cur_value['value'] == 'on' ? ' checked="checked"' : '';
        } else {
            // Default to false - no need to check if it matches
            // a 'false' word.
            $vlc = strtolower(trim($cur_value));
            if (in_array($vlc, explode(',', wfMessage('smw_true_words')->inContentLanguage()->text()), true)) {
                $checked_str = ' checked="checked"';
            } else {
                $checked_str = '';
            }
        }
        $text = <<<END
\t<input name="{$input_name}[is_checkbox]" type="hidden" value="true" />
\t<input id="{$input_id}" name="{$input_name}[value]" type="checkbox" class="{$className}" tabindex="{$sfgTabIndex}" {$checked_str} {$disabled_text}/>

END;
        return $text;
    }