23 parent::__construct($oConfig,
$oDb);
26 $GLOBALS[
'oAdmTemplate']->addDynamicLocation($this->_oConfig->getHomePath(), $this->_oConfig->getHomeUrl());
38 function profileCustomizeBlock($aTopMenu, $sPage, $aTargets, $sTarget,
$aVars)
41 $aMenuItems = array();
42 $sBaseUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri();
46 foreach ($aTopMenu
as $sName => $aItem) {
49 'active' => $aItem[
'active'],
50 'href' => $aItem[
'href'],
51 'onclick' =>
'oChSctrMain.reloadCustomizeBlock(this.href, false); return false;'
58 if ($sPage !=
'themes') {
59 $sTopControls = $this->
parsePageByName(
'designbox_top_controls.html', array(
60 'top_controls' => $this->
parseHtmlByName(
'content_box_top_controls.html', array(
61 'name_box' =>
_t(
'_ch_sctr_select_target'),
62 'name_targets_box' =>
'background_box',
63 'ch_repeat:targets' => $aTargets
68 'ch_if:select_target' => array(
69 'condition' => !
empty($aTargets),
71 'top_controls' => $sTopControls
74 'content' => call_user_func_array(array($this,
'_customPage' . ucfirst($sPage)), array($sPage, $sTarget,
$aVars)),
75 'ch_repeat:buttons' => array(
77 'btn_type' =>
'button',
78 'btn_name' =>
'preview',
79 'btn_value' =>
_t(
'_ch_sctr_btn_preview'),
80 'btn_action' =>
"oChSctrMain.reloadCustom('" . $sPage .
"', '" . $sTarget .
"', 'preview');"
83 'btn_type' =>
'button',
84 'btn_name' =>
'reset',
85 'btn_value' =>
_t(
'_ch_sctr_btn_reset'),
86 'btn_action' =>
"oChSctrMain.resetCustom('" . $sPage .
"', '" . $sTarget .
"', 'reset');"
89 'btn_type' =>
'button',
91 'btn_value' =>
_t(
'_ch_sctr_btn_save'),
92 'btn_action' =>
"oChSctrMain.reloadCustom('" . $sPage .
"', '" . $sTarget .
"', 'save');"
95 'btn_type' =>
'button',
96 'btn_name' =>
'publish',
97 'btn_value' =>
_t(
'_ch_sctr_btn_publish'),
98 'btn_action' =>
"oChSctrMain.showPublish('{$sBaseUrl}publish');"
103 $iUserId = $sTarget ==
'my' ? $this->_oModule->iUserId : 0;
104 $sPageThemes = $this->_customPageThemes($iUserId,
true);
109 'btn_type' =>
'button',
110 'btn_name' =>
'preview',
111 'btn_value' =>
_t(
'_ch_sctr_btn_preview'),
112 'btn_action' =>
"oChSctrMain.previewTheme();"
115 'btn_type' =>
'button',
116 'btn_name' =>
'reset',
117 'btn_value' =>
_t(
'_ch_sctr_btn_reset'),
118 'btn_action' =>
"oChSctrMain.resetCustom('', '', 'reset');"
121 'btn_type' =>
'button',
122 'btn_name' =>
'save',
123 'btn_value' =>
_t(
'_ch_sctr_btn_save'),
124 'btn_action' =>
"oChSctrMain.saveTheme();"
130 if ($sPageThemes && $sTarget !=
'shared')
132 'btn_type' =>
'button',
133 'btn_name' =>
'delete',
134 'btn_value' =>
_t(
'_ch_sctr_btn_delete'),
135 'btn_action' =>
"oChSctrMain.deleteTheme('" . $sBaseUrl .
"deletetheme/');"
139 'btn_type' =>
'button',
140 'btn_name' =>
'reset',
141 'btn_value' =>
_t(
'_ch_sctr_btn_reset_all'),
142 'btn_action' =>
"oChSctrMain.resetAll('{$sBaseUrl}resetall');"
145 $sTopControls = $this->
parsePageByName(
'designbox_top_controls.html', array(
146 'top_controls' => $this->
parseHtmlByName(
'content_box_top_controls.html', array(
147 'name_box' =>
_t(
'_ch_sctr_select_target'),
148 'name_targets_box' =>
'background_box',
149 'ch_repeat:targets' => $aTargets
154 'ch_if:select_target' => array(
155 'condition' => !
empty($aTargets),
157 'top_controls' => $sTopControls
160 'content' => $sPageThemes ? $sPageThemes :
MsgBox(
_t(
'_Empty')),
161 'ch_repeat:buttons' => $aButtons
167 'js_code' => $this->getJsCode(
true),
168 'content' =>
$GLOBALS[
'oFunctions']->transBox(
173 $this->
addCss(array(
'main.css'));
174 $this->
addJs(array(
'colorinput.js',
'main.js'));
178 function getPublishForm($sComplete =
'')
180 $sName =
'site_customize_popup';
185 'text' =>
MsgBox($sComplete),
186 'btn_value' =>
_t(
'_ch_sctr_btn_close'),
191 'form_attrs' => array(
192 'name' =>
'publish_form',
193 'action' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'publish/1',
195 'enctype' =>
'multipart/form-data',
198 'params' => array (),
201 'name_theme' => array(
203 'name' =>
'name_theme',
205 'caption' =>
_t(
'_ch_sctr_name_theme'),
208 'thumbnail' => array(
210 'name' =>
'thumbnail',
212 'caption' =>
_t(
'_ch_sctr_thumbnail'),
217 'name' =>
'submit_form',
218 'value' =>
_t(
'_ch_sctr_btn_save'),
221 'onclick' =>
"oChSctrMain.savePublish();"
228 'content' =>
$oForm->getCode()
258 function getAdminPage(
$sType =
'', $iUnitId =
'')
271 $aItems = array(
'background',
'font',
'border');
272 if (in_array(
$sType, $aItems))
275 $sSelType = $aItems[0];
276 foreach ($aItems
as $sPageType) {
277 $aMenu[$sPageType] = array(
278 'title' =>
_t(
'_ch_sctr_page_' . $sPageType),
279 'href' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration/' . $sPageType,
280 'active' => $sSelType == $sPageType ? 1 : 0
283 $sContent .= $this->adminBlock($this->getAdminBlockUnits($sSelType),
_t(
'_ch_sctr_units'),
$aMenu);
286 $aItems = array(
'themes',
'import');
287 if (in_array(
$sType, $aItems))
290 $sSelType = $aItems[0];
291 foreach ($aItems
as $sPageType) {
292 $aMenu[$sPageType] = array(
293 'title' =>
_t(
'_ch_sctr_page_' . $sPageType),
294 'href' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration/' . $sPageType,
295 'active' => $sSelType == $sPageType ? 1 : 0
301 $sContent .= $this->adminBlock($this->getAdminPageThemes($sSelType),
_t(
'_ch_sctr_page_themes'),
$aMenu);
305 $sContent .= $this->adminBlock($this->getAdminPageImport($sSelType),
_t(
'_ch_sctr_page_import'),
$aMenu);
309 return $this->getJsCode(
true) .
$sContent;
312 function getAdminBlockForm(
$sType =
'', $iUnitId =
'')
314 $aUnit = $iUnitId ? $this->_oDb->getUnitById($iUnitId) : array(
'type' =>
$sType);
319 if (
$oForm->isSubmittedAndValid()) {
320 $iRes = $iUnitId ?
$oForm->update($iUnitId) :
$oForm->insert();
322 header(
'Location:' . CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration/' .
$sType);
325 return $GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'design_box_content.html', array(
'content' =>
$oForm->getCode()));
328 function getAdminBlockUnits(
$sType)
331 if ($_POST[
'action_delete'] && is_array($_POST[
'entry'])) {
332 foreach ($_POST[
'entry']
as $iUnitId)
333 $this->_oDb->deleteUnit($iUnitId);
337 ch_import (
'SearchResult', $oMain->_aModule);
339 $sUnits = $oSearch->displayResultBlock();
341 $sFormName =
'custom_units_form';
342 $aButtons[
'action_delete'] =
'_ch_sctr_btn_delete';
343 $aPageTypes = array();
345 foreach (array(
'background',
'font',
'border')
as $sPageType) {
346 $aPageTypes[] = array(
347 'value' => $sPageType,
348 'caption' =>
_t(
'_ch_sctr_page_' . $sPageType),
349 'selected' =>
$sType == $sPageType ?
'selected="selected"' :
''
354 'form_name' => $sFormName,
355 'action' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration/' .
$sType,
357 'actions_panel' => $oSearch->showAdminActionsPanel($sFormName, $aButtons),
365 function getAdminPageThemes(
$sType)
367 $sPageThemes = $this->_customPageThemes();
369 $sFormName =
'sctr_custom_themes_form';
371 'action_theme_export' =>
'_ch_sctr_btn_export',
372 'action_theme_delete' =>
'_ch_sctr_btn_delete'
376 'form_name' => $sFormName,
377 'action' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration/' .
$sType,
378 'units' => $sPageThemes,
387 function getAdminPageImport(
$sType)
393 return $sResult .
$GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'design_box_content.html', array(
'content' =>
$oForm->getCode()));
396 function getJsCode($bWrap =
false)
398 $sJsMainClass = $this->_oConfig->getJsClass();
399 $sJsMainObject = $this->_oConfig->getJsObject();
402 var <?php echo $sJsMainObject; ?> = new <?php echo $sJsMainClass; ?>({
403 sBaseUrl:
'<?php echo CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri(); ?>',
404 sReset:
'<?php echo ch_js_string(_t('_ch_sctr_js_reset
')); ?>',
405 sErrThemeName:
'<?php echo ch_js_string(_t('_ch_sctr_js_err_theme_name
')); ?>',
406 sErrChooseTheme:
'<?php echo ch_js_string(_t('_ch_sctr_js_err_choose_theme
')); ?>',
407 sDeleteTheme:
'<?php echo ch_js_string(_t('_ch_sctr_js_delete_theme
')); ?>',
408 sResetPage:
'<?php echo ch_js_string(_t('_ch_sctr_js_reset_page
')); ?>'
418 function _getImportForm(
$sType)
421 'form_attrs' => array(
422 'name' =>
'publish_form',
423 'action' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration/' .
$sType,
425 'enctype' =>
'multipart/form-data',
428 'theme_file' => array(
430 'name' =>
'theme_file',
432 'caption' =>
_t(
'_ch_sctr_theme'),
437 'name' =>
'submit_import',
438 'value' =>
_t(
'_ch_sctr_btn_import'),
447 function _getCustomUnitForm(
$aUnit = array())
450 'form_attrs' => array(
451 'name' =>
'unit_form',
452 'action' => $_SERVER[
'REQUEST_URI'],
454 'enctype' =>
'multipart/form-data',
458 'table' => $this->_oDb->getPrefix() .
'units',
460 'submit_name' =>
'submit_save',
469 'caption' =>
_t(
'_ch_sctr_name'),
473 'params' => array(1,100),
474 'error' =>
_t(
'_ch_sctr_form_field_err'),
484 'value' => isset(
$aUnit[
'caption']) ?
$aUnit[
'caption'] :
'',
485 'caption' =>
_t(
'_ch_sctr_caption'),
489 'params' => array(1,100),
490 'error' =>
_t(
'_ch_sctr_form_field_err'),
499 'name' =>
'css_name',
500 'value' => isset(
$aUnit[
'css_name']) ?
$aUnit[
'css_name'] :
'',
501 'caption' =>
_t(
'_ch_sctr_css_name'),
505 'params' => array(1,500),
506 'error' =>
_t(
'_ch_sctr_form_field_err'),
518 'background' =>
_t(
'_ch_sctr_page_background'),
519 'font' =>
_t(
'_ch_sctr_page_font'),
520 'border' =>
_t(
'_ch_sctr_page_border'),
523 'caption' =>
_t(
'_ch_sctr_type'),
525 'multiplyable' =>
false
534 'name' =>
'submit_save',
535 'value' => isset(
$aUnit[
'id']) ?
_t(
'_ch_sctr_btn_save') :
_t(
'_ch_sctr_btn_add'),
544 function _customPageThemes($iUserId = 0, $bForm =
false)
546 $aThemes = $this->_oDb->getAllThemes();
551 foreach ($aThemes
as $aTheme) {
553 if (file_exists($this->_oModule->_getImagesDir() . $sFileName))
554 $sThumb = $this->_oModule->_getImagesPath() . $sFileName;
556 $sThumb = $this->
getIconUrl(
'no-photo-64.png');
559 'id' => $aTheme[
'id'],
560 'name' => $aTheme[
'name'],
561 'thumbnail' => $sThumb,
567 'ch_repeat:items' => $aItems,
568 'save_url' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'savetheme/'
573 'name' =>
'themes_form',
574 'action' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'save',
581 function _customPageBackground($sPage, $sTarget,
$aVars)
584 'form_attrs' => array(
585 'name' =>
'background_form',
586 'action' => $sBaseUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'save',
588 'enctype' =>
'multipart/form-data',
589 'id' =>
'sctr_custom_themes_form',
595 'value' => isset(
$aVars[
'color']) ?
$aVars[
'color'] :
'',
596 'caption' =>
_t(
'_ch_sctr_color'),
601 'name' =>
'useimage',
602 'caption' =>
_t(
'_ch_sctr_use_image'),
608 'value' => isset(
$aVars[
'image']) ?
$aVars[
'image'] :
'',
609 'caption' =>
_t(
'_ch_sctr_image'),
616 'default' =>
_t(
'_ch_sctr_default'),
617 'no-repeat' =>
_t(
'_ch_sctr_no'),
618 'repeat' =>
_t(
'_ch_sctr_repeat'),
619 'repeat-x' =>
_t(
'_ch_sctr_repeat_x'),
620 'repeat-y' =>
_t(
'_ch_sctr_repeat_y'),
622 'value' => isset(
$aVars[
'repeat']) ?
$aVars[
'repeat'] :
'',
623 'caption' =>
_t(
'_ch_sctr_repeat'),
625 'multiplyable' =>
false
631 'name' =>
'position',
633 'default' =>
_t(
'_ch_sctr_default'),
634 'left top' =>
_t(
'_ch_sctr_top_left'),
635 'center top' =>
_t(
'_ch_sctr_top_center'),
636 'right top' =>
_t(
'_ch_sctr_top_right'),
637 'left center' =>
_t(
'_ch_sctr_center_left'),
638 'center center' =>
_t(
'_ch_sctr_center'),
639 'right center' =>
_t(
'_ch_sctr_center_right'),
640 'left bottom' =>
_t(
'_ch_sctr_bottom_left'),
641 'center bottom' =>
_t(
'_ch_sctr_bottom_center'),
642 'right bottom' =>
_t(
'_ch_sctr_bottom_right')
644 'value' => isset(
$aVars[
'position']) ?
$aVars[
'position'] :
'default',
645 'caption' =>
_t(
'_ch_sctr_position'),
647 'multiplyable' =>
false
672 'spacer' => $this->getImageUrl(
'spacer.gif'),
673 'name' =>
'useimage',
674 'checked' => isset(
$aVars[
'useimage']) ?
'checked="1"' :
'',
677 $aForm[
'inputs'][
'image'][
'caption'] =
_t(
'_ch_sctr_other_image');
680 unset(
$aForm[
'inputs'][
'useimage']);
686 function _customPageFont($sPage, $sTarget,
$aVars)
689 'form_attrs' => array(
690 'name' =>
'fonts_form',
691 'action' => $sBaseUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'save',
693 'enctype' =>
'multipart/form-data',
700 -1 =>
_t(
'_ch_sctr_default'),
713 'value' => isset(
$aVars[
'size']) ? (
int)
$aVars[
'size'] : -1,
714 'caption' =>
_t(
'_ch_sctr_size'),
716 'multiplyable' =>
false
723 'value' => isset(
$aVars[
'color']) ?
$aVars[
'color'] :
'',
724 'caption' =>
_t(
'_ch_sctr_color'),
731 'default' =>
_t(
'_ch_sctr_default'),
732 'Arial, Helvetica, sans-serif' =>
'Arial',
733 'comicsans' =>
'Comic Sans',
734 'Courier New, Courier, monospace' =>
'Courier New',
735 'Georgia, lucida grande, Times New Roman, Times, serif' =>
'Georgia',
736 'Tahoma, Verdana, Arial, Helvetica, sans-serif' =>
'Tahoma',
737 'Times New Roman, Times, serif' =>
'Times Roman',
738 'Trebuchet, Trebuchet MS, Helvetica, sans-serif' =>
'Trebuchet',
739 'Verdana, Arial, Helvetica, sans-serif' =>
'Verdana'
742 'caption' =>
_t(
'_ch_sctr_name'),
744 'multiplyable' =>
false
752 'default' =>
_t(
'_ch_sctr_default'),
753 'normal' =>
_t(
'_ch_sctr_normal'),
754 'bold' =>
_t(
'_ch_sctr_bold'),
755 'italic' =>
_t(
'_ch_sctr_italic')
757 'value' => isset(
$aVars[
'style']) ?
$aVars[
'style'] :
'default',
758 'caption' =>
_t(
'_ch_sctr_style'),
760 'multiplyable' =>
false
786 function _customPageBorder($sPage, $sTarget,
$aVars)
789 'form_attrs' => array(
790 'name' =>
'border_form',
791 'action' => $sBaseUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'save',
793 'enctype' =>
'multipart/form-data',
800 -1 =>
_t(
'_ch_sctr_default'),
801 0 =>
_t(
'_ch_sctr_none'),
813 'value' => isset(
$aVars[
'size']) ? (
int)
$aVars[
'size'] : -1,
814 'caption' =>
_t(
'_ch_sctr_size'),
816 'multiplyable' =>
false
823 'value' => isset(
$aVars[
'color']) ?
$aVars[
'color'] :
'',
824 'caption' =>
_t(
'_ch_sctr_color'),
831 'default' =>
_t(
'_ch_sctr_default'),
832 'dotted' =>
_t(
'_ch_sctr_dotted'),
833 'dashed' =>
_t(
'_ch_sctr_dashed'),
834 'solid' =>
_t(
'_ch_sctr_solid'),
835 'double' =>
_t(
'_ch_sctr_double'),
836 'groove' =>
_t(
'_ch_sctr_groove'),
837 'ridge' =>
_t(
'_ch_sctr_ridge'),
838 'inset' =>
_t(
'_ch_sctr_inset'),
839 'outset' =>
_t(
'_ch_sctr_outset'),
841 'value' => isset(
$aVars[
'style']) ?
$aVars[
'style'] :
'default',
842 'caption' =>
_t(
'_ch_sctr_style'),
844 'multiplyable' =>
false
850 'name' =>
'position',
852 'default' =>
_t(
'_ch_sctr_default'),
853 'full' =>
_t(
'_ch_sctr_border_full'),
854 'top' =>
_t(
'_ch_sctr_border_top'),
855 'right' =>
_t(
'_ch_sctr_border_right'),
856 'bottom' =>
_t(
'_ch_sctr_border_bottom'),
857 'left' =>
_t(
'_ch_sctr_border_left'),
858 'left_right' =>
_t(
'_ch_sctr_border_left_right'),
859 'top_bottom' =>
_t(
'_ch_sctr_border_top_bottom'),
860 'top_right' =>
_t(
'_ch_sctr_border_top_right'),
861 'right_bottom' =>
_t(
'_ch_sctr_border_right_bottom'),
862 'bottom_left' =>
_t(
'_ch_sctr_border_bottom_left'),
863 'left_top' =>
_t(
'_ch_sctr_border_left_top'),
865 'value' => isset(
$aVars[
'position']) ?
$aVars[
'position'] :
'default',
866 'caption' =>
_t(
'_ch_sctr_position'),
868 'multiplyable' =>
false