8 require_once(CH_DIRECTORY_PATH_INC .
'profiles.inc.php');
11 define(
'CH_PROFILE_MENU_ID', 9);
37 $this->aTopMenu = array();
43 $this->aTopMenu =
$oCache->getData(
$GLOBALS[
'MySQL']->genDbCacheKey(
'sys_menu_top'));
45 if (
null === $this->aTopMenu) {
50 $this->aTopMenu =
$oCache->getData(
$GLOBALS[
'MySQL']->genDbCacheKey(
'sys_menu_top'));
53 if( !$this->aTopMenu
or !is_array( $this->aTopMenu ) ) {
54 echo
'<b>Warning!</b> Cannot evaluate Menu Cache.';
67 $iProfileID = (int)$iProfileID;
71 if($iProfileID > 0 && !
empty($sProfileUserName) && !
empty($sProfileNickName)) {
72 $this->aMenuInfo[
'profileID'] = $iProfileID;
73 $this->aMenuInfo[
'profileUsername'] = $sProfileUserName;
74 $this->aMenuInfo[
'profileNick'] = $sProfileNickName;
77 $this->aMenuInfo[
'profileID'] = 0;
78 $this->aMenuInfo[
'profileUsername'] =
'';
79 $this->aMenuInfo[
'profileNick'] =
'';
80 $this->aMenuInfo[
'profileLink'] =
'';
86 $this->aMenuInfo[$sVar] = $sVal;
91 $this->aMenuInfo[$sVar] = $sVal;
96 $sNickName = trim($sNickName);
97 $iProfileID =
getID($sNickName);
105 $aSiteUrl = parse_url( CH_WSB_URL_ROOT );
106 $this->sRequestUriFile = substr($_SERVER[
'REQUEST_URI'], strlen($aSiteUrl[
'path']));
107 $this->sSelfFile = substr(
ch_html_attribute($_SERVER[
'PHP_SELF']), strlen($aSiteUrl[
'path']));
110 $this->aMenuInfo[
'memberID'] = (int)$_COOKIE[
'memberID'];
111 $this->aMenuInfo[
'memberUsername'] =
getUsername( $this->aMenuInfo[
'memberID'] );
112 $this->aMenuInfo[
'memberNick'] =
getNickName( $this->aMenuInfo[
'memberID'] );
113 $this->aMenuInfo[
'memberLink'] =
getProfileLink( $this->aMenuInfo[
'memberID'] );
114 $this->aMenuInfo[
'visible'] =
'memb';
116 $this->aMenuInfo[
'memberID'] = 0;
117 $this->aMenuInfo[
'memberUsername'] =
'';
118 $this->aMenuInfo[
'memberNick'] =
'';
119 $this->aMenuInfo[
'memberLink'] =
'';
120 $this->aMenuInfo[
'visible'] =
'non';
124 if (
empty($this->aMenuInfo[
'profileID'])) {
127 $selfFile = basename( $_SERVER[
'PHP_SELF'] );
130 $iProfileID = (int)
$p_arr[
'ID'];
133 elseif ($selfFile ==
'browseMedia.php')
134 $iProfileID = (int)
$_GET[
'userID'];
135 elseif ($selfFile ==
'viewFriends.php')
136 $iProfileID = (int)
$_GET[
'iUser'];
144 $iProfileID = (int)
$_REQUEST[
'profileID'];
157 $this->aMenuInfo[
'currentCustom'] = -1;
158 $this->aMenuInfo[
'currentTop'] = 0;
159 $this->aMenuInfo[
'currentTopLink'] = 0;
161 $aPossibleItems = array();
162 foreach( $this->aTopMenu
as $iItemID => $aItem ) {
164 if( $aItem[
'Type'] ==
'top' and $this->aMenuInfo[
'currentTop']
and $this->aMenuInfo[
'currentTop'] != $iItemID )
168 if((!isset($this->aMenuInfo[
'profileID']) || !$this->aMenuInfo[
'profileID']) &&
CH_PROFILE_MENU_ID == $aItem[
'Parent'] )
171 $this->aMenuInfo[
'currentTopLink'] = $aItem[
'Link'];
173 $aItemUris = explode(
'|', $aItem[
'Link'] );
174 foreach ($aItemUris
as $sItemUri) {
176 if(
empty($this->aMenuInfo[
'memberID'] )) {
177 unset($this->aMenuInfo[
'memberID']);
178 unset($this->aMenuInfo[
'memberUsername']);
179 unset($this->aMenuInfo[
'memberNick']);
180 unset($this->aMenuInfo[
'memberLink']);
183 if(
empty($this->aMenuInfo[
'profileID']) ) {
184 unset ($this->aMenuInfo[
'profileID']);
185 unset ($this->aMenuInfo[
'profileUsername']);
186 unset ($this->aMenuInfo[
'profileNick']);
187 unset ($this->aMenuInfo[
'profileLink']);
190 foreach ($this->aMenuInfo
as $k => $v)
191 $sItemUri = str_replace(
'{'.$k.
'}', $v, $sItemUri);
193 $sItemUriPermalink = $this->oPermalinks->permalink($sItemUri);
195 if (0 === strcasecmp($sItemUri, $this->sRequestUriFile) || 0 === strcasecmp($sItemUriPermalink, $this->sRequestUriFile) || 0 === strncasecmp(rawurldecode($this->sRequestUriFile), $sItemUri, strlen($sItemUri)) || 0 === strncasecmp($this->sRequestUriFile, $sItemUriPermalink, strlen($sItemUriPermalink))) {
197 if ((isset($aPossibleItems[$sItemUriPermalink]) && $aPossibleItems[$sItemUriPermalink][
'Type'] ==
"custom" && $aItem[
'Type'] ==
"top")
199 (isset($this->aTopMenu[$aItem[
'Parent']]) && !$this->
checkToShow($this->aTopMenu[$aItem[
'Parent']]))
203 $aItem[
'ID'] = $iItemID;
204 $aPossibleItems[$sItemUriPermalink] = $aItem;
209 $aPossibleItemsKeys = array_keys($aPossibleItems);
210 if (!
empty($aPossibleItemsKeys)) {
211 $sMaxUri = $aPossibleItemsKeys[0];
212 for($i=1; $i<count($aPossibleItemsKeys); $i++)
213 if(strlen($aPossibleItemsKeys[$i]) > strlen($sMaxUri))
214 $sMaxUri = $aPossibleItemsKeys[$i];
217 if(count($aPossibleItems) > 0) {
218 $aItem = $aPossibleItems[$sMaxUri];
219 if( $aItem[
'Type'] ==
'custom' ) {
220 $this->aMenuInfo[
'currentCustom'] = $aItem[
'ID'];
221 $this->aMenuInfo[
'currentTop'] = (int)$aItem[
'Parent'];
222 $this->aMenuInfo[
'currentTopName'] = (int)$aItem[
'Parent'];
224 if( $this->aMenuInfo[
'currentTop']
and $this->aMenuInfo[
'currentTop'] != $aItem[
'ID'] ) {
226 $this->aMenuInfo[
'currentTop'] = $aItem[
'ID'];
232 if(!$this->aMenuInfo[
'currentTop']) {
233 $this->aMenuInfo[
'currentCustom'] = -1;
234 $this->aMenuInfo[
'currentTop'] = -1;
235 $this->aMenuInfo[
'currentTopLink'] = -1;
242 foreach( $this->aNotShowSubsFor
as $sExcep )
243 if( $this->sSelfFile == $sExcep )
253 if( !$this->
checkCond( $aItem[
'Check'] ) )
261 return ( strpos( $sVisible, $this->aMenuInfo[
'visible'] ) !==
false );
269 return eval($sCheck);
275 $iTItemID = $this->aMenuInfo[
'currentTop'];
277 foreach( $this->aTopMenu
as $iItemID => $aItem ) {
278 if( $aItem[
'Type'] !=
'custom' )
281 if( $aItem[
'Parent'] != $iTItemID )
288 list( $aItem[
'Link'] ) = explode(
'|', $aItem[
'Link'] );
291 $aItem[
'Onclick'] = $this->
replaceMetas( $aItem[
'Onclick'] );
293 $bActive = ( $iItemID == $this->aMenuInfo[
'currentCustom'] );
295 $this->genSubItem(
_t( $aItem[
'Caption'] ), $aItem[
'Link'], $aItem[
'Target'], $aItem[
'Onclick'], $bActive );
301 $sLink = str_replace(
'{memberPass}',
empty($this->aMenuInfo[
'memberID']) ?
'' :
getPassword( $this->aMenuInfo[
'memberID'] ), $sLink );
303 foreach ($this->aMenuInfo
as $k => $v)
304 $sLink = str_replace(
'{'.$k.
'}', $v, $sLink);
311 $sEval =
"return array(\n";
312 $aFields = array(
'Type',
'Caption',
'Link',
'Visible',
'Target',
'Onclick',
'Check',
'Parent',
'Picture',
'Icon',
'BQuickLink',
'Statistics',
'Name' );
322 ( `Type` = 'system' OR `Type` = 'top' )
323 ORDER BY `Type`,`Order`
326 $rMenu =
db_res( $sQuery );
327 while( $aMenuItem = $rMenu ->fetch() ) {
328 $sEval .=
" " . str_pad( $aMenuItem[
'ID'], 2 ) .
" => array(\n";
331 $sCont = $aMenuItem[$sField];
333 if( $sField ==
'Link' )
344 $sEval .=
" " . str_pad(
"'$sField'", 11 ) .
" => \"$sCont\",\n";
358 `Type` = 'custom' AND
359 `Parent` = {$aMenuItem['ID']}
363 $rCMenu =
db_res( $sQuery );
364 while( $aMenuItem = $rCMenu ->fetch() ) {
365 $sEval .=
" " . str_pad( $aMenuItem[
'ID'], 2 ) .
" => array(\n";
368 $sCont = $aMenuItem[$sField];
370 if( $sField ==
'Link' )
381 $sEval .=
" " . str_pad(
"'$sField'", 11 ) .
" => \"$sCont\",\n";
408 $aCurrLink = explode(
'|',
$sCont);
409 $aCurrLink[0] = $this->oPermalinks->permalink($aCurrLink[0]);
410 $sCont = implode(
'|', $aCurrLink );
426 $this->aCustomBreadcrumbs = $a;