示例#1
0
 /**
  * @param User $editor The editor that triggered the update.  Their notification
  *  timestamp will not be updated(they have already seen it)
  * @param LinkTarget $linkTarget The link target of the title to update timestamps for
  * @param string $timestamp Set the update timestamp to this value
  * @return int[] Array of user IDs
  */
 public static function updateWatchlistTimestamp(User $editor, LinkTarget $linkTarget, $timestamp)
 {
     global $wgEnotifWatchlist, $wgShowUpdatedMarker;
     if (!$wgEnotifWatchlist && !$wgShowUpdatedMarker) {
         return array();
     }
     $dbw = wfGetDB(DB_MASTER);
     $res = $dbw->select(array('watchlist'), array('wl_user'), array('wl_user != ' . intval($editor->getID()), 'wl_namespace' => $linkTarget->getNamespace(), 'wl_title' => $linkTarget->getDBkey(), 'wl_notificationtimestamp IS NULL'), __METHOD__);
     $watchers = array();
     foreach ($res as $row) {
         $watchers[] = intval($row->wl_user);
     }
     if ($watchers) {
         // Update wl_notificationtimestamp for all watching users except the editor
         $fname = __METHOD__;
         $dbw->onTransactionIdle(function () use($dbw, $timestamp, $watchers, $linkTarget, $fname) {
             $dbw->update('watchlist', array('wl_notificationtimestamp' => $dbw->timestamp($timestamp)), array('wl_user' => $watchers, 'wl_namespace' => $linkTarget->getNamespace(), 'wl_title' => $linkTarget->getDBkey()), $fname);
         });
     }
     return $watchers;
 }
示例#2
0
 /**
  * @see TitleFormatter::getText()
  *
  * @param LinkTarget $title
  *
  * @return string
  */
 public function getFullText(LinkTarget $title)
 {
     return $this->formatTitle($title->getNamespace(), $title->getText(), $title->getFragment());
 }
示例#3
0
 /**
  * Load either the current, or a specified, revision
  * that's attached to a given link target. If not attached
  * to that link target, will return null.
  *
  * $flags include:
  *      Revision::READ_LATEST  : Select the data from the master
  *      Revision::READ_LOCKING : Select & lock the data from the master
  *
  * @param LinkTarget $linkTarget
  * @param int $id (optional)
  * @param int $flags Bitfield (optional)
  * @return Revision|null
  */
 public static function newFromTitle(LinkTarget $linkTarget, $id = 0, $flags = 0)
 {
     $conds = array('page_namespace' => $linkTarget->getNamespace(), 'page_title' => $linkTarget->getDBkey());
     if ($id) {
         // Use the specified ID
         $conds['rev_id'] = $id;
         return self::newFromConds($conds, $flags);
     } else {
         // Use a join to get the latest revision
         $conds[] = 'rev_id=page_latest';
         $db = wfGetDB($flags & self::READ_LATEST ? DB_MASTER : DB_SLAVE);
         return self::loadFromConds($db, $conds, $flags);
     }
 }
示例#4
0
 /**
  * Move a page
  *
  * @param integer $id The page_id
  * @param LinkTarget $newLinkTarget The new title link target
  * @return bool
  */
 private function movePage($id, LinkTarget $newLinkTarget)
 {
     $this->db->update('page', array("page_namespace" => $newLinkTarget->getNamespace(), "page_title" => $newLinkTarget->getDBkey()), array("page_id" => $id), __METHOD__);
     // Update *_from_namespace in links tables
     $fromNamespaceTables = array(array('pagelinks', 'pl'), array('templatelinks', 'tl'), array('imagelinks', 'il'));
     foreach ($fromNamespaceTables as $tableInfo) {
         list($table, $fieldPrefix) = $tableInfo;
         $this->db->update($table, array("{$fieldPrefix}_from_namespace" => $newLinkTarget->getNamespace()), array("{$fieldPrefix}_from" => $id), __METHOD__);
     }
     return true;
 }
示例#5
0
文件: Title.php 项目: OrBin/mediawiki
 /**
  * Create a new Title from a LinkTarget
  *
  * @param LinkTarget $linkTarget Assumed to be safe.
  *
  * @return Title
  */
 public static function newFromLinkTarget(LinkTarget $linkTarget)
 {
     return self::makeTitle($linkTarget->getNamespace(), $linkTarget->getText(), $linkTarget->getFragment());
 }