function hosting_site_list in Hosting 5
Display a list of created sites on the front page @TODO Add ability to filter by additional fields @TODO Add paging.
6 calls to hosting_site_list()
- hosting_client_view in client/
hosting_client.module - Implementation of hook_view().
- hosting_db_server_view in db_server/
hosting_db_server.module - Implementation of hook_view().
- hosting_package_view in package/
hosting_package.module - Implementation of hook_view().
- hosting_platform_view in platform/
hosting_platform.module - Implementation of hook_view().
- hosting_sites in site/
hosting_site.module - Page handler for displaying list of hosted sites on front page
File
- site/
hosting_site.module, line 615
Code
function hosting_site_list($filter_by = null, $filter_value = null) {
$args[] = 'site';
$cond = '';
if ($filter_by && $filter_value) {
if ($filter_by == 'status') {
$cond = ' AND s.' . $filter_by . ' & %d';
}
else {
$cond = ' AND s.' . $filter_by . ' = %d';
}
$args[] = $filter_value;
}
$header = array(
array(
'data' => t('Site'),
'field' => 'title',
),
array(
'data' => t('Profile'),
'field' => 'profile',
),
array(
'data' => t('Language'),
'field' => 'language',
),
array(
'data' => t('Created'),
'field' => 'created',
'sort' => 'desc',
),
);
$platforms = _hosting_get_platforms();
if (sizeof($platforms) > 1) {
$header[] = array(
'data' => t('Platform'),
'field' => 'platform',
);
}
$sql = "SELECT n.nid, n.title, n.created, s.status as site_status, profile, language, platform, verified FROM {node} n left join {hosting_site} s ON n.vid=s.vid WHERE type='%s' AND s.status != -2 " . $cond;
$sql .= tablesort_sql($header);
// @TODO hide deleted sites
$result = pager_query(db_rewrite_sql($sql), 25, 1, null, $args);
if (!db_num_rows($result)) {
return null;
}
$rows = array();
while ($node = db_fetch_object($result)) {
$row = array();
$row[] = array(
'data' => l($node->title, 'node/' . $node->nid),
'class' => 'hosting-status',
);
$row[] = $node->profile ? _hosting_node_link($node->profile) : t('n/a');
$row[] = $node->language ? _hosting_language_name($node->language) : t('n/a');
$row[] = t("@interval ago", array(
'@interval' => format_interval(mktime() - $node->created, 1),
));
if (sizeof($platforms) > 1) {
$row[] = $node->platform ? _hosting_node_link($node->platform) : t('n/a');
}
$rows[] = array(
'data' => $row,
'class' => _hosting_site_list_class($node),
);
}
return theme('table', $header, $rows, array(
'class' => 'hosting-table',
)) . theme('pager', null, 25, 1);
}