/** * Make html of the 'Follow this tag' button * Check is user is already following it, then * shows 'Following' button * Sets the value of $this->aPageVars['side'] * to be the div with follow button * * @return object $this * */ protected function makeFollowTagButton() { /** * Only show the follow tag button * if viewing page about only one tag * a page about multiple tags * will not show follow tag because * it's not clear which tag to follow * */ if (1 === count($this->aTags)) { $tag = $this->aTags[0]; d('tag: ' . $tag); $aFollowed = $this->Registry->Viewer['a_f_t']; d('$aFollowed: ' . print_r($aFollowed, 1)); $aVars = array('id' => $tag, 'icon' => 'cplus', 'label' => $this->_('Follow this tag'), 'class' => 'follow', 'type' => 't', 'title' => $this->_('Follow this tag to be notified when new questions are added')); if (in_array($tag, $aFollowed)) { $aVars['label'] = $this->_('Following'); $aVars['class'] = 'following'; $aVars['icon'] = 'check'; $aVars['title'] = $this->_('You are following this tag'); } $this->aPageVars['side'] = '<div class="fr cb w90 lg rounded3 pl10 mb10"><div class="follow_wrap">' . \tplFollowButton::parse($aVars, false) . '</div></div>'; $this->addTagFollowers(); } return $this; }
/** * Makes the button to "Follow" or "Following" * for this topic and sets this html as value * of $this->aPageVars['side'] * * @return object $this */ protected function makeFollowButton() { $qid = $this->Question->getResourceId(); $aVars = array('id' => $qid, 'icon' => 'cplus', 'label' => $this->_('Follow this topic'), 'class' => 'follow', 'type' => 'q', 'title' => $this->_('Follow this topic to be notified of new posts, comments and edits')); if (in_array($this->Registry->Viewer->getUid(), $this->Question['a_flwrs'])) { $aVars['label'] = $this->_('Following'); $aVars['class'] = 'following'; $aVars['icon'] = 'check'; $aVars['title'] = $this->_('You are following this topic'); } $this->aPageVars['side'] = '<div class="fr cb w90 lg rounded3 pl10 mb10"><div class="follow_wrap">' . \tplFollowButton::parse($aVars, false) . '</div></div>'; return $this; }
/** * Make a follow user button * checks that user is not the same * as viewer, otherwise just returns * empty string * * * @param Registry $Registry * @param User $User use who to follow * @return string html of "Follow" button * of empty string if Viewer is same as User * */ public function makeFollowButton() { $button = ''; $oViewer = $this->Registry->Viewer; $uid = $this->User->getUid(); if ($uid !== $oViewer->getUid()) { /** * @todo * Translate strings */ $aVars = array('id' => $uid, 'icon' => 'cplus', 'label' => 'Follow', 'class' => 'follow', 'type' => 'u', 'title' => 'Follow this user'); /** * @todo * Translate strings */ if (in_array($uid, $oViewer['a_f_u'])) { $aVars['label'] = 'Following'; $aVars['class'] = 'following'; $aVars['icon'] = 'check'; $aVars['title'] = 'You are following this user'; } $button = '<div class="fl mt10 mb10"><div class="follow_wrap">' . \tplFollowButton::parse($aVars, false) . '</div></div>'; } return $button; }