示例#1
0
 /**
  * @param Title $title
  * @param Page $article
  *
  * @return true because it's a hook
  */
 public static function onArticleFromTitle(&$title, &$article)
 {
     wfProfileIn(__METHOD__);
     $app = F::app();
     if (WikiaPageType::isWikiaHubMain() || $title->isSubpageOf(Title::newMainPage())) {
         $model = new WikiaHubsV3HooksModel();
         $dbKeyName = $title->getDBKey();
         $dbKeyNameSplit = explode('/', $dbKeyName);
         $hubTimestamp = $model->getTimestampFromSplitDbKey($dbKeyNameSplit);
         $app->wg->SuppressRail = true;
         $app->wg->SuppressFooter = true;
         if (!$app->wg->request->wasPosted()) {
             // don't change article object while saving data
             $article = new WikiaHubsV3Article($title, $hubTimestamp);
         }
     }
     wfProfileOut(__METHOD__);
     return true;
 }
 /**
  * @dataProvider getTimestampFromSplitDbKeyDataProvider
  */
 public function testGetTimestampFromSplitDbKey($urlDbKey, $expectedTimestamp)
 {
     $hook = new WikiaHubsV3HooksModel();
     $timestamp = $hook->getTimestampFromSplitDbKey(explode('/', $urlDbKey));
     $this->assertEquals($expectedTimestamp, $timestamp);
 }