Cheetah
ChWsbTemplate.php
Go to the documentation of this file.
1 <?php
2 
8 ini_set('pcre.backtrack_limit', 1000000);
9 
10 define('CH_WSB_TEMPLATE_DEFAULT_CODE', 'uni');
11 define('CH_WSB_TEMPLATE_FOLDER_ROOT', 'templates');
12 define('CH_WSB_TEMPLATE_FOLDER_BASE', 'base');
13 
14 define('CH_WSB_TEMPLATE_INJECTIONS_CACHE', 'sys_injections.inc');
15 
16 define('CH_WSB_TEMPLATE_CHECK_IN_BOTH', 'both');
17 define('CH_WSB_TEMPLATE_CHECK_IN_BASE', 'base');
18 define('CH_WSB_TEMPLATE_CHECK_IN_TMPL', 'tmpl');
19 
121 {
130  var $_sCode;
138 
141 
158 
162  function __construct($sRootPath = CH_DIRECTORY_PATH_ROOT, $sRootUrl = CH_WSB_URL_ROOT)
163  {
164  $this->_sPrefix = 'ChWsbTemplate';
165 
166  $this->_sRootPath = $sRootPath;
167  $this->_sRootUrl = $sRootUrl;
168  $this->_sInjectionsTable = 'sys_injections';
169  $this->_sInjectionsCache = CH_WSB_TEMPLATE_INJECTIONS_CACHE;
170 
171  $this->_sCodeKey = 'skin';
172  $this->_sCode = $GLOBALS['MySQL']->getParam('template');
173  if(empty($this->_sCode))
174  $this->_sCode = CH_WSB_TEMPLATE_DEFAULT_CODE;
175 
176  //--- Check selected template in COOKIE(the lowest priority) ---//
177  $sCode = empty($_COOKIE[$this->_sCodeKey]) ? '' : $_COOKIE[$this->_sCodeKey];
178  if (!empty($sCode) && preg_match('/^[A-Za-z0-9_-]+$/', $sCode) && file_exists($this->_sRootPath . 'templates/tmpl_' . $sCode) && !is_file($this->_sRootPath . 'templates/tmpl_' . $sCode))
179  $this->_sCode = $sCode;
180 
181  //--- Check selected template in GET(the highest priority) ---//
182  $sCode = empty($_GET[$this->_sCodeKey]) ? '' : $_GET[$this->_sCodeKey];
183  if(!empty($sCode) && preg_match('/^[A-Za-z0-9_-]+$/', $sCode) && file_exists($this->_sRootPath . 'templates/tmpl_' . $sCode) && !is_file($this->_sRootPath . 'templates/tmpl_' . $sCode)) {
184  $this->_sCode = $sCode;
185 
186  $aUrl = parse_url($GLOBALS['site']['url']);
187  $sPath = isset($aUrl['path']) && !empty($aUrl['path']) ? $aUrl['path'] : '/';
188 
189  if (!ch_get('preview'))
190  setcookie( $this->_sCodeKey, $this->_sCode, time() + 60*60*24*365, $sPath);
191 
192  if (isset($_GET[$this->_sCodeKey])) {
193  ch_import('ChWsbPermalinks');
194  $oPermalinks = new ChWsbPermalinks();
195  if ($oPermalinks->redirectIfNecessary(array($this->_sCodeKey)))
196  exit;
197  }
198 
199  }
200 
201  $this->_sKeyWrapperHtml = '__';
202  $this->_sFolderHtml = '';
203  $this->_sFolderCss = 'css/';
204  $this->_sFolderImages = 'images/';
205  $this->_sFolderIcons = 'images/icons/';
206  $this->_aTemplates = array();
207 
208  $this->addLocation('system', $this->_sRootPath, $this->_sRootUrl);
209 
210  $this->addLocationJs('system_inc_js', CH_DIRECTORY_PATH_INC . 'js/' , CH_WSB_URL_ROOT . 'inc/js/');
211  $this->addLocationJs('system_inc_js_classes', CH_DIRECTORY_PATH_INC . 'js/classes/' , CH_WSB_URL_ROOT . 'inc/js/classes/');
212  $this->addLocationJs('system_plugins', CH_DIRECTORY_PATH_PLUGINS, CH_WSB_URL_PLUGINS);
213  $this->addLocationJs('system_plugins_jquery', CH_DIRECTORY_PATH_PLUGINS . 'jquery/' , CH_WSB_URL_PLUGINS . 'jquery/');
214  $this->addLocationJs('system_plugins_tinymce', CH_DIRECTORY_PATH_PLUGINS . 'tiny_mce/' , CH_WSB_URL_PLUGINS . 'tiny_mce/');
215 
216  $this->_bCacheEnable = !defined('CH_WSB_CRON_EXECUTE') && getParam('sys_template_cache_enable') == 'on';
217  $this->_sCacheFolderUrl = '';
218  $this->_sCachePublicFolderUrl = CH_WSB_URL_CACHE_PUBLIC;
219  $this->_sCachePublicFolderPath = CH_DIRECTORY_PATH_CACHE_PUBLIC;
220  $this->_sCacheFilePrefix = "ch_templ_";
221 
222  $this->_bImagesInline = getParam('sys_template_cache_image_enable') == 'on';
223  $this->_iImagesMaxSize = (int)getParam('sys_template_cache_image_max_size') * 1024;
224 
225  $bArchive = getParam('sys_template_cache_compress_enable') == 'on';
226  $this->_bCssCache = !defined('CH_WSB_CRON_EXECUTE') && getParam('sys_template_cache_css_enable') == 'on';
227  $this->_bCssArchive = $this->_bCssCache && $bArchive;
228  $this->_sCssCachePrefix = $this->_sCacheFilePrefix . 'css_';
229 
230  $this->_bJsCache = !defined('CH_WSB_CRON_EXECUTE') && getParam('sys_template_cache_js_enable') == 'on';
231  $this->_bJsArchive = $this->_bJsCache && $bArchive;
232  $this->_sJsCachePrefix = $this->_sCacheFilePrefix . 'js_';
233  }
238  function loadTemplates()
239  {
240  $aResult = array();
241  foreach($this->_aTemplates as $sName)
242  $aResult[$sName] = $this->getHtml($sName . '.html');
243  $this->_aTemplates = $aResult;
244  }
249  function init()
250  {
251  //--- Load injection's cache ---//
252  $oCache = $GLOBALS['MySQL']->getDbCacheObject();
253  $aInjections = $oCache->getData($GLOBALS['MySQL']->genDbCacheKey($this->_sInjectionsCache));
254  if (null === $aInjections) {
255  $rInjections = db_res("SELECT `page_index`, `name`, `key`, `type`, `data`, `replace` FROM `" . $this->_sInjectionsTable . "` WHERE `active`='1'");
256  while($aInjection = $rInjections->fetch())
257  $aInjections['page_' . $aInjection['page_index']][$aInjection['key']][] = $aInjection;
258 
259  $oCache->setData ($GLOBALS['MySQL']->genDbCacheKey($this->_sInjectionsCache), $aInjections);
260  }
261 
262  $GLOBALS[$this->_sPrefix . 'Injections'] = isset($GLOBALS[$this->_sPrefix . 'Injections']) ? array_merge_recursive ($GLOBALS[$this->_sPrefix . 'Injections'], $aInjections) : $aInjections;
263 
264  //--- Load page elements related static variables ---//
265  $GLOBALS[$this->_sPrefix . 'PageKeywords'] = array();
266  $GLOBALS[$this->_sPrefix . 'OG'] = array();
267 
268  $GLOBALS[$this->_sPrefix . 'Js'] = array();
269  $GLOBALS[$this->_sPrefix . 'JsSystem'] = array();
270 
271  $GLOBALS[$this->_sPrefix . 'Css'] = array();
272  $GLOBALS[$this->_sPrefix . 'CssSystem'] = array();
273  $GLOBALS[$this->_sPrefix . 'CssStyles'] = array();
274  $GLOBALS[$this->_sPrefix . 'CssAsync'] = array();
275 
276  $this->setPageWidth(getParam('main_div_width'));
277  $this->setPageTitle('');
278  $this->setPageMainBoxTitle('');
279  $this->setPageDescription('');
280  }
281 
290  function addLocation($sKey, $sLocationPath, $sLocationUrl)
291  {
292  $this->_aLocations[$sKey] = array(
293  'path' => $sLocationPath . CH_WSB_TEMPLATE_FOLDER_ROOT . DIRECTORY_SEPARATOR,
294  'url' => $sLocationUrl . CH_WSB_TEMPLATE_FOLDER_ROOT . '/'
295  );
296  }
304  function addDynamicLocation($sLocationPath, $sLocationUrl)
305  {
306  $sLocationKey = time();
307  $this->addLocation($sLocationKey, $sLocationPath, $sLocationUrl);
308 
309  return $sLocationKey;
310  }
317  function removeLocation($sKey)
318  {
319  if(isset($this->_aLocations[$sKey]))
320  unset($this->_aLocations[$sKey]);
321  }
330  function addLocationJs($sKey, $sLocationPath, $sLocationUrl)
331  {
332  $this->_aLocationsJs[$sKey] = array(
333  'path' => $sLocationPath,
334  'url' => $sLocationUrl
335  );
336  }
344  function addDynamicLocationJs($sLocationPath, $sLocationUrl)
345  {
346  $sLocationKey = time();
347  $this->addLocationJs($sLocationKey, $sLocationPath, $sLocationUrl);
348 
349  return $sLocationKey;
350  }
357  function removeLocationJs($sKey)
358  {
359  if(isset($this->_aLocationsJs[$sKey]))
360  unset($this->_aLocationsJs[$sKey]);
361  }
367  function getCodeKey()
368  {
369  return $this->_sCodeKey;
370  }
376  function getCode()
377  {
378  return isset($GLOBALS['iAdminPage']) && (int)$GLOBALS['iAdminPage'] == 1 ? CH_WSB_TEMPLATE_DEFAULT_CODE : $this->_sCode;
379  }
385  function getPageWidth()
386  {
387  return $GLOBALS[$this->_sPrefix . 'PageWidth'];
388  }
394  function setPageWidth($sWidth)
395  {
396  $GLOBALS[$this->_sPrefix . 'PageWidth'] = $sWidth;
397 
398  $this->addCssStyle('.sys_main_page_width', array(
399  'max-width' => $GLOBALS[$this->_sPrefix . 'PageWidth']
400  ));
401  }
408  {
409  $GLOBALS[$this->_sPrefix . 'PageTitle'] = $sTitle;
410  }
417  {
418  $GLOBALS[$this->_sPrefix . 'PageMainBoxTitle'] = $sTitle;
419  }
425  function setPageDescription($sDescription)
426  {
427  $GLOBALS[$this->_sPrefix . 'PageDescription'] = $sDescription;
428  }
434  function addJsOption($mixedName)
435  {
436  if(is_string($mixedName))
437  $mixedName = array($mixedName);
438 
439  foreach($mixedName as $sName)
440  $GLOBALS['ChWsbTemplateJsOptions'][$sName] = $GLOBALS['MySQL']->getParam($sName);
441  }
447  function addJsTranslation($mixedKey)
448  {
449  if(is_string($mixedKey))
450  $mixedKey = array($mixedKey);
451 
452  foreach($mixedKey as $sKey)
453  $GLOBALS['ChWsbTemplateJsTranslations'][$sKey] = _t($sKey, '{0}', '{1}');
454  }
461  function addJsImage($aImages)
462  {
463  if(!is_array($aImages))
464  return;
465 
466  foreach($aImages as $sKey => $sFile) {
467  $sUrl = $this->getImageUrl($sFile);
468  if(empty($sUrl))
469  continue;
470 
471  $GLOBALS['ChWsbTemplateJsImages'][$sKey] = $sUrl;
472  }
473  }
480  function addJsIcon($aIcons)
481  {
482  if(!is_array($aIcons))
483  return;
484 
485  foreach($aIcons as $sKey => $sFile) {
486  $sUrl = $this->getIconUrl($sFile);
487  if(empty($sUrl))
488  continue;
489 
490  $GLOBALS[$this->_sPrefix . 'JsImages'][$sKey] = $sUrl;
491  }
492  }
500  {
501  $GLOBALS[$this->_sPrefix . 'CssStyles'][$sName] = $sContent;
502  }
509  function addPageKeywords($mixedKeywords, $sDevider = ',')
510  {
511  if (!$mixedKeywords)
512  return;
513 
514  if(is_string($mixedKeywords))
515  $mixedKeywords = strpos($mixedKeywords, $sDevider) !== false ? explode($sDevider, $mixedKeywords) : array($mixedKeywords);
516 
517  foreach($mixedKeywords as $iKey => $sValue)
518  $mixedKeywords[$iKey] = trim($sValue);
519 
520  $GLOBALS[$this->_sPrefix . 'PageKeywords'] = array_merge($GLOBALS[$this->_sPrefix . 'PageKeywords'], $mixedKeywords);
521  }
527  function setOpenGraphInfo($a, $sNamespace = 'og')
528  {
529  $GLOBALS[$this->_sPrefix . 'OG'][$sNamespace] = array_merge(isset($GLOBALS[$this->_sPrefix . 'OG'][$sNamespace]) ? $GLOBALS[$this->_sPrefix . 'OG'][$sNamespace] : array(), $a);
530  }
534  function getMetaInfo()
535  {
536  $sRet = '';
537 
538  if (!empty($GLOBALS[$this->_sPrefix . 'PageKeywords']) && is_array($GLOBALS[$this->_sPrefix . 'PageKeywords']) && $GLOBALS[$this->_sPrefix . 'PageKeywords'])
539  $sRet .= '<meta name="keywords" content="' . ch_html_attribute(implode(',', $GLOBALS[$this->_sPrefix . 'PageKeywords'])) . "\" />\n";
540 
541  if (!empty($GLOBALS[$this->_sPrefix . 'PageDescription']) && is_string($GLOBALS[$this->_sPrefix . 'PageDescription']))
542  $sRet .= '<meta name="description" content="' . ch_html_attribute($GLOBALS[$this->_sPrefix . 'PageDescription']) . "\" />\n";
543 
544  if (!empty($GLOBALS[$this->_sPrefix . 'OG']))
545  foreach ($GLOBALS[$this->_sPrefix . 'OG'] as $sNamespace => $a)
546  foreach ($a as $k => $s)
547  $sRet .= '<meta property="' . ($sNamespace ? $sNamespace . ':' : '') . $k . '" content="' . ch_html_attribute($s) . "\" />\n";
548 
549  return $sRet;
550  }
558  function getTemplate($sName)
559  {
560  return $this->_aTemplates[$sName];
561  }
570  {
571  $sContent = "";
572  if(($sContent = $this->_getInlineData('icon', $sName, $sCheckIn)) !== false)
573  return $sContent;
574 
575  return $this->_getAbsoluteLocation('url', $this->_sFolderIcons, $sName, $sCheckIn);
576  }
585  {
586  return $this->_getAbsoluteLocation('path', $this->_sFolderIcons, $sName, $sCheckIn);
587  }
596  {
597  $sContent = "";
598  if(($sContent = $this->_getInlineData('image', $sName, $sCheckIn)) !== false)
599  return $sContent;
600 
601  return $this->_getAbsoluteLocation('url', $this->_sFolderImages, $sName, $sCheckIn);
602  }
611  {
612  return $this->_getAbsoluteLocation('path', $this->_sFolderImages, $sName, $sCheckIn);
613  }
622  {
623  return $this->_getAbsoluteLocation('url', $this->_sFolderCss, $sName, $sCheckIn);
624  }
633  {
634  return $this->_getAbsoluteLocation('path', $this->_sFolderCss, $sName, $sCheckIn);
635  }
644  {
645  $sAbsolutePath = $this->_getAbsoluteLocation('path', $this->_sFolderHtml, $sName, $sCheckIn);
646  return !empty($sAbsolutePath) ? file_get_contents($sAbsolutePath) : false;
647  }
648 
660  function parseHtmlByName($sName, $aVariables, $mixedKeyWrapperHtml = null, $sCheckIn = CH_WSB_TEMPLATE_CHECK_IN_BOTH)
661  {
662  if (isset($GLOBALS['ch_profiler'])) $GLOBALS['ch_profiler']->beginTemplate($sName, $sRand = time().rand());
663 
664  if (($sContent = $this->getCached($sName, $aVariables, $mixedKeyWrapperHtml, $sCheckIn)) !== false) {
665  if (isset($GLOBALS['ch_profiler'])) $GLOBALS['ch_profiler']->endTemplate($sName, $sRand, $sRet, true);
666  return $sContent;
667  }
668 
669  $sRet = '';
670  if (($sContent = $this->getHtml($sName, $sCheckIn)) !== false)
671  $sRet = $this->_parseContent($sContent, $aVariables, $mixedKeyWrapperHtml);
672 
673  if (isset($GLOBALS['ch_profiler'])) $GLOBALS['ch_profiler']->endTemplate($sName, $sRand, $sRet, false);
674 
675  return $sRet;
676  }
687  function parseHtmlByContent($sContent, $aVariables, $mixedKeyWrapperHtml = null)
688  {
689  if(empty($sContent))
690  return "";
691 
692  return $this->_parseContent($sContent, $aVariables, $mixedKeyWrapperHtml);
693  }
704  function parseHtmlByTemplateName($sName, $aVariables, $mixedKeyWrapperHtml = null)
705  {
706  if(!isset($this->_aTemplates[$sName]) || empty($this->_aTemplates[$sName]))
707  return "";
708 
709  return $this->_parseContent($this->_aTemplates[$sName], $aVariables, $mixedKeyWrapperHtml);
710  }
720  function parsePageByName($sName, $aVariables)
721  {
722  if (isset($GLOBALS['ch_profiler'])) $GLOBALS['ch_profiler']->beginPage($sName);
723 
724  // add facebook meta tag
725  if ($sFbId = getParam('ch_facebook_connect_api_key'))
726  $this->setOpenGraphInfo(array('app_id' => $sFbId), 'fb');
727 
728  $sContent = $this->parseHtmlByName($sName, $aVariables, $this->_sKeyWrapperHtml, CH_WSB_TEMPLATE_CHECK_IN_BOTH);
729  if(empty($sContent))
730  $sContent = $this->parseHtmlByName('default.html', $aVariables, $this->_sKeyWrapperHtml, CH_WSB_TEMPLATE_CHECK_IN_BOTH);
731 
732  //--- Add CSS and JS at the very last ---//
733  if(strpos($sContent, '<ch_include_css_styles />') !== false)
734  $sContent = str_replace('<ch_include_css_styles />', $this->includeCssStyles(), $sContent);
735 
736  if(strpos($sContent , '<ch_include_css />') !== false) {
737  if (!empty($GLOBALS['_page']['css_name'])) {
738  $this->addCss($GLOBALS['_page']['css_name']);
739  }
740  $sContent = str_replace('<ch_include_css />', $this->includeFiles('css', true) . $this->includeFiles('css'), $sContent);
741  }
742 
743  if(strpos($sContent , '<ch_include_js />') !== false) {
744  if (!empty($GLOBALS['_page']['js_name'])) {
745  $this->addJs($GLOBALS['_page']['js_name']);
746  }
747  $sContent = str_replace('<ch_include_js />', $this->includeFiles('js', true) . $this->includeFiles('js') . $this->includeCssAsync(), $sContent);
748  }
749 
750  if (isset($GLOBALS['ch_profiler'])) $GLOBALS['ch_profiler']->endPage($sContent);
751 
752  return $sContent;
753  }
760  function parseSystemKey($sKey, $mixedKeyWrapperHtml = null)
761  {
762  global $site;
763  global $_page;
766  global $logged;
767 
768  $aKeyWrappers = $this->_getKeyWrappers($mixedKeyWrapperHtml);
769 
770  $sRet = '';
771  switch( $sKey ) {
772  case 'dir':
773  $a = ch_lang_info();
774  return $a['Direction'];
775  case 'page_charset':
776  $sRet = 'UTF-8';
777  break;
778  case 'meta_info':
779  $sRet = $this->getMetaInfo();
780  break;
781  case 'page_header':
782  if (!empty($GLOBALS[$this->_sPrefix . 'PageTitle']))
783  $sRet = $GLOBALS[$this->_sPrefix . 'PageTitle'];
784  else if (isset($_page['header']))
785  $sRet = $_page['header'];
787  $bOk = true;
788  if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
789  $bOk = false;
790  if ($_SERVER['HTTP_USER_AGENT'] == '')
791  $bOk = false;
792  if (!$iProfileId)
793  $bOk = false;
794  if (!$sRet)
795  $bOk = false;
796  if ($sRet == 'Page was not found')
797  $bOk = false;
798  if ($bOk) {
799  $sQuery = "UPDATE `Profiles` SET `DateLastPage` = NOW(), `CurrentPageTitle` = ? WHERE `ID` = '{$iProfileId}'";
800  db_res($sQuery, [$sRet]);
801  }
802  break;
803  case 'page_header_text':
804  if(!empty($GLOBALS[$this->_sPrefix . 'PageMainBoxTitle']))
805  $sRet = $GLOBALS[$this->_sPrefix . 'PageMainBoxTitle'];
806  else if(isset($_page['header_text']))
807  $sRet = $_page['header_text'];
808  break;
809  case 'main_div_width':
810  if(!empty($GLOBALS[$this->_sPrefix . 'PageWidth']))
811  $sRet = process_line_output($GLOBALS[$this->_sPrefix . 'PageWidth']);
812  break;
813  case 'main_logo':
814  $sRet = $GLOBALS['oFunctions']->genSiteLogo();
815  break;
816  case 'main_splash':
817  $sRet = $GLOBALS['oFunctions']->genSiteSplash();
818  break;
819  case 'main_search':
820  $sRet = $GLOBALS['oFunctions']->genSiteSearch();
821  break;
822  case 'service_menu':
823  $sRet = $GLOBALS['oFunctions']->genSiteServiceMenu();
824  break;
825  case 'top_menu':
826  $sRet = $GLOBALS['oTopMenu'] -> getCode();
827  break;
828  case 'show_breadcrumb':
829  $sShow = getParam('ext_breadcrumb_menu_enabled');
830  if($sShow) {
831  $sRet = '';
832  } else {
833  $sRet = 'display: none; visibility: hidden;';
834  }
835  break;
836  case 'footer_style_breadcrumb':
837  $sShow = getParam('ext_breadcrumb_menu_enabled');
838  if($sShow) {
839  $sRet = '';
840  } else {
841  $sRet = 'position: relative;';
842  }
843  break;
844  case 'top_menu_breadcrumb':
845  $sRet = !empty($GLOBALS['oTopMenu']->sBreadCrumb) ? $GLOBALS['oTopMenu'] -> sBreadCrumb : $GLOBALS['oTopMenu']->genBreadcrumb();
846  break;
847  case 'extra_top_menu':
849 
850  if ($iProfileId && getParam('ext_nav_menu_enabled')) {
851  ch_import('ChTemplMemberMenu');
853  $sRet = $oMemberMenu -> genMemberMenu($iProfileId);
854  }
855  break;
856  case 'bottom_links':
857  $sRet = $oFunctions -> genSiteBottomMenu();
858  break;
859  case 'switch_skin_block':
860  $sRet = getParam("enable_template") ? templates_select_txt() : '';
861  break;
862  case 'dol_images':
863  $sRet = $this->_processJsImages();
864  break;
865  case 'dol_lang':
866  $sRet = $this->_processJsTranslations();
867  break;
868  case 'dol_options':
869  $sRet = $this->_processJsOptions();
870  break;
871  case 'bottom_text':
872  $sRet = _t( '_bottom_text', date('Y') );
873  break;
874  case 'copyright':
875  $sRet = _t( '_copyright', date('Y') ) . getVersionComment();
876  break;
877  case 'flush_header':
878  //TODO: add some variable to disable it if needed
879  //flush();
880  break;
881  case 'extra_js':
882  $sRet = empty($_page['extra_js']) ? '' : $_page['extra_js'];
883  break;
884  case 'is_profile_page':
885  $sRet = (defined('CH_PROFILE_PAGE')) ? 'true' : 'false';
886  break;
887  // Below system keys unique to Cheetah. Not ava in Dolphin.
888  case 'logged_member_id':
889  $sRet = getLoggedId();
890  break;
891  case 'logged_nickname':
892  $sRet = getUsername();
893  break;
894  case 'logged_usertitle':
895  $sRet = getNickName();
896  break;
897  case 'current_date_short':
899  break;
900  case 'current_date_long':
902  break;
903  default:
904  $sRet = ($sTemplAdd = $oFunctions->TemplPageAddComponent($sKey)) !== false ? $sTemplAdd : $aKeyWrappers['left'] . $sKey . $aKeyWrappers['right'];
905  }
906 
907  $sRet = ChWsbTemplate::processInjection($_page['name_index'], $sKey, $sRet);
908  return $sRet;
909  }
915  {
916  $sCacheEngine = getParam('sys_template_cache_engine');
917  $oCacheEngine = ch_instance('ChWsbCache' . $sCacheEngine);
918  if(!$oCacheEngine->isAvailable())
919  $oCacheEngine = ch_instance('ChWsbCacheFileHtml');
920  return $oCacheEngine;
921  }
932  function getCached($sName, &$aVariables, $mixedKeyWrapperHtml = null, $sCheckIn = CH_WSB_TEMPLATE_CHECK_IN_BOTH, $bEvaluate = true)
933  {
934  // initialization
935 
936  if (!$this->_bCacheEnable)
937  return false;
938 
939  $sAbsolutePath = $this->_getAbsoluteLocation('path', $this->_sFolderHtml, $sName, $sCheckIn);
940  if (empty($sAbsolutePath))
941  return false;
942 
943  $oCacheEngine = $this->getTemplatesCacheObject ();
944  $isFileBasedEngine = $bEvaluate && method_exists($oCacheEngine, 'getDataFilePath');
945 
946  // try to get cached content
947 
948  $sCacheVariableName = "a";
949  $sCacheKey = $this->_getCacheFileName('html', $sAbsolutePath) . '.php';
950  if ($isFileBasedEngine)
951  $sCacheContent = $oCacheEngine->getDataFilePath($sCacheKey);
952  else
953  $sCacheContent = $oCacheEngine->getData($sCacheKey);
954 
955 
956  // recreate cache if it is empty
957 
958  if ($sCacheContent === null && ($sContent = file_get_contents($sAbsolutePath)) !== false && ($sContent = $this->_compileContent($sContent, "\$" . $sCacheVariableName, 1, $aVariables, $mixedKeyWrapperHtml)) !== false) {
959  if (false === $oCacheEngine->setData($sCacheKey, $sContent))
960  return false;
961 
962  if ($isFileBasedEngine)
963  $sCacheContent = $oCacheEngine->getDataFilePath($sCacheKey);
964  else
965  $sCacheContent = $sContent;
966  }
967 
968  if ($sCacheContent === null)
969  return false;
970 
971  // return simple cache content
972 
973  if (!$bEvaluate)
974  return $sCacheContent;
975 
976  // return evaluated cache content
977 
978  ob_start();
979 
980  $$sCacheVariableName = &$aVariables;
981 
982  if ($isFileBasedEngine)
983  include($sCacheContent);
984  else
985  eval('?'.'>' . $sCacheContent);
986 
987  $sContent = ob_get_clean();
988 
989  return $sContent;
990  }
991 
999  function addJs($mixedFiles, $bDynamic = false)
1000  {
1001  return $this->_processFiles('js', 'add', $mixedFiles, $bDynamic);
1002  }
1003 
1012  function addJsSystem($mixedFiles) {
1013  return $this->_processFiles('js', 'add', $mixedFiles, false, true);
1014  }
1015 
1022  function deleteJs($mixedFiles)
1023  {
1024  return $this->_processFiles('js', 'delete', $mixedFiles);
1025  }
1026 
1033  function deleteJsSystem($mixedFiles) {
1034  return $this->_processFiles('js', 'delete', $mixedFiles, false, true);
1035  }
1036 
1044  function _compileJs($sAbsolutePath, &$aIncluded)
1045  {
1046  if(isset($aIncluded[$sAbsolutePath]))
1047  return '';
1048 
1049  $bExternal = strpos($sAbsolutePath, "http://") !== false || strpos($sAbsolutePath, "https://") !== false;
1050  if($bExternal) {
1051  $sPath = $sAbsolutePath;
1052  $sName = '';
1053 
1054  $sContent = ch_file_get_contents($sAbsolutePath);
1055  } else {
1056  $aFileInfo = pathinfo($sAbsolutePath);
1057  $sPath = $aFileInfo['dirname'] . DIRECTORY_SEPARATOR;
1058  $sName = $aFileInfo['basename'];
1059 
1060  $sContent = file_get_contents($sPath . $sName);
1061  }
1062 
1063  if(empty($sContent))
1064  return '';
1065 
1066  $sUrl = ch_ltrim_str($sPath, realpath(CH_DIRECTORY_PATH_ROOT), CH_WSB_URL_ROOT);
1067  $sUrl = str_replace(DIRECTORY_SEPARATOR, '/', $sPath);
1068 
1069  $sContent = "\r\n/*--- BEGIN: " . $sUrl . $sName . "---*/\r\n" . $sContent . ";\r\n/*--- END: " . $sUrl . $sName . "---*/\r\n";
1070  $sContent = str_replace(array("\n\r", "\r\n", "\r"), "\n", $sContent);
1071 
1072  $aIncluded[$sAbsolutePath] = 1;
1073 
1074  return preg_replace(
1075  array(
1076  "'<ch_url_root />'",
1077  "'\r\n'"
1078  ),
1079  array(
1080  CH_WSB_URL_ROOT,
1081  "\n"
1082  ),
1083  $sContent
1084  );
1085  }
1093  {
1094  return "<script language=\"javascript\" type=\"text/javascript\" src=\"" . $sFile . "\"></script>";
1095  }
1103  {
1104  return "<script language=\"javascript\" type=\"text/javascript\">\n<!--\n" . $sCode . "\n-->\n</script>";
1105  }
1106 
1114  function addCss($mixedFiles, $bDynamic = false)
1115  {
1116  return $this->_processFiles('css', 'add', $mixedFiles, $bDynamic);
1117  }
1118 
1123  function addCssAsync($mixedFiles)
1124  {
1125  if (!is_array($mixedFiles))
1126  $mixedFiles = array($mixedFiles);
1127 
1128  foreach ($mixedFiles as $sFile)
1129  $GLOBALS[$this->_sPrefix . 'CssAsync'][] = $this->_getAbsoluteLocationCss('url', $sFile);
1130 
1131  $this->addJs('loadCSS.js');
1132  }
1133 
1138  function includeCssAsync ()
1139  {
1140  if (empty($GLOBALS[$this->_sPrefix . 'CssAsync']))
1141  return '';
1142 
1143  $GLOBALS[$this->_sPrefix . 'CssAsync'] = array_unique($GLOBALS[$this->_sPrefix . 'CssAsync']);
1144 
1145  $sList = '';
1146  foreach ($GLOBALS[$this->_sPrefix . 'CssAsync'] as $sUrl)
1147  $sList .= 'loadCSS("' . $sUrl . '", document.getElementById("ch_css_async"));';
1148 
1149  // don't load css for mobile devices
1150  return '
1151  <script id="ch_css_async">
1152  if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
1153  ' . $sList . '
1154  }
1155  </script>
1156  ';
1157  }
1158 
1166  function addCssSystem($mixedFiles) {
1167  return $this->_processFiles('css', 'add', $mixedFiles, false, true);
1168  }
1169 
1176  function deleteCss($mixedFiles)
1177  {
1178  return $this->_processFiles('css', 'delete', $mixedFiles);
1179  }
1180 
1187  function deleteCssSystem($mixedFiles){
1188  return $this->_processFiles('css', 'delete', $mixedFiles, false, true);
1189  }
1190 
1198  function _compileCss($sAbsolutePath, &$aIncluded)
1199  {
1200  if(isset($aIncluded[$sAbsolutePath]))
1201  return '';
1202 
1203  $bExternal = strpos($sAbsolutePath, "http://") !== false || strpos($sAbsolutePath, "https://") !== false;
1204  if($bExternal) {
1205  $sPath = $sAbsolutePath;
1206  $sName = '';
1207 
1208  $sContent = ch_file_get_contents($sAbsolutePath);
1209  } else {
1210  $aFileInfo = pathinfo($sAbsolutePath);
1211  $sPath = $aFileInfo['dirname'] . DIRECTORY_SEPARATOR;
1212  $sName = $aFileInfo['basename'];
1213 
1214  $sContent = file_get_contents($sPath . $sName);
1215  }
1216 
1217  if(empty($sContent))
1218  return '';
1219 
1220  $sUrl = ch_ltrim_str($sPath, realpath(CH_DIRECTORY_PATH_ROOT), CH_WSB_URL_ROOT);
1221  $sUrl = str_replace(DIRECTORY_SEPARATOR, '/', $sPath);
1222 
1223  $sContent = "\r\n/*--- BEGIN: " . $sUrl . $sName . "---*/\r\n" . $sContent . "\r\n/*--- END: " . $sUrl . $sName . "---*/\r\n";
1224  $aIncluded[$sAbsolutePath] = 1;
1225 
1226  $sContent = str_replace(array("\n\r", "\r\n", "\r"), "\n", $sContent);
1227  if($bExternal) {
1228  $sContent = preg_replace_callback(
1229  "'@import\s+url\s*\‍(\s*[\'|\"]*\s*([a-zA-Z0-9\.\/_-]+)\s*[\'|\"]*\s*\‍)\s*;'",
1230  function($matches) { return ''; },
1231  $sContent
1232  );
1233 
1234  $sContent = preg_replace_callback(
1235  "'url\s*\‍(\s*[\'|\"]*\s*([a-zA-Z0-9\.\/\?\#_=-]+)\s*[\'|\"]*\s*\‍)'",
1236  function($matches) use ($sPath) { return "url({$sPath}{$matches[1]});"; },
1237  $sContent
1238  );
1239  } else {
1240  $sContent = preg_replace_callback(
1241  "'@import\s+url\s*\‍(\s*[\'|\"]*\s*([a-zA-Z0-9\.\/_-]+)\s*[\'|\"]*\s*\‍)\s*;'",
1242  function($matches) use ($sPath) { return $this->_compileCss(realpath($sPath . dirname($matches[1])) . DIRECTORY_SEPARATOR . basename($matches[1]), $aIncluded); },
1243  $sContent
1244  );
1245 
1246  $sContent = preg_replace_callback(
1247  "'url\s*\‍(\s*[\'|\"]*\s*([a-zA-Z0-9\.\/\?\#_=-]+)\s*[\'|\"]*\s*\‍)'",
1248  function ($aMatches) use ($sPath) {
1249  return ChWsbTemplate::_callbackParseUrl(addslashes($sPath), $aMatches);
1250  },
1251  $sContent
1252  );
1253  }
1254  return $sContent;
1255  }
1256 
1263  function _minifyCss($s)
1264  {
1265  require_once(CH_DIRECTORY_PATH_PLUGINS . 'minify/lib/Minify/CSS/Compressor.php');
1267  }
1268 
1276  public static function _callbackParseUrl($sPath, $aMatches)
1277  {
1278  $sFile = basename($aMatches[1]);
1279  $sDirectory = dirname($aMatches[1]);
1280 
1281  $sRootPath = realpath(CH_DIRECTORY_PATH_ROOT);
1282  $sAbsolutePath = realpath($sPath . $sDirectory) . DIRECTORY_SEPARATOR . $sFile;
1283 
1284  $sRootPath = str_replace(DIRECTORY_SEPARATOR, '/', $sRootPath);
1285  $sAbsolutePath = str_replace(DIRECTORY_SEPARATOR, '/', $sAbsolutePath);
1286 
1287  return 'url(' . ch_ltrim_str($sAbsolutePath, $sRootPath, CH_WSB_URL_ROOT) . ')';
1288  }
1289 
1297  {
1298  if (!$sFile)
1299  return '';
1300  return "<link href=\"" . $sFile . "\" rel=\"stylesheet\" type=\"text/css\" />";
1301  }
1309  {
1310  return "<style>" . $sCode . "</style>";
1311  }
1312  /*
1313  * Include CSS style(s) in the page's head section.
1314  */
1315  function includeCssStyles()
1316  {
1317  $sResult = "";
1318  if(empty($GLOBALS[$this->_sPrefix . 'CssStyles']) || !is_array($GLOBALS[$this->_sPrefix . 'CssStyles']))
1319  return $sResult;
1320 
1321  foreach($GLOBALS[$this->_sPrefix . 'CssStyles'] as $sName => $aContent) {
1322  $sContent = "";
1323  if(!empty($aContent) && is_array($aContent))
1324  foreach($aContent as $sStyleName => $sStyleValue)
1325  $sContent .= "\t" . $sStyleName . ": " . $sStyleValue . ";\r\n";
1326 
1327  $sResult .= $sName . " {\r\n" . $sContent . "}\r\n";
1328  }
1329 
1330  return !empty($sResult) ? $this->_wrapInTagCssCode($sResult) : '';
1331  }
1339  function includeFiles($sType, $bSystem = false)
1340  {
1341  $sUpcaseType = ucfirst($sType);
1342 
1343  $sArrayKey = $this->_sPrefix . $sUpcaseType . ($bSystem ? 'System' : '');
1344  $aFiles = isset($GLOBALS[$sArrayKey]) ? $GLOBALS[$sArrayKey] : array();
1345  if(empty($aFiles) || !is_array($aFiles))
1346  return "";
1347 
1348  if(!$this->{'_b' . $sUpcaseType . 'Cache'})
1349  return $this->_includeFiles($sType, $aFiles);
1350 
1351  //--- If cache already exists, return it ---//
1352  $sMethodWrap = '_wrapInTag' . $sUpcaseType;
1353  $sMethodCompile = '_compile' . $sUpcaseType;
1354  $sMethodMinify = '_minify' . $sUpcaseType;
1355 
1356  ksort($aFiles);
1357 
1358  $sName = "";
1359  foreach($aFiles as $aFile)
1360  $sName .= $aFile['url'];
1362 
1363  $sCacheAbsoluteUrl = $this->_sCachePublicFolderUrl . $sName . '.' . $sType;
1364  $sCacheAbsolutePath = $this->_sCachePublicFolderPath . $sName . '.' . $sType;
1365  if(file_exists($sCacheAbsolutePath)) {
1366  if($this->{'_b' . $sUpcaseType . 'Archive'})
1367  $sCacheAbsoluteUrl = $this->_getLoaderUrl($sType, $sName);
1368 
1369  return $this->$sMethodWrap($sCacheAbsoluteUrl);
1370  }
1371 
1372  //--- Collect all attached CSS/JS in one file ---//
1373  $sResult = "";
1374  $aIncluded = array();
1375  foreach($aFiles as $aFile)
1376  if(($sContent = $this->$sMethodCompile($aFile['path'], $aIncluded)) !== false)
1377  $sResult .= $sContent;
1378 
1379  if (method_exists($this, $sMethodMinify))
1380  $sResult = $this->$sMethodMinify($sResult);
1381 
1382  $mixedWriteResult = false;
1383  if(!empty($sResult) && ($rHandler = fopen($sCacheAbsolutePath, 'w')) !== false) {
1384  $mixedWriteResult = fwrite($rHandler, $sResult);
1385  fclose($rHandler);
1386  @chmod ($sCacheAbsolutePath, 0666);
1387  }
1388 
1389  if($mixedWriteResult === false)
1390  return $this->_includeFile($sType, $aFiles);
1391 
1392  if($this->{'_b' . $sUpcaseType . 'Archive'})
1393  $sCacheAbsoluteUrl = $this->_getLoaderUrl($sType, $sName);
1394 
1395  return $this->$sMethodWrap($sCacheAbsoluteUrl);
1396  }
1404  function _includeFiles($sType, &$aFiles)
1405  {
1406  $sMethod = '_wrapInTag' . ucfirst($sType);
1407 
1408  $sResult = "";
1409  foreach($aFiles as $aFile)
1410  $sResult .= $this->$sMethod($aFile['url']);
1411 
1412  return $sResult;
1413  }
1422  function _processFiles($sType, $sAction, $mixedFiles, $bDynamic = false, $bSystem = false)
1423  {
1424  if(empty($mixedFiles))
1425  return $bDynamic ? "" : false;
1426 
1427  if(is_string($mixedFiles))
1428  $mixedFiles = array($mixedFiles);
1429 
1430  $sUpcaseType = ucfirst($sType);
1431  $sMethodLocate = '_getAbsoluteLocation' . $sUpcaseType;
1432  $sMethodWrap = '_wrapInTag' . $sUpcaseType;
1433  $sResult = '';
1434  foreach($mixedFiles as $sFile) {
1435  //--- Process 3d Party CSS/JS file ---//
1436  if(strpos($sFile, "http://") !== false || strpos($sFile, "https://") !== false) {
1437  $sUrl = $sFile;
1438  $sPath = $sFile;
1439  }
1440  //--- Process Custom CSS/JS file ---//
1441  else if(strpos($sFile, "|") !== false && $aParts = explode("|", $sFile)) {
1442  $sFile = array_pop($aParts);
1443  if (!isset($aParts[0]))
1444  $aParts[0] = '';
1445  $sUrl = CH_WSB_URL_ROOT . (isset($aParts[1]) ? $aParts[1] : $aParts[0]) . $sFile;
1446  $sPath = realpath(CH_DIRECTORY_PATH_ROOT . $aParts[0] . $sFile);
1447  }
1448  //--- Process Common CSS/JS file(check in default locations) ---//
1449  else {
1450  $sUrl = $this->$sMethodLocate('url', $sFile);
1451  $sPath = $this->$sMethodLocate('path', $sFile);
1452  }
1453 
1454  if(empty($sPath) || empty($sUrl))
1455  continue;
1456 
1457  $sArrayKey = $this->_sPrefix . $sUpcaseType . ($bSystem ? 'System' : '');
1458  switch($sAction) {
1459  case 'add':
1460  if($bDynamic)
1461  $sResult .= $this->$sMethodWrap($sUrl);
1462  else {
1463  $bFound = false;
1464  foreach($GLOBALS[$sArrayKey] as $iKey => $aValue)
1465  if($aValue['url'] == $sUrl && $aValue['path'] == $sPath) {
1466  $bFound = true;
1467  break;
1468  }
1469 
1470  if(!$bFound)
1471  $GLOBALS[$sArrayKey][] = array('url' => $sUrl, 'path' => $sPath);
1472  }
1473  break;
1474  case 'delete':
1475  if(!$bDynamic)
1476  foreach($GLOBALS[$sArrayKey] as $iKey => $aValue)
1477  if($aValue['url'] == $sUrl) {
1478  unset($GLOBALS[$sArrayKey][$iKey]);
1479  break;
1480  }
1481  break;
1482  }
1483  }
1484 
1485  return $bDynamic ? $sResult : true;
1486  }
1487 
1496  function _parseContent($sContent, $aVariables, $mixedKeyWrapperHtml = null)
1497  {
1498  $aKeys = array_keys($aVariables);
1499  $aValues = array_values($aVariables);
1500 
1501  $aKeyWrappers = $this->_getKeyWrappers($mixedKeyWrapperHtml);
1502 
1503  $iCountKeys = count($aKeys);
1504  for ($i = 0; $i < $iCountKeys; $i++) {
1505  if (strncmp($aKeys[$i], 'ch_repeat:', 10) === 0) {
1506  $sKey = "'<" . $aKeys[$i] . ">(.*)<\/" . $aKeys[$i] . ">'s";
1507 
1508  $aMatches = array();
1509  preg_match($sKey, $sContent, $aMatches);
1510 
1511  $sValue = '';
1512  if(isset($aMatches[1]) && !empty($aMatches[1])) {
1513  if(is_array($aValues[$i]))
1514  foreach($aValues[$i] as $aValue)
1515  $sValue .= $this->parseHtmlByContent($aMatches[1], $aValue, $mixedKeyWrapperHtml);
1516  else if(is_string($aValues[$i]))
1517  $sValue = $aValues[$i];
1518  }
1519  } else if (strncmp($aKeys[$i], 'ch_if:', 6) === 0) {
1520  $sKey = "'<" . $aKeys[$i] . ">(.*)<\/" . $aKeys[$i] . ">'s";
1521 
1522  $aMatches = array();
1523  preg_match($sKey, $sContent, $aMatches);
1524 
1525  $sValue = '';
1526  if(isset($aMatches[1]) && !empty($aMatches[1]))
1527  if(is_array($aValues[$i]) && isset($aValues[$i]['content']) && $aValues[$i]['condition'])
1528  $sValue .= $this->parseHtmlByContent($aMatches[1], $aValues[$i]['content'], $mixedKeyWrapperHtml);
1529  } else {
1530  $sKey = "'" . $aKeyWrappers['left'] . $aKeys[$i] . $aKeyWrappers['right'] . "'s";
1531  $sValue = $aValues[$i];
1532  //$sValue = str_replace('$', '\\$', $aValues[$i]);
1533  }
1534 
1535  $aKeys[$i] = $sKey;
1536  $aValues[$i] = $sValue;
1537  }
1538 
1539  $aKeys = array_merge($aKeys, array(
1540  "'<ch_include_auto:([^\s]+) \/>'s",
1541  "'<ch_include_tmpl:([^\s]+) \/>'s",
1542  "'<ch_include_base:([^\s]+) \/>'s",
1543  "'<ch_injection:([^\s]+) />'s",
1544  "'<ch_image_url:([^\s]+) \/>'s",
1545  "'<ch_icon_url:([^\s]+) \/>'s",
1546  "'<ch_text:([_\{\}\w\d\s]+[^\s]{1}) \/>'s",
1547  "'<ch_text_js:([^\s]+) \/>'s",
1548  "'<ch_text_attribute:([^\s]+) \/>'s",
1549  "'<ch_url_root />'",
1550  "'<ch_url_admin />'"
1551  ));
1552 
1553  $aValues = array_merge($aValues, array(
1554  function($matches) use ($aVariables, $mixedKeyWrapperHtml) { return $this->parseHtmlByName($matches[1], $aVariables, $mixedKeyWrapperHtml, CH_WSB_TEMPLATE_CHECK_IN_BOTH); },
1555  function($matches) use ($aVariables, $mixedKeyWrapperHtml) { return $this->parseHtmlByName($matches[1], $aVariables, $mixedKeyWrapperHtml, CH_WSB_TEMPLATE_CHECK_IN_TMPL); },
1556  function($matches) use ($aVariables, $mixedKeyWrapperHtml) { return $this->parseHtmlByName($matches[1], $aVariables, $mixedKeyWrapperHtml, CH_WSB_TEMPLATE_CHECK_IN_BASE); },
1557  function($matches) { return $this->processInjection($GLOBALS['_page']['name_index'], $matches[1]); },
1558  function($matches) { return $this->getImageUrl($matches[1]); },
1559  function($matches) { return $this->getIconUrl($matches[1]); },
1560  function($matches) { return _t($matches[1]); },
1561  function($matches) { return ch_js_string(_t($matches[1])); },
1562  function($matches) { return ch_html_attribute(_t($matches[1])); },
1563  CH_WSB_URL_ROOT,
1564  CH_WSB_URL_ADMIN
1565  ));
1566 
1567  //--- Parse Predefined Keys ---//
1568  //$sContent = preg_replace($aKeys, $aValues, $sContent);
1569 
1570  $aCombined = array_combine($aKeys, $aValues);
1571  foreach($aCombined as $sPattern => $sValue) {
1572 
1573  if(is_object($sValue) && ($sValue instanceof Closure)) {
1574  $sContent = preg_replace_callback($sPattern, $sValue, $sContent);
1575  continue;
1576  }
1577 
1578  $sContent = preg_replace_callback($sPattern, function($matches) use ($sValue) {
1579  return $sValue;
1580  }, $sContent);
1581  }
1582 
1583  //--- Parse System Keys ---//
1584  //$sContent = preg_replace( "'" . $aKeyWrappers['left'] . "([a-zA-Z0-9_-]+)" . $aKeyWrappers['right'] . "'e", "\$this->parseSystemKey('\\1', \$mixedKeyWrapperHtml)", $sContent);
1585  $sContent = preg_replace_callback("'" . $aKeyWrappers['left'] . "([a-zA-Z0-9_-]+)" . $aKeyWrappers['right'] . "'",
1586  function($matches) use ($mixedKeyWrapperHtml) {
1587 
1588  return $this->parseSystemKey($matches[1], $mixedKeyWrapperHtml);
1589  }, $sContent);
1590 
1591  return $sContent;
1592  }
1593 
1604  function _compileContent($sContent, $aVarName, $iVarDepth, $aVarValues, $mixedKeyWrapperHtml = null)
1605  {
1606  $aKeys = array_keys($aVarValues);
1607  $aValues = array_values($aVarValues);
1608 
1609  $aKeyWrappers = $this->_getKeyWrappers($mixedKeyWrapperHtml);
1610 
1611  for($i = 0; $i < count($aKeys); $i++) {
1612  if(strpos($aKeys[$i], 'ch_repeat:') === 0) {
1613  $sKey = "'<" . $aKeys[$i] . ">(.*)<\/" . $aKeys[$i] . ">'s";
1614 
1615  $aMatches = array();
1616  preg_match($sKey, $sContent, $aMatches);
1617 
1618  $sValue = '';
1619  if(isset($aMatches[1]) && !empty($aMatches[1])) {
1620  if(empty($aValues[$i]) || !is_array($aValues[$i]))
1621  return false;
1622 
1623  $sIndex = "\$" . str_repeat("i", $iVarDepth);
1624  $sValue .= '<'."?php if(is_array(" . $aVarName . "['" . $aKeys[$i] . "'])) for(" . $sIndex . "=0; " . $sIndex . "<count(" . $aVarName . "['" . $aKeys[$i] . "']); " . $sIndex . "++){ ?".'>';
1625  if(($sInnerValue = $this->_compileContent($aMatches[1], $aVarName . "['" . $aKeys[$i] . "'][" . $sIndex . "]", $iVarDepth + 1, current($aValues[$i]), $mixedKeyWrapperHtml)) === false)
1626  return false;
1627  $sValue .= $sInnerValue;
1628  $sValue .= '<'."?php } else if(is_string(" . $aVarName . "['" . $aKeys[$i] . "'])) echo " . $aVarName . "['" . $aKeys[$i] . "']; ?".'>';
1629  }
1630  } else if(strpos($aKeys[$i], 'ch_if:') === 0) {
1631  $sKey = "'<" . $aKeys[$i] . ">(.*)<\/" . $aKeys[$i] . ">'s";
1632 
1633  $aMatches = array();
1634  preg_match($sKey, $sContent, $aMatches);
1635 
1636  $sValue = '';
1637  if(isset($aMatches[1]) && !empty($aMatches[1])) {
1638  if(!is_array($aValues[$i]) || !isset($aValues[$i]['content']) || empty($aValues[$i]['content']) || !is_array($aValues[$i]['content']))
1639  return false;
1640 
1641  $sValue .= '<'."?php if(" . $aVarName . "['" . $aKeys[$i] . "']['condition']){ ?".'>';
1642  if(($sInnerValue = $this->_compileContent($aMatches[1], $aVarName . "['" . $aKeys[$i] . "']['content']", $iVarDepth, $aValues[$i]['content'], $mixedKeyWrapperHtml)) === false)
1643  return false;
1644  $sValue .= $sInnerValue;
1645  $sValue .= '<'.'?php } ?'.'>';
1646  }
1647  } else {
1648  $sKey = "'" . $aKeyWrappers['left'] . $aKeys[$i] . $aKeyWrappers['right'] . "'s";
1649  $sValue = '<'.'?=' . $aVarName . "['" . $aKeys[$i] . "'];?".'>';
1650  }
1651 
1652  $aKeys[$i] = $sKey;
1653  $aValues[$i] = $sValue;
1654  }
1655 
1656  $aKeys = array_merge($aKeys, array(
1657  "'<ch_include_auto:([^\s]+) \/>'s",
1658  "'<ch_include_base:([^\s]+) \/>'s",
1659  "'<ch_include_tmpl:([^\s]+) \/>'s",
1660  "'<ch_injection:([^\s]+) />'s",
1661  "'<ch_image_url:([^\s]+) \/>'s",
1662  "'<ch_icon_url:([^\s]+) \/>'s",
1663  "'<ch_text:([_\{\}\w\d\s]+[^\s]{1}) \/>'s",
1664  "'<ch_text_js:([^\s]+) \/>'s",
1665  "'<ch_text_attribute:([^\s]+) \/>'s",
1666  "'<ch_url_root />'",
1667  "'<ch_url_admin />'"
1668  ));
1669 
1670  $aValues = array_merge($aValues, array(
1671  function($matches) use ($aVarValues, $mixedKeyWrapperHtml) { return $this->getCached($matches[1], $aVarValues, $mixedKeyWrapperHtml, CH_WSB_TEMPLATE_CHECK_IN_BOTH, false); },
1672  function($matches) use ($aVarValues, $mixedKeyWrapperHtml) { return $this->getCached($matches[1], $aVarValues, $mixedKeyWrapperHtml, CH_WSB_TEMPLATE_CHECK_IN_BASE, false); },
1673  function($matches) use ($aVarValues, $mixedKeyWrapperHtml) { return $this->getCached($matches[1], $aVarValues, $mixedKeyWrapperHtml, CH_WSB_TEMPLATE_CHECK_IN_TMPL, false); },
1674  function($matches) { return '<?=$this->processInjection($GLOBALS[\'_page\'][\'name_index\'], "'.$matches[1].'")?>'; },
1675  function($matches) { return $this->getImageUrl($matches[1]); },
1676  function($matches) { return $this->getIconUrl($matches[1]); },
1677  function($matches) { return _t($matches[1]); },
1678  function($matches) { return ch_js_string(_t($matches[1])); },
1679  function($matches) { return ch_html_attribute(_t($matches[1])); },
1680  CH_WSB_URL_ROOT,
1681  CH_WSB_URL_ADMIN
1682  ));
1683 
1684  //--- Parse Predefined Keys ---//
1685  $aCombined = array_combine($aKeys, $aValues);
1686  foreach($aCombined as $sPattern => $sValue) {
1687  if(is_object($sValue) && ($sValue instanceof Closure)) {
1688  $sContent = preg_replace_callback($sPattern, $sValue, $sContent);
1689  continue;
1690  }
1691 
1692  $sContent = preg_replace_callback($sPattern, function($matches) use ($sValue) {
1693  return $sValue;
1694  }, $sContent);
1695  }
1696 
1697  //--- Parse System Keys ---//
1698  $sContent = preg_replace( "'" . $aKeyWrappers['left'] . "([a-zA-Z0-9_-]+)" . $aKeyWrappers['right'] . "'", "<?=\$this->parseSystemKey('\\1', \$mixedKeyWrapperHtml);?".">", $sContent);
1699 
1700  return $sContent;
1701  }
1712  {
1713  if($sType == 'path') {
1714  $sDivider = DIRECTORY_SEPARATOR;
1715  $sRoot = CH_DIRECTORY_PATH_ROOT;
1716  } else if($sType == 'url') {
1717  $sDivider = '/';
1718  $sRoot = CH_WSB_URL_ROOT;
1719  }
1720 
1721  if(strpos($sName,'|') !== false) {
1722  $aParts = explode('|', $sName);
1723 
1724  $sName = $aParts[1];
1725  $sLocationKey = $this->addDynamicLocation(CH_DIRECTORY_PATH_ROOT . $aParts[0], CH_WSB_URL_ROOT . $aParts[0]);
1726  }
1727 
1728  $sResult = '';
1729  $aLocations = array_reverse($this->_aLocations, true);
1730  foreach($aLocations as $sKey => $aLocation) {
1731  $sCode = $this->getCode();
1732 
1733  if(($sCheckIn == CH_WSB_TEMPLATE_CHECK_IN_BOTH || $sCheckIn == CH_WSB_TEMPLATE_CHECK_IN_TMPL) && extFileExists($aLocation['path'] . 'tmpl_' . $sCode . DIRECTORY_SEPARATOR . $sFolder . $sName))
1734  $sResult = $aLocation[$sType] . 'tmpl_' . $sCode . $sDivider . $sFolder . $sName;
1735  else if(($sCheckIn == CH_WSB_TEMPLATE_CHECK_IN_BOTH || $sCheckIn == CH_WSB_TEMPLATE_CHECK_IN_BASE) && extFileExists($aLocation['path'] . CH_WSB_TEMPLATE_FOLDER_BASE . DIRECTORY_SEPARATOR . $sFolder . $sName))
1736  $sResult = $aLocation[$sType] . CH_WSB_TEMPLATE_FOLDER_BASE . $sDivider . $sFolder . $sName;
1737  else
1738  continue;
1739  break;
1740  }
1741 
1745  if(!$sResult && @is_file(CH_DIRECTORY_PATH_ROOT . $aParts[0] . DIRECTORY_SEPARATOR . $aParts[1])) {
1746  $sResult = $sRoot . $aParts[0] . $sDivider . $aParts[1];
1747  }
1748 
1749  if(isset($sLocationKey))
1750  $this->removeLocation($sLocationKey);
1751 
1752  return $sType == 'path' && !empty($sResult) ? realpath($sResult) : $sResult;
1753  }
1762  {
1763  $sResult = '';
1764  $aLocations = array_reverse($this->_aLocationsJs, true);
1765  foreach($aLocations as $sKey => $aLocation) {
1766  if(extFileExists($aLocation['path'] . $sName))
1767  $sResult = $aLocation[$sType] . $sName;
1768  else
1769  continue;
1770  break;
1771  }
1772  return $sType == 'path' && !empty($sResult) ? realpath($sResult) : $sResult;
1773  }
1775  {
1776  return $this->_getAbsoluteLocation($sType, $this->_sFolderCss, $sName);
1777  }
1786  function _getInlineData($sType, $sName, $sCheckIn)
1787  {
1788  switch($sType) {
1789  case 'image':
1791  break;
1792  case 'icon':
1794  break;
1795  }
1796  $sPath = $this->_getAbsoluteLocation('path', $sFolder, $sName, $sCheckIn);
1797 
1798  $iFileSize = 0;
1799  if($this->_bImagesInline && ($iFileSize = filesize($sPath)) !== false && $iFileSize < $this->_iImagesMaxSize) {
1800  $aFileInfo = pathinfo($sPath);
1801  return "data:image/" . strtolower($aFileInfo['extension']) . ";base64," . base64_encode(file_get_contents($sPath));
1802  }
1803 
1804  return false;
1805  }
1812  function _getCacheFileName($sType, $sAbsolutePath)
1813  {
1814  $sResult = md5($sAbsolutePath . $GLOBALS['site']['ver'] . $GLOBALS['site']['build'] . $GLOBALS['site']['url']);
1815  switch($sType) {
1816  case 'html':
1817  $sResult = $this->_sCacheFilePrefix . ch_lang_name() . '_' . $this->_sCode . '_' . $sResult;
1818  break;
1819  case 'css':
1820  $sResult = $this->_sCssCachePrefix . $sResult;
1821  break;
1822  case 'js':
1823  $sResult = $this->_sJsCachePrefix . $sResult;
1824  break;
1825  }
1826 
1827  return $sResult;
1828  }
1835  function _getKeyWrappers($mixedKeyWrapperHtml)
1836  {
1837  $aResult = array();
1838  if(!empty($mixedKeyWrapperHtml) && is_string($mixedKeyWrapperHtml))
1839  $aResult = array('left' => $mixedKeyWrapperHtml, 'right' => $mixedKeyWrapperHtml);
1840  else if(!empty($mixedKeyWrapperHtml) && is_array($mixedKeyWrapperHtml))
1841  $aResult = array('left' => $mixedKeyWrapperHtml[0], 'right' => $mixedKeyWrapperHtml[1]);
1842  else
1843  $aResult = array('left' => $this->_sKeyWrapperHtml, 'right' => $this->_sKeyWrapperHtml);
1844  return $aResult;
1845  }
1846 
1853  {
1854  $aSearch = array("\r", "\n", '\'');
1855  $aReplacement = array('', '\n', '\\\'');
1856 
1857  $sReturn = '';
1858  foreach($GLOBALS['ChWsbTemplateJsTranslations'] as $sKey => $sString) {
1859  $sKey = str_replace($aSearch, $aReplacement, $sKey);
1860  $sString = str_replace($aSearch, $aReplacement, $sString);
1861 
1862  $sReturn .= "'" . $sKey . "': '" . $sString . "',";
1863  }
1864 
1865  return '<script type="text/javascript" language="javascript">var aWsbLang = {' . substr($sReturn, 0, -1) . '};</script>';
1866  }
1873  {
1874  $sReturn = '';
1875  foreach($GLOBALS['ChWsbTemplateJsOptions'] as $sName => $mixedValue)
1876  $sReturn .= "'" . $sName . "': '" . addslashes($mixedValue) . "',";
1877 
1878  return '<script type="text/javascript" language="javascript">var aWsbOptions = {' . substr($sReturn, 0, -1) . '};</script>';
1879  }
1885  function _processJsImages()
1886  {
1887  $sReturn = '';
1888  foreach($GLOBALS['ChWsbTemplateJsImages'] as $sKey => $sUrl)
1889  $sReturn .= "'" . $sKey . "': '" . $sUrl . "',";
1890 
1891  return '<script type="text/javascript" language="javascript">var aWsbImages = {' . substr($sReturn, 0, -1) . '};</script>';
1892  }
1893 
1902  {
1903  return CH_WSB_URL_ROOT . 'gzip_loader.php?file=' . $sName . '.' . $sType;
1904  }
1905 
1912  {
1913  $sTitle = _t('_Access denied');
1914 
1915  $GLOBALS['_page'] = array(
1916  'name_index' => 0,
1917  'header' => $sTitle,
1918  'header_text' => $sTitle
1919  );
1920  $GLOBALS['_page_cont'][0]['page_main_code'] = MsgBox($sTitle);
1921 
1922  PageCode();
1923  exit;
1924  }
1925  function displayNoData ()
1926  {
1927  $sTitle = _t('_Empty');
1928 
1929  $GLOBALS['_page'] = array(
1930  'name_index' => 0,
1931  'header' => $sTitle,
1932  'header_text' => $sTitle
1933  );
1934  $GLOBALS['_page_cont'][0]['page_main_code'] = MsgBox($sTitle);
1935 
1936  PageCode();
1937  exit;
1938  }
1940  {
1941  $sTitle = _t('_Error Occured');
1942 
1943  $GLOBALS['_page'] = array(
1944  'name_index' => 0,
1945  'header' => $sTitle,
1946  'header_text' => $sTitle
1947  );
1948  $GLOBALS['_page_cont'][0]['page_main_code'] = MsgBox($sTitle);
1949 
1950  PageCode();
1951  exit;
1952  }
1954  {
1955  $sTitle = _t('_sys_request_page_not_found_cpt');
1956 
1957  $GLOBALS['_page'] = array(
1958  'name_index' => 0,
1959  'header' => $sTitle,
1960  'header_text' => $sTitle
1961  );
1962  $GLOBALS['_page_cont'][0]['page_main_code'] = MsgBox($sTitle);
1963 
1964  header("HTTP/1.0 404 Not Found");
1965  PageCode();
1966  exit;
1967  }
1968  function displayMsg ($s, $bTranslate = false)
1969  {
1970  $sTitle = $bTranslate ? _t($s) : $s;
1971 
1972  $GLOBALS['_page'] = array(
1973  'name_index' => 0,
1974  'header' => $sTitle,
1975  'header_text' => $sTitle
1976  );
1977  $GLOBALS['_page_cont'][0]['page_main_code'] = MsgBox($sTitle);
1978 
1979  PageCode();
1980  exit;
1981  }
1982 
1994  function processInjection($iPageIndex, $sKey, $sValue = "")
1995  {
1996  if($iPageIndex != 0 && isset($GLOBALS[$this->_sPrefix . 'Injections']['page_0'][$sKey]) && isset($GLOBALS[$this->_sPrefix . 'Injections']['page_' . $iPageIndex][$sKey]))
1997  $aSelection = @array_merge($GLOBALS[$this->_sPrefix . 'Injections']['page_0'][$sKey], $GLOBALS[$this->_sPrefix . 'Injections']['page_' . $iPageIndex][$sKey]);
1998  else if(isset($GLOBALS[$this->_sPrefix . 'Injections']['page_0'][$sKey]))
1999  $aSelection = $GLOBALS[$this->_sPrefix . 'Injections']['page_0'][$sKey];
2000  else if(isset($GLOBALS[$this->_sPrefix . 'Injections']['page_' . $iPageIndex][$sKey]))
2001  $aSelection = $GLOBALS[$this->_sPrefix . 'Injections']['page_' . $iPageIndex][$sKey];
2002  else
2003  $aSelection = array();
2004 
2005  if(is_array($aSelection))
2006  foreach($aSelection as $aInjection) {
2007 
2008  if (isset($GLOBALS['ch_profiler'])) $GLOBALS['ch_profiler']->beginInjection($sRand = time().rand());
2009 
2010  switch($aInjection['type']) {
2011  case 'text':
2012  $sInjData = $aInjection['data'];
2013  break;
2014  case 'php':
2015  ob_start();
2016  $sInjData = eval($aInjection['data']);
2017  if(!empty($sInjData))
2018  ob_end_clean();
2019  else
2020  $sInjData = ob_get_clean();
2021  break;
2022  }
2023  if((int)$aInjection['replace'] == 1)
2024  $sValue = $sInjData;
2025  else
2026  $sValue .= $sInjData;
2027 
2028  if (isset($GLOBALS['ch_profiler'])) $GLOBALS['ch_profiler']->endInjection($sRand, $aInjection['name'], $aInjection['key'], (int)$aInjection['replace'] == 1);
2029 
2030  }
2031 
2032  return $sValue != '__' . $sKey . '__' ? str_replace('__' . $sKey . '__', '', $sValue) : $sValue;
2033  }
2042  function addInjection($sKey, $sType, $sData, $iReplace = 0)
2043  {
2044  $GLOBALS[$this->_sPrefix . 'Injections']['page_0'][$sKey][] = array(
2045  'page_index' => 0,
2046  'key' => $sKey,
2047  'type' => $sType,
2048  'data' => $sData,
2049  'replace' => $iReplace
2050  );
2051  }
2052 }
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
ChTemplMemberMenu
Definition: ChTemplMemberMenu.php:14
CH_WSB_LOCALE_DATE
const CH_WSB_LOCALE_DATE
Definition: utils.inc.php:16
ChWsbTemplate\__construct
__construct($sRootPath=CH_DIRECTORY_PATH_ROOT, $sRootUrl=CH_WSB_URL_ROOT)
Definition: ChWsbTemplate.php:162
ChWsbTemplate\_getLoaderUrl
_getLoaderUrl($sType, $sName)
Definition: ChWsbTemplate.php:1901
ChWsbTemplate\$_sCacheFilePrefix
$_sCacheFilePrefix
Definition: ChWsbTemplate.php:149
ChWsbTemplate\$_sCacheFolderUrl
$_sCacheFolderUrl
Definition: ChWsbTemplate.php:146
ChWsbTemplate\_wrapInTagCss
_wrapInTagCss($sFile)
Definition: ChWsbTemplate.php:1296
ChWsbTemplate\$_bImagesInline
$_bImagesInline
Definition: ChWsbTemplate.php:150
ChWsbTemplate
Definition: ChWsbTemplate.php:121
ChWsbTemplate\getTemplatesCacheObject
getTemplatesCacheObject()
Definition: ChWsbTemplate.php:914
ChWsbTemplate\parsePageByName
parsePageByName($sName, $aVariables)
Definition: ChWsbTemplate.php:720
ChWsbTemplate\addJsImage
addJsImage($aImages)
Definition: ChWsbTemplate.php:461
ChWsbTemplate\_getCacheFileName
_getCacheFileName($sType, $sAbsolutePath)
Definition: ChWsbTemplate.php:1812
$sRootPath
$sRootPath
Definition: header.inc.php:37
ChWsbTemplate\getPageWidth
getPageWidth()
Definition: ChWsbTemplate.php:385
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
ChWsbTemplate\$_aTemplates
$_aTemplates
Definition: ChWsbTemplate.php:137
ChWsbTemplate\processInjection
processInjection($iPageIndex, $sKey, $sValue="")
Definition: ChWsbTemplate.php:1994
ChWsbTemplate\addDynamicLocationJs
addDynamicLocationJs($sLocationPath, $sLocationUrl)
Definition: ChWsbTemplate.php:344
ChWsbTemplate\removeLocation
removeLocation($sKey)
Definition: ChWsbTemplate.php:317
ChWsbTemplate\addLocation
addLocation($sKey, $sLocationPath, $sLocationUrl)
Definition: ChWsbTemplate.php:290
ch_js_string
ch_js_string($mixedInput, $iQuoteType=CH_ESCAPE_STR_AUTO)
Definition: utils.inc.php:1294
$sCode
$sCode
Definition: explanation.php:19
$sResult
$sResult
Definition: advanced_settings.php:26
ChWsbTemplate\displayAccessDenied
displayAccessDenied()
Definition: ChWsbTemplate.php:1911
CH_WSB_TEMPLATE_INJECTIONS_CACHE
const CH_WSB_TEMPLATE_INJECTIONS_CACHE
Definition: ChWsbTemplate.php:14
$_page
$_page['name_index']
Definition: about_us.php:13
ChWsbTemplate\$_sInjectionsTable
$_sInjectionsTable
Definition: ChWsbTemplate.php:128
ChWsbTemplate\addPageKeywords
addPageKeywords($mixedKeywords, $sDevider=',')
Definition: ChWsbTemplate.php:509
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
$aResult
$aResult
Definition: index.php:19
ch_get
ch_get($sName)
Definition: utils.inc.php:1664
use
GNU LESSER GENERAL PUBLIC LICENSE February Free Software Inc Franklin Fifth MA USA Everyone is permitted to copy and distribute verbatim copies of this license but changing it is not allowed[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it By the GNU General Public Licenses are intended to guarantee your freedom to share and change free software to make sure the software is free for all its users This the Lesser General Public applies to some specially designated software packages typically libraries of the Free Software Foundation and other authors who decide to use it You can use it but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular based on the explanations below When we speak of free we are referring to freedom of use
Definition: license.txt:27
ChWsbTemplate\addCss
addCss($mixedFiles, $bDynamic=false)
Definition: ChWsbTemplate.php:1114
ChWsbTemplate\$_sFolderCss
$_sFolderCss
Definition: ChWsbTemplate.php:134
ChWsbTemplate\addDynamicLocation
addDynamicLocation($sLocationPath, $sLocationUrl)
Definition: ChWsbTemplate.php:304
ChWsbTemplate\getIconUrl
getIconUrl($sName, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:569
$sUrl
$sUrl
Definition: cart.php:15
ChWsbTemplate\$_sKeyWrapperHtml
$_sKeyWrapperHtml
Definition: ChWsbTemplate.php:132
ChWsbTemplate\_wrapInTagCssCode
_wrapInTagCssCode($sCode)
Definition: ChWsbTemplate.php:1308
ChWsbTemplate\_compileJs
_compileJs($sAbsolutePath, &$aIncluded)
Definition: ChWsbTemplate.php:1044
php
ChWsbTemplate\addCssAsync
addCssAsync($mixedFiles)
Definition: ChWsbTemplate.php:1123
ChWsbTemplate\includeCssStyles
includeCssStyles()
Definition: ChWsbTemplate.php:1315
ChWsbTemplate\includeCssAsync
includeCssAsync()
Definition: ChWsbTemplate.php:1138
ChWsbTemplate\$_sCachePublicFolderUrl
$_sCachePublicFolderUrl
Definition: ChWsbTemplate.php:147
ChWsbTemplate\$_sJsCachePrefix
$_sJsCachePrefix
Definition: ChWsbTemplate.php:157
ChWsbTemplate\$_sFolderImages
$_sFolderImages
Definition: ChWsbTemplate.php:135
ChWsbTemplate\getMetaInfo
getMetaInfo()
Definition: ChWsbTemplate.php:534
ChWsbTemplate\$_bJsCache
$_bJsCache
Definition: ChWsbTemplate.php:155
ChWsbTemplate\deleteCss
deleteCss($mixedFiles)
Definition: ChWsbTemplate.php:1176
ChWsbTemplate\$_sCode
$_sCode
Definition: ChWsbTemplate.php:130
CH_WSB_TEMPLATE_DEFAULT_CODE
const CH_WSB_TEMPLATE_DEFAULT_CODE
Definition: ChWsbTemplate.php:10
ChWsbTemplate\_parseContent
_parseContent($sContent, $aVariables, $mixedKeyWrapperHtml=null)
Definition: ChWsbTemplate.php:1496
ChWsbTemplate\$_aLocations
$_aLocations
Definition: ChWsbTemplate.php:139
ChWsbTemplate\addCssSystem
addCssSystem($mixedFiles)
Definition: ChWsbTemplate.php:1166
ChWsbTemplate\_compileCss
_compileCss($sAbsolutePath, &$aIncluded)
Definition: ChWsbTemplate.php:1198
ChWsbTemplate\setPageDescription
setPageDescription($sDescription)
Definition: ChWsbTemplate.php:425
ChWsbTemplate\$_sCodeKey
$_sCodeKey
Definition: ChWsbTemplate.php:131
ChWsbTemplate\addJsIcon
addJsIcon($aIcons)
Definition: ChWsbTemplate.php:480
ChWsbTemplate\parseSystemKey
parseSystemKey($sKey, $mixedKeyWrapperHtml=null)
Definition: ChWsbTemplate.php:760
$oCache
$oCache
Definition: prof.inc.php:10
ChWsbTemplate\getImagePath
getImagePath($sName, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:610
ChWsbTemplate\addJsSystem
addJsSystem($mixedFiles)
Definition: ChWsbTemplate.php:1012
CH_WSB_TEMPLATE_CHECK_IN_TMPL
const CH_WSB_TEMPLATE_CHECK_IN_TMPL
Definition: ChWsbTemplate.php:18
ch_html_attribute
ch_html_attribute($mixedInput)
Definition: utils.inc.php:1324
ChWsbTemplate\$_sCachePublicFolderPath
$_sCachePublicFolderPath
Definition: ChWsbTemplate.php:148
ChWsbTemplate\$_bCssArchive
$_bCssArchive
Definition: ChWsbTemplate.php:153
$oFunctions
$oFunctions
Definition: ChTemplFunctions.php:20
ChWsbTemplate\$_bCssCache
$_bCssCache
Definition: ChWsbTemplate.php:152
ChWsbTemplate\displayNoData
displayNoData()
Definition: ChWsbTemplate.php:1925
ChWsbTemplate\addJsOption
addJsOption($mixedName)
Definition: ChWsbTemplate.php:434
ch_lang_info
ch_lang_info()
Definition: languages.inc.php:562
ChWsbTemplate\_getAbsoluteLocationJs
_getAbsoluteLocationJs($sType, $sName)
Definition: ChWsbTemplate.php:1761
ChWsbTemplate\setOpenGraphInfo
setOpenGraphInfo($a, $sNamespace='og')
Definition: ChWsbTemplate.php:527
ChWsbTemplate\parseHtmlByContent
parseHtmlByContent($sContent, $aVariables, $mixedKeyWrapperHtml=null)
Definition: ChWsbTemplate.php:687
CH_WSB_TEMPLATE_CHECK_IN_BOTH
const CH_WSB_TEMPLATE_CHECK_IN_BOTH
Definition: ChWsbTemplate.php:16
exit
exit
Definition: cart.php:21
ChWsbTemplate\_getInlineData
_getInlineData($sType, $sName, $sCheckIn)
Definition: ChWsbTemplate.php:1786
$sType
$sType
Definition: actions.inc.php:11
$sFile
$sFile
Definition: index.php:20
$_GET
$_GET['debug']
Definition: index.php:67
ChWsbTemplate\_wrapInTagJsCode
_wrapInTagJsCode($sCode)
Definition: ChWsbTemplate.php:1102
$oMemberMenu
$oMemberMenu
Definition: member_menu_queries.php:20
ChWsbTemplate\getCode
getCode()
Definition: ChWsbTemplate.php:376
ChWsbTemplate\$_sRootPath
$_sRootPath
Definition: ChWsbTemplate.php:126
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
getVersionComment
getVersionComment()
Definition: design.inc.php:203
ChWsbTemplate\_getAbsoluteLocationCss
_getAbsoluteLocationCss($sType, $sName)
Definition: ChWsbTemplate.php:1774
ChWsbTemplate\init
init()
Definition: ChWsbTemplate.php:249
ChWsbTemplate\getImageUrl
getImageUrl($sName, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:595
ChWsbTemplate\addJsTranslation
addJsTranslation($mixedKey)
Definition: ChWsbTemplate.php:447
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
$sTitle
$sTitle
Definition: actions.inc.php:13
ChWsbTemplate\setPageWidth
setPageWidth($sWidth)
Definition: ChWsbTemplate.php:394
ChWsbTemplate\$_sRootUrl
$_sRootUrl
Definition: ChWsbTemplate.php:127
ChWsbTemplate\_getAbsoluteLocation
_getAbsoluteLocation($sType, $sFolder, $sName, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:1711
ChWsbTemplate\displayErrorOccured
displayErrorOccured()
Definition: ChWsbTemplate.php:1939
CH_WSB_TEMPLATE_FOLDER_BASE
const CH_WSB_TEMPLATE_FOLDER_BASE
Definition: ChWsbTemplate.php:12
ChWsbTemplate\addLocationJs
addLocationJs($sKey, $sLocationPath, $sLocationUrl)
Definition: ChWsbTemplate.php:330
ChWsbTemplate\getTemplate
getTemplate($sName)
Definition: ChWsbTemplate.php:558
ChWsbTemplate\getCached
getCached($sName, &$aVariables, $mixedKeyWrapperHtml=null, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH, $bEvaluate=true)
Definition: ChWsbTemplate.php:932
ChWsbTemplate\_minifyCss
_minifyCss($s)
Definition: ChWsbTemplate.php:1263
getNickName
getNickName( $ID='')
Definition: profiles.inc.php:461
ChWsbTemplate\_processFiles
_processFiles($sType, $sAction, $mixedFiles, $bDynamic=false, $bSystem=false)
Definition: ChWsbTemplate.php:1422
ChWsbTemplate\$_sInjectionsCache
$_sInjectionsCache
Definition: ChWsbTemplate.php:129
$site
$site['ver']
Definition: version.inc.php:8
ChWsbTemplate\$_sFolderHtml
$_sFolderHtml
Definition: ChWsbTemplate.php:133
$sFolder
$sFolder
Definition: index.php:15
Minify_CSS_Compressor\process
static process($css, $options=array())
Definition: Compressor.php:32
templates_select_txt
templates_select_txt()
Definition: utils.inc.php:621
ch_file_get_contents
ch_file_get_contents($sFileUrl, $aParams=array(), $sMethod='get', $aHeaders=array(), &$sHttpCode=null)
Definition: utils.inc.php:1357
ch_instance
ch_instance($sClassName, $aParams=array(), $aModule=array())
Definition: utils.inc.php:1264
getUsername
getUsername( $ID='')
Definition: profiles.inc.php:443
ChWsbTemplate\_callbackParseUrl
static _callbackParseUrl($sPath, $aMatches)
Definition: ChWsbTemplate.php:1276
extFileExists
extFileExists($sFileSrc)
Definition: utils.inc.php:638
ChWsbTemplate\addInjection
addInjection($sKey, $sType, $sData, $iReplace=0)
Definition: ChWsbTemplate.php:2042
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
$sContent
$sContent
Definition: bottom_menu_compose.php:169
_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
ChWsbTemplate\getCssUrl
getCssUrl($sName, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:621
ChWsbTemplate\$_aLocationsJs
$_aLocationsJs
Definition: ChWsbTemplate.php:140
PageCode
PageCode($oTemplate=null)
Definition: design.inc.php:91
ChWsbTemplate\_processJsImages
_processJsImages()
Definition: ChWsbTemplate.php:1885
ChWsbTemplate\_processJsOptions
_processJsOptions()
Definition: ChWsbTemplate.php:1872
CH_WSB_LOCALE_DATE_SHORT
const CH_WSB_LOCALE_DATE_SHORT
Definition: utils.inc.php:15
ChWsbTemplate\getHtml
getHtml($sName, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:643
ChWsbTemplate\getCodeKey
getCodeKey()
Definition: ChWsbTemplate.php:367
ChWsbTemplate\getCssPath
getCssPath($sName, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:632
process_line_output
process_line_output($text, $maxwordlen=100)
Definition: utils.inc.php:328
ChWsbTemplate\$_bJsArchive
$_bJsArchive
Definition: ChWsbTemplate.php:156
ChWsbTemplate\displayMsg
displayMsg($s, $bTranslate=false)
Definition: ChWsbTemplate.php:1968
$s
$s
Definition: embed.php:13
ChWsbTemplate\addJs
addJs($mixedFiles, $bDynamic=false)
Definition: ChWsbTemplate.php:999
db_res
db_res($query, $bindings=[])
Definition: db.inc.php:39
ChWsbTemplate\_getKeyWrappers
_getKeyWrappers($mixedKeyWrapperHtml)
Definition: ChWsbTemplate.php:1835
$logged
$logged['member']
Definition: activation_email.php:16
ChWsbTemplate\$_sCssCachePrefix
$_sCssCachePrefix
Definition: ChWsbTemplate.php:154
ChWsbTemplate\parseHtmlByTemplateName
parseHtmlByTemplateName($sName, $aVariables, $mixedKeyWrapperHtml=null)
Definition: ChWsbTemplate.php:704
ChWsbTemplate\_processJsTranslations
_processJsTranslations()
Definition: ChWsbTemplate.php:1852
ChWsbTemplate\_wrapInTagJs
_wrapInTagJs($sFile)
Definition: ChWsbTemplate.php:1092
ChWsbTemplate\getIconPath
getIconPath($sName, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:584
ChWsbTemplate\_includeFiles
_includeFiles($sType, &$aFiles)
Definition: ChWsbTemplate.php:1404
ChWsbTemplate\loadTemplates
loadTemplates()
Definition: ChWsbTemplate.php:238
ChWsbTemplate\setPageMainBoxTitle
setPageMainBoxTitle($sTitle)
Definition: ChWsbTemplate.php:416
CH_WSB_TEMPLATE_CHECK_IN_BASE
const CH_WSB_TEMPLATE_CHECK_IN_BASE
Definition: ChWsbTemplate.php:17
ChWsbTemplate\deleteCssSystem
deleteCssSystem($mixedFiles)
Definition: ChWsbTemplate.php:1187
ChWsbTemplate\$_bCacheEnable
$_bCacheEnable
Definition: ChWsbTemplate.php:145
ch_lang_name
ch_lang_name()
Definition: languages.inc.php:557
$sAction
$sAction
Definition: categories.php:274
ChWsbTemplate\deleteJs
deleteJs($mixedFiles)
Definition: ChWsbTemplate.php:1022
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
$oTemplConfig
$oTemplConfig
Definition: params.inc.php:90
getLocaleDate
getLocaleDate($sTimestamp='', $iCode=CH_WSB_LOCALE_DATE_SHORT)
Definition: utils.inc.php:70
ChWsbTemplate\deleteJsSystem
deleteJsSystem($mixedFiles)
Definition: ChWsbTemplate.php:1033
ChWsbTemplate\setPageTitle
setPageTitle($sTitle)
Definition: ChWsbTemplate.php:407
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChWsbTemplate\$_sFolderIcons
$_sFolderIcons
Definition: ChWsbTemplate.php:136
ChWsbTemplate\$_sPrefix
$_sPrefix
Definition: ChWsbTemplate.php:125
$sName
$sName
Definition: ChWsbAdminTools.php:853
ChWsbTemplate\parseHtmlByName
parseHtmlByName($sName, $aVariables, $mixedKeyWrapperHtml=null, $sCheckIn=CH_WSB_TEMPLATE_CHECK_IN_BOTH)
Definition: ChWsbTemplate.php:660
CH_WSB_TEMPLATE_FOLDER_ROOT
const CH_WSB_TEMPLATE_FOLDER_ROOT
Definition: ChWsbTemplate.php:11
ChWsbTemplate\addCssStyle
addCssStyle($sName, $sContent)
Definition: ChWsbTemplate.php:499
ch_ltrim_str
ch_ltrim_str($sString, $sPrefix, $sReplace='')
Definition: utils.inc.php:1787
ChWsbTemplate\_compileContent
_compileContent($sContent, $aVarName, $iVarDepth, $aVarValues, $mixedKeyWrapperHtml=null)
Definition: ChWsbTemplate.php:1604
ChWsbTemplate\$_iImagesMaxSize
$_iImagesMaxSize
Definition: ChWsbTemplate.php:151
$iProfileId
if( $sMembersList) $iProfileId
Definition: communicator.php:29
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10
ChWsbTemplate\includeFiles
includeFiles($sType, $bSystem=false)
Definition: ChWsbTemplate.php:1339
ChWsbTemplate\removeLocationJs
removeLocationJs($sKey)
Definition: ChWsbTemplate.php:357
ChWsbTemplate\displayPageNotFound
displayPageNotFound()
Definition: ChWsbTemplate.php:1953