HomeHelpTrac

source: tags/6.1/qsearch.php @ 10242

Revision 10242, 3.9 KB checked in by Alexander Trofimov, 3 years ago (diff)

dolphin 6.1.5, initial commit

Line 
1<?
2
3/***************************************************************************
4*                            Dolphin Smart Community Builder
5*                              -----------------
6*     begin                : Mon Mar 23 2006
7*     copyright            : (C) 2006 BoonEx Group
8*     website              : http://www.boonex.com/
9* This file is part of Dolphin - Smart Community Builder
10*
11* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
12* http://creativecommons.org/licenses/by/3.0/
13*
14* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15* without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16* See the Creative Commons Attribution 3.0 License for more details.
17* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
18* see license.txt file; if not, write to marketing@boonex.com
19***************************************************************************/
20
21require_once( 'inc/header.inc.php' );
22require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
23require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
24
25// --------------- page variables and login
26
27
28$_page['name_index']    = 79;
29$_page['css_name']      = 'qsearch.css';
30
31
32$logged['member'] = member_auth( 0, false );
33
34$memberID = (int)$_COOKIE['memberID'];
35
36$_page['header'] = $site['title'].". ". _t( "_Quick Search Members" );
37//$_page['header_text'] = _t( "_Quick Search Members" );
38
39// --------------- page components
40
41$_ni = $_page['name_index'];
42$_page_cont[$_ni]['close_window'] = "<a href=\"javascript:window.close();\">"._t('_close window')."</a>";
43
44if( $_REQUEST['do_submit'] and $_REQUEST['keyword'] )
45{
46    $_page['header_text']               = _t('_Quick search results');
47    $_page['extra_js']                  = <<<EOJ
48<script type="text/javascript">
49    hMemberAction = window.opener.{$_REQUEST['handler']}; //Member Action Handler
50</script>
51EOJ;
52
53    $_page_cont[$_ni]['page_main_code'] = PageCompSearchResults();
54}
55else
56{
57    $_page['header_text']               = _t('_Enter search parameters');
58    $_page_cont[$_ni]['page_main_code'] = PageCompSearchForm();
59}
60
61// --------------- [END] page components
62
63PageCode();
64
65// --------------- page components functions
66
67/**
68 * page code function
69 */
70function PageCompSearchForm()
71{
72    ob_start();
73    ?>
74        <form action="<?=$_SERVER['PHP_SELF']?>" method="GET">
75            <input type="hidden" name="handler" value="<?=$_REQUEST['handler']?>" />
76            <div class="qsearch_form">
77                <div class="qsearch_label"><?=_t('_Enter member NickName or ID')?>:</div>
78                <input type="text" name="keyword" />
79                <input type="submit" name="do_submit" value="<?=_t('_Search')?>" />
80            </div>
81        </form>
82    <?php
83    return ob_get_clean();
84}
85
86function PageCompSearchResults()
87{
88    global $tmpl;
89   
90    $keyword = process_db_input($_REQUEST['keyword']);
91   
92    $sMembersQuery = "
93        SELECT *
94        FROM `Profiles`
95        WHERE
96        " .
97        ( is_numeric( $keyword ) ?
98          "`ID` = '$keyword'" :
99          "`NickName` LIKE '%$keyword%'" ) .
100        "";
101   
102    $rMembers = db_res( $sMembersQuery );
103   
104    if( !mysql_num_rows( $rMembers ) )
105        return '<div class="qsearch_notfound">'._t('_Sorry, no members found').'</div>';
106   
107    $sRowTmpl = file_get_contents( BX_DIRECTORY_PATH_ROOT . "templates/tmpl_$tmpl/qsearch_row.html" );
108   
109    $ret = '';
110    while( $aMember = mysql_fetch_assoc( $rMembers ) )
111    {
112        $aRowTmpl = array();
113       
114        $aRowTmpl['thumbnail'] = get_member_thumbnail( $aMember['ID'], 'none' );
115        $aRowTmpl['NickName']  = "<a href=\"".getProfileLink($aMember['ID'])."\" target=\"_blank\">".htmlspecialchars_adv( $aMember['NickName'] )."</a>";
116        $aRowTmpl['actions']   = "<a href=\"javascript:void(0);\" onclick=\"hMemberAction({$aMember['ID']}, '{$aMember['NickName']}')\">"._t('_Add member')."</a>";
117       
118        $sRow = $sRowTmpl;
119        foreach( $aRowTmpl as $what => $to )
120            $sRow = str_replace( "__{$what}__", $to, $sRow );
121       
122        $ret .= $sRow;
123    }
124    return $ret;
125}
126
127?>
Note: See TracBrowser for help on using the repository browser.