[Customisation Database Commits] r106 - in /branches/highwayoflife/titania/includes: class_titania.php mods/mods_main.php titania_cache.php
David Lewis
highwayoflife at phpbb.com
Thu Nov 6 09:59:55 CET 2008
Author: HighwayofLife
Date: Thu Nov 6 09:59:54 2008
New Revision: 106
Log:
Updates -- mod list/search results moved to module, we may globalise it later, but not in the same way.
Modified:
branches/highwayoflife/titania/includes/class_titania.php
branches/highwayoflife/titania/includes/mods/mods_main.php
branches/highwayoflife/titania/includes/titania_cache.php
Modified: branches/highwayoflife/titania/includes/class_titania.php
==============================================================================
*** branches/highwayoflife/titania/includes/class_titania.php (original)
--- branches/highwayoflife/titania/includes/class_titania.php Thu Nov 6 09:59:54 2008
***************
*** 201,298 ****
}
/**
- * Function to list contribs for the selected type.
- *
- * @param string $contrib_type
- */
- public function contrib_list($contrib_type)
- {
- global $db, $template;
-
- // set an upper and lowercase contrib_type as well need each in multiple occurences.
- $l_contrib_type = strtolower($contrib_type);
- $u_contrib_type = strtoupper($contrib_type);
-
- if (!defined('CONTRIB_TYPE_' . $u_contrib_type))
- {
- trigger_error('NO_CONTRIB_TYPE');
- }
-
- // $submit = isset($_REQUEST['submit']) ? true : false;
-
- if (!class_exists('sort'))
- {
- include(TITANIA_ROOT . 'includes/class_sort.' . PHP_EXT);
- }
-
- if (!class_exists('pagination'))
- {
- include(TITANIA_ROOT . 'includes/class_pagination.' . PHP_EXT);
- }
-
- /**
- * @todo too much hard-coding here
- */
- $sort = new sort();
- $sort->set_sort_keys(array(
- array('SORT_AUTHOR', 'a.author_username_clean', 'default' => true),
- array('SORT_TIME_ADDED', 'c.contrib_release_date'),
- array('SORT_TIME_UPDATED', 'c.contrib_update_date'),
- array('SORT_DOWNLOADS', 'c.contrib_downloads'),
- array('SORT_RATING', 'c.contrib_rating'),
- array('SORT_CONTRIB_NAME', 'c.contrib_name'),
- ));
-
- $sort->sort_request(false);
-
- $pagination = new pagination();
- $start = $pagination->set_start();
- $limit = $pagination->set_limit();
-
- // select the list of contribs
- $sql_ary = array(
- 'SELECT' => 'a.author_id, a.author_username, c.*',
- 'FROM' => array(
- CUSTOMISATION_CONTRIBS_TABLE => 'c',
- ),
- 'LEFT_JOIN' => array(
- array(
- 'FROM' => array(CUSTOMISATION_AUTHORS_TABLE => 'a'),
- 'ON' => 'c.contrib_author_id = a.author_id'
- ),
- ),
- 'WHERE' => 'contrib_status = ' . STATUS_APPROVED . '
- AND contrib_type = ' . constant('CONTRIB_TYPE_' . $u_contrib_type),
- 'ORDER_BY' => $sort->get_order_by(),
- );
- $sql = $db->sql_build_query('SELECT', $sql_ary);
- $result = $db->sql_query_limit($sql, $limit, $start);
-
- while ($row = $db->sql_fetchrow($result))
- {
- $template->assign_block_vars($l_contrib_type, array(
- $u_contrib_type . '_ID' => $row['contrib_id'],
- ));
- }
- $db->sql_freeresult($result);
-
- $pagination->sql_total_count($sql_ary, 'c.contrib_id');
-
- $pagination->set_params(array(
- 'sk' => $sort->get_sort_key(),
- 'sd' => $sort->get_sort_dir(),
- ));
-
- $pagination->build_pagination($this->page);
-
- $template->assign_vars(array(
- 'S_MODE_SELECT' => $sort->get_sort_key_list(),
- 'S_ORDER_SELECT' => $sort->get_sort_dir_list(),
- ));
- }
-
-
- /**
* Function to list authors
*
*/
--- 201,206 ----
***************
*** 314,320 ****
* @todo too much hard-coding here
*/
$sort = new sort();
!
$sort->set_sort_keys(array(
array('SORT_AUTHOR', 'a.author_username_clean', 'default' => true),
array('SORT_AUTHOR_RATING', 'a.author_rating'),
--- 222,228 ----
* @todo too much hard-coding here
*/
$sort = new sort();
!
$sort->set_sort_keys(array(
array('SORT_AUTHOR', 'a.author_username_clean', 'default' => true),
array('SORT_AUTHOR_RATING', 'a.author_rating'),
***************
*** 345,366 ****
'WHERE' => 'a.author_visible <> ' . AUTHOR_HIDDEN,
'ORDER_BY' => $sort->get_order_by(),
);
!
$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query_limit($sql, $limit, $start);
!
$authors = array();
$author_id_key = array();
!
while ($author = $db->sql_fetchrow($result))
{
$author_id_key[$author['user_id']] = $author;
$author_id_key[$author['user_id']]['online'] = false;
$authors[] = &$author_id_key[$author['user_id']];
}
!
$db->sql_freeresult($result);
!
// Generate online information for user
if ($config['load_onlinetrack'] && sizeof($authors))
{
--- 253,274 ----
'WHERE' => 'a.author_visible <> ' . AUTHOR_HIDDEN,
'ORDER_BY' => $sort->get_order_by(),
);
!
$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query_limit($sql, $limit, $start);
!
$authors = array();
$author_id_key = array();
!
while ($author = $db->sql_fetchrow($result))
{
$author_id_key[$author['user_id']] = $author;
$author_id_key[$author['user_id']]['online'] = false;
$authors[] = &$author_id_key[$author['user_id']];
}
!
$db->sql_freeresult($result);
!
// Generate online information for user
if ($config['load_onlinetrack'] && sizeof($authors))
{
***************
*** 392,398 ****
'U_PHPBB_PROFILE' => ($author['phpbb_user_id'] > 0) ? 'http://www.phpbb.com/community/memberlist.php?mode=viewprofile&u=' . $author['phpbb_user_id'] : '',
));
}
!
$pagination->sql_total_count($sql_ary, 'a.author_id');
$pagination->set_params(array(
--- 300,306 ----
'U_PHPBB_PROFILE' => ($author['phpbb_user_id'] > 0) ? 'http://www.phpbb.com/community/memberlist.php?mode=viewprofile&u=' . $author['phpbb_user_id'] : '',
));
}
!
$pagination->sql_total_count($sql_ary, 'a.author_id');
$pagination->set_params(array(
***************
*** 401,407 ****
));
$pagination->build_pagination($this->page);
!
$template->assign_vars(array(
'S_MODE_SELECT' => $sort->get_sort_key_list(),
--- 309,315 ----
));
$pagination->build_pagination($this->page);
!
$template->assign_vars(array(
'S_MODE_SELECT' => $sort->get_sort_key_list(),
Modified: branches/highwayoflife/titania/includes/mods/mods_main.php
==============================================================================
*** branches/highwayoflife/titania/includes/mods/mods_main.php (original)
--- branches/highwayoflife/titania/includes/mods/mods_main.php Thu Nov 6 09:59:54 2008
***************
*** 37,78 ****
$user->add_lang(array('titania_contrib', 'titania_mods'));
! // Set desired template
! $this->tpl_name = 'mods/mod_categories';
! $this->page_title = 'MODS_CATEGORIES';
}
public function mod_categories()
{
global $cache, $template, $user;
! $categories = $cache->get_categories(TAG_TYPE_MOD_CATEGORY);
foreach ($categories as $row)
{
$template->assign_block_vars('category', array(
'U_CATEGORY'=> append_sid(TITANIA_ROOT . $user->page['page'], 'id=' . $id . '&mode=list&category=' . $row['id']),
'ID' => $row['id'],
! 'TITLE' => $row['field_name'],
! 'DESC' => $row['field_desc'],
));
}
}
public function mod_list()
{
global $db, $template, $user;
$category = request_var('category', 0);
! if (!class_exists('sort'))
! {
! include(TITANIA_ROOT . 'includes/class_sort.' . PHP_EXT);
! }
! if (!class_exists('pagination'))
! {
! include(TITANIA_ROOT . 'includes/class_pagination.' . PHP_EXT);
! }
$sql_ary = array(
'SELECT' => 'c.*, a.author_id, a.author_username, u.user_colour',
--- 37,106 ----
$user->add_lang(array('titania_contrib', 'titania_mods'));
! switch ($mode)
! {
! case 'list':
! case 'search':
! $this->mod_list();
! break;
!
! case 'categories':
! default:
! $this->mod_categories();
! break;
! }
}
+ /**
+ * MOD Categories
+ */
public function mod_categories()
{
global $cache, $template, $user;
! // Set desired template
! $this->tpl_name = 'mods/mod_categories';
! $this->page_title = 'MODS_CATEGORIES';
!
! $categories = $cache->get_categories(TAG_TYPE_CATEGORY);
foreach ($categories as $row)
{
$template->assign_block_vars('category', array(
'U_CATEGORY'=> append_sid(TITANIA_ROOT . $user->page['page'], 'id=' . $id . '&mode=list&category=' . $row['id']),
'ID' => $row['id'],
! 'TITLE' => $row['name'],
! 'DESC' => $row['desc'],
));
}
}
+ /**
+ * MOD list and search results
+ */
public function mod_list()
{
global $db, $template, $user;
$category = request_var('category', 0);
! include_once(TITANIA_ROOT . 'includes/class_sort.' . PHP_EXT);
! include_once(TITANIA_ROOT . 'includes/class_pagination.' . PHP_EXT);
! $sort = new sort();
! $sort->set_sort_keys(array(
! array('SORT_AUTHOR', 'a.author_username_clean', 'default' => true),
! array('SORT_TIME_ADDED', 'c.contrib_release_date'),
! array('SORT_TIME_UPDATED', 'c.contrib_update_date'),
! array('SORT_DOWNLOADS', 'c.contrib_downloads'),
! array('SORT_RATING', 'c.contrib_rating'),
! array('SORT_CONTRIB_NAME', 'c.contrib_name'),
! ));
!
! $sort->sort_request(false);
!
! $pagination = new pagination();
! $start = $pagination->set_start();
! $limit = $pagination->set_limit();
$sql_ary = array(
'SELECT' => 'c.*, a.author_id, a.author_username, u.user_colour',
***************
*** 91,100 ****
'ON' => 'u.user_id = a.user_id',
),
),
! 'WHERE' => 't.tag_id = ' . $category,
);
$sql = $db->sql_build_query('SELECT', $sql_ary);
! $result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
--- 119,130 ----
'ON' => 'u.user_id = a.user_id',
),
),
! 'WHERE' => 't.tag_id = ' . $category . '
! AND c.contrib_status = ' . STATUS_APPROVED,
! 'ORDER_BY' => $sort->get_order_by(),
);
$sql = $db->sql_build_query('SELECT', $sql_ary);
! $result = $db->sql_query_limit($sql, $limit, $start);
while ($row = $db->sql_fetchrow($result))
{
***************
*** 112,116 ****
--- 142,161 ----
'AUTHOR' => sprintf($user->lang['AUTHOR_BY'], get_username_string('full', $row['author_id'], $row['author_username'], $row['user_colour'], false, $profile_url)),
));
}
+ $db->sql_freeresult($result);
+
+ $pagination->sql_total_count($sql_ary, 'c.contrib_id');
+
+ $pagination->set_params(array(
+ 'sk' => $sort->get_sort_key(),
+ 'sd' => $sort->get_sort_dir(),
+ ));
+
+ $pagination->build_pagination($this->u_action);
+
+ $template->assign_vars(array(
+ 'S_MODE_SELECT' => $sort->get_sort_key_list(),
+ 'S_ORDER_SELECT' => $sort->get_sort_dir_list(),
+ ));
}
}
\ No newline at end of file
Modified: branches/highwayoflife/titania/includes/titania_cache.php
==============================================================================
*** branches/highwayoflife/titania/includes/titania_cache.php (original)
--- branches/highwayoflife/titania/includes/titania_cache.php Thu Nov 6 09:59:54 2008
***************
*** 51,58 ****
{
$categories[$row['tag_id']] = array(
'id' => $row['tag_id'],
! 'field_name'=> $row['tag_field_name'],
! 'field_desc'=> $row['tag_field_desc'],
);
}
$db->sql_freeresult($result);
--- 51,59 ----
{
$categories[$row['tag_id']] = array(
'id' => $row['tag_id'],
! 'name' => $row['tag_field_name'],
! 'clean_name'=> $row['tag_clean_name'],
! 'desc' => $row['tag_field_desc'],
);
}
$db->sql_freeresult($result);
More information about the customisationdb-commits
mailing list