23 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
25 include_once
$GLOBALS['xoops']->path('class/xoopsblock.php');
26 include_once
$GLOBALS['xoops']->path('class/template.php');
39 var $blocks = array();
49 $this->retrieveBlocks();
51 $this->theme->template->assign_by_ref(
'xoBlocks', $this->blocks);
59 function preRender($zone =
'')
65 function postRender($zone =
'')
74 function retrieveBlocks()
79 $startMod = ($xoopsConfig[
'startpage'] ==
'--') ?
'system' : $xoopsConfig[
'startpage'];
82 $GLOBALS[
'xoopsModule']->getVar(
'mid') ,
83 $GLOBALS[
'xoopsModule']->getVar(
'dirname'));
84 $isStart = (substr(
$_SERVER[
'PHP_SELF'], - 9) ==
'index.php' && $xoopsConfig[
'startpage'] ==
$dirname && empty(
$_SERVER[
'QUERY_STRING']));
89 $isStart = !empty(
$GLOBALS[
'xoopsOption'][
'show_cblock']);
93 XOOPS_GROUP_ANONYMOUS);
104 foreach ($oldzones as $zone) {
105 $this->blocks[$zone] = array();
108 $template =& $this->theme->template;
111 $template->cache_lifetime);
117 $block_arr = array();
119 $xoopsPreload->triggerEvent(
'core.class.theme_blocks.retrieveBlocks', array(&$this, &$template, &$block_arr));
120 foreach ($block_arr as $block) {
121 $side = $oldzones[$block->getVar(
'side')];
122 if (
$var = $this->buildBlock($block, $template)) {
123 $this->blocks[$side][
$var[
"id"]] =
$var;
127 list ($template->caching, $template->cache_lifetime) = $backup;
137 function generateCacheId($cache_id)
140 $cache_id = $this->theme->generateCacheId($cache_id);
152 function buildBlock($xobject, &$template)
157 'id' => $xobject->getVar(
'bid') ,
158 'module' => $xobject->getVar(
'dirname') ,
159 'title' => $xobject->getVar(
'title') ,
161 'weight' => $xobject->getVar(
'weight') ,
162 'lastmod' => $xobject->getVar(
'last_modified'));
164 $bcachetime = intval($xobject->getVar(
'bcachetime'));
165 if (empty($bcachetime)) {
166 $template->caching = 0;
168 $template->caching = 2;
169 $template->cache_lifetime = $bcachetime;
171 $template->setCompileId($xobject->getVar(
'dirname',
'n'));
172 $tplName = ($tplName = $xobject->getVar(
'template')) ?
"db:$tplName" :
'db:system_block_dummy.html';
173 $cacheid = $this->generateCacheId(
'blk_' . $xobject->getVar(
'bid'));
176 if (!$bcachetime || !$template->is_cached($tplName, $cacheid)) {
179 if ($this->theme && $bcachetime) {
180 foreach ($this->theme->metas as
$type => $value) {
186 $xoopsLogger->addBlock($xobject->getVar(
'name'));
187 if ($bresult = $xobject->buildBlock()) {
188 $template->assign(
'block', $bresult);
189 $block[
'content'] = $template->fetch($tplName, $cacheid);
195 if ($this->theme && $bcachetime) {
197 foreach ($this->theme->metas as
$type => $value) {
198 $dif = array_diff_assoc($this->theme->metas[
$type], $old[
$type]);
200 $metas[
$type] = $dif;
206 $cache->write($cacheid, $metas);
210 $xoopsLogger->addBlock($xobject->getVar(
'name'),
true, $bcachetime);
211 $block[
'content'] = $template->fetch($tplName, $cacheid);
215 if ($this->theme && $bcachetime) {
218 if ($metas = $cache->read($cacheid)) {
219 foreach ($metas as
$type => $value) {
220 $this->theme->metas[
$type] = array_merge($this->theme->metas[
$type], $metas[
$type]);
225 $template->setCompileId();