public function executeIndex($params)
 {
     $page_owner = User::newFromName($this->wg->Title->getText());
     if (!is_object($page_owner) || $page_owner->getId() == 0) {
         // do not show module if page owner does not exist or is an anonymous user
         return false;
     }
     // add CSS for this module
     $this->wg->Out->addStyle(AssetsManager::getInstance()->getSassCommonURL("skins/oasis/css/modules/FollowedPages.scss"));
     $showDeletedPages = isset($params['showDeletedPages']) ? (bool) $params['showDeletedPages'] : true;
     // get 6 followed pages
     $watchlist = FollowModel::getWatchList($page_owner->getId(), 0, 6, null, $showDeletedPages);
     $data = array();
     // weird.  why is this an array of one element?
     foreach ($watchlist as $unused_id => $item) {
         $pagelist = $item['data'];
         foreach ($pagelist as $page) {
             $data[] = $page;
         }
     }
     // only display  your own page
     if ($page_owner->getId() == $this->wg->User->getId()) {
         $this->follow_all_link = Wikia::specialPageLink('Following', 'oasis-wikiafollowedpages-special-seeall', 'more');
     }
     $this->data = $data;
     $this->max_followed_pages = min(self::MAX_FOLLOWED_PAGES, count($this->data));
 }
Exemplo n.º 2
0
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser, $wgTitle, $wgExtensionsPath, $wgJsMimeType, $wgExtensionsPath;
     $reqTitle = $wgRequest->getText('title', false);
     $userspace = "";
     $list = explode('/', $reqTitle, 2);
     if (!empty($list[1])) {
         $t = Title::newFromText('Following', NS_SPECIAL);
         $wgOut->redirect($t->getFullURL());
     }
     if ($wgRequest->wasPosted()) {
         if ($wgUser->getId() != 0 && $wgRequest->getVal("show_followed", 0) == 1) {
             $wgUser->setGlobalPreference("hidefollowedpages", false);
             $wgUser->saveSettings();
         }
     }
     $wgOut->addExtensionStyle("{$wgExtensionsPath}/wikia/Follow/css/special.css");
     $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$wgExtensionsPath}/wikia/Follow/js/ajax.js\"></script>\n");
     $wgOut->setPageTitle(wfMsg('wikiafollowedpages-special-title'));
     if ($wgUser->getId() == 0) {
         $wgOut->addHTML(wfMsgExt('wikiafollowedpages-special-anon', array('parse')));
         return true;
     }
     $user = $wgUser;
     $is_hide = false;
     if ($user->getGlobalPreference('hidefollowedpages')) {
         $is_hide = true;
         if ($user->getId() != $wgUser->getId()) {
             $wgOut->addHTML(wfMsgExt('wikiafollowedpages-special-hidden', array('parse'), $user->getName));
             return true;
         }
     }
     $data = FollowModel::getWatchList($user->getId());
     if (empty($data) || $user->getId() == 0) {
         $wgOut->addHTML(wfMsgExt('wikiafollowedpages-special-empty', array('parse')));
         return true;
     }
     $this->setHeaders();
     $template = new EasyTemplate(dirname(__FILE__) . '/templates/');
     $template->set_vars(array("data" => $data, "owner" => $wgUser->getId() == $user->getId(), "user_id" => $user->getId(), "is_hide" => $is_hide, "show_link" => $wgTitle->getFullUrl()));
     $text = $template->render("followedPages");
     $wgOut->addHTML($text);
     return true;
 }
Exemplo n.º 3
0
 /**
  * renderUserProfile -- return mashead tab for fallowed pages
  *
  * @static
  * @access public
  *
  *
  * @return  array
  */
 public static function renderUserProfile(&$out)
 {
     global $wgTitle, $wgRequest, $wgOut, $wgExtensionsPath, $wgJsMimeType, $wgUser;
     wfProfileIn(__METHOD__);
     if (F::app()->checkSkin('wikiamobile')) {
         return true;
     }
     if ($wgUser->getId() != 0 && $wgRequest->getVal("hide_followed", 0) == 1) {
         $wgUser->setOption("hidefollowedpages", true);
         $wgUser->saveSettings();
     }
     $key = $wgTitle->getDBKey();
     if (strlen($key) > 0) {
         $user = User::newFromName($key);
         if ($user == null) {
             return true;
         }
         if ($user->getId() == 0) {
             //not a real user
             return true;
         }
     } else {
         $user = $wgUser;
     }
     // do not show Followed box on diffs
     if ($wgRequest->getVal('diff', null) != null) {
         return true;
     }
     if ($user->getOption("hidefollowedpages")) {
         return true;
     }
     $data = FollowModel::getUserPageWatchList($user->getId());
     $wgOut->addExtensionStyle("{$wgExtensionsPath}/wikia/Follow/css/userpage.css");
     $template = new EasyTemplate(dirname(__FILE__) . '/templates/');
     if (count($data) == 0) {
         $data = null;
     }
     /*
     		if ( count($data) > 5 ) {
     			$data2 = array_slice($data, 5 );
     			$data = array_slice($data, 0, 5);
     		} */
     // BugId:2643
     $moreUrl = null;
     if ($wgUser->getId() == $user->getId()) {
         $specialPage = SpecialPage::getSafeTitleFor('Following', $user->getName());
         if (!empty($specialPage)) {
             $moreUrl = $specialPage->getLocalUrl();
         }
     }
     $template->set_vars(array("isLogin" => $wgUser->getId() == $user->getId(), "hideUrl" => $wgTitle->getFullUrl("hide_followed=1"), "data" => $data, "moreUrl" => $moreUrl));
     wfProfileOut(__METHOD__);
     $out['followedPages'] = $template->render("followedUserPage");
     return true;
 }
Exemplo n.º 4
0
 public function getFollowsByElementId($elementId)
 {
     // find follows
     $conditions = 'elementId=:elementId';
     $params = array(':elementId' => $elementId);
     $records = FollowRecord::model()->findAll($conditions, $params);
     return FollowModel::populateModels($records);
 }