Cheetah
index.php
Go to the documentation of this file.
1 <?php
2 
8  require_once( CH_DIRECTORY_PATH_MODULES . $aModule['path'] . 'classes/' . $aModule['class_prefix'] . 'View.php');
9  require_once( CH_DIRECTORY_PATH_MODULES . $aModule['path'] . 'classes/' . $aModule['class_prefix'] . 'Module.php');
10 
11  // ** init some needed variables ;
12 
15 
17 
18  $iIndex = 57;
19 
20  $iPollId = ( isset($_GET['id']) ) ? (int) $_GET['id'] : 0;
21 
22  // define all needed poll's settings ;
24  (
25  // check admin mode ;
26  'admin_mode' => isAdmin() ? true : false,
27 
28  // logged member's id ;
29  'member_id' => $iProfileId,
30 
31  // number of poll's columns for per page ;
32  'page_columns' => 2,
33 
34  // number of poll's elements for per page ;
35  'per_page' => ( isset($_GET['per_page']) )
36  ? (int) $_GET['per_page']
37  : 6,
38 
39  // current page ;
40  'page' => ( isset($_GET['page']) )
41  ? (int) $_GET['page']
42  : 1,
43 
44  'featured_page' => ( isset($_GET['featured_page']) )
45  ? (int) $_GET['featured_page']
46  : 1,
47 
48  'featured_per_page' => ( isset($_GET['featured_per_page']) )
49  ? (int) $_GET['featured_per_page']
50  : 3,
51 
52  // contain some specific actions for polls ;
53  'action' => ( isset($_GET['action']) )
54  ? $_GET['action']
55  : null,
56 
57  // contain number of needed pool id ;
58  'edit_poll_id' => ( isset($_GET['edit_poll_id']) )
59  ? (int) $_GET['edit_poll_id']
60  : 0,
61 
62  'mode' => ( isset($_GET['mode']) )
63  ? addslashes($_GET['mode'])
64  : null,
65 
66  'tag' => ( isset($_GET['tag']) )
67  ? addslashes($_GET['tag'])
68  : null
69  );
70 
72 
73  $_page['name_index'] = $iIndex;
74 
75  $sPageCaption = _t('_ch_poll_all');
76 
77  $_page['header'] = $sPageCaption ;
78  $_page['header_text'] = $sPageCaption ;
79  $_page['css_name'] = 'main.css';
80 
81  $oPoll -> _oTemplate -> setPageDescription( _t('_ch_poll_PH') );
82  $oPoll -> _oTemplate -> addPageKeywords( _t('_ch_poll_keyword') );
83 
84  // get custom actions button;
85  $oPoll -> getCustomActionButton();
86 
87  if(!$aPollSettings['action']) {
88  $_page_cont[$iIndex]['page_main_code'] = $oPoll -> searchAll();
89  } else {
90  switch($aPollSettings['action']) {
91  case 'user' :
92  $sUserName = ( isset($_GET['nickname']) )
93  ? $_GET['nickname']
94  : null;
95 
96  // define profile's Id;
97  $iProfileId = getId($sUserName);
98 
99  if($iProfileId) {
100  $GLOBALS['oTopMenu']->setCurrentProfileID($iProfileId);
101  $_page_cont[$iIndex]['page_main_code'] = $oPoll -> searchAllProfilePolls($iProfileId);
102  } else {
103  // if profile's Id not defined will draw all polls list;
104  $_page_cont[$iIndex]['page_main_code'] = $oPoll -> searchAll();
105  }
106  break;
107 
108  case 'tag' :
109  $sPageCaption = _t('_ch_poll_tags');
110 
111  $_page['header'] = $sPageCaption ;
112  $_page['header_text'] = $sPageCaption ;
113 
114  $sTag = ( isset($_GET['tag']) )
115  ? uri2title($_GET['tag'])
116  : null;
117 
118  $_page_cont[$iIndex]['page_main_code'] = $oPoll -> searchTags($sTag);
119  break;
120 
121  case 'category' :
122  $sPageCaption = _t('_ch_poll_view_category');
123 
124  $_page['header'] = $sPageCaption ;
125  $_page['header_text'] = $sPageCaption ;
126 
127  $sCategory = ( isset($_GET['category']) )
128  ? uri2title($_GET['category'])
129  : null;
130 
131  $_page_cont[$iIndex]['page_main_code'] = $oPoll -> searchCategories($sCategory);
132  break;
133 
134  case 'featured' :
135  $sPageCaption = _t('_ch_poll_featured_polls');
136 
137  $_page['header'] = $sPageCaption ;
138  $_page['header_text'] = $sPageCaption ;
139 
140  $_page_cont[$iIndex]['page_main_code'] = $oPoll -> searchFeatured();
141  break;
142 
143  case 'popular' :
144  $sPageCaption = _t('_ch_poll_popular_polls');
145 
146  $_page['header'] = $sPageCaption ;
147  $_page['header_text'] = $sPageCaption ;
148 
149  $_page_cont[$iIndex]['page_main_code'] = $oPoll -> searchPopular();
150  break;
151 
152  case 'my' :
153  $sPageCaption = _t('_ch_poll_my');
154 
155  $_page['header'] = $sPageCaption ;
156  $_page['header_text'] = $sPageCaption ;
157 
158  if($iProfileId) {
159  $GLOBALS['oTopMenu']->setCurrentProfileID($iProfileId);
160  $_page_cont[$iIndex]['page_main_code'] = $oPoll -> searchMy();
161  } else {
162  member_auth(0);
163  }
164  break;
165 
166  case 'show_poll_info' :
167  case 'poll_home' :
168 
169  // draw polls question on menu's panel;
170  $aPollInfo = current($oPoll -> _oDb -> getPollInfo($iPollId));
171  $sCode = '';
172  $sInitPart = $oPoll -> getInitPollPage();
173  if ($aPollSettings['action'] == 'show_poll_info') {
174  $isAllowView = FALSE;
175  if (!empty($aPollInfo))
176  {
177  if ((int)$aPollInfo['poll_approval'] == 1 || isAdmin($iProfileId) || isModerator($iProfileId))
178  $isAllowView = TRUE;
179  }
180  if ($isAllowView)
181  {
182  $oViewPoll = ch_instance($aModule['class_prefix'] . 'View', array($aPollSettings['action'], $aModule, $oPoll, $iPollId), $aModule);
183  $sPageTitle = $aPollInfo['poll_question'];
184 
185  $sPageCaption = _t('_ch_poll_view', $aPollInfo['poll_question']);
186  $_page['header'] = $sPageCaption ;
187  $_page['header_text'] = $sPageCaption ;
188 
189  $oPoll -> _oTemplate -> addJsTranslation(array('_Are_you_sure'));
190  $oPoll -> _oTemplate -> setPageDescription($aPollInfo['poll_question']);
191  $oPoll -> _oTemplate -> addPageKeywords($aPollInfo['poll_answers'], CH_POLL_ANS_DIVIDER);
192 
193  if( mb_strlen($sPageTitle) > $oPoll -> sPollHomeTitleLenght) {
194  $sPageTitle = mb_substr($sPageTitle, 0, $oPoll -> sPollHomeTitleLenght) . '...';
195  }
196  $sCode = $sInitPart . $oViewPoll -> getCode();
197  }
198  else
199  {
200  $oPoll->_oTemplate->displayPageNotFound();
201  }
202  $GLOBALS['oTopMenu'] -> setCustomSubHeader($sPageTitle);
203  $_page_cont[$iIndex]['page_main_code'] = $sCode;
204  } else {
205  $oViewPoll = ch_instance($aModule['class_prefix'] . 'View', array($aPollSettings['action'], $aModule, $oPoll, $iPollId), $aModule);
206  $sPageCaption = _t('_ch_poll_home');
207  $_page['header'] = $sPageCaption ;
208  $_page['header_text'] = $sPageCaption ;
209  $sCode = $sInitPart . $oViewPoll -> getCode();
210  }
211  $_page_cont[$iIndex]['page_main_code'] = $sCode;
212  break;
213 
214  case 'delete_poll':
215  if($iPollId)
216  $oPoll->deletePoll($iPollId);
217 
218  $_page_cont[$iIndex]['page_main_code'] = $oPoll -> searchAll();
219  break;
220 
221  default :
222  $_page_cont[$iIndex]['page_main_code'] = $oPoll -> searchAll();
223  }
224  }
225 
226  PageCode($oPoll -> _oTemplate);
TRUE
URI MungeSecretKey $secret_key</pre >< p > If the output is TRUE
Definition: URI.MungeSecretKey.txt:17
$sPageTitle
$sPageTitle
Definition: antispam.php:374
$sCode
$sCode
Definition: explanation.php:19
$aModule
$aModule
Definition: classifieds.php:21
$iPollId
$iPollId
Definition: index.php:20
uri2title
uri2title($sValue)
Definition: utils.inc.php:51
php
CH_POLL_ANS_DIVIDER
const CH_POLL_ANS_DIVIDER
Definition: ChPollModule.php:17
isAdmin
isAdmin()
Definition: index.php:649
isModerator
isModerator($iId=0)
Definition: profiles.inc.php:58
$oPoll
$oPoll
Definition: index.php:71
$aPollSettings
$aPollSettings
Definition: index.php:23
$_GET
$_GET['debug']
Definition: index.php:67
$sPageCaption
$sPageCaption
Definition: index.php:75
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
$GLOBALS
$GLOBALS['aRequest']
Definition: index.php:10
ch_instance
ch_instance($sClassName, $aParams=array(), $aModule=array())
Definition: utils.inc.php:1264
ChPollModule
Definition: ChPollModule.php:117
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
$_page
$_page['name_index']
Definition: index.php:47
PageCode
PageCode($oTemplate=null)
Definition: design.inc.php:91
member_auth
member_auth($member=0, $error_handle=true, $bAjx=false)
Definition: admin.inc.php:262
default
Attr AllowedFrameTargets _parent and _top Values should be as validation will be done in a case sensitive manner despite W3C s recommendation XHTML Strict does not permit the target attribute so this directive will have no effect in that doctype XHTML does not enable the Target module by default
Definition: Attr.AllowedFrameTargets.txt:10
$iProfileId
$iProfileId
Definition: index.php:16
$iIndex
$iIndex
Definition: index.php:18
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
$_page_cont
$_page_cont[$_ni]['page_main_code']
Definition: index.php:58