예제 #1
0
 /**
  * Add block with user's answers
  *
  * @return object $this
  *
  * @todo finish up with pagination
  *
  */
 protected function addAnswers()
 {
     /**
      *
      * html of parsed answers and pagination links
      * at the bottom all wrapped inside <div class="user_answers">
      *
      * @var $userQuestions
      */
     $userQuestions = UserAnswers::get($this->Registry, $this->User);
     /**
      * UserQuestions::get() may return an empty string
      * if this user does not have
      * any answers in which case skip the
      * rest of the method
      */
     if (empty($userQuestions)) {
         return $this;
     }
     /**
      * @todo must user Router now!
      */
     $cond = $this->Registry->Request->get('sort', 's', 'recent');
     $tabs = Urhere::factory($this->Registry)->get('tplSortuans', $cond, array('uid' => $this->User->getUid()));
     $ansBlock = '<div id="useranswers" class="cp fl sortable paginated">' . $userQuestions . '</div>';
     $this->aPageVars['body'] .= $tabs . $ansBlock;
     return $this;
 }
 protected function makeTopTabs()
 {
     $tabs = Urhere::factory($this->Registry)->get('tplToptabs', 'questions');
     $this->aPageVars['topTabs'] = $tabs;
     return $this;
 }
 /**
  * Select items according to conditions passed in GET
  * Conditions can be == 'unanswered', 'hot', 'recent' (default)
  */
 protected function getCursor()
 {
     $cond = $this->Request->get('cond', 's', 'recent');
     d('cond: ' . $cond);
     /**
      * Default sort is by timestamp Descending
      * meaning most recent should be on top
      *
      */
     $sort = array('i_ts' => -1);
     /**
      * @todo translate this title later
      *
      */
     $this->title = 'Questions with no accepted answer';
     switch ($cond) {
         /**
          * Most answers/comments/views
          * There is an activity counter
          * 1 point per view, 10 point per comment,
          * 50 points per answer
          * but still limit to 30 days
          * Cache Tags for 1 day only
          * uncache onQuestionVote, onQuestionComment
          */
         case 'noanswer':
             $this->title = $this->_('Topics without response');
             $this->pagerPath = '/unanswered/noanswers';
             $where = array('i_ans' => 0);
             $this->typeDiv = Urhere::factory($this->Registry)->get('tplQuntypes', 'noanswer');
             break;
         case 'tagged':
             $where = array('i_sel_ans' => null, 'a_tags' => array('$all' => $this->getTags()));
             $this->pagerPath = '/unanswered/tagged/' . $this->rawTags;
             $this->typeDiv = Urhere::factory($this->Registry)->get('tplQuntypes', 'newest');
             $this->makeFollowTagButton();
             $replaced = \str_replace(' ', ' + ', $this->tags);
             $this->counterTaggedText = \tplCounterblocksub::parse(array($replaced, $this->_('Tagged')), false);
             break;
             /**
              * Default is all questions
              * with no selected answer!
              */
         /**
          * Default is all questions
          * with no selected answer!
          */
         default:
             $this->title = $this->_('Questions with no accepted answer');
             $where = array('i_sel_ans' => null);
             $this->typeDiv = Urhere::factory($this->Registry)->get('tplQuntypes', 'newest');
     }
     /**
      * Exclude deleted items
      */
     $where['i_del_ts'] = null;
     $this->Cursor = $this->Registry->Mongo->QUESTIONS->find($where, $this->aFields);
     $this->count = $this->Cursor->count(true);
     d('$this->Cursor: ' . gettype($this->Cursor) . ' $this->count: ' . $this->count);
     $this->Cursor->sort($sort);
     return $this;
 }
