Exemplo n.º 1
0
 /**
  * Regenerate / invalidate service cache for current page
  */
 public function regenerateData()
 {
     global $wgMemc;
     wfProfileIn(__METHOD__);
     wfDebug(__METHOD__ . ": page #{$this->pageId}\n");
     // invalidate cached data from getMostLinkedCategories()
     $wgMemc->delete($this->getKey('mostlinkedcategories'));
     // invalidate cached data from getCurrentRevision()
     $wgMemc->delete($this->getKey('current-revision'));
     // invalidate cached data from getPreviousEdits()
     $wgMemc->delete($this->getKey('previous-edits'));
     // invalidate cached data from getCommentsCount()
     $title = Title::newFromId($this->pageId, Title::GAID_FOR_UPDATE);
     if (!empty($title)) {
         $pageName = $title->getPrefixedText();
         wfDebug(__METHOD__ . ": page '{$pageName}' has been touched\n");
         // invalidate cache with number of comments / talk page revisions
         if ($title->isTalkPage()) {
             if (self::isArticleCommentsEnabled() && ArticleComment::isTitleComment($title)) {
                 // get subject page for this article comment
                 $parts = ArticleComment::explode($title->getText());
                 $title = Title::newFromText($parts['title'], MWNamespace::getSubject($title->getNamespace()));
                 wfDebug(__METHOD__ . ": article comment added\n");
             } else {
                 // get subject page for this talk page
                 $title = $title->getSubjectPage();
             }
             $contentPageName = $title->getPrefixedText();
             wfDebug(__METHOD__ . ": talk page / article comment for '{$contentPageName}' has been touched\n");
             $contentPageService = new self($title->getArticleId());
             $contentPageService->regenerateCommentsCount();
         }
     }
     wfProfileOut(__METHOD__);
     return true;
 }
 /**
  * formats links in the "File usage" section of file pages
  * @author Jakub Olek
  */
 public static function onFilePageImageUsageSingleLink(&$link, &$element)
 {
     $app = F::app();
     $ns = $element->page_namespace;
     $title = Title::newFromText($element->page_title, $ns);
     if (empty($title)) {
         // sanity check
         return true;
     }
     // format links to comment pages
     if ($ns == NS_TALK && ArticleComment::isTitleComment($title)) {
         $parentTitle = reset(explode('/', $element->page_title));
         // getBaseText returns me parent comment for subcomment
         $link = wfMsgExt('article-comments-file-page', array('parsemag'), $title->getLocalURL(), self::getUserNameFromRevision($title), Title::newFromText($parentTitle)->getLocalURL(), $parentTitle);
         // format links to blog posts
     } else {
         if (defined('NS_BLOG_ARTICLE_TALK') && $ns == NS_BLOG_ARTICLE_TALK) {
             $baseText = $title->getBaseText();
             $titleNames = explode('/', $baseText);
             $userBlog = Title::newFromText($titleNames[0], NS_BLOG_ARTICLE);
             $link = wfMsgExt('article-blog-comments-file-page', array('parsemag'), $title->getLocalURL(), self::getUserNameFromRevision($title), Title::newFromText($baseText, NS_BLOG_ARTICLE)->getLocalURL(), $titleNames[1], $userBlog->getLocalURL(), $userBlog->getBaseText());
         }
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * Hook
  *
  * @param Title $title -- instance of EmailNotification class
  * @param Array $keys -- array of all special variables like $PAGETITLE etc
  * @param String $message (subject or body)
  * @param $editor User
  *
  * @static
  * @access public
  *
  * @return Bool true -- because it's a hook
  */
 public static function ComposeCommonMail($title, &$keys, &$message, $editor)
 {
     global $wgEnotifUseRealName;
     if (MWNamespace::isTalk($title->getNamespace()) && ArticleComment::isTitleComment($title)) {
         if (!is_array($keys)) {
             $keys = array();
         }
         $name = $wgEnotifUseRealName ? $editor->getRealName() : $editor->getName();
         if ($editor->isIP($name)) {
             $utext = trim(wfMsgForContent('enotif_anon_editor', ''));
             $message = str_replace('$PAGEEDITOR', $utext, $message);
             $keys['$PAGEEDITOR'] = $utext;
         }
     }
     return true;
 }
 /**
  * Handle confirmations when page is deleted
  *
  * @param WikiPage $article
  */
 public static function addPageDeletedConfirmation(&$article, &$user, $reason, $articleId)
 {
     global $wgOut;
     if (F::app()->checkSkin('oasis')) {
         $title = $article->getTitle();
         // special handling of ArticleComments
         if (class_exists('ArticleComment') && MWNamespace::isTalk($title->getNamespace()) && ArticleComment::isTitleComment($title) && $title->getNamespace() != NS_USER_WALL) {
             self::addConfirmation(wfMessage('oasis-confirmation-comment-deleted')->escaped());
             return true;
         }
         $pageName = $title->getPrefixedText();
         $message = wfMessage('oasis-confirmation-page-deleted', $pageName)->inContentLanguage()->parse();
         wfRunHooks('OasisAddPageDeletedConfirmationMessage', array(&$title, &$message));
         self::addConfirmation($message, self::CONFIRMATION_CONFIRM, true);
         // redirect to main page
         $wgOut->redirect(Title::newMainPage()->getFullUrl(array('cb' => rand(1, 1000))));
     }
     return true;
 }
 /**
  * TODO: Document what the parameters are.
  */
 static function ChangesListInsertArticleLink($changeList, &$articlelink, &$s, $rc, $unpatrolled, $watched)
 {
     $rcTitle = $rc->getAttribute('rc_title');
     $rcNamespace = $rc->getAttribute('rc_namespace');
     $title = Title::newFromText($rcTitle, $rcNamespace);
     if (MWNamespace::isTalk($rcNamespace) && ArticleComment::isTitleComment($title)) {
         $parts = ArticleComment::explode($rcTitle);
         $titleMainArticle = Title::newFromText($parts['title'], MWNamespace::getSubject($rcNamespace));
         //fb#15143
         if ($titleMainArticle instanceof Title) {
             if (defined('NS_BLOG_ARTICLE') && $rcNamespace == NS_BLOG_ARTICLE || defined('NS_BLOG_ARTICLE_TALK') && $rcNamespace == NS_BLOG_ARTICLE_TALK) {
                 $messageKey = 'article-comments-rc-blog-comment';
             } else {
                 $messageKey = 'article-comments-rc-comment';
             }
             $articleId = $title->getArticleId();
             $articlelink = wfMsgExt($messageKey, array('parseinline'), $title->getFullURL("permalink={$articleId}#comm-{$articleId}"), $titleMainArticle->getText());
         } else {
             //it should never happened because $rcTitle is never empty,
             //ArticleComment::explode() always returns an array with not-empty 'title' element,
             //(both files: ArticleComments/classes/ArticleComments.class.php
             //and WallArticleComment/classes/ArticleComments.class.php have
             //the same definition of explode() method)
             //and static constructor newFromText() should create a Title instance for $parts['title']
             Wikia::log(__METHOD__, false, 'WALL_ARTICLE_COMMENT_ERROR: no main article title: ' . print_r($parts, true) . ' namespace: ' . $rcNamespace);
         }
     }
     return true;
 }
Exemplo n.º 6
0
 private function filterLog($res)
 {
     wfProfileIn(__METHOD__);
     if ($res['logtype'] == 'move') {
         if (isset($res['move'], $res['move']['new_title'], $res['move']['new_ns'])) {
             //FB#35775
             //RT#27870
             if (!empty($this->parameters['type']) && $this->parameters['type'] == 'widget') {
                 return;
             }
             $newTitle = Title::newFromText($res['move']['new_title'], $res['move']['new_ns']);
         } else {
             $newTitle = Title::newFromText(trim($res['rc_params']));
         }
         if ($newTitle && $newTitle->exists()) {
             $oldTitle = Title::newFromText($res['title']);
             if (empty($oldTitle)) {
                 wfProfileOut(__METHOD__);
                 return;
             }
             // Filter Article Comments from Activity Log without using rc_params FB:1336
             if (class_exists('ArticleComment') && ArticleComment::isTitleComment($newTitle)) {
                 wfProfileOut(__METHOD__);
                 return;
             }
             $this->add(array('type' => 'move', 'to_title' => $newTitle->getPrefixedText(), 'to_url' => $newTitle->getLocalUrl(), 'title' => $oldTitle->getPrefixedText(), 'url' => $oldTitle->getLocalUrl(), 'comment' => $res['comment']), $res);
             wfProfileOut(__METHOD__);
             return true;
         }
     }
     if ($this->proxyType == self::WL) {
         if ($res['logtype'] == 'delete') {
             $this->add(array('type' => 'delete', 'title' => $res['title']), $res);
             wfProfileOut(__METHOD__);
             return true;
         } else {
             if ($res['logtype'] == 'upload') {
                 $title = Title::newFromText($res['title']);
                 if ($title && $title->exists()) {
                     $file = wfFindFile($title);
                     if ($file) {
                         $this->add(array('type' => 'upload', 'title' => $title->getPrefixedText(), 'url' => $title->getLocalUrl(), 'thumbnail' => $file->transform(array('width' => self::UPLOAD_THUMB_WIDTH))->toHtml()), $res);
                         wfProfileOut(__METHOD__);
                         return true;
                     }
                 }
             }
         }
     }
     wfProfileOut(__METHOD__);
 }
Exemplo n.º 7
0
 /**
  * @desc Enables article and blog comments deletion for users who have commentdelete right but don't have delete
  *
  * @param Article $article
  * @param Title $title
  * @param User $user
  * @param Array $permission_errors
  *
  * @return true because it's a hook
  */
 public static function onBeforeDeletePermissionErrors(&$article, &$title, &$user, &$permission_errors)
 {
     if (self::isCommentingEnabled() && $user->isAllowed('commentdelete') && ArticleComment::isTitleComment($title)) {
         foreach ($permission_errors as $key => $errorArr) {
             if (self::isBadAccessError($errorArr)) {
                 unset($permission_errors[$key]);
             }
         }
     }
     return true;
 }
	/**
	 * Handle confirmations when page is deleted
	 *
	 * @param WikiPage $article
	 */
	public static function addPageDeletedConfirmation(&$article, &$user, $reason, $articleId) {
		wfProfileIn(__METHOD__);
		global $wgOut;

		if ( F::app()->checkSkin( 'oasis' ) ) {
			$title = $article->getTitle();
			// special handling of ArticleComments
			if (class_exists('ArticleComment') && MWNamespace::isTalk($title->getNamespace()) && ArticleComment::isTitleComment($title) && $title->getNamespace() != NS_USER_WALL ) {
				self::addConfirmation(wfMsg('oasis-confirmation-comment-deleted'));

				wfProfileOut(__METHOD__);
				return true;
			}

			$pageName = $title->getPrefixedText();

			self::addConfirmation(wfMsgExt('oasis-confirmation-page-deleted', array('parseinline'), $pageName));

			// redirect to main page
			$wgOut->redirect(Title::newMainPage()->getFullUrl( array( 'cb' => rand( 1, 1000 ) ) ));
		}

		wfProfileOut(__METHOD__);
		return true;
	}
 /**
  * HAWelcome
  *
  * @param Title $title
  * @param User $fakeUser
  *
  * @access public
  * @author Jakub
  *
  * @return boolean
  */
 public static function HAWelcomeGetPrefixText(&$prefixedText, $title)
 {
     if (ArticleComment::isTitleComment($title)) {
         $title = $title->getSubjectPage();
         $prefixedText = $title->getPrefixedText();
         $aPrefix = explode(ARTICLECOMMENT_PREFIX, $prefixedText);
         if (count($aPrefix) > 0) {
             $prefixedText = substr_replace($aPrefix[0], "", -1);
         }
     }
     return true;
 }