summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormoshe weitzman2008-04-02 21:37:56 (GMT)
committer moshe weitzman2008-04-02 21:37:56 (GMT)
commitb292c0a05c904af888b5c879356f50d46141047c (patch)
treedcb9c9fb3676920e9c4bfc8520d91904d3d745d4
parent8174eebf57c3731547b6a43fea9b4c5495588cf5 (diff)
enhance faces content item so that it can be configured for row count and column count. also improve its css and pager
-rw-r--r--includes/groupcontent.inc23
-rw-r--r--og.css6
-rw-r--r--og.module26
3 files changed, 40 insertions, 15 deletions
diff --git a/includes/groupcontent.inc b/includes/groupcontent.inc
index 24edd19..b4da4e2 100644
--- a/includes/groupcontent.inc
+++ b/includes/groupcontent.inc
@@ -146,7 +146,7 @@ function og_panels_ct_render_callback_faces($conf, $panel_args, $context) {
$block->subject = t('Group Faces');
if ($node) {
- $block->content = og_list_users_faces_page($node->nid, $conf['row_count']);
+ $block->content = og_list_users_faces_page($node->nid, $conf['column_count'], $conf['row_count'], $conf['pager_id']);
$block->delta = $node->nid;
}
else {
@@ -158,10 +158,22 @@ function og_panels_ct_render_callback_faces($conf, $panel_args, $context) {
}
function og_panels_content_types_addedit_callback_faces($id, $panel_args, $conf = NULL) {
- $form['row_count'] = array(
+ $form['column_count'] = array(
'#type' => 'textfield',
'#title' => t('Number of pictures per row'),
- '#default_value' => isset($conf['row_count']) ? $conf['row_count'] : 5,
+ '#default_value' => isset($conf['column_count']) ? $conf['column_count'] : 5,
+ '#size' => 5,
+ );
+ $form['row_count'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Maximum number of rows per page'),
+ '#default_value' => isset($conf['row_count']) ? $conf['row_count'] : 10,
+ '#size' => 5,
+ );
+ $form['pager_id'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Pager ID'),
+ '#default_value' => isset($conf['pager_id']) ? $conf['pager_id'] : 0,
'#size' => 5,
);
return $form;
@@ -206,8 +218,11 @@ function og_panels_content_types_validate_callback_subscribers($form, $form_valu
}
function og_panels_content_types_validate_callback_faces($form, $form_values) {
+ if (!is_numeric($form_values['column_count'])) {
+ form_error($form['column_count'], t('Number of pictures per row must be an integer.'));
+ }
if (!is_numeric($form_values['row_count'])) {
- form_error($form['row_count'], t('Number of faces must be an integer.'));
+ form_error($form['row_count'], t('Maximum number of rows per page must be an integer.'));
}
}
diff --git a/og.css b/og.css
index 7df8b5d..c9ff7ba 100644
--- a/og.css
+++ b/og.css
@@ -34,7 +34,11 @@ table.og-picture-grid td {
text-align: center;
width: 20%;
padding: 7px 0 7px 0;
- border-bottom: 1px dotted;
+ border-top: #CCCCCC 1px dotted;
+}
+
+table.og-picture-grid td.first {
+ border-top: none;
}
td.og-picture-grid-item {
diff --git a/og.module b/og.module
index d27b18c..70db500 100644
--- a/og.module
+++ b/og.module
@@ -968,29 +968,35 @@ function og_list_users_page($gid) {
return $output;
}
-function og_list_users_faces_page($gid, $row_count = 5) {
+function og_list_users_faces_page($gid, $column_count = 5, $row_count = 10, $pager_id = 0) {
+ $max_per_page = $row_count * $column_count;
$sql = og_list_users_sql(0, 0, 'ou.is_admin DESC, u.picture DESC, u.name ASC');
- /* list group admins first, pending members second, regular members last. Alphabetize within each of these categories */
- $result = pager_query($sql, 100, "faces_$gid", NULL, $gid);
- $output = theme('og_picture_grid', $result, $row_count);
- $output .= theme('pager', "faces_$gid", 100);
+ /* list group admins first, members with pics second, regular members last. Alphabetize within each of these categories */
+ $result = pager_query($sql, $max_per_page, $pager_id, NULL, $gid);
+ $output = theme('og_picture_grid', $result, $column_count);
+ $output .= theme('pager', NULL, $max_per_page, $pager_id);
return $output;
}
// from views_bonus: grid.inc
-function theme_og_picture_grid($result, $row_count = 5) {
+function theme_og_picture_grid($result, $column_count = 5) {
$content = '<table class="og-picture-grid">';
$count = 0;
- $total = count($users);
+ $total = db_num_rows($result);
while ($user = db_fetch_object($result)) {
+ $classes = 'og-picture-grid-item';
+ if ($count < $column_count) {
+ $classes .= ' first';
+ }
+
$item = '';
- if ($count % $row_count == 0) {
+ if ($count % $column_count == 0) {
$content .= '<tr>';
}
$picture = theme('user_picture', $user);
$name = theme('username', $user);
$group_role = $user->is_admin ? t('admin') : '&nbsp;';
- $content .= "<td class=\"og-picture-grid-item\">$picture<div class=\"og-name\">$name</div>";
+ $content .= "<td class=\"$classes\">$picture<div class=\"og-name\">$name</div>";
if ($user->is_admin) {
$txt = t('admin');
$content .= "<div class=\"group-role\">$txt</div>";
@@ -998,7 +1004,7 @@ function theme_og_picture_grid($result, $row_count = 5) {
$content .= "</td>\n";
$count++;
- if ($count % $row_count == 0 || $count == $total) {
+ if ($count % $column_count == 0 || $count == $total) {
$content .= '</tr>';
}
}