예제 #4
0
 /**
  * Select items according to conditions passed in GET
  * Conditions can be == 'unanswered', 'hot', 'recent' (default)
  *
  * @return \Lampcms\Controllers\Unanswered
  */
 protected function getCursor()
 {
     $urlParts = $this->Registry->Ini->getSection('URI_PARTS');
     $cond = $this->Router->getSegment(1, 's', $urlParts['SORT_RECENT']);
     d('cond: ' . $cond);
     /**
      * Default sort is by timestamp Descending
      * meaning most recent should be on top
      *
      */
     $sort = array(Schema::CREATED_TIMESTAMP => -1);
     $this->title = '@@Questions with no accepted answer@@';
     switch ($cond) {
         /**
          * Most answers/comments/views
          * There is an activity counter
          * 1 point per view, 10 point per comment,
          * 50 points per answer
          * but still limit to 30 days
          * Cache Tags for 1 day only
          * uncache onQuestionVote, onQuestionComment
          */
         case $urlParts['COND_NOANSWERS']:
             $this->title = '@@Questions with no answers@@';
             $this->pagerPath .= '/{_COND_NOANSWERS_}';
             $where = array(Schema::NUM_ANSWERS => 0);
             $this->typeDiv = Urhere::factory($this->Registry)->get('tplQuntypes', 'noanswer');
             break;
         case $urlParts['COND_TAGGED']:
             $where = array(Schema::SELECTED_ANSWER_ID => null, Schema::TAGS_ARRAY => array('$all' => $this->getTags($urlParts['COND_TAGGED'])));
             $this->pagerPath .= '/{_COND_TAGGED_}' . $this->rawTags;
             $this->typeDiv = Urhere::factory($this->Registry)->get('tplQuntypes', 'newest');
             $this->makeFollowTagButton();
             $replaced = array('tags' => \str_replace(' ', ' + ', $this->tags), 'text' => '@@Tagged@@');
             $this->counterTaggedText = \tplCounterblocksub::parse($replaced, false);
             break;
             /**
              * Default is all questions
              * with no selected answer!
              */
         /**
          * Default is all questions
          * with no selected answer!
          */
         default:
             $this->title = '@@Questions with no accepted answer@@';
             $where = array(Schema::SELECTED_ANSWER_ID => null);
             $this->typeDiv = Urhere::factory($this->Registry)->get('tplQuntypes', 'newest');
     }
     /**
      * Exclude deleted items
      */
     if ($this->Registry->Viewer->isModerator()) {
         $where[Schema::RESOURCE_STATUS_ID] = array('$lt' => Schema::DELETED);
     } else {
         $where[Schema::RESOURCE_STATUS_ID] = Schema::POSTED;
     }
     $this->Cursor = $this->Registry->Mongo->QUESTIONS->find($where, $this->aFields);
     $this->count = $this->Cursor->count(true);
     d('$this->Cursor: ' . gettype($this->Cursor) . ' $this->count: ' . $this->count);
     $this->Cursor->sort($sort);
     return $this;
 }
예제 #5
0
 /**
  * Sets the value of "sort by" tabs
  *
  * Will not add any tabs if there are fewer than 4 users on the site
  * because there are just 4 "sort by" tabs
  * and there is no need to sort the results
  * of just 4 items
  *
  * @return object $this
  */
 protected function makeSortTabs()
 {
     $tabs = '';
     /**
      * Does not make sense to show
      * any type of 'sort by' when
      * Total number of users is
      * fewer than number of "sort by" tabs
      */
     if ($this->usersCount > 4) {
         $tabs = Urhere::factory($this->Registry)->get('tplUsertypes', $this->sort);
     }
     $aVars = array($this->usersCount, 1 === $this->usersCount ? 'User' : 'Users', $tabs);
     $this->aPageVars['body'] .= \tplUsersheader::parse($aVars, false);
     return $this;
 }
예제 #6
0
 /**
  * Select items according to conditions passed in GET
  * Conditions can be == 'unanswered', 'hot', 'recent' (default)
  */
 protected function getCursor()
 {
     $aFields = array('tag', 'i_count', 'hts');
     $cond = $this->Request->get('cond', 's', 'popular');
     d('cond: ' . $cond);
     /**
      * Default sort is by timestamp Descending
      * meaning most recent should be on top
      *
      */
     $sort = array('tag' => 1);
     /**
      * @todo translate this title later
      *
      */
     $this->title = 'Tags';
     switch ($cond) {
         /**
          * Hot is strictly per views
          */
         case 'popular':
             $sort = array('i_count' => -1);
             $this->title = 'Popular tags';
             $this->pagerPath = '/tags/popular';
             d('cp');
             break;
             /**
              * Most answers/comments/views
              * There is an activity counter
              * 1 point per view, 10 point per comment,
              * 50 points per answer
              * but still limit to 30 days
              * Cache Tags for 1 day only
              * uncache onQuestionVote, onQuestionComment
              */
         /**
          * Most answers/comments/views
          * There is an activity counter
          * 1 point per view, 10 point per comment,
          * 50 points per answer
          * but still limit to 30 days
          * Cache Tags for 1 day only
          * uncache onQuestionVote, onQuestionComment
          */
         case 'recent':
             $this->title = 'Recent tags';
             $sort = array('i_ts' => -1);
             $this->pagerPath = '/tags/recent';
             d('cp');
             break;
             /**
              * Default is all questions
              * Tags are qrecent
              * uncache qrecent onNewQuestion only!
              */
         /**
          * Default is all questions
          * Tags are qrecent
          * uncache qrecent onNewQuestion only!
          */
         default:
             $sort = array('tag' => 1);
     }
     $this->typeDiv = Urhere::factory($this->Registry)->get('tplTagsort', $cond);
     $this->Cursor = $this->Registry->Mongo->QUESTION_TAGS->find(array('i_count' => array('$gt' => 0)), $aFields);
     $this->count = $this->Cursor->count(true);
     d('$this->Cursor: ' . gettype($this->Cursor) . ' $this->count: ' . $this->count);
     $this->Cursor->sort($sort);
     return $this;
 }
예제 #7
0
 /**
  * Select items according to conditions passed in GET
  * Conditions can be == 'unanswered', 'hot', 'recent' (default)
  *
  * @return \Lampcms\Controllers\Viewqtags|\Lampcms\Controllers\Viewquestions
  */
 protected function getCursor()
 {
     $uriParts = $this->Registry->Ini->getSection('URI_PARTS');
     $aFields = array('tag', 'i_count', 'hts');
     $cond = $this->Router->getSegment(1, 's', $uriParts['SORT_POPULAR']);
     d('cond: ' . $cond);
     $this->title = '@@Tags@@';
     switch ($cond) {
         /**
          * Hot is strictly per views
          */
         case $uriParts['SORT_POPULAR']:
             $sort = array('i_count' => -1);
             $this->title = '@@Popular tags@@';
             $this->pagerPath = '{_viewqtags_}/{_SORT_POPULAR_}';
             d('cp');
             break;
             /**
              * Most answers/comments/views
              * There is an activity counter
              * 1 point per view, 10 point per comment,
              * 50 points per answer
              * but still limit to 30 days
              * Cache Tags for 1 day only
              * uncache onQuestionVote, onQuestionComment
              */
         /**
          * Most answers/comments/views
          * There is an activity counter
          * 1 point per view, 10 point per comment,
          * 50 points per answer
          * but still limit to 30 days
          * Cache Tags for 1 day only
          * uncache onQuestionVote, onQuestionComment
          */
         case $uriParts['SORT_RECENT']:
             $this->title = '@@Recent tags@@';
             $sort = array('i_ts' => -1);
             $this->pagerPath = '{_viewqtags_}/{_SORT_RECENT_}';
             d('cp');
             break;
             /**
              * Default is all questions
              * Tags are qrecent
              * uncache qrecent onNewQuestion only!
              */
         /**
          * Default is all questions
          * Tags are qrecent
          * uncache qrecent onNewQuestion only!
          */
         default:
             $sort = array('tag' => 1);
     }
     $this->typeDiv = Urhere::factory($this->Registry)->get('tplTagsort', $cond);
     $this->Cursor = $this->Registry->Mongo->QUESTION_TAGS->find(array('i_count' => array('$gt' => 0)), $aFields);
     $this->count = $this->Cursor->count(true);
     d('$this->Cursor: ' . gettype($this->Cursor) . ' $this->count: ' . $this->count);
     $this->Cursor->sort($sort);
     return $this;
 }