Exemple #1
0
 public static function &getInstance()
 {
     if (!self::$instance) {
         self::$instance = new PonyDocsCache();
     }
     return self::$instance;
 }
 /**
  * Our hook which is processed whenever a Category Page is viewed.  When 
  * this happens, we hijack the normal mediawiki flow and create an instance 
  * of our CategoryViewer(PonyDocsCategoryPageHandler) which has a special 
  * addPage method which adds the H1 of the article content, instead of the 
  * title itself.
  *
  * @param CategoryArticle $categoryArticle a reference to the 
  * CategoryArticle which fired off the event.
  * @return boolean We return false to make mediawiki stop processing the 
  * normal flow.
  */
 static function onCategoryPageView(&$categoryArticle)
 {
     global $wgOut, $wgRequest;
     $from = $wgRequest->getVal('from');
     $until = $wgRequest->getVal('until');
     $cacheKey = "category-" . $categoryArticle->getTitle() . "-{$from}-{$until}";
     $res = null;
     $cache = PonyDocsCache::getInstance();
     // See if this exists in our cache
     $res = $cache->get($cacheKey);
     if ($res == null) {
         // Either cache is disabled, or cached entry does not exist
         $categoryViewer = new PonyDocsCategoryPageHandler($categoryArticle->getTitle(), $from, $until);
         $res = $categoryViewer->getHTML();
         // Store in our cache
         $cache->put($cacheKey, $res, CATEGORY_CACHE_TTL);
     }
     $wgOut->addHTML($res);
     return false;
     // We don't want to continue processing the "normal" mediawiki path, so return false here.
 }
 /**
  * Deletes PonyDocs category cache associated with the article
  * @param Article $article
  */
 public static function clearArticleCategoryCache($article)
 {
     $topic = new PonyDocsTopic($article);
     $cache = PonyDocsCache::getInstance();
     $ponydocsVersions = $topic->getProductVersions();
     if (count($ponydocsVersions) > 0) {
         foreach ($ponydocsVersions as $ver) {
             $cache->remove("category-Category:V:" . $ver->getProductName() . ':' . $ver->getVersionName());
         }
     }
 }
Exemple #4
0
 public static function clearTOCCache($manual, $version, $product)
 {
     error_log("INFO [PonyDocsTOC::clearTOCCache] Deleting cache entry of TOC for product " . $product->getShortName() . " manual " . $manual->getShortName() . ' and version ' . $version->getVersionName());
     $key = "TOCCACHE-" . $product->getShortName() . "-" . $manual->getShortName() . "-" . $version->getVersionName();
     $cache = PonyDocsCache::getInstance();
     $cache->remove($key);
 }
 public static function clearNAVCache(PonyDocsProductVersion $version)
 {
     error_log("INFO [" . __METHOD__ . "] Deleting cache entry of NAV for product " . $version->getProductName() . " version " . $version->getVersionName());
     $cache = PonyDocsCache::getInstance();
     $key = "NAVDATA-" . $version->getProductName() . "-" . $version->getVersionName();
     $cache->remove($key);
 }