/** * Calculates related tags * via shutdown function * * @return object $this */ protected function addRelatedTags() { $oRelated = Relatedtags::factory($this->Registry); $Question = $this->Question; if (count($Question['a_tags']) > 0) { d('cp'); $callable = function () use($oRelated, $Question) { $oRelated->addTags($Question); }; runLater($callable); } d('cp'); return $this; }
protected function makeRecentTags() { /** * @todo * Currently we are finding related tags for just one tag * This is very fast because we store related tags pre-parsed * as html string. This works and looks good but... * If we really wanted this to work just like * on stackoverflow then we have to change it to this: * if there is only one tag passed in URL, then use this method * otherwise do this: * Use find() on RELATED_TAGS collection and pass $this->aTags * as $all condition. This will find all records in RELATED_TAGS * that have all these tags. Then we have result cursor from which * we are only interested in _id value which is the actual tag related * to all our tags. * We would then loop over cursor and pass * each array to tplRelatedlink, passing each _id * as value of 'tag' and prepend +tag to $this->rawTags as * value of 'link' * * This will be slower than just using pre-parsed related tags * but it will be exactly like on Stackoverflow * * For this to work we need to ensureIndex on 'tags' in RELATED_TAGS * collection! */ $tag = end($this->aTags); d('tag: ' . $tag); $s = Relatedtags::factory($this->Registry)->getHtml($tag); if (!empty($s)) { $tags = \tplBoxrecent::parse(array('tags' => $s, 'title' => $this->_('Related Tags'))); $this->aPageVars['tags'] = $tags; } $this->makeFollowTagButton(); return $this; }
/** * Update USER_TAGS and QUESTION_TAGS collections * to add new tags that belong to this questions * * @return object $this */ protected function addNewTags() { if (count($this->aSubmitted) > 0) { \Lampcms\Qtagscounter::factory($this->Registry)->parse($this->Question); \Lampcms\UserTags::factory($this->Registry)->addTags($this->Question['i_uid'], $this->Question); \Lampcms\Relatedtags::factory($this->Registry)->addTags($this->Question); if (0 === $this->Question['i_sel_ans']) { d('going to add to Unanswered tags'); \Lampcms\UnansweredTags::factory($this->Registry)->set($this->Question); } } return $this; }
/** * Calculates related tags * via shutdown function * * @return object $this */ protected function addRelatedTags() { $Related = Relatedtags::factory($this->Registry); $Question = $this->Question; if (count($Question['a_tags']) > 0) { d('cp'); $callable = function () use($Related, $Question) { try { $Related->addTags($Question); } catch (\Exception $e) { // cannot do much here, only error_log may be // safe to use } }; runLater($callable); } d('cp'); return $this; }