/** This function gets the article information based on the defined criteria * * @return array */ protected function getContent() { // First, compose the sql $sql = "SELECT node.contenttypeid, node.url, node.publishdate, node.userid, node.setpublish, node.publicpreview, info.title, user.username, node.showuser, node.nodeid, node.contenttypeid, thread.replycount FROM " . TABLE_PREFIX . "cms_node AS node INNER JOIN " . TABLE_PREFIX . "contenttype AS type on type.contenttypeid = node.contenttypeid INNER JOIN " . TABLE_PREFIX . "cms_nodeinfo AS info on info.nodeid = node.nodeid " . ( (($this->config['categories'] != '') AND ($this->config['categories'] != '0')) ? " INNER JOIN " . TABLE_PREFIX . "cms_nodecategory nc ON nc.nodeid = node.nodeid " : '') . " LEFT JOIN " . TABLE_PREFIX . "user AS user ON user.userid = node.userid LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON thread.threadid = info.associatedthreadid WHERE type.isaggregator = '0' AND " . vBCMS_Permissions::getPermissionString() ; if (($this->config['categories'] != '') AND ($this->config['categories'] != '0') ) { $sql .= "\n AND nc.categoryid IN (" . $this->config['categories'] . ")\n"; } if (($this->config['sections'] != '') AND ($this->config['sections'] != '0')) { $sql .= "\n AND node.parentnode IN (" . $this->config['sections'] . ")\n"; } if (isset($this->config['days']) AND (intval($this->config['days'])) ) { $sql .= "\n AND node.publishdate > " . (TIMENOW - (86400 * $this->config['days'])) . "\n"; } $sql .= "\n ORDER BY node.publishdate DESC LIMIT " . $this->config['count']; $items = array(); //Execute if ($rst = vB::$db->query_read($sql)) { $current_record = array('contentid' => -1); //now build the results array while($item = vB::$db->fetch_array($rst)) { $item['categories'] = array(); $item['tags'] = array(); $class = vB_Types::instance()->getContentTypeClass($item['contenttypeid']); $package = vB_Types::instance()->getContentTypePackage($item['contenttypeid']); $node = vBCms_Content::create($package, $class, $item['nodeid']); $item['pagetext'] = $item['previewtext'] = ''; //get the avatar if (vB::$vbulletin->options['avatarenabled']) { $item['avatar'] = fetch_avatar_url($item['userid']); } if (method_exists($node, 'getPageText')) { $item['pagetext'] = fetch_censored_text($node->getPageText()); } if (method_exists($node, 'getPreviewText')) { $item['previewtext'] = fetch_censored_text($node->getPreviewText()); } else if (!empty($item['pagetext'])) { $item['previewtext'] = vB_Search_Searchtools::getSummary($item['pagetext'], 200); } if (method_exists($node, 'getPreviewImage')) { $item['pagetext'] = fetch_censored_text($node->getPageText()); } $items[$item['nodeid']] = $item; } //Let's get the tags and the categories // we can do that with one query each. if (count($articles)) { //first let's get categories $nodeids = implode(', ', array_keys($item)); $sql = "SELECT nc.nodeid, nc.categoryid, category.category FROM " . TABLE_PREFIX . "cms_nodecategory AS nc INNER JOIN " . TABLE_PREFIX . "cms_category AS category ON category.categoryid = nc.categoryid WHERE nc.nodeid IN ($nodeids)"; if ($rst = vB::$db->query_read($sql)) { while ($record = vB::$db->fetch_array($rst)) { $route_info = $record['categoryid'] . ($record['category'] != '' ? '-' . str_replace(' ', '-', $record['category']) : ''); $record['route_info'] = $route_info; $record['category_url'] = vB_Route::create('vBCms_Route_List', "category/" . $record['route_info'] . "/1")->getCurrentURL(); $items[$record['nodeid']]['categories'][$record['categoryid']] = $record; } } //next tags; $sql = "SELECT tag.tagid, node.nodeid, tag.tagtext FROM " . TABLE_PREFIX . "cms_node AS node INNER JOIN " . TABLE_PREFIX . "tagcontent AS tc ON (tc.contentid = node.contentid AND tc.contenttypeid = node.contenttypeid) INNER JOIN " . TABLE_PREFIX . "tag AS tag ON tag.tagid = tc.tagid WHERE node.nodeid IN ($nodeids) "; if ($rst = vB::$db->query_read($sql)) { while ($record = vB::$db->fetch_array($rst)) { $items[$record['nodeid']]['tags'][$record['tagid']] = $record['tagtext']; } } } } return $items; }
/** * function to return the rendered html for this result * * @param string $current_user * @param object $criteria * @return */ public function render($current_user, $criteria, $template_name = '') { global $vbulletin; global $show; include_once DIR . '/vb/search/searchtools.php'; if (!strlen($template_name)) { $template_name = 'vbcms_searchresult_statichtml'; } $template = vB_Template::create($template_name); $template->register('title', $this->record['title'] ); $template->register('html_title', $this->record['html_title'] ); $template->register('page_url', vB_Route::create('vBCms_Route_Content', $this->record['nodeid'])->getCurrentURL()); $template->register('username', $this->record['username']); $template->register('user', array( 'username' => $this->record['username'], 'userid' => $this->record['userid'], )); $template->register('parentnode', $this->record['parentnode']); $template->register('parenttitle', $this->record['parenttitle']); $template->register('parent_html_title', $this->record['parent_html_title']); $template->register('pagetext', vB_Search_Searchtools::getSummary(vB_Search_Searchtools::stripHtmlTags($this->record['pagetext']), 100)); $template->register('publishdate', $this->record['publishdate']); $template->register('published', $this->record['publishdate'] >= TIMENOW ? true : false ); $template->register('dateline', date($vbulletin->options['dateformat']. ' ' . $vbulletin->options['default_timeformat'], $this->record['dateline'])); $template->register('dateformat', $vbulletin->options['dateformat']); $template->register('timeformat', $vbulletin->options['default_timeformat']); $template->register('categories', $this->record['categories']); $result = $template->render(); return $result; }
/** * function to return the rendered html for this result * * @param string $current_user * @param object $criteria * @return */ public function render($current_user, $criteria, $template_name = '') { global $vbulletin; global $show; include_once DIR . '/vb/search/searchtools.php'; if (!strlen($template_name)) { $template_name = 'vbcms_content_article_preview'; } $template = vB_Template::create($template_name); $template->register('title', $this->record['title'] ); $template->register('html_title', $this->record['html_title'] ); $page_url = vB_Route::create('vBCms_Route_Content', $this->record['nodeid'])->getCurrentURL(); $template->register('page_url', $page_url); $join_char = strpos($page_url,'?') ? '&' : '?'; $template->register('newcomment_url', $page_url . $join_char . "goto=newcomment"); $template->register('username', $this->record['username']); $template->register('description', $this->record['description']); $template->register('pagetext', vB_Search_Searchtools::getSummary($this->record['pagetext'], 100)); $template->register('dateline', date($vbulletin->options['dateformat']. ' ' . $vbulletin->options['default_timeformat'], $this->record['dateline'])); $result = $template->render(); return $result; }
/** * vBForum_Search_Result_VisitorMessage::render() * * @param string $current_user * @param object $criteria * @return */ public function render($current_user, $criteria, $template_name = '') { global $vbulletin; if (!strlen($template_name)) { $template_name = 'search_results_visitormessage'; } //TODO- create a template and pass it the necessary information //TODO- check vbphrase and see what we have to add. //TODO- figure if we are passing the right parameters. I suspect not. global $show; $template = vB_Template::create($template_name); $template->register('messagetext', vB_Search_Searchtools::getSummary($this->message['pagetext'], 100)); //The template is out with the variables fromid and toid. It should just be // from and to, but we need to get out a simple patch. $from = array('userid' => $this->message['postuserid'], 'username' => $this->message['postusername']); $to = array('userid' => $this->message['userid'], 'username' => $this->message['username']); $template->register('vmid', $this->message['vmid']); $template->register('to', $this->message['username']); $template->register('from', $this->message['postusername']); $template->register('fromid', $from); $template->register('toid', $to); $template->register('sent', date($vbulletin->options['dateformat']. ' ' . $vbulletin->options['default_timeformat'], $this->message['dateline'])); $template->register('dateline', $this->message['dateline']); $template->register('dateformat', $vbulletin->options['dateformat']); $template->register('timeformat', $vbulletin->options['default_timeformat']); return $template->render(); }
/** * vBForum_Search_Result_VisitorMessage::render() * * @param string $current_user * @param object $criteria * @return */ public function render($current_user, $criteria, $template_name = '') { require_once DIR . '/includes/functions_user.php'; if (!strlen($template_name)) { $template_name = 'search_results_visitormessage'; } //TODO- create a template and pass it the necessary information //TODO- check vbphrase and see what we have to add. //TODO- figure if we are passing the right parameters. I suspect not. global $show; $template = vB_Template::create($template_name); $template->register('messagetext', vB_Search_Searchtools::getSummary($this->message['pagetext'], 100)); //The template is out with the variables fromid and toid. It should just be // from and to, but we need to get out a simple patch. $from = array('userid' => $this->message['postuserid'], 'username' => $this->message['postusername']); $to = array('userid' => $this->message['userid'], 'username' => $this->message['username']); $template->register('vmid', $this->message['vmid']); $template->register('to', $this->message['username']); $template->register('from', $this->message['postusername']); $template->register('fromid', $from); $template->register('toid', $to); $template->register('sentdate', vbdate(vB::$vbulletin->options['dateformat'], $this->message['dateline'], true)); $template->register('senttime', vbdate(vB::$vbulletin->options['timeformat'], $this->message['dateline'])); if (vB::$vbulletin->options['avatarenabled']) { $template->register('avatar', fetch_avatar_from_record($this->message, true, 'postuserid')); } return $template->render(); }