コード例 #1
0
ファイル: SpecialAllpages.php プロジェクト: negabaro/alfresco
 /**
  * HTML for the top form
  * @param integer $namespace A namespace constant (default NS_MAIN).
  * @param string $from Article name we are starting listing at.
  */
 function namespaceForm($namespace = NS_MAIN, $from = '')
 {
     global $wgScript;
     $t = SpecialPage::getTitleFor($this->name);
     $namespaceselect = HTMLnamespaceselector($namespace, null);
     $frombox = "<input type='text' size='20' name='from' id='nsfrom' value=\"" . htmlspecialchars($from) . '"/>';
     $submitbutton = '<input type="submit" value="' . wfMsgHtml('allpagessubmit') . '" />';
     $out = "<div class='namespaceoptions'><form method='get' action='{$wgScript}'>";
     $out .= '<input type="hidden" name="title" value="' . $t->getPrefixedText() . '" />';
     $out .= "\n<table id='nsselect' class='allpages'>\n\t<tr>\n\t\t<td align='right'>" . wfMsgHtml($this->nsfromMsg) . "</td>\n\t\t<td align='left'><label for='nsfrom'>{$frombox}</label></td>\n\t</tr>\n\t<tr>\n\t\t<td align='right'><label for='namespace'>" . wfMsgHtml('namespace') . "</label></td>\n\t\t<td align='left'>\n\t\t\t{$namespaceselect} {$submitbutton}\n\t\t</td>\n\t</tr>\n</table>\n";
     $out .= '</form></div>';
     return $out;
 }
コード例 #2
0
/**
 * Creates the choose namespace selection
 *
 * @private
 *
 * @param $namespace Mixed: the key of the currently selected namespace, empty string
 *              if there is none
 * @param $invert Bool: whether to invert the namespace selection
 * @param $nondefaults Array: an array of non default options to be remembered
 * @param $categories_any Bool: Default value for the checkbox
 *
 * @return string
 */
