recent_topics.php

来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 327 行

PHP
327
字号
<?php/*+--------------------------------------------------------------------------|   Invision Power Board v2.1.5|   =============================================|   by Matthew Mecham|   (c) 2001 - 2005 Invision Power Services, Inc.|   |   =============================================|   Web: |   Time: Wed, 01 Mar 2006 19:11:29 GMT|   Release: |   Licence Info: +---------------------------------------------------------------------------|   > $Date: 2005-12-06 17:36:43 +0000 (Tue, 06 Dec 2005) $|   > $Revision: 94 $|   > $Author: bfarber $+---------------------------------------------------------------------------||   > PORTAL PLUG IN MODULE: Recent topics|   > Module written by Matt Mecham|   > Date started: Monday 1st August 2005 (16:22)+--------------------------------------------------------------------------*//*** Portal Plug In Module** This module displays the recently posted topic title and* first post.** @package		InvisionPowerBoard* @subpackage	PortalPlugIn* @author		Matt Mecham* @copyright	Invision Power Services, Inc.* @version		2.1*//*** Portal Plug In Module** This module displays the recently posted topic title and* first post.* Each class name MUST be in the format of:* ppi_{file_name_minus_dot_php}** @package		InvisionPowerBoard* @subpackage	PortalPlugIn* @author		Matt Mecham* @copyright	Invision Power Services, Inc.* @version		2.1*/class ppi_recent_topics{	/**	* IPS Global object	*	* @var string	*/	var $ipsclass;	/**	* Array of portal objects including:	* good_forum, bad_forum	*	* @var array	*/	var $portal_object = array();		/*-------------------------------------------------------------------------*/ 	// INIT	/*-------------------------------------------------------------------------*/ 	/**	* This function must be available always	* Add any set up here, such as loading language and skins, etc	*	*/ 	function init() 	{ 	} 		/*-------------------------------------------------------------------------*/ 	// SHOW RECENT DISCUSSIONS X	/*-------------------------------------------------------------------------*/ 	 	function recent_topics_discussions_last_x() 	{ 		//----------------------------------------- 		// INIT 		//----------------------------------------- 		 		$html  = ""; 		$limit = $this->ipsclass->vars['recent_topics_discuss_number'] ? $this->ipsclass->vars['recent_topics_discuss_number'] : 5; 		 		if ( count( $this->portal_object['good_forum'] ) > 0 )    	{    		$qe = "forum_id IN(".implode(',', $this->portal_object['good_forum'] ).") AND ";    	} 		 		$this->ipsclass->DB->simple_construct( array( 'select' => 'tid, title, posts, starter_id as member_id, starter_name as member_name, start_date as post_date, views',													  'from'   => 'topics',													  'where'  => "$qe approved=1 and state != 'closed' and (moved_to is null or moved_to = '')",													  'order'  => 'start_date DESC',													  'limit'  => array( 0, $limit ) ) );		$this->ipsclass->DB->simple_exec();		 		while ( $row = $this->ipsclass->DB->fetch_row() ) 		{ 			$html .= $this->_tmpl_format_topic($row, 30); 		} 		 		return $this->ipsclass->compiled_templates['skin_portal']->tmpl_latestposts($html); 	} 			/*-------------------------------------------------------------------------*/	// SHOW RECENT TOPICS X	/*-------------------------------------------------------------------------*/	/**	* Show the actual topics w/post	*	* @return VOID	*/	function recent_topics_last_x() 	{ 		//----------------------------------------- 		// INIT 		//----------------------------------------- 		 		$html         = ""; 		$attach_pids  = array(); 		$attach_posts = array(); 		 		//-----------------------------------------    	// Grab articles new/recent in 1 bad ass query    	//-----------------------------------------    	    	$limit = intval($this->ipsclass->vars['recent_topics_article_max']);    	    	if ( count( $this->portal_object['bad_forum'] ) > 0 )    	{    		$qe = " AND t.forum_id NOT IN(".implode(',', $this->portal_object['bad_forum'] ).") ";    	}    	    	if ( count( $this->portal_object['good_forum'] ) > 0 )		{			$qe .= " AND t.forum_id IN(".implode(',', $this->portal_object['good_forum'] ).") ";		}                if ( $this->ipsclass->vars['recent_topics_article_forum'] )        {        	$this->ipsclass->vars['recent_topics_article_forum'] = ','.$this->ipsclass->vars['recent_topics_article_forum'];        }                $this->ipsclass->DB->cache_add_query( 'portal_get_monster_bitch', array( 'csite_article_forum' => $this->ipsclass->vars['recent_topics_article_forum'], 'qe' => $qe, 'limit' => $limit ) );		$outer = $this->ipsclass->DB->cache_exec_query();		 		//----------------------------------------- 		// Loop through.. 		//----------------------------------------- 		 		while( $entry = $this->ipsclass->DB->fetch_row($outer) ) 		{ 			//----------------------------------------- 			// INIT 			//----------------------------------------- 			 			$bottom_string  = ""; 			$read_more      = ""; 			$top_string     = ""; 			$got_these_attach = 0; 			 			//----------------------------------------- 			// BASIC INFO 			//----------------------------------------- 			 			$real_posts     = $entry['posts']; 			$entry['title'] = strip_tags($entry['title']); 			$entry['posts'] = $this->ipsclass->do_number_format(intval($entry['posts'])); 			$entry['views'] = $this->ipsclass->do_number_format($entry['views']); 			 			//----------------------------------------- 			// LINKS 			//----------------------------------------- 			 			$comment_link   = $this->ipsclass->compiled_templates['skin_portal']->tmpl_comment_link($entry['tid']); 			$profile_link   = $this->ipsclass->make_profile_link( $entry['last_poster_name'], $entry['last_poster_id'] ); 			 			if ( $real_posts > 0 ) 			{ 				$bottom_string = sprintf( $this->ipsclass->lang['article_reply'], $entry['views'], $comment_link, $profile_link ); 			} 			else 			{ 				$bottom_string = sprintf( $this->ipsclass->lang['article_noreply'], $entry['views'], $comment_link ); 			} 			 			//----------------------------------------- 			// Set up date 			//----------------------------------------- 			 			$this->ipsclass->vars['csite_article_date'] = $this->ipsclass->vars['csite_article_date'] ? $this->ipsclass->vars['csite_article_date'] : 'm-j-y H:i'; 			 			//----------------------------------------- 			// Get Date 			//----------------------------------------- 			 			$entry['date'] = gmdate( $this->ipsclass->vars['csite_article_date'], $entry['post_date'] + $this->ipsclass->get_time_offset() ); 			 			$top_string = sprintf( 								   $this->ipsclass->lang['article_postedby'], 								   $this->ipsclass->make_profile_link( $entry['member_name'], $entry['member_id'] ), 								   $entry['date'], 								   $entry['posts'] 								 ); 			 			$entry['post'] = str_replace( '<br>', '<br />', $entry['post'] ); 			 			//-----------------------------------------			// Attachments?			//-----------------------------------------						preg_match_all( "#\[attachmentid=(\d+)\]#is", $entry['post'], $match );						if ( is_array($match[0]) and count($match[0]) )			{				for ( $i = 0 ; $i < count($match[0]) ; $i++ )				{					if ( $match[1][$i] )					{						$attach_pids[ $match[1][$i] ] = $match[1][$i];					}				}				$got_these_attach = 1;			}						if( $entry['topic_hasattach'] > 0 && $got_these_attach == 0 )			{				$this->ipsclass->DB->build_query( array( 'select' => 'attach_id', 'from' => 'attachments', 'where' => "attach_pid={$entry['topic_firstpost']}" ) );				$this->ipsclass->DB->exec_query();								$these_attach = array();								while( $att = $this->ipsclass->DB->fetch_row() )				{					$attach_pids[$att['attach_id']] = $att['attach_id'];					$these_attach[] = $att['attach_id'];				}								foreach($these_attach as $k => $v )				{					$entry['post'] .= "<br />\n[attachmentid={$v}]";				}			}			 			//----------------------------------------- 			// Format posts 			//----------------------------------------- 			 			$this->portal_object['parser']->parse_html  = ( $this->ipsclass->cache['forum_cache'][ $entry['forum_id'] ]['use_html'] and $entry['post_htmlstate'] ) ? 1 : 0;			$this->portal_object['parser']->parse_wordwrap = $this->ipsclass->vars['post_wordwrap'];			$this->portal_object['parser']->parse_nl2br    = $entry['post_htmlstate'] == 2 ? 1 : 0; 			 			$entry['post'] = $this->portal_object['parser']->pre_display_parse( $entry['post'] ); 			 			//----------------------------------------- 			// Avatar 			//----------------------------------------- 			 			$entry['avatar'] = $this->ipsclass->get_avatar( $entry['avatar_location'], 1, $entry['avatar_size'], $entry['avatar_type'] ); 			 			if ( $entry['avatar'] ) 			{ 				$entry['avatar'] = $this->ipsclass->compiled_templates['skin_portal']->tmpl_wrap_avatar( $entry['avatar'] ); 			} 			 			$html .= $this->ipsclass->compiled_templates['skin_portal']->tmpl_articles_row($entry, $bottom_string, $top_string); 		} 		 		//----------------------------------------- 		// Process Attachments 		//----------------------------------------- 		 		if ( count( $attach_pids ) ) 		{ 			require_once( ROOT_PATH.'sources/action_public/topics.php' );			$this->topic = new topics();			$this->topic->ipsclass =& $this->ipsclass; 			$this->topic->topic_init(); 			 			$html = $this->topic->parse_attachments( $html, $attach_pids , 'attach_id' ); 		} 		 		return $this->ipsclass->compiled_templates['skin_portal']->tmpl_articles($html); 	} 	 	/*-------------------------------------------------------------------------*/ 	// Format topic entry 	/*-------------------------------------------------------------------------*/ 	 	function _tmpl_format_topic($entry, $cut) 	{ 		$entry['title'] = strip_tags($entry['title']);		$entry['title'] = str_replace( "&#33;" , "!" , $entry['title'] );		$entry['title'] = str_replace( "&quot;", "\"", $entry['title'] );				if (strlen($entry['title']) > $cut)		{			$entry['title'] = substr( $entry['title'],0,($cut - 3) ) . "...";			$entry['title'] = preg_replace( '/&(#(\d+;?)?)?(\.\.\.)?$/', '...',$entry['title'] );		}				$entry['posts'] = $this->ipsclass->do_number_format($entry['posts']); 		$entry['views'] = $this->ipsclass->do_number_format($entry['views']); 		 		$this->ipsclass->vars['csite_article_date'] = $this->ipsclass->vars['csite_article_date'] ? $this->ipsclass->vars['csite_article_date'] : 'm-j-y H:i'; 		 		$entry['date']  = gmdate( $this->ipsclass->vars['csite_article_date'], $entry['post_date'] + $this->ipsclass->get_time_offset() ); 		 		return $this->ipsclass->compiled_templates['skin_portal']->tmpl_topic_row($entry['tid'], $entry['title'], $entry['posts'], $entry['views'], $entry['member_id'], $entry['member_name'], $entry['date']); 	}}?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?