Esempio n. 1
0
 /**
  * Add insights param to edit page form to keep information about insights flow
  */
 public static function onGetLocalURL(Title $title, &$url, $query)
 {
     global $wgRequest;
     $subpage = $wgRequest->getVal('insights', null);
     if (InsightsHelper::isInsightPage($subpage)) {
         $action = $wgRequest->getVal('action', 'view');
         if ($action == 'edit' && $query == 'action=submit') {
             $url .= '&insights=' . $subpage;
         }
     }
     return true;
 }
 /**
  * Setup method for Insights_loopNotification.mustache template
  */
 public function loopNotification()
 {
     $subpage = $this->request->getVal('insight', null);
     if (InsightsHelper::isInsightPage($subpage)) {
         $model = InsightsHelper::getInsightModel($subpage);
         if ($model instanceof InsightsModel) {
             $params = [];
             $type = '';
             $isFixed = false;
             $articleName = $this->getVal('article', null);
             $title = Title::newFromText($articleName);
             $next = $model->getNextItem($model->getInsightType(), $articleName);
             $isEdit = $this->request->getBool('isEdit', false);
             if (!$isEdit) {
                 $isFixed = $model->isItemFixed($title);
                 if ($isFixed) {
                     $model->updateInsightsCache($title->getArticleId());
                 }
             }
             if ($isEdit) {
                 $params = $this->getInProgressNotificationParams($subpage);
                 $type = self::FLOW_STATUS_INPROGRESS;
             } elseif (!$isFixed) {
                 $params = $this->getNotFixedNotificationParams($subpage, $title, $model);
                 $type = self::FLOW_STATUS_NOTFIXED;
             } elseif ($isFixed && empty($next)) {
                 $params = $this->getCongratulationsNotificationParams($subpage);
                 $type = self::FLOW_STATUS_ALLDONE;
             } elseif ($isFixed) {
                 $params = $this->getInsightFixedNotificationParams($subpage, $next);
                 $type = self::FLOW_STATUS_FIXED;
             }
             $html = \MustacheService::getInstance()->render('extensions/wikia/Insights/templates/Insights_loopNotification.mustache', $params);
             $this->response->setData(['html' => $html, 'isFixed' => $isFixed, 'notificationType' => $type]);
         }
     }
 }