function smarty_function_poll($params, &$smarty) { global $polllib; global $dbTiki; global $commentslib; global $feature_poll_comments; extract($params); // Param = zone if (!is_object($polllib)) { include_once 'lib/polls/polllib_shared.php'; } include_once 'lib/commentslib.php'; if (isset($rate)) { if (!$tikilib->page_exists($rate)) { return false; } } if (empty($id)) { $id = $polllib->get_random_active_poll(); } if ($id) { $menu_info = $polllib->get_poll($id); $channels = $polllib->list_poll_options($id); if ($feature_poll_comments == 'y') { $commentslib = new Comments($dbTiki); $comments_count = $commentslib->count_comments("poll:" . $menu_info["pollId"]); } $smarty->assign('comments', $comments_count); $smarty->assign('ownurl', 'tiki-poll_results.php?pollId=' . $id); $smarty->assign('menu_info', $menu_info); $smarty->assign('channels', $channels); $smarty->display('tiki-poll.tpl'); } }
function smarty_function_poll($params, $smarty) { global $polllib, $dbTiki, $commentslib, $prefs; global $tiki_p_view_poll_results, $tiki_p_vote_poll; extract($params); // Param = zone if (!is_object($polllib)) { include_once 'lib/polls/polllib_shared.php'; } include_once 'lib/comments/commentslib.php'; if (isset($rate)) { if (!$tikilib->page_exists($rate)) { return false; } } if (empty($id)) { $id = $polllib->get_random_poll("a"); } if ($id == "current") { $id = $polllib->get_random_poll("c"); } if ($tiki_p_view_poll_results != 'y' && $tiki_p_vote_poll != 'y') { return tra('You do not have permission to use this feature'); } if ($id) { $menu_info = $polllib->get_poll($id); if ($menu_info) { $channels = $polllib->list_poll_options($id); if ($prefs['feature_poll_comments'] == 'y') { $commentslib = new Comments($dbTiki); $comments_count = $commentslib->count_comments("poll:" . $menu_info["pollId"]); } else { $comments_count = 0; } $smarty->assign('comments_cant', $comments_count); if ($tiki_p_view_poll_results == 'y') { $smarty->assign('ownurl', 'tiki-poll_results.php?pollId=' . $id); } $smarty->assign('menu_info', $menu_info); $smarty->assign('channels', $channels); $ret = $smarty->fetch('tiki-poll.tpl'); return $ret; } } }
} if (!empty($forum_mode) && $forum_mode == 'y') { $_REQUEST["comments_parentId"] > 0; } if (isset($_REQUEST["post_reply"]) && isset($_REQUEST["comments_reply_threadId"])) { $threadId_if_reply = $_REQUEST["comments_reply_threadId"]; } else { $threadId_if_reply = 0; } // $end_time = microtime(true); // print "TIME4 in comments.php: ".($end_time - $start_time)."\n"; $comments_coms = $commentslib->get_comments($comments_objectId, $_REQUEST["comments_parentId"], $comments_offset, $comments_per_page, $thread_sort_mode, $_REQUEST["comments_commentFind"], $_REQUEST['comments_threshold'], $thread_style, $threadId_if_reply); // $end_time = microtime(true); // print "TIME5 in comments.php: ".($end_time - $start_time)."\n"; if ($comments_prefix_var == 'forum:') { $comments_cant = $commentslib->count_comments('topic:' . $_REQUEST['comments_parentId']); // comments in the topic not in the forum } else { $comments_cant = $commentslib->count_comments($comments_objectId); } $comments_cant_page = $comments_coms['cant']; $smarty->assign('comments_below', $comments_coms["below"]); $smarty->assign('comments_cant', $comments_cant); //print "<pre>"; //print_r($comments_coms); //print "</pre>"; // Offset management $comments_maxRecords = $comments_per_page; //print "<pre>Counts: "; //print_r($comments_cant); //print ",";
function wikiplugin_articles($data, $params) { global $smarty, $tikilib, $prefs, $tiki_p_read_article, $tiki_p_articles_read_heading, $dbTiki, $pageLang; global $artlib; require_once 'lib/articles/artlib.php'; $default = array('max' => -1, 'start' => 0, 'usePagination' => 'n', 'topicId' => '', 'topic' => '', 'sort' => 'publishDate_desc', 'type' => '', 'lang' => '', 'quiet' => 'n', 'categId' => '', 'largefirstimage' => 'n', 'urlparam' => '', 'translationOrphan' => '', 'showtable' => 'n'); $auto_args = array('lang', 'topicId', 'topic', 'sort', 'type', 'lang', 'categId'); $params = array_merge($default, $params); extract($params, EXTR_SKIP); $filter = ''; if ($prefs['feature_articles'] != 'y') { // the feature is disabled or the user can't read articles, not even article headings return ""; } $urlnext = ''; if ($usePagination == 'y') { //Set offset when pagniation is used if (!isset($_REQUEST["offset"])) { $start = 0; } else { $start = $_REQUEST["offset"]; } //Default to 10 when pagination is used if ($max == -1) { $countPagination = 10; } foreach ($auto_args as $arg) { if (!empty(${$arg})) { $paramsnext[$arg] = ${$arg}; } } $paramsnext['_type'] = 'absolute_path'; $smarty->loadPlugin('smarty_function_query'); $urlnext = smarty_function_query($paramsnext, $smarty); } $smarty->assign_by_ref('quiet', $quiet); $smarty->assign_by_ref('urlparam', $urlparam); $smarty->assign_by_ref('urlnext', $urlnext); if (!isset($containerClass)) { $containerClass = 'wikiplugin_articles'; } $smarty->assign('container_class', $containerClass); $dateStartTS = 0; $dateEndTS = 0; // if a period of time is set, date start and end are ignored if (isset($periodQuantity)) { switch ($periodUnit) { case 'hour': $periodUnit = 3600; break; case 'day': $periodUnit = 86400; break; case 'week': $periodUnit = 604800; break; case 'month': $periodUnit = 2628000; break; default: break; } if (is_int($periodUnit)) { $dateStartTS = $tikilib->now - $periodQuantity * $periodUnit; $dateEndTS = $tikilib->now; } } else { if (isset($dateStart)) { $dateStartTS = strtotime($dateStart); } if (isset($dateEnd)) { $dateEndTS = strtotime($dateEnd); } } if (isset($fullbody) && $fullbody == 'y') { $smarty->assign('fullbody', 'y'); } else { $smarty->assign('fullbody', 'n'); $fullbody = 'n'; } $smarty->assign('largefirstimage', $largefirstimage); if (!isset($overrideDates)) { $overrideDates = 'n'; } if (!empty($translationOrphan)) { $filter['translationOrphan'] = $translationOrphan; } if (!empty($articleId)) { $filter['articleId'] = $articleId; } if (!empty($notArticleId)) { $filter['notArticleId'] = $notArticleId; } include_once "lib/comments/commentslib.php"; $commentslib = new Comments($dbTiki); if (count($categId) == 0) { $categIds = ''; } elseif (count($categId) == 1) { // For performance reasons, if there is only one value, the SQL query should not return IN () as it does with arrays // So we send a single value instead of a single-value array $categIds = $categId[0]; } else { // We want the list of articles which are in all categories $categIds = array('AND' => $categId); } $listpages = $artlib->list_articles($start, $max, $sort, '', $dateStartTS, $dateEndTS, 'admin', $type, $topicId, 'y', $topic, $categIds, '', '', $lang, '', '', $overrideDates == 'y', 'y', $filter); if ($prefs['feature_multilingual'] == 'y' && empty($translationOrphan)) { global $multilinguallib; include_once "lib/multilingual/multilinguallib.php"; $listpages['data'] = $multilinguallib->selectLangList('article', $listpages['data'], $pageLang); } for ($i = 0, $icount_listpages = count($listpages["data"]); $i < $icount_listpages; $i++) { $listpages["data"][$i]["parsed_heading"] = $tikilib->parse_data($listpages["data"][$i]["heading"], array('min_one_paragraph' => true)); if ($fullbody == 'y') { $listpages["data"][$i]["parsed_body"] = $tikilib->parse_data($listpages["data"][$i]["body"], array('min_one_paragraph' => true, 'is_html' => $prefs['feature_wysiwyg'] === 'y' && $prefs['wysiwyg_htmltowiki'] !== 'y')); } $comments_prefix_var = 'article:'; $comments_object_var = $listpages["data"][$i]["articleId"]; $comments_objectId = $comments_prefix_var . $comments_object_var; $listpages["data"][$i]["comments_cant"] = $commentslib->count_comments($comments_objectId); //print_r($listpages["data"][$i]['title']); } global $artlib; require_once 'lib/articles/artlib.php'; $topics = $artlib->list_topics(); $smarty->assign_by_ref('topics', $topics); if (!empty($topic) && !strstr($topic, '!') && !strstr($topic, '+')) { $smarty->assign_by_ref('topic', $topic); } elseif (!empty($topicId) && is_numeric($topicId)) { if (!empty($listpages['data'][0]['topicName'])) { $smarty->assign_by_ref('topic', $listpages['data'][0]['topicName']); } else { $topic_info = $artlib->get_topic($topicId); if (isset($topic_info['name'])) { $smarty->assign_by_ref('topic', $topic_info['name']); } } } if (!empty($type) && !strstr($type, '!') && !strstr($type, '+')) { $smarty->assign_by_ref('type', $type); } if ($usePagination == 'y') { $smarty->assign('maxArticles', $max); $smarty->assign_by_ref('offset', $start); $smarty->assign_by_ref('cant', $listpages['cant']); } if (!empty($order)) { foreach ($listpages['data'] as $i => $article) { $memo[$article['articleId']] = $i; } foreach ($order as $articleId) { if (isset($memo[$articleId])) { $list[] = $listpages['data'][$memo[$articleId]]; } } foreach ($listpages['data'] as $i => $article) { if (!in_array($article['articleId'], $order)) { $list[] = $article; } } $smarty->assign_by_ref('listpages', $list); } else { $smarty->assign_by_ref('listpages', $listpages["data"]); } $smarty->assign('usePagination', $usePagination); $smarty->assign_by_ref('actions', $actions); if (isset($titleonly) && $titleonly == 'y') { return "~np~ " . $smarty->fetch('tiki-view_articles-titleonly.tpl') . " ~/np~"; } else { return "~np~ " . $smarty->fetch('tiki-view_articles.tpl') . " ~/np~"; } //return str_replace("\n","",$smarty->fetch('tiki-view_articles.tpl')); // this considers the hour in the header like a link }
if ($forum_check[0] == 'forum') { $smarty->assign('forumId', $forum_check[1]); } if (isset($_REQUEST["comments_grandParentId"])) { $smarty->assign('comments_grandParentId', $_REQUEST["comments_grandParentId"]); } if (!empty($forum_mode) && $forum_mode == 'y') { $_REQUEST["comments_parentId"] > 0; } if (isset($_REQUEST["post_reply"]) && isset($_REQUEST["comments_reply_threadId"])) { $threadId_if_reply = $_REQUEST["comments_reply_threadId"]; } else { $threadId_if_reply = 0; } $comments_coms = $commentslib->get_comments($comments_objectId, $_REQUEST["comments_parentId"], $comments_offset, $_REQUEST["comments_maxComments"], $_REQUEST["comments_sort_mode"], $_REQUEST["comments_commentFind"], $_REQUEST['comments_threshold'], $_REQUEST["comments_style"], $threadId_if_reply); $comments_cant = $commentslib->count_comments($comments_objectId); $comments_cant_page = $comments_coms['cant']; $smarty->assign('comments_below', $comments_coms["below"]); $smarty->assign('comments_cant', $comments_cant); //print "<pre>"; //print_r($comments_coms); //print "</pre>"; // Offset management $comments_maxRecords = $_REQUEST["comments_maxComments"]; //print "<pre>Counts: "; //print_r($comments_cant); //print ","; //print_r($comments_maxRecords); //print "</pre>"; if ($comments_maxRecords != 0) { $comments_cant_pages = ceil($comments_cant_page / $comments_maxRecords);
$categId = ''; } $smarty->assign_by_ref('categId', $categId); if (!isset($_REQUEST['lang'])) { $_REQUEST['lang'] = ''; } // Get a list of last changes to the Wiki database $listpages = $tikilib->list_articles($offset, $prefs['maxArticles'], $sort_mode, $find, $pdate, $user, $type, $topic, 'y', $topicName, $categId, '', '', $_REQUEST['lang']); if ($prefs['feature_multilingual'] == 'y') { include_once "lib/multilingual/multilinguallib.php"; $listpages['data'] = $multilinguallib->selectLangList('article', $listpages['data']); } $temp_max = count($listpages["data"]); for ($i = 0; $i < $temp_max; $i++) { $listpages["data"][$i]["parsed_heading"] = $tikilib->parse_data($listpages["data"][$i]["heading"]); $comments_prefix_var = 'article:'; $comments_object_var = $listpages["data"][$i]["articleId"]; $comments_objectId = $comments_prefix_var . $comments_object_var; $listpages["data"][$i]["comments_cant"] = $commentslib->count_comments($comments_objectId); } $topics = $artlib->list_topics(); $smarty->assign_by_ref('topics', $topics); $smarty->assign('maxArticles', $prefs['maxArticles']); // If there're more records then assign next_offset $smarty->assign_by_ref('listpages', $listpages["data"]); $smarty->assign_by_ref('cant', $listpages["cant"]); include_once 'tiki-section_options.php'; ask_ticket('view_article'); // Display the template $smarty->assign('mid', 'tiki-view_articles.tpl'); $smarty->display("tiki.tpl");
$smarty->assign('offset', 0); $smarty->assign('sort_mode', $sort_mode); $smarty->assign('total', $total); $smarty->assign('find', ''); $smarty->assign('filters', array()); $smarty->assign('currentPage', 1); $smarty->assign('lastPage', ceil($total / 5)); // licenca padrao if ($licencaId = $tikilib->get_user_preference($view_user, 'licencaPadrao')) { $lController = new PersistentObjectController("License"); $licenca = $lController->noStructureFindAll(array("id" => $licencaId)); $smarty->assign('licenca', $licenca[0]); } $userPosts = $bloglib->list_user_posts($view_user, 0, 5); for ($i = 0; $i < sizeof($userPosts['data']); $i++) { $userPosts['data'][$i]['commentsCount'] = $commentslib->count_comments('post:' . $userPosts['data'][$i]['postId']); } $smarty->assign('userPosts', $userPosts); $liveChannels = array(); $result = $tikilib->query('select * from el_ice where user = ?', array($view_user)); while ($row = $result->fetchRow()) { $liveChannels[] = $row; } $smarty->assign('liveChannels', $liveChannels); $userMessages = $messulib->list_user_messages($view_user, 0, 5, 'date_desc', '', '', '', '', 'messages'); $total = $userMessages['cant']; $smarty->assign('userMessages', $userMessages); $smarty->assign('msgMaxRecords', 5); $smarty->assign('msgOffset', 0); $smarty->assign('msgTotal', $total); $smarty->assign('msgPage', 1);
function wikiplugin_articles($data, $params) { global $smarty, $tikilib, $prefs, $tiki_p_read_article, $tiki_p_articles_read_heading, $dbTiki, $pageLang; extract($params, EXTR_SKIP); if ($prefs['feature_articles'] != 'y' || $tiki_p_read_article != 'y' && $tiki_p_articles_read_heading != 'y') { // the feature is disabled or the user can't read articles, not even article headings return ""; } if (!isset($max)) { $max = '3'; } if (!isset($start)) { $start = '0'; } if (!isset($topicId)) { $topicId = ''; } if (!isset($topic)) { $topic = ''; } if (!isset($sort)) { $sort = 'publishDate_desc'; } // Adds filtering by type if type is passed if (!isset($type)) { $type = ''; } if (!isset($categId)) { $categId = ''; } if (!isset($lang)) { $lang = ''; } if (!isset($quiet)) { $quiet = 'n'; } $smarty->assign_by_ref('quiet', $quiet); include_once "lib/commentslib.php"; $commentslib = new Comments($dbTiki); $listpages = $tikilib->list_articles($start, $max, $sort, '', 0, $tikilib->now, 'admin', $type, $topicId, 'y', $topic, $categId, '', '', $lang); if ($prefs['feature_multilingual'] == 'y') { global $multilinguallib; include_once "lib/multilingual/multilinguallib.php"; $listpages['data'] = $multilinguallib->selectLangList('article', $listpages['data'], $pageLang); } for ($i = 0; $i < count($listpages["data"]); $i++) { $listpages["data"][$i]["parsed_heading"] = $tikilib->parse_data($listpages["data"][$i]["heading"]); $comments_prefix_var = 'article:'; $comments_object_var = $listpages["data"][$i]["articleId"]; $comments_objectId = $comments_prefix_var . $comments_object_var; $listpages["data"][$i]["comments_cant"] = $commentslib->count_comments($comments_objectId); //print_r($listpages["data"][$i]['title']); } global $artlib; require_once 'lib/articles/artlib.php'; $topics = $artlib->list_topics(); $smarty->assign_by_ref('topics', $topics); if (!empty($topic) && !strstr($topic, '!') && !strstr($topic, '+')) { $smarty->assign_by_ref('topic', $topic); } elseif (!empty($topicId) && is_numeric($topicId)) { if (!empty($listpages['data'][0]['topicName'])) { $smarty->assign_by_ref('topic', $listpages['data'][0]['topicName']); } else { $topic_info = $artlib->get_topic($topicId); if (isset($topic_info['name'])) { $smarty->assign_by_ref('topic', $topic_info['name']); } } } if (!empty($type) && !strstr($type, '!') && !strstr($type, '+')) { $smarty->assign_by_ref('type', $type); } $smarty->assign_by_ref('listpages', $listpages["data"]); if (isset($titleonly) && $titleonly == 'y') { return "~np~ " . $smarty->fetch('tiki-view_articles-titleonly.tpl') . " ~/np~"; } else { return "~np~ " . $smarty->fetch('tiki-view_articles.tpl') . " ~/np~"; } //return str_replace("\n","",$smarty->fetch('tiki-view_articles.tpl')); // this considers the hour in the header like a link }
/** * list_blog_posts Returns all the posts for the blog $blogId * * @param int $blogId * @param bool $allowDrafts * @param int $offset * @param int $maxRecords * @param string $sort_mode * @param string $find * @param string $date_min * @param string $date_max * @param string $approved * @access public * @return array posts */ function list_blog_posts($blogId = 0, $allowDrafts = false, $offset = 0, $maxRecords = -1, $sort_mode = 'created_desc', $find = '', $date_min = '', $date_max = '', $approved = 'y') { global $tikilib, $tiki_p_admin, $tiki_p_blog_admin, $tiki_p_blog_post, $user; global $commentslib; require_once 'lib/comments/commentslib.php'; $parserlib = TikiLib::lib('parser'); if (!is_object($commentslib)) { $commentslib = new Comments(); } $mid = array(); $bindvars = array(); $ownsblog = 'n'; if ($blogId > 0) { $mid[] = "tbp.`blogId`=?"; $bindvars[] = (int) $blogId; $blog_data = $this->get_blog($blogId); if ($user && $user == $blog_data["user"]) { $ownsblog = 'y'; } } $mid[] = "tbp.blogId = tb.blogId"; if (!$allowDrafts) { $mid[] = "`priv`!='y'"; } else { // Private posts can be accessed on the following conditions: // user has tiki_p_admin or tiki_p_blog_admin or has written the post // If blog is configured with 'Allow other user to post in this blog', then also if user has tiki_p_blog_post or is owner of this blog if ($tiki_p_admin != 'y' and $tiki_p_blog_admin != 'y' and !isset($blog_data["public"]) || $blog_data["public"] != 'y' || $tiki_p_blog_post != 'y' and !isset($blog_data["public"]) || $blog_data["public"] != 'y' || $ownsblog != 'y') { if (isset($user)) { $mid[] = "(tbp.`priv`!='y' or tbp.`user`=?)"; $bindvars[] = "{$user}"; } else { $mid[] = "tbp.`priv`!='y'"; } } } if ($find) { $findesc = '%' . $find . '%'; $mid[] = "(tbp.`data` like ? or tbp.`title` like ?)"; $bindvars[] = $findesc; $bindvars[] = $findesc; } if ($date_min) { $mid[] = "tbp.`created`>=?"; $bindvars[] = (int) $date_min; } if ($date_max) { $mid[] = "tbp.`created`<=?"; $bindvars[] = (int) $date_max; } $mid = empty($mid) ? '' : 'where ' . implode(' and ', $mid); $query = "select tbp.*,tb.title as blogTitle from `tiki_blog_posts` as tbp, `tiki_blogs` as tb {$mid} order by " . $this->convertSortMode($sort_mode); $query_cant = "select count(*) from `tiki_blog_posts` as tbp, `tiki_blogs` as tb {$mid}"; $result = $this->query($query, $bindvars, $maxRecords, $offset); $cant = $this->getOne($query_cant, $bindvars); $ret = array(); while ($res = $result->fetchRow()) { $res["comments"] = $commentslib->count_comments('blog post:' . $res['postId']); $res['pages'] = $this->get_number_of_pages($res['data']); $res['avatar'] = $tikilib->get_user_avatar($res['user']); if (isset($res['excerpt']) && $res['excerpt'] != NULL) { $res['excerpt'] = $parserlib->parse_data($res['excerpt'], array('is_html' => true)); } if (isset($res['wysiwyg']) && $res['wysiwyg'] == 'n') { $res['data'] = $parserlib->parse_data($res['data']); } $ret[] = $res; } $retval = array(); $retval["data"] = $ret; $retval["cant"] = $cant; return $retval; }
private function setupComments() { global $commentslib; include_once 'lib/comments/commentslib.php'; $commentslib = new Comments(); $count_comments = $commentslib->count_comments('wiki page:' . $this->page, 'n'); $this->smartyassign('count_comments', $count_comments); }
function wikiplugin_articles($data, $params) { global $smarty; global $tikilib; global $feature_articles; global $tiki_p_read_article; global $dbTiki; global $feature_multilingual; global $pageLang; extract($params, EXTR_SKIP); if ($feature_articles != 'y' || $tiki_p_read_article != 'y') { // the feature is disabled or the user can't read articles return ""; } if (!isset($max)) { $max = '3'; } if (!isset($start)) { $start = '0'; } // Addes filtering by topic if topic is passed if (!isset($topic)) { $topic = ''; } else { $topic = $tikilib->fetchtopicId($topic); } // Adds filtering by type if type is passed if (!isset($type)) { $type = ''; } if (!isset($categId)) { $categId = ''; } $now = date("U"); include_once "lib/commentslib.php"; $commentslib = new Comments($dbTiki); $listpages = $tikilib->list_articles($start, $max, 'publishDate_desc', '', $now, 'admin', $type, $topic, 'y', '', $categId); if ($feature_multilingual == 'y') { global $multilinguallib; include_once "lib/multilingual/multilinguallib.php"; $listpages['data'] = $multilinguallib->selectLangList('article', $listpages['data'], $pageLang); } for ($i = 0; $i < count($listpages["data"]); $i++) { $listpages["data"][$i]["parsed_heading"] = $tikilib->parse_data($listpages["data"][$i]["heading"]); $comments_prefix_var = 'article:'; $comments_object_var = $listpages["data"][$i]["articleId"]; $comments_objectId = $comments_prefix_var . $comments_object_var; $listpages["data"][$i]["comments_cant"] = $commentslib->count_comments($comments_objectId); //print_r($listpages["data"][$i]['title']); } require_once 'lib/articles/artlib.php'; // Unsure of reasoning, but Ive added a isset around here for when Articles plugin is called // multiple times on a page. - Damian aka Damosoft if (isset($artlib)) { $topics = $artlib->list_topics(); $smarty->assign_by_ref('topics', $topics); } if (isset($artlib)) { $type = $artlib->list_types(); $smarty->assign_by_ref('type', $type); } // If there're more records then assign next_offset $smarty->assign_by_ref('listpages', $listpages["data"]); return "~np~ " . $smarty->fetch('tiki-view_articles.tpl') . " ~/np~"; //return str_replace("\n","",$smarty->fetch('tiki-view_articles.tpl')); // this considers the hour in the header like a link }