72 if (($req = @$_REQUEST[
'xoops_theme_select']) && $this->
isThemeAllowed($req)) {
74 if (isset(
$_SESSION) && $this->allowUserSelection) {
78 if (isset(
$_SESSION[$this->xoBundleIdentifier][
'defaultTheme'])) {
106 return (empty($this->allowedThemes) || in_array(
$name, $this->allowedThemes));
124 $inst = parent::createInstance(
$options);
127 $inst->template->assign(array(
128 'theme_path' => $inst->path,
'theme_tpl' => $inst->path .
'/xotpl',
'theme_url' => $inst->url,
129 'theme_img' => $inst->url .
'/img',
'theme_icons' => $inst->url .
'/icons',
130 'theme_css' => $inst->url .
'/css',
'theme_js' => $inst->url .
'/js',
131 'theme_lang' => $inst->url .
'/language',
237 'meta' => array(),
'link' => array(),
'script' => array()
307 $this->assets =
$xoops->assets();
310 $this->
template = null;
313 $this->
template->assignByRef(
'xoTheme', $this);
314 $this->
template->assign(array(
315 'xoops_theme' =>
$xoops->getConfig(
'theme_set'),
317 'xoops_themecss' =>
$xoops->getCss(
$xoops->getConfig(
'theme_set')),
318 'xoops_requesturi' => htmlspecialchars(
$_SERVER[
'REQUEST_URI'], ENT_QUOTES),
319 'xoops_sitename' => htmlspecialchars(
$xoops->getConfig(
'sitename'), ENT_QUOTES),
320 'xoops_slogan' => htmlspecialchars(
$xoops->getConfig(
'slogan'), ENT_QUOTES),
321 'xoops_dirname' =>
$xoops->moduleDirname,
322 'xoops_banner' => $this->renderBanner ?
$xoops->getBanner() :
' ',
323 'xoops_pagetitle' =>
$xoops->isModule() ?
$xoops->module->getVar(
'name') : htmlspecialchars(
$xoops->getConfig(
'slogan'), ENT_QUOTES)
325 $this->
template->assign(array(
326 'theme_path' => $this->path,
'theme_tpl' => $this->path .
'/xotpl',
'theme_url' => $this->url,
327 'theme_img' => $this->url .
'/img',
'theme_icons' => $this->url .
'/icons',
328 'theme_css' => $this->url .
'/css',
'theme_js' => $this->url .
'/js',
329 'theme_lang' => $this->url .
'/language',
337 $this->
template->assign(array(
338 'xoops_isuser' =>
true,
340 'xoops_userid' =>
$xoops->user->getVar(
'uid'),
'xoops_uname' =>
$xoops->user->getVar(
'uname'),
341 'xoops_name' =>
$xoops->user->getVar(
'name'),
'xoops_isadmin' =>
$xoops->isAdmin(),
342 'xoops_usergroups' =>
$xoops->user->getGroups()
345 $this->
template->assign(array(
346 'xoops_isuser' =>
false,
347 'xoops_isadmin' =>
false,
348 'xoops_usergroups' => array(FixedGroups::ANONYMOUS)
354 'description',
'keywords',
'robots',
'rating',
'author',
'copyright'
357 $this->
addMeta(
'meta', $name,
$xoops->getConfig(
'meta_' . $name));
362 'title',
'slogan',
'locale',
'footer',
'jquery_theme',
'startpage'
364 foreach ($assigns as $name) {
366 $this->
template->assign(
"xoops_$name",
$xoops->getConfig($name));
373 if (!empty($cssAssets)) {
379 if (!empty($jsAssets)) {
383 if ($this->bufferOutput) {
387 $xoops->setTpl($this->
template);
397 include_once($this->path .
"/theme_onload.php");
401 foreach ($this->plugins as $k => $bundleId) {
402 if (!is_object($bundleId)) {
404 $plugin =
new $bundleId();
405 $plugin->theme = $this;
408 $this->plugins[$bundleId] = null;
409 $this->plugins[$bundleId] = $plugin;
410 unset($this->plugins[$k]);
428 static $extra_string;
429 if (!$this->use_extra_cache_id) {
433 if (empty($extraString)) {
434 if (empty($extra_string)) {
436 $extra_string =
$xoops->getConfig(
'locale');
439 $extra_string .=
'-' . FixedGroups::ANONYMOUS;
448 $extraString = $extra_string;
450 $cache_id .=
'-' . $extraString;
461 if (
$_SERVER[
'REQUEST_METHOD'] !=
'POST' && $this->contentCacheLifetime) {
462 $template = $this->contentTemplate ? $this->contentTemplate :
'module:system/system_dummy.tpl';
463 $this->
template->caching = 2;
467 if (defined(
'SID') && SID && strpos(
$uri, SID)) {
468 $uri = preg_replace(
"/([\?&])(" . SID .
"$|" . SID .
"&)/",
"\\1",
$uri);
471 if ($this->template->isCached(
$template, $this->contentCacheId)) {
494 public function render($canvasTpl = null, $pageTpl = null, $contentTpl = null, $vars = array())
496 if ($this->renderCount) {
500 $xoops->events()->triggerEvent(
'core.theme.render.start', array($this));
501 $cache =
$xoops->cache($this->headersCacheEngine);
504 if ($this->contentCacheLifetime && $this->contentCacheId &&
$content = $cache->read($this->contentCacheId)) {
506 $this->htmlHeadStrings = array_merge($this->htmlHeadStrings,
$content[
'htmlHeadStrings']);
510 $xoops->setOption(
'xoops_pagetitle',
$content[
'xoops_pagetitle']);
514 if (
$xoops->getOption(
'xoops_pagetitle')) {
515 $this->
template->assign(
'xoops_pagetitle',
$xoops->getOption(
'xoops_pagetitle'));
517 $header = !
$xoops->getOption(
'xoops_module_header') ? $this->
template->getTemplateVars(
'xoops_module_header') :
$xoops->getOption(
'xoops_module_header');
520 if ($this->contentCacheLifetime && $this->contentCacheId && !$contentTpl) {
521 $content[
'htmlHeadStrings'] = (array)$this->htmlHeadStrings;
522 $content[
'metas'] = (array)$this->metas;
523 $content[
'xoops_pagetitle'] = $this->
template->getTemplateVars(
'xoops_pagetitle');
525 $cache->write($this->contentCacheId,
$content);
529 $old = array(
'robots',
'keywords',
'description',
'rating',
'author',
'copyright');
530 foreach ($this->metas[
'meta'] as
$name => $value) {
531 if (in_array(
$name, $old)) {
532 $this->
template->assign(
"xoops_meta_$name", htmlspecialchars($value, ENT_QUOTES));
533 unset($this->metas[
'meta'][
$name]);
538 $this->
template->assign(
'xoops_module_header', $this->
renderMetas(
true) .
"\n" .
$header);
541 $this->canvasTemplate = $canvasTpl;
544 $this->contentTemplate = $contentTpl;
547 $this->
template->assign($vars);
549 if ($this->contentTemplate) {
550 $this->content = $this->
template->fetch($this->contentTemplate, $this->contentCacheId);
552 if ($this->bufferOutput) {
553 $this->content .= ob_get_contents();
557 $this->
template->assignByRef(
'xoops_contents', $this->content);
560 $this->
template->caching = 0;
561 $this->
template->display($this->path .
'/' . $this->canvasTemplate);
562 $this->renderCount++;
563 $xoops->events()->triggerEvent(
'core.theme.render.end', array($this));
581 $cssAssets = array();
596 $jsAssets[] = $this->url .
'/locale/' . $language .
'/script.js';
599 $cssAssets[] = $this->path .
'/locale/' . $language .
'/style.css';
601 return array($cssAssets, $jsAssets);
657 if (empty($attributes)) {
658 $attributes = array();
662 $attributes[
'src'] = $src;
667 if (!isset($attributes[
'type'])) {
668 $attributes[
'type'] =
'text/javascript';
670 $this->
addMeta(
'script', $src, $attributes);
685 if (empty($attributes)) {
686 $attributes = array();
690 $attributes[
'href'] = $src;
692 if (!isset($attributes[
'type'])) {
693 $attributes[
'type'] =
'text/css';
698 $this->
addMeta(
'stylesheet', $src, $attributes);
795 return $this->assets->registerAssetReference(
$name,
$assets, $filters);
807 public function addLink($rel, $href =
'', $attributes = array())
809 if (empty($attributes)) {
810 $attributes = array();
813 $attributes[
'href'] = $href;
815 $attributes[
'rel'] = $rel;
816 $this->
addMeta(
'link',
'', $attributes);
832 unset($this->metas[
'http'][
$name]);
847 if (!isset($this->metas[
$type])) {
848 $this->metas[
$type] = array();
853 $this->metas[
$type][md5(serialize(array($value)))] = $value;
871 $this->htmlHeadStrings[] =
$content;
886 if (!empty($this->baseAssets[
'js'])) {
887 $url = $this->assets->getUrlToAssets(
'js', $this->baseAssets[
'js']);
889 $str .=
'<script src="' .
$url .
'" type="text/javascript"></script>'.
"\n";
893 if (!empty($this->baseAssets[
'css'])) {
894 $url = $this->assets->getUrlToAssets(
'css', $this->baseAssets[
'css']);
896 $str .=
'<link rel="stylesheet" href="' .
$url .
'" type="text/css" />'.
"\n";
900 foreach (array_keys($this->metas) as
$type) {
903 $str .= implode(
"\n", $this->htmlHeadStrings);
928 foreach ($this->metas[
$type] as $attrs) {
931 $str .=
"\n//<![CDATA[\n" . $attrs[
'_'] .
"\n//]]>";
933 $str .=
"</script>\n";
937 foreach ($this->metas[
$type] as $attrs) {
938 $rel = $attrs[
'rel'];
939 unset($attrs[
'rel']);
940 $str .=
'<link rel="' . $rel .
'"' . $this->
renderAttributes($attrs) .
" />\n";
944 foreach ($this->metas[
$type] as $attrs) {
947 .
">\n/* <![CDATA[ */\n" . $attrs[
'_'] .
"\n/* //]]> */\n</style>";
949 $str .=
'<link rel="stylesheet"' . $this->
renderAttributes($attrs) .
" />\n";
955 $str .=
'<meta http-equiv="' . htmlspecialchars(
$name, ENT_QUOTES) .
'" content="' . htmlspecialchars(
$content, ENT_QUOTES) .
"\" />\n";
960 $str .=
'<meta name="' . htmlspecialchars(
$name, ENT_QUOTES) .
'" content="' . htmlspecialchars(
$content, ENT_QUOTES) .
"\" />\n";
977 static $cache = array();
978 if (!isset($cache[$tagName])) {
979 $cache[$tagName] = 1;
981 return $tagName .
'-' . $cache[$tagName]++;
994 foreach ($coll as
$name => $val) {
996 $str .=
' ' .
$name .
'="' . htmlspecialchars($val, ENT_QUOTES) .
'"';
1011 if (substr(
$path, 0, 1) ==
'/') {
1018 return "{$this->themesPath}/{$this->folderName}/{$path}";
1023 return "themes/{$this->folderName}/{$path}";
1035 public $theme =
false;
1037 abstract function xoInit();
createInstance($options=array())
$_SESSION['RF']["verify"]
addBaseScriptAssets($assets)
createInstance($options=array())
generateCacheId($cache_id, $extraString= '')
getLocalizationAssets($type="main")
addScriptAssets($assets, $filters= 'default', $target=null)
if(DIRECTORY_SEPARATOR!="/") $xoops_root_path
addScript($src= '', $attributes=array(), $content= '')
static loadThemeLocale(XoopsTheme $theme)
addBaseStylesheetAssets($assets)
addLink($rel, $href= '', $attributes=array())
addStylesheetAssets($assets, $filters= 'default', $target=null)
addHttpMeta($name, $value=null)
addMeta($type= 'meta', $name= '', $value= '')
genElementId($tagName= 'xos')
renderMetas($return=false)
addStylesheet($src= '', $attributes=array(), $content= '')
setNamedAsset($name, $assets, $filters=null)
addBaseAssets($type, $assets)
if($xoops->isUser()&&$isAdmin) $response
headContent($params, $content, &$smarty, &$repeat)
render($canvasTpl=null, $pageTpl=null, $contentTpl=null, $vars=array())