Example #1
0
 /**
  * Return absolute URL to a page to be shared (uses wgTitle)
  * The path component of the URL is urlencoded to prevent confusion between sharing services
  * @return string URL to be shared
  */
 protected function getURL()
 {
     $path = $this->title->getLocalUrl();
     $paths = explode('/', $path);
     foreach ($paths as $index => $section) {
         $paths[$index] = urlencode($section);
     }
     return str_replace($path, implode('/', $paths), $this->title->getFullUrl());
 }
 /**
  * Render the special page
  * @param string $par parameter as subpage of specialpage
  */
 public function executeWhenAvailable($par = '')
 {
     $out = $this->getOutput();
     $out->setPageTitle($this->msg('history'));
     $out->addModuleStyles(array('mobile.pagelist.styles', 'mobile.pagesummary.styles'));
     $this->offset = $this->getRequest()->getVal('offset', false);
     if ($par) {
         // enter article history view
         $this->title = Title::newFromText($par);
         if ($this->title && $this->title->exists()) {
             // make sure, the content of the page supports the default history page
             if (!self::shouldUseSpecialHistory($this->title)) {
                 // and if not, redirect to the default history action
                 $out->redirect($this->title->getLocalUrl(array('action' => 'history')));
                 return;
             }
             $this->addModules();
             $this->getOutput()->addHtml(Html::openElement('div', array('class' => 'history content-unstyled')));
             $this->renderHeaderBar($this->title);
             $res = $this->doQuery();
             $this->showHistory($res);
             $this->getOutput()->addHtml(Html::closeElement('div'));
             return;
         }
     }
     $this->showPageNotFound();
 }
 /**
  * Prepare the form action
  *
  * @return string
  */
 private function getAction()
 {
     $q = array();
     $q['action'] = 'delete';
     if ($this->oldimage) {
         $q['oldimage'] = $this->oldimage;
     }
     return $this->title->getLocalUrl($q);
 }
 /**
  * Render the page with a list of languages the page is available in
  * @param string $pagename The name of the page
  */
 public function executeWhenAvailable($pagename)
 {
     if (!is_string($pagename) || $pagename === '') {
         wfHttpError(404, $this->msg('mobile-frontend-languages-404-title')->text(), $this->msg('mobile-frontend-languages-404-desc')->text());
         return;
     }
     $this->title = Title::newFromText($pagename);
     $output = $this->getOutput();
     $html = '';
     if ($this->title && $this->title->exists()) {
         $titlename = $this->title->getPrefixedText();
         $pageTitle = $this->msg('mobile-frontend-languages-header-page', $titlename)->text();
         $languages = $this->getLanguages();
         $variants = $this->getLanguageVariants();
         $languagesCount = count($languages);
         $variantsCount = count($variants);
         $html .= Html::element('p', array(), $this->msg('mobile-frontend-languages-text')->params($titlename)->numParams($languagesCount)->text());
         $html .= Html::openElement('p');
         $html .= Html::element('a', array('href' => $this->title->getLocalUrl()), $this->msg('returnto', $titlename)->text());
         $html .= Html::closeElement('p');
         if ($languagesCount > 0 || $variantsCount > 1) {
             // Language variants first
             if ($variantsCount > 1) {
                 $variantHeader = $variantsCount > 1 ? $this->msg('mobile-frontend-languages-variant-header')->text() : '';
                 $html .= Html::element('h2', array('id' => 'mw-mf-language-variant-header'), $variantHeader);
                 $html .= Html::openElement('ul', array('id' => 'mw-mf-language-variant-selection'));
                 foreach ($variants as $val) {
                     $html .= $this->makeLangListItem($val);
                 }
                 $html .= Html::closeElement('ul');
             }
             // Then other languages
             if ($languagesCount > 0) {
                 $languageHeader = $this->msg('mobile-frontend-languages-header')->text();
                 $html .= Html::element('h2', array('id' => 'mw-mf-language-header'), $languageHeader) . Html::openElement('ul', array('id' => 'mw-mf-language-selection'));
                 foreach ($languages as $val) {
                     $html .= $this->makeLangListItem($val);
                 }
                 $html .= Html::closeElement('ul');
             }
         }
     } else {
         $pageTitle = $this->msg('mobile-frontend-languages-header')->text();
         $html .= Html::element('p', array(), $this->msg('mobile-frontend-languages-nonexistent-title')->params($pagename)->text());
     }
     $html = MobileUI::contentElement($html);
     $output->setPageTitle($pageTitle);
     $output->addHTML($html);
 }
 /**
  * Gets the HTML fragment for a watched page.
  *
  * @param Title $title The title of the watched page
  * @param int $ts When the page was last touched
  * @param string $thumb An HTML fragment for the page's thumbnaiL
  * @return string
  */
 public static function getLineHtml(Title $title, $ts, $thumb)
 {
     $titleText = $title->getPrefixedText();
     if ($ts) {
         $ts = new MWTimestamp($ts);
         $lastModified = wfMessage('mobile-frontend-watchlist-modified', $ts->getHumanTimestamp())->text();
         $className = 'title';
     } else {
         $className = 'title new';
         $lastModified = '';
     }
     $html = Html::openElement('li', array('class' => 'page-summary', 'title' => $titleText, 'data-id' => $title->getArticleId())) . Html::openElement('a', array('href' => $title->getLocalUrl(), 'class' => $className));
     $html .= $thumb;
     $html .= Html::element('h3', array(), $titleText) . Html::element('div', array('class' => 'info'), $lastModified) . Html::closeElement('a') . Html::closeElement('li');
     return $html;
 }
 private function getTargetURL(Title $title)
 {
     global $wgCreatePageEditExisting, $wgCreatePageUseVisualEditor;
     $isKnown = $title->isKnown();
     $query = array();
     if (!$isKnown || $wgCreatePageEditExisting) {
         # Preload is not yet supported by VisualEditor, but probably will be eventually.
         # See https://phabricator.wikimedia.org/T51622
         $query['preload'] = $this->getRequest()->getText('preload', '');
         if (!$isKnown) {
             $query['redlink'] = '1';
         }
         if ($wgCreatePageUseVisualEditor) {
             $query['veaction'] = 'edit';
         } else {
             $query['action'] = 'edit';
         }
     }
     return $title->getLocalUrl($query);
 }
 /**
  * Modify edit section link markup (for Oasis only)
  */
 public static function onDoEditSectionLink($skin, Title $title, $section, $tooltip, &$result, $lang = false)
 {
     global $wgBlankImgUrl, $wgUser;
     wfProfileIn(__METHOD__);
     // modify Oasis only (BugId:8444)
     if (!$skin instanceof SkinOasis) {
         wfProfileOut(__METHOD__);
         return true;
     }
     $result = '';
     // reset result first
     $editUrl = $title->getLocalUrl(array('action' => 'edit', 'section' => $section));
     $class = 'editsection';
     $result .= Xml::openElement('span', array('class' => $class));
     $result .= Xml::openElement('a', array('href' => $editUrl, 'title' => wfMsg('oasis-section-edit-alt', $tooltip)));
     $result .= Xml::element('img', array('src' => $wgBlankImgUrl, 'class' => 'sprite edit-pencil'));
     $result .= wfMsg('oasis-section-edit');
     $result .= Xml::closeElement('a');
     $result .= Xml::closeElement('span');
     wfProfileOut(__METHOD__);
     return true;
 }
	/**
	 * Modify edit section link markup (for Oasis only)
	 */
	public static function onDoEditSectionLink( $skin, Title $title, $section, $tooltip, &$result, $lang = false ) {
		global $wgBlankImgUrl, $wgUser;
		wfProfileIn(__METHOD__);

		// modify Oasis only (BugId:8444)
		if (!$skin instanceof SkinOasis) {
			wfProfileOut(__METHOD__);
			return true;
		}

		$result = ''; // reset result first

		$editUrl = $title->getLocalUrl( array( 'action' => 'edit', 'section' => $section ) );

		$class = 'editsection';

		// RT#84733 - prompt to login if the user is an anon and can't edit right now (protected pages and wgDisableAnonEditing wikis).
		if ( !$title->userCan('edit') && $wgUser->isAnon() ) {
			$class .= " loginToEditProtectedPage";
		}

		$result .= Xml::openElement( 'span', array( 'class' => $class ) );
		$result .= Xml::openElement( 'a', array(
			'href' => $editUrl,
			'title' => wfMsg( 'oasis-section-edit-alt', $tooltip ),
		));
		$result .= Xml::element( 'img',	array(
			'src' => $wgBlankImgUrl,
			'class' => 'sprite edit-pencil',
		));
		$result .= wfMsg( 'oasis-section-edit' );
		$result .= Xml::closeElement( 'a' );
		$result .= Xml::closeElement( 'span' );

		wfProfileOut(__METHOD__);
		return true;
	}
 /**
  * Return a url to a resource or to a login screen that redirects to that resource.
  * @param Title $title
  * @param array $query representation of query string parameters
  * @return string url
  */
 protected function getPersonalUrl(Title $title, array $query = array())
 {
     if ($this->getUser()->isLoggedIn()) {
         return $title->getLocalUrl($query);
     } else {
         return $this->getLoginUrl(array('returnto' => $title));
     }
 }
    /**
     * Prepares links used in the mobile footer
     * @param Skin $sk
     * @param QuickTemplate $tpl
     * @param MobileContext $ctx
     * @param Title $title
     * @param WebRequest $req
     * @return QuickTemplate
     */
    protected static function mobileFooter($sk, $tpl, $ctx, $title, $req)
    {
        $url = $sk->getOutput()->getProperty('desktopUrl');
        if ($url) {
            $url = wfAppendQuery($url, 'mobileaction=toggle_view_desktop');
        } else {
            $url = $title->getLocalUrl($req->appendQueryValue('mobileaction', 'toggle_view_desktop', true));
        }
        $url = htmlspecialchars($ctx->getDesktopUrl(wfExpandUrl($url, PROTO_RELATIVE)));
        $desktop = wfMessage('mobile-frontend-view-desktop')->escaped();
        $mobile = wfMessage('mobile-frontend-view-mobile')->escaped();
        $sitename = self::getSitename(true);
        $switcherHtml = <<<HTML
<h2>{$sitename}</h2>
<ul>
\t<li>{$mobile}</li><li><a id="mw-mf-display-toggle" href="{$url}">{$desktop}</a></li>
</ul>
HTML;
        // Generate the licensing text displayed in the footer of each page.
        // See Skin::getCopyright for desktop equivalent.
        $license = self::getLicense('footer');
        if (isset($license['link']) && $license['link']) {
            $licenseText = $sk->msg($license['msg'])->rawParams($license['link'])->text();
        } else {
            $licenseText = '';
        }
        // Enable extensions to add links to footer in Mobile view, too - bug 66350
        Hooks::run('MobileSiteOutputPageBeforeExec', array(&$sk, &$tpl));
        // FIXME: Deprecate this hook.
        Hooks::run('SkinMinervaOutputPageBeforeExec', array(&$sk, &$tpl), '1.26');
        $tpl->set('mobile-switcher', $switcherHtml);
        $tpl->set('mobile-license', $licenseText);
        $tpl->set('privacy', $sk->footerLink('mobile-frontend-privacy-link-text', 'privacypage'));
        $tpl->set('terms-use', self::getTermsLink($sk));
        $tpl->set('footerlinks', array('info' => array('mobile-switcher', 'mobile-license'), 'places' => array('terms-use', 'privacy')));
        return $tpl;
    }
 /**
  * Gets HTML to place in the header bar. Title should always refer to a logged in user
  * @param Title $title The page to link to
  * @return string HTML representing the link in the header bar
  */
 protected function getHeaderBarLink($title)
 {
     return Html::element('a', array('class' => MobileUI::iconClass('user', 'before', 'mw-mf-user'), 'href' => $title->getLocalUrl()), $title->getText());
 }
 /**
  * Gets HTML to place in the header bar
  * @param Title $title The page to link to
  * @return string HTML representing the link in the header bar
  */
 protected function getHeaderBarLink($title)
 {
     return Html::element('a', array('href' => $title->getLocalUrl()), $title->getText());
 }
 /**
  * getForm
  *
  * Does nothing.  We don't need that.  Created just for the sake of compatibility.
  *
  * @access public
  * @param Title $title
  * @param $data array default null - unserialized arguments for task
  * @return boolean false
  */
 public function getForm($title, $data = null)
 {
     return '<form id="task-form" action="' . $title->getLocalUrl('action=save') . '" method="post">' . '<input type="hidden" name="wpType" value="' . $this->mType . '" /><fieldset>' . '<legend>Add Rebuild Localisation Cache task</legend>' . "<p>You are about to add a Rebuild Localisation Cache task to the TaskManager's queue. The task will be marked as successfully done immediately after form submission. It only means it has been successfully <em>queued</em> not performed. The localisation cache rebuild is performed on multiple servers independently. Each of the servers will report to the task log, once the process has been completed on that particular server. The notification will go to the log which corresponds to the <em>most recent</em> task of type rebuild_localisation_cache.</p>" . '<div style="text-align: center;">' . '<input type="submit" name="wpSubmit" value="Add task to queue" />' . '</div></fieldset></form>';
 }
Example #14
0
 /**
  * Hook
  *
  * @param $catView
  * @param Title $title
  * @param $row
  * @param $sortkey
  *
  * @return bool
  * @internal param $CategoryViewer
  */
 public static function addCategoryPage(&$catView, &$title, &$row, $sortkey)
 {
     if (in_array($row->page_namespace, array(NS_BLOG_ARTICLE, NS_BLOG_LISTING))) {
         /**
          * initialize CategoryView->blogs array
          */
         if (!isset($catView->blogs)) {
             $catView->blogs = array();
         }
         if (F::app()->checkSkin('wikiamobile')) {
             $catView->blogs[] = ['name' => $title->getText(), 'url' => $title->getLocalUrl()];
             return false;
         }
         /**
          * initialize CategoryView->blogs_start_char array
          */
         if (!isset($catView->blogs_start_char)) {
             $catView->blogs_start_char = array();
         }
         // remove user blog:foo from displayed titles (requested by Angie)
         // "User blog:Homersimpson89/Best Simpsons episode..." -> "Best Simpsons episode..."
         $text = $title->getSubpageText();
         $userName = $title->getBaseText();
         $link = $catView->getSkin()->link($title, $userName . " - " . $text);
         $catView->blogs[] = $row->page_is_redirect ? '<span class="redirect-in-category">' . $link . '</span>' : $link;
         // The blog entries should be sorted on the category page
         // just like other pages
         $catView->blogs_start_char[] = $catView->collation->getFirstLetter($sortkey);
         /**
          * when we return false it won't be displayed as normal category but
          * in "other" categories
          */
         return false;
     }
     return true;
 }
 /**
  * Builds an array with tab definition
  *
  * @param Title $title page where the tab links to
  * @param string|array $message message key or an array of message keys (will fall back)
  * @param boolean $selected display the tab as selected
  * @param string $query query string attached to tab URL
  * @param boolean $checkEdit check if $title exists and mark with .new if one doesn't
  *
  * @return array
  */
 function tabAction($title, $message, $selected, $query = '', $checkEdit = false)
 {
     $classes = array();
     if ($selected) {
         $classes[] = 'selected';
     }
     if ($checkEdit && !$title->isKnown()) {
         $classes[] = 'new';
         if ($query !== '') {
             $query = 'action=edit&redlink=1&' . $query;
         } else {
             $query = 'action=edit&redlink=1';
         }
     }
     // wfMessageFallback will nicely accept $message as an array of fallbacks
     // or just a single key
     $msg = wfMessageFallback($message)->setContext($this->getContext());
     if (is_array($message)) {
         // for hook compatibility just keep the last message name
         $message = end($message);
     }
     if ($msg->exists()) {
         $text = $msg->text();
     } else {
         global $wgContLang;
         $text = $wgContLang->getFormattedNsText(MWNamespace::getSubject($title->getNamespace()));
     }
     $result = array();
     if (!wfRunHooks('SkinTemplateTabAction', array(&$this, $title, $message, $selected, $checkEdit, &$classes, &$query, &$text, &$result))) {
         return $result;
     }
     return array('class' => implode(' ', $classes), 'text' => $text, 'href' => $title->getLocalUrl($query), 'primary' => true);
 }
 protected static function getDiffLink(Title $title, $current_rev_id, $approved_rev_id)
 {
     $href = $title->getLocalUrl(array('diff' => $current_rev_id, 'oldid' => $approved_rev_id));
     $diffLink = Xml::element('a', array('href' => $href), wfMessage('approvedrevs-special-difflink'));
     return $diffLink;
 }
 function __construct(Title $title)
 {
     $this->name = $title->getText();
     $this->url = $title->getLocalUrl();
     $this->type = $title->getNamespace() == NS_CATEGORY ? self::TYPE_SUBCATEGORY : self::TYPE_ARTICLE;
 }
 /**
  * Return a url to a resource or to a login screen that redirects to that resource.
  * @param Title $title
  * @param string $warning Key of message to display on login page (optional)
  * @param array $query representation of query string parameters (optional)
  * @return string url
  */
 protected function getPersonalUrl(Title $title, $warning, array $query = array())
 {
     if ($this->getUser()->isLoggedIn()) {
         return $title->getLocalUrl($query);
     } else {
         $loginQueryParams['returnto'] = $title;
         if ($query) {
             $loginQueryParams['returntoquery'] = wfArrayToCgi($query);
         }
         if ($warning) {
             $loginQueryParams['warning'] = $warning;
         }
         return $this->getLoginUrl($loginQueryParams);
     }
 }
 /**
  * Display the tabs for a course or institution.
  *
  * @since 0.1
  *
  * @param SkinTemplate $sktemplate
  * @param array $links
  * @param Title $title
  */
 protected static function displayTabs(SkinTemplate &$sktemplate, array &$links, Title $title)
 {
     $classes = array(EP_NS_INSTITUTION => 'EPOrg', EP_NS_COURSE => 'EPCourse');
     $exists = null;
     if (array_key_exists($title->getNamespace(), $classes)) {
         $links['views'] = array();
         $links['actions'] = array();
         $user = $sktemplate->getUser();
         $class = $classes[$title->getNamespace()];
         $exists = $class::hasIdentifier($title->getText());
         $type = $sktemplate->getRequest()->getText('action');
         $isSpecial = $sktemplate->getTitle()->isSpecialPage();
         if ($exists) {
             $links['views']['view'] = array('class' => !$isSpecial && $type === '' ? 'selected' : false, 'text' => wfMsg('ep-tab-view'), 'href' => $title->getLocalUrl());
         }
         if ($user->isAllowed($class::getEditRight())) {
             $links['views']['edit'] = array('class' => $type === 'edit' ? 'selected' : false, 'text' => wfMsg($exists ? 'ep-tab-edit' : 'ep-tab-create'), 'href' => $title->getLocalUrl(array('action' => 'edit')));
         }
         if ($exists) {
             $links['views']['history'] = array('class' => $type === 'history' ? 'selected' : false, 'text' => wfMsg('ep-tab-history'), 'href' => $title->getLocalUrl(array('action' => 'history')));
             if ($title->getNamespace() === EP_NS_COURSE) {
                 if ($user->isAllowed('ep-enroll')) {
                     $student = EPStudent::newFromUser($user);
                     if ($student === false || !$student->hasCourse(array('name' => $title->getText()))) {
                         $links['views']['enroll'] = array('class' => $isSpecial ? 'selected' : false, 'text' => wfMsg('ep-tab-enroll'), 'href' => SpecialPage::getTitleFor('Enroll', $title->getText())->getLocalURL());
                     }
                 }
             }
         }
     }
 }