Source for file BitSmarty.php
Documentation is available at BitSmarty.php
* Smarty Library Inteface Class
* Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
* All Rights Reserved. See below for details and a complete list of authors.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
require_once( EXTERNAL_LIBS_PATH. 'smarty/libs/SmartyBC.class.php' );
function check( $perm ) {
return $gBitUser->hasPermission( $perm );
global $smarty_force_compile, $smarty_debugging;
$this->config_dir = "configs/";
// $this->caching = TRUE;
$this->force_compile = //$smarty_force_compile;
$this->debugging = isset ($smarty_debugging) && $smarty_debugging;
$this->assign( 'app_name', 'bitweaver' );
$this->register_prefilter( "add_link_ticket" );
$this->error_reporting = E_ALL & ~ E_NOTICE & ~ E_STRICT;
// SMARTY3 $this->register_object( 'perm', $permCheck, array(), TRUE, array( 'autoComplete' ));
$this->assign_by_ref( 'perm', $permCheck );
foreach( $gBitSystem->mPackages as &$packageHash ) {
if( $packageHash['dir'] != THEMES_PKG_DIR && file_exists( $packageHash['path']. 'smartyplugins' ) ) {
$this->plugins_dir = array_merge( array( $dir ), $this->plugins_dir );
public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false) {
if( strpos( $template, ':' )) {
list ( $resource, $location ) = explode( ':', $template);
if( $resource == 'bitpackage' ) {
list ( $package, $tpl ) = explode( '/', $location );
// exclude temp, as it contains nexus menus
if( !$gBitSystem->isPackageActive( $package ) && $package != 'temp' ) {
if( defined( 'TEMPLATE_DEBUG' ) && TEMPLATE_DEBUG == TRUE ) {
echo "\n<!-- - - - {$template} - - - -->\n";
return parent::fetch($template, $cache_id, $compile_id, $parent, $display, $merge_tpl_vars, $no_output_filter);
* @return hash of config values set in sibling .cfg file
$moduleConfigFile = str_replace( '.tpl', '.cfg', $pModuleRsrc );
$this->includeSiblingFile( $moduleConfigFile );
* 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
function includeSiblingFile( $pFile, $pIncludeVars= NULL ) {
list ( $resource, $location ) = explode( ':', $pFile );
if( $resource == 'bitpackage' ) {
list ( $package, $modFile ) = explode( '/', $location );
$subdir = preg_match( '/mod_/', $modFile ) ? 'modules' : 'templates';
$includeFile = "$path$subdir/$modFile";
global $gBitSmarty, $gBitSystem, $gBitUser, $gQueryUserId, $moduleParams;
if( !empty( $pIncludeVars['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( $pIncludeVars['module_params'] );
// Module Params were passed in from the template, like kernel/dynamic.tpl
$moduleParams = $this->get_template_vars( 'moduleParams' );
global $gBitThemes, $gBitLanguage, $bitdomain;
$endPath = $bitdomain. '/'. $gBitThemes->getStyle(). '/'. $gBitLanguage->mLanguage;
$compDir = $temp . "templates_c/$endPath";
$this->setCompileDir( $compDir );
$cacheDir = $temp . "cache/$endPath";
$this->setCacheDir( $cacheDir );
* add_link_ticket This will insert a ticket on all template URL's that have GET parameters.
* @param array $pTplSource source of template
* @return ammended template source
if( is_object( $gBitUser ) && $gBitUser->isRegistered() ) {
// $from = '#href="(.*PKG_URL.*php)\?(.*)&(.*)"#i';
// $to = 'href="\\1?\\2&tk={$gBitUser->mTicket}&\\3"';
// $pTplSource = preg_replace( $from, $to, $pTplSource );
$from = '#<form([^>]*)>#i';
// div tag is for stupid XHTML compliance.
$to = '<form\\1><div style="display:inline"><input type="hidden" name="tk" value="{$gBitUser->mTicket}" /></div>';
if( strpos( $pTplSource, '{form}' )) {
$pTplSource = str_replace( '{form}', '{form}<div style="display:inline"><input type="hidden" name="tk" value="{$gBitUser->mTicket}" /></div>', $pTplSource );
} elseif( strpos( $pTplSource, '{form ' ) ) {
$from = '#\{form(\}| [^\}]*)\}#i';
$to = '{form\\1}<div style="display:inline"><input type="hidden" name="tk" value="{$gBitUser->mTicket}" /></div>';
|