[Customisation Database Commits] r151 - in /trunk/titania: includes/authors/authors_main.php language/en/titania_authors.php template/authors/author_list.html template/authors/author_profile.html

Brainy - brainy at phpbb.com
Sun Nov 9 02:23:15 CET 2008


Author: brainy
Date: Sun Nov  9 02:23:15 2008
New Revision: 151

Log:
Added author profile functionality.

Modified:
    trunk/titania/includes/authors/authors_main.php
    trunk/titania/language/en/titania_authors.php
    trunk/titania/template/authors/author_list.html
    trunk/titania/template/authors/author_profile.html

Modified: trunk/titania/includes/authors/authors_main.php
==============================================================================
*** trunk/titania/includes/authors/authors_main.php (original)
--- trunk/titania/includes/authors/authors_main.php Sun Nov  9 02:23:15 2008
***************
*** 59,80 ****
  				$this->tpl_name = 'authors/author_profile';
  				$this->page_title = 'AUTHOR_PROFILE';
  
! 				require_once(TITANIA_ROOT . 'includes/class_author.' . PHP_EXT);
! 
! 				$author = new titania_author(request_var('author_id', 0));
! 				$author->load();
  
! 				if (!$author)
  				{
  					titania::error_box('ERROR', $user->lang['AUTHOR_NOT_FOUND'], ERROR_ERROR);
  					$this->main($id, 'list');
  					return;
  				}
! 
! 				/**
! 				 * @TODO
! 				 * Send author data to the template
! 				 **/
  			break;
  
  			case 'list':
--- 59,74 ----
  				$this->tpl_name = 'authors/author_profile';
  				$this->page_title = 'AUTHOR_PROFILE';
  
! 				$found = $this->author_profile();
  
! 				if (!$found)
  				{
  					titania::error_box('ERROR', $user->lang['AUTHOR_NOT_FOUND'], ERROR_ERROR);
+ 					
  					$this->main($id, 'list');
  					return;
  				}
! 			
  			break;
  
  			case 'list':
***************
*** 82,100 ****
  				$this->tpl_name = 'authors/author_list';
  				$this->page_title = 'AUTHOR_LIST';
  
- 				/**
- 				 * @TODO
- 				 * Send authors to template
- 				 * Uses $titania->author_list()
- 				 **/
  				$this->author_list();
  			break;
  		}
  	}
  
- 	/**
- 	 * Function to list authors
- 	 */
  	private function author_list()
  	{
  		global $db, $template, $config, $auth, $user;
--- 76,86 ----
***************
*** 182,188 ****
  				'CONTRIBS'			=> $author['author_contribs'],
  				'MODS'				=> $author['author_mods'],
  				'STYLES'			=> $author['author_styles'],
! 				'RATING'			=> round($author['author_rating'], 2),
  				'WEBSITE'			=> $author['author_website'],
  				'LAST_VISIT'		=> $user->format_date($author['user_lastvisit'], false, true),
  				'POSTS'				=> $author['user_posts'],
--- 168,174 ----
  				'CONTRIBS'			=> $author['author_contribs'],
  				'MODS'				=> $author['author_mods'],
  				'STYLES'			=> $author['author_styles'],
! 				'RATING'			=> $this->generate_rating($author['author_rating']),
  				'WEBSITE'			=> $author['author_website'],
  				'LAST_VISIT'		=> $user->format_date($author['user_lastvisit'], false, true),
  				'POSTS'				=> $author['user_posts'],
***************
*** 205,208 ****
  			'S_ORDER_SELECT'	=> $sort->get_sort_dir_list(),
  		));
  	}
! }
--- 191,284 ----
  			'S_ORDER_SELECT'	=> $sort->get_sort_dir_list(),
  		));
  	}
