XOOPS  2.6.0
resource.module.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_Module extends Smarty_Resource_Custom
18 {
28  protected function fetch($name, &$source, &$mtime)
29  {
30  $tpl = $this->moduleTplInfo($name);
31  $stat = stat($tpl);
32 
33  // Did we fail to get stat information?
34  if ($stat) {
35  $mtime = $stat['mtime'];
36  $filesize = $stat['size'];
37  $fp = fopen($tpl, 'r');
38  $source = ($filesize > 0) ? fread($fp, $filesize) : '';
39  fclose($fp);
40 
41  } else {
42  $source = null;
43  $mtime = null;
44  }
45  }
46 
54  private function moduleTplInfo($tpl_name)
55  {
56  static $cache = array();
58  $tpl_info = $xoops->getTplInfo('module:'.$tpl_name);
59  $tpl_name = $tpl_info['tpl_name'];
60  $dirname = $tpl_info['module'];
61  $file = $tpl_info['file'];
62 
63  if (isset($cache[$tpl_name])) {
64  return $cache[$tpl_name];
65  }
66 
67  $theme_set = $xoops->getConfig('theme_set') ? $xoops->getConfig('theme_set') : 'default';
68  if (!file_exists($file_path = $xoops->path("themes/{$theme_set}/modules/{$dirname}/{$file}"))) {
69  $file_path = $xoops->path("modules/{$dirname}/templates/{$file}");
70  }
71  return $cache[$tpl_name] = $file_path;
72  }
73 }
$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
fetch($name, &$source, &$mtime)
$xoops
Definition: admin.php:25
$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