[Isocial-svn] SF.net SVN: isocial:[302] app
Status: Pre-Alpha
Brought to you by:
aguidrevitch
From: <di...@us...> - 2008-09-01 14:10:27
|
Revision: 302 http://isocial.svn.sourceforge.net/isocial/?rev=302&view=rev Author: dim0s77 Date: 2008-09-01 14:10:35 +0000 (Mon, 01 Sep 2008) Log Message: ----------- maked search of groups by group name Modified Paths: -------------- app/controllers/groupapp/group_controller.php app/views/groupapp/group/browse.tpl Modified: app/controllers/groupapp/group_controller.php =================================================================== --- app/controllers/groupapp/group_controller.php 2008-08-29 13:44:26 UTC (rev 301) +++ app/controllers/groupapp/group_controller.php 2008-09-01 14:10:35 UTC (rev 302) @@ -287,8 +287,29 @@ } } + function _get_conditions_for_group( $to_ascii = true ) { + $query = $this->params['group_name']; + $aquery = utf8_to_ascii($query); + if ($to_ascii && $aquery != $query) { + $conditions = 'name LIKE "%' . $query . '%" OR name LIKE "%' . $aquery . '%"'; + } else { + $conditions = 'name LIKE "%' . $query . '%"'; + } + return $conditions; + } + function browse () { - $all_groups = $this->GroupappGroup->find('all'); + $all_groups = array(); + if (empty($this->params['group_name'])) { + $all_groups = $this->GroupappGroup->find('all'); + } else { + $all_groups = $this->GroupappGroup->find('all', + array('conditions' => $this->_get_conditions_for_group(), + 'order' => 'name' + )); + $this->group_name = $this->params['group_name']; + } + if (!($this->all_groups_count = count($all_groups))) { return; } $this->_extract_group_types(); @@ -304,6 +325,9 @@ " BETWEEN " . $this->group_type_id * 100 . " and " . ($this->group_type_id + 1) * 100; $_filter_pagination['count_conditions'] = "type_id" . $type_id; $_filter['conditions'] = 'type_id' . $type_id; + } elseif (!empty($this->params['group_name'])) { + $_filter_pagination['count_conditions'] = $this->_get_conditions_for_group(); + $_filter['conditions'] = $_filter_pagination['count_conditions']; } $group_pages = $this->pagination_helper->getPaginator($this->GroupappGroup, $_filter_pagination);// paginator Modified: app/views/groupapp/group/browse.tpl =================================================================== --- app/views/groupapp/group/browse.tpl 2008-08-29 13:44:26 UTC (rev 301) +++ app/views/groupapp/group/browse.tpl 2008-09-01 14:10:35 UTC (rev 302) @@ -33,8 +33,8 @@ <div class="right_content"> <div class="title_text">_{Search groups}:</div> - <form> - <input class="mediumtextinput search" id="searchfield" name="" type="text" value="_{Search by name}" onclick="on_search_group_click(this)" onblur="on_search_group_blur(this)" /><a class="submitsearchbtn">_{Search}</a> + <form name="search_group" action="/groupapp/group/browse" method="get"> + <input class="mediumtextinput search" id="searchfield" name="group_name" type="text" value="{?group_name}{group_name}{else}_{Search by name}{end}" onclick="on_search_group_click(this)" onblur="on_search_group_blur(this)" /><a class="submitsearchbtn" onclick="document.search_group.submit();">_{Search}</a> </form> <div class="clearfix"></div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |