/**
  * Hook-Handler for 'ArticleSave' (MediaWiki). Validates provided mapping syntax for Emoticons.
  * @param Article $oArticle The article object being saved
  * @param User $oUser The user object saving the article
  * @param string $sText The new article text
  * @param string $sSummary The article summary (comment)
  * @param bool $bIsMinor Minor flag
  * @param bool $bIsWatch Watch flag
  * @param int $iSection Number of edited section
  * @param int &$iFlags
  * @param Status $oStatus The Status object
  * @global MWMemcached $wgMemc The MediaWiki Memcached object
  * @return mixed Boolean true if syntax is okay or the saved article is not the MappingSourceArticle, String 'error-msg' if an error occurs.
  */
 public function onArticleSave($oArticle, $oUser, $sText, $sSummary, $bIsMinor, $bIsWatch, $iSection, &$iFlags, $oStatus)
 {
     global $wgMemc;
     $oMappingSourceTitle = Title::newFromText('bs-emoticons-mapping', NS_MEDIAWIKI);
     if (!$oMappingSourceTitle->equals($oArticle->getTitle())) {
         return true;
     }
     $aLines = explode("\n", $sText);
     foreach ($aLines as $iLineNumber => $sLine) {
         $iLineNumber++;
         $sLine = trim($sLine);
         //Remove leading space
         if (empty($sLine)) {
             continue;
         }
         //Empty line?
         if ($sLine[0] == '#') {
             continue;
         }
         //Comment line?
         $aEmoticonHash = preg_split('/ +/', $sLine);
         $oErrorView = new ViewErrorMessage();
         if (!isset($aEmoticonHash[1])) {
             $oErrorView->addData(array(wfMessage('bs-emoticons-error-validation-missing-symbol', $iLineNumber, $aEmoticonHash[0])->plain()));
             return $oErrorView->execute();
         }
         if (preg_match('#^.*?\\.(jpg|jpeg|gif|png)$#si', $aEmoticonHash[0]) === 0) {
             //$oStatus->fatal ( 'edit-no-change' );
             $oErrorView->addData(array(wfMessage('bs-emoticons-error-validation-imagename', $iLineNumber, $aEmoticonHash[0])->plain()));
             return $oErrorView->execute();
         }
         foreach ($aEmoticonHash as $sPart) {
             if ($sPart == $aEmoticonHash[0]) {
                 continue;
             }
             //Skip imagename
             $iSymbolLength = strlen($sPart);
             if ($iSymbolLength < 2 || $iSymbolLength > 10) {
                 $oErrorView->addData(array(wfMessage('bs-emoticons-error-validation-symbol', $iLineNumber, $sPart)));
                 return $oErrorView->execute();
             }
         }
     }
     BsCacheHelper::invalidateCache(BsCacheHelper::getCacheKey('BlueSpice', 'Emoticons'));
     return true;
 }
 /**
  * Invalidate blog cache
  * @param WikiPage $article
  * @param User $user
  * @param String $reason
  * @param Integer $id
  * @param Content $content
  * @param type $logEntry
  * @return boolean
  */
 public function onArticleDeleteComplete(&$article, User &$user, $reason, $id, $content, $logEntry)
 {
     # TODO: Cache must also be invalidated on other occasions like blog tags
     # for subpages or categories.
     if (!in_array($article->getTitle()->getNamespace(), array(NS_BLOG, NS_BLOG_TALK))) {
         return true;
     }
     $sTagsKey = BsCacheHelper::getCacheKey('BlueSpice', 'Blog', 'Tags');
     $aTagsData = BsCacheHelper::get($sTagsKey);
     // Invalidate all blog tag caches
     BsCacheHelper::invalidateCache($aTagsData);
     // Invalidate blog tag cache
     BsCacheHelper::invalidateCache($sTagsKey);
     return true;
 }
 /**
  * Invalidates cache for authors
  * @param WikiPage $wikiPage
  * @param User $user
  * @param Content $content
  * @param type $summary
  * @param type $isMinor
  * @param type $isWatch
  * @param type $section
  * @param type $flags
  * @param Status $status
  * @return boolean
  */
 public static function onPageContentSave($wikiPage, $user, $content, $summary, $isMinor, $isWatch, $section, $flags, $status)
 {
     BsCacheHelper::invalidateCache(BsCacheHelper::getCacheKey('BlueSpice', 'Authors', $wikiPage->getTitle()->getArticleID()));
     return true;
 }
 public static function deleteResponsibleEditorsFromCache($iArticleId)
 {
     BsCacheHelper::invalidateCache(BsCacheHelper::getCacheKey('ResponsibleEditors', 'getResponsibleEditorsByArticleId', (int) $iArticleId));
 }
 /**
  * Invalidates user sidebar cache
  * @param Article $article
  * @param User $user
  * @param Content $content
  * @param type $summary
  * @param type $isMinor
  * @param type $isWatch
  * @param type $section
  * @param type $flags
  * @param Revision $revision
  * @param Status $status
  * @param type $baseRevId
  * @return boolean
  */
 public static function onPageContentSaveComplete($article, $user, $content, $summary, $isMinor, $isWatch, $section, $flags, $revision, $status, $baseRevId)
 {
     if (!$article->getTitle()->equals(Title::newFromText($user->getName() . '/Sidebar', NS_USER))) {
         return true;
     }
     $aKeys = array(BsCacheHelper::getCacheKey('BlueSpice', 'UserSidebar', $article->getTitle()->getPrefixedDBkey()), BsCacheHelper::getCacheKey('BlueSpice', 'UserSidebar', 'default'));
     BsCacheHelper::invalidateCache($aKeys);
     return true;
 }
 public function invalidateCache()
 {
     BsCacheHelper::invalidateCache($this->getCacheKey('NavigationSitesData'));
 }
 public static function invalidateShoutBoxCache($iArticleId)
 {
     // A better solution might be to store all possible limits and their values in one key.
     for ($iLimit = 0; $iLimit < 300; $iLimit++) {
         BsCacheHelper::invalidateCache(BsCacheHelper::getCacheKey('BlueSpice', 'ShoutBox', $iArticleId, $iLimit));
     }
     BsCacheHelper::invalidateCache(BsCacheHelper::getCacheKey('BlueSpice', 'ShoutBox', 'totalCount' . $iArticleId));
 }
 /**
  * Hook-Handler for MediaWiki 'ArticleSaveComplete' hook. Removes an article from wishlist when created.
  * @param Article $oArticle Article modified
  * @param User $oUser User performing the modification
  * @param string $sText New content
  * @param string $sSummary Edit summary/comment
  * @param bool $bIsMinor Whether or not the edit was marked as minor
  * @param bool $bIsWatch (No longer used)
  * @param int $iSection (No longer used)
  * @param mixed $vFlags Flags passed to Article::doEdit()
  * @param Revision $oRevision New Revision of the article
  * @param Object $oStatus
  * @param mixed $vBaseRevId the rev ID (or false) this edit was based on
  * @return bool Always true to keep hooks running.
  */
 public function onArticleSaveComplete($oArticle, $oUser, $sText, $sSummary, $bIsMinor, $bIsWatch, $iSection, $vFlags, $oRevision, $oStatus, $vBaseRevId)
 {
     if ($oArticle->getTitle()->equals($this->getDataSourceTemplateArticle()->getTitle())) {
         BsCacheHelper::invalidateCache(BsCacheHelper::getCacheKey('BlueSpice', 'WantedArticle', $oArticle->getTitle()->getPrefixedText()));
     }
     if ($oStatus->value['new'] != true) {
         return true;
     }
     if (BsConfig::get('MW::WantedArticle::DeleteOnCreation') === false) {
         return true;
     }
     $oWantedArticleListTitle = $this->getDataSourceTemplateArticle()->getTitle();
     $aWishList = $this->getTitleListFromTitle($oWantedArticleListTitle);
     $oNewTitle = $oArticle->getTitle();
     $bListChanged = false;
     foreach ($aWishList as $key => $aWish) {
         if (!$oNewTitle->equals($aWish['title'])) {
             continue;
         }
         unset($aWishList[$key]);
         $bListChanged = true;
         break;
     }
     if ($bListChanged) {
         $this->saveTitleListToTitle($aWishList, $oWantedArticleListTitle, wfMessage('bs-wantedarticle-page-removed', $oNewTitle->getPrefixedText())->plain());
     }
     return true;
 }