Smarty
[ class tree: Smarty ] [ index: Smarty ] [ all elements ]

Source for file BitSmarty.php

Documentation is available at BitSmarty.php

  1. <?php
  2. /**
  3.  * Smarty Library Inteface Class
  4.  *
  5.  * @package Smarty
  6.  * @version $Header$
  7.  *
  8.  *  Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
  9.  *  All Rights Reserved. See below for details and a complete list of authors.
  10.  *  Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
  11.  */
  12.  
  13. /**
  14.  * required setup
  15.  */
  16.  
  17. require_onceEXTERNAL_LIBS_PATH.'smarty/libs/SmartyBC.class.php' );
  18.  
  19.  
  20. /**
  21.  * PermissionCheck
  22.  *
  23.  * @package kernel
  24.  */
  25. class PermissionCheck {
  26.     function check$perm {
  27.         global $gBitUser;
  28.         return $gBitUser->hasPermission$perm );
  29.     }
  30. }
  31.  
  32. /**
  33.  * BitSmarty
  34.  *
  35.  * @package kernel
  36.  */
  37. class BitSmarty extends SmartyBC {
  38.  
  39.     protected $mCompileRsrc;
  40.  
  41.     /**
  42.      * BitSmarty initiation
  43.      *
  44.      * @access public
  45.      * @return void 
  46.      */
  47.     function __construct({
  48.         global $smarty_force_compile$smarty_debugging;
  49.         parent::__construct();
  50.         $this->mCompileRsrc = NULL;
  51.         $this->config_dir "configs/";
  52.         // $this->caching = TRUE;
  53.         $this->force_compile //$smarty_force_compile;
  54.         $this->debugging = isset($smarty_debugging&& $smarty_debugging;
  55.         $this->assign'app_name''bitweaver' );
  56.         $this->addPluginsDirTHEMES_PKG_PATH "smartyplugins" );
  57.         $this->register_prefilter"add_link_ticket" );
  58.         $this->error_reporting E_ALL ~E_NOTICE ~E_STRICT;
  59.  
  60.         global $permCheck;
  61.         $permCheck new PermissionCheck();
  62. // SMARTY3    $this->register_object( 'perm', $permCheck, array(), TRUE, array( 'autoComplete' ));
  63.         $this->assign_by_ref'perm'$permCheck );
  64.     }
  65.  
  66.     function scanPackagePluginDirs({
  67.         global $gBitSystem;
  68.         foreach$gBitSystem->mPackages as &$packageHash {
  69.             if$packageHash['dir'!= THEMES_PKG_DIR && file_exists$packageHash['path'].'smartyplugins' ) ) {
  70.                 $this->addPluginsDir$packageHash['path'].'smartyplugins' );
  71.             }
  72.         }
  73.     }
  74.  
  75.     function addPluginsDir$dir {
  76.         $this->plugins_dir array_mergearray$dir )$this->plugins_dir );
  77.     }
  78.  
  79.     public function fetch($template null$cache_id null$compile_id null$parent null$display false$merge_tpl_vars true$no_output_filter false{
  80.         global $gBitSystem;
  81.  
  82.         ifstrpos$template':' )) {
  83.             list$resource$location explode':'$template);
  84.             if$resource == 'bitpackage' {
  85.                 list$package$tpl explode'/'$location );
  86.                 // exclude temp, as it contains nexus menus
  87.                 if!$gBitSystem->isPackageActive$package && $package != 'temp' {
  88.                     return '';
  89.                 }
  90.             }
  91.         }
  92.  
  93.         ifdefined'TEMPLATE_DEBUG' && TEMPLATE_DEBUG == TRUE {
  94.             echo "\n<!-- - - - {$template} - - - -->\n";
  95.         }
  96.  
  97.         return parent::fetch($template$cache_id$compile_id$parent$display$merge_tpl_vars$no_output_filter);
  98.     }
  99.  
  100.     /**
  101.      * getModuleConfig
  102.      *
  103.      * @access public
  104.      * @return hash of config values set in sibling .cfg file
  105.      */
  106.     function getModuleConfig$pModuleRsrc {
  107.         global $moduleConfig;
  108.         $moduleConfig array();
  109.         $moduleConfigFile str_replace'.tpl''.cfg'$pModuleRsrc );
  110.         $this->includeSiblingFile$moduleConfigFile );
  111.         return $moduleConfig;
  112.     }
  113.  
  114.     /**
  115.      * THE method to invoke if you want to be sure a tpl's sibling php file gets included if it exists. This
  116.      * should not need to be invoked from anywhere except within this class
  117.      *
  118.      * @param string $pFile file to be included, should be of the form "bitpackage:<packagename>/<templatename>"
  119.      * @return TRUE if a sibling php file was included
  120.      * @access private
  121.      */
  122.     function includeSiblingFile$pFile$pIncludeVars=NULL {
  123.         global $gBitThemes;
  124.         $ret FALSE;
  125.         ifstrpos$pFile':' )) {
  126.             list$resource$location explode':'$pFile );
  127.             if$resource == 'bitpackage' {
  128.                 list$package$modFile explode'/'$location );
  129.                 $subdir preg_match'/mod_/'$modFile 'modules' 'templates';
  130.                 ifpreg_match('/mod_/'$modFile || preg_match'/center_/'$modFile ) ) {
  131.                     global $gBitSystem;
  132.                     $path constantstrtoupper$package )."_PKG_PATH" );
  133.                     $includeFile "$path$subdir/$modFile";
  134.                     iffile_exists$includeFile )) {
  135.                         global $gBitSmarty$gBitSystem$gBitUser$gQueryUserId$moduleParams;
  136.                         $moduleParams array();
  137.                         if!empty$pIncludeVars['module_params') ) {
  138.                             // module_params were passed through via the {include},
  139.                             // e.g. {include file="bitpackage:foobar/mod_list_foo.tpl" module_params="user_id=`$gBitUser->mUserId`&sort_mode=created_desc"}
  140.                             $moduleParams['module_params'$gBitThemes->parseString$pIncludeVars['module_params');
  141.                         else {
  142.                             // Module Params were passed in from the template, like kernel/dynamic.tpl
  143.                             $moduleParams $this->get_template_vars'moduleParams' );
  144.                         }
  145.                         include$includeFile );
  146.                         $ret TRUE;
  147.                     }
  148.                 }
  149.             }
  150.         }
  151.     }
  152.  
  153.     /**
  154.      * verifyCompileDir
  155.      *
  156.      * @access public
  157.      * @return void 
  158.      */
  159.     function verifyCompileDir({
  160.         global $gBitThemes$gBitLanguage$bitdomain;
  161.         if!defined"TEMP_PKG_PATH" )) {
  162.             $temp BIT_ROOT_PATH "temp/";
  163.         else {
  164.             $temp TEMP_PKG_PATH;
  165.         }
  166.  
  167.         $endPath $bitdomain.'/'.$gBitThemes->getStyle().'/'.$gBitLanguage->mLanguage;
  168.  
  169.         // Compile directory
  170.         $compDir $temp "templates_c/$endPath";
  171.         $compDir str_replace'//''/'$compDir );
  172.         $compDir clean_file_path$compDir );
  173.         mkdir_p$compDir );
  174.         $this->setCompileDir$compDir );
  175.  
  176.         // Cache directory
  177.         $cacheDir $temp "cache/$endPath";
  178.         $cacheDir str_replace'//''/'$cacheDir );
  179.         $cacheDir clean_file_path$cacheDir );
  180.         mkdir_p$cacheDir );
  181.         $this->setCacheDir$cacheDir );
  182.     }
  183. }
  184.  
  185. /**
  186.  * add_link_ticket This will insert a ticket on all template URL's that have GET parameters.
  187.  *
  188.  * @param array $pTplSource source of template
  189.  * @access public
  190.  * @return ammended template source
  191.  */
  192. function add_link_ticket$pTplSource {
  193.     global $gBitUser;
  194.  
  195.     ifis_object$gBitUser && $gBitUser->isRegistered() ) {
  196. //        $from = '#href="(.*PKG_URL.*php)\?(.*)&(.*)"#i';
  197. //        $to = 'href="\\1?\\2&amp;tk={$gBitUser->mTicket}&\\3"';
  198. //        $pTplSource = preg_replace( $from, $to, $pTplSource );
  199.         $from '#<form([^>]*)>#i';
  200.         // div tag is for stupid XHTML compliance.
  201.         $to '<form\\1><div style="display:inline"><input type="hidden" name="tk" value="{$gBitUser->mTicket}" /></div>';
  202.         $pTplSource preg_replace$from$to$pTplSource );
  203.         ifstrpos$pTplSource'{form}' )) {
  204.             $pTplSource str_replace'{form}''{form}<div style="display:inline"><input type="hidden" name="tk" value="{$gBitUser->mTicket}" /></div>'$pTplSource );
  205.         elseifstrpos$pTplSource'{form ' ) ) {
  206.             $from '#\{form(\}| [^\}]*)\}#i';
  207.             $to '{form\\1}<div style="display:inline"><input type="hidden" name="tk" value="{$gBitUser->mTicket}" /></div>';
  208.             $pTplSource preg_replace$from$to$pTplSource );
  209.         }
  210.     }
  211.  
  212.     return $pTplSource;
  213. }
  214. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:00 +0000 by phpDocumentor 1.5.0-lsces