当前位置: 首页>>代码示例>>PHP>>正文


PHP Title::newFromUrl方法代码示例

本文整理汇总了PHP中Title::newFromUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::newFromUrl方法的具体用法?PHP Title::newFromUrl怎么用?PHP Title::newFromUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Title的用法示例。


在下文中一共展示了Title::newFromUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handleImageFeedback

 private function handleImageFeedback()
 {
     global $wgRequest, $wgOut, $wgName, $wgUser;
     $dbw = wfGetDB(DB_MASTER);
     $reason = $wgRequest->getVal('reason');
     // Remove / chars from reason since this will be our delimeter in the ii_reason field
     $reason = $dbw->strencode(trim(str_replace("/", "", $reason)));
     // Add user who reported
     $reason = $wgUser->getName() . " says: {$reason}";
     $voteTypePrefix = $wgRequest->getVal('voteType') == 'good' ? 'ii_good' : 'ii_bad';
     $aid = $dbw->addQuotes($wgRequest->getVal('aid'));
     $imgUrl = substr(trim($wgRequest->getVal('imgUrl')), 1);
     $isWikiPhotoImg = 0;
     // Check if image is a wikiphoto image
     $t = Title::newFromUrl($imgUrl);
     if ($t && $t->exists()) {
         $r = Revision::newFromTitle($t);
         $userText = $r->getUserText();
         if (strtolower($r->getUserText()) == self::WIKIPHOTO_USER_NAME) {
             $isWikiPhotoImg = 1;
         }
         $url = substr($t->getLocalUrl(), 1);
         $voteField = $voteTypePrefix . "_votes";
         $reasonField = $voteTypePrefix . "_reasons";
         $sql = "INSERT INTO image_feedback \n\t\t\t\t(ii_img_page_id, ii_wikiphoto_img, ii_page_id, ii_img_url, {$voteField}, {$reasonField}) VALUES \n\t\t\t\t({$t->getArticleId()}, {$isWikiPhotoImg}, {$aid}, '{$url}', 1, '{$reason}') \n\t\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\t{$voteField} = {$voteField} + 1, {$reasonField} = CONCAT({$reasonField}, '/{$reason}')";
         $dbw->query($sql, __METHOD__);
         $wgOut->setArticleBodyOnly(true);
     }
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:29,代码来源:ImageFeedback.body.php

示例2: urlFunction

 static function urlFunction($func, $s = '', $arg = null)
 {
     $found = false;
     $title = Title::newFromText($s);
     # Due to order of execution of a lot of bits, the values might be encoded
     # before arriving here; if that's true, then the title can't be created
     # and the variable will fail. If we can't get a decent title from the first
     # attempt, url-decode and try for a second.
     if (is_null($title)) {
         $title = Title::newFromUrl(urldecode($s));
     }
     if (!is_null($title)) {
         if (!is_null($arg)) {
             $text = $title->{$func}($arg);
         } else {
             $text = $title->{$func}();
         }
         $found = true;
     }
     if ($found) {
         return $text;
     } else {
         return array('found' => false);
     }
 }
开发者ID:k-hasan-19,项目名称:wiki,代码行数:25,代码来源:CoreParserFunctions.php

示例3: revertList

 public function revertList($list, $revertUser)
 {
     global $wgServer, $wgLanguageCode;
     $results = array();
     foreach ($list as $l) {
         if (preg_match('@^http://(.+)\\.wikihow\\.com/(.+)@', $l, $matches)) {
             if (!($wgLanguageCode == "en" && $matches[1] == "www" || $matches[1] == $wgLanguageCode)) {
                 $results[] = array('url' => $l, 'success' => false, 'msg' => "Invalid URL for language");
             } else {
                 $link = $matches[2];
                 $title = Title::newFromUrl($link);
                 $article = new Article($title);
                 if ($article && $article->exists()) {
                     $ret = $article->commitRollback($revertUser, wfMsg("mass-revert-message"), TRUE, $resultDetails);
                     if (empty($ret)) {
                         $results[] = array('url' => $l, 'success' => true);
                     } else {
                         $results[] = array('url' => $l, 'success' => false, 'msg' => $ret[0][0]);
                     }
                 } else {
                     $results[] = array('url' => $l, 'success' => false, 'msg' => "Article not found");
                 }
             }
         } else {
             $results[] = array('url' => $l, 'success' => false, 'msg' => "Bad URL");
         }
     }
     return $results;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:29,代码来源:RevertTool.body.php

示例4: execute

 function execute($par)
 {
     global $wgUser, $wgRequest;
     $this->setHeaders();
     if (!$this->userCanExecute($wgUser)) {
         $this->displayRestrictionError();
         return;
     }
     $this->outputHeader();
     // For live revisions
     $this->mRevisions = (array) $wgRequest->getIntArray('revision');
     // For deleted/archived revisions
     $this->mTarget = Title::newFromUrl($wgRequest->getVal('target'));
     $this->mTimestamps = (array) $wgRequest->getArray('timestamp');
     if (is_null($this->mTarget)) {
         // title and timestamps must go together
         $this->mTimestamps = array();
     }
     $this->mPopulated = !empty($this->mRevisions) || !empty($this->mTimestamps);
     $this->mReason = $wgRequest->getText('wpReason');
     $submitted = $wgRequest->wasPosted() && $wgRequest->getVal('action') == 'submit' && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'));
     if ($this->mPopulated && $submitted) {
         $this->submit();
     } elseif ($this->mPopulated) {
         $this->showForm();
     } else {
         $this->showEmpty();
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:29,代码来源:HideRevision_body.php

示例5: __construct

 /**
  * @param Title $page
  * @param int $oldid
  */
 function __construct($request)
 {
     global $wgUser;
     $target = $request->getVal('target');
     $this->page = Title::newFromUrl($target);
     $this->revisions = $request->getIntArray('oldid', array());
     $this->skin = $wgUser->getSkin();
     $this->checks = array(array('revdelete-hide-text', 'wpHideText', Revision::DELETED_TEXT), array('revdelete-hide-comment', 'wpHideComment', Revision::DELETED_COMMENT), array('revdelete-hide-user', 'wpHideUser', Revision::DELETED_USER), array('revdelete-hide-restricted', 'wpHideRestricted', Revision::DELETED_RESTRICTED));
 }
开发者ID:puring0815,项目名称:OpenKore,代码行数:13,代码来源:SpecialRevisiondelete.php

示例6: wfSpecialRevisiondelete

/**
 * Special page allowing users with the appropriate permissions to view
 * and hide revisions. Log items can also be hidden.
 *
 * @file
 * @ingroup SpecialPage
 */
function wfSpecialRevisiondelete($par = null)
{
    global $wgOut, $wgRequest, $wgUser;
    # Handle our many different possible input types
    $target = $wgRequest->getText('target');
    $oldid = $wgRequest->getArray('oldid');
    $artimestamp = $wgRequest->getArray('artimestamp');
    $logid = $wgRequest->getArray('logid');
    $img = $wgRequest->getArray('oldimage');
    $fileid = $wgRequest->getArray('fileid');
    # For reviewing deleted files...
    $file = $wgRequest->getVal('file');
    # If this is a revision, then we need a target page
    $page = Title::newFromUrl($target);
    if (is_null($page)) {
        $wgOut->addWikiMsg('undelete-header');
        return;
    }
    # Only one target set at a time please!
    $i = (bool) $file + (bool) $oldid + (bool) $logid + (bool) $artimestamp + (bool) $fileid + (bool) $img;
    if ($i !== 1) {
        $wgOut->showErrorPage('revdelete-nooldid-title', 'revdelete-nooldid-text');
        return;
    }
    # Logs must have a type given
    if ($logid && !strpos($page->getDBKey(), '/')) {
        $wgOut->showErrorPage('revdelete-nooldid-title', 'revdelete-nooldid-text');
        return;
    }
    # Either submit or create our form
    $form = new RevisionDeleteForm($page, $oldid, $logid, $artimestamp, $fileid, $img, $file);
    if ($wgRequest->wasPosted()) {
        $form->submit($wgRequest);
    } else {
        if ($oldid || $artimestamp) {
            $form->showRevs();
        } else {
            if ($fileid || $img) {
                $form->showImages();
            } else {
                if ($logid) {
                    $form->showLogItems();
                }
            }
        }
    }
    # Show relevant lines from the deletion log. This will show even if said ID
    # does not exist...might be helpful
    $wgOut->addHTML("<h2>" . htmlspecialchars(LogPage::logName('delete')) . "</h2>\n");
    LogEventsList::showLogExtract($wgOut, 'delete', $page->getPrefixedText());
    if ($wgUser->isAllowed('suppressionlog')) {
        $wgOut->addHTML("<h2>" . htmlspecialchars(LogPage::logName('suppress')) . "</h2>\n");
        LogEventsList::showLogExtract($wgOut, 'suppress', $page->getPrefixedText());
    }
}
开发者ID:amjadtbssm,项目名称:website,代码行数:62,代码来源:SpecialRevisiondelete.php

示例7: __construct

 function __construct()
 {
     global $wgRequest, $wgMiserMode;
     if ($wgRequest->getText('sort', 'img_date') == 'img_date') {
         $this->mDefaultDirection = true;
     } else {
         $this->mDefaultDirection = false;
     }
     $search = $wgRequest->getText('ilsearch');
     if ($search != '' && !$wgMiserMode) {
         $nt = Title::newFromUrl($search);
         if ($nt) {
             $dbr = wfGetDB(DB_SLAVE);
             $m = $dbr->strencode(strtolower($nt->getDBkey()));
             $m = str_replace("%", "\\%", $m);
             $m = str_replace("_", "\\_", $m);
             $this->mQueryConds = array("LOWER(img_name) LIKE '%{$m}%'");
         }
     }
     parent::__construct();
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:21,代码来源:SpecialListfiles.php

示例8: execute

 function execute($par)
 {
     global $wgRequest, $wgOut, $wgTitle;
     $param = $wgRequest->getText('param');
     $parcheck = $wgRequest->getText('parcheck');
     $action = $wgTitle->getFullURL();
     $description = wfMsgExt('checksite-description', array('parse'));
     $label = wfMsgExt('checksite-label', array('parseinline'));
     $submit = wfMsg('checksite-submit');
     $post = "\n\t\t\t<form action=\"{$action}\" method=\"get\">\n\t\t\t{$description}\n\t\t\t{$label}\n\t\t\t<input type=\"text\" name=\"parcheck\" value=\"{$param}\" size=\"40\" maxlength=\"80\" />\n\t\t\t<input type=\"submit\" value=\"{$submit}\" />\n\t\t\t</form>";
     $this->setHeaders();
     if (!isset($parcheck) || strlen($parcheck) < 5) {
         $wgOut->addHTML($post);
         return;
     }
     $newdom = check_validate_domain($parcheck);
     if (!$newdom) {
         $parcheck = htmlspecialchars($parcheck);
         $wgOut->addWikiMsg('checksite-cant-check', $parcheck);
         return;
     }
     $newpage = $newdom;
     $newpage[0] = strtoupper($newpage[0]);
     $title = Title::newFromUrl($newpage);
     if (!is_object($title)) {
         $wgOut->addWikiMsg('checksite-not-found', $newpage);
         return;
     }
     if (!$title->exists()) {
         $wgOut->addWikiMsg('checksite-not-exist', $newpage);
         return;
     }
     $newhost = check_get_host($newdom);
     if (!$newhost) {
         $wgOut->addWikiMsg('checksite-url-not-found', $newdom);
         return;
     }
     if ($rob = @fopen("http://{$newhost}/robots.txt", 'r')) {
         $txt = fread($rob, 4096);
         while (!feof($rob)) {
             $txt .= fread($rob, 4096);
             if (strlen($txt) > 20000) {
                 break;
             }
         }
         fclose($rob);
         if (eregi("User-agent:[ \t\n]*WebsiteWiki[ \t\r\n]*Disallow:[ \t\r\n]*/", $txt)) {
             global $wgUser;
             $output = wfMsg('checksite-robots', $newhost, $newpage);
             $orgUser = $wgUser;
             //TODO: should this hardcoded user be here?
             $wgUser = User::newFromName('Sysop');
             $article = new Article($title);
             $restrict = array('edit' => 'sysop', 'move' => 'sysop');
             $article->updateRestrictions($restrict, $output);
             $redirectUrl = wfMsg('checksite-redirect-url');
             $redirectComment = wfMsg('checksite-redirect-comment');
             $article->updateArticle("#REDIRECT [[{$redirectUrl}]]", $redirectComment, false, false);
             $wgUser = $orgUser;
             return;
         }
     }
     //TODO: check if this hardcoded URL should remain here
     if (stristr($newhost, 'duckshop.de')) {
         $wgOut->addWikiMsg('checksite-screenshot-error');
         return;
     }
     $output = wfMsg('checksite-screenshot-updating', $newpage);
     /**
      * @todo -- lines below do nothing, so why they are there?
      * 
      * $url = fopen("http://thumbs.websitewiki.de/newthumb.php?name=$newdom", 'r');
      * fclose($url);
      */
     # Output
     $wgOut->addHTML($output);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:77,代码来源:Checksite.body.php

示例9: execute

 function execute($par)
 {
     global $wgOut, $wgRequest, $wgParser, $wgUser, $wgFilterCallback, $wgCookiePath, $wgCookieDomain, $wgCookieSecure;
     $wgOut->disable();
     // build the article which we are about to save
     $t = Title::newFromUrl($wgRequest->getVal('target'));
     $a = new Article($t);
     $action = $wgRequest->getVal('eaction');
     wfDebug("Html5Editor::execute called with {$action}\n");
     // process the edit update
     if ($action == 'get-vars') {
         $wgOut->disable();
         $response = array('edittoken' => $wgUser->editToken(), 'edittime' => $a->getTimestamp(true), 'drafttoken' => wfGenerateToken(), 'olddraftid' => 0);
         // do they already have a draft saved?
         $drafts = Draft::getDrafts($t, $wgUser->getID());
         if ($drafts) {
             // do we only select an html5 draft? probably not.
             // for loop here in  case we want to display multiple drafts of same article
             $response['olddraftid'] = $drafts[0]->getID();
         }
         print json_encode($response);
         return;
     } else {
         if ($action == 'load-draft') {
             $draftid = $wgRequest->getVal('draftid');
             $draft = new Draft($draftid);
             if (!$draft->exists()) {
                 wfLoadExtensionMessages("Html5editor");
                 $response = array('error' => wfMsg('h5e-draft-does-not-exist', $draftid), 'html' => '');
                 wfDebug("DRAFT: {$draftid} does not exist \n");
             } else {
                 $text = $draft->getText();
                 $html = $this->parse($t, $a, $text);
                 $response = array(error => '', 'html' => $html);
             }
             print json_encode($response);
             return;
         } else {
             if ($action == 'save-draft') {
                 $token = $wgRequest->getVal('edittoken');
                 if ($wgUser->matchEditToken($token)) {
                     wfDebug("Html5Editor::execute save-draft edit token ok!\n");
                     $oldtext = $a->getContent();
                     $html = $wgRequest->getVal('html');
                     $newtext = $this->convertHTML2Wikitext($html, $oldtext);
                     $draftid = $wgRequest->getVal('draftid', null);
                     $draft = null;
                     // 'null' apparently is what javascript is giving us. doh.
                     if (!$draftid || preg_match("@[^0-9]@", $draftid)) {
                         wfDebug("Html5Editor::execute getting draft id from title \n");
                         $draftid = self::getDraftIDFromTitle($t);
                     }
                     if (!$draftid || $draftid == 'null') {
                         $draft = new Draft();
                     } else {
                         $draft = Draft::newFromID($draftid);
                     }
                     wfDebug("Html5Editor::execute got draft id {$draftid} \n");
                     $draft->setTitle($t);
                     //$draft->setStartTime( $wgRequest->getText( 'wpStarttime' ) );
                     $draft->setEditTime($wgRequest->getText('edittime'));
                     $draft->setSaveTime(wfTimestampNow());
                     $draft->setText($newtext);
                     $draft->setSummary($wgRequest->getText('editsummary'));
                     $draft->setHtml5(true);
                     //$draft->setMinorEdit( $wgRequest->getInt( 'wpMinoredit', 0 ) );
                     // Save draft
                     $draft->save();
                     wfDebug("Html5Editor::execute saved draft with id {$draft->getID()} and text {$newtext} \n");
                     $response = array('draftid' => $draft->getID());
                     print json_encode($response);
                     return;
                 } else {
                     wfDebug("Html5Editor::execute save-draft edit token BAD {$token} \n");
                     $response = array('error' => 'edit token bad');
                     print json_encode($response);
                     return;
                 }
                 return;
             } else {
                 if ($action == 'save-summary') {
                     // this implementation could have a few problems
                     // 1. if a user is editing the article in separate windows, it will
                     //		only update the last edit
                     // 2. Could be easy to fake an edit summary save, but is limited to
                     // edits made by the user
                     /// 3. There's no real 'paper' trail of the saved summary
                     // grab the cookie with the rev_id
                     global $wgCookiePrefix;
                     if (isset($_COOKIE["{$wgCookiePrefix}RevId" . $t->getArticleID()])) {
                         $revid = $_COOKIE["{$wgCookiePrefix}RevId" . $t->getArticleID()];
                         wfDebug("AXX: updating revcomment {$revid} \n");
                         $dbw = wfGetDB(DB_MASTER);
                         $summary = "updating from html5 editor, " . $wgRequest->getVal('summary');
                         $dbw->update('revision', array('rev_comment' => $summary), array('rev_id' => $revid, 'rev_user_text' => $wgUser->getName()), "Html5Editor::saveComment", array("LIMIT" => 1));
                         $dbw->update('recentchanges', array('rc_comment' => $summary), array('rc_this_oldid' => $revid, 'rc_user_text' => $wgUser->getName()), "Html5Editor::saveComment", array("LIMIT" => 1));
                     } else {
                         wfDebug("AXX: NOT updating revcomment, why\n");
                     }
                     return;
//.........这里部分代码省略.........
开发者ID:biribogos,项目名称:wikihow-src,代码行数:101,代码来源:Html5editor.body.php

示例10: wfSpecialNewimages

/**
 *
 */
function wfSpecialNewimages()
{
    global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest;
    $wpIlMatch = $wgRequest->getText('wpIlMatch');
    $dbr =& wfGetDB(DB_SLAVE);
    $sk = $wgUser->getSkin();
    /** If we were clever, we'd use this to cache. */
    $latestTimestamp = wfTimestamp(TS_MW, $dbr->selectField('image', 'img_timestamp', '', 'wfSpecialNewimages', array('ORDER BY' => 'img_timestamp DESC', 'LIMIT' => 1)));
    /** Hardcode this for now. */
    $limit = 48;
    $where = array();
    if ($wpIlMatch != '') {
        $nt = Title::newFromUrl($wpIlMatch);
        if ($nt) {
            $m = $dbr->strencode(strtolower($nt->getDBkey()));
            $m = str_replace('%', "\\%", $m);
            $m = str_replace('_', "\\_", $m);
            $where[] = "LCASE(img_name) LIKE '%{$m}%'";
        }
    }
    $invertSort = false;
    if ($until = $wgRequest->getVal('until')) {
        $where[] = 'img_timestamp < ' . $dbr->timestamp($until);
    }
    if ($from = $wgRequest->getVal('from')) {
        $where[] = 'img_timestamp >= ' . $dbr->timestamp($from);
        $invertSort = true;
    }
    $res = $dbr->select('image', array('img_size', 'img_name', 'img_user', 'img_user_text', 'img_description', 'img_timestamp'), $where, 'wfSpecialNewimages', array('LIMIT' => $limit + 1, 'ORDER BY' => 'img_timestamp' . ($invertSort ? '' : ' DESC')));
    /**
     * We have to flip things around to get the last N after a certain date
     */
    $images = array();
    while ($s = $dbr->fetchObject($res)) {
        if ($invertSort) {
            array_unshift($images, $s);
        } else {
            array_push($images, $s);
        }
    }
    $dbr->freeResult($res);
    $gallery = new ImageGallery();
    $firstTimestamp = null;
    $lastTimestamp = null;
    $shownImages = 0;
    foreach ($images as $s) {
        if (++$shownImages > $limit) {
            # One extra just to test for whether to show a page link;
            # don't actually show it.
            break;
        }
        $name = $s->img_name;
        $ut = $s->img_user_text;
        $nt = Title::newFromText($name, NS_IMAGE);
        $img = Image::newFromTitle($nt);
        $ul = $sk->makeLinkObj(Title::makeTitle(NS_USER, $ut), $ut);
        $gallery->add($img, "{$ul}<br />\n<i>" . $wgLang->timeanddate($s->img_timestamp, true) . "</i><br />\n");
        $timestamp = wfTimestamp(TS_MW, $s->img_timestamp);
        if (empty($firstTimestamp)) {
            $firstTimestamp = $timestamp;
        }
        $lastTimestamp = $timestamp;
    }
    $bydate = wfMsg('bydate');
    $lt = $wgLang->formatNum(min($shownImages, $limit));
    $text = wfMsg("imagelisttext", "<strong>{$lt}</strong>", "<strong>{$bydate}</strong>");
    $wgOut->addHTML("<p>{$text}\n</p>");
    $sub = wfMsg('ilsubmit');
    $titleObj = Title::makeTitle(NS_SPECIAL, 'Newimages');
    $action = $titleObj->escapeLocalURL("limit={$limit}");
    $wgOut->addHTML("<form id=\"imagesearch\" method=\"post\" action=\"" . "{$action}\">" . "<input type='text' size='20' name=\"wpIlMatch\" value=\"" . htmlspecialchars($wpIlMatch) . "\" /> " . "<input type='submit' name=\"wpIlSubmit\" value=\"{$sub}\" /></form>");
    $here = $wgContLang->specialPage('Newimages');
    /**
     * Paging controls...
     */
    $now = wfTimestampNow();
    $date = $wgLang->timeanddate($now);
    $dateLink = $sk->makeKnownLinkObj($titleObj, wfMsg('rclistfrom', $date), 'from=' . $now);
    $prevLink = wfMsg('prevn', $wgLang->formatNum($limit));
    if ($firstTimestamp && $firstTimestamp != $latestTimestamp) {
        $prevLink = $sk->makeKnownLinkObj($titleObj, $prevLink, 'from=' . $firstTimestamp);
    }
    $nextLink = wfMsg('nextn', $wgLang->formatNum($limit));
    if ($shownImages > $limit && $lastTimestamp) {
        $nextLink = $sk->makeKnownLinkObj($titleObj, $nextLink, 'until=' . $lastTimestamp);
    }
    $prevnext = '<p>' . wfMsg('viewprevnext', $prevLink, $nextLink, $dateLink) . '</p>';
    $wgOut->addHTML($prevnext);
    if (count($images)) {
        $wgOut->addHTML($gallery->toHTML());
        $wgOut->addHTML($prevnext);
    } else {
        $wgOut->addWikiText(wfMsg('noimages'));
    }
}
开发者ID:BackupTheBerlios,项目名称:openzaurus-svn,代码行数:98,代码来源:SpecialNewimages.php

示例11: execute


//.........这里部分代码省略.........
                    $aid = $user_talk->getArticleId();
                    if ($aid > 0) {
                        $r = Revision::newFromTitle($user_talk);
                        $text = $r->getText();
                    }
                    $a = new Article($user_talk);
                    $text .= "\n\n{$formattedComment}\n\n";
                    if ($aid > 0) {
                        $a->updateArticle($text, "", true, false, false, '', true);
                    } else {
                        $a->insertNewArticle($text, "", true, false, true, false, false);
                    }
                    // MARK CHANGES PATROLLED
                    //
                    //
                    $res = $dbr->select('recentchanges', 'max(rc_id) as rc_id', array('rc_title=\'' . mysql_real_escape_string($utitem) . '\'', 'rc_user=' . $wgUser->getID(), 'rc_cur_id=' . $aid, 'rc_patrolled=0'));
                    while ($row = $dbr->fetchObject($res)) {
                        wfDebug("UTT: mark patroll rcid: " . $row->rc_id . " \n");
                        RecentChange::markPatrolled($row->rc_id);
                        PatrolLog::record($row->rc_id, false);
                    }
                    $dbr->freeResult($res);
                    wfDebug("UTT: done\n");
                    wfDebug("UTT: Completed posting for [" . $utitem . "]\n");
                    $wgOut->addHTML("Completed posting for - " . $utitem);
                } else {
                    wfDebug("UTT: No user\n");
                    $wgOut->addHTML("UT_MSG ERROR: No user specified. \n");
                }
            } else {
                wfDebug("UTT: No message to post\n");
                $wgOut->addHTML("UT_MSG ERROR: No message to post for - " . $utitem . "\n");
                return;
            }
            $wgOut->redirect('');
        } else {
            $sk = $wgUser->getSkin();
            $wgOut->addHTML('
<script language="javascript" src="/extensions/wikihow/common/prototype1.8.2/prototype.js"></script>
<script language="javascript" src="/extensions/wikihow/common/prototype1.8.2/effects.js"></script>
<script language="javascript" src="/extensions/wikihow/common/prototype1.8.2/controls.js"></script>
		' . "\n");
            $wgOut->addHTML("\n\t\t\t<script type='text/javascript'>\n\t\t\t\tfunction utSend () {\n\n\t\t\t\t\t\$('formdiv').style.display = 'none';\n\t\t\t\t\t\$('resultdiv').innerHTML = 'Sending...<br />';\n\n\t\t\t\t\tliArray = document.getElementById('ut_ol').childNodes;\n\t\t\t\t\ti=0;\n\t\t\t\t\twhile(liArray[i]){\n\t\t\t\t\t\tif (document.getElementById(liArray[i].id)) {\n\t\t\t\t\t\t\tif (liArray[i].getAttribute('id').match(/^ut_li_/)) {\n\n\t\t\t\t\t\t\t\tdocument.forms['utForm'].utuser.value = liArray[i].getAttribute('id').replace('ut_li_','');\n\t\t\t\t\t\t\t\t\$('utForm').request({\n\t\t\t\t\t\t\t\t\tasynchronous: false,\n\t\t\t\t\t\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\t\t\t\t\t\t\$('resultdiv').innerHTML += transport.responseText+'<br />';\n\t\t\t\t\t\t\t\t\t\tif (transport.responseText.match(/Completed posting for - /)){\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\tvar u = transport.responseText.replace(/Completed posting for - /,'');\n\t\t\t\t\t\t\t\t\t\t\t//\$('resultdiv').innerHTML += 'UID: '+u+'<br />';\n\t\t\t\t\t\t\t\t\t\t\t\$('ut_li_'+u).innerHTML +=  '  <img src=\"/skins/WikiHow/light_green_check.png\" height=\"15\" width=\"15\" />';\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tonFailure: function(transport) {\n\t\t\t\t\t\t\t\t\t\t\$('resultdiv').innerHTML += 'Sending returned error for '+liArray[i].id+' <br />';\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t//\$('resultdiv').innerHTML += 'Sending '+liArray[i].id+'<br />';\n\t\t\t\t\t\t \t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\ti++;\n\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t</script>\n\t\t\t\n\t\t\t");
            // GET LIST OF RECIPIENTS
            //
            //
            if ($target) {
                $t = Title::newFromUrl($target);
                if ($t->getArticleId() <= 0) {
                    $wgOut->addHTML("Target not a valid article.");
                    return;
                } else {
                    $r = Revision::newFromTitle($t);
                    $text = $r->getText();
                    #$wgOut->addHTML( $text );
                    $utcount = preg_match_all('/\\[\\[User_talk:(.*?)[#\\]\\|]/', $text, $matches);
                    #print_r($matches);
                    $utlist = $matches[1];
                }
            }
            // DISPLAY COUNT OF USER TALK PAGES FOUND
            //
            //
            if (count($utlist) == 0) {
                $wgOut->addHTML(wfMsg('notalkpagesfound'));
                return;
            } else {
                $wgOut->addHTML(count($utlist) . ' ' . wfMsg('talkpagesfound') . "<br />");
            }
            // TEXTAREA and FORM
            //
            //
            $wgOut->addHTML('
<form id="utForm" method="post">
				');
            // DISPLAY LIST OF USER TALK PAGES
            //
            //
            $wgOut->addHTML('<div id="utlist" style="border: 1px grey solid;margin: 15px 0px 15px 0px;padding: 15px;height:215px;overflow:auto"><ol id="ut_ol">' . "\n");
            foreach ($utlist as $utitem) {
                $wgOut->addHTML('<li id="ut_li_' . preg_replace('/\\s/m', '-', $utitem) . '"><a href="/User_talk:' . $utitem . '">' . $utitem . '</a></li>' . "\n");
            }
            $wgOut->addHTML('</ol></div>' . "\n");
            // TEXTAREA and FORM
            //
            //
            $wgOut->addHTML('
<div id="formdiv">
' . wfMsg('sendbox') . '<br />
<textarea id="utmessage" name="utmessage" rows="6" style="margin: 5px 0px 5px 0px;"></textarea>
<input id="utuser" type="hidden" name="utuser" value="">

<input tabindex="4" type="button" value="Send" cl1ass="btn" id="postcommentbutton" style="font-size: 110%; font-weight:bold" onclick="utSend(); return false;" />


</form>
</div>
<div id="resultdiv"></div>' . "\n");
        }
    }
开发者ID:ErdemA,项目名称:wikihow,代码行数:101,代码来源:UserTalkTool.body.php

示例12: execute

 /**
  * Show the special page
  *
  * @param $par Mixed: parameter passed to the page or null
  */
 public function execute($par)
 {
     global $wgGroupPermissions;
     $out = $this->getOutput();
     $request = $this->getRequest();
     $lang = $this->getLang();
     $out->setPageTitle(wfMsgHtml('newvideos'));
     $wpIlMatch = $request->getText('wpIlMatch');
     $dbr = wfGetDB(DB_SLAVE);
     $sk = $this->getSkin();
     $shownav = !$this->including();
     $hidebots = $request->getBool('hidebots', 1);
     $hidebotsql = '';
     if ($hidebots) {
         /*
          * Make a list of group names which have the 'bot' flag
          * set.
          */
         $botconds = array();
         foreach ($wgGroupPermissions as $groupname => $perms) {
             if (array_key_exists('bot', $perms) && $perms['bot']) {
                 $botconds[] = "ug_group='{$groupname}'";
             }
         }
         /* If not bot groups, do not set $hidebotsql */
         if ($botconds) {
             $isbotmember = $dbr->makeList($botconds, LIST_OR);
             /*
              * This join, in conjunction with WHERE ug_group
              * IS NULL, returns only those rows from IMAGE
              * where the uploading user is not a member of
              * a group which has the 'bot' permission set.
              */
             $ug = $dbr->tableName('user_groups');
             $hidebotsql = " LEFT OUTER JOIN {$ug} ON video_user_name=ug_user AND ({$isbotmember})";
         }
     }
     $video = $dbr->tableName('video');
     $sql = "SELECT video_timestamp FROM {$video}";
     if ($hidebotsql) {
         $sql .= "{$hidebotsql} WHERE ug_group IS NULL";
     }
     $sql .= ' ORDER BY video_timestamp DESC LIMIT 1';
     $res = $dbr->query($sql, __METHOD__);
     $row = $dbr->fetchRow($res);
     if ($row !== false) {
         $ts = $row[0];
     } else {
         $ts = false;
     }
     $sql = '';
     /** If we were clever, we'd use this to cache. */
     $latestTimestamp = wfTimestamp(TS_MW, $ts);
     /** Hardcode this for now. */
     $limit = 48;
     if ($parval = intval($par)) {
         if ($parval <= $limit && $parval > 0) {
             $limit = $parval;
         }
     }
     $where = array();
     $searchpar = array();
     if ($wpIlMatch != '') {
         $nt = Title::newFromUrl($wpIlMatch);
         if ($nt) {
             $m = $dbr->strencode(strtolower($nt->getDBkey()));
             $m = str_replace('%', "\\%", $m);
             $m = str_replace('_', "\\_", $m);
             $where[] = "LCASE(video_name) LIKE '%{$m}%'";
             $searchpar['wpIlMatch'] = $wpIlMatch;
         }
     }
     $invertSort = false;
     if ($until = $request->getVal('until')) {
         $where[] = 'video_timestamp < ' . $dbr->timestamp($until);
     }
     if ($from = $request->getVal('from')) {
         $where[] = 'video_timestamp >= ' . $dbr->timestamp($from);
         $invertSort = true;
     }
     $sql = 'SELECT video_name, video_url, video_user_name, video_user_id, ' . " video_timestamp FROM {$video}";
     if ($hidebotsql) {
         $sql .= $hidebotsql;
         $where[] = 'ug_group IS NULL';
     }
     if (count($where)) {
         $sql .= ' WHERE ' . $dbr->makeList($where, LIST_AND);
     }
     $sql .= ' ORDER BY video_timestamp ' . ($invertSort ? '' : ' DESC');
     $sql .= ' LIMIT ' . ($limit + 1);
     $res = $dbr->query($sql, __METHOD__);
     // We have to flip things around to get the last N after a certain date
     $videos = array();
     foreach ($res as $s) {
         if ($invertSort) {
//.........这里部分代码省略.........
开发者ID:Tjorriemorrie,项目名称:app,代码行数:101,代码来源:SpecialNewVideos.php

示例13: wfSpecialWikiaNewFiles

function wfSpecialWikiaNewFiles($par, $specialPage)
{
    global $wgOut, $wgLang, $wgRequest, $wgMiserMode;
    global $wmu, $wgOasisHD;
    $wpIlMatch = $wgRequest->getText('wpIlMatch');
    $dbr = wfGetDB(DB_SLAVE);
    $sk = RequestContext::getMain()->getSkin();
    $shownav = !$specialPage->including();
    $hidebots = $wgRequest->getBool('hidebots', 1);
    $hidebotsql = '';
    if ($hidebots) {
        # Make a list of group names which have the 'bot' flag set.
        $botconds = array();
        foreach (User::getGroupsWithPermission('bot') as $groupname) {
            $botconds[] = 'ug_group = ' . $dbr->addQuotes($groupname);
        }
        # If not bot groups, do not set $hidebotsql
        if ($botconds) {
            $isbotmember = $dbr->makeList($botconds, LIST_OR);
            # This join, in conjunction with WHERE ug_group IS NULL, returns
            # only those rows from IMAGE where the uploading user is not a mem-
            # ber of a group which has the 'bot' permission set.
            $ug = $dbr->tableName('user_groups');
            $hidebotsql = " LEFT JOIN {$ug} ON img_user=ug_user AND ({$isbotmember})";
        }
    }
    $image = $dbr->tableName('image');
    $sql = "SELECT img_timestamp from {$image}";
    if ($hidebotsql) {
        $sql .= "{$hidebotsql} WHERE ug_group IS NULL";
    }
    $sql .= ' ORDER BY img_timestamp DESC LIMIT 1';
    $res = $dbr->query($sql, __FUNCTION__);
    $row = $dbr->fetchRow($res);
    if ($row !== false) {
        $ts = $row[0];
    } else {
        $ts = false;
    }
    $dbr->freeResult($res);
    $sql = '';
    # If we were clever, we'd use this to cache.
    $latestTimestamp = wfTimestamp(TS_MW, $ts);
    # Hardcode this for now.
    $limit = 48;
    if ($parval = intval($par)) {
        if ($parval <= $limit && $parval > 0) {
            $limit = $parval;
        }
    }
    $where = array();
    $searchpar = '';
    if ($wpIlMatch != '' && !$wgMiserMode) {
        $nt = Title::newFromUrl($wpIlMatch);
        if ($nt) {
            $m = $dbr->buildLike($dbr->anyString(), strtolower($nt->getDBkey()), $dbr->anyString());
            $where[] = 'LOWER(img_name)' . $m;
            $searchpar = '&wpIlMatch=' . urlencode($wpIlMatch);
        }
    }
    $invertSort = false;
    if ($until = $wgRequest->getVal('until')) {
        $where[] = "img_timestamp < '" . $dbr->timestamp($until) . "'";
    }
    if ($from = $wgRequest->getVal('from')) {
        $where[] = "img_timestamp >= '" . $dbr->timestamp($from) . "'";
        $invertSort = true;
    }
    $sql = 'SELECT img_size, img_name, img_user, img_user_text,' . "img_description,img_timestamp FROM {$image}";
    if ($hidebotsql) {
        $sql .= $hidebotsql;
        $where[] = 'ug_group IS NULL';
    }
    // hook by Wikia, Bartek Lapinski 26.03.2009, for videos and stuff
    wfRunHooks('SpecialNewImages::beforeQuery', array(&$where));
    if (count($where)) {
        $sql .= ' WHERE ' . $dbr->makeList($where, LIST_AND);
    }
    $sql .= ' ORDER BY img_timestamp ' . ($invertSort ? '' : ' DESC');
    $sql .= ' LIMIT ' . ($limit + 1);
    $res = $dbr->query($sql, __FUNCTION__);
    /**
     * We have to flip things around to get the last N after a certain date
     */
    $images = array();
    while ($s = $dbr->fetchObject($res)) {
        if ($invertSort) {
            array_unshift($images, $s);
        } else {
            array_push($images, $s);
        }
    }
    $dbr->freeResult($res);
    $gallery = new WikiaPhotoGallery();
    $gallery->parseParams(array("rowdivider" => true, "hideoverflow" => true));
    //FB#1150 - make the images fit the whole horizontal space in Oasis and Oasis HD
    if (get_class($sk) == 'SkinOasis') {
        if ($wgOasisHD) {
            $gallery->setWidths(202);
        } else {
//.........这里部分代码省略.........
开发者ID:schwarer2006,项目名称:wikia,代码行数:101,代码来源:SpecialNewFiles.php

示例14: wfSpecialImagelist

/**
 *
 */
function wfSpecialImagelist()
{
    global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest, $wgMiserMode;
    $sort = $wgRequest->getVal('sort');
    $wpIlMatch = $wgRequest->getText('wpIlMatch');
    $dbr =& wfGetDB(DB_SLAVE);
    $image = $dbr->tableName('image');
    $sql = "SELECT img_size,img_name,img_user,img_user_text," . "img_description,img_timestamp FROM {$image}";
    $byname = wfMsg("byname");
    $bydate = wfMsg("bydate");
    $bysize = wfMsg("bysize");
    if (!$wgMiserMode && !empty($wpIlMatch)) {
        $nt = Title::newFromUrl($wpIlMatch);
        if ($nt) {
            $m = $dbr->strencode(strtolower($nt->getDBkey()));
            $m = str_replace("%", "\\%", $m);
            $m = str_replace("_", "\\_", $m);
            $sql .= " WHERE LCASE(img_name) LIKE '%{$m}%'";
        }
    }
    if ("bysize" == $sort) {
        $sql .= " ORDER BY img_size DESC";
        $st = $bysize;
    } else {
        if ("byname" == $sort) {
            $sql .= " ORDER BY img_name";
            $st = $byname;
        } else {
            $sort = "bydate";
            $sql .= " ORDER BY img_timestamp DESC";
            $st = $bydate;
        }
    }
    list($limit, $offset) = wfCheckLimits(50);
    if (0 == $limit) {
        $lt = wfMsg('imagelistall');
    } else {
        $lt = $wgLang->formatNum("{$limit}");
        $sql .= " LIMIT {$limit}";
    }
    $wgOut->addHTML("<p>" . wfMsg("imglegend") . "</p>\n");
    $text = wfMsg("imagelisttext", "<strong>{$lt}</strong>", "<strong>{$st}</strong>");
    $wgOut->addHTML("<p>{$text}\n</p>");
    $sk = $wgUser->getSkin();
    $sub = wfMsg("ilsubmit");
    $titleObj = Title::makeTitle(NS_SPECIAL, "Imagelist");
    $action = $titleObj->escapeLocalURL("sort={$sort}&limit={$limit}");
    if (!$wgMiserMode) {
        $wgOut->addHTML("<form id=\"imagesearch\" method=\"post\" action=\"" . "{$action}\">" . "<input type='text' size='20' name=\"wpIlMatch\" value=\"" . htmlspecialchars($wpIlMatch) . "\" /> " . "<input type='submit' name=\"wpIlSubmit\" value=\"{$sub}\" /></form>");
    }
    $nums = array(50, 100, 250, 500);
    $here = Title::makeTitle(NS_SPECIAL, 'Imagelist');
    $fill = "";
    $first = true;
    foreach ($nums as $num) {
        if (!$first) {
            $fill .= " | ";
        }
        $first = false;
        $fill .= $sk->makeKnownLinkObj($here, $wgLang->formatNum($num), "sort=byname&limit={$num}&wpIlMatch=" . urlencode($wpIlMatch));
    }
    $text = wfMsg("showlast", $fill, $byname);
    $wgOut->addHTML("<p>{$text}<br />\n");
    $fill = "";
    $first = true;
    foreach ($nums as $num) {
        if (!$first) {
            $fill .= " | ";
        }
        $first = false;
        $fill .= $sk->makeKnownLinkObj($here, $wgLang->formatNum($num), "sort=bysize&limit={$num}&wpIlMatch=" . urlencode($wpIlMatch));
    }
    $text = wfMsg("showlast", $fill, $bysize);
    $wgOut->addHTML("{$text}<br />\n");
    $fill = "";
    $first = true;
    foreach ($nums as $num) {
        if (!$first) {
            $fill .= " | ";
        }
        $first = false;
        $fill .= $sk->makeKnownLinkObj($here, $wgLang->formatNum($num), "sort=bydate&limit={$num}&wpIlMatch=" . urlencode($wpIlMatch));
    }
    $text = wfMsg("showlast", $fill, $bydate);
    $wgOut->addHTML("{$text}</p>\n<p>");
    $res = $dbr->query($sql, "wfSpecialImagelist");
    while ($s = $dbr->fetchObject($res)) {
        $name = $s->img_name;
        $ut = $s->img_user_text;
        if (0 == $s->img_user) {
            $ul = $ut;
        } else {
            $ul = $sk->makeLinkObj(Title::makeTitle(NS_USER, $ut), $ut);
        }
        $ilink = "<a href=\"" . htmlspecialchars(Image::imageUrl($name)) . "\">" . strtr(htmlspecialchars($name), '_', ' ') . "</a>";
        $nb = wfMsg("nbytes", $wgLang->formatNum($s->img_size));
        $l = "(" . $sk->makeKnownLinkObj(Title::makeTitle(NS_IMAGE, $name), wfMsg("imgdesc")) . ") {$ilink} . . {$nb} . . {$ul} . . " . $wgLang->timeanddate($s->img_timestamp, true);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:openzaurus-svn,代码行数:101,代码来源:SpecialImagelist.php

示例15: wfSpecialImagelist

/**
 *
 */
function wfSpecialImagelist()
{
    global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest, $wgMiserMode;
    $sort = $wgRequest->getVal('sort');
    $wpIlMatch = $wgRequest->getText('wpIlMatch');
    $dbr =& wfGetDB(DB_SLAVE);
    $image = $dbr->tableName('image');
    $sql = "SELECT img_size,img_name,img_user,img_user_text," . "img_description,img_timestamp FROM {$image}";
    if (!$wgMiserMode && !empty($wpIlMatch)) {
        $nt = Title::newFromUrl($wpIlMatch);
        if ($nt) {
            $m = $dbr->strencode(strtolower($nt->getDBkey()));
            $m = str_replace("%", "\\%", $m);
            $m = str_replace("_", "\\_", $m);
            $sql .= " WHERE LCASE(img_name) LIKE '%{$m}%'";
        }
    }
    if ("bysize" == $sort) {
        $sql .= " ORDER BY img_size DESC";
    } else {
        if ("byname" == $sort) {
            $sql .= " ORDER BY img_name";
        } else {
            $sort = "bydate";
            $sql .= " ORDER BY img_timestamp DESC";
        }
    }
    list($limit, $offset) = wfCheckLimits(50);
    $lt = $wgLang->formatNum("{$limit}");
    $sql .= " LIMIT {$limit}";
    $wgOut->addWikiText(wfMsg('imglegend'));
    $wgOut->addHTML(wfMsgExt('imagelisttext', array('parse'), $lt, wfMsg($sort)));
    $sk = $wgUser->getSkin();
    $titleObj = Title::makeTitle(NS_SPECIAL, "Imagelist");
    $action = $titleObj->escapeLocalURL("sort={$sort}&limit={$limit}");
    if (!$wgMiserMode) {
        $wgOut->addHTML("<form id=\"imagesearch\" method=\"post\" action=\"" . "{$action}\">" . wfElement('input', array('type' => 'text', 'size' => '20', 'name' => 'wpIlMatch', 'value' => $wpIlMatch)) . wfElement('input', array('type' => 'submit', 'name' => 'wpIlSubmit', 'value' => wfMsg('ilsubmit'))) . '</form>');
    }
    $here = Title::makeTitle(NS_SPECIAL, 'Imagelist');
    foreach (array('byname', 'bysize', 'bydate') as $sorttype) {
        $urls = null;
        foreach (array(50, 100, 250, 500) as $num) {
            $urls[] = $sk->makeKnownLinkObj($here, $wgLang->formatNum($num), "sort={$sorttype}&limit={$num}&wpIlMatch=" . urlencode($wpIlMatch));
        }
        $sortlinks[] = wfMsgExt('showlast', array('parseinline', 'replaceafter'), implode($urls, ' | '), wfMsgExt($sorttype, array('escape')));
    }
    $wgOut->addHTML(implode($sortlinks, "<br />\n") . "\n\n<hr />");
    // lines
    $wgOut->addHTML('<p>');
    $res = $dbr->query($sql, "wfSpecialImagelist");
    while ($s = $dbr->fetchObject($res)) {
        $name = $s->img_name;
        $ut = $s->img_user_text;
        if (0 == $s->img_user) {
            $ul = $ut;
        } else {
            $ul = $sk->makeLinkObj(Title::makeTitle(NS_USER, $ut), $ut);
        }
        $dirmark = $wgContLang->getDirMark();
        // to keep text in correct direction
        $ilink = "<a href=\"" . htmlspecialchars(Image::imageUrl($name)) . "\">" . strtr(htmlspecialchars($name), '_', ' ') . "</a>";
        $nb = wfMsgExt('nbytes', array('parsemag', 'escape'), $wgLang->formatNum($s->img_size));
        $desc = $sk->makeKnownLinkObj(Title::makeTitle(NS_IMAGE, $name), wfMsg('imgdesc'));
        $date = $wgLang->timeanddate($s->img_timestamp, true);
        $comment = $sk->commentBlock($s->img_description);
        $l = "({$desc}) {$dirmark}{$ilink} . . {$dirmark}{$nb} . . {$dirmark}{$ul}" . " . . {$dirmark}{$date} . . {$dirmark}{$comment}<br />\n";
        $wgOut->addHTML($l);
    }
    $dbr->freeResult($res);
    $wgOut->addHTML('</p>');
}
开发者ID:k-hasan-19,项目名称:wiki,代码行数:74,代码来源:SpecialImagelist.php


注:本文中的Title::newFromUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。