blob: 82711e19815f76044ec010f52ba5e6f8a541086c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
<?php
/**
* Smarty plugin
* -------------------------------------------------------------
* File: resource.bitpackage.php
* Type: resource
* Name: bitpackage
* Purpose: Fetches templates from the correct package
* -------------------------------------------------------------
* @package Smarty
* @subpackage plugins
*/
class Smarty_Resource_Bitpackage extends Smarty_Resource_Custom {
protected function fetch ( $pTplName, &$pTplSource, &$pTplTime ) {
$resources = $this->getTplLocations( $pTplName );
foreach( $resources as $resource ) {
if( file_exists( $resource )) {
$pTplSource = file_get_contents( $resource );
$pTplTime = filemtime( $resource );
}
}
}
protected function fetchTimestamp( $pTplName ) {
$ret = FALSE;
foreach( $this->getTplLocations( $pTplName ) as $resource ) {
if( file_exists( $resource )) {
$ret = filemtime( $resource );
}
}
return $ret;
}
private function getTplLocations( $pTplName ) {
global $gBitThemes, $gNoForceStyle;
$path = explode( '/', $pTplName );
$package = array_shift( $path );
$template = array_pop( $path );
$subdir = '';
foreach( $path as $p ) {
$subdir .= $p.'/';
}
// files found in temp are special - these are stored in temp/<pkg>/(templates|modules)/<template.tpl>
if( $package == 'temp' ) {
// if it's a module, we need to look in the correct place
$subdir .= ( preg_match( '/\b(help_)?mod_/', $template ) ? 'modules' : 'templates' );
// we can't override these templates - they only exist in temp
$ret['package_template'] = constant( strtoupper( $package ).'_PKG_PATH' )."$subdir/$template";
} else {
if( empty( $gNoForceStyle )) {
// look in config/themes/force/
$ret['force'] = CONFIG_PKG_PATH."themes/force/$package/$subdir$template";
$ret['force_simple'] = CONFIG_PKG_PATH."themes/force/$subdir$template";
}
// look in themes/style/<stylename>/
$ret['override'] = $gBitThemes->getStylePath()."$package/$subdir$template";
$ret['override_simple'] = $gBitThemes->getStylePath().$subdir.$template;
// if it's a module, we need to look in the correct place
$subdir = ( preg_match( '/\b(help_)?mod_/', $template ) ? 'modules' : 'templates' )."/".$subdir;
// look for default package template
$ret['package_template'] = constant( strtoupper( $package ).'_PKG_PATH' )."$subdir$template";
}
return $ret;
}
}
?>
|