Cheetah
ChSpySearch.php
Go to the documentation of this file.
1 <?php
2 
8  require_once( CH_DIRECTORY_PATH_ROOT . 'templates/tmpl_' . $GLOBALS['tmpl'] . '/scripts/ChTemplSearchResultText.php');
9  require_once( CH_DIRECTORY_PATH_CLASSES . 'ChWsbPaginate.php' );
10  require_once( 'ChSpyModule.php' );
11 
13  {
15  var $aModule;
16 
20  function __construct($oSpyObject = null)
21  {
22  // call the parent constructor ;
23  parent::__construct();
24 
25  if(!$oSpyObject) {
26  $this -> oSpyObject = ChWsbModule::getInstance('ChSpyModule');
27  } else {
28  $this -> oSpyObject = $oSpyObject;
29  }
30 
31  // init some needed db table's fields ;
32 
33  /* main settings for shared modules
34  ownFields - fields which will be got from main table ($this->aCurrent['table'])
35  searchFields - fields which using for full text key search
36  join - array of join tables
37  join array (
38  'type' - type of join
39  'table' - join table
40  'mainField' - field from main table for 'on' condition
41  'onField' - field from joining table for 'on' condition
42  'joinFields' - array of fields from joining table
43  )
44  */
45 
46  $this -> aCurrent = array (
47 
48  // module name ;
49  'name' => 'spy',
50  'title' => '_ch_spy',
51  'table' => $this -> oSpyObject -> _oDb -> sTablePrefix . 'data',
52 
53  'ownFields' => array('id', 'sender_id', 'lang_key', 'params', 'date'),
54 
55  'join' => array(
56  'profile' => array(
57  'type' => 'left',
58  'table' => 'Profiles',
59  'mainField' => 'sender_id',
60  'onField' => 'ID',
61  'joinFields' => array('NickName'),
62  ),
63  ),
64 
65  'restriction' => array (
66  'global' => array('value'=>'', 'field'=>'', 'operator'=>'='),
67  'friends' => array('value' => '', 'field' => 'friend_id', 'operator'=>'=', 'table' => $this -> oSpyObject -> _oDb -> sTablePrefix . 'friends_data'),
68  'no_my' => array('value'=>'', 'field'=>'sender_id', 'operator'=>'<>', 'table' => $this -> oSpyObject -> _oDb -> sTablePrefix . 'data'),
69  'over_id' => array('value'=>'', 'field'=>'id', 'operator'=>'>', 'table' => $this -> oSpyObject -> _oDb -> sTablePrefix . 'data'),
70  'type' => array('value'=>'', 'field'=>'type', 'operator'=>'=', 'table' => $this -> oSpyObject -> _oDb -> sTablePrefix . 'data'),
71  'only_me' => array('value'=>'', 'field'=>'recipient_id', 'operator'=>'=', 'table' => $this -> oSpyObject -> _oDb -> sTablePrefix . 'data'),
72  'viewed' => array('value'=>'', 'field'=>'viewed', 'operator'=>'in', 'table' => $this -> oSpyObject -> _oDb -> sTablePrefix . 'data'),
73  ),
74 
75  'paginate' => array( 'perPage' => $this -> oSpyObject -> _oConfig -> iPerPage, 'page' => 1, 'totalNum' => 10, 'totalPages' => 1),
76  'sorting' => 'last',
77  'view' => 'full',
78  'ident' => 'id'
79  );
80  }
81 
88  function showPagination($aParams = array())
89  {
90  $sModulePath = '';
91  if(isset($aParams['module_path']) && !empty($aParams['module_path']))
92  $sModulePath = $aParams['module_path'];
93  else
94  $sModulePath = ch_append_url_params($this->oSpyObject->_oConfig->getBaseUri(), array('type' => 'all'));
95 
96  $sScript = isset($aParams['on_change_page']) && !empty($aParams['on_change_page']) ? $aParams['on_change_page'] : null;
97 
98  $aPaginate = array(
99  'count' => $this -> aCurrent['paginate']['totalNum'],
100  'per_page' => $this -> aCurrent['paginate']['perPage'],
101  'page' => $this -> aCurrent['paginate']['page'],
102  'page_url' => $sModulePath . '&page={page}&per_page={per_page}',
103  'on_change_page' => $sScript,
104  'on_change_per_page' => null
105  );
106 
107  $oPaginate = new ChWsbPaginate($aPaginate);
108  return '<div class="clear_both"></div>' . $oPaginate -> getSimplePaginate(null, -1, -1, false);
109  }
110 
111  function getAlterOrder ()
112  {/*
113  return array(
114  'groupBy' => " GROUP BY `{$this -> oSpyObject -> _oDb -> sTablePrefix}events`.`id`",
115  );*/
116  }
117 
118  function getLimit ()
119  {
120  if( isset($this->aCurrent['paginate']['unlimit']) ) {
121  return;
122  } else if( isset($this->aCurrent['paginate']['limit']) ){
123  return 'LIMIT ' . $this->aCurrent['paginate']['limit'];
124  } else if (isset($this->aCurrent['paginate'])) {
125  $sqlFrom = ( $this->aCurrent['paginate']['page'] - 1 ) * $this->aCurrent['paginate']['perPage'];
126  $sqlTo = $this->aCurrent['paginate']['perPage'];
127  return 'LIMIT ' . $sqlFrom .', '.$sqlTo;
128  }
129  }
130  }
ChSpySearch\$aModule
$aModule
Definition: ChSpySearch.php:15
$sModulePath
$sModulePath
Definition: ChSoundsUploader.php:21
ChWsbModule\getInstance
static getInstance($sClassName)
Definition: ChWsbModule.php:89
ChTemplSearchResultText
Definition: ChTemplSearchResultText.php:11
ChSpySearch\showPagination
showPagination($aParams=array())
Definition: ChSpySearch.php:88
php
ChSpySearch\getAlterOrder
getAlterOrder()
Definition: ChSpySearch.php:111
ChSpySearch\$oSpyObject
$oSpyObject
Definition: ChSpySearch.php:14
ChSpySearch\__construct
__construct($oSpyObject=null)
Definition: ChSpySearch.php:20
ChSpySearch
Definition: ChSpySearch.php:13
ch_append_url_params
ch_append_url_params($sUrl, $mixedParams)
Definition: utils.inc.php:1697
ChSpySearch\getLimit
getLimit()
Definition: ChSpySearch.php:118
ChWsbPaginate
Definition: ChWsbPaginate.php:69
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10