function rcNamespaceForm($namespace, $invert, $nondefaults, $categories_any)
{
    global $wgScript, $wgAllowCategorizedRecentChanges, $wgRequest;
    $t = SpecialPage::getTitleFor('Recentchanges');
    $namespaceselect = HTMLnamespaceselector($namespace, '');
    $submitbutton = '<input type="submit" value="' . wfMsgHtml('allpagessubmit') . "\" />\n";
    $invertbox = "<input type='checkbox' name='invert' value='1' id='nsinvert'" . ($invert ? ' checked="checked"' : '') . ' />';
    if ($wgAllowCategorizedRecentChanges) {
        $categories = trim($wgRequest->getVal('categories', ""));
        $cb_arr = array('type' => 'checkbox', 'name' => 'categories_any', 'value' => "1");
        if ($categories_any) {
            $cb_arr['checked'] = "checked";
        }
        $catbox = "<br />";
        $catbox .= wfMsgExt('rc_categories', array('parseinline')) . " ";
        $catbox .= wfElement('input', array('type' => 'text', 'name' => 'categories', 'value' => $categories));
        $catbox .= " &nbsp;";
        $catbox .= wfElement('input', $cb_arr);
        $catbox .= wfMsgExt('rc_categories_any', array('parseinline'));
    } else {
        $catbox = "";
    }
    $out = "<div class='namespacesettings'><form method='get' action='{$wgScript}'>\n";
    foreach ($nondefaults as $key => $value) {
        if ($key != 'namespace' && $key != 'invert') {
            $out .= wfElement('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
        }
    }
    $out .= '<input type="hidden" name="title" value="' . $t->getPrefixedText() . '" />';
    $out .= "\r\n<div id='nsselect' class='recentchanges'>\r\n\t<label for='namespace'>" . wfMsgHtml('namespace') . "</label>\r\n\t{$namespaceselect}{$submitbutton}{$invertbox} <label for='nsinvert'>" . wfMsgHtml('invert') . "</label>{$catbox}\n</div>";
    $out .= '</form></div>';
    return $out;
}
コード例 #3
0
ファイル: SpecialImport.php プロジェクト: k-hasan-19/wiki
/**
 * Constructor
 */
function wfSpecialImport($page = '')
{
    global $wgUser, $wgOut, $wgRequest, $wgTitle, $wgImportSources;
    global $wgImportTargetNamespace;
    $interwiki = false;
    $namespace = $wgImportTargetNamespace;
    $frompage = '';
    $history = true;
    if ($wgRequest->wasPosted() && $wgRequest->getVal('action') == 'submit') {
        $isUpload = false;
        $namespace = $wgRequest->getIntOrNull('namespace');
        switch ($wgRequest->getVal("source")) {
            case "upload":
                $isUpload = true;
                if ($wgUser->isAllowed('importupload')) {
                    $source = ImportStreamSource::newFromUpload("xmlimport");
                } else {
                    return $wgOut->permissionRequired('importupload');
                }
                break;
            case "interwiki":
                $interwiki = $wgRequest->getVal('interwiki');
                $history = $wgRequest->getCheck('interwikiHistory');
                $frompage = $wgRequest->getText("frompage");
                $source = ImportStreamSource::newFromInterwiki($interwiki, $frompage, $history);
                break;
            default:
                $source = new WikiErrorMsg("importunknownsource");
        }
        if (WikiError::isError($source)) {
            $wgOut->addWikiText(wfEscapeWikiText($source->getMessage()));
        } else {
            $wgOut->addWikiText(wfMsg("importstart"));
            $importer = new WikiImporter($source);
            if (!is_null($namespace)) {
                $importer->setTargetNamespace($namespace);
            }
            $reporter = new ImportReporter($importer, $isUpload, $interwiki);
            $reporter->open();
            $result = $importer->doImport();
            $reporter->close();
            if (WikiError::isError($result)) {
                $wgOut->addWikiText(wfMsg("importfailed", wfEscapeWikiText($result->getMessage())));
            } else {
                # Success!
                $wgOut->addWikiText(wfMsg("importsuccess"));
            }
        }
    }
    $action = $wgTitle->escapeLocalUrl('action=submit');
    if ($wgUser->isAllowed('importupload')) {
        $wgOut->addWikiText(wfMsg("importtext"));
        $wgOut->addHTML("\n<fieldset>\n\t<legend>" . wfMsgHtml('upload') . "</legend>\n\t<form enctype='multipart/form-data' method='post' action=\"{$action}\">\n\t\t<input type='hidden' name='action' value='submit' />\n\t\t<input type='hidden' name='source' value='upload' />\n\t\t<input type='hidden' name='MAX_FILE_SIZE' value='2000000' />\n\t\t<input type='file' name='xmlimport' value='' size='30' />\n\t\t<input type='submit' value=\"" . wfMsgHtml("uploadbtn") . "\" />\n\t</form>\n</fieldset>\n");
    } else {
        if (empty($wgImportSources)) {
            $wgOut->addWikiText(wfMsg('importnosources'));
        }
    }
    if (!empty($wgImportSources)) {
        $wgOut->addHTML("\n<fieldset>\n\t<legend>" . wfMsgHtml('importinterwiki') . "</legend>\n\t<form method='post' action=\"{$action}\">" . $wgOut->parse(wfMsg('import-interwiki-text')) . "\n\t\t<input type='hidden' name='action' value='submit' />\n\t\t<input type='hidden' name='source' value='interwiki' />\n\t\t<table>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<select name='interwiki'>");
        foreach ($wgImportSources as $prefix) {
            $iw = htmlspecialchars($prefix);
            $selected = $interwiki === $prefix ? ' selected="selected"' : '';
            $wgOut->addHTML("<option value=\"{$iw}\"{$selected}>{$iw}</option>\n");
        }
        $wgOut->addHTML("\n\t\t\t\t\t</select>\n\t\t\t\t</td>\n\t\t\t\t<td>" . wfInput('frompage', 50, $frompage) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td></td>\n\t\t\t\t<td>" . wfCheckLabel(wfMsg('import-interwiki-history'), 'interwikiHistory', 'interwikiHistory', $history) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td></td>\n\t\t\t\t<td>\n\t\t\t\t\t" . wfMsgHtml('import-interwiki-namespace') . " " . HTMLnamespaceselector($namespace, '') . "\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td></td>\n\t\t\t\t<td>" . wfSubmitButton(wfMsg('import-interwiki-submit')) . "</td>\n\t\t\t</tr>\n\t\t</table>\n\t</form>\n</fieldset>\n");
    }
}
コード例 #4
0
ファイル: SpecialWatchlist.php プロジェクト: k-hasan-19/wiki
/**
 * Constructor
 * @todo Document $par parameter.
 * @param $par String: FIXME
 */
function wfSpecialWatchlist($par)
{
    global $wgUser, $wgOut, $wgLang, $wgMemc, $wgRequest, $wgContLang;
    global $wgUseWatchlistCache, $wgWLCacheTimeout, $wgDBname;
    global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker;
    global $wgEnotifWatchlist;
    $fname = 'wfSpecialWatchlist';
    $skin =& $wgUser->getSkin();
    $specialTitle = Title::makeTitle(NS_SPECIAL, 'Watchlist');
    $wgOut->setRobotPolicy('noindex,nofollow');
    # Anons don't get a watchlist
    if ($wgUser->isAnon()) {
        $wgOut->setPageTitle(wfMsg('watchnologin'));
        $llink = $skin->makeKnownLinkObj(Title::makeTitle(NS_SPECIAL, 'Userlogin'), wfMsgHtml('loginreqlink'), 'returnto=' . $specialTitle->getPrefixedUrl());
        $wgOut->addHtml(wfMsgWikiHtml('watchlistanontext', $llink));
        return;
    } else {
        $wgOut->setPageTitle(wfMsg('watchlist'));
        $wgOut->setSubtitle(wfMsgWikiHtml('watchlistfor', htmlspecialchars($wgUser->getName())));
    }
    if (wlHandleClear($wgOut, $wgRequest, $par)) {
        return;
    }
    $defaults = array('days' => floatval($wgUser->getOption('watchlistdays')), 'hideOwn' => (int) $wgUser->getBoolOption('watchlisthideown'), 'hideBots' => (int) $wgUser->getBoolOption('watchlisthidebots'), 'namespace' => 'all');
    extract($defaults);
    # Extract variables from the request, falling back to user preferences or
    # other default values if these don't exist
    $prefs['days'] = floatval($wgUser->getOption('watchlistdays'));
    $prefs['hideown'] = $wgUser->getBoolOption('watchlisthideown');
    $prefs['hidebots'] = $wgUser->getBoolOption('watchlisthidebots');
    # Get query variables
    $days = $wgRequest->getVal('days', $prefs['days']);
    $hideOwn = $wgRequest->getBool('hideOwn', $prefs['hideown']);
    $hideBots = $wgRequest->getBool('hideBots', $prefs['hidebots']);
    # Get namespace value, if supplied, and prepare a WHERE fragment
    $nameSpace = $wgRequest->getIntOrNull('namespace');
    if (!is_null($nameSpace)) {
        $nameSpace = intval($nameSpace);
        $nameSpaceClause = " AND rc_namespace = {$nameSpace}";
    } else {
        $nameSpace = '';
        $nameSpaceClause = '';
    }
    # Watchlist editing
    $action = $wgRequest->getVal('action');
    $remove = $wgRequest->getVal('remove');
    $id = $wgRequest->getArray('id');
    $uid = $wgUser->getID();
    if ($wgEnotifWatchlist && $wgRequest->getVal('reset') && $wgRequest->wasPosted()) {
        $wgUser->clearAllNotifications($uid);
    }
    # Deleting items from watchlist
    if ($action == 'submit' && isset($remove) && is_array($id)) {
        $wgOut->addWikiText(wfMsg('removingchecked'));
        $wgOut->addHTML('<p>');
        foreach ($id as $one) {
            $t = Title::newFromURL($one);
            if (!is_null($t)) {
                // WERELATE - run UnwatchArticle hooks; fix UnwatchArticle hook below to UnwatchArticleComplete
                $article = new Article($t);
                if (wfRunHooks('UnwatchArticle', array(&$wgUser, &$article))) {
                    $wl = WatchedItem::fromUserTitle($wgUser, $t);
                    if ($wl->removeWatch() === false) {
                        $wgOut->addHTML("<br />\n" . wfMsg('couldntremove', htmlspecialchars($one)));
                    } else {
                        wfRunHooks('UnwatchArticleComplete', array(&$wgUser, &$article));
                        $wgOut->addHTML(' (' . htmlspecialchars($one) . ')');
                    }
                }
            } else {
                $wgOut->addHTML("<br />\n" . wfMsg('iteminvalidname', htmlspecialchars($one)));
            }
        }
        $wgOut->addHTML("<br />\n" . wfMsg('wldone') . "</p>\n");
    }
    if ($wgUseWatchlistCache) {
        $memckey = "{$wgDBname}:watchlist:id:" . $wgUser->getId();
        $cache_s = @$wgMemc->get($memckey);
        if ($cache_s) {
            $wgOut->addWikiText(wfMsg('wlsaved'));
            $wgOut->addHTML($cache_s);
            return;
        }
    }
    $dbr =& wfGetDB(DB_SLAVE);
    extract($dbr->tableNames('page', 'revision', 'watchlist', 'recentchanges'));
    $sql = "SELECT COUNT(*) AS n FROM {$watchlist} WHERE wl_user={$uid}";
    $res = $dbr->query($sql, $fname);
    $s = $dbr->fetchObject($res);
    #	Patch *** A1 *** (see A2 below)
    #	adjust for page X, talk:page X, which are both stored separately, but treated together
    $nitems = floor($s->n / 2);
    #	$nitems = $s->n;
    if ($nitems == 0) {
        $wgOut->addWikiText(wfMsg('nowatchlist'));
        return;
    }
    if (is_null($days) || !is_numeric($days)) {
        $big = 1000;
        /* The magical big */
        // WERELATE - don't change default; pages don't change that often
        //		if($nitems > $big) {
        # Set default cutoff shorter
        //			$days = $defaults['days'] = (12.0 / 24.0); # 12 hours...
        //		} else {
        $days = $defaults['days'];
        # default cutoff for shortlisters
        //		}
    } else {
        $days = floatval($days);
    }
    // Dump everything here
    $nondefaults = array();
    wfAppendToArrayIfNotDefault('days', $days, $defaults, $nondefaults);
    wfAppendToArrayIfNotDefault('hideOwn', (int) $hideOwn, $defaults, $nondefaults);
    wfAppendToArrayIfNotDefault('hideBots', (int) $hideBots, $defaults, $nondefaults);
    wfAppendToArrayIfNotDefault('namespace', $nameSpace, $defaults, $nondefaults);
    if ($days <= 0) {
        $docutoff = '';
        $cutoff = false;
        $npages = wfMsg('watchlistall1');
    } else {
        $docutoff = "AND rev_timestamp > '" . ($cutoff = $dbr->timestamp(time() - intval($days * 86400))) . "'";
        /*
        $sql = "SELECT COUNT(*) AS n FROM $page, $revision  WHERE rev_timestamp>'$cutoff' AND page_id=rev_page";
        $res = $dbr->query( $sql, $fname );
        $s = $dbr->fetchObject( $res );
        $npages = $s->n;
        */
        $npages = 40000 * $days;
    }
    /* Edit watchlist form */
    if ($wgRequest->getBool('edit') || $par == 'edit') {
        $wgOut->addWikiText(wfMsg('watchlistcontains', $wgLang->formatNum($nitems)) . "\n\n" . wfMsg('watcheditlist'));
        $wgOut->addHTML('<form action=\'' . $specialTitle->escapeLocalUrl('action=submit') . "' method='post'>\n");
        #		Patch A2
        #		The following was proposed by KTurner 07.11.2004 to T.Gries
        #		$sql = "SELECT distinct (wl_namespace & ~1),wl_title FROM $watchlist WHERE wl_user=$uid";
        $sql = "SELECT wl_namespace, wl_title, page_is_redirect FROM {$watchlist} LEFT JOIN {$page} ON wl_namespace = page_namespace AND wl_title = page_title WHERE wl_user={$uid}";
        $res = $dbr->query($sql, $fname);
        # Batch existence check
        $linkBatch = new LinkBatch();
        while ($row = $dbr->fetchObject($res)) {
            $linkBatch->addObj(Title::makeTitleSafe($row->wl_namespace, $row->wl_title));
        }
        $linkBatch->execute();
        if ($dbr->numRows($res) > 0) {
            $dbr->dataSeek($res, 0);
        }
        # Let's do the time warp again!
        $sk = $wgUser->getSkin();
        $list = array();
        while ($s = $dbr->fetchObject($res)) {
            $list[$s->wl_namespace][$s->wl_title] = $s->page_is_redirect;
        }
        // TODO: Display a TOC
        foreach ($list as $ns => $titles) {
            if (Namespac::isTalk($ns)) {
                continue;
            }
            if ($ns != NS_MAIN) {
                $wgOut->addHTML('<h2>' . $wgContLang->getFormattedNsText($ns) . '</h2>');
            }
            $wgOut->addHTML('<ul>');
            foreach ($titles as $title => $redir) {
                $titleObj = Title::makeTitle($ns, $title);
                if (is_null($titleObj)) {
                    $wgOut->addHTML('<!-- bad title "' . htmlspecialchars($s->wl_title) . '" in namespace ' . $s->wl_namespace . " -->\n");
                } else {
                    global $wgContLang;
                    $toolLinks = array();
                    $titleText = $titleObj->getPrefixedText();
                    $pageLink = $sk->makeLinkObj($titleObj);
                    $toolLinks[] = $sk->makeLinkObj($titleObj->getTalkPage(), $wgLang->getNsText(NS_TALK));
                    if ($titleObj->exists()) {
                        $toolLinks[] = $sk->makeKnownLinkObj($titleObj, wfMsgHtml('history_short'), 'action=history');
                    }
                    $toolLinks = '(' . implode(' | ', $toolLinks) . ')';
                    $checkbox = '<input type="checkbox" name="id[]" value="' . htmlspecialchars($titleObj->getPrefixedText()) . '" /> ' . ($wgContLang->isRTL() ? '&rlm;' : '&lrm;');
                    if ($redir) {
                        $spanopen = '<span class="watchlistredir">';
                        $spanclosed = '</span>';
                    } else {
                        $spanopen = $spanclosed = '';
                    }
                    $wgOut->addHTML("<li>{$checkbox}{$spanopen}{$pageLink}{$spanclosed} {$toolLinks}</li>\n");
                }
            }
            $wgOut->addHTML('</ul>');
        }
        $wgOut->addHTML("<input type='submit' name='remove' value=\"" . htmlspecialchars(wfMsg("removechecked")) . "\" />\n" . "</form>\n");
        return;
    }
    # If the watchlist is relatively short, it's simplest to zip
    # down its entirety and then sort the results.
    # If it's relatively long, it may be worth our while to zip
    # through the time-sorted page list checking for watched items.
    # Up estimate of watched items by 15% to compensate for talk pages...
    # Toggles
    $andHideOwn = $hideOwn ? "AND (rc_user <> {$uid})" : '';
    $andHideBots = $hideBots ? "AND (rc_bot = 0)" : '';
    # Show watchlist header
    $header = '';
    if ($wgUser->getOption('enotifwatchlistpages') && $wgEnotifWatchlist) {
        $header .= wfMsg('wlheader-enotif') . "\n";
    }
    if ($wgEnotifWatchlist && $wgShowUpdatedMarker) {
        $header .= wfMsg('wlheader-showupdated') . "\n";
    }
    # Toggle watchlist content (all recent edits or just the latest)
    if ($wgUser->getOption('extendwatchlist')) {
        $andLatest = '';
        $limitWatchlist = 'LIMIT ' . intval($wgUser->getOption('wllimit'));
    } else {
        $andLatest = 'AND rc_this_oldid=page_latest';
        $limitWatchlist = '';
    }
    # TODO: Consider removing the third parameter
    $header .= wfMsg('watchdetails', $wgLang->formatNum($nitems), $wgLang->formatNum($npages), '', $specialTitle->getFullUrl('edit=yes'));
    $wgOut->addWikiText($header);
    if ($wgEnotifWatchlist && $wgShowUpdatedMarker) {
        $wgOut->addHTML('<form action="' . $specialTitle->escapeLocalUrl() . '" method="post"><input type="submit" name="dummy" value="' . htmlspecialchars(wfMsg('enotif_reset')) . '" /><input type="hidden" name="reset" value="all" /></form>' . "\n\n");
    }
    // WERELATE - handle changed view
    if ($wgRequest->getBool('changed') || $par == 'changed') {
        $wgOut->addHTML('<hr /><h2>All pages changed since last visited</h2><ul><li><a href="' . $specialTitle->getFullUrl() . '">Show recently-changed pages</a></li></ul>');
        $sql = 'select wl_namespace, wl_title from watchlist where wl_user='******' and wl_notificationtimestamp > \'0\'';
        $res = $dbr->query($sql, $fname);
        $sk = $wgUser->getSkin();
        $changed = '';
        $count = 0;
        while ($obj = $dbr->fetchObject($res)) {
            $t = Title::makeTitle($obj->wl_namespace, $obj->wl_title);
            $historylink = $sk->makeKnownLinkObj($t, 'hist', wfArrayToCGI(array('action' => 'history')));
            $articlelink = $sk->makeKnownLinkObj($t);
            $changed .= "<li> ( {$historylink} ) . . {$articlelink}</li>\n";
            $count += 1;
        }
        $dbr->freeResult($res);
        $wgOut->addHTML("<h3>{$count} page(s)</h3>\n<ul>" . $changed . '</ul>');
        return;
    }
    // WERELATE - remove join with page table
    $sql = "SELECT\n\t  rc_namespace AS page_namespace, rc_title AS page_title,\n\t  rc_comment AS rev_comment, rc_cur_id AS page_id,\n\t  rc_user AS rev_user, rc_user_text AS rev_user_text,\n\t  rc_timestamp AS rev_timestamp, rc_minor AS rev_minor_edit,\n\t  rc_this_oldid AS rev_id,\n\t  rc_last_oldid, rc_id, rc_patrolled,\n\t  rc_new AS page_is_new,wl_notificationtimestamp\n\t  FROM {$watchlist},{$recentchanges}\n\t  WHERE wl_user={$uid}\n\t  AND wl_namespace=rc_namespace\n\t  AND wl_title=rc_title\n\t  AND rc_timestamp > '{$cutoff}'\n\t  {$andHideOwn}\n\t  {$andHideBots}\n\t  {$nameSpaceClause}\n\t  ORDER BY rc_timestamp DESC\n\t  {$limitWatchlist}";
    $res = $dbr->query($sql, $fname);
    // WERELATE - moved up from below so we can calculate $numRows inside the loop
    //	$numRows = $dbr->numRows( $res );
    $numRows = 0;
    $list = ChangesList::newFromUser($wgUser);
    $rcs = $list->beginRecentChangesList();
    $counter = 1;
    // WERELATE - added array of seen pagetitles
    $seen = array();
    while ($obj = $dbr->fetchObject($res)) {
        $nsTitle = "{$obj->page_namespace}:{$obj->page_title}";
        if (!$andLatest || !isset($seen[$nsTitle])) {
            $seen[$nsTitle] = 1;
            $numRows++;
            # Make fake RC entry
            $rc = RecentChange::newFromCurRow($obj, $obj->rc_last_oldid);
            $rc->counter = $counter++;
            if ($wgShowUpdatedMarker) {
                $updated = $obj->wl_notificationtimestamp;
            } else {
                // Same visual appearance as MW 1.4
                $updated = true;
            }
            if ($wgRCShowWatchingUsers && $wgUser->getOption('shownumberswatching')) {
                $sql3 = "SELECT COUNT(*) AS n FROM {$watchlist} WHERE wl_title='" . wfStrencode($obj->page_title) . "' AND wl_namespace='{$obj->page_namespace}'";
                $res3 = $dbr->query($sql3, DB_READ, $fname);
                $x = $dbr->fetchObject($res3);
                $rc->numberofWatchingusers = $x->n;
            } else {
                $rc->numberofWatchingusers = 0;
            }
            $rcs .= $list->recentChangesLine($rc, $updated);
        }
    }
    $rcs .= $list->endRecentChangesList();
    $dbr->freeResult($res);
    /* Start bottom header */
    // WERELATE - add link to changed view
    //	$wgOut->addHTML( "<hr />\n<p>" );
    $wgOut->addHTML('<hr /><h2>Recently-changed pages</h2><ul><li><a href="' . $specialTitle->getFullUrl('changed=yes') . '">Show all pages changed since last visited</a></li></ul><br/><p>');
    if ($days >= 1) {
        $wgOut->addWikiText(wfMsg('rcnote', $wgLang->formatNum($numRows), $wgLang->formatNum($days), $wgLang->timeAndDate(wfTimestampNow(), true)) . '<br />', false);
    } elseif ($days > 0) {
        $wgOut->addWikiText(wfMsg('wlnote', $wgLang->formatNum($numRows), $wgLang->formatNum(round($days * 24))) . '<br />', false);
    }
    $wgOut->addHTML("\n" . wlCutoffLinks($days, 'Watchlist', $nondefaults) . "<br />\n");
    # Spit out some control panel links
    $thisTitle = Title::makeTitle(NS_SPECIAL, 'Watchlist');
    $skin = $wgUser->getSkin();
    $linkElements = array('hideOwn' => 'wlhideshowown', 'hideBots' => 'wlhideshowbots');
    # Problems encountered using the fancier method
    $label = $hideBots ? wfMsgHtml('show') : wfMsgHtml('hide');
    $linkBits = wfArrayToCGI(array('hideBots' => 1 - (int) $hideBots), $nondefaults);
    $link = $skin->makeKnownLinkObj($thisTitle, $label, $linkBits);
    $links[] = wfMsgHtml('wlhideshowbots', $link);
    $label = $hideOwn ? wfMsgHtml('show') : wfMsgHtml('hide');
    $linkBits = wfArrayToCGI(array('hideOwn' => 1 - (int) $hideOwn), $nondefaults);
    $link = $skin->makeKnownLinkObj($thisTitle, $label, $linkBits);
    $links[] = wfMsgHtml('wlhideshowown', $link);
    $wgOut->addHTML(implode(' | ', $links));
    # Form for namespace filtering
    $thisAction = $thisTitle->escapeLocalUrl();
    $nsForm = "<form method=\"post\" action=\"{$thisAction}\">\n";
    $nsForm .= "<label for=\"namespace\">" . wfMsgExt('namespace', array('parseinline')) . "</label> ";
    $nsForm .= HTMLnamespaceselector($nameSpace, '') . "\n";
    $nsForm .= $hideOwn ? "<input type=\"hidden\" name=\"hideown\" value=\"1\" />\n" : "";
    $nsForm .= $hideBots ? "<input type=\"hidden\" name=\"hidebots\" value=\"1\" />\n" : "";
    $nsForm .= "<input type=\"hidden\" name=\"days\" value=\"" . $days . "\" />\n";
    $nsForm .= "<input type=\"submit\" name=\"submit\" value=\"" . wfMsgExt('allpagessubmit', array('escape')) . "\" />\n";
    $nsForm .= "</form>\n";
    $wgOut->addHTML($nsForm);
    if ($numRows == 0) {
        $wgOut->addWikitext("<br />" . wfMsg('watchnochange'), false);
        $wgOut->addHTML("</p>\n");
        return;
    }
    $wgOut->addHTML("</p>\n");
    /* End bottom header */
    // WERELATE - change $s to $rcs
    $wgOut->addHTML($rcs);
    if ($wgUseWatchlistCache) {
        $wgMemc->set($memckey, $s, $wgWLCacheTimeout);
    }
}
コード例 #5
0
function getGotoPageForm($namespace, $titleText, $hideNamespace = false)
{
    if ($namespace == 'person') {
        $result = <<<END
<form name="search" action="/wiki/Special:GotoPageOld" method="get">
<input type="hidden" name="namespace" value="person"/>
<table>
<tr><td align="right">First given name:</td><td><input type="text" name="personGiven" size=12 maxlength="100" value="" onfocus="select()"/></td></tr>
<tr><td align="right">Surname:</td><td><input type="text" name="personSurname" size=12 maxlength="100" value=""/></td></tr>
<tr><td></td><td align="right"><input type="submit" name="add" value="Add" /></td></tr></table>
</form>
END;
    } else {
        if ($namespace == 'family') {
            $result = <<<END
<form name="search" action="/wiki/Special:GotoPageOld" method="get">
<input type="hidden" name="namespace" value="family"/>
<table>
<tr><td></td><td align="center">First given name</td><td align="center">Surname</td></tr>
<tr><td align="right">Husband:</td><td><input type="text" name="husbandGiven" size=10 maxlength="100" value="" onfocus="select()"/></td><td><input type="text" name="husbandSurname" size=10 maxlength="100" value=""/></td></tr>
<tr><td align="right">Wife:</td><td><input type="text" name="wifeGiven" size=10 maxlength="100" value=""/></td><td><input type="text" name="wifeSurname" size=10 maxlength="100" value=""/></td></tr>
<tr><td></td><td></td><td align="right"><input type="submit" name="add" value="Add" /></td></tr></table>
</form>
END;
        } else {
            $addPage = true;
            $size = 24;
            $titleAttrs = '';
            $nsSelector = '';
            if ($namespace == 'watchlist') {
                $namespace = NS_PERSON;
                $titleAttrs = ' class="person_input"';
                $hideNamespace = false;
                $addPage = false;
                $size = 15;
                $nsSelector = "<select id='namespace' name='namespace' class='namespaceselector' onChange='changeNs()'>\n\t";
                foreach (AutoCompleter::$nsidToNs as $index => $name) {
                    if ($index === $namespace) {
                        $nsSelector .= Xml::element("option", array("value" => $index, "selected" => "selected"), $name);
                    } else {
                        $nsSelector .= Xml::element("option", array("value" => $index), $name);
                    }
                }
                $nsSelector .= "\n</select>\n";
                $fieldAlign = 'left';
                $fieldSeparator = ' ';
            } else {
                $fieldAlign = 'right';
                $fieldSeparator = '</td><td align="left">';
                if (!$hideNamespace || strlen($namespace) == 0) {
                    $nsSelector = HTMLnamespaceselector($namespace, null);
                }
            }
            if (!$nsSelector) {
                $namespaceselect = '<input type="hidden" name="namespace" value="' . $namespace . '"/>';
            } else {
                $namespaceselect = "<tr><td align=\"{$fieldAlign}\">Namespace:{$fieldSeparator}{$nsSelector}</tr>";
            }
            if ($namespace == NS_IMAGE || $namespace == NS_USER) {
                $addPage = false;
            }
            $result = <<<END
<form name="search" action="/wiki/Special:GotoPageOld" method="get">
<table>
{$namespaceselect}<tr><td align="{$fieldAlign}">Title:{$fieldSeparator}<input id="titleinput" type="text" name="pagetitle" size="{$size}" maxlength="150" value="{$titleText}" onfocus="select()"{$titleAttrs}/>
</td></tr><tr><td align="right" colspan="2">
END;
            if ($addPage) {
                $result .= '<input type="submit" name="goto" value="Go to page"/>&nbsp;&nbsp;<input type="submit" name="add" value="Add new page"/>';
            } else {
                $result .= ' <input type="submit" name="goto" value="Go"/>';
            }
            $result .= '</td></tr></table></form>';
        }
    }
    return "<div class=\"gotopage\">{$result}</div>";
}
コード例 #6
0
ファイル: SpecialAddPage.php プロジェクト: k-hasan-19/wiki
    public function getFormHtml()
    {
        global $wgLang, $wgUser;
        $target = $this->target;
        if (!$target) {
            $target = 'AddPage';
        }
        $buttonValue = 'Next';
        $nsText = $wgLang->getFormattedNsText($this->namespace);
        if ($this->namespace == NS_PERSON) {
            $givenname = htmlspecialchars($this->givenname);
            $surname = htmlspecialchars($this->surname);
            $birthSelect = StructuredData::addSelectToHtml(1, 'bt', AddPageForm::$BIRTH_TYPE_OPTIONS, $this->birthType);
            $birthdate = htmlspecialchars($this->birthdate);
            $birthplace = htmlspecialchars($this->birthplace);
            $deathSelect = StructuredData::addSelectToHtml(1, 'dt', AddPageForm::$DEATH_TYPE_OPTIONS, $this->deathType);
            $deathdate = htmlspecialchars($this->deathdate);
            $deathplace = htmlspecialchars($this->deathplace);
            $genderSelect = StructuredData::addSelectToHtml(1, 'gnd', Person::$GENDER_OPTIONS, $this->gender);
            $parentFamily = htmlspecialchars($this->parentFamily);
            $spouseFamily = htmlspecialchars($this->spouseFamily);
            $wifegivenname = htmlspecialchars($this->wifeGivenname);
            // if we're adding a father we need to remember the mother's name
            $wifesurname = htmlspecialchars($this->wifeSurname);
            $result = <<<END
<form name="search" action="/wiki/Special:Search" method="get">
<input type="hidden" name="target" value="{$target}"/>
<input type="hidden" id="ns" name="ns" value="{$nsText}"/>
<input type="hidden" id="input_pf" name="pf" value="{$parentFamily}"/>
<input type="hidden" id="input_sf" name="sf" value="{$spouseFamily}"/>
<input type="hidden" id="input_wg" name="wg" value="{$wifegivenname}"/>
<input type="hidden" id="input_ws" name="ws" value="{$wifesurname}"/>
<table class="searchform">
<tr><td align="right">Given name: </td><td><input type="text" id="givenname_input" name="g" size=15 maxlength="50" value="{$givenname}" tabindex="1"/></td>
  <td align="right">Surname: </td><td><input type="text" name="s" size=35 maxlength="50" value="{$surname}" tabindex="1"/></td></tr>
<tr><td align="right">Gender: </td><td>{$genderSelect}</td></tr>
<tr><td align="right">{$birthSelect} date: </td><td><input type="text" name="bd" size=15 maxlength="25" value="{$birthdate}"  tabindex="1" /></td>
  <td align="right">Place: </td><td><input class="place_input" type="text" name="bp" size=35 maxlength="130" value="{$birthplace}" tabindex="1" /></td></tr>
<tr><td align="right">{$deathSelect} date: </td><td><input type="text" name="dd" size=15 maxlength="25" value="{$deathdate}" tabindex="1" /></td>
  <td align="right">Place: </td><td><input class="place_input" type="text" name="dp" size=35 maxlength="130" value="{$deathplace}" tabindex="1" /></td></tr>
<tr><td colspan=4 align="right"><input type="submit" name="add" value="{$buttonValue}" tabindex="1"/></td></tr></table>
</form>
END;
        } else {
            if ($this->namespace == NS_FAMILY) {
                $gender = htmlspecialchars($this->gender);
                $husbandgivenname = htmlspecialchars($this->husbandGivenname);
                $husbandsurname = htmlspecialchars($this->husbandSurname);
                $wifegivenname = htmlspecialchars($this->wifeGivenname);
                $wifesurname = htmlspecialchars($this->wifeSurname);
                $marriagedate = htmlspecialchars($this->marriagedate);
                $marriageplace = htmlspecialchars($this->marriageplace);
                $husbandTitle = htmlspecialchars($this->husbandTitle);
                $wifeTitle = htmlspecialchars($this->wifeTitle);
                $childTitle = htmlspecialchars($this->childTitle);
                $result = <<<END
<form name="search" action="/wiki/Special:Search" method="get">
<input type="hidden" name="target" value="{$target}"/>
<input type="hidden" id = "ns" name="ns" value="{$nsText}"/>
<input type="hidden" id="input_gnd" name="gnd" value="{$gender}"/>
<input type="hidden" id="input_ht" name="ht" value="{$husbandTitle}"/>
<input type="hidden" id="input_wt" name="wt" value="{$wifeTitle}"/>
<input type="hidden" id="input_ct" name="ct" value="{$childTitle}"/>
<table class="searchform">
<tr id="husband_row"><td align="right">Husband given name: </td><td><input type="text" name="hg" size=15 maxlength="50" value="{$husbandgivenname}" tabindex="1" /></td>
  <td align="right">Surname: </td><td><input type="text" name="hs" size=25 maxlength="50" value="{$husbandsurname}" tabindex="1" /></td></tr>
<tr><td align="right">Wife given name: </td><td><input type="text" name="wg" size=15 maxlength="50" value="{$wifegivenname}" tabindex="1" /></td>
  <td align="right">Maiden name: </td><td><input type="text" name="ws" size=25 maxlength="50" value="{$wifesurname}" tabindex="1" /></td></tr>
<tr><td align="right">Marriage date: </td><td><input type="text" name="md" size=15 maxlength="25" value="{$marriagedate}" tabindex="1" /></td>
  <td align="right">Place: </td><td><input class="place_input" type="text" name="mp" size=25 maxlength="130" value="{$marriageplace}" tabindex="1" /></td></tr>
<tr><td colspan=4 align="right"><input type="submit" name="add" value="{$buttonValue}" tabindex="1" /></td></tr></table>
</form>
END;
            } else {
                if ($this->namespace == NS_SOURCE) {
                    $title = htmlspecialchars($this->sourceTitle);
                    $author = htmlspecialchars($this->author);
                    $place = htmlspecialchars($this->place);
                    $placeIssued = htmlspecialchars($this->placeIssued);
                    $publisher = htmlspecialchars($this->publisher);
                    $select = StructuredData::addSelectToHtml(1, 'sty', Source::$ADD_SOURCE_TYPE_OPTIONS, $this->sourceType);
                    $result = <<<END
<form name="search" action="/wiki/Special:Search" method="get">
<input type="hidden" name="target" value="{$target}"/>
<input type="hidden" id = "ns" name="ns" value="{$nsText}"/>
<table class="searchform">
<tr><td align="right">Source type:</td><td align="left">{$select}</td><td></td></tr>
<tr id="author_row"><td align="right">Author:</td><td align="left"><input type="text" name="a" size="35" value="{$author}" tabindex="1" /></td><td>&nbsp;<i>surname, given name(s) of first author</i></td></tr>
<tr><td align="right">Title:</td><td align="left"><input type="text" name="st" size="35" value="{$title}" tabindex="1" /></td><td>&nbsp;<i>title only, no subtitle</i></td></tr>
<tr><td align="right">Place covered:</td><td align="left"><input class="place_input" type="text" name="p" size="35" value="{$place}" tabindex="1" /></td><td>&nbsp;<i>for government/church records</i></td></tr>
<tr><td align="right">Publisher:</td><td align="left"><input type="text" name="pu" size="35" value="{$publisher}" tabindex="1" /></td><td></td></tr>
<tr><td align="right">Place issued:</td><td align="left"><input type="text" name="pi" size="35" value="{$placeIssued}" tabindex="1" /></td><td></td></tr>
<tr><td colspan=3 align="right"><input type="submit" name="add" value="{$buttonValue}" tabindex="1" /></td></tr>
</table></form>
END;
                } else {
                    if ($this->namespace == NS_MYSOURCE) {
                        $author = htmlspecialchars($this->author);
                        $title = htmlspecialchars($this->titleText);
                        $result = <<<END
<form name="search" action="/wiki/Special:Search" method="get">
<input type="hidden" name="target" value="{$target}"/>
<input type="hidden" id = "ns" name="ns" value="{$nsText}"/>
<table class="searchform">
<tr><td align="right">Title:</td><td align="left"><input type="text" name="t" size="35" value="{$title}" tabindex="1" /></td></tr>
<tr><td colspan=2 align="right"><input type="submit" name="add" value="{$buttonValue}" tabindex="1" /></td></tr>
</table></form>
END;
                    } else {
                        if ($this->namespace == NS_PLACE) {
                            $placeName = htmlspecialchars($this->placeName);
                            $locatedIn = htmlspecialchars($this->locatedIn);
                            $result = <<<END
<form name="search" action="/wiki/Special:Search" method="get">
<input type="hidden" name="target" value="{$target}"/>
<input type="hidden" id = "ns" name="ns" value="{$nsText}"/>
<table class="searchform">
<tr id="placename_row"><td align="right">Place name:</td><td align="left"><input type="text" name="pn" size="20" value="{$placeName}" tabindex="1" /></td><td>Name of the place to add</td></tr>
<tr><td align="right">Located in:</td><td align="left"><input class="place_input" type="text" name="li" size="35" value="{$locatedIn}" tabindex="1" /></td><td>County, District, or State in which the place is located</td></tr>
<tr><td colspan=3 align="right"><input type="submit" name="add" value="{$buttonValue}" tabindex="1" /></td></tr>
</table></form>
END;
                        } else {
                            $title = htmlspecialchars($this->titleText);
                            if (strlen($this->namespace) == 0) {
                                $hiddenField = '';
                                $namespaceselect = "<tr><td align=\"right\">Namespace:</td><td align=\"left\">" . HTMLnamespaceselector('', null) . "</tr>";
                            } else {
                                $hiddenField = "<input type=\"hidden\" name=\"namespace\" value=\"{$this->namespace}\"/>";
                                $namespaceselect = '';
                            }
                            $result = <<<END
<form name="search" action="/wiki/Special:AddPage" method="get">
<input type="hidden" name="confirm" value="true"/>
{$hiddenField}
<table class="searchform">
{$namespaceselect}<tr id="title_row"><td align="right">Title:</td><td align="left"><input id="titleinput" type="text" name="t" size="40" maxlength="160" value="{$title}" />
</td><td><input type="submit" name="add" value="{$buttonValue}"/>
</td></tr></table></form>
END;
                        }
                    }
                }
            }
        }
        //      $treeCheckboxes = '';
        //      if ($this->namespace == NS_PERSON || $this->namespace == NS_FAMILY) {
        //         $treeCheckboxes = '<p>'.FamilyTreeUtil::generateTreeCheckboxes($wgUser, null, true).'</p>';
        //      }
        $addPageCache = $this->namespace == NS_SOURCE || $this->namespace == NS_MYSOURCE || $this->namespace == NS_PERSON || $this->namespace == NS_FAMILY ? '<div id="addpage_cache" style="display:none"></div>' : '';
        // was $treeCheckboxes inside div
        return '<center>' . $result . '</center>' . $addPageCache;
    }
コード例 #7
0
/**
 * Special page "user contributions".
 * Shows a list of the contributions of a user.
 *
 * @return	none
 * @param	string	$par	(optional) user name of the user for which to show the contributions
 */
function wfSpecialContributions($par = null)
{
    global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest, $wgTitle, $wgScript;
    $fname = 'wfSpecialContributions';
    $target = isset($par) ? $par : $wgRequest->getVal('target');
    if (!strlen($target)) {
        $wgOut->errorpage('notargettitle', 'notargettext');
        return;
    }
    $nt = Title::newFromURL($target);
    if (!$nt) {
        $wgOut->errorpage('notargettitle', 'notargettext');
        return;
    }
    $nt =& Title::makeTitle(NS_USER, $nt->getDBkey());
    list($limit, $offset) = wfCheckLimits();
    $offset = $wgRequest->getVal('offset');
    /* Offset must be an integral. */
    if (!strlen($offset) || !preg_match("/^[0-9]+\$/", $offset)) {
        $offset = 0;
    }
    $title = Title::makeTitle(NS_SPECIAL, "Contributions");
    $urlbits = "target=" . wfUrlEncode($target);
    $myurl = $title->escapeLocalURL($urlbits);
    $finder = new contribs_finder($target == 'newbies' ? 'newbies' : $nt->getText());
    $finder->set_limit($limit);
    $finder->set_offset($offset);
    $nsurl = $xnsurl = "";
    if (($ns = $wgRequest->getVal('namespace', null)) !== null) {
        $nsurl = "&namespace={$ns}";
        $xnsurl = htmlspecialchars($nsurl);
        $finder->set_namespace($ns);
    }
    if ($wgRequest->getText('go') == "prev") {
        $prevts = $finder->get_previous_offset_for_paging();
        $prevurl = $title->getLocalURL($urlbits . "&offset={$prevts}&limit={$limit}{$nsurl}");
        $wgOut->redirect($prevurl);
        return;
    }
    if ($wgRequest->getText('go') == "first") {
        $prevts = $finder->get_first_offset_for_paging();
        $prevurl = $title->getLocalURL($urlbits . "&offset={$prevts}&limit={$limit}{$nsurl}");
        $wgOut->redirect($prevurl);
        return;
    }
    $sk = $wgUser->getSkin();
    $id = User::idFromName($nt->getText());
    if (0 == $id) {
        $ul = $nt->getText();
    } else {
        $ul = $sk->makeLinkObj($nt, htmlspecialchars($nt->getText()));
        $userCond = '=' . $id;
    }
    $talk = $nt->getTalkPage();
    if ($talk) {
        $ul .= ' (' . $sk->makeLinkObj($talk, $wgLang->getNsText(NS_TALK)) . ')';
    }
    if ($target == 'newbies') {
        $ul = wfMsg('newbies');
    }
    $wgOut->setSubtitle(wfMsgHtml('contribsub', $ul));
    wfRunHooks('SpecialContributionsBeforeMainOutput', $id);
    $arr = $wgContLang->getFormattedNamespaces();
    $nsform = "<form method='get' action=\"{$wgScript}\">\n";
    $nsform .= wfElement("input", array("name" => "title", "type" => "hidden", "value" => $wgTitle->getPrefixedText()));
    $nsform .= wfElement("input", array("name" => "offset", "type" => "hidden", "value" => $offset));
    $nsform .= wfElement("input", array("name" => "limit", "type" => "hidden", "value" => $limit));
    $nsform .= wfElement("input", array("name" => "target", "type" => "hidden", "value" => $target));
    $nsform .= "<p>";
    $nsform .= wfMsgHtml('namespace');
    $nsform .= HTMLnamespaceselector($ns, '');
    $nsform .= wfElement("input", array("type" => "submit", "value" => wfMsg('allpagessubmit')));
    $nsform .= "</p></form>\n";
    $wgOut->addHTML($nsform);
    $contribsPage = Title::makeTitle(NS_SPECIAL, 'Contributions');
    $contribs = $finder->find();
    if (count($contribs) == 0) {
        $wgOut->addWikiText(wfMsg("nocontribs"));
        return;
    }
    list($early, $late) = $finder->get_edit_limits();
    $lastts = count($contribs) ? $contribs[count($contribs) - 1]->rev_timestamp : 0;
    $atstart = !count($contribs) || $late == $contribs[0]->rev_timestamp;
    $atend = !count($contribs) || $early == $lastts;
    $lasturl = $wgTitle->escapeLocalURL("action=history&limit={$limit}");
    $firsttext = wfMsgHtml("histfirst");
    $lasttext = wfMsgHtml("histlast");
    $prevtext = wfMsg("prevn", $limit);
    if ($atstart) {
        $lastlink = $lasttext;
        $prevlink = $prevtext;
    } else {
        $lastlink = "<a href=\"{$myurl}&amp;limit={$limit}{$xnsurl}\">{$lasttext}</a>";
        $prevlink = "<a href=\"{$myurl}&amp;offset={$offset}&amp;limit={$limit}{$xnsurl}&amp;go=prev\">{$prevtext}</a>";
    }
    $nexttext = wfMsg("nextn", $limit);
    if ($atend) {
        $firstlink = $firsttext;
        $nextlink = $nexttext;
    } else {
        $firstlink = "<a href=\"{$myurl}&amp;limit={$limit}{$xnsurl}&amp;go=first\">{$firsttext}</a>";
        $nextlink = "<a href=\"{$myurl}&amp;offset={$lastts}&amp;limit={$limit}{$xnsurl}\">{$nexttext}</a>";
    }
    $firstlast = "({$lastlink} | {$firstlink})";
    $urls = array();
    foreach (array(20, 50, 100, 250, 500) as $num) {
        $urls[] = "<a href=\"{$myurl}&amp;offset={$offset}&amp;limit={$num}{$xnsurl}\">" . $wgLang->formatNum($num) . "</a>";
    }
    $bits = implode($urls, ' | ');
    $prevnextbits = "{$firstlast} " . wfMsgHtml("viewprevnext", $prevlink, $nextlink, $bits);
    $wgOut->addHTML("<p>{$prevnextbits}</p>\n");
    $wgOut->addHTML("<ul>\n");
    foreach ($contribs as $contrib) {
        $wgOut->addHTML(ucListEdit($sk, $contrib));
    }
    $wgOut->addHTML("</ul>\n");
    $wgOut->addHTML("<p>{$prevnextbits}</p>\n");
}
コード例 #8
0
function rcNamespaceForm($namespace, $invert, $nondefaults)
{
    global $wgContLang, $wgScript;
    $t = Title::makeTitle(NS_SPECIAL, 'Recentchanges');
    $namespaceselect = HTMLnamespaceselector($namespace, '');
    $submitbutton = '<input type="submit" value="' . wfMsgHtml('allpagessubmit') . '" />';
    $invertbox = "<input type='checkbox' name='invert' value='1' id='nsinvert'" . ($invert ? ' checked="checked"' : '') . ' />';
    $out = "<div class='namespacesettings'><form method='get' action='{$wgScript}'>\n";
    foreach ($nondefaults as $key => $value) {
        if ($key != 'namespace' && $key != 'invert') {
            $out .= wfElement('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
        }
    }
    $out .= '<input type="hidden" name="title" value="' . $t->getPrefixedText() . '" />';
    $out .= "\n<div id='nsselect' class='recentchanges'>\n\t<label for='namespace'>" . wfMsgHtml('namespace') . "</label>\n\t{$namespaceselect} {$submitbutton} {$invertbox} <label for='nsinvert'>" . wfMsgHtml('invert') . "</label>\n</div>";
    $out .= '</form></div>';
    return $out;
}
コード例 #9
0
/**
 * Generates the namespace selector form with hidden attributes.
 * @param $options Array: the options to be included.
 */
function contributionsForm($options)
{
    global $wgScript, $wgTitle;
    $options['title'] = $wgTitle->getPrefixedText();
    $f = "<form method='get' action=\"{$wgScript}\">\n";
    foreach ($options as $name => $value) {
        if ($name === 'namespace') {
            continue;
        }
        $f .= "\t" . wfElement('input', array('name' => $name, 'type' => 'hidden', 'value' => $value)) . "\n";
    }
    $f .= '<p>' . wfMsgHtml('namespace') . ' ' . HTMLnamespaceselector($options['namespace'], '') . wfElement('input', array('type' => 'submit', 'value' => wfMsg('allpagessubmit'))) . "</p></form>\n";
    return $f;
}
コード例 #10
0
ファイル: RCPatrol.body.php プロジェクト: ErdemA/wikihow
 private static function getOrderingTab()
 {
     global $wgRequest;
     $reverse = $wgRequest->getVal('reverse', 0);
     $tab = "<tr class='rc_submenu' id='rc_ordering'><td>\n\t\t\t<div id='controls' style='text-align:center'>\n\t\t\t<input type='radio' id='reverse_newest' name='reverse' value='0' " . (!$reverse ? "checked" : "") . " style='height: 10px;' onchange='changeReverse();'> <label for='reverse_newest'>" . wfMsg('rcpatrol_newest_oldest') . "</label>\n\t\t\t<input type='radio' id='reverse_oldest' name='reverse' value='1' id='reverse' " . ($reverse ? "checked" : "") . " style='height: 10px; margin-left:10px;' onchange='changeReverse();'> <label for='reverse_oldest'>" . wfMsg('rcpatrol_oldest_newest') . "</label>\n\t\t\t&nbsp; &nbsp; - &nbsp; &nbsp; " . wfMsg('rcpatrol_namespace') . ": " . HTMLnamespaceselector($namespace, '') . " <script>     \$('#namespace').change(function() { ns = \$('#namespace').val(); nextrev = null; }); </script>\n\t\t\t</div></td></tr>";
     return $tab;
 }
コード例 #11
0
ファイル: SpecialGotoPage.php プロジェクト: k-hasan-19/wiki
function wfSpecialGotoPage()
{
    global $wgOut, $wgRequest, $wgUser, $wgScriptPath;
    $scope = $wgRequest->getVal('scope');
    $namespace = $wgRequest->getVal('namespace');
    $pageTitle = $wgRequest->getVal('pagetitle');
    $id = $wgRequest->getVal('id');
    if (!$scope) {
        if ($wgUser->isLoggedIn()) {
            $scope = 'watched';
        } else {
            $scope = 'all';
        }
    }
    if (strlen($namespace) == 0) {
        $namespace = NS_MAIN;
    }
    $title = null;
    if ($pageTitle) {
        $title = Title::newFromText($pageTitle, $namespace);
        if ($title) {
            $pageTitle = $title->getText();
            $namespace = $title->getNamespace();
            // if not choosing and the title exists, go there now
            if (!$id && $title->exists()) {
                $wgOut->redirect($title->getFullURL());
                return;
            }
        }
    }
    $nsSelector = HTMLnamespaceselector($namespace);
    // set up page
    $wgOut->setPagetitle($id ? 'Choose page' : 'Go to page');
    $wgOut->setArticleRelated(false);
    $wgOut->setRobotpolicy('noindex,nofollow');
    // add javascript functions
    $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/gotopage.js\"></script>");
    //!!! must turn this into a document ready call
    $wgOut->setOnloadHandler("gpInit('{$id}')");
    // set up alpha links
    $alphaLinks = '';
    $c = 'A';
    for ($i = 0; $i < 26; $i++) {
        $alphaLinks .= "&nbsp;<a title=\"{$c}\" href=\"javascript:gpGo('{$c}')\">{$c}</a>\n";
        $c++;
    }
    // !!! set up table
    $tableRows = '';
    $sk = $wgUser->getSkin();
    $dbr =& wfGetDB(DB_SLAVE);
    if ($scope == 'all') {
        $rows = $dbr->select('page', array('page_title'), array('page_namespace' => $namespace, 'page_title >= ' . ($title ? $dbr->addQuotes($title->getDBkey()) : "''")), 'wfSpecialGotoPage', array('LIMIT' => 11, 'ORDER BY' => 'page_title'));
    } else {
        $rows = $dbr->select('watchlist', array('wl_title'), array('wl_user' => $wgUser->getID(), 'wl_namespace' => $namespace, 'wl_title >= ' . ($title ? $dbr->addQuotes($title->getDBkey()) : "''")), 'wfSpecialGotoPage', array('LIMIT' => 11, 'ORDER BY' => 'wl_title'));
    }
    $nextDisplay = 'none';
    $prevDisplay = $pageTitle ? 'inline' : 'none';
    $cnt = 0;
    while ($row = $dbr->fetchRow($rows)) {
        if ($cnt == 10) {
            $nextDisplay = 'inline';
            break;
        }
        $t = Title::makeTitleSafe($namespace, $row[0]);
        if ($t) {
            if ($id) {
                $link = "<a href=\"javascript:gpReturn({$cnt})\">" . htmlspecialchars($t->getText()) . '</a>';
            } else {
                $link = $sk->makeKnownLinkObj($t, htmlspecialchars($t->getText()));
            }
            $tableRows .= "<tr><td align=\"left\">{$link}</td></tr>\n";
        }
        $cnt++;
    }
    $dbr->freeResult($rows);
    while ($cnt < 10) {
        $tableRows .= "<tr><td></td></tr>\n";
        $cnt++;
    }
    // set up scope
    if ($scope == 'all') {
        $watchedSelected = '';
        $allSelected = ' checked';
    } else {
        $watchedSelected = ' checked';
        $allSelected = '';
    }
    // set up namespace selector
    $nsDisabled = $id ? ' disabled' : '';
    $nsSelector = str_replace('<select ', "<select onChange=\"gpGo('')\"{$nsDisabled} ", $nsSelector);
    // set up form action
    $onSubmit = '';
    if ($id) {
        $onSubmit = ' onSubmit="gpGo(\'\'); return false;"';
    }
    // add form
    $wgOut->addHTML(<<<END
<center>
<div class="gotopage">
<form name="goto" action="/wiki/Special:GotoPage" method="get"{$onSubmit}>
<table style="margin: 0 .5em 1em .5em">
<tr><td></td><td align="left"><input type="radio" name="scope" value="watched"{$watchedSelected} onChange="gpGo('')"> Watched pages
<input type="radio" name="scope" value="all"{$allSelected} onChange="gpGo('')"> All pages</td></tr>
<tr><td align="right">Namespace:</td><td align="left">{$nsSelector}
<span id="pleasewait" style="display: none"><span style="padding: 0 .2em; color: #fff; background-color: #888">Please Wait</span></span>
</td></tr>
<tr><td align="right">Title:</td><td align="left"><input id="titleinput" type="text" name="pagetitle" size="25" maxlength="150" value="{$pageTitle}"/>
<input type="submit" name="go" value="Go"/>
</td></tr>
<tr><td></td><td style="margin: 0; padding: 0; line-height: .7em; font-size: 80%;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Title is case-sensitive</td></tr>
</table>
</form>
</div>
{$alphaLinks}
<div id="message">Choose a page from the list</div>
<table id="results" align="center">
<tr><td align="center"><span id="prevlink" style="display: {$prevDisplay}"><a title="Previous page" href="javascript:gpPrev()">< Prev</a></span> &nbsp;&nbsp;&nbsp;
<span id="nextlink" style="display: {$nextDisplay}"><a title="Next page" href="javascript:gpNext()">Next ></a></span></td></tr>
{$tableRows}
<tr><td align="center"><span id="prevlink2" style="display: {$prevDisplay}"><a title="Previous page" href="javascript:gpPrev()">< Prev</a></span> &nbsp;&nbsp;&nbsp;
<span id="nextlink2" style="display: {$nextDisplay}"><a title="Next page" href="javascript:gpNext()">Next ></a></span></td></tr>
</table>
</center>
END
);
}
コード例 #12
0
ファイル: SpecialBrowse.php プロジェクト: k-hasan-19/wiki
function wfSpecialBrowse()
{
    global $wgOut, $wgRequest, $wgUser, $wgScriptPath;
    $scope = $wgRequest->getVal('scope');
    $namespace = $wgRequest->getVal('namespace');
    $pageTitle = $wgRequest->getVal('pagetitle');
    // default namespace
    if (strlen($namespace) == 0) {
        $namespace = NS_MAIN;
    }
    // default scope
    if (!$scope) {
        $scope = 'all';
    }
    // get title
    $title = null;
    if ($pageTitle) {
        $title = Title::newFromText($pageTitle, $namespace);
        if ($title) {
            $pageTitle = $title->getText();
            $namespace = $title->getNamespace();
        }
    }
    // set up page
    $wgOut->setPagetitle('Browse Pages');
    $wgOut->setArticleRelated(false);
    $wgOut->setRobotpolicy('noindex,nofollow');
    $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/browse.5.js\"></script>");
    // set up alpha links
    $alphaLinks = '';
    $c = 'A';
    for ($i = 0; $i < 26; $i++) {
        $alphaLinks .= "&nbsp;<a title=\"{$c}\" href=\"javascript:void(0)\" onClick=\"browseGo('{$c}'); return preventDefaultAction(event);\">{$c}</a>\n";
        $c++;
    }
    $tableRows = '';
    $sk = $wgUser->getSkin();
    $dbr =& wfGetDB(DB_SLAVE);
    if ($scope == 'all') {
        $rows = $dbr->select('page', array('page_title'), array('page_namespace' => $namespace, 'page_is_redirect' => '0', 'page_title >= ' . ($title ? $dbr->addQuotes($title->getDBkey()) : "''")), 'wfSpecialBrowse', array('LIMIT' => 11, 'ORDER BY' => 'page_title'));
    } else {
        $rows = $dbr->select('watchlist', array('wl_title'), array('wl_user' => $wgUser->getID(), 'wl_namespace' => $namespace, 'wl_title >= ' . ($title ? $dbr->addQuotes($title->getDBkey()) : "''")), 'wfSpecialBrowse', array('LIMIT' => 11, 'ORDER BY' => 'wl_title'));
    }
    $nextDisplay = 'none';
    $prevDisplay = $pageTitle ? 'inline' : 'none';
    $cnt = 0;
    while ($row = $dbr->fetchRow($rows)) {
        if ($cnt == 10) {
            $nextDisplay = 'inline';
            break;
        }
        $t = Title::makeTitleSafe($namespace, $row[0]);
        if ($t) {
            $link = $sk->makeKnownLinkObj($t, htmlspecialchars($t->getText()));
            $tableRows .= "<tr><td align=\"left\">{$link}</td></tr>\n";
        }
        $cnt++;
    }
    $dbr->freeResult($rows);
    while ($cnt < 10) {
        $tableRows .= "<tr><td></td></tr>\n";
        $cnt++;
    }
    // set up scope
    if ($scope == 'all') {
        $watchedSelected = '';
        $allSelected = ' checked';
    } else {
        $watchedSelected = ' checked';
        $allSelected = '';
    }
    // set up namespace selector
    $nsSelector = str_replace('<select ', "<select onChange=\"browseChangeNs('')\" ", HTMLnamespaceselector($namespace));
    // add form
    $sideText = $wgOut->parse(<<<END
Browse pages in your watchlist (typically includes all pages that you have created or edited), or browse all pages on WeRelate.

''Namespace'' corresponds to the type of page; e.g., Main (articles), Person, Family, or Image.  

Each type of page also has an associated "talk" page. Browse talk pages by selecting the corresponding Talk namespace.
END
);
    $wgOut->addHTML(<<<END
<center>
<div class="browse">
<form name="browse" action="/wiki/Special:Browse" method="get">
<table style="margin: 0 .5em 1em .5em">
<tr><td></td><td align="left"><input type="radio" name="scope" value="watched"{$watchedSelected} onChange="browseGo('')"> Watched pages
<input type="radio" name="scope" value="all"{$allSelected} onChange="browseGo('')"> All pages</td></tr>
<tr><td align="right">Namespace:</td><td align="left">{$nsSelector}
<span id="pleasewait" style="display: none"><span style="padding: 0 .2em; color: #fff; background-color: #888">Please Wait</span></span>
</td></tr>
<tr><td align="right">Title:</td><td align="left"><input id="titleinput" type="text" name="pagetitle" size="25" maxlength="150" value="{$pageTitle}"/>
<input type="submit" name="go" value="Go"/>
</td></tr>
<tr><td></td><td style="margin: 0; padding: 0; line-height: .7em; font-size: 80%;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Title is case-sensitive</td></tr>
</table>
</form>
</div>
{$alphaLinks}
<div id="message">Choose a page from the list</div>
<table id="results" align="center">
<tr><td align="center"><span id="prevlink" style="display: {$prevDisplay}"><a title="Previous page" href="javascript:void(0)" onClick="browsePrev(); return preventDefaultAction(event);">< Prev</a></span> &nbsp;&nbsp;&nbsp;
<span id="nextlink" style="display: {$nextDisplay}"><a title="Next page" href="javascript:void(0)" onClick="browseNext(); return preventDefaultAction(event);">Next ></a></span></td></tr>
{$tableRows}
<tr><td align="center"><span id="prevlink2" style="display: {$prevDisplay}"><a title="Previous page" href="javascript:void(0)" onClick="browsePrev(); return preventDefaultAction(event);">< Prev</a></span> &nbsp;&nbsp;&nbsp;
<span id="nextlink2" style="display: {$nextDisplay}"><a title="Next page" href="javascript:void(0)" onClick="browseNext(); return preventDefaultAction(event);">Next ></a></span></td></tr>
</table>
</center>
END
);
}