! 	
! 	private function author_profile()
! 	{
! 		global $db, $template;
! 		
! 		$author_id = request_var('u', 0);
! 		
! 		$sql_ary = array(
! 			'SELECT' => 'a.*, u.user_lastvisit, u.username, u.user_posts, u.user_colour',
! 			'FROM'		=> array(
! 				CUSTOMISATION_AUTHORS_TABLE => 'a',
! 			),
! 			'LEFT_JOIN'	=> array(
! 				array(
! 					'FROM'	=> array(USERS_TABLE => 'u'),
! 					'ON'	=> 'a.user_id = u.user_id'
! 				),
! 			),
! 			'WHERE'		=> 'a.author_id = ' . $author_id . '
! 				AND a.author_visible <> ' . AUTHOR_HIDDEN
! 		);
! 		
! 		$sql = $db->sql_build_query('SELECT', $sql_ary);
! 		
! 		$result = $db->sql_query($sql);
! 		
! 		if(!($author = $db->sql_fetchrow($result)))
! 		{
! 			return false;
! 		}
! 		
! 		if(!$author['author_visible'])
! 		{
! 			return false;
! 		}
! 		
! 		$template->assign_vars(array(
! 			'AUTHOR_NAME'		=> get_username_string('username', $author['user_id'], $author['username'], $author['user_colour']),
! 			'USER_FULL'			=> ($author['user_id']) ? get_username_string('full', $author['user_id'], $author['username'], $author['user_colour']) : '',
! 			'REAL_NAME'			=> htmlspecialchars($author['author_realname']),
! 			'WEBSITE'			=> $author['author_website'],
! 			'RATING'			=> $this->generate_rating($author['author_rating']),
! 			'S_RATING_PERCENT'	=> $author['author_rating'] / 5,
! 			'CONTRIB_COUNT'		=> $this->generate_contrib_string('contrib', 'link', $author['author_contribs'], $author_id),
! 			'SNIPPET_COUNT'		=> $this->generate_contrib_string('snippet', 'link', $author['author_snippets'], $author_id),
! 			'MOD_COUNT'			=> $this->generate_contrib_string('mod', 'link', $author['author_mods'], $author_id),
! 			'STYLE_COUNT'		=> $this->generate_contrib_string('style', 'link', $author['author_styles'], $author_id),
! 			
! 			'U_PHPBB_PROFILE'	=> ($author['phpbb_user_id']) ? U_PHPBBCOM_VIEWPROFILE . '&amp;u=' . $author['phpbb_user_id'] : '',
! 		));
! 		
! 		return true;
! 	}
! 	
! 	// Currently this just returns the $rating parameter, but we may want to use an image/image combo for ratings
! 	// This can be changed later if this is decided.
! 	private function generate_rating($rating)
! 	{
! 		return round($rating, 2);
! 	}
! 	
! 	// This can handle generating links to a contrib list, as well as just text
! 	private function generate_contrib_string($contrib_type, $string_type, $num, $author_id = 0)
! 	{
! 		global $user;
! 		
! 		$contrib_type = strtoupper($contrib_type);
! 		$lang_key = 'NUM_' . $contrib_type . (($num == 1)?'':'S');
! 		$contrib_string = sprintf($user->lang[$lang_key], $num);
! 		if($string_type == 'link')
! 		{
! 			if($author_id == 0)
! 			{
! 				trigger_error('Author ID not set when using link', E_USER_WARNING);
! 			}
! 			switch($contrib_type)
! 			{
! 				case 'MOD':
! 					$url = append_sid(TITANIA_ROOT . 'mods/index.php', 'mode=search&amp;u=' . $author_id);
! 					
! 				break;
! 				
! 				default:
! 					$url = '#';
! 			}
! 			$contrib_string = '<a href="' . $url . '">' . $contrib_string . '</a>';
! 		}
! 		
! 		return $contrib_string;
! 	}
! }
\ No newline at end of file

Modified: trunk/titania/language/en/titania_authors.php
==============================================================================
*** trunk/titania/language/en/titania_authors.php (original)
--- trunk/titania/language/en/titania_authors.php Sun Nov  9 02:23:15 2008
***************
*** 38,42 ****
--- 38,51 ----
  $lang = array_merge($lang, array(
  	'AUTHOR_LIST'		=> 'Author List',
  	'AUTHOR_PROFILE'	=> 'Author Profile',
+ 	'AUTHOR_NOT_FOUND'	=> 'Author not found',
+ 	'NUM_CONTRIB'		=> '%s Contribution',
+ 	'NUM_CONTRIBS'		=> '%s Contributions',
+ 	'NUM_MOD'			=> '%s MOD',
+ 	'NUM_MODS'			=> '%s MODs',
+ 	'NUM_STYLE'			=> '%s Style',
+ 	'NUM_STYLES'		=> '%s Styles',
+ 	'NUM_SNIPPET'		=> '%s Snippet',
+ 	'NUM_SNIPPETS'		=> '%s Snippets',
  ));
  

