Cheetah
ChSctrModule.php
Go to the documentation of this file.
1 <?php
2 
8 require_once(CH_DIRECTORY_PATH_PLUGINS . 'myadmin/zip.lib.php');
9 require_once(CH_DIRECTORY_PATH_PLUGINS . 'myadmin/unzip.lib.php');
10 
11 ch_import('ChWsbModule');
12 
13 define('CH_SCTR_DIR_IMAGES', 'data/images/');
14 define('CH_SCTR_SMALL_PREFIX', 's_');
15 define('CH_SCTR_THEME_PREFIX', 't_');
16 define('CH_SCTR_THUMB_EXT', '.jpg');
17 define('CH_SCTR_THEME_CONF', 'conf.php');
18 define('CH_SCTR_THEME_THUMB', 'thumb.jpg');
19 define('CH_SCTR_IMAGES_DELETE', 0);
20 define('CH_SCTR_IMAGES_COPY', 1);
21 
22 function ch_sctr_import($sClassPostfix, $aModuleOverwright = array())
23 {
25  $a = $aModuleOverwright ? $aModuleOverwright : $aModule;
26  if (!$a || $a['uri'] != 'site_customize') {
27  $oMain = ChWsbModule::getInstance('ChSctrModule');
28  $a = $oMain->_aModule;
29  }
30  ch_import ($sClassPostfix, $a) ;
31 }
32 
63 {
64  var $iUserId;
66 
71  {
72  parent::__construct($aModule);
73  $this->iUserId = isLogged() && isAdmin() ? getLoggedId() : 0;
74 
75  $this->_oConfig->init($this->_oDb);
76  $this->_oTemplate->initialize($this, $this->_oDb);
77 
78  $this->_aCssMatch = $this->_oDb->getUnits();
79  }
80 
81  function actionCustomizePage($sPage = '', $sTarget = '')
82  {
83  $this->_oConfig->cancelSession();
84 
85  header('Content-Type: text/html; charset=utf-8');
86  echo $this->_getCustomizeBlock($sPage, $sTarget);
87  }
88 
89  function actionOpen($iOpen)
90  {
91  if (!$this->iUserId)
92  return;
93 
94  if((int)$iOpen != 0)
95  $this->_oConfig->doOpen();
96  else
97  $this->_oConfig->doClose();
98  }
99 
100  function actionSave($isReset = '')
101  {
102  if (!$this->iUserId)
103  return;
104 
105  $sPage = $sTarget = '';
106  if (isset($_POST['page']) && isset($_POST['trg'])) {
107  $sPage = process_db_input($_POST['page'], CH_TAGS_STRIP);
108  $sTarget = process_db_input($_POST['trg'], CH_TAGS_STRIP);
109 
110  unset($_POST['page']);
111  unset($_POST['trg']);
112 
113  $aTmpStyle = $this->_oDb->getSiteTmp();
114 
115  if (!$isReset) {
116  if (!empty($aTmpStyle) && isset($aTmpStyle[$sPage][$sTarget])) {
117  foreach ($aTmpStyle[$sPage][$sTarget] as $sKey => $sValue) {
118  if ($sKey != 'image')
119  unset($aTmpStyle[$sPage][$sTarget][$sKey]);
120  }
121  }
122  $aVars = $_POST;
123  if (isset($_FILES['image'])) {
124  $sImage = $this->_addImage('image');
125  if (strlen($sImage) > 0) {
126  if (isset($aTmpStyle[$sPage][$sTarget]['image']))
127  $this->_deleteImage($aTmpStyle[$sPage][$sTarget]['image']);
128 
129  $aTmpStyle[$sPage][$sTarget]['image'] = $sImage;
130  if (!isset($aVars['useimage']))
131  $aVars['useimage'] = 'on';
132  }
133  }
134 
135  foreach ($aVars as $sKey => $sValue) {
136  if ($sValue != '' && $sValue != 'default' && $sValue != '-1')
137  $aTmpStyle[$sPage][$sTarget][$sKey] = process_db_input($sValue, CH_TAGS_STRIP);
138  }
139  }
140  else if(!empty($aTmpStyle) && isset($aTmpStyle[$sPage][$sTarget])) {
141  $this->_parseImages($aTmpStyle[$sPage][$sTarget], CH_SCTR_IMAGES_DELETE);
142  unset($aTmpStyle[$sPage][$sTarget]);
143  }
144 
145  $this->_oDb->updateSiteTmp($aTmpStyle);
146  }
147 
148  if(isset($_POST['action']) && !empty($_POST['action'])) {
149  $sAction = process_db_input($_POST['action'], CH_TAGS_STRIP);
150  unset($_POST['action']);
151 
152  $iTheme = 0;
153  if(isset($_POST['theme']) && !empty($_POST['theme'])) {
154  $iTheme = (int)$_POST['theme'];
155  unset($_POST['theme']);
156  }
157 
158  if($sAction == 'reset')
159  $this->_oConfig->setSessionData(array($sPage, $sTarget, 0, ''));
160  else
161  $this->_oConfig->setSessionData(array($sPage, $sTarget, $iTheme, $sAction));
162  }
163 
164  echo 'Ok';
165  }
166 
167  function actionPublish($isSave = '')
168  {
169  if (!$this->iUserId)
170  return;
171 
172  $sComplete = '';
173 
174  if ($isSave && isset($_POST['name_theme']) && $_POST['name_theme']) {
175  $sName = process_db_input($_POST['name_theme'], CH_TAGS_STRIP);
176  $aTheme = $this->_oDb->getThemeByName($sName);
177 
178  if (empty($aTheme)) {
179  $iThemeId = $this->_oDb->addTheme($sName, ($this->isAdmin() ? 0 : $this->iUserId), $this->_getThemeFromTmp());
180 
181  if ($iThemeId != -1) {
182  $sThumb = 'thumbnail';
183 
184  if (isset($_FILES[$sThumb]) && is_uploaded_file($_FILES[$sThumb]['tmp_name'])) {
185  if (strpos($_FILES[$sThumb]['type'], 'image') !== false) {
186  $sDestDir = $this->_getImagesDir();
187  $sExt = '.' . pathinfo($_FILES[$sThumb]['name'], PATHINFO_EXTENSION);
188  $sTmpName = 'tmp_' . time() . $this->iUserId . $sExt;
189  $sThumbName = CH_SCTR_THEME_PREFIX . $iThemeId . CH_SCTR_THUMB_EXT;
190 
191  if (move_uploaded_file($_FILES[$sThumb]['tmp_name'], $sDestDir . $sTmpName)) {
192  imageResize($sDestDir . $sTmpName, $sDestDir . $sThumbName, 64, 64, true);
193  unlink($sDestDir . $sTmpName);
194  }
195  } else
196  unlink($_FILES[$sThumb]['tmp_name']);
197  }
198 
199  $sComplete = _t('_ch_sctr_complete');
200  } else
201  $sComplete = _t('_ch_sctr_err_add_theme');
202  } else
203  $sComplete = sprintf(_t('_ch_sctr_err_already_exist'), $sName);
204  }
205 
206  header('Content-Type: text/html; charset=utf-8');
207  echo $this->_oTemplate->getPublishForm($sComplete);
208  }
209 
210  function actionSaveTheme($iThemeId)
211  {
212  $iThemeId = (int)$iThemeId;
213 
214  if (!$this->iUserId)
215  return;
216 
217  $sCss = '';
218  $aTheme = $this->_oDb->getThemeStyle($iThemeId);
219 
220  if (!empty($aTheme)) {
221  $aStyles = $this->_oDb->getSite();
222  if (!empty($aStyles)) {
223  $this->_parseImages(unserialize($aStyles['css']), CH_SCTR_IMAGES_DELETE);
224  $this->_parseImages(unserialize($aStyles['tmp']), CH_SCTR_IMAGES_DELETE);
225  }
226 
227  $this->_parseImages($aTheme, CH_SCTR_IMAGES_COPY);
228  $this->_parseImages($aTheme, CH_SCTR_IMAGES_COPY);
229 
230  $this->_oDb->updateSiteTmp($aTheme);
231  $this->_oDb->updateSiteCss($aTheme);
232 
233  $this->_oConfig->cancelSession();
234  }
235  }
236 
237  function actionDeleteTheme($iThemeId)
238  {
239  if(!$this->iUserId)
240  return;
241 
242  $this->_deleteTheme((int)$iThemeId);
243 
244  header('Content-Type: text/html; charset=utf-8');
245  echo $this->serviceGetCustomizeBlock('themes');
246  }
247 
248  function actionResetAll()
249  {
250  if (!$this->iUserId)
251  return;
252 
253  $aStyles = $this->_oDb->getSite();
254  if (!empty($aStyles)) {
255  $this->_parseImages(unserialize($aStyles['css']), CH_SCTR_IMAGES_DELETE);
256  $this->_parseImages(unserialize($aStyles['tmp']), CH_SCTR_IMAGES_DELETE);
257  $this->_oDb->resetSite();
258  }
259  }
260 
265  function actionAdministration($sType = '', $iUnitId = '')
266  {
267  $iUnitId = (int)$iUnitId;
268 
269  if (!$this->isAdmin()) {
270  // TODO: show access denied
271  return;
272  }
273 
274  $this->_oTemplate->addAdminCss(array('forms_adv.css', 'main.css', 'admin.css'));
275  $this->_oTemplate->addAdminJs(array('main.js'));
276 
277  $this->_oTemplate->pageCodeAdmin (_t('_ch_sctr_administration'), $sType, $iUnitId, $this->_checkActions());
278  }
279 
284  {
285  if(!isAdmin() || !$this->_oConfig->isEnabled())
286  return '';
287 
288  return array(
289  'evalResult' => 'oChSctrMain.showBlock();',
290  'evalResultCssClassWrapper' => 'ch-phone-hide'
291  );
292  }
293  function serviceGetCustomizeBlock($sPage = '', $sTarget = '')
294  {
295  if(!$this->_oConfig->isEnabled())
296  return '';
297 
298  return $this->_oTemplate->parseHtmlByName('customize_block_wrp.html', array(
299  'name_id' => 'site_customize',
300  'ch_if:hide' => array(
301  'condition' => !$this->_oConfig->isOpen(),
302  'content' => array()
303  ),
304  'content' => $this->_getCustomizeBlock($sPage, $sTarget)
305  ));
306  }
307 
309  {
310  if(!$this->_oConfig->isEnabled())
311  return '';
312 
313  list($sPage, $sTarget, $iTheme, $sAction) = $this->_oConfig->getSessionData();
314 
315  $sCss = '';
316  switch ($sAction) {
317  case 'save':
318  $aStyles = $this->_oDb->getSite();
319  if (!empty($aStyles)) {
320  $this->_parseImages(unserialize($aStyles['css']), CH_SCTR_IMAGES_DELETE);
321  $this->_parseImages(unserialize($aStyles['tmp']), CH_SCTR_IMAGES_COPY);
322  $this->_oDb->saveSite();
323  $sCss .= $this->_getCssFromArray($this->_oDb->getSiteCss());
324  }
325 
326  $this->_oConfig->setSessionData(array($sPage, $sTarget, $iTheme, ''));
327  break;
328 
329  case 'preview':
330  $sCss .= $this->_getCssFromArray($this->_oDb->getSiteTmp());
331  break;
332 
333  case 'theme':
334  $sCss .= $this->_getCssFromArray($this->_oDb->getThemeStyle($iTheme));
335  break;
336 
337  default:
338  $sCss .= $this->_getCssFromArray($this->_oDb->getSiteCss());
339  }
340 
341  return '<style type="text/css">' . $sCss . '</style>';
342  }
343 
344  function isAdmin()
345  {
346  return isAdmin($this->iUserId);
347  }
348 
349  function _getImagesPath()
350  {
351  return CH_WSB_URL_MODULES . $this->_aModule['path'] . CH_SCTR_DIR_IMAGES;
352  }
353 
354  function _getImagesDir()
355  {
356  return CH_DIRECTORY_PATH_MODULES . $this->_aModule['path'] . CH_SCTR_DIR_IMAGES;
357  }
358 
359  function _addImage($sName)
360  {
361  if (isset($_FILES[$sName]) && is_uploaded_file($_FILES[$sName]['tmp_name'])) {
362  if (strpos($_FILES[$sName]['type'], 'image') !== false) {
363  $sExt = pathinfo($_FILES[$sName]['name'], PATHINFO_EXTENSION);
364  $sFileName = $this->_oDb->addImage($sExt);
365  if ($sFileName) {
366  $sDestDir = $this->_getImagesDir();
367  if (move_uploaded_file($_FILES[$sName]['tmp_name'], $sDestDir . $sFileName)) {
368  imageResize($sDestDir . $sFileName, $sDestDir . CH_SCTR_SMALL_PREFIX . $sFileName, 64, 64);
369  return $sFileName;
370  }
371  }
372  } else
373  unlink($_FILES[$sName]['tmp_name']);
374  }
375 
376  return '';
377  }
378 
379  function _deleteImage($sFileName)
380  {
381  if ($this->_oDb->deleteImage($sFileName)) {
382  $sDestDir = $this->_getImagesDir();
383  if (file_exists($sDestDir . $sFileName))
384  unlink($sDestDir . $sFileName);
385  if (file_exists($sDestDir . CH_SCTR_SMALL_PREFIX . $sFileName))
386  unlink($sDestDir . CH_SCTR_SMALL_PREFIX . $sFileName);
387  }
388  }
389 
390  function _convertFormVarToTmpStyle($sPage, $sTarget, $aVars, &$aResult, $bFiles = false)
391  {
392  foreach ($aVars as $sKey => $sValue) {
393  if ($bFiles)
394  $sValue = $this->_addImage($sKey);
395 
396  if ($sValue != '' && $sValue != 'default' && $sValue != '-1')
397  $aResult[$sPage][$sTarget][$sKey] = $sValue;
398  }
399  }
400 
401  function _getCssFromArray($aTmpStyle)
402  {
403  $bPageBackgroundChanged = false;
404  $sCss = '';
405 
406  if (empty($aTmpStyle))
407  return '';
408 
409  foreach ($aTmpStyle as $sKey => $aValue) {
410  if (!isset($this->_aCssMatch[$sKey]))
411  continue;
412 
413  foreach ($aValue as $sValKey => $aParam) {
414  if (!isset($this->_aCssMatch[$sKey][$sValKey]['css_name']))
415  continue;
416 
417  $sPartCss = $this->_aCssMatch[$sKey][$sValKey]['css_name'] . ' {';
418 
419  $sMethod = '_compile' . ucfirst($sKey);
420  $s = method_exists($this, $sMethod) ? call_user_func_array(array($this, $sMethod), array($aParam)) : '';
421  if ('bgbody' == $sValKey && 'background' == $sKey && '' != $s && 'background-image: none;' != $s)
422  $bPageBackgroundChanged = true;
423  $sPartCss .= $s;
424 
425  $sPartCss .= ' }';
426  $sCss .= $sPartCss;
427  }
428  }
429 
430  if ($bPageBackgroundChanged)
431  $sCss .= ' html div.sys_root_bg {display:none;} ';
432 
433  return $sCss;
434  }
435 
436  function _getThemeFromTmp()
437  {
438  $aTmpStyle = $this->_oDb->getSiteTmp();
439 
440  if (empty($aTmpStyle))
441  return '';
442 
443  $this->_parseImages($aTmpStyle, CH_SCTR_IMAGES_COPY);
444 
445  return serialize($aTmpStyle);
446  }
447 
448  function _parseImages($aCss, $iOperation)
449  {
450  if (empty($aCss))
451  return;
452 
453  foreach ($aCss as $sKey => $mixedValue) {
454  if (!is_array($mixedValue)) {
455  if ($sKey == 'image') {
456  switch ($iOperation) {
458  $this->_deleteImage($mixedValue);
459  break;
460 
461  case CH_SCTR_IMAGES_COPY:
462  $this->_oDb->copyImage($mixedValue);
463  break;
464  }
465  }
466  } else
467  $this->_parseImages($mixedValue, $iOperation);
468  }
469  }
470 
471  function _getImages($aCss)
472  {
473  $aResult = array();
474 
475  if (empty($aCss))
476  return $aResult;
477 
478  foreach ($aCss as $sKey => $mixedValue) {
479  if (!is_array($mixedValue)) {
480  if ($sKey == 'image')
481  $aResult[] = $mixedValue;
482  } else
483  $aResult = array_merge($aResult, $this->_getImages($mixedValue));
484  }
485 
486  return $aResult;
487  }
488 
489  function _importImages($aCss, $oZip, $aImages)
490  {
491  $aResult = array();
492 
493  if (empty($aCss))
494  return $aResult;
495 
496  foreach ($aCss as $sKey => $mixedValue) {
497  if (!is_array($mixedValue)) {
498  if ($sKey == 'image') {
499  $sExt = pathinfo($mixedValue, PATHINFO_EXTENSION);
500  $sFileName = $this->_oDb->addImage($sExt);
501  if ($sFileName) {
502  $sDestDir = $this->_getImagesDir();
503  $oFile = fopen($sDestDir . $sFileName, 'w', false);
504  if ($oFile) {
505  fwrite($oFile, $oZip->GetData($aImages[$mixedValue]));
506  fclose($oFile);
507  imageResize($sDestDir . $sFileName, $sDestDir . CH_SCTR_SMALL_PREFIX . $sFileName, 64, 64);
508  $aResult[$sKey] = $sFileName;
509  }
510  }
511  } else
512  $aResult[$sKey] = $mixedValue;
513  } else
514  $aResult[$sKey] = $this->_importImages($mixedValue, $oZip, $aImages);
515  }
516 
517  return $aResult;
518  }
519 
520  function _saveCss()
521  {
522  $sTmpCss = $this->_getCssFromArray($this->_oDb->getSiteTmp());
523  $this->_oDb->updateSiteCss($this->iUserId, $sTmpCss);
524  }
525 
526  function _deleteTheme($iThemeId)
527  {
528  $sResult = _t('_ch_sctr_err_delete_theme');
529 
530  if (!$iThemeId)
531  return $sResult;
532 
533  $aTheme = $this->_oDb->getThemeById($iThemeId);
534  if (!empty($aTheme) && $this->_oDb->deleteTheme($iThemeId)) {
535  $sFile = $this->_getImagesDir() . CH_SCTR_THEME_PREFIX . $iThemeId . CH_SCTR_THUMB_EXT;
536  if (file_exists($sFile))
537  unlink($sFile);
538  $this->_parseImages(unserialize($aTheme['css']), CH_SCTR_IMAGES_DELETE);
539 
540  $sResult = _t('_ch_sctr_delete_complete');
541  }
542 
543  return $sResult;
544  }
545 
546  function _checkActions()
547  {
548  $sResult = '';
549  $sFileImport = 'theme_file';
550 
551  if ($_POST['theme']) {
552  if ($_POST['action_theme_export'])
553  $this->_exportTheme($_POST['theme']);
554 
555  if ($_POST['action_theme_delete'])
556  $sResult = $this->_deleteTheme($_POST['theme']);
557  } else if (isset($_FILES[$sFileImport]) && is_uploaded_file($_FILES[$sFileImport]['tmp_name'])) {
558  $sResult = $this->_importTheme($sFileImport);
559  unlink($_FILES[$sFileImport]['tmp_name']);
560  }
561 
562  return $sResult;
563  }
564 
565  function _exportTheme($iThemeId)
566  {
567  $aTheme = $this->_oDb->getThemeById($iThemeId);
568 
569  if (empty($aTheme))
570  return;
571 
572  $sConf = "\$sThemeName = '{$aTheme['name']}';\n";
573  $sConf .= "\$sThemeStyle = '{$aTheme['css']}';\n";
574 
575  $sImagesPath = $this->_getImagesDir();
576  $oZipFile = new zipfile();
577 
578  $oZipFile->addFile($sConf, CH_SCTR_THEME_CONF);
580  if (file_exists($sFile)) {
581  $oData = implode("", file($sFile));
582  $oZipFile->addFile($oData, CH_SCTR_THEME_THUMB);
583  }
584 
585  $aImages = $this->_getImages(unserialize($aTheme['css']));
586  foreach ($aImages as $sImage) {
587  $sFile = $sImagesPath . $sImage;
588  if (file_exists($sFile)) {
589  $oData = implode("", file($sFile));
590  $oZipFile->addFile($oData, 'images/' . $sImage);
591  }
592  }
593 
594  header("Content-type: application/octet-stream");
595  header("Content-disposition: attachment; filename={$aTheme['name']}.dfn");
596  echo $oZipFile->file();
597  }
598 
599  function _importTheme($sFileImport)
600  {
601  $sResult = '';
602  $sDestDir = $this->_getImagesDir();
603 
604  if (!$sFileImport)
605  return $sResult;
606 
607  if (pathinfo($_FILES[$sFileImport]['name'], PATHINFO_EXTENSION) != 'dfn')
608  return _t('_ch_sctr_err_format');
609 
610  $oUnZip = new SimpleUnzip($_FILES[$sFileImport]['tmp_name']);
611  $aFiles = $this->_getZipFilesFromPath($oUnZip, '');
612 
613  // check exist 'conf.php'
614  if (!isset($aFiles[CH_SCTR_THEME_CONF]))
615  return sprintf(_t('_ch_sctr_err_conf_php'), 'conf.php');
616 
617  eval($oUnZip->GetData($aFiles[CH_SCTR_THEME_CONF]));
618 
619  // check parameters
620  if (!isset($sThemeName) || !isset($sThemeStyle))
621  return _t('_ch_sctr_err_theme_parameters');
622 
623  // check exist theme
624  $aTheme = $this->_oDb->getThemeByName($sThemeName);
625  if (!empty($aTheme))
626  return sprintf(_t('_ch_sctr_err_already_exist'), $sThemeName);
627 
628  $aImages = $this->_getZipFilesFromPath($oUnZip, 'images');
629  if (!empty($aImages))
630  $sStyle = serialize($this->_importImages(unserialize($sThemeStyle), $oUnZip, $aImages));
631  else
632  $sStyle = '';
633 
634  // insert in table
635  $iThemeId = $this->_oDb->addTheme($sThemeName, 0, $sStyle);
636  if ($iThemeId == -1)
637  return _t('_ch_sctr_err_add_theme');
638 
639  // copy thumbnail
640  if (isset($aFiles[CH_SCTR_THEME_THUMB])) {
641  $sThumbName = CH_SCTR_THEME_PREFIX . $iThemeId . CH_SCTR_THUMB_EXT;
642 
643  $oFile = fopen($sDestDir . $sThumbName, 'w', false);
644  if ($oFile) {
645  fwrite($oFile, $oUnZip->GetData($aFiles[CH_SCTR_THEME_THUMB]));
646  fclose($oFile);
647  }
648  }
649 
650  return _t('_ch_sctr_import_complete');
651  }
652 
653  function _getZipFilesFromPath($oZipFile, $sPath = '')
654  {
655  $aFiles = array();
656 
657  for ($i = 0; $i < $oZipFile->Count(); $i++) {
658  if ($oZipFile->GetPath($i) == $sPath)
659  $aFiles[$oZipFile->GetName($i)] = $i;
660  }
661 
662  return $aFiles;
663  }
664 
665  function _compileBackground($aParam)
666  {
667  $sParams = '';
668 
669  foreach ($aParam as $sKey => $sValue) {
670  if (!$sValue)
671  continue;
672 
673  switch ($sKey) {
674  case 'color':
675  $sParams .= 'background-color: ' . $sValue . ';';
676  if (!isset($aParam['image']))
677  $sParams .= 'background-image: none;';
678  break;
679 
680  case 'image':
681  if (isset($aParam['useimage']))
682  $sParams .= 'background-image: url(' . $this->_getImagesPath() . $sValue . ');';
683  else
684  $sParams .= 'background-image: none;';
685  break;
686 
687  case 'repeat':
688  $sParams .= 'background-repeat: ' . $sValue . ';';
689  break;
690 
691  case 'position':
692  $sParams .= 'background-position: ' . $sValue . ';';
693  break;
694  }
695  }
696 
697  return $sParams;
698  }
699 
700  function _compileFont($aParam)
701  {
702  $sParams = '';
703 
704  foreach ($aParam as $sKey => $sValue) {
705  if ($sValue == '')
706  continue;
707 
708  switch ($sKey) {
709  case 'size':
710  $sParams .= 'font-size: ' . $sValue . 'px;';
711  break;
712 
713  case 'color':
714  $sParams .= 'color: ' . $sValue . ';';
715  break;
716 
717  case 'name':
718  $sParams .= 'font-family: ' . $sValue . ';';
719  break;
720 
721  case 'style':
722  switch ($sValue) {
723  case 'normal':
724  $sParams .= 'font-style: normal;';
725  break;
726 
727  case 'bold':
728  $sParams .= 'font-weight: bold;';
729  break;
730 
731  case 'italic':
732  $sParams .= 'font-style: italic;';
733  break;
734  }
735  }
736  }
737 
738  return $sParams;
739  }
740 
741  function _compileBorder($aParam)
742  {
743  $sParams = '';
744  $aProperties = array(
745  'border'
746  );
747 
748  if (isset($aParam['position']))
749  switch($aParam['position']) {
750  case 'top':
751  $aProperties = array(
752  'border-top'
753  );
754  break;
755 
756  case 'right':
757  $aProperties = array(
758  'border-right'
759  );
760  break;
761 
762  case 'bottom':
763  $aProperties = array(
764  'border-bottom'
765  );
766  break;
767 
768  case 'left':
769  $aProperties = array(
770  'border-left'
771  );
772  break;
773 
774  case 'left_right':
775  $aProperties = array(
776  'border-left',
777  'border-right'
778  );
779  break;
780 
781  case 'top_bottom':
782  $aProperties = array(
783  'border-top',
784  'border-bottom'
785  );
786  break;
787 
788  case 'top_right':
789  $aProperties = array(
790  'border-top',
791  'border-right'
792  );
793  break;
794 
795  case 'right_bottom':
796  $aProperties = array(
797  'border-right',
798  'border-bottom'
799  );
800  break;
801 
802  case 'bottom_left':
803  $aProperties = array(
804  'border-bottom',
805  'border-left'
806  );
807  break;
808 
809  case 'left_top':
810  $aProperties = array(
811  'border-left',
812  'border-top'
813  );
814  break;
815  }
816 
817  foreach ($aParam as $sKey => $sValue) {
818  $sProperty = '';
819  if ($sValue == '')
820  continue;
821 
822  switch ($sKey) {
823  case 'size':
824  foreach ($aProperties as $sVal)
825  $sParams .= $sVal . '-width: ' . $sValue . 'px;';
826  break;
827 
828  case 'color':
829  foreach ($aProperties as $sVal)
830  $sParams .= $sVal . '-color: ' . $sValue . ';';
831  break;
832 
833  case 'style':
834  foreach ($aProperties as $sVal)
835  $sParams .= $sVal . '-style: ' . $sValue . ';';
836  break;
837  }
838  }
839 
840  return $sParams;
841  }
842 
843  function _getCustomizeBlock($sPage = '', $sTarget = '')
844  {
845  if (!$this->iUserId || !isAdmin($this->iUserId) || !getParam('ch_sctr_enable'))
846  return '';
847 
848  $sUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'customizepage/';
849  $aMenuItems = array('themes', 'background', 'font', 'border');
850  $aTopMenu = array();
851  $aTargets = array();
852 
853  list($sSesPage, $sSesTarget, $iSesTheme, $sSesAction) = $this->_oConfig->getSessionData();
854  if($sPage == '' && !empty($sSesPage))
855  $sPage = $sSesPage;
856 
857  if($sTarget == '' && !empty($sSesTarget))
858  $sTarget = $sSesTarget;
859 
860  if (!$sPage)
861  $sPage = $aMenuItems[0];
862 
863  foreach ($aMenuItems as $sItem) {
864  $aTopMenu[_t('_ch_sctr_page_' . $sItem)] = array(
865  'href' => $sUrl . $sItem,
866  'dynamic' => true,
867  'active' => $sItem == $sPage
868  );
869  }
870 
871  $aTargets = array();
872  if (isset($this->_aCssMatch[$sPage])) {
873  if (!$sTarget)
874  $sTarget = key($this->_aCssMatch[$sPage]);
875 
876  foreach ($this->_aCssMatch[$sPage] as $sKey => $aValues) {
877  $aTargets[] = array(
878  'name' => _t($aValues['name']),
879  'value' => $sUrl . $sPage . '/' . $sKey,
880  'select' => $sKey == $sTarget ? 'selected' : ''
881  );
882  }
883  }
884 
885  $aVars = array();
886  $aStyle = $this->_oDb->getSiteTmp();
887  if (!empty($aStyle) && isset($aStyle[$sPage][$sTarget]))
888  $aVars = $aStyle[$sPage][$sTarget];
889 
890  return $this->_oTemplate->profileCustomizeBlock($aTopMenu, $sPage, $aTargets, $sTarget, $aVars);
891  }
892 }
CH_SCTR_IMAGES_DELETE
const CH_SCTR_IMAGES_DELETE
Definition: ChSctrModule.php:19
process_db_input
process_db_input($sText, $iStripTags=0)
Definition: utils.inc.php:256
header
</code > Be careful enabling this directive if you have a redirector script that does not use the< code > Location</code > HTTP header
Definition: URI.MungeResources.txt:10
ChSctrModule\actionSaveTheme
actionSaveTheme($iThemeId)
Definition: ChSctrModule.php:210
ChSctrModule\_importImages
_importImages($aCss, $oZip, $aImages)
Definition: ChSctrModule.php:489
ChSctrModule\_getImagesPath
_getImagesPath()
Definition: ChSctrModule.php:349
ChSctrModule\actionPublish
actionPublish($isSave='')
Definition: ChSctrModule.php:167
ChSctrModule\actionResetAll
actionResetAll()
Definition: ChSctrModule.php:248
ChSctrModule\_saveCss
_saveCss()
Definition: ChSctrModule.php:520
ChSctrModule\_getImages
_getImages($aCss)
Definition: ChSctrModule.php:471
ChWsbModule\getInstance
static getInstance($sClassName)
Definition: ChWsbModule.php:89
ChWsbModule\isLogged
isLogged()
Definition: ChWsbModule.php:113
ChSctrModule\_compileBackground
_compileBackground($aParam)
Definition: ChSctrModule.php:665
$sResult
$sResult
Definition: advanced_settings.php:26
ChSctrModule\__construct
__construct($aModule)
Definition: ChSctrModule.php:70
$aModule
$aModule
Definition: classifieds.php:21
ch_sctr_import
ch_sctr_import($sClassPostfix, $aModuleOverwright=array())
Definition: ChSctrModule.php:22
ChSctrModule\_compileFont
_compileFont($aParam)
Definition: ChSctrModule.php:700
ChSctrModule\$_aCssMatch
$_aCssMatch
Definition: ChSctrModule.php:65
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
$aResult
$aResult
Definition: index.php:19
ChSctrModule\actionAdministration
actionAdministration($sType='', $iUnitId='')
Definition: ChSctrModule.php:265
CH_SCTR_SMALL_PREFIX
const CH_SCTR_SMALL_PREFIX
Definition: ChSctrModule.php:14
$sUrl
$sUrl
Definition: cart.php:15
php
$sExt
$sExt
Definition: get_file.php:14
ChSctrModule\_importTheme
_importTheme($sFileImport)
Definition: ChSctrModule.php:599
ChSctrModule\isAdmin
isAdmin()
Definition: ChSctrModule.php:344
ChSctrModule
Definition: ChSctrModule.php:63
CH_SCTR_DIR_IMAGES
const CH_SCTR_DIR_IMAGES
Definition: ChSctrModule.php:13
CH_SCTR_IMAGES_COPY
const CH_SCTR_IMAGES_COPY
Definition: ChSctrModule.php:20
ChSctrModule\actionDeleteTheme
actionDeleteTheme($iThemeId)
Definition: ChSctrModule.php:237
ChSctrModule\_getZipFilesFromPath
_getZipFilesFromPath($oZipFile, $sPath='')
Definition: ChSctrModule.php:653
ChSctrModule\serviceGetSiteStyle
serviceGetSiteStyle()
Definition: ChSctrModule.php:308
ChSctrModule\_exportTheme
_exportTheme($iThemeId)
Definition: ChSctrModule.php:565
ChSctrModule\_parseImages
_parseImages($aCss, $iOperation)
Definition: ChSctrModule.php:448
CH_SCTR_THEME_THUMB
const CH_SCTR_THEME_THUMB
Definition: ChSctrModule.php:18
$sType
$sType
Definition: actions.inc.php:11
$sFile
$sFile
Definition: index.php:20
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
ChSctrModule\actionSave
actionSave($isReset='')
Definition: ChSctrModule.php:100
ChSctrModule\_getCssFromArray
_getCssFromArray($aTmpStyle)
Definition: ChSctrModule.php:401
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
ChSctrModule\actionCustomizePage
actionCustomizePage($sPage='', $sTarget='')
Definition: ChSctrModule.php:81
ChSctrModule\_convertFormVarToTmpStyle
_convertFormVarToTmpStyle($sPage, $sTarget, $aVars, &$aResult, $bFiles=false)
Definition: ChSctrModule.php:390
ChSctrModule\_checkActions
_checkActions()
Definition: ChSctrModule.php:546
ChSctrModule\$iUserId
$iUserId
Definition: ChSctrModule.php:64
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
ChWsbModule
Definition: ChWsbModule.php:41
ChSctrModule\_getCustomizeBlock
_getCustomizeBlock($sPage='', $sTarget='')
Definition: ChSctrModule.php:843
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
CH_SCTR_THEME_CONF
const CH_SCTR_THEME_CONF
Definition: ChSctrModule.php:17
time
that in the case of a Adaptation or at a minimum such credit will if a credit for all contributing authors of the Adaptation or Collection then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors For the avoidance of You may only use the credit required by this Section for the purpose of attribution in the manner set out above by exercising Your rights under this You may not implicitly or explicitly assert or imply any connection sponsorship or endorsement by the Original Licensor and or Attribution as of You or Your use of the without the express prior written permission of the Original Licensor and or Attribution Parties Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable if You Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or You must not modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author s honor or reputation Licensor agrees that in those in which any exercise of the right granted in modification or other derogatory action prejudicial to the Original Author s honor and the Licensor will waive or not as this to the fullest extent permitted by the applicable national to enable You to reasonably exercise Your right under Warranties and Disclaimer UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN LICENSOR OFFERS THE WORK AS IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE STATUTORY OR WITHOUT WARRANTIES OF FITNESS FOR A PARTICULAR OR THE ABSENCE OF LATENT OR OTHER OR THE PRESENCE OF ABSENCE OF WHETHER OR NOT DISCOVERABLE SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED SO SUCH EXCLUSION MAY NOT APPLY TO YOU Limitation on Liability EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES Termination This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License Individuals or entities who have received Adaptations or Collections from You under this will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses and will survive any termination of this License Subject to the above terms and the license granted here is Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time
Definition: license.txt:56
ChSctrModule\_getThemeFromTmp
_getThemeFromTmp()
Definition: ChSctrModule.php:436
CH_SCTR_THUMB_EXT
const CH_SCTR_THUMB_EXT
Definition: ChSctrModule.php:16
ChSctrModule\_deleteTheme
_deleteTheme($iThemeId)
Definition: ChSctrModule.php:526
CH_TAGS_STRIP
const CH_TAGS_STRIP
Definition: utils.inc.php:22
SimpleUnzip
Definition: unzip.lib.php:48
zipfile
Definition: zip.lib.php:28
CH_SCTR_THEME_PREFIX
const CH_SCTR_THEME_PREFIX
Definition: ChSctrModule.php:15
$aVars
$aVars
Definition: license.php:101
$s
$s
Definition: embed.php:13
$sImagesPath
$sImagesPath
Definition: header.inc.php:94
ChSctrModule\_deleteImage
_deleteImage($sFileName)
Definition: ChSctrModule.php:379
ChSctrModule\actionOpen
actionOpen($iOpen)
Definition: ChSctrModule.php:89
$sAction
$sAction
Definition: categories.php:274
ChSctrModule\_addImage
_addImage($sName)
Definition: ChSctrModule.php:359
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
imageResize
imageResize( $srcFilename, $dstFilename, $sizeX, $sizeY, $forceJPGOutput=false, $isSquare=false)
Definition: images.inc.php:29
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChSctrModule\serviceGetCustomizeBlock
serviceGetCustomizeBlock($sPage='', $sTarget='')
Definition: ChSctrModule.php:293
$sName
$sName
Definition: ChWsbAdminTools.php:853
ChSctrModule\_getImagesDir
_getImagesDir()
Definition: ChSctrModule.php:354
ChSctrModule\serviceGetCustomizeButton
serviceGetCustomizeButton()
Definition: ChSctrModule.php:283
ChSctrModule\_compileBorder
_compileBorder($aParam)
Definition: ChSctrModule.php:741