diff --git a/main/css/blue_lagoon/default.css b/main/css/blue_lagoon/default.css
index 7ffc173428..806dbcdffb 100755
--- a/main/css/blue_lagoon/default.css
+++ b/main/css/blue_lagoon/default.css
@@ -3024,7 +3024,8 @@ a.read {
}
.message-group-date {
color:#666;
- float:right;
+ width:100%;
+ text-align:right;
}
.view-message-content {
line-height:150%;
@@ -3185,6 +3186,13 @@ a.read {
.profile_grid_element_1 { width:170px; float:left; text-align:left; margin-bottom:1px; }
+/* pagination grid sortable */
+.sub_header {width:100%}
+.grid_selectbox {float:left;width:35%}
+.grid_title {float:left;width:30%;text-align:center}
+.grid_nav {float:left;width:35%;text-align:right}
+
+
/* Groups boxes */
.group_invitation_grid_container { width:100%;}
diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php
index 0b26b673c1..ef4121f113 100755
--- a/main/inc/lib/display.lib.php
+++ b/main/inc/lib/display.lib.php
@@ -321,10 +321,39 @@ class Display {
if (is_array($query_vars)) {
$table->set_additional_parameters($query_vars);
}
- $table->display_simple_grid($vibility_options, $paging_options['hide_navigation']);
+ echo $table->display_simple_grid($vibility_options, $paging_options['hide_navigation']);
}
-
+ /**
+ * gets a nice grid in html string
+ * @param string grid name (important to create css)
+ * @param array header content
+ * @param array array with the information to show
+ * @param array $paging_options Keys are:
+ * 'per_page_default' = items per page when switching from
+ * full- list to per-page-view
+ * 'per_page' = number of items to show per page
+ * 'page_nr' = The page to display
+ * 'hide_navigation' = true to hide the navigation
+ * @param array $query_vars Additional variables to add in the query-string
+ * @param array $form actions Additional variables to add in the query-string
+ * @param mixed An array with bool values to know which columns show. i.e: $vibility_options= array(true, false) we will only show the first column
+ * Can be also only a bool value. TRUE: show all columns, FALSE: show nothing
+ * @param bool true for sorting data or false otherwise
+ * @return string html grid
+ */
+ public static function return_sortable_grid ($name, $header, $content, $paging_options = array (), $query_vars = null, $form_actions=array(), $vibility_options = true, $sort_data = true) {
+ global $origin;
+ $column = 0;
+ $default_items_per_page = isset ($paging_options['per_page']) ? $paging_options['per_page'] : 20;
+ $table = new SortableTableFromArray($content, $column, $default_items_per_page, $name);
+
+ if (is_array($query_vars)) {
+ $table->set_additional_parameters($query_vars);
+ }
+ //var_dump($table->get_additional_url_paramstring());
+ return $table->display_simple_grid($vibility_options, $paging_options['hide_navigation'], $paging_options['per_page'], $sort_data);
+ }
/**
* Display a table with a special configuration
diff --git a/main/inc/lib/message.lib.php b/main/inc/lib/message.lib.php
index 4081493d2f..02624b2864 100755
--- a/main/inc/lib/message.lib.php
+++ b/main/inc/lib/message.lib.php
@@ -836,9 +836,13 @@ class MessageManager
$rows = self::get_messages_by_group($group_id);
$rows = self::calculate_children($rows);
$group_info = GroupPortalManager::get_group_data($group_id);
- $current_user_id = api_get_user_id();
+ $current_user_id = api_get_user_id();
+ $topics_per_page = 5;
+ $items_per_page = 3;
$count_items = 0;
- $html = '';
+ $html_messages = '';
+ $query_vars = array('id'=>$group_id,'topics_page_nr'=>0);
+
if (is_array($rows) && count($rows)> 0) {
// prepare array for topics with its items
@@ -852,25 +856,12 @@ class MessageManager
$topics[$x]['items'][] = $value;
}
}
- uasort($topics,array('MessageManager','order_desc_date'));
-
- // pager
- $page = isset($_GET['page_nr'])?intval($_GET['page_nr']):1;
- $total_topics = count($topics);
- $topics_per_page = 5;
- $pager = self::get_pager_for_message_group($group_id,$page,$total_topics,$topics_per_page);
-
+ uasort($topics,array('MessageManager','order_desc_date'));
- // topics and items
- $parents = array_keys(self::get_messages_by_parent(0,$group_id,$page,$topics_per_page));
- $html .= '
';
- $html .= ' ';
+ $param_names = array_keys($_GET);
+ $array_html = array();
foreach ($topics as $index => $topic) {
-
- if (!in_array($index,$parents)) continue;
-
+ $html = '';
// topics
$indent = 0;
$user_sender_info = UserManager::get_user_info_by_id($topic['user_sender_id']);
@@ -880,179 +871,91 @@ class MessageManager
$html .= '
';
$html .= '
'.Display::return_icon('content-post-group1.jpg').'
';
$html .= '
';
- $html .= '
- '.((isset($_GET['div_id']) && $_GET['div_id'] == 'content_'.$topic['id'])?Display::return_icon('div_hide.gif',get_lang('Hide'),array('style'=>'vertical-align: middle')):
- Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align: middle'))).'
- '.$topic['title'].'';
- $html .= '';
+ $html .= '
';
+ $html .= ''.(((isset($_GET['anchor_topic']) && $_GET['anchor_topic'] == 'topic_'.$topic['id']) || in_array('items_'.$topic['id'].'_page_nr',$param_names))?Display::return_icon('div_hide.gif',get_lang('Hide'),array('style'=>'vertical-align: middle')):
+ Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align: middle'))).'
+ '.$topic['title'].'';
+ $html .= '';
- if ($topic['send_date']!=$topic['update_date']) {
- if (!empty($topic['update_date']) && $topic['update_date'] != '0000-00-00 00:00:00' ) {
- $html .= '
('.get_lang('LastUpdate').' '.date_to_str_ago($topic['update_date']).')';
- }
- } else {
- $html .= '
('.get_lang('Created').' '.date_to_str_ago($topic['send_date']).')';
- }
+ if ($topic['send_date']!=$topic['update_date']) {
+ if (!empty($topic['update_date']) && $topic['update_date'] != '0000-00-00 00:00:00' ) {
+ $html .= '
('.get_lang('LastUpdate').' '.date_to_str_ago($topic['update_date']).')';
+ }
+ } else {
+ $html .= '
('.get_lang('Created').' '.date_to_str_ago($topic['send_date']).')';
+ }
- $html .= '
';
- $html .= '
';
- $html.= '
';
- $html.= '
';
- $html.= '
';
- $html.= '
';
- $html.= '
'.$topic['content'].'
';
- $html.= '
'.(!empty($files_attachments)?implode(' | ',$files_attachments):'').'
';
- $html.= '
';
+ $html .= '
';
+ $html .= '
';
+ $html.= '
';
+ $html.= '
';
+ $html.= '
';
+ $html.= '
';
+ $html.= '
'.$topic['content'].'
';
+ $html.= '
'.(!empty($files_attachments)?implode(' | ',$files_attachments):'').'
';
+ $html.= '
';
- // items
+ // items
if (is_array($topic['items'])) {
-
- // pager items
- $page_item = isset($_GET['page_item_nr'])?intval($_GET['page_item_nr']):1;
- $total_items = count($topic['items']);
- $items_per_page = 3;
- $div_content = 'content_'.$topic['id'];
- $pager_items = self::get_pager_for_message_group($group_id,$page_item,$total_items,$items_per_page,true,$div_content);
- $html .= ' ';
-
- $topic_slice['items'] = array_slice($topic['items'],($page_item-1)*($items_per_page),$items_per_page);
-
- $count_items = count($topic['items']);
- $current_page = $count_items/$items_per_page;
- if (is_int($current_page)) {
- $page_item_nr = $current_page + 1;
- } else {
- $page_item_nr = intval($_GET['page_item_nr']);
- }
-
- foreach ($topic_slice['items'] as $item) {
- $indent = $item['indent_cnt']*'15';
+ $items_page_nr = intval($_GET['items_'.$topic['id'].'_page_nr']);
+ $array_html_items = array();
+ foreach ($topic['items'] as $item) {
+ $html_items = '';
+ //$indent = $item['indent_cnt']*'15';
$user_sender_info = UserManager::get_user_info_by_id($item['user_sender_id']);
$files_attachments = self::get_links_message_attachment_files($item['id']);
$name = api_get_person_name($user_sender_info['firstname'], $user_sender_info['lastname']);
-
-
- //$html.= '
';
- $html.= '
';
- $html .= '
'.Display::return_icon('content-post-reply01.jpg').'
';
- $html .= '
';
- $html.= '
';
- //$html.= '
'.Display :: return_icon('forumthread_new.gif', get_lang('Reply')).'';
- $html.= '
'.Display :: return_icon('forumthread_new.gif', get_lang('Reply')).'';
+
+ $html_items.= '
';
+ $html_items .= '
'.Display::return_icon('content-post-reply01.jpg').'
';
+ $html_items .= '
';
+ $html_items.= '
';
- $html.= '
'.$item['title'].'
';
- $html.= '
';
- $html.= '
'.$item['content'].'
';
+ $html_items.= '
';
+ $html_items.= '
'.$item['title'].'
';
+ $html_items.= '
';
+ $html_items.= '
'.$item['content'].'
';
if ($item['send_date'] != $item['update_date']) {
if (!empty($item['update_date']) && $item['update_date'] != '0000-00-00 00:00:00' ) {
- $html .= '
'.get_lang('LastUpdate').' '.date_to_str_ago($item['update_date']).'';
+ $html_items .= '
'.get_lang('LastUpdate').' '.date_to_str_ago($item['update_date']).'
';
}
} else {
- $html .= '
'.get_lang('Created').' '.date_to_str_ago($item['send_date']).'';
+ $html_items .= '
'.get_lang('Created').' '.date_to_str_ago($item['send_date']).'
';
}
- $html.= '
'.(!empty($files_attachments)?implode(' | ',$files_attachments):'').'
';
- $html.= '
';
- $html.= '
';
- }
-
- /*
- // pager items
- $html .= ' ';
- */
-
+
+ $html_items.= '
'.(!empty($files_attachments)?implode(' | ',$files_attachments):'').'
';
+ $html_items.= '
';
+ $html_items.= '
';
+ $array_html_items[] = array($html_items);
+ }
+ // grids for items with paginations
+ $html .= Display::return_sortable_grid('items_'.$topic['id'], array(), $array_html_items, array('hide_navigation'=>false, 'per_page' => $items_per_page), $query_vars, false, array(true, true, true,false), false);
}
$html .= '
';
$html .= '
';
- $html .= '
';
+ $html .= '
';
+ $array_html[] = array($html);
}
- $html .= '
';
+ // grids for items and topics with paginations
- /*
- // pager
- $html .= ' ';
- */
- }
- return $html;
- }
-
- /**
- * Get pager for messages of group
- * @param int group id
- * @param int current page
- * @param int total rows
- * @param int rows per page
- * @return array pager with details and links
- */
- public static function get_pager_for_message_group($group_id,$page,$num_rows,$rows_per_page,$pager_items = false,$div_content='') {
-
- $link = '';
- $details = '';
- $pager = array();
- $group_id = intval($group_id);
- $page = intval($page);
- $num_rows = intval($num_rows);
- $first_page = 1;
- $last_page = ceil($num_rows/$rows_per_page);
-
- // get details
- if ($page == $first_page) {
- $details = $page.' - '.($page*$rows_per_page).' / '.$num_rows;
- } else if ($page > $first_page && $page < $last_page) {
- $details = ((($page-1)*$rows_per_page)+1).' - '.($page*$rows_per_page).' / '.$num_rows;
- } else {
- $details = ((($page-1)*$rows_per_page)+1).' - '.($num_rows).' / '.$num_rows;
- }
- $pager['details'] = $details;
-
-
- // get links for pager
- $href = api_get_path(WEB_CODE_PATH).'social/groups.php?id='.$group_id;
-
- if ($pager_items) {
- $page_topic = isset($_GET['page_nr'])?intval($_GET['page_nr']):1;
- $param_name_page_nr = '&page_nr='.$page_topic.'&div_id='.$div_content.'&page_item_nr=';
- } else {
- $param_name_page_nr = '&page_nr=';
+ $html_messages .= '
';
+ $html_messages .= Display::return_sortable_grid('topics', array(), $array_html, array('hide_navigation'=>false, 'per_page' => $topics_per_page), $query_vars, false, array(true, true, true,false), false);
+ $html_messages .= '
';
}
- if ($page > 1) {
- $link .= '
';
- $link .= Display::return_icon('first.png',get_lang('FirstPage'),array('style'=>'vertical-align: middle'));
- $link .= '';
- $link .= '
';
- $link .= Display::return_icon('prev.png',get_lang('PreviousPage'),array('style'=>'vertical-align: middle'));
- $link .= '';
- }
- $link .= $page.'/'.$last_page;
-
- if ($page < $last_page) {
- $link .= '
';
- $link .= Display::return_icon('next.png',get_lang('NextPage'),array('style'=>'vertical-align: middle'));
- $link .= '';
- $link .= '
';
- $link .= Display::return_icon('last.png',get_lang('PreviousPage'),array('style'=>'vertical-align: middle'));
- $link .= '';
- }
- $pager['links'] = $link;
- return $pager;
+ return $html_messages;
}
-
/**
* Add children to messages by id is used for nested view messages
diff --git a/main/inc/lib/sortabletable.class.php b/main/inc/lib/sortabletable.class.php
index dcc55ea62d..9d40d12b24 100755
--- a/main/inc/lib/sortabletable.class.php
+++ b/main/inc/lib/sortabletable.class.php
@@ -429,7 +429,16 @@ class SortableTable extends HTML_Table {
echo $html;
}
- public function display_simple_grid($vibility_options, $hide_navigation) {
+ /**
+ * This function return the content of a table in a grid
+ * Should not be use to edit information (edit/delete rows) only.
+ * @param array options of visibility
+ * @param bool hide navigation optionally
+ * @param int content per page when show navigation (optional)
+ * @param bool sort data optionally
+ * @return string grid html
+ */
+ public function display_simple_grid($vibility_options, $hide_navigation = true, $per_page = 0, $sort_data = true) {
global $charset;
$empty_table = false;
$html = '';
@@ -448,19 +457,21 @@ class SortableTable extends HTML_Table {
if (!$empty_table) {
//if we show the pagination
- if ($hide_navigation == false ) {
- $form = $this->get_page_select_form();
- $nav = $this->get_navigation_html();
-
+ if ($hide_navigation == false ) {
+ $form = ' ';
+ if ($per_page > 10) {
+ $form = $this->get_page_select_form();
+ }
+ $nav = $this->get_navigation_html();
//this also must be moved
- $html = '