|
From: Jon O. <jon...@us...> - 2006-08-04 20:10:47
|
Update of /cvsroot/mxbb/mx_kb/kb/includes In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv4946/modules/mx_kb/kb/includes Modified Files: functions.php functions_kb.php Log Message: statistics print view Index: functions.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/kb/includes/functions.php,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** functions.php 4 Aug 2006 16:30:30 -0000 1.13 --- functions.php 4 Aug 2006 20:10:43 -0000 1.14 *************** *** 299,307 **** 'U_MCP' => $mcp_url, 'U_SEARCH' => $search_url, ! 'U_TOPRATED' => append_sid( $mx_kb->this_mxurl( "mode=stats&stats=toprated" ) ), 'L_TOPRATED' => $lang['Top_toprated'], ! 'U_MOST_POPULAR' => append_sid( $mx_kb->this_mxurl( "mode=stats&stats=mostpopular" ) ), 'L_MOST_POPULAR' => $lang['Top_most_popular'], ! 'U_LATEST' => append_sid( $mx_kb->this_mxurl( "mode=stats&stats=latest" ) ), 'L_LATEST' => $lang['Top_latest'] )); --- 299,307 ---- 'U_MCP' => $mcp_url, 'U_SEARCH' => $search_url, ! 'U_TOPRATED' => append_sid( $mx_kb->this_mxurl( "mode=stats&sort_method=Toprated&sort_order=DESC" ) ), 'L_TOPRATED' => $lang['Top_toprated'], ! 'U_MOST_POPULAR' => append_sid( $mx_kb->this_mxurl( "mode=stats&sort_method=Most_popular&sort_order=DESC" ) ), 'L_MOST_POPULAR' => $lang['Top_most_popular'], ! 'U_LATEST' => append_sid( $mx_kb->this_mxurl( "mode=stats&sort_method=Latest&sort_order=DESC" ) ), 'L_LATEST' => $lang['Top_latest'] )); Index: functions_kb.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/kb/includes/functions_kb.php,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** functions_kb.php 4 Aug 2006 16:30:30 -0000 1.16 --- functions_kb.php 4 Aug 2006 20:10:43 -0000 1.17 *************** *** 828,865 **** * @param unknown_type $approve */ ! function display_items( $start, $cat_id = false, $block_name = 'articlerow', $approve = '1' ) { global $db, $kb_config, $template, $board_config; ! global $images, $lang, $phpEx, $mx_kb_functions; global $phpbb_root_path, $mx_root_path, $module_root_path, $is_block, $phpEx; $filelist = false; - // - // This ambigious extra code is for reusing this method for the mcp (not needed with new mcp panel) - // - $approved_sql = ''; if ( empty( $cat_id ) ) { ! $approved_sql = " t.approved = '1'"; ! $cat_where = ''; ! } ! else ! { ! if ( !$this->auth_user[$cat_id]['auth_mod'] ) ! { ! $approved_sql = " t.approved = " . $approve; ! } ! $cat_where = !empty($approved_sql) ? "AND t.article_category_id = $cat_id" : " t.article_category_id = $cat_id"; ! } ! ! $order_sql = ''; ! if ( defined( 'IN_ADMIN' ) ) ! { ! $order_sql = " ORDER BY t.article_id"; } else { ! $order_sql = " ORDER BY " . $this->sort_method_extra . $this->sort_method . " " . $this->sort_order; } --- 828,846 ---- * @param unknown_type $approve */ ! function display_items( $start, $cat_id = false ) { global $db, $kb_config, $template, $board_config; ! global $images, $lang, $theme, $phpEx, $mx_kb_functions; global $phpbb_root_path, $mx_root_path, $module_root_path, $is_block, $phpEx; $filelist = false; if ( empty( $cat_id ) ) { ! $cat_where = "AND t.article_category_id IN (" . $this->gen_cat_ids( '0' ) . ")"; } else { ! $cat_where = "AND t.article_category_id = $cat_id"; } *************** *** 872,884 **** AND t.article_type = typ.id(+) AND t.article_author_id = u.user_id(+) ! $approved_sql AND t.article_category_id = cat.category_id $cat_where GROUP BY t.article_id ! $order_sql"; break; default: ! $sql = "SELECT t.*, t.article_id, r.votes_article, AVG(r.rate_point) AS rating, COUNT(r.votes_article) AS total_votes, u.user_id, u.username, typ.type FROM " . KB_ARTICLES_TABLE . " AS t LEFT JOIN " . KB_VOTES_TABLE . " AS r ON t.article_id = r.votes_article --- 853,865 ---- AND t.article_type = typ.id(+) AND t.article_author_id = u.user_id(+) ! AND t.approved = '1' AND t.article_category_id = cat.category_id $cat_where GROUP BY t.article_id ! ORDER BY " . $this->sort_method_extra . $this->sort_method . " " . $this->sort_order; break; default: ! $sql = "SELECT t.*, t.article_id, r.votes_article, IF(COUNT(r.rate_point)>0,AVG(r.rate_point),0) AS rating, COUNT(r.votes_article) AS total_votes, u.user_id, u.username, typ.type FROM " . KB_ARTICLES_TABLE . " AS t LEFT JOIN " . KB_VOTES_TABLE . " AS r ON t.article_id = r.votes_article *************** *** 886,893 **** LEFT JOIN " . USERS_TABLE . " AS u ON t.article_author_id = u.user_id LEFT JOIN " . KB_CATEGORIES_TABLE . " AS cat ON t.article_category_id = cat.category_id ! WHERE $approved_sql $cat_where GROUP BY t.article_id ! $order_sql"; break; } --- 867,874 ---- LEFT JOIN " . USERS_TABLE . " AS u ON t.article_author_id = u.user_id LEFT JOIN " . KB_CATEGORIES_TABLE . " AS cat ON t.article_category_id = cat.category_id ! WHERE t.approved = '1' $cat_where GROUP BY t.article_id ! ORDER BY " . $this->sort_method_extra . $this->sort_method . " " . $this->sort_order; break; } *************** *** 911,919 **** $db->sql_freeresult( $result ); ! $where_sql = ( !empty( $cat_id ) ) ? "AND article_category_id = $cat_id" : ''; ! $sql = "SELECT COUNT(article_id) as total_articles ! FROM " . KB_ARTICLES_TABLE . " ! WHERE approved='1' ! $where_sql"; if ( !( $result = $db->sql_query( $sql ) ) ) --- 892,899 ---- $db->sql_freeresult( $result ); ! $sql = "SELECT COUNT(t.article_id) as total_articles ! FROM " . KB_ARTICLES_TABLE . " AS t ! WHERE t.approved='1' ! $cat_where"; if ( !( $result = $db->sql_query( $sql ) ) ) *************** *** 992,1048 **** $article_url = append_sid( $this->this_mxurl( "mode=article&k=$article_id" ) ); - /* - $approve = ''; - $delete = ''; - - if ( defined( 'IN_ADMIN' ) ) - { - if ( $article_approved == 2 || $article_approved == 0 ) - { - // approve - $temp_url = append_sid( $module_root_path . "admin/admin_kb_art.$phpEx?mode=approve&a=$article_id&cat=$article_cat_id" . "&start=" . $start); - $approve = '<a href="' . $temp_url . '"><img src="' . $images['kb_icon_approve'] . '" border="0" alt="' . $lang['Approve'] . '"></a>'; - } - elseif ( $article_approved == 1 ) - { - // unapprove - $temp_url = append_sid( $module_root_path . "admin/admin_kb_art.$phpEx?mode=unapprove&a=$article_id&cat=$article_cat_id" . "&start=" . $start); - $approve = '<a href="' . $temp_url . '"><img src="' . $images['kb_icon_unapprove'] . '" border="0" alt="' . $lang['Un_approve'] . '"></a>'; - } - // delete - $temp_url = append_sid( $module_root_path . "admin/admin_kb_art.$phpEx?mode=delete&a=$article_id&cat=$article_cat_id" . "&start=" . $start); - $delete = '<a href="' . $temp_url . '"><img src="' . $images['kb_icon_delpost'] . '" border="0" alt="' . $lang['Delete'] . '"></a>'; - } - else - { - if ( $this->auth_user[$cat_id]['auth_mod'] ) - { - if ( $article_approved == 2 || $article_approved == 0 ) - { - // approve - $temp_url = append_sid( $this->this_mxurl( "mode=moderate&action=approve&a=$article_id&cat=$article_cat_id&page=$page_id" . "&start=" . $start) ); - $approve = '<a href="' . $temp_url . '"><img src="' . $images['kb_icon_approve'] . '" border="0" alt="' . $lang['Approve'] . '"></a>'; - } - elseif ( $article_approved == 1 ) - { - // unapprove - $temp_url = append_sid( $this->this_mxurl( "mode=moderate&action=unapprove&a=$article_id&cat=$article_cat_id&page=$page_id" . "&start=" . $start) ); - $approve = '<a href="' . $temp_url . '"><img src="' . $images['kb_icon_unapprove'] . '" border="0" alt="' . $lang['Un_approve'] . '"></a>'; - } - } - if ( $this->auth_user[$cat_id]['auth_delete'] || $this->auth_user[$cat_id]['auth_mod']) - { - // delete - $temp_url = append_sid( $this->this_mxurl( "mode=moderate&action=delete&a=$article_id&cat=$article_cat_id&page=$page_id" . "&start=" . $start) ); - $delete = '<a href="' . $temp_url . '"><img src="' . $images['kb_icon_delpost'] . '" border="0" alt="' . $lang['Delete'] . '"></a>'; - } - } - */ - // =================================================== // Assign Vars // =================================================== ! $template->assign_block_vars( ARTICLELIST .'.'.$block_name, array( 'ARTICLE' => $article_title, 'ARTICLE_DESCRIPTION' => $article_description, --- 972,980 ---- $article_url = append_sid( $this->this_mxurl( "mode=article&k=$article_id" ) ); // =================================================== // Assign Vars // =================================================== ! $template->assign_block_vars( "ARTICLELIST.articlerow", array( 'ARTICLE' => $article_title, 'ARTICLE_DESCRIPTION' => $article_description, *************** *** 1085,1089 **** if ( $filelist ) { ! $action = ( empty( $cat_id ) ) ? 'viewall' : 'cat&cat=' . $cat_id; $sort_method = isset($_REQUEST['sort_method']) ? $_REQUEST['sort_method'] : $kb_config['sort_method']; --- 1017,1021 ---- if ( $filelist ) { ! $action = ( empty( $cat_id ) ) ? 'stats' : 'cat&cat=' . $cat_id; $sort_method = isset($_REQUEST['sort_method']) ? $_REQUEST['sort_method'] : $kb_config['sort_method']; *************** *** 1091,1097 **** $template->assign_vars( array( 'L_ARTICLES' => $lang['Articles'], - 'L_CATEGORY' => $lang['Category'], 'L_LINK_SITE_DESC' => $lang['Siteld'], 'L_DOWNLOADS' => $lang['Hits'], --- 1023,1037 ---- $template->assign_vars( array( + 'L_CATEGORY' => $lang['Category'], + 'L_CATEGORY_NAME' => $category_name, + 'L_ARTICLE' => $lang['Article'], 'L_ARTICLES' => $lang['Articles'], + 'L_ARTICLE_TYPE' => $lang['Article_type'], + 'L_ARTICLE_CATEGORY' => $lang['Category'], + 'L_ARTICLE_DATE' => $lang['Date'], + 'L_ARTICLE_AUTHOR' => $lang['Author'], + 'L_VIEWS' => $lang['Views'], + 'L_VOTES' => $lang['Votes'], 'L_LINK_SITE_DESC' => $lang['Siteld'], 'L_DOWNLOADS' => $lang['Hits'], *************** *** 1100,1104 **** 'L_FILE' => $lang['Link'], 'L_SUBMITED_BY' => $lang['Submiter'], - 'L_VOTES' => $lang['Votes'], 'L_SELECT_SORT_METHOD' => $lang['Select_sort_method'], --- 1040,1043 ---- *************** *** 1147,1435 **** /** - * Enter description here... - * - * @param unknown_type $start - * @param unknown_type $cat_id - */ - function display_stats( $start, $type = false, $cat_id = false, $block_name = 'articlerow', $approve = '1' ) - { - global $db, $kb_config, $template, $board_config; - global $images, $lang, $phpEx, $mx_kb_functions; - global $phpbb_root_path, $mx_root_path, $module_root_path, $is_block, $phpEx; - - $filelist = false; - - $approved_sql = ''; - if ( empty( $cat_id ) ) - { - $approved_sql = " t.approved = '1'"; - $cat_where = ''; - } - else - { - if ( !$this->auth_user[$cat_id]['auth_mod'] ) - { - $approved_sql = " t.approved = " . $approve; - } - $cat_where = !empty($approved_sql) ? "AND t.article_category_id = $cat_id" : " t.article_category_id = $cat_id"; - } - - $order_sql = ''; - if ( $type ) - { - if ( $type == 'toprated' ) - { - $order_sql = " ORDER BY rating DESC "; - } - elseif ( $type == 'latest' ) - { - $order_sql = " ORDER BY article_date DESC "; - } - elseif ( $type == 'mostpopular' ) - { - $order_xtra = !empty($cat_where) || !empty($approved_sql)? " AND views > 0" : " views > 0 "; - $order_sql = " ORDER BY views DESC "; - } - } - else - { - - } - - switch ( SQL_LAYER ) - { - case 'oracle': - $sql = "SELECT t.*, t.article_id, r.votes_article, AVG(r.rate_point) AS rating, COUNT(r.votes_article) AS total_votes, u.user_id, u.username, COUNT(c.comments_id) AS total_comments, cat.cat_allow_ratings, cat.cat_allow_comments, typ.type - FROM " . KB_ARTICLES_TABLE . " AS t, " . KB_VOTES_TABLE . " AS r, " . USERS_TABLE . " AS u, " . KB_COMMENTS_TABLE . " AS c, " . KB_CATEGORIES_TABLE . " AS cat, " . KB_TYPES_TABLE . " AS typ - WHERE t.article_id = r.votes_article(+) - AND t.article_type = typ.id(+) - AND t.article_author_id = u.user_id(+) - AND t.article_id = c.article_id(+) - AND t.article_category_id = cat.category_id - $approved_sql - $cat_where - $order_xtra - GROUP BY t.article_id - $order_sql"; - break; - - default: - $sql = "SELECT t.*, t.article_id, r.votes_article, AVG(r.rate_point) AS rating, COUNT(r.votes_article) AS total_votes, u.user_id, u.username, COUNT(c.comments_id) AS total_comments, cat.cat_allow_ratings, cat.cat_allow_comments, typ.type - FROM " . KB_ARTICLES_TABLE . " AS t - LEFT JOIN " . KB_VOTES_TABLE . " AS r ON t.article_id = r.votes_article - LEFT JOIN " . KB_TYPES_TABLE . " AS typ ON t.article_type = typ.id - LEFT JOIN " . USERS_TABLE . " AS u ON t.article_author_id = u.user_id - LEFT JOIN " . KB_COMMENTS_TABLE . " AS c ON t.article_id = c.article_id - LEFT JOIN " . KB_CATEGORIES_TABLE . " AS cat ON t.article_category_id = cat.category_id - WHERE $approved_sql - $cat_where - $order_xtra - GROUP BY t.article_id - $order_sql"; - break; - } - - if ( !( $result = $mx_kb_functions->sql_query_limit( $sql, $kb_config['pagination'], $start ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Couldn\'t get file info for this category', '', __LINE__, __FILE__, $sql ); - } - - $file_rowset = array(); - $total_file = 0; - - while ( $row = $db->sql_fetchrow( $result ) ) - { - if ( $this->auth_user[$row['article_category_id']]['auth_view'] ) - { - $file_rowset[] = $row; - } - } - - $db->sql_freeresult( $result ); - - $where_sql = ( !empty( $cat_id ) ) ? "AND article_category_id = $cat_id" : ''; - $sql = "SELECT COUNT(article_id) as total_articles - FROM " . KB_ARTICLES_TABLE . " - WHERE approved='1' - $where_sql"; - - if ( !( $result = $db->sql_query( $sql ) ) ) - { - mx_message_die( GENERAL_ERROR, 'Couldn\'t get number of article', '', __LINE__, __FILE__, $sql ); - } - - $row = $db->sql_fetchrow( $result ); - $db->sql_freeresult( $result ); - - $total_file = $row['total_articles']; - unset( $row ); - - if (count( $file_rowset ) > 0) - { - $template->assign_block_vars( 'ARTICLELIST', array() ); - - $filelist = true; - } - - // - // Ratings - // - $kb_use_ratings = false; - for ( $i = 0; $i < count( $file_rowset ); $i++ ) - { - if ( $this->ratings[$file_rowset[$i]['article_category_id']]['activated'] ) - { - $kb_use_ratings = true; - break; - } - } - - for ( $i = 0; $i < count( $file_rowset ); $i++ ) - { - // =================================================== - // Format the date for the given file - // =================================================== - $article_date = create_date( $board_config['default_dateformat'], $file_rowset[$i]['article_date'], $board_config['board_timezone'] ); - // =================================================== - // Get rating for the file and format it - // =================================================== - $rating = ( $file_rowset[$i]['rating'] != 0 ) ? round( $file_rowset[$i]['rating'], 2 ) . ' / 10' : $lang['Not_rated']; - // - // If the file is new then put a new image in front of it - // - $is_new = FALSE; - if (time() - ($kb_config['settings_newdays'] * 24 * 60 * 60) < $file_rowset[$i]['article_date']) - { - $is_new = TRUE; - } - // - // If the file is new then put a new image in front of it - // - $is_new = FALSE; - if (time() - ($kb_config['settings_newdays'] * 24 * 60 * 60) < $file_rowset[$i]['article_date']) - { - $is_new = TRUE; - } - - $cat_name = ( empty( $cat_id ) ) ? $this->cat_rowset[$file_rowset[$i]['file_catid']]['category_name'] : ''; - $cat_url = append_sid( $this->this_mxurl( 'action=category&cat_id=' . $file_rowset[$i]['article_category_id'] ) ); - - $article_description = $file_rowset[$i]['article_description'] ; - $article_cat_id = $file_rowset[$i]['article_category_id']; - $article_approved = $file_rowset[$i]['approved']; - - // - // type - // - $article_type = isset($lang['KB_type_' . $file_rowset[$i]['type']]) ? $lang['KB_type_' . $file_rowset[$i]['type']] : $file_rowset[$i]['type']; - - // - // author information - // - $author = ( $file_rowset[$i]['user_id'] != ANONYMOUS ) ? '<a href="' . append_sid( $phpbb_root_path . 'profile.' . $phpEx . '?mode=viewprofile&' . POST_USERS_URL . '=' . $file_rowset[$i]['user_id'] ) . '" target=_blank>' : ''; - $author .= ( $file_rowset[$i]['user_id'] != ANONYMOUS ) ? $file_rowset[$i]['username'] : $file_rowset[$i]['post_username'] . '(' . $lang['Guest'] . ')'; - $author .= ( $file_rowset[$i]['user_id'] != ANONYMOUS ) ? '</a>' : ''; - - $article_id = $file_rowset[$i]['article_id']; - $views = $file_rowset[$i]['views']; - - $article_title = $file_rowset[$i]['article_title']; - $temp_url = append_sid( $this->this_mxurl( "mode=article&k=$article_id" ) ); - $article = '<a href="' . $temp_url . '" class="gen">' . $article_title . '</a>'; - - /* - $approve = ''; - $delete = ''; - - if ( defined( 'IN_ADMIN' ) ) - { - if ( $article_approved == 2 || $article_approved == 0 ) - { - // approve - $temp_url = append_sid( $module_root_path . "admin/admin_kb_art.$phpEx?mode=approve&a=$article_id&cat=$article_cat_id" . "&start=" . $start); - $approve = '<a href="' . $temp_url . '"><img src="' . $images['kb_icon_approve'] . '" border="0" alt="' . $lang['Approve'] . '"></a>'; - } - elseif ( $article_approved == 1 ) - { - // unapprove - $temp_url = append_sid( $module_root_path . "admin/admin_kb_art.$phpEx?mode=unapprove&a=$article_id&cat=$article_cat_id" . "&start=" . $start); - $approve = '<a href="' . $temp_url . '"><img src="' . $images['kb_icon_unapprove'] . '" border="0" alt="' . $lang['Un_approve'] . '"></a>'; - } - // delete - $temp_url = append_sid( $module_root_path . "admin/admin_kb_art.$phpEx?mode=delete&a=$article_id&cat=$article_cat_id" . "&start=" . $start); - $delete = '<a href="' . $temp_url . '"><img src="' . $images['kb_icon_delpost'] . '" border="0" alt="' . $lang['Delete'] . '"></a>'; - } - else - { - if ( $this->auth_user[$cat_id]['auth_mod'] ) - { - if ( $article_approved == 2 || $article_approved == 0 ) - { - // approve - $temp_url = append_sid( $this->this_mxurl( "mode=moderate&action=approve&a=$article_id&cat=$article_cat_id&page=$page_id" . "&start=" . $start) ); - $approve = '<a href="' . $temp_url . '"><img src="' . $images['kb_icon_approve'] . '" border="0" alt="' . $lang['Approve'] . '"></a>'; - } - elseif ( $article_approved == 1 ) - { - // unapprove - $temp_url = append_sid( $this->this_mxurl( "mode=moderate&action=unapprove&a=$article_id&cat=$article_cat_id&page=$page_id" . "&start=" . $start) ); - $approve = '<a href="' . $temp_url . '"><img src="' . $images['kb_icon_unapprove'] . '" border="0" alt="' . $lang['Un_approve'] . '"></a>'; - } - } - if ( $this->auth_user[$cat_id]['auth_delete'] || $this->auth_user[$cat_id]['auth_mod']) - { - // delete - $temp_url = append_sid( $this->this_mxurl( "mode=moderate&action=delete&a=$article_id&cat=$article_cat_id&page=$page_id" . "&start=" . $start) ); - $delete = '<a href="' . $temp_url . '"><img src="' . $images['kb_icon_delpost'] . '" border="0" alt="' . $lang['Delete'] . '"></a>'; - } - } - */ - - // =================================================== - // Assign Vars - // =================================================== - $template->assign_block_vars( $block_name, array( - 'ARTICLE' => $article , - 'ARTICLE_DESCRIPTION' => $article_description, - 'ARTICLE_TYPE' => $article_type, - 'ARTICLE_DATE' => $article_date, - 'ARTICLE_AUTHOR' => $author, - - 'ARTICLE_IMAGE' => $is_new ? $images['kb_article'] : $images['kb_article'], - - 'CATEGORY' => $cat_name, - 'ART_VIEWS' => $views, - - 'ARTICLE_VOTES' => $file_rowset[$i]['total_votes'], - 'L_RATING' => '<a href="' . append_sid( $this->this_mxurl( 'mode=rate&k=' . $file_rowset[$i]['article_id'] ) ) . '">' . $lang['Votes_label'] . '</a>', - 'RATING' => $rating, - - //'U_APPROVE' => $approve, - - 'ARTICLE_IMAGE' => $is_new ? $images['kb_article_new'] : $images['kb_article'], - 'COLOR' => ( ( $i % 2 ) ? "row2" : "row1" ), - 'POSTER' => $file_poster, - - //'U_DELETE' => $delete - )); - - if ( $kb_use_ratings ) - { - $template->assign_block_vars( "articlerow.show_ratings", array() ); - } - - if ( $is_new ) - { - $template->assign_block_vars( "articlerow.is_new_file", array() ); - } - } - - if ( !$filelist ) - { - $template->assign_block_vars( 'no_articles', array( 'COMMENT' => $lang['No_Articles'] ) ); - } - } - - /** * auth_can. * --- 1086,1089 ---- |