Modified: trunk/titania/template/authors/author_list.html
==============================================================================
*** trunk/titania/template/authors/author_list.html (original)
--- trunk/titania/template/authors/author_list.html Sun Nov  9 02:23:15 2008
***************
*** 3,9 ****
  <table width="100%">
  <!-- BEGIN authors -->
  <tr>
! 	<td width="10%">{authors.USERNAME}</td>
  	<td width="10%"><!-- IF authors.U_PHPBB_PROFILE --><a href="{authors.U_PHPBB_PROFILE}">{L_PHPBB_PROFILE}</a><!-- ELSE -->&nbsp;<!-- ENDIF --></td>
  	<td width="10%">{authors.CONTRIBS}</td>
  	<td width="10%">{authors.MODS}</td>
--- 3,10 ----
  <table width="100%">
  <!-- BEGIN authors -->
  <tr>
! 	<td width="10%">{authors.AUTHOR_FULL}</td>
! 	<td width="10%">{authors.USER_FULL}</td>
  	<td width="10%"><!-- IF authors.U_PHPBB_PROFILE --><a href="{authors.U_PHPBB_PROFILE}">{L_PHPBB_PROFILE}</a><!-- ELSE -->&nbsp;<!-- ENDIF --></td>
  	<td width="10%">{authors.CONTRIBS}</td>
  	<td width="10%">{authors.MODS}</td>
***************
*** 16,19 ****
--- 17,27 ----
  </tr>
  <!-- END -->
  </table>
+ <fieldset class="display-options">
+ 	<!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}" class="left-box {S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
+ 	<!-- IF NEXT_PAGE --><a href="{NEXT_PAGE}" class="right-box {S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
+ 	<!-- IF S_MODE_SELECT --><label for="sk">{L_SELECT_SORT_METHOD}: <select name="sk" id="sk">{S_MODE_SELECT}</select></label>
+ 	<label for="sd">{L_ORDER} <select name="sd" id="sd">{S_ORDER_SELECT}</select> <input type="submit" name="sort" value="{L_SUBMIT}" class="button2" /></label>
+ 	<!-- ENDIF -->
+ </fieldset>
  <!-- INCLUDE overall_footer.html -->
\ No newline at end of file

Modified: trunk/titania/template/authors/author_profile.html
==============================================================================
*** trunk/titania/template/authors/author_profile.html (original)
--- trunk/titania/template/authors/author_profile.html Sun Nov  9 02:23:15 2008
***************
*** 1,3 ****
--- 1,15 ----
  <!-- INCLUDE overall_header.html -->
  {L_AUTHOR_PROFILE}
+ <table>
+ <tr><td>{AUTHOR_NAME}</td></tr>
+ <tr><td>{USER_FULL}</td></tr>
+ <tr><td>{REAL_NAME}</td></tr>
+ <tr><td>{WEBSITE}</td></tr>
+ <tr><td>{RATING}</td></tr>
+ <tr><td>{CONTRIB_COUNT}</td></tr>
+ <tr><td>{SNIPPET_COUNT}</td></tr>
+ <tr><td>{MOD_COUNT}</td></tr>
+ <tr><td>{STYLE_COUNT}</td></tr>
+ <td width="10%"><!-- IF authors.U_PHPBB_PROFILE --><a href="{authors.U_PHPBB_PROFILE}">{L_PHPBB_PROFILE}</a><!-- ELSE -->&nbsp;<!-- ENDIF --></td>
+ </table>
  <!-- INCLUDE overall_footer.html -->
\ No newline at end of file




More information about the customisationdb-commits mailing list