Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:bitweaver/themes
- Loading branch information
Showing
2 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Smarty plugin | ||
* ------------------------------------------------------------- | ||
* File: resource._custom.php | ||
* Type: resource | ||
* Name: _custom | ||
* Purpose: Fetches templates from the correct package | ||
* ------------------------------------------------------------- | ||
* @package Smarty | ||
* @subpackage plugins | ||
*/ | ||
|
||
class Smarty_Resource__Custom extends Smarty_Resource_Custom { | ||
|
||
protected function fetch ( $pTplName, &$pTplSource, &$pTplTime ) { | ||
global $gBitLanguage, $gBitThemes, $gBitSmarty; | ||
$ret = ''; | ||
|
||
// We're gonna run our own cache mechanism for user_modules | ||
// the cache is here to avoid calls to consumming queries, | ||
// each module is different for each language because of the strings | ||
$cacheDir = TEMP_PKG_PATH.'modules/cache/'; | ||
if( !is_dir( $cacheDir )) { | ||
mkdir_p( $cacheDir ); | ||
} | ||
list( $package, $template ) = explode( '/', $pTplName ); | ||
$cacheFile = $cacheDir.'_custom.'.$gBitLanguage->mLanguage.'.'.$template.'.tpl.cache'; | ||
|
||
if( !empty( $r["cache_time"] ) && file_exists( $cacheFile ) && !(( $gBitSystem->getUTCTime() - filemtime( $cacheFile )) > $r["cache_time"] )) { | ||
$pTplSource = file_get_contents( $cacheFile ); | ||
} else { | ||
global $moduleParams; | ||
if( $moduleParams = $gBitThemes->getCustomModule( $template )) { | ||
$gBitSmarty->assign_by_ref( 'moduleParams', $moduleParams ); | ||
$pTplSource = $gBitSmarty->fetch( 'bitpackage:themes/custom_module.tpl' ); | ||
// write to chache file | ||
$fp = fopen( $cacheFile, "w+" ); | ||
fwrite( $fp, $data, strlen( $data )); | ||
fclose( $fp ); | ||
} | ||
} | ||
$pTplTime = filemtime( $cacheFile ); | ||
} | ||
|
||
protected function fetchTimestamp( $pTplName ) { | ||
return null; | ||
} | ||
|
||
} | ||
|
||
|