Cheetah
ChProfileCustomizeModule.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_PROFILE_CUSTOMIZE_DIR_IMAGES', 'data/images/');
14 define('CH_PROFILE_CUSTOMIZE_SMALL_PREFIX', 's_');
15 define('CH_PROFILE_CUSTOMIZE_THEME_PREFIX', 't_');
16 define('CH_PROFILE_CUSTOMIZE_THUMB_EXT', '.jpg');
17 define('CH_PROFILE_CUSTOMIZE_THEME_CONF', 'conf.php');
18 define('CH_PROFILE_CUSTOMIZE_THEME_THUMB', 'thumb.jpg');
19 define('CH_PROFILE_CUSTOMIZE_IMAGES_DELETE', 0);
20 define('CH_PROFILE_CUSTOMIZE_IMAGES_COPY', 1);
21 
22 define('CH_PROFILE_PAGE', 1);
23 
24 function ch_profile_customize_import($sClassPostfix, $aModuleOverwright = array())
25 {
27  $a = $aModuleOverwright ? $aModuleOverwright : $aModule;
28  if (!$a || $a['uri'] != 'profile_customize') {
29  $oMain = ChWsbModule::getInstance('ChProfileCustomizeModule');
30  $a = $oMain->_aModule;
31  }
32  ch_import ($sClassPostfix, $a) ;
33 }
34 
65 {
67 
72  {
73  parent::__construct($aModule);
74  $this->iUserId = getLoggedId();
75  $this->_oConfig->init($this->_oDb);
76  $this->_oTemplate->setModule($this);
77 
78  $this->_aCssMatch = $this->_oDb->getUnits();
79  }
80 
81  function actionCustomizePage($sPage = '', $sTarget = '')
82  {
83  header('Content-Type: text/html; charset=utf-8');
84  echo $this->serviceGetCustomizeBlock($sPage, $sTarget);
85  }
86 
87  function actionSave($isReset = '')
88  {
89  if (!$this->iUserId)
90  return;
91 
92  if (isset($_POST['page']) && isset($_POST['trg'])) {
93  $sPage = process_db_input($_POST['page'], CH_TAGS_STRIP);
94  $sTarget = process_db_input($_POST['trg'], CH_TAGS_STRIP);
95 
96  unset($_POST['page']);
97  unset($_POST['trg']);
98 
99  $aTmpStyle = $this->_oDb->getProfileTmpByUserId($this->iUserId);
100 
101  if (!$isReset) {
102  if (!empty($aTmpStyle) && isset($aTmpStyle[$sPage][$sTarget])) {
103  foreach ($aTmpStyle[$sPage][$sTarget] as $sKey => $sValue) {
104  if ($sKey != 'image')
105  unset($aTmpStyle[$sPage][$sTarget][$sKey]);
106  }
107  }
108  $aVars = $_POST;
109  if (isset($_FILES['image'])) {
110  $sImage = $this->_addImage('image');
111  if (strlen($sImage) > 0) {
112  if (isset($aTmpStyle[$sPage][$sTarget]['image']))
113  $this->_deleteImage($aTmpStyle[$sPage][$sTarget]['image']);
114 
115  $aTmpStyle[$sPage][$sTarget]['image'] = $sImage;
116  if (!isset($aVars['useimage']))
117  $aVars['useimage'] = 'on';
118  }
119  }
120 
121  foreach ($aVars as $sKey => $sValue) {
122  if ($sValue != '' && $sValue != 'default' && $sValue != '-1')
123  $aTmpStyle[$sPage][$sTarget][$sKey] = process_db_input($sValue, CH_TAGS_STRIP);
124  }
125  } else if (!empty($aTmpStyle) && isset($aTmpStyle[$sPage][$sTarget])) {
126  $this->_parseImages($aTmpStyle[$sPage][$sTarget], CH_PROFILE_CUSTOMIZE_IMAGES_DELETE);
127  unset($aTmpStyle[$sPage][$sTarget]);
128  }
129 
130  $this->_oDb->updateProfileTmpByUserId($this->iUserId, $aTmpStyle);
131  }
132  echo 'Ok';
133  }
134 
135  function actionProfileBlock($sAction = '', $iTheme = '')
136  {
137  $iTheme = (int)$iTheme;
138 
139  if (!$this->iUserId)
140  return '';
141 
142  $sCss = '<style type="text/css">';
143  switch ($sAction) {
144  case 'save':
145  $aStyles = $this->_oDb->getProfileByUserId($this->iUserId);
146  if (!empty($aStyles)) {
147  $this->_parseImages(unserialize($aStyles['css']), CH_PROFILE_CUSTOMIZE_IMAGES_DELETE);
148  $this->_parseImages(unserialize($aStyles['tmp']), CH_PROFILE_CUSTOMIZE_IMAGES_COPY);
149  $this->_oDb->saveProfileByUserId($this->iUserId);
150  $sCss .= $this->_getCssFromArray($this->_oDb->getProfileCssByUserId($this->iUserId));
151  }
152  break;
153 
154  case 'preview':
155  $sCss .= $this->_getCssFromArray($this->_oDb->getProfileTmpByUserId($this->iUserId));
156  break;
157 
158  case 'theme':
159  $sCss .= $this->_getCssFromArray($this->_oDb->getThemeStyle($iTheme));
160  break;
161 
162  default:
163  $sCss .= $this->_getCssFromArray($this->_oDb->getProfileCssByUserId($this->iUserId));
164  }
165  $sCss .= '</style>';
166 
167  header('Content-Type: text/html; charset=utf-8');
168  echo $this->_oTemplate->profilePage($this->iUserId, $sCss);
169  }
170 
171  function actionPublish($isSave = '')
172  {
173  if (!$this->iUserId)
174  return;
175 
176  $sComplete = '';
177 
178  if ($isSave && isset($_POST['name_theme']) && $_POST['name_theme']) {
179  $sName = process_db_input($_POST['name_theme'], CH_TAGS_STRIP);
180  $aTheme = $this->_oDb->getThemeByName($sName);
181 
182  if (empty($aTheme)) {
183  $iThemeId = $this->_oDb->addTheme($sName, ($this->isAdmin() ? (int)$_POST['destination'] : $this->iUserId), $this->_getThemeFromTmp());
184 
185  if ($iThemeId != -1) {
186  $sThumb = 'thumbnail';
187 
188  if (isset($_FILES[$sThumb]) && is_uploaded_file($_FILES[$sThumb]['tmp_name'])) {
189  if (strpos($_FILES[$sThumb]['type'], 'image') !== false) {
190  $sDestDir = $this->_getImagesDir();
191  $sExt = '.' . pathinfo($_FILES[$sThumb]['name'], PATHINFO_EXTENSION);
192  $sTmpName = 'tmp_' . time() . $this->iUserId . $sExt;
194 
195  if (move_uploaded_file($_FILES[$sThumb]['tmp_name'], $sDestDir . $sTmpName)) {
196  imageResize($sDestDir . $sTmpName, $sDestDir . $sThumbName, 64, 64, true);
197  unlink($sDestDir . $sTmpName);
198  }
199  } else
200  unlink($_FILES[$sThumb]['tmp_name']);
201  }
202 
203  $sComplete = _t('_ch_profile_customize_complete');
204  } else
205  $sComplete = _t('_ch_profile_customize_err_add_theme');
206  } else
207  $sComplete = sprintf(_t('_ch_profile_customize_err_already_exist'), $sName);
208  }
209 
210  header('Content-Type: text/html; charset=utf-8');
211  echo $this->_oTemplate->getPublishForm($sComplete);
212  }
213 
214  function actionSaveTheme($iThemeId)
215  {
216  $iThemeId = (int)$iThemeId;
217 
218  if (!$this->iUserId)
219  return;
220 
221  $sCss = '';
222  $aTheme = $this->_oDb->getThemeStyle($iThemeId);
223 
224  if (!empty($aTheme)) {
225  $aStyles = $this->_oDb->getProfileByUserId($this->iUserId);
226  if (!empty($aStyles)) {
227  $this->_parseImages(unserialize($aStyles['css']), CH_PROFILE_CUSTOMIZE_IMAGES_DELETE);
228  $this->_parseImages(unserialize($aStyles['tmp']), CH_PROFILE_CUSTOMIZE_IMAGES_DELETE);
229  }
230 
233 
234  $this->_oDb->updateProfileTmpByUserId($this->iUserId, $aTheme);
235  $this->_oDb->updateProfileCssByUserId($this->iUserId, $aTheme);
236 
237  $sCss = '<style type="text/css">';
238  $sCss .= $this->_getCssFromArray($this->_oDb->getProfileCssByUserId($this->iUserId));
239  $sCss .= '</style>';
240  }
241 
242  echo $this->_oTemplate->profilePage($this->iUserId, $sCss);
243  }
244 
245  function actionDeleteTheme($iThemeId)
246  {
247  $iThemeId = (int)$iThemeId;
248 
249  if (!$this->iUserId)
250  return;
251 
252  $this->_deleteTheme($iThemeId);
253  echo $this->serviceGetCustomizeBlock('themes');
254  }
255 
256  function actionResetAll()
257  {
258  if (!$this->iUserId)
259  return;
260 
261  $aStyles = $this->_oDb->getProfileByUserId($this->iUserId);
262  if (!empty($aStyles)) {
263  $this->_parseImages(unserialize($aStyles['css']), CH_PROFILE_CUSTOMIZE_IMAGES_DELETE);
264  $this->_parseImages(unserialize($aStyles['tmp']), CH_PROFILE_CUSTOMIZE_IMAGES_DELETE);
265  $this->_oDb->resetProfileStyleByUserId($this->iUserId);
266  }
267 
268  $sCss = '<style type="text/css">';
269  $sCss .= $this->_getCssFromArray($this->_oDb->getProfileCssByUserId($this->iUserId));
270  $sCss .= '</style>';
271 
272  header('Content-Type: text/html; charset=utf-8');
273  echo $this->_oTemplate->profilePage($this->iUserId, $sCss);
274  }
275 
280  function actionAdministration($sType = '', $iUnitId = '')
281  {
282  $iUnitId = (int)$iUnitId;
283 
284  if (!$this->isAdmin()) {
285  // TODO: show access denied
286  return;
287  }
288 
289  $this->_oTemplate->addAdminCss(array('forms_adv.css', 'main.css', 'admin.css'));
290  $this->_oTemplate->addAdminJs(array('main.js'));
291 
292  $this->_oTemplate->pageCodeAdmin (_t('_ch_profile_customize_administration'), $sType, $iUnitId, $this->_checkActions());
293  }
294 
299  function serviceGetCustomizeBlock($sPage = '', $sTarget = '')
300  {
301  if (!$this->iUserId || !getParam('ch_profile_customize_enable'))
302  return '';
303 
304  $sUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'customizepage/';
305  $aMenuItems = array('themes', 'background', 'font', 'border');
306  $aTopMenu = array();
307  $aTargets = array();
308 
309  if (!$sPage)
310  $sPage = $aMenuItems[0];
311 
312  foreach ($aMenuItems as $sItem) {
313  $aTopMenu[_t('_ch_profile_customize_page_' . $sItem)] = array(
314  'href' => $sUrl . $sItem,
315  'dynamic' => true,
316  'active' => $sItem == $sPage
317  );
318  }
319 
320  if (isset($this->_aCssMatch[$sPage])) {
321  if (!$sTarget)
322  $sTarget = key($this->_aCssMatch[$sPage]);
323 
324  foreach ($this->_aCssMatch[$sPage] as $sKey => $aValues) {
325  $aTargets[] = array(
326  'name' => _t($aValues['name']),
327  'value' => $sUrl . $sPage . '/' . $sKey,
328  'select' => $sKey == $sTarget ? 'selected' : ''
329  );
330  }
331  } else if ($sPage == 'themes') {
332  $aThemesTargets = array('my', 'shared');
333 
334  if (!$sTarget)
335  $sTarget = $aThemesTargets[0];
336 
337  foreach ($aThemesTargets as $sValue) {
338  $aTargets[] = array(
339  'name' => _t('_ch_profile_customize_page_themes_' . $sValue),
340  'value' => $sUrl . $sPage . '/' . $sValue,
341  'select' => $sValue == $sTarget ? 'selected' : ''
342  );
343  }
344  }
345 
346  $aVars = array();
347  $aStyle = $this->_oDb->getProfileTmpByUserId($this->iUserId);
348  if (!empty($aStyle) && isset($aStyle[$sPage][$sTarget]))
349  $aVars = $aStyle[$sPage][$sTarget];
350 
351  return $this->_oTemplate->profileCustomizeBlock($aTopMenu, $sPage, $aTargets, $sTarget, $aVars);
352  }
353 
354  function serviceGetProfileStyle($iUserId)
355  {
356  $iUserId = (int)$iUserId;
357 
358  if (!$iUserId || !getParam('ch_profile_customize_enable'))
359  return '';
360 
361  return $this->_getCssFromArray($this->_oDb->getProfileCssByUserId($iUserId));
362  }
363 
364  function isAdmin()
365  {
366  return isAdmin($this->iUserId);
367  }
368 
369  function _getImagesPath()
370  {
371  return CH_WSB_URL_MODULES . $this->_aModule['path'] . CH_PROFILE_CUSTOMIZE_DIR_IMAGES;
372  }
373 
374  function _getImagesDir()
375  {
376  return CH_DIRECTORY_PATH_MODULES . $this->_aModule['path'] . CH_PROFILE_CUSTOMIZE_DIR_IMAGES;
377  }
378 
379  function _addImage($sName)
380  {
381  if (isset($_FILES[$sName]) && is_uploaded_file($_FILES[$sName]['tmp_name'])) {
382  $sExt = pathinfo($_FILES[$sName]['name'], PATHINFO_EXTENSION);
383  if (strpos($_FILES[$sName]['type'], 'image') !== false && in_array($sExt, array ('gif', 'png', 'jpg', 'jpeg'))) {
384  $sFileName = $this->_oDb->addImage($sExt);
385  if ($sFileName) {
386  $sDestDir = $this->_getImagesDir();
387  if (move_uploaded_file($_FILES[$sName]['tmp_name'], $sDestDir . $sFileName)) {
388  imageResize($sDestDir . $sFileName, $sDestDir . CH_PROFILE_CUSTOMIZE_SMALL_PREFIX . $sFileName, 64, 64);
389  return $sFileName;
390  }
391  }
392  } else
393  unlink($_FILES[$sName]['tmp_name']);
394  }
395 
396  return '';
397  }
398 
399  function _deleteImage($sFileName)
400  {
401  if ($this->_oDb->deleteImage($sFileName)) {
402  $sDestDir = $this->_getImagesDir();
403  if (file_exists($sDestDir . $sFileName))
404  unlink($sDestDir . $sFileName);
405  if (file_exists($sDestDir . CH_PROFILE_CUSTOMIZE_SMALL_PREFIX . $sFileName))
406  unlink($sDestDir . CH_PROFILE_CUSTOMIZE_SMALL_PREFIX . $sFileName);
407  }
408  }
409 
410  function _convertFormVarToTmpStyle($sPage, $sTarget, $aVars, &$aResult, $bFiles = false)
411  {
412  foreach ($aVars as $sKey => $sValue) {
413  if ($bFiles)
414  $sValue = $this->_addImage($sKey);
415 
416  if ($sValue != '' && $sValue != 'default' && $sValue != '-1')
417  $aResult[$sPage][$sTarget][$sKey] = $sValue;
418  }
419  }
420 
421  function _getCssFromArray($aTmpStyle)
422  {
423  $bPageBackgroundChanged = false;
424  $sCss = '';
425 
426  if (empty($aTmpStyle))
427  return '';
428 
429  foreach ($aTmpStyle as $sKey => $aValue) {
430  if (!isset($this->_aCssMatch[$sKey]))
431  continue;
432 
433  foreach ($aValue as $sValKey => $aParam) {
434  if (!isset($this->_aCssMatch[$sKey][$sValKey]['css_name']))
435  continue;
436 
437  $sPartCss = $this->_aCssMatch[$sKey][$sValKey]['css_name'] . ' {';
438 
439  $sMethod = '_compile' . ucfirst($sKey);
440  $s = method_exists($this, $sMethod) ? call_user_func_array(array($this, $sMethod), array($aParam)) : '';
441  if ('body' == $sValKey && 'background' == $sKey && '' != $s && 'background-image: none;' != $s)
442  $bPageBackgroundChanged = true;
443  $sPartCss .= $s;
444 
445  $sPartCss .= ' }';
446  $sCss .= $sPartCss;
447  }
448  }
449 
450  if ($bPageBackgroundChanged)
451  $sCss .= ' html div.sys_root_bg {display:none;} ';
452 
453  return $sCss;
454  }
455 
456  function _getThemeFromTmp()
457  {
458  $aTmpStyle = $this->_oDb->getProfileTmpByUserId($this->iUserId);
459 
460  if (empty($aTmpStyle))
461  return '';
462 
464 
465  return serialize($aTmpStyle);
466  }
467 
468  function _parseImages($aCss, $iOperation)
469  {
470  if (empty($aCss))
471  return;
472 
473  foreach ($aCss as $sKey => $mixedValue) {
474  if (!is_array($mixedValue)) {
475  if ($sKey == 'image') {
476  switch ($iOperation) {
478  $this->_deleteImage($mixedValue);
479  break;
480 
482  $this->_oDb->copyImage($mixedValue);
483  break;
484  }
485  }
486  } else
487  $this->_parseImages($mixedValue, $iOperation);
488  }
489  }
490 
491  function _getImages($aCss)
492  {
493  $aResult = array();
494 
495  if (empty($aCss))
496  return $aResult;
497 
498  foreach ($aCss as $sKey => $mixedValue) {
499  if (!is_array($mixedValue)) {
500  if ($sKey == 'image')
501  $aResult[] = $mixedValue;
502  } else
503  $aResult = array_merge($aResult, $this->_getImages($mixedValue));
504  }
505 
506  return $aResult;
507  }
508 
509  function _importImages($aCss, $oZip, $aImages)
510  {
511  $aResult = array();
512 
513  if (empty($aCss))
514  return $aResult;
515 
516  foreach ($aCss as $sKey => $mixedValue) {
517  if (!is_array($mixedValue)) {
518  if ($sKey == 'image') {
519  $sExt = pathinfo($mixedValue, PATHINFO_EXTENSION);
520  $sFileName = $this->_oDb->addImage($sExt);
521  if ($sFileName) {
522  $sDestDir = $this->_getImagesDir();
523  $oFile = fopen($sDestDir . $sFileName, 'w', false);
524  if ($oFile) {
525  fwrite($oFile, $oZip->GetData($aImages[$mixedValue]));
526  fclose($oFile);
527  imageResize($sDestDir . $sFileName, $sDestDir . CH_PROFILE_CUSTOMIZE_SMALL_PREFIX . $sFileName, 64, 64);
528  $aResult[$sKey] = $sFileName;
529  }
530  }
531  } else
532  $aResult[$sKey] = $mixedValue;
533  } else
534  $aResult[$sKey] = $this->_importImages($mixedValue, $oZip, $aImages);
535  }
536 
537  return $aResult;
538  }
539 
540  function _saveCss()
541  {
542  $sTmpCss = $this->_getCssFromArray($this->_oDb->getProfileTmpByUserId($this->iUserId));
543  $this->_oDb->updateProfileCssByUserId($this->iUserId, $sTmpCss);
544  }
545 
546  function _deleteTheme($iThemeId)
547  {
548  $sResult = _t('_ch_profile_customize_err_delete_theme');
549 
550  if (!$iThemeId)
551  return $sResult;
552 
553  $aTheme = $this->_oDb->getThemeById($iThemeId);
554  if (!empty($aTheme) && $this->_oDb->deleteTheme($iThemeId)) {
556  if (file_exists($sFile))
557  unlink($sFile);
558  $this->_parseImages(unserialize($aTheme['css']), CH_PROFILE_CUSTOMIZE_IMAGES_DELETE);
559 
560  $sResult = _t('_ch_profile_customize_delete_complete');
561  }
562 
563  return $sResult;
564  }
565 
566  function _checkActions()
567  {
568  $sResult = '';
569  $sFileImport = 'theme_file';
570 
571  if ($_POST['theme']) {
572  if ($_POST['action_theme_export'])
573  $this->_exportTheme($_POST['theme']);
574 
575  if ($_POST['action_theme_delete'])
576  $sResult = $this->_deleteTheme($_POST['theme']);
577  } else if (isset($_FILES[$sFileImport]) && is_uploaded_file($_FILES[$sFileImport]['tmp_name'])) {
578  $sResult = $this->_importTheme($sFileImport);
579  unlink($_FILES[$sFileImport]['tmp_name']);
580  }
581 
582  return $sResult;
583  }
584 
585  function _exportTheme($iThemeId)
586  {
587  $aTheme = $this->_oDb->getThemeById($iThemeId);
588 
589  if (empty($aTheme))
590  return;
591 
592  $sConf = "\$sThemeName = '{$aTheme['name']}';\n";
593  $sConf .= "\$sThemeStyle = '{$aTheme['css']}';\n";
594 
595  $sImagesPath = $this->_getImagesDir();
596  $oZipFile = new zipfile();
597 
598  $oZipFile->addFile($sConf, CH_PROFILE_CUSTOMIZE_THEME_CONF);
600  if (file_exists($sFile)) {
601  $oData = implode("", file($sFile));
602  $oZipFile->addFile($oData, CH_PROFILE_CUSTOMIZE_THEME_THUMB);
603  }
604 
605  $aImages = $this->_getImages(unserialize($aTheme['css']));
606  foreach ($aImages as $sImage) {
607  $sFile = $sImagesPath . $sImage;
608  if (file_exists($sFile)) {
609  $oData = implode("", file($sFile));
610  $oZipFile->addFile($oData, 'images/' . $sImage);
611  }
612  }
613 
614  header("Content-type: application/octet-stream");
615  header("Content-disposition: attachment; filename={$aTheme['name']}.dfn");
616  echo $oZipFile->file();
617  exit;
618  }
619 
620  function _importTheme($sFileImport)
621  {
622  $sResult = '';
623  $sDestDir = $this->_getImagesDir();
624 
625  if (!$sFileImport)
626  return $sResult;
627 
628  if (pathinfo($_FILES[$sFileImport]['name'], PATHINFO_EXTENSION) != 'dfn')
629  return _t('_ch_profile_customize_err_format');
630 
631  $oUnZip = new SimpleUnzip($_FILES[$sFileImport]['tmp_name']);
632  $aFiles = $this->_getZipFilesFromPath($oUnZip, '');
633 
634  // check exist 'conf.php'
635  if (!isset($aFiles[CH_PROFILE_CUSTOMIZE_THEME_CONF]))
636  return sprintf(_t('_ch_profile_customize_err_conf_php'), 'conf.php');
637 
638  eval($oUnZip->GetData($aFiles[CH_PROFILE_CUSTOMIZE_THEME_CONF]));
639 
640  // check parameters
641  if (!isset($sThemeName) || !isset($sThemeStyle))
642  return _t('_ch_profile_customize_err_theme_parameters');
643 
644  // check exist theme
645  $aTheme = $this->_oDb->getThemeByName($sThemeName);
646  if (!empty($aTheme))
647  return sprintf(_t('_ch_profile_customize_err_already_exist'), $sThemeName);
648 
649  $aStyle = unserialize($sThemeStyle);
650  $aImages = $this->_getZipFilesFromPath($oUnZip, 'images');
651  if(!empty($aImages))
652  $aStyle = $this->_importImages($aStyle, $oUnZip, $aImages);
653 
654  // insert in table
655  $iThemeId = $this->_oDb->addTheme($sThemeName, 0, serialize($aStyle));
656  if ($iThemeId == -1)
657  return _t('_ch_profile_customize_err_add_theme');
658 
659  // copy thumbnail
660  if (isset($aFiles[CH_PROFILE_CUSTOMIZE_THEME_THUMB])) {
662 
663  $oFile = fopen($sDestDir . $sThumbName, 'w', false);
664  if ($oFile) {
665  fwrite($oFile, $oUnZip->GetData($aFiles[CH_PROFILE_CUSTOMIZE_THEME_THUMB]));
666  fclose($oFile);
667  }
668  }
669 
670  return _t('_ch_profile_customize_import_complete');
671  }
672 
673  function _getZipFilesFromPath($oZipFile, $sPath = '')
674  {
675  $aFiles = array();
676 
677  for ($i = 0; $i < $oZipFile->Count(); $i++) {
678  if ($oZipFile->GetPath($i) == $sPath)
679  $aFiles[$oZipFile->GetName($i)] = $i;
680  }
681 
682  return $aFiles;
683  }
684 
685  function _compileBackground($aParam)
686  {
687  $sParams = '';
688 
689  foreach ($aParam as $sKey => $sValue) {
690  if (!$sValue)
691  continue;
692 
693  switch ($sKey) {
694  case 'color':
695  $sParams .= 'background-color: ' . $sValue . ';';
696  if (!isset($aParam['image']))
697  $sParams .= 'background-image: none;';
698  break;
699 
700  case 'image':
701  if (isset($aParam['useimage']))
702  $sParams .= 'background-image: url(' . $this->_getImagesPath() . $sValue . ');';
703  else
704  $sParams .= 'background-image: none;';
705  break;
706 
707  case 'repeat':
708  $sParams .= 'background-repeat: ' . $sValue . ';';
709  break;
710 
711  case 'position':
712  $sParams .= 'background-position: ' . $sValue . ';';
713  break;
714  }
715  }
716 
717  return $sParams;
718  }
719 
720  function _compileFont($aParam)
721  {
722  $sParams = '';
723 
724  foreach ($aParam as $sKey => $sValue) {
725  if ($sValue == '')
726  continue;
727 
728  switch ($sKey) {
729  case 'size':
730  $sParams .= 'font-size: ' . $sValue . 'px;';
731  break;
732 
733  case 'color':
734  $sParams .= 'color: ' . $sValue . ';';
735  break;
736 
737  case 'name':
738  $sParams .= 'font-family: ' . $sValue . ';';
739  break;
740 
741  case 'style':
742  switch ($sValue) {
743  case 'normal':
744  $sParams .= 'font-style: normal;';
745  break;
746 
747  case 'bold':
748  $sParams .= 'font-weight: bold;';
749  break;
750 
751  case 'italic':
752  $sParams .= 'font-style: italic;';
753  break;
754  }
755  }
756  }
757 
758  return $sParams;
759  }
760 
761  function _compileBorder($aParam)
762  {
763  $sParams = '';
764  $aProperties = array(
765  'border'
766  );
767 
768  if (isset($aParam['position']))
769  switch($aParam['position']) {
770  case 'top':
771  $aProperties = array(
772  'border-top'
773  );
774  break;
775 
776  case 'right':
777  $aProperties = array(
778  'border-right'
779  );
780  break;
781 
782  case 'bottom':
783  $aProperties = array(
784  'border-bottom'
785  );
786  break;
787 
788  case 'left':
789  $aProperties = array(
790  'border-left'
791  );
792  break;
793 
794  case 'left_right':
795  $aProperties = array(
796  'border-left',
797  'border-right'
798  );
799  break;
800 
801  case 'top_bottom':
802  $aProperties = array(
803  'border-top',
804  'border-bottom'
805  );
806  break;
807 
808  case 'top_right':
809  $aProperties = array(
810  'border-top',
811  'border-right'
812  );
813  break;
814 
815  case 'right_bottom':
816  $aProperties = array(
817  'border-right',
818  'border-bottom'
819  );
820  break;
821 
822  case 'bottom_left':
823  $aProperties = array(
824  'border-bottom',
825  'border-left'
826  );
827  break;
828 
829  case 'left_top':
830  $aProperties = array(
831  'border-left',
832  'border-top'
833  );
834  break;
835  }
836 
837  foreach ($aParam as $sKey => $sValue) {
838  $sProperty = '';
839  if ($sValue == '')
840  continue;
841 
842  switch ($sKey) {
843  case 'size':
844  foreach ($aProperties as $sVal)
845  $sParams .= $sVal . '-width: ' . $sValue . 'px;';
846  break;
847 
848  case 'color':
849  foreach ($aProperties as $sVal)
850  $sParams .= $sVal . '-color: ' . $sValue . ';';
851  break;
852 
853  case 'style':
854  foreach ($aProperties as $sVal)
855  $sParams .= $sVal . '-style: ' . $sValue . ';';
856  break;
857  }
858  }
859 
860  return $sParams;
861  }
862 }
ChProfileCustomizeModule
Definition: ChProfileCustomizeModule.php:65
process_db_input
process_db_input($sText, $iStripTags=0)
Definition: utils.inc.php:256
ChProfileCustomizeModule\actionSave
actionSave($isReset='')
Definition: ChProfileCustomizeModule.php:87
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
ch_profile_customize_import
ch_profile_customize_import($sClassPostfix, $aModuleOverwright=array())
Definition: ChProfileCustomizeModule.php:24
ChProfileCustomizeModule\_compileBorder
_compileBorder($aParam)
Definition: ChProfileCustomizeModule.php:761
ChProfileCustomizeModule\_parseImages
_parseImages($aCss, $iOperation)
Definition: ChProfileCustomizeModule.php:468
ChProfileCustomizeModule\_importImages
_importImages($aCss, $oZip, $aImages)
Definition: ChProfileCustomizeModule.php:509
ChProfileCustomizeModule\_compileFont
_compileFont($aParam)
Definition: ChProfileCustomizeModule.php:720
ChProfileCustomizeModule\serviceGetProfileStyle
serviceGetProfileStyle($iUserId)
Definition: ChProfileCustomizeModule.php:354
CH_PROFILE_CUSTOMIZE_THUMB_EXT
const CH_PROFILE_CUSTOMIZE_THUMB_EXT
Definition: ChProfileCustomizeModule.php:16
ChWsbModule\getInstance
static getInstance($sClassName)
Definition: ChWsbModule.php:89
$sResult
$sResult
Definition: advanced_settings.php:26
ChProfileCustomizeModule\_addImage
_addImage($sName)
Definition: ChProfileCustomizeModule.php:379
$aModule
$aModule
Definition: classifieds.php:21
CH_PROFILE_CUSTOMIZE_SMALL_PREFIX
const CH_PROFILE_CUSTOMIZE_SMALL_PREFIX
Definition: ChProfileCustomizeModule.php:14
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
$aResult
$aResult
Definition: index.php:19
ChProfileCustomizeModule\actionResetAll
actionResetAll()
Definition: ChProfileCustomizeModule.php:256
ChProfileCustomizeModule\actionPublish
actionPublish($isSave='')
Definition: ChProfileCustomizeModule.php:171
$sUrl
$sUrl
Definition: cart.php:15
php
$sExt
$sExt
Definition: get_file.php:14
CH_PROFILE_CUSTOMIZE_IMAGES_COPY
const CH_PROFILE_CUSTOMIZE_IMAGES_COPY
Definition: ChProfileCustomizeModule.php:20
ChProfileCustomizeModule\_getImagesPath
_getImagesPath()
Definition: ChProfileCustomizeModule.php:369
ChProfileCustomizeModule\_deleteTheme
_deleteTheme($iThemeId)
Definition: ChProfileCustomizeModule.php:546
ChProfileCustomizeModule\_checkActions
_checkActions()
Definition: ChProfileCustomizeModule.php:566
ChProfileCustomizeModule\actionDeleteTheme
actionDeleteTheme($iThemeId)
Definition: ChProfileCustomizeModule.php:245
ChProfileCustomizeModule\isAdmin
isAdmin()
Definition: ChProfileCustomizeModule.php:364
ChProfileCustomizeModule\_getCssFromArray
_getCssFromArray($aTmpStyle)
Definition: ChProfileCustomizeModule.php:421
ChProfileCustomizeModule\actionProfileBlock
actionProfileBlock($sAction='', $iTheme='')
Definition: ChProfileCustomizeModule.php:135
exit
exit
Definition: cart.php:21
$sType
$sType
Definition: actions.inc.php:11
$sFile
$sFile
Definition: index.php:20
ChProfileCustomizeModule\_getImages
_getImages($aCss)
Definition: ChProfileCustomizeModule.php:491
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
ChProfileCustomizeModule\_compileBackground
_compileBackground($aParam)
Definition: ChProfileCustomizeModule.php:685
ChProfileCustomizeModule\__construct
__construct($aModule)
Definition: ChProfileCustomizeModule.php:71
CH_PROFILE_CUSTOMIZE_THEME_THUMB
const CH_PROFILE_CUSTOMIZE_THEME_THUMB
Definition: ChProfileCustomizeModule.php:18
ChProfileCustomizeModule\_deleteImage
_deleteImage($sFileName)
Definition: ChProfileCustomizeModule.php:399
ChProfileCustomizeModule\_exportTheme
_exportTheme($iThemeId)
Definition: ChProfileCustomizeModule.php:585
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
ChWsbModule
Definition: ChWsbModule.php:41
ChProfileCustomizeModule\serviceGetCustomizeBlock
serviceGetCustomizeBlock($sPage='', $sTarget='')
Definition: ChProfileCustomizeModule.php:299
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
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
ChProfileCustomizeModule\_getThemeFromTmp
_getThemeFromTmp()
Definition: ChProfileCustomizeModule.php:456
CH_PROFILE_CUSTOMIZE_IMAGES_DELETE
const CH_PROFILE_CUSTOMIZE_IMAGES_DELETE
Definition: ChProfileCustomizeModule.php:19
CH_TAGS_STRIP
const CH_TAGS_STRIP
Definition: utils.inc.php:22
SimpleUnzip
Definition: unzip.lib.php:48
zipfile
Definition: zip.lib.php:28
ChProfileCustomizeModule\actionAdministration
actionAdministration($sType='', $iUnitId='')
Definition: ChProfileCustomizeModule.php:280
$aVars
$aVars
Definition: license.php:101
$s
$s
Definition: embed.php:13
ChProfileCustomizeModule\_importTheme
_importTheme($sFileImport)
Definition: ChProfileCustomizeModule.php:620
$sImagesPath
$sImagesPath
Definition: header.inc.php:94
CH_PROFILE_CUSTOMIZE_THEME_CONF
const CH_PROFILE_CUSTOMIZE_THEME_CONF
Definition: ChProfileCustomizeModule.php:17
ChProfileCustomizeModule\actionSaveTheme
actionSaveTheme($iThemeId)
Definition: ChProfileCustomizeModule.php:214
ChProfileCustomizeModule\_getZipFilesFromPath
_getZipFilesFromPath($oZipFile, $sPath='')
Definition: ChProfileCustomizeModule.php:673
ChProfileCustomizeModule\_getImagesDir
_getImagesDir()
Definition: ChProfileCustomizeModule.php:374
$sAction
$sAction
Definition: categories.php:274
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
ChProfileCustomizeModule\actionCustomizePage
actionCustomizePage($sPage='', $sTarget='')
Definition: ChProfileCustomizeModule.php:81
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChProfileCustomizeModule\$_aCssMatch
$_aCssMatch
Definition: ChProfileCustomizeModule.php:66
ChProfileCustomizeModule\_saveCss
_saveCss()
Definition: ChProfileCustomizeModule.php:540
$sName
$sName
Definition: ChWsbAdminTools.php:853
ChProfileCustomizeModule\_convertFormVarToTmpStyle
_convertFormVarToTmpStyle($sPage, $sTarget, $aVars, &$aResult, $bFiles=false)
Definition: ChProfileCustomizeModule.php:410
CH_PROFILE_CUSTOMIZE_THEME_PREFIX
const CH_PROFILE_CUSTOMIZE_THEME_PREFIX
Definition: ChProfileCustomizeModule.php:15
CH_PROFILE_CUSTOMIZE_DIR_IMAGES
const CH_PROFILE_CUSTOMIZE_DIR_IMAGES
Definition: ChProfileCustomizeModule.php:13