/** * 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; }
/** * Select items according to conditions passed in GET * Conditions can be == 'unanswered', 'hot', 'recent' (default) */ protected function getCursor() { /** * Must call getTags() before * using this->rawTags because * it is set inside the getTags() method * * */ $this->aTags = $this->getTags(); $this->pagerPath = '/tagged/' . $this->rawTags; d('aTags: ' . print_r($this->aTags, 1)); $cond = $this->Request->get('cond', 's', 'recent'); /** * Default sort is by timestamp Descending * meaning most recent should be on top * */ $sort = array('i_ts' => -1); $where = array('a_tags' => array('$all' => $this->aTags)); $where['i_del_ts'] = null; $this->counterTaggedText = \tplCounterblocksub::parse(array(str_replace(' ', ' + ', $this->tags), $this->_('Tagged')), false); $this->Cursor = $this->Registry->Mongo->QUESTIONS->find($where, $this->aFields); $this->count = $this->Cursor->count(true); $this->Cursor->sort($sort); return $this; }
/** * 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; }
/** * Select items according to conditions passed in GET * Conditions can be == 'unanswered', 'hot', 'recent' (default) * * @throws \Lampcms\RedirectException * @return \Lampcms\Controllers\Tagged */ protected function getCursor() { /** * Must call getTags() before * using this->rawTags because * it is set inside the getTags() method * * */ $this->aTags = $this->getTags(); if (!isset($this->aTags)) { d('Tags not found in request: ' . $_SERVER['REQUEST_URI']); /** * No tags passed in url * just redirect to view all tags * */ throw new RedirectException("{_WEB_ROOT_}/{_viewqtags_}/"); } $this->pagerPath = '{_tagged_}/' . $this->rawTags; d('aTags: ' . print_r($this->aTags, 1)); $cond = $this->Request->get('cond', 's', 'recent'); /** * Default sort is by timestamp Descending * meaning most recent should be on top * */ $sort = array(Schema::CREATED_TIMESTAMP => -1); $where = array(Schema::TAGS_ARRAY => array('$all' => $this->aTags)); /** * 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; } $replaced = array('tags' => \str_replace(' ', ' + ', $this->tags), 'text' => '@@Tagged@@'); $this->counterTaggedText = \tplCounterblocksub::parse($replaced, false); $this->Cursor = $this->Registry->Mongo->QUESTIONS->find($where, $this->aFields); $this->count = $this->Cursor->count(true); $this->Cursor->sort($sort); return $this; }