Cheetah
ChPollSearch.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( 'ChPollModule.php' );
11 
13 {
15  var $aModule;
16 
20  function __construct($oPollObject = null)
21  {
22  // call the parent constructor ;
23  parent::__construct();
24 
25  if(!$oPollObject) {
26  $this -> oPollObject = ChWsbModule::getInstance('ChPollModule');
27  } else {
28  $this -> oPollObject = $oPollObject;
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' => 'poll',
50  'title' => '_ch_polls',
51  'table' => $this -> oPollObject -> _oDb -> sTablePrefix . 'data',
52 
53  'ownFields' => array('id_poll', 'poll_question', 'poll_answers', 'poll_date'),
54  'searchFields' => array('poll_question', 'poll_answers', 'poll_tags', 'poll_categories'),
55 
56  'join' => array(
57  'profile' => array(
58  'type' => 'left',
59  'table' => 'Profiles',
60  'mainField' => 'id_profile',
61  'onField' => 'ID',
62  'joinFields' => array('NickName'),
63  )
64  ),
65 
66  'restriction' => array (
67  'activeStatus' => array('value'=>'active', 'field'=>'poll_status', 'operator'=>'='),
68  'approvalStatus' => array('value'=>'1', 'field'=>'poll_approval', 'operator'=>'='),
69  'tag' => array('value'=>'', 'field'=>'poll_tags', 'operator'=>'against', 'paramName'=>'tag'),
70  'category' => array('value'=>'', 'field'=>'poll_categories', 'operator'=>'against', 'paramName'=>'categoryUri'),
71  'owner' => array('value'=>'', 'field'=>'id_profile', 'operator'=>'=', 'paramName'=>'userID'),
72  'featured' => array('value'=>'', 'field'=>'poll_featured', 'operator'=>'='),
73  'unfeatured' => array('value'=>'', 'field'=>'poll_featured', 'operator'=>'='),
74  'my' => array('value'=>'', 'field'=>'id_profile', 'operator'=>'='),
75  'calendar-min' => array('value' => "", 'field' => 'poll_date', 'operator' => '>=', 'no_quote_value' => true),
76  'calendar-max' => array('value' => "", 'field' => 'poll_date', 'operator' => '<=', 'no_quote_value' => true),
77  'allow_view' => array('value' => "", 'field' => 'allow_view_to', 'operator' => 'in'),
78  ),
79 
80  'paginate' => array( 'perPage' => 6, 'page' => 1, 'totalNum' => 10, 'totalPages' => 1),
81  'sorting' => 'last',
82  'view' => 'full',
83  'ident' => 'id_poll'
84  );
85  }
86 
87  function displayResultBlock ()
88  {
89  $sCode = parent::displayResultBlock();
90  return !empty($sCode) ? $this->oPollObject->_oTemplate->parseHtmlByName('default_margin.html', array('content' => $sCode)) : $sCode;
91  }
92 
98  function displaySearchUnit($aData)
99  {
100  $aData['poll_ago'] = time() - $aData['poll_date'];
101  $sOutputHtml = $this -> oPollObject -> getPollBlock($aData);
102  return $sOutputHtml;
103  }
104 
110  function displaySearchBox ($sCode, $sPaginate = '', $bAdminBox = false)
111  {
112  // generate the init poll's part ;
113  $sInitSection = $this -> oPollObject -> getInitPollPage(false);
114 
115  if (isset($this->aCurrent['rss']) && $this->aCurrent['rss']['link'])
116  $aCaptionMenu = '<div class="dbTopMenu"><div class="notActive notActiveIcon" style="background-image:url('.getTemplateIcon('rss.png').')"><a target="_blank" class="top_members_menu" href="' . $this->aCurrent['rss']['link'] . (false === strpos($this->aCurrent['rss']['link'], '?') ? '?' : '&') . 'rss=1">' . _t('RSS') . '</a></div></div>';
117  $sCode = DesignBoxContent(_t($this->aCurrent['title']), $sCode. $sPaginate, 1, $aCaptionMenu);
118  if (!isset($_POST['searchMode'], $_GET['searchMode']))
119  $sCode = '<div id="page_block_'.$this->id.'">'.$sCode.'<div class="clear_both"></div></div>';
120 
121  // include css file ;
122  $sCssStyles = $this -> oPollObject -> _oTemplate -> addCss('main.css', true);
123 
124  return $sCssStyles . $sInitSection . $sCode;
125  }
126 
127  function _getPseud ()
128  {
129  }
130 
131  function getAlterOrder ()
132  {
133  $aSql = array();
134  switch($this->aCurrent['sorting']) {
135  case 'popular' :
136  $aSql['order'] = " ORDER BY `poll_rate` DESC";
137  break;
138 
139  case 'last' :
140  $aSql['order'] = " ORDER BY `poll_date` DESC";
141  break;
142 
143  default;
144  $aSql['order'] = " ORDER BY `poll_rate_count` DESC";
145  break;
146  }
147 
148  return $aSql;
149  }
150 
151  function showPagination($aParams = array())
152  {
153  $sModulePath = isset($aParams['module_path']) && !empty($aParams['module_path']) ? $aParams['module_path'] : false;
154 
155  $aParameters['settings'] = array(
156  'count' => $this -> aCurrent['paginate']['totalNum'],
157  'per_page' => $this -> aCurrent['paginate']['perPage'],
158  'page' => $this -> aCurrent['paginate']['page'],
159  );
160 
161  //define some pagination parameters;
162  if(!$sModulePath) {
163  $aLinkAddon = $this -> getLinkAddByPrams();
164  $aParameters['settings']['page_url'] = $this -> getCurrentUrl('browseAll', 0, '');
165  $aParameters['settings']['on_change_page'] = 'return !loadDynamicBlock(' . $this -> id . ', \'searchKeywordContent.php?searchMode=ajax&section[]=' . $this -> aCurrent['name'] . '&keyword=' . rawurlencode($_REQUEST['keyword']) . $aLinkAddon['params'] . '&page={page}&per_page={per_page}\');';
166  $aParameters['settings']['on_change_per_page'] = 'return !loadDynamicBlock(' . $this -> id . ', \'searchKeywordContent.php?searchMode=ajax&section[]=' . $this -> aCurrent['name'] . '&keyword=' . rawurlencode($_REQUEST['keyword']) . $aLinkAddon['params'] . '&page=1&per_page=\' + this.value);';
167  } else {
168  $aParameters['settings']['page_url'] = $sModulePath . '&page={page}&per_page={per_page}';
169  $aParameters['settings']['on_change_page'] = null;
170  $aParameters['settings']['on_change_per_page'] = null;
171  }
172 
173  $oPaginate = new ChWsbPaginate( array_shift($aParameters) );
174  $sPaginate = '<div class="clear_both"></div>' . $oPaginate -> getPaginate();
175 
176  return $sPaginate;
177  }
178 }
$sOutputHtml
$sOutputHtml
Definition: browse.php:86
$sModulePath
$sModulePath
Definition: ChSoundsUploader.php:21
ChBaseSearchResult\getLinkAddByPrams
getLinkAddByPrams($aExclude=array())
Definition: ChBaseSearchResult.php:186
ChWsbModule\getInstance
static getInstance($sClassName)
Definition: ChWsbModule.php:89
$sCode
$sCode
Definition: explanation.php:19
ChPollSearch\getAlterOrder
getAlterOrder()
Definition: ChPollSearch.php:131
ChTemplSearchResultText
Definition: ChTemplSearchResultText.php:11
ChBaseSearchResult\getCurrentUrl
getCurrentUrl($sType, $iId, $sUri, $aOwner='')
Definition: ChBaseSearchResult.php:27
ChPollSearch\$oPollObject
$oPollObject
Definition: ChPollSearch.php:14
php
ChPollSearch\displaySearchBox
displaySearchBox($sCode, $sPaginate='', $bAdminBox=false)
Definition: ChPollSearch.php:110
ChPollSearch\_getPseud
_getPseud()
Definition: ChPollSearch.php:127
$_GET
$_GET['debug']
Definition: index.php:67
ChPollSearch\showPagination
showPagination($aParams=array())
Definition: ChPollSearch.php:151
ChPollSearch\displaySearchUnit
displaySearchUnit($aData)
Definition: ChPollSearch.php:98
$_REQUEST
$_REQUEST['action']
Definition: cmd.php:11
ChWsbPaginate
Definition: ChWsbPaginate.php:69
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
time
that in the case of a Adaptation or at a minimum such credit will if a credit for all contributing authors of the Adaptation or Collection then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors For the avoidance of You may only use the credit required by this Section for the purpose of attribution in the manner set out above by exercising Your rights under this You may not implicitly or explicitly assert or imply any connection sponsorship or endorsement by the Original Licensor and or Attribution as of You or Your use of the without the express prior written permission of the Original Licensor and or Attribution Parties Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable if You Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or You must not modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author s honor or reputation Licensor agrees that in those in which any exercise of the right granted in modification or other derogatory action prejudicial to the Original Author s honor and the Licensor will waive or not as this to the fullest extent permitted by the applicable national to enable You to reasonably exercise Your right under Warranties and Disclaimer UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN LICENSOR OFFERS THE WORK AS IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE STATUTORY OR WITHOUT WARRANTIES OF FITNESS FOR A PARTICULAR OR THE ABSENCE OF LATENT OR OTHER OR THE PRESENCE OF ABSENCE OF WHETHER OR NOT DISCOVERABLE SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED SO SUCH EXCLUSION MAY NOT APPLY TO YOU Limitation on Liability EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES Termination This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License Individuals or entities who have received Adaptations or Collections from You under this will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses and will survive any termination of this License Subject to the above terms and the license granted here is Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time
Definition: license.txt:56
ChPollSearch\displayResultBlock
displayResultBlock()
Definition: ChPollSearch.php:87
ChPollSearch
Definition: ChPollSearch.php:13
ChPollSearch\$aModule
$aModule
Definition: ChPollSearch.php:15
ChPollSearch\__construct
__construct($oPollObject=null)
Definition: ChPollSearch.php:20
DesignBoxContent
DesignBoxContent($title, $content, $db_num=0, $caption_item='', $bottom_item='')
Definition: design.inc.php:78
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
$aParameters
$aParameters
Definition: index.php:29
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10