XOOPS  2.6.0
resource.block.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  */
11 
17 class Smarty_Resource_Block extends Smarty_Resource_Custom
18 {
28  protected function fetch($name, &$source, &$mtime)
29  {
30  $tpl = $this->blockTplInfo($name);
31  $stat = stat($tpl);
32  // Did we fail to get stat information?
33  if ($stat) {
34  $mtime = $stat['mtime'];
35  $filesize = $stat['size'];
36  $fp = fopen($tpl, 'r');
37  $source = ($filesize > 0) ? fread($fp, $filesize) : '';
38  fclose($fp);
39 
40  } else {
41  $source = null;
42  $mtime = null;
43  }
44  }
45 
53  private function blockTplInfo($tpl_name)
54  {
55  static $cache = array();
57  $tpl_info = $xoops->getTplInfo('block:'.$tpl_name);
58  $tpl_name = $tpl_info['tpl_name'];
59  $dirname = $tpl_info['module'];
60  $file = $tpl_info['file'];
61 
62  // why are we not checking $cache here?
63 
64  $theme_set = $xoops->getConfig('theme_set') ? $xoops->getConfig('theme_set') : 'default';
65  if (!file_exists($file_path = $xoops->path("themes/{$theme_set}/modules/{$dirname}/blocks/{$file}"))) {
66  $file_path = $xoops->path("modules/{$dirname}/templates/blocks/{$file}");
67  }
68  return $cache[$tpl_name] = $file_path;
69  }
70 }
$tpl
Definition: backend.php:39
static getInstance()
Definition: Xoops.php:160
if(!isset($xoops->paths[$path_type])) if($path_type== 'var') $file
Definition: browse.php:55
$xoops
Definition: admin.php:25
fetch($name, &$source, &$mtime)
$dirname
Definition: backend.php:38
if($file===false||$dir===false||!strstr($file, $dir)) if(empty($file)||strpos($file, '.php')!==false) $mtime
Definition: browse.php:71