diff options
| author | lsces <lester@lsces.co.uk> | 2026-02-02 09:41:21 +0000 |
|---|---|---|
| committer | lsces <lester@lsces.co.uk> | 2026-02-02 09:41:21 +0000 |
| commit | 25960cbcc47f0339272bab6c2b1cab7fea57d52e (patch) | |
| tree | 2f03e21cecf9b90c339830c5caf51e131f62dcf1 | |
| parent | 074a097c26e53bd2338e2f3162a1ff22276ff6b8 (diff) | |
| download | themes-25960cbcc47f0339272bab6c2b1cab7fea57d52e.tar.gz themes-25960cbcc47f0339272bab6c2b1cab7fea57d52e.tar.bz2 themes-25960cbcc47f0339272bab6c2b1cab7fea57d52e.zip | |
additional smarty plugins massaged for Smarty5
| -rwxr-xr-x | smartyplugins/function.attachhelp.php | 3 | ||||
| -rw-r--r-- | smartyplugins/resource.bitpackage.php | 130 |
2 files changed, 2 insertions, 131 deletions
diff --git a/smartyplugins/function.attachhelp.php b/smartyplugins/function.attachhelp.php index a9cdc89..c42b989 100755 --- a/smartyplugins/function.attachhelp.php +++ b/smartyplugins/function.attachhelp.php @@ -1,5 +1,6 @@ <?php namespace Bitweaver\Plugins; +use Bitweaver\KernelTools; /** * Smarty plugin @@ -26,7 +27,7 @@ function smarty_function_attachhelp( $pParams, &$gSmartyTemplate ) { // prepare the output if( empty( $pParams['attachment_id'] )) { - $gBitSmarty->trigger_error( tra( 'You need to provide an attachment_id' )); + trigger_error( KernelTools::tra( 'You need to provide an attachment_id' )); return; } elseif( !empty( $pParams['wiki_plugin_link'] )) { $attachhelp = trim( $pParams['wiki_plugin_link'] ); diff --git a/smartyplugins/resource.bitpackage.php b/smartyplugins/resource.bitpackage.php deleted file mode 100644 index 9207465..0000000 --- a/smartyplugins/resource.bitpackage.php +++ /dev/null @@ -1,130 +0,0 @@ -<?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 $location => $resource ) { - if( file_exists( $resource )) { - $pTplSource = file_get_contents( $resource ); - $pTplTime = filemtime( $resource ); - return; - } - } - } - - /** - * THE method to invoke if you want to be sure a tpl's sibling php file gets included if it exists. This - * should not need to be invoked from anywhere except within this class - * - * @param string $pFile file to be included, should be of the form "bitpackage:<packagename>/<templatename>" - * @return TRUE if a sibling php file was included - * @access private - */ - public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null) { - global $gBitThemes; - $ret = FALSE; - - if( $siblingPhpFile = static::getSiblingPhpFile( $source->name ) ) { - global $gBitSmarty, $gBitSystem, $gBitUser, $gQueryUserId, $moduleParams; - $moduleParams = array(); - if( !empty( $_template->tpl_vars['moduleParams'] ) ) { - // Module Params were passed in from the template, like kernel/dynamic.tpl - $moduleParams = $_template->tpl_vars['moduleParams']->value; - } - if( !empty( $_template->tpl_vars['module_params'] ) ) { - // module_params were passed through via the {include}, - // e.g. {include file="bitpackage:foobar/mod_list_foo.tpl" module_params="user_id=`$gBitUser->mUserId`&sort_mode=created_desc"} - $moduleParams['module_params'] = $gBitThemes->parseString( $_template->tpl_vars['module_params']->value ); - } - //$_template->templateId = md5(serialize( $moduleParams )); - include( $siblingPhpFile ); - } - - parent::populate( $source, $_template ); - } - - public static function getSiblingPhpFile( $pTplName ) { - $ret = NULL; - if( preg_match('/mod_/', $pTplName ) || preg_match( '/center_/', $pTplName ) ) { - if( strpos( $pTplName, '/' )) { - list( $package, $modFile ) = explode( '/', $pTplName ); - $subdir = preg_match( '/mod_/', $modFile ) ? 'modules' : 'templates'; - global $gBitSmarty, $gBitSystem, $gBitUser, $gQueryUserId, $moduleParams; - // the PHP sibling file needs to be included here, before the fetch so caching works properly - $modFile = str_replace( '.tpl', '.php', $modFile ); - - $path = constant( strtoupper( $package )."_PKG_PATH" ); - $includeFile = "$path$subdir/$modFile"; - - if( file_exists( $includeFile )) { - $ret = $includeFile; - } - } - } - return $ret; - } - - - protected function fetchTimestamp( $pTplName ) { - $ret = FALSE; - $locations = $this->getTplLocations( $pTplName ); - foreach( $locations as $resource ) { - if( file_exists( $resource )) { - $ret = filemtime( $resource ); - break; - } - } - 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; - } -} - |
