From bcc0ad4746f4a8eb18739e52c085e9325d3436eb Mon Sep 17 00:00:00 2001 From: Evgeny Gryaznov Date: Mon, 29 Sep 2008 22:37:47 +0000 Subject: [PATCH] minor: formatting git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@112 c66351dc-e62f-0410-b875-e3a5c0b9693f --- src/messenger/webim/libs/operator.php | 15 ++++----------- src/messenger/webim/libs/pagination.php | 25 ++++++++++++------------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/messenger/webim/libs/operator.php b/src/messenger/webim/libs/operator.php index 68f07376..cfd4a209 100644 --- a/src/messenger/webim/libs/operator.php +++ b/src/messenger/webim/libs/operator.php @@ -36,17 +36,10 @@ function get_operators() { $link = connect(); $query = "select * from chatoperator order by vclogin"; - $result = mysql_query($query,$link) or die(' Query failed: ' .mysql_error().": ".$query); - - $operators = array(); - while ($op = mysql_fetch_array($result, MYSQL_ASSOC)) { - $operators[] = $op; - } - - mysql_free_result($result); + $result = select_multi_assoc($query, $link); mysql_close($link); - return $operators; -} + return $result; +} function update_operator($operatorid,$login,$password,$localename,$commonname) { $link = connect(); @@ -65,7 +58,7 @@ function update_operator($operatorid,$login,$password,$localename,$commonname) { function create_operator_($login,$password,$localename,$commonname,$link) { $query = sprintf( - "insert into chatoperator (vclogin,vcpassword,vclocalename,vccommonname".") values ('%s','%s','%s','%s'".")", + "insert into chatoperator (vclogin,vcpassword,vclocalename,vccommonname) values ('%s','%s','%s','%s')", mysql_real_escape_string($login), md5($password), mysql_real_escape_string($localename), diff --git a/src/messenger/webim/libs/pagination.php b/src/messenger/webim/libs/pagination.php index d7e2b687..9c2aebdd 100644 --- a/src/messenger/webim/libs/pagination.php +++ b/src/messenger/webim/libs/pagination.php @@ -34,31 +34,31 @@ function setup_pagination($items,$default_items_per_page=15) { $items_per_page = verifyparam("items", "/^\d{1,3}$/", $default_items_per_page); if( $items_per_page < 2 ) $items_per_page = 2; - + $total_pages = div(count($items) + $items_per_page - 1, $items_per_page); $curr_page = verifyparam("page", "/^\d{1,6}$/", 1); - + if( $curr_page < 1 ) $curr_page = 1; if( $curr_page > $total_pages ) $curr_page = $total_pages; - + $start_index = ($curr_page-1)*$items_per_page; $end_index = min($start_index+$items_per_page, count($items)); - $page['pagination.items'] = array_slice($items, $start_index, $end_index-$start_index); - $page['pagination'] = - array( "page" => $curr_page, "items" => $items_per_page, "total" => $total_pages, - "count" => count($items), "start" => $start_index, "end" => $end_index ); + $page['pagination.items'] = array_slice($items, $start_index, $end_index-$start_index); + $page['pagination'] = + array( "page" => $curr_page, "items" => $items_per_page, "total" => $total_pages, + "count" => count($items), "start" => $start_index, "end" => $end_index ); } else { - $page['pagination.items'] = false; - $page['pagination'] = true; + $page['pagination.items'] = false; + $page['pagination'] = true; } } function setup_empty_pagination() { global $page; - $page['pagination.items'] = false; - $page['pagination'] = false; + $page['pagination.items'] = false; + $page['pagination'] = false; } function generate_pagination($pagination) { @@ -72,7 +72,7 @@ function generate_pagination($pagination) { $minPage = max( $curr_page - $links_on_page, 1 ); $maxPage = min( $curr_page + $links_on_page, $pagination['total'] ); - + if( $curr_page > 1 ) { $result .= generate_pagination_link($curr_page-1, generate_pagination_image("prevpage")).$pagination_spacing; } @@ -87,7 +87,6 @@ function generate_pagination($pagination) { $result .= $pagination_spacing; } - if( $curr_page < $pagination['total'] ) { $result .= $pagination_spacing.generate_pagination_link($curr_page+1, generate_pagination_image("nextpage")); }