Posted on: 01/15/05 06:40pm
By: machinari
/** * Shows all available topics * * Show the topics in the system the user has access to and prints them in HTML. * This function is used to show the topics in the sections block. * * @param string $topic TopicID of currently selected * @return string HTML formatted topic list * */ function phpblock_custom_showTopics( $topic='' ) { global $_CONF, $_TABLES, $_USER, $_GROUPS, $LANG01, $HTTP_SERVER_VARS, $_THEME_URL, $_BLOCK_TEMPLATE, $page, $newstories; $sql = "SELECT tid,topic,imageurl FROM {$_TABLES['topics']}"; if( $_USER['uid'] > 1 ) { $tids = DB_getItem( $_TABLES['userindex'], 'tids', "uid = '{$_USER['uid']}'" ); if( !empty( $tids )) { $sql .= " WHERE (tid NOT IN ('" . str_replace( ' ', "','", $tids ) . "'))" . COM_getPermSQL( 'AND' ); } else { $sql .= COM_getPermSQL(); } } else { $sql .= COM_getPermSQL(); } if( $_CONF['sortmethod'] == 'alpha' ) { $sql .= ' ORDER BY topic ASC'; } else { $sql .= ' ORDER BY sortnum'; } $result = DB_query( $sql ); $retval = ''; $sections = new Template( $_CONF['path_layout'] ); if( isset( $_BLOCK_TEMPLATE['topicoption'] )) { $templates = explode( ',', $_BLOCK_TEMPLATE['topicoption'] ); $sections->set_file( array( 'option' => $templates[0], 'current' => $templates[1] )); } else { $sections->set_file( array( 'option' => 'topicoption.thtml', 'inactive' => 'topicoption_off.thtml' )); } $sections->set_var( 'site_url', $_CONF['site_url'] ); $sections->set_var( 'layout_url', $_CONF['layout_url'] ); $sections->set_var( 'block_name', str_replace( '_', '-', 'section_block' )); if( $_CONF['hide_home_link'] == 0 ) { // Give a link to the homepage here since a lot of people use this for // navigating the site if( COM_isFrontpage() ) { $sections->set_var( 'option_url', $_CONF['site_url'] . '/index.php' ); $sections->set_var( 'option_label', $LANG01[90] ); $sections->set_var( 'option_count', '' ); $retval .= $sections->parse( 'item', 'option' ); } else { $sections->set_var( 'option_url', '' ); $sections->set_var( 'option_label', $LANG01[90] ); $sections->set_var( 'option_count', '' ); $retval .= $sections->parse( 'item', 'inactive' ); } } if( $_CONF['showstorycount'] ) { $sql = "SELECT tid, count(*) AS count FROM {$_TABLES['stories']} " . 'WHERE (draft_flag = 0) AND (date <= NOW()) ' . COM_getPermSQL( 'AND' ) . ' GROUP BY tid'; $rcount = DB_query( $sql ); while( $C = DB_fetchArray( $rcount )) { $storycount[$C['tid']] = $C['count']; } } if( $_CONF['showsubmissioncount'] ) { $sql = "SELECT tid, count(*) AS count FROM {$_TABLES['storysubmission']} " . ' GROUP BY tid'; $rcount = DB_query( $sql ); while( $C = DB_fetchArray( $rcount )) { $submissioncount[$C['tid']] = $C['count']; } } while( $A = DB_fetchArray( $result ) ) { $dontshow = array('announcements', 'Security', 'someothertopicID');//use topic id's of those topics you don't want in the list if(!in_array($A['tid'], $dontshow)) { $topicname = stripslashes( $A['topic'] ); $sections->set_var( 'option_url', $_CONF['site_url'] . '/index.php?topic=' . $A['tid'] ); $sections->set_var( 'option_label', $topicname ); $countstring = ''; if( $_CONF['showstorycount'] || $_CONF['showsubmissioncount'] ) { $countstring .= '('; if( $_CONF['showstorycount'] ) { if( empty( $storycount[$A['tid']] )) { $countstring .= 0; } else { $countstring .= $storycount[$A['tid']]; } } if( $_CONF['showsubmissioncount'] ) { if( $_CONF['showstorycount'] ) { $countstring .= '/'; } if( empty( $submissioncount[$A['tid']] ) ) { $countstring .= 0; } else { $countstring .= $submissioncount[$A['tid']]; } } $countstring .= ')'; } $sections->set_var( 'option_count', $countstring ); $topicimage = ''; if( !empty( $A['imageurl'] )) { if( isset( $_THEME_URL )) { $imagebase = $_THEME_URL; } else { $imagebase = $_CONF['site_url']; } $topicimage = '<img src="' . $imagebase . $A['imageurl'] . '" alt="' . $topicname . '" title="' . $topicname . '">'; } $sections->set_var( 'topic_image', $topicimage ); if(( $A['tid'] == $topic ) && ( $page == 1 )) { $retval .= $sections->parse( 'item', 'inactive' ); } else { $retval .= $sections->parse( 'item', 'option' ); } } } return $retval; }
Posted on: 01/23/05 01:41pm
By: ronack