24 parent::__construct($oConfig,
$oDb);
27 $GLOBALS[
'oAdmTemplate']->addDynamicLocation($this->_oConfig->getHomePath(), $this->_oConfig->getHomeUrl());
35 function profileCustomizeBlock($aTopMenu, $sPage, $aTargets, $sTarget,
$aVars)
38 $sBlockName =
'profile_customize';
39 $aMenuItems = array();
40 $sBaseUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri();
44 foreach ($aTopMenu
as $sName => $aItem) {
47 'active' => $aItem[
'active'],
48 'href' => $aItem[
'href'],
49 'onclick' =>
'oCustomizer.reloadCustomizeBlock(this.href, false); return false;'
56 if ($sPage !=
'themes') {
57 $sTopControls = $this->
parsePageByName(
'designbox_top_controls.html', array(
58 'top_controls' => $this->
parseHtmlByName(
'content_box_top_controls.html', array(
59 'name_box' =>
_t(
'_ch_profile_customize_select_target'),
60 'name_targets_box' =>
'background_box',
61 'ch_repeat:targets' => $aTargets
66 'ch_if:select_target' => array(
67 'condition' => !
empty($aTargets),
69 'top_controls' => $sTopControls
72 'content' => call_user_func_array(array($this,
'_customPage' . ucfirst($sPage)), array($sPage, $sTarget,
$aVars)),
73 'ch_repeat:buttons' => array(
75 'btn_type' =>
'button',
77 'btn_value' =>
_t(
'_ch_profile_customize_btn_save'),
78 'btn_action' =>
"oCustomizer.reloadCustom('" . $sBaseUrl .
"customizepage/" . $sPage .
'/' . $sTarget .
"', '" . $sBaseUrl .
"profileblock/save');"
81 'btn_type' =>
'button',
82 'btn_name' =>
'reset',
83 'btn_value' =>
_t(
'_ch_profile_customize_btn_reset'),
84 'btn_action' =>
"oCustomizer.resetCustom('" . $sBaseUrl .
"customizepage/" . $sPage .
'/' . $sTarget .
"', '" . $sBaseUrl .
"profileblock/preview');"
87 'btn_type' =>
'button',
88 'btn_name' =>
'preview',
89 'btn_value' =>
_t(
'_ch_profile_customize_btn_preview'),
90 'btn_action' =>
"oCustomizer.reloadCustom('" . $sBaseUrl .
"customizepage/" . $sPage .
'/' . $sTarget .
"', '" . $sBaseUrl .
"profileblock/preview');"
93 'btn_type' =>
'button',
94 'btn_name' =>
'publish',
95 'btn_value' =>
_t(
'_ch_profile_customize_btn_publish'),
96 'btn_action' =>
"oCustomizer.showPublish('{$sBaseUrl}publish');"
101 $iUserId = $sTarget ==
'my' ? $this->_oModule->iUserId : 0;
102 $sPageThemes = $this->_customPageThemes($iUserId,
true);
107 'btn_type' =>
'button',
108 'btn_name' =>
'save',
109 'btn_value' =>
_t(
'_ch_profile_customize_btn_save'),
110 'btn_action' =>
"oCustomizer.saveTheme();"
113 'btn_type' =>
'button',
114 'btn_name' =>
'preview',
115 'btn_value' =>
_t(
'_ch_profile_customize_btn_preview'),
116 'btn_action' =>
"oCustomizer.previewTheme();"
122 if ($sPageThemes && $sTarget !=
'shared')
124 'btn_type' =>
'button',
125 'btn_name' =>
'delete',
126 'btn_value' =>
_t(
'_ch_profile_customize_btn_delete'),
127 'btn_action' =>
"oCustomizer.deleteTheme('" . $sBaseUrl .
"deletetheme/');"
131 'btn_type' =>
'button',
132 'btn_name' =>
'reset',
133 'btn_value' =>
_t(
'_ch_profile_customize_btn_reset_all'),
134 'btn_action' =>
"oCustomizer.resetAll('{$sBaseUrl}resetall');"
137 $sTopControls = $this->
parsePageByName(
'designbox_top_controls.html', array(
138 'top_controls' => $this->
parseHtmlByName(
'content_box_top_controls.html', array(
139 'name_box' =>
_t(
'_ch_profile_customize_select_target'),
140 'name_targets_box' =>
'background_box',
141 'ch_repeat:targets' => $aTargets
146 'ch_if:select_target' => array(
147 'condition' => !
empty($aTargets),
149 'top_controls' => $sTopControls
152 'content' => $sPageThemes ? $sPageThemes :
MsgBox(
_t(
'_Empty')),
153 'ch_repeat:buttons' => $aButtons
159 'js_code' => $this->getJsCode(
true),
160 'name' => $sBlockName,
161 'content' =>
$GLOBALS[
'oFunctions']->transBox(
166 $this->
addCss(array(
'main.css'));
167 $this->
addJs(array(
'colorinput.js',
'main.js'));
171 function profilePage($iUserId, $sCss)
184 'page_main_css' => $sCss,
185 'page_main_code' =>
$oPPV->getCode()
189 function getPublishForm($sComplete =
'')
196 'text' =>
MsgBox($sComplete),
197 'btn_value' =>
_t(
'_ch_profile_customize_btn_close'),
202 'form_attrs' => array(
203 'name' =>
'publish_form',
204 'action' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'publish/1',
206 'enctype' =>
'multipart/form-data',
209 'params' => array (),
212 'name_theme' => array(
214 'name' =>
'name_theme',
216 'caption' =>
_t(
'_ch_profile_customize_name_theme'),
219 'thumbnail' => array(
221 'name' =>
'thumbnail',
223 'caption' =>
_t(
'_ch_profile_customize_thumbnail'),
226 'destination' => array(
227 'type' =>
'radio_set',
228 'name' =>
'destination',
229 'caption' =>
_t(
'_ch_profile_customize_destination'),
230 'value' => $this->_oModule->iUserId,
232 $this->_oModule->iUserId =>
_t(
'_ch_profile_customize_page_themes_my'),
233 0 =>
_t(
'_ch_profile_customize_page_themes_shared')
238 'name' =>
'submit_form',
239 'value' =>
_t(
'_ch_profile_customize_btn_save'),
242 'onclick' =>
"oCustomizer.savePublish();"
248 if(!$this->_oModule->isAdmin())
249 unset(
$aForm[
'inputs'][
'destination']);
253 'content' =>
$oForm->getCode()
285 function getAdminPage(
$sType =
'', $iUnitId =
'')
298 $aItems = array(
'background',
'font',
'border');
299 if (in_array(
$sType, $aItems))
302 $sSelType = $aItems[0];
303 foreach ($aItems
as $sPageType) {
304 $aMenu[$sPageType] = array(
305 'title' =>
_t(
'_ch_profile_customize_page_' . $sPageType),
306 'href' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration/' . $sPageType,
307 'active' => $sSelType == $sPageType ? 1 : 0
310 $sContent .= $this->adminBlock($this->getAdminBlockUnits($sSelType),
_t(
'_ch_profile_customize_units'),
$aMenu);
313 $aItems = array(
'themes',
'import');
314 if (in_array(
$sType, $aItems))
317 $sSelType = $aItems[0];
318 foreach ($aItems
as $sPageType) {
319 $aMenu[$sPageType] = array(
320 'title' =>
_t(
'_ch_profile_customize_page_' . $sPageType),
321 'href' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration/' . $sPageType,
322 'active' => $sSelType == $sPageType ? 1 : 0
328 $sContent .= $this->adminBlock($this->getAdminPageThemes($sSelType),
_t(
'_ch_profile_customize_page_themes'),
$aMenu);
332 $sContent .= $this->adminBlock($this->getAdminPageImport($sSelType),
_t(
'_ch_profile_customize_page_import'),
$aMenu);
336 return $this->getJsCode(
true) .
$sContent;
339 function getAdminBlockForm(
$sType =
'', $iUnitId =
'')
342 $aUnit = $this->_oDb->getUnitById($iUnitId);
351 if (
$oForm->isSubmittedAndValid()) {
353 $iRes =
$oForm->update($iUnitId);
358 header(
'Location:' . CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration/' .
$sType);
361 return $GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'design_box_content.html', array(
'content' =>
$oForm->getCode()));
364 function getAdminBlockUnits(
$sType)
367 if ($_POST[
'action_delete'] && is_array($_POST[
'entry'])) {
368 foreach ($_POST[
'entry']
as $iUnitId)
369 $this->_oDb->deleteUnit($iUnitId);
373 ch_import (
'SearchResult', $oMain->_aModule);
375 $sUnits = $oSearch->displayResultBlock();
377 $sFormName =
'custom_units_form';
378 $aButtons[
'action_delete'] =
'_ch_profile_customize_btn_delete';
379 $aPageTypes = array();
381 foreach (array(
'background',
'font',
'border')
as $sPageType) {
382 $aPageTypes[] = array(
383 'value' => $sPageType,
384 'caption' =>
_t(
'_ch_profile_customize_page_' . $sPageType),
385 'selected' =>
$sType == $sPageType ?
'selected="selected"' :
''
390 'form_name' => $sFormName,
391 'action' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration/' .
$sType,
393 'actions_panel' => $oSearch->showAdminActionsPanel($sFormName, $aButtons),
401 function getAdminPageThemes(
$sType)
403 $sPageThemes = $this->_customPageThemes();
405 $sFormName =
'custom_themes_form';
407 'action_theme_export' =>
'_ch_profile_customize_btn_export',
408 'action_theme_delete' =>
'_ch_profile_customize_btn_delete'
412 'form_name' => $sFormName,
413 'action' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration/' .
$sType,
414 'units' => $sPageThemes,
423 function getAdminPageImport(
$sType)
429 return $sResult .
$GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'design_box_content.html', array(
'content' =>
$oForm->getCode()));
432 function getJsCode($bWrap =
false)
434 $sJsMainClass = $this->_oConfig->getJsClass();
435 $sJsMainObject = $this->_oConfig->getJsObject();
438 var <?php echo $sJsMainObject; ?> = new <?php echo $sJsMainClass; ?>({
439 sReset:
'<?php echo ch_js_string(_t('_ch_profile_customize_js_reset
')); ?>',
440 sErrThemeName:
'<?php echo ch_js_string(_t('_ch_profile_customize_js_err_theme_name
')); ?>',
441 sErrChooseTheme:
'<?php echo ch_js_string(_t('_ch_profile_customize_js_err_choose_theme
')); ?>',
442 sDeleteTheme:
'<?php echo ch_js_string(_t('_ch_profile_customize_js_delete_theme
')); ?>',
443 sResetPage:
'<?php echo ch_js_string(_t('_ch_profile_customize_js_reset_page
')); ?>'
454 function _getImportForm(
$sType)
458 'form_attrs' => array(
459 'name' =>
'publish_form',
460 'action' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration/' .
$sType,
462 'enctype' =>
'multipart/form-data',
466 'theme_file' => array(
468 'name' =>
'theme_file',
470 'caption' =>
_t(
'_ch_profile_customize_theme'),
475 'name' =>
'submit_import',
476 'value' =>
_t(
'_ch_profile_customize_btn_import'),
483 function _getCustomUnitForm(
$aUnit = array())
487 'form_attrs' => array(
488 'name' =>
'unit_form',
489 'action' => $_SERVER[
'REQUEST_URI'],
491 'enctype' =>
'multipart/form-data',
496 'table' =>
'ch_profile_custom_units',
498 'submit_name' =>
'submit_save',
508 'caption' =>
_t(
'_ch_profile_customize_name'),
512 'params' => array(1,100),
513 'error' =>
_t(
'_ch_profile_customize_form_field_err'),
523 'value' => isset(
$aUnit[
'caption']) ?
$aUnit[
'caption'] :
'',
524 'caption' =>
_t(
'_ch_profile_customize_caption'),
528 'params' => array(1,100),
529 'error' =>
_t(
'_ch_profile_customize_form_field_err'),
538 'name' =>
'css_name',
539 'value' => isset(
$aUnit[
'css_name']) ?
$aUnit[
'css_name'] :
'',
540 'caption' =>
_t(
'_ch_profile_customize_css_name'),
544 'params' => array(1,500),
545 'error' =>
_t(
'_ch_profile_customize_form_field_err'),
557 'background' =>
_t(
'_ch_profile_customize_page_background'),
558 'font' =>
_t(
'_ch_profile_customize_page_font'),
559 'border' =>
_t(
'_ch_profile_customize_page_border'),
562 'caption' =>
_t(
'_ch_profile_customize_type'),
564 'multiplyable' =>
false
573 'name' =>
'submit_save',
574 'value' => isset(
$aUnit[
'id']) ?
_t(
'_ch_profile_customize_btn_save') :
_t(
'_ch_profile_customize_btn_add'),
583 function _customPageThemes($iUserId = 0, $bForm =
false)
586 $aThemes = $this->_oDb->getAllThemesByUserId($iUserId);
590 foreach ($aThemes
as $aTheme) {
592 if (file_exists($this->_oModule->_getImagesDir() . $sFileName))
593 $sThumb = $this->_oModule->_getImagesPath() . $sFileName;
595 $sThumb = $this->
getIconUrl(
'no-photo-64.png');
598 'id' => $aTheme[
'id'],
599 'name' => $aTheme[
'name'],
600 'thumbnail' => $sThumb,
606 'ch_repeat:items' => $aItems,
607 'preview_url' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'profileblock/theme/',
608 'save_url' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'savetheme/'
613 'name' =>
'themes_form',
620 function _customPageBackground($sPage, $sTarget,
$aVars)
624 'form_attrs' => array(
625 'name' =>
'background_form',
626 'action' => $sBaseUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'save',
628 'enctype' =>
'multipart/form-data',
629 'id' =>
'custom_themes_form',
632 'params' => array (),
639 'value' => isset(
$aVars[
'color']) ?
$aVars[
'color'] :
'',
640 'caption' =>
_t(
'_ch_profile_customize_color'),
645 'name' =>
'useimage',
646 'caption' =>
_t(
'_ch_profile_customize_use_image'),
652 'value' => isset(
$aVars[
'image']) ?
$aVars[
'image'] :
'',
653 'caption' =>
_t(
'_ch_profile_customize_image'),
660 'default' =>
_t(
'_ch_profile_customize_default'),
661 'no-repeat' =>
_t(
'_ch_profile_customize_no'),
662 'repeat' =>
_t(
'_ch_profile_customize_repeat'),
663 'repeat-x' =>
_t(
'_ch_profile_customize_repeat_x'),
664 'repeat-y' =>
_t(
'_ch_profile_customize_repeat_y'),
666 'value' => isset(
$aVars[
'repeat']) ?
$aVars[
'repeat'] :
'',
667 'caption' =>
_t(
'_ch_profile_customize_repeat'),
669 'multiplyable' =>
false
675 'name' =>
'position',
677 'default' =>
_t(
'_ch_profile_customize_default'),
678 'left top' =>
_t(
'_ch_profile_customize_top_left'),
679 'center top' =>
_t(
'_ch_profile_customize_top_center'),
680 'right top' =>
_t(
'_ch_profile_customize_top_right'),
681 'left center' =>
_t(
'_ch_profile_customize_center_left'),
682 'center center' =>
_t(
'_ch_profile_customize_center'),
683 'right center' =>
_t(
'_ch_profile_customize_center_right'),
684 'left bottom' =>
_t(
'_ch_profile_customize_bottom_left'),
685 'center bottom' =>
_t(
'_ch_profile_customize_bottom_center'),
686 'right bottom' =>
_t(
'_ch_profile_customize_bottom_right')
688 'value' => isset(
$aVars[
'position']) ?
$aVars[
'position'] :
'default',
689 'caption' =>
_t(
'_ch_profile_customize_position'),
691 'multiplyable' =>
false
708 if (isset(
$aVars[
'image']) &&
713 'spacer' => $this->getImageUrl(
'spacer.gif'),
714 'name' =>
'useimage',
715 'checked' => isset(
$aVars[
'useimage']) ?
'checked="1"' :
'',
718 $aForm[
'inputs'][
'image'][
'caption'] =
_t(
'_ch_profile_customize_other_image');
720 unset(
$aForm[
'inputs'][
'useimage']);
727 function _customPageFont($sPage, $sTarget,
$aVars)
731 'form_attrs' => array(
732 'name' =>
'fonts_form',
733 'action' => $sBaseUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'save',
735 'enctype' =>
'multipart/form-data',
738 'params' => array (),
745 -1 =>
_t(
'_ch_profile_customize_default'),
758 'value' => isset(
$aVars[
'size']) ? (
int)
$aVars[
'size'] : -1,
759 'caption' =>
_t(
'_ch_profile_customize_size'),
761 'multiplyable' =>
false
768 'value' => isset(
$aVars[
'color']) ?
$aVars[
'color'] :
'',
769 'caption' =>
_t(
'_ch_profile_customize_color'),
776 'inherit' =>
_t(
'_ch_profile_customize_default'),
777 'Arial, Helvetica, sans-serif' =>
'Arial',
778 'comicsans' =>
'Comic Sans',
779 'Courier New, Courier, monospace' =>
'Courier New',
780 'Georgia, lucida grande, Times New Roman, Times, serif' =>
'Georgia',
781 'Tahoma, Verdana, Arial, Helvetica, sans-serif' =>
'Tahoma',
782 'Times New Roman, Times, serif' =>
'Times Roman',
783 'Trebuchet, Trebuchet MS, Helvetica, sans-serif' =>
'Trebuchet',
784 'Verdana, Arial, Helvetica, sans-serif' =>
'Verdana'
787 'caption' =>
_t(
'_ch_profile_customize_name'),
789 'multiplyable' =>
false
797 'default' =>
_t(
'_ch_profile_customize_default'),
798 'normal' =>
_t(
'_ch_profile_customize_normal'),
799 'bold' =>
_t(
'_ch_profile_customize_bold'),
800 'italic' =>
_t(
'_ch_profile_customize_italic')
802 'value' => isset(
$aVars[
'style']) ?
$aVars[
'style'] :
'default',
803 'caption' =>
_t(
'_ch_profile_customize_style'),
805 'multiplyable' =>
false
825 function _customPageBorder($sPage, $sTarget,
$aVars)
829 'form_attrs' => array(
830 'name' =>
'border_form',
831 'action' => $sBaseUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'save',
833 'enctype' =>
'multipart/form-data',
836 'params' => array (),
844 -1 =>
_t(
'_ch_profile_customize_default'),
845 0 =>
_t(
'_ch_profile_customize_none'),
857 'value' => isset(
$aVars[
'size']) ? (
int)
$aVars[
'size'] : -1,
858 'caption' =>
_t(
'_ch_profile_customize_size'),
860 'multiplyable' =>
false
867 'value' => isset(
$aVars[
'color']) ?
$aVars[
'color'] :
'',
868 'caption' =>
_t(
'_ch_profile_customize_color'),
875 'default' =>
_t(
'_ch_profile_customize_default'),
876 'dotted' =>
_t(
'_ch_profile_customize_dotted'),
877 'dashed' =>
_t(
'_ch_profile_customize_dashed'),
878 'solid' =>
_t(
'_ch_profile_customize_solid'),
879 'double' =>
_t(
'_ch_profile_customize_double'),
880 'groove' =>
_t(
'_ch_profile_customize_groove'),
881 'ridge' =>
_t(
'_ch_profile_customize_ridge'),
882 'inset' =>
_t(
'_ch_profile_customize_inset'),
883 'outset' =>
_t(
'_ch_profile_customize_outset'),
885 'value' => isset(
$aVars[
'style']) ?
$aVars[
'style'] :
'default',
886 'caption' =>
_t(
'_ch_profile_customize_style'),
888 'multiplyable' =>
false
894 'name' =>
'position',
896 'default' =>
_t(
'_ch_profile_customize_default'),
897 'full' =>
_t(
'_ch_profile_customize_border_full'),
898 'top' =>
_t(
'_ch_profile_customize_border_top'),
899 'right' =>
_t(
'_ch_profile_customize_border_right'),
900 'bottom' =>
_t(
'_ch_profile_customize_border_bottom'),
901 'left' =>
_t(
'_ch_profile_customize_border_left'),
902 'left_right' =>
_t(
'_ch_profile_customize_border_left_right'),
903 'top_bottom' =>
_t(
'_ch_profile_customize_border_top_bottom'),
904 'top_right' =>
_t(
'_ch_profile_customize_border_top_right'),
905 'right_bottom' =>
_t(
'_ch_profile_customize_border_right_bottom'),
906 'bottom_left' =>
_t(
'_ch_profile_customize_border_bottom_left'),
907 'left_top' =>
_t(
'_ch_profile_customize_border_left_top'),
909 'value' => isset(
$aVars[
'position']) ?
$aVars[
'position'] :
'default',
910 'caption' =>
_t(
'_ch_profile_customize_position'),
912 'multiplyable' =>
false