Go to the documentation of this file.
12 define (
'CH_SECURITY_EXCEPTIONS',
true);
17 require_once(
'../inc/header.inc.php' );
18 require_once( CH_DIRECTORY_PATH_INC .
'profiles.inc.php' );
19 require_once( CH_DIRECTORY_PATH_INC .
'design.inc.php' );
20 require_once( CH_DIRECTORY_PATH_INC .
'admin_design.inc.php' );
21 require_once( CH_DIRECTORY_PATH_INC .
'utils.inc.php' );
22 require_once( CH_DIRECTORY_PATH_INC .
'languages.inc.php' );
28 $GLOBALS[
'oAdmTemplate']->addJsTranslation(array(
29 '_adm_mbuilder_Sorry_could_not_insert_object',
30 '_adm_mbuilder_This_items_are_non_editable'
35 if(
ch_get(
'action') !==
false) {
40 header(
'Content-Type: text/html; charset=utf-8');
42 $aItem =
db_assoc_arr(
"SELECT * FROM `sys_menu_top` WHERE `ID` = '{$id}'", 0 );
52 case 'deactivate_item':
53 $res =
db_res(
"UPDATE `sys_menu_top` SET `Active`=0 WHERE `ID`=" . (
int)
ch_get(
'id'));
58 $id = (int)$_POST[
'id'];
60 $aResult = array(
'code' => 1,
'message' =>
_t(
'_Error occured'));
62 $aItemFields = array(
'Name',
'Caption',
'Link',
'Picture',
'Icon');
64 foreach( $aItemFields
as $field )
65 $aItem[$field] = $_POST[$field];
68 if( (
int)$_POST[
'Visible_non'] )
70 if( (
int)$_POST[
'Visible_memb'] )
73 $aItem[
'Visible'] = implode(
',', $aVis );
74 $aItem[
'BQuickLink'] = (int)$_POST[
'BInQuickLink'] ?
'1' :
'0';
75 $aItem[
'Target'] = $_POST[
'Target'] ==
'_blank' ?
'_blank' :
'';
85 $id = (int)$_POST[
'id'];
87 echo
_t(
'_adm_mbuilder_Item_ID_not_specified');
91 $aItem =
db_arr(
"SELECT `Deletable` FROM `sys_menu_top` WHERE `ID` = '{$id}'" );
93 echo
_t(
'_adm_mbuilder_Item_not_found');
97 if( !(
int)$aItem[
'Deletable'] ) {
98 echo
_t(
'_adm_mbuilder_Item_is_non_deletable');
102 $res =
db_res(
"DELETE FROM `sys_menu_top` WHERE `ID` = $id" );
106 echo
_t(
'_adm_mbuilder_Could_not_delete_the_item');
116 $sTopQuery =
"SELECT `ID`, `Name`, `Movable` FROM `sys_menu_top` WHERE `Active`=1 AND `Type`='top' ORDER BY `Order`";
119 $sSysQuery =
"SELECT `ID`, `Name`, `Movable` FROM `sys_menu_top` WHERE `Active`=1 AND `Type`='system' ORDER BY `Order`";
122 $sAllQuery =
"SELECT `ID`, `Name` FROM `sys_menu_top` WHERE `Type`!='system' AND (`Clonable`='1' OR (`Clonable`='0' AND `Active`='0')) ORDER BY `Name`";
128 <script type=\"text/javascript\">
130 topParentID = 'menu_app_wrapper';
131 parserUrl = '" .
$GLOBALS[
'site'][
'url_admin'] .
"nav_menu_compose.php?';
134 allowAddToTop = true;
135 allowAddToCustom = true;
137 sendSystemOrder = false;
140 aCoords['startX'] = 6;
141 aCoords['startY'] = 24;
142 aCoords['width'] = 117;
143 aCoords['height'] = 28;
144 aCoords['diffX'] = 122;
145 aCoords['diffY'] = 32;
154 while(($aTopItem =
$rTopItems->fetch()) !==
false) {
158 aCustomItems[$iIndex] = {};";
159 $sQuery =
"SELECT `ID`, `Name`, `Movable` FROM `sys_menu_top` WHERE `Active`=1 AND `Type`='custom' AND `Parent`={$aTopItem['ID']} ORDER BY `Order`";
162 $rCustomItems =
db_res( $sQuery );
163 while(($aCustomItem = $rCustomItems->fetch()) !==
false) {
165 aCustomItems[$iIndex][" . ($iSubIndex++) .
"] = [{$aCustomItem['ID']}, '" .
ch_js_string( $aCustomItem[
'Name'],
CH_ESCAPE_STR_APOS ) .
"', " . $aCustomItem[
'Movable'] .
"];";
171 while(($aSystemItem =
$rSysItems->fetch()) !==
false) {
174 aSystemItems[$iIndex] = [{$aSystemItem['ID']}, '" .
ch_js_string( $aSystemItem[
'Name'],
CH_ESCAPE_STR_APOS ) .
"', " . $aSystemItem[
'Movable'] .
"];
175 aCustomItems[$iIndex] = {};";
176 $sQuery =
"SELECT `ID`, `Name`, `Movable` FROM `sys_menu_top` WHERE `Active`=1 AND `Type`='custom' AND `Parent`={$aSystemItem['ID']} ORDER BY `Order`";
179 $rCustomItems =
db_res( $sQuery );
180 while(($aCustomItem = $rCustomItems->fetch()) !==
false) {
182 aCustomItems[$iIndex][" . ($iSubIndex++) .
"] = [{$aCustomItem['ID']}, '" .
ch_js_string( $aCustomItem[
'Name'],
CH_ESCAPE_STR_APOS ) .
"', " . $aCustomItem[
'Movable'] .
"];";
189 while(($aAllItem =
$rAllItems->fetch()) !==
false) {
200 'css_name' => array(
'menu_compose.css',
'forms_adv.css'),
201 'js_name' => array(
'menu_compose.js',
'ChWsbMenu.js'),
202 'header' =>
_t(
'_adm_mbuilder_title')
218 'form_attrs' => array(
219 'id' =>
'formItemEdit',
220 'name' =>
'formItemEdit',
221 'action' =>
$GLOBALS[
'site'][
'url_admin'] .
'nav_menu_compose.php',
223 'enctype' =>
'multipart/form-data',
229 'caption' =>
_t(
'_adm_mbuilder_System_Name'),
230 'value' => $aItem[
'Name'],
236 'caption' =>
_t(
'_adm_mbuilder_Language_Key'),
237 'value' => $aItem[
'Caption'],
240 'LangCaption' => array(
242 'name' =>
'LangCaption',
243 'caption' =>
_t(
'_adm_mbuilder_Default_Name'),
244 'value' =>
_t( $aItem[
'Caption'] ),
250 'caption' =>
_t(
'_URL'),
251 'value' => $aItem[
'Link'],
257 'caption' =>
_t(
'_Picture'),
258 'value' => $aItem[
'Picture'],
264 'caption' =>
_t(
'_adm_mbuilder_icon'),
265 'value' => $aItem[
'Icon'],
268 'BInQuickLink' => array(
269 'type' =>
'checkbox',
270 'name' =>
'BInQuickLink',
271 'caption' =>
_t(
'_adm_mbuilder_Quick_Link'),
273 'checked' => $aItem[
'BQuickLink'] != 0,
277 'type' =>
'radio_set',
279 'caption' =>
_t(
'_adm_mbuilder_Target_Window'),
280 'value' => $aItem[
'Target'] ==
'_blank' ?
'_blank' :
'_self',
282 '_self' =>
_t(
'_adm_mbuilder_Same'),
283 '_blank' =>
_t(
'_adm_mbuilder_New')
288 'type' =>
'checkbox_set',
290 'caption' =>
_t(
'_adm_mbuilder_Visible_for'),
293 'non' =>
_t(
'_Guest'),
294 'memb' =>
_t(
'_Member')
299 'type' =>
'input_set',
303 'value' =>
_t(
'_Save Changes'),
305 'onclick' =>
'javascript:saveItem(' . $aItem[
'ID'] .
');'
311 'value' =>
_t(
'_Delete'),
313 'onclick' =>
'javascript:deleteItem(' . $aItem[
'ID'] .
');'
320 foreach(
$aForm[
'inputs']
as $sKey => $aInput)
321 if(in_array($aInput[
'type'], array(
'text',
'checkbox')) && !$aItem[
'Editable'])
322 $aForm[
'inputs'][$sKey][
'attrs'][
'disabled'] =
"disabled";
324 if(strpos($aItem[
'Visible'],
'non') !==
false)
325 $aForm[
'inputs'][
'Visible'][
'value'][] =
'non';
326 if(strpos($aItem[
'Visible'],
'memb') !==
false)
327 $aForm[
'inputs'][
'Visible'][
'value'][] =
'memb';
330 return PopupBox(
'tmc_edit_popup',
_t(
'_adm_mbuilder_edit_item'),
$GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'design_box_content.html', array(
'content' =>
$oForm->getCode() .
LoadingBox(
'formItemEditLoading'))));
338 $sourceActive =
db_value(
"SELECT `Active` FROM `sys_menu_top` WHERE `ID`='{$source}'" );
339 if( !$sourceActive ) {
341 db_res(
"UPDATE `sys_menu_top` SET `Active`=1, `Type`='{$type}' WHERE `ID`='{$source}'" );
345 db_res(
"INSERT INTO `sys_menu_top`
346 (`Name`, `Caption`, `Link`, `Visible`, `Target`, `Onclick`, `Check`, `Movable`, `Clonable`, `Editable`, `Deletable`, `Type`, `Picture`, `Icon`, `BQuickLink`, `Statistics`)
348 `Name`, `Caption`, `Link`, `Visible`, `Target`, `Onclick`, `Check`, `Movable`, '0', `Editable`, '1', '{$type}', `Picture`, `Icon`, `BQuickLink`, `Statistics`
350 WHERE `ID`='{$source}'" );
355 db_res(
"INSERT INTO `sys_menu_top` ( `Name`, `Type` ) VALUES ( 'NEW ITEM', '{$type}' )" );
366 <div onclick=
"hideEditForm();" style=
"color:{$color};text-align:center;">{$text}</div>
367 <script
type=
"text/javascript">setTimeout(
'hideEditForm();', 1000 )</script>
375 $sSavedC =
_t(
'_Saved');
376 $sItemNotFoundC =
_t(
'_adm_mbuilder_Item_not_found');
377 $sItemNonEditableC =
_t(
'_adm_mbuilder_Item_is_non_editable');
379 $aOldItem =
db_arr(
"SELECT * FROM `sys_menu_top` WHERE `ID`='{$id}'" );
382 return array(
'code' => 2,
'message' => $sItemNotFoundC);
384 if((
int)$aOldItem[
'Editable'] != 1)
385 return array(
'code' => 3,
'message' => $sItemNonEditableC);
388 foreach( $aItem
as $field => $value )
391 $sQuerySet = substr( $sQuerySet, 1 );
393 $sQuery =
"UPDATE `sys_menu_top` SET {$sQuerySet} WHERE `ID` = '{$id}'";
398 return array(
'code' => 0,
'message' => $sSavedC,
'timer' => 3);
406 $langName =
getParam(
'lang_default' );
407 $langID =
db_value(
"SELECT `ID` FROM `sys_localization_languages` WHERE `Name` = '" .
process_db_input( $langName ) .
"'" );
411 db_res(
"UPDATE `sys_localization_strings` SET `String` = '" .
process_db_input( $string ) .
"' WHERE `IDKey`='{$keyID}' AND `IDLanguage`='{$langID}'" );
413 db_res(
"INSERT INTO `sys_localization_keys` SET `IDCategory` = 2, `Key` = '" .
process_db_input( $key ) .
"'" );
414 db_res(
"INSERT INTO `sys_localization_strings` SET `IDKey` = " .
db_last_id() .
", `IDLanguage` = '{$langID}', `String` = '" .
process_db_input( $string ) .
"'" );
424 db_res(
"UPDATE `sys_menu_top` SET `Order` = 0, `Parent` = 0" );
426 $sTop = trim( $sTop,
' ,' );
427 $aTopIDs = explode(
',', $sTop );
428 foreach( $aTopIDs
as $iOrd => $iID ) {
429 $iID = trim( $iID,
' ,' );
435 db_res(
"UPDATE `sys_menu_top` SET `Order` = '{$iOrd}', `Type` = 'top' WHERE `ID` = '{$iID}'" );
438 foreach( $aCustom
as $iParent => $sCustom ) {
439 $iParent = (int)$iParent;
440 $sCustom = trim( $sCustom,
' ,' );
441 $aCustomIDs = explode(
',', $sCustom );
442 foreach( $aCustomIDs
as $iOrd => $iID ) {
443 $iID = trim( $iID,
' ,' );
449 db_res(
"UPDATE `sys_menu_top` SET `Order` = '{$iOrd}', `Type` = 'custom', `Parent`='{$iParent}' WHERE `ID` = '{$iID}'" );
process_db_input($sText, $iStripTags=0)
</code > Be careful enabling this directive if you have a redirector script that does not use the< code > Location</code > HTTP header
db_assoc_arr($query, $bindings=[])
MsgBox($sText, $iTimer=0)
ch_js_string($mixedInput, $iQuoteType=CH_ESCAPE_STR_AUTO)
compileLanguage($langID=0)
ch_import($sClassName, $aModule=array())
DesignBoxAdmin($sTitle, $sContent, $mixedTopItems='', $sBottomItems='', $iIndex=1)
db_arr($query, $bindings=[])
getParam($sParamName, $bUseCache=true)
if(!defined("USER_STATUS_TYPE")) define("USER_STATUS_TYPE" type
PageCodeAdmin($oTemplate=null)
_t($key, $arg0="", $arg1="", $arg2="")
member_auth($member=0, $error_handle=true, $bAjx=false)
db_affected_rows($oStmt=null)
const CH_ESCAPE_STR_APOS
escape apostrophes only, for js strings enclosed in apostrophes, for use in
db_res($query, $bindings=[])
PopupBox($sName, $sTitle, $sContent, $aActions=array())
db_value($query, $bindings=[], $error_checking=true, $index=0)