/**
  * 构造函数
  *
  * @param Smarty $tpl
  *
  * @return FLEA_View_SmartyHelper
  */
 function FLEA_View_SmartyHelper(&$tpl)
 {
     $tpl->register_function('url', array(&$this, '_pi_func_url'));
     $tpl->register_function('webcontrol', array(&$this, '_pi_func_webcontrol'));
     $tpl->register_function('_t', array(&$this, '_pi_func_t'));
     $tpl->register_function('get_app_inf', array(&$this, '_pi_func_get_app_inf'));
     $tpl->register_function('dump_ajax_js', array(&$this, '_pi_func_dump_ajax_js'));
     $tpl->register_modifier('parse_str', array(&$this, '_pi_mod_parse_str'));
     $tpl->register_modifier('to_hashmap', array(&$this, '_pi_mod_to_hashmap'));
     $tpl->register_modifier('col_values', array(&$this, '_pi_mod_col_values'));
 }
 /**
  * 构造函数
  *
  * @param Smarty $tpl
  */
 public function __construct($tpl)
 {
     $tpl->register_function('url', array(&$this, '_pi_func_url'));
     $tpl->register_function('webcontrol', array(&$this, '_pi_func_webcontrol'));
     $tpl->register_function('_t', array(&$this, '_pi_func_t'));
     $tpl->register_function('get_conf', array(&$this, '_pi_func_get_conf'));
     $tpl->register_function('dump_ajax_js', array(&$this, '_pi_func_dump_ajax_js'));
     $tpl->register_modifier('parse_str', array(&$this, '_pi_mod_parse_str'));
     $tpl->register_modifier('to_hashmap', array(&$this, '_pi_mod_to_hashmap'));
     $tpl->register_modifier('col_values', array(&$this, '_pi_mod_col_values'));
     $tpl->register_modifier('friendly_time', array(&$this, '_friendly_time'));
 }
Exemple #3
0
 function __construct(QContext $context)
 {
     parent::__construct($context);
     $this->smarty = new Smarty();
     $view_config = (array) $context->getIni('view_config');
     foreach ($view_config as $key => $value) {
         $this->smarty->{$key} = $value;
     }
     $this->smarty->assign('context', $this->context);
     $this->smarty->assign('view_adapter', $this);
     $this->smarty->register_function('url', array($this, 'func_url'));
     $this->smarty->register_function('control', array($this, 'func_control'));
     $this->smarty->register_function('ini', array($this, 'func_ini'));
     $this->smarty->register_modifier('mb_truncate', array($this, 'mod_mb_truncate'));
 }
Exemple #4
0
/**
 * @return   Smarty  Locally-usable Smarty instance.
 */
function get_smarty_instance()
{
    $s = new Smarty();
    $s->compile_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates', 'cache'));
    $s->cache_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates', 'cache'));
    $s->template_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates'));
    $s->config_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates'));
    $s->register_modifier('url_domain', 'get_url_domain');
    $s->register_modifier('nice_relative_time', 'get_relative_time');
    $s->assign('domain', get_domain_name());
    $s->assign('base_dir', get_base_dir());
    $s->assign('base_href', get_base_href());
    $s->assign('logo', '<img src="' . LOGO . '" />');
    $s->assign('site_title', SITE_TITLE);
    //	    $s->clear_all_cache();
    return $s;
}
Exemple #5
0
 public static function init_smarty()
 {
     $smarty = new Smarty();
     $theme = self::get_default_template();
     $smarty->template_dir = DATA_DIR . '/Base_Theme/templates/' . $theme;
     $smarty->compile_dir = DATA_DIR . '/Base_Theme/compiled/';
     $smarty->compile_id = $theme;
     $smarty->config_dir = DATA_DIR . '/Base_Theme/config/';
     $smarty->cache_dir = DATA_DIR . '/Base_Theme/cache/';
     $smarty->register_modifier('t', array(__CLASS__, 'smarty_modifier_translate'));
     return $smarty;
 }
 /**
  * Loads all *.function.php files in the folder and register the function
  */
 public function loadExtraPlugins($path)
 {
     $i = new DirectoryIterator($path);
     foreach ($i as $file) {
         // Adds custom functions and modifiers
         if (preg_match('/^function\\.(.+)\\.php$/', $file, $match)) {
             /** @todo include_once instead and rather log the error? */
             require_once $file->getPathname();
             $this->_smarty->register_function($match[1], 'smarty_function_' . $match[1]);
         } else {
             if (preg_match('/^modifier\\.(.+)\\.php$/', $file, $match)) {
                 /** @todo include_once instead and rather log the error? */
                 require_once $file->getPathname();
                 $this->_smarty->register_modifier($match[1], 'smarty_modifier_' . $match[1]);
             }
         }
     }
 }
Exemple #7
0
 public static function smarty_factory()
 {
     if (!isset($_SERVER['smartybase'])) {
         $_SERVER['smartybase'] = "/var/tmp/smarty-" . md5($_SERVER['SCRIPT_FILENAME']);
     }
     if (!lib::$appvars) {
         lib::$appvars = array('filebase' => $_SERVER['filebase'], 'mediabase' => $_SERVER['mediabase'], 'uribase' => $_SERVER['uribase'], 'urirequest' => $_SERVER['urirequest']);
     }
     $smbase = $_SERVER['smartybase'];
     #@mkdir("$smbase/templates", 0777, true);
     @mkdir("{$smbase}/templates_c", 0777, true);
     @mkdir("{$smbase}/cache", 0777, true);
     $smarty = new Smarty();
     $smarty->template_dir = "./views";
     $smarty->compile_dir = "{$smbase}/templates_c";
     $smarty->cache_dir = "{$smbase}/cache";
     # we don't set config dir, we most likely won't use it initially
     $smext = array('smarty_extensions', 'smarty_custom');
     foreach ($smext as $smo) {
         $mnames = get_class_methods($smo);
         foreach ($mnames as $method) {
             if (preg_match('/^func_(\\w+)$/', $method, $m)) {
                 $smarty->register_function($m[1], array($smo, $method));
             } elseif (preg_match('/^modifier_(\\w+)$/', $method, $m)) {
                 $smarty->register_modifier($m[1], array($smo, $method));
             } elseif (preg_match('/^block_(\\w+)$/', $method, $m)) {
                 $smarty->register_block($m[1], array($smo, $method));
             }
         }
     }
     # these are order dependent
     $smarty->register_prefilter(array('smarty_extensions', 'prefilter_convert_loop_breaks'));
     $smarty->register_prefilter(array('smarty_extensions', 'prefilter_convert_loop_continue'));
     $smarty->assign_by_ref('app', lib::$appvars);
     if (file_exists("setup/template_conf.php")) {
         include "setup/template_conf.php";
     }
     return $smarty;
 }
Exemple #8
0
/**
 * @return   Smarty  Locally-usable Smarty instance.
 */
function get_smarty_instance($user)
{
    $s = new Smarty();
    $s->compile_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates', 'cache'));
    $s->cache_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates', 'cache'));
    $s->template_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates'));
    $s->config_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'templates'));
    $s->assign('domain', get_domain_name());
    $s->assign('base_dir', get_base_dir());
    $s->assign('base_href', get_base_href());
    $s->assign('constants', get_defined_constants());
    $s->assign('providers', get_map_providers());
    $s->assign('request', array('get' => $_GET, 'post' => $_POST, 'uri' => $_SERVER['REQUEST_URI'], 'query' => $_SERVER['QUERY_STRING'], 'authenticated' => isset($user), 'user' => $user));
    $s->register_modifier('nice_placename', 'nice_placename');
    $s->register_modifier('nice_domainname', 'nice_domainname');
    $s->register_modifier('nice_relativetime', 'nice_relativetime');
    $s->register_modifier('nice_datetime', 'nice_datetime');
    $s->register_modifier('nice_degree', 'nice_degree');
    $s->register_modifier('decode_utf8', 'decode_utf8');
    return $s;
}
 function render($aDict = null)
 {
     $smarty = new Smarty();
     $oConfig =& KTConfig::getSingleton();
     $sVarDirectory = $oConfig->get('urls/varDirectory');
     $smarty->compile_dir = $oConfig->get('urls/tmpDirectory');
     //        foreach (array($sVarDirectory . '/tmp', '/tmp') as $sPath) {
     //            if (is_writeable($sPath)) {
     //                $smarty->compile_dir = $sPath;
     //                break;
     //            }
     //        }
     if (is_array($aDict)) {
         $iLen = count($aDict);
         $aKeys = array_keys($aDict);
         for ($i = 0; $i < $iLen; $i++) {
             $sKey = $aKeys[$i];
             $smarty->assign_by_ref($sKey, $aDict[$sKey]);
         }
     }
     if (is_array($this->aDict)) {
         $iLen = count($this->aDict);
         $aKeys = array_keys($this->aDict);
         for ($i = 0; $i < $iLen; $i++) {
             $sKey = $aKeys[$i];
             $smarty->assign_by_ref($sKey, $this->aDict[$sKey]);
         }
     }
     $KTConfig =& KTConfig::getSingleton();
     // needed for a very, very few places.
     $isSSL = $KTConfig->get("KnowledgeTree/sslEnabled");
     $hostname = $KTConfig->get("KnowledgeTree/serverName");
     $absroot = 'http';
     $absroot .= $isSSL ? 's://' : '://';
     $absroot .= $hostname;
     $absroot .= $KTConfig->get("KnowledgeTree/rootUrl");
     if (isset($_SESSION['search2_quick'])) {
         $search2_quick = $_SESSION['search2_quick'];
         $search2_general = $_SESSION['search2_general'];
         $search2_quickQuery = trim($_SESSION['search2_quickQuery']);
         if ($search2_quickQuery == '') {
             $search2_quickQuery = '';
         }
     } else {
         $search2_quick = 0;
         $search2_general = 1;
         $search2_quickQuery = '';
         $_SESSION['search2_quick'] = $search2_quick;
         $_SESSION['search2_general'] = $search2_general;
         $_SESSION['search2_quickQuery'] = '';
     }
     $smarty->assign('search2_anonymous', !array_key_exists('userID', $_SESSION) || $_SESSION['userID'] == -2);
     $smarty->assign('search2_user', $_SESSION['userId']);
     $smarty->assign('search2_quick', $search2_quick);
     $smarty->assign('search2_general', $search2_general);
     $smarty->assign('search2_quickQuery', $search2_quickQuery);
     $smarty->assign("config", $KTConfig);
     $smarty->assign("appname", $KTConfig->get("ui/appName", "KnowledgeTree"));
     $smarty->assign("rootUrl", $KTConfig->get("KnowledgeTree/rootUrl"));
     $smarty->assign("absoluteRootUrl", $absroot);
     $smarty->caching = false;
     $smarty->register_function('entity_select', array('KTSmartyTemplate', 'entity_select'));
     $smarty->register_function('boolean_checkbox', array('KTSmartyTemplate', 'boolean_checkbox'));
     $smarty->register_function('entity_checkboxes', array('KTSmartyTemplate', 'entity_checkboxes'));
     $smarty->register_function('entity_radios', array('KTSmartyTemplate', 'entity_radios'));
     $smarty->register_block('i18n', array('KTSmartyTemplate', 'i18n_block'), false);
     $smarty->register_modifier('addQueryString', array('KTSmartyTemplate', 'addQueryString'));
     $smarty->register_function('ktLink', array('KTSmartyTemplate', 'ktLink'));
     $smarty->register_modifier('addQS', array('KTSmartyTemplate', 'addQueryString'));
     $smarty->register_modifier('addQueryStringSelf', array('KTSmartyTemplate', 'addQueryStringSelf'));
     $smarty->register_modifier('addQSSelf', array('KTSmartyTemplate', 'addQueryStringSelf'));
     $smarty->register_block('addQS', array('KTSmartyTemplate', 'addQueryStringBlock'), false);
     $smarty->register_function('getUrlForFolder', array('KTSmartyTemplate', 'getUrlForFolder'));
     $smarty->register_function('getCrumbStringForDocument', array('KTSmartyTemplate', 'getCrumbStringForDocument'));
     return $smarty->fetch($this->sPath);
 }
Exemple #10
0
    header("Location: index.php");
    exit;
}
if ($file != 'c-404error') {
    include_once SPATH_ROOT . "/section/content/setaccess.php";
}
//include_once('');
//define here page
$smarty->assign("page", $scr);
//define here prefix
$smarty->assign("prefix", $prefix);
//define here section
$smarty->assign("section", $sec);
$smarty->assign("subsec", $subsec);
//define here generalize variables of front section like siteurl,path,bottom text,etc...
$smarty->register_modifier("sslash", "stripslashes");
//assign the file names which won't include left.tpl
$notincleft = array();
////commment when development [Caching files for pages]
if ($sec == "content") {
    $sec_pre = "c";
    //include_caching($scr,$sec_pre);
}
//logout from here
$slog = $generalobj->getlogoutset();
// prints($slog); exit;
if (is_array($slog) && count($slog) > 0) {
    header("Location: " . SITE_URL_DUM . "logout/sotp");
    exit;
}
//Call Function For Recent Online Members
Exemple #11
0
 /**
  * Return smarty instance
  *
  * @return Smarty
  */
 public function getSmarty()
 {
     static $oSmarty;
     if (!$oSmarty) {
         //create smarty object
         require_once 'Smarty.class.php';
         $oSmarty = new Smarty();
         foreach ($this->_aSmartyProperties as $sName => $mValue) {
             $oSmarty->{$sName} = substr($sName, -4) == '_dir' ? Volcano_Tools::fixPath($mValue) : $mValue;
         }
         foreach ($this->_aCustomFunctions as $sType => $aItems) {
             foreach ($aItems as $aItem) {
                 if (substr($oSmarty->_version, 0, 1) != '2') {
                     //bad code, but smarty3 has version like 'Smarty3-SVN$Rev: 3286 $'
                     if ($sType == 'modifier' || $sType == 'function') {
                         $oSmarty->registerPlugin($sType, $aItem[1], $aItem[0]);
                     } elseif ($sType == 'outputfilter') {
                         $oSmarty->registerFilter('output', $aItem[0]);
                     } elseif ($sType == 'postfilter') {
                         $oSmarty->registerFilter('post', $aItem[0]);
                     } elseif ($sType == 'prefilter') {
                         $oSmarty->registerFilter('pre', $aItem[0]);
                     }
                 } else {
                     if ($sType == 'modifier') {
                         $oSmarty->register_modifier($aItem[1], $aItem[0]);
                     } elseif ($sType == 'function') {
                         $oSmarty->register_function($aItem[1], $aItem[0]);
                     } elseif ($sType == 'outputfilter') {
                         $oSmarty->register_outputfilter($aItem[0]);
                     } elseif ($sType == 'postfilter') {
                         $oSmarty->register_postfilter($aItem[0]);
                     } elseif ($sType == 'prefilter') {
                         $oSmarty->register_prefilter($aItem[0]);
                     }
                 }
             }
         }
     }
     $oSmarty->error_reporting = error_reporting() & ~E_NOTICE;
     return $oSmarty;
 }
    $sep = isset($params['sep']) ? $params['sep'] : '...';
    if (Tools::strlen($text) > $length + Tools::strlen($sep)) {
        $text = substr($text, 0, $length) . $sep;
    }
    return isset($params['encode']) ? Tools::htmlentitiesUTF8($text, ENT_NOQUOTES) : $text;
}
$smarty->register_function('t', 'smartyTruncate');
function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false, $charset = 'UTF-8')
{
    if ($length == 0) {
        return '';
    }
    if (Tools::strlen($string) > $length) {
        $length -= min($length, Tools::strlen($etc));
        if (!$break_words && !$middle) {
            $string = preg_replace('/\\s+?(\\S+)?$/', '', Tools::substr($string, 0, $length + 1, $charset));
        }
        if (!$middle) {
            return Tools::substr($string, 0, $length, $charset) . $etc;
        } else {
            return Tools::substr($string, 0, $length / 2, $charset) . $etc . Tools::substr($string, -$length / 2, $charset);
        }
    } else {
        return $string;
    }
}
$smarty->register_modifier('truncate', 'smarty_modifier_truncate');
$smarty->register_modifier('secureReferrer', array('Tools', 'secureReferrer'));
global $link;
$link = new Link();
$smarty->assign('link', $link);
Exemple #13
0
$vars = array_merge_recursive($vars, $config);
include_once $vars['templates']['path'] . $vars['templates']['default'] . '/config.php';
$vars = array_merge($vars, $template_config);
include_once ROOT_PATH . "globals/functions.php";
$php_start = getmicrotime();
include_once ROOT_PATH . "globals/classes/mysql.php";
include_once ROOT_PATH . "globals/classes/construct.php";
include_once ROOT_PATH . "globals/classes/form.php";
include_once ROOT_PATH . "globals/classes/table.php";
if (!file_exists($vars['smarty']['class'])) {
    die("WiND error: Cannot find Smarty lib. Please check config.php ...");
}
include_once $vars['smarty']['class'];
if ($vars['template']['version'] < $vars['info']['min_template_version'] || $vars['template']['version'] > $vars['info']['version']) {
    die("WiND error: Template version does not match.");
}
$smarty = new Smarty();
$smarty->template_dir = $vars['templates']['path'] . $vars['templates']['default'] . '/';
$smarty->plugins_dir = array($vars['templates']['path'] . $vars['templates']['default'] . '/plugins/', 'plugins');
$smarty->compile_dir = $vars['templates']['compiled_path'] . $vars['templates']['default'] . '/';
$smarty->register_modifier('stripslashes', 'stripslashes');
reset_smarty();
$construct = new construct();
if ($vars['mail']['smtp'] != '') {
    ini_set('SMTP', $vars['mail']['smtp']);
    ini_set('smtp_port', $vars['mail']['smtp_port']);
}
$db = new mysql($vars['db']['server'], $vars['db']['username'], $vars['db']['password'], $vars['db']['database']);
if ($db->error) {
    die("WiND MySQL database error: {$db->error_report}");
}
define('P_STDERR', 2);
/* initialize smarty template library */
require SMARTY_LIBRARY;
$smarty = new Smarty();
$smarty->setTemplateDir(SMARTY_TEMPLATE);
$smarty->setCompileDir(SMARTY_COMPILE);
/* define some modifiers for bitrate conversion */
function kbyte($bits)
{
    return round($bits / 8 / 1024, 2);
}
function kbit($bits)
{
    return round($bits / 1000, 2);
}
$smarty->register_modifier("kbyte", "kbyte");
$smarty->register_modifier("kbit", "kbit");
/* just a very simple debug logger */
function dbg($message)
{
    file_put_contents(DEBUG_LOG, time() . ": {$message}\n", FILE_APPEND);
}
/* test for ffmpeg and mplayer */
if (!preg_match('/MPlayer (\\S+)/', shell_exec(MPLAYER), $mplayer_version)) {
    $smarty->assign('error', 'MPlayer not found. (' . MPLAYER . ')');
    $smarty->display('error.tpl.html');
    exit;
}
$smarty->assign('mplayer_version', $mplayer_version[1]);
if (!preg_match('/FFmpeg (\\S+)/', shell_exec(FFMPEG . ' -version'), $ffmpeg_version)) {
    $smarty->assign('error', 'FFmpeg not found. (' . FFMPEG . ')');
Exemple #15
0
 /**
  * Register modifier to be used in templates
  *
  * @param string $modifier Name of template modifier
  * @param string $modifierImpl Name of PHP function to register
  * @return void
  * 
  * @example 
  *        - register in register() function:
  *             $this->registerModifier('modifierName', array('NameofRegisterClass', 'functionOfRegisterClass'));
  *        - using in template:
  *              {{* template with Smarty engine *}}
  *              {{$var|modifierName}}
  */
 function registerModifier($modifier, $modifierImpl)
 {
     $this->_smarty->register_modifier($modifier, $modifierImpl);
 }
Exemple #16
0
$db = base::get_instance()->db = new mysql_driver(MYDB_HOST,MYDB_LIBR, MYDB_USER, MYDB_PASS, 'utf8', true);
$db->init();
*/
//cache
/*require (VENDORS_PATH .'cache'.DS. 'memcached.php');

$memcached = new memcached($cache_server);
require (VENDORS_PATH .'session'.DS. 'session.php');
require (VENDORS_PATH .'session'.DS. 'drivers'.DS.'session_memcache_driver.php');

$sess = new session_memcache_driver(DOMAIN);
$_SESSION = $sess->start();*/
//if (true) //需要加载Smarty的条件
//{
//加载Smarty
header('Cache-control: private');
header('Content-type: text/html; charset=utf-8');
/* Create Smarty Object */
require VENDORS_PATH . 'smarty' . DS . 'Smarty.class.php';
$tpl = new Smarty();
$tpl->left_delimiter = TPL_LEFT_DELIMITER;
$tpl->right_delimiter = TPL_RIGHT_DELIMITER;
$tpl->caching = TPL_CACHING;
$tpl->cache_lifetime = TPL_CACHE_LIFETIME;
$tpl->cache_dir = TPL_CACHE;
$tpl->template_dir = TPL_TEMPLATE;
$tpl->compile_dir = TPL_COMPILE;
$tpl->compile_check = true;
$tpl->register_function("insert_scripts", "insert_scripts");
$tpl->register_modifier("sslash", "stripslashes");
//}
Exemple #17
0
 /**
  * Returns an instance of the Smarty Template Engine
  * 
  * @static 
  * @return Smarty
  */
 static function getInstance()
 {
     static $instance = null;
     if (null == $instance) {
         define('SMARTY_RESOURCE_CHAR_SET', LANG_CHARSET_CODE);
         require DEVBLOCKS_PATH . 'libs/smarty/Smarty.class.php';
         $instance = new Smarty();
         $instance->template_dir = APP_PATH . '/templates';
         $instance->compile_dir = APP_TEMP_PATH . '/templates_c';
         $instance->cache_dir = APP_TEMP_PATH . '/cache';
         $instance->caching = 0;
         $instance->cache_lifetime = 0;
         $instance->compile_check = false;
         // Devblocks plugins
         $instance->register_block('devblocks_url', array(_DevblocksTemplateManager, 'block_devblocks_url'));
         $instance->register_modifier('devblocks_date', array(_DevblocksTemplateManager, 'modifier_devblocks_date'));
         $instance->register_modifier('devblocks_prettytime', array(_DevblocksTemplateManager, 'modifier_devblocks_prettytime'));
         $instance->register_modifier('devblocks_translate', array(_DevblocksTemplateManager, 'modifier_devblocks_translate'));
         $instance->register_resource('devblocks', array(array(_DevblocksSmartyTemplateResource, 'get_template'), array(_DevblocksSmartyTemplateResource, 'get_timestamp'), array(_DevblocksSmartyTemplateResource, 'get_secure'), array(_DevblocksSmartyTemplateResource, 'get_trusted')));
     }
     return $instance;
 }
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
// Sessions
session_start();
// Smarty
require "smarty/libs/Smarty.class.php";
$smarty = new Smarty();
$smarty->compile_check = true;
#$smarty->debugging		= true;
$smarty->debugging = false;
$smarty->security = false;
// vet ikke hva denne gjør... hehe :P
$smarty->register_modifier('printDato', 'smarty_modifier_printDato');
function iconHTML($ico, $end = '.png', $extra = '')
{
    return '<img src="./img/icons/' . $ico . $end . '" style="border: 0px solid black; vertical-align: middle;" alt="' . _('Icon') . ': ' . $ico . '"' . $extra . '>';
}
function templateIconHtml($params, &$smarty)
{
    if (isset($params['ico'])) {
        $ico = $params['ico'];
    } else {
        $ico = '';
    }
    if (isset($params['end'])) {
        $end = $params['end'];
    } else {
        $end = '.png';
Exemple #19
0
// Active aussi pour Zend_Locale
/*
 * Zend Framework cache section - end
 */
$smarty = new Smarty();
$smarty->debugging = false;
//cache directory. Have to be writeable (chmod 777)
$smarty->compile_dir = "tmp/cache";
if (!is_writable($smarty->compile_dir)) {
    simpleInvoicesError("notWriteable", 'folder', $smarty->compile_dir);
    //exit("Simple Invoices Error : The folder <i>".$smarty -> compile_dir."</i> has to be writeable");
}
//adds own smarty plugins
$smarty->plugins_dir = array("plugins", "include/smarty_plugins");
//add stripslash smarty function
$smarty->register_modifier("unescape", "stripslashes");
/* 
 * Smarty inint - end
 */
$path = pathinfo($_SERVER['REQUEST_URI']);
//SC: Install path handling will need changes if used in non-HTML contexts
$install_path = htmlsafe($path['dirname']);
include_once './config/define.php';
/*
 * Include another config file if required
 */
if (is_file('./config/custom.config.ini')) {
    $config = new Zend_Config_Ini('./config/custom.config.ini', $environment, true);
} else {
    $config = new Zend_Config_Ini('./config/config.ini', $environment, true);
    //added 'true' to allow modifications from db
 /**
  *	This function will parse the template and will return the parsed contents. The name of the template you need
  *	to specify is the basename of the template without the file extension. This function automatically adds some
  *	variables to the template, which you can use as well in the template: YD_FW_NAME, YD_FW_VERSION, 
  *	YD_FW_NAMEVERS, YD_FW_HOMEPAGE, YD_SELF_SCRIPT, YD_SELF_URI, YD_ACTION_PARAM, YD_ENV, YD_COOKIE, YD_GET,
  *	YD_POST, YD_FILES, YD_REQUEST, YD_SESSION, YD_GLOBALS.
  *
  *	@param $name	The name of the template you want to parse and output.
  *
  *	@returns	This function returns the output of the parsed template.
  *
  *	@todo
  *		We should add options here to cache the output.
  */
 function getOutput($name)
 {
     // Add some default variables
     $this->setVar('YD_FW_NAME', YD_FW_NAME);
     $this->setVar('YD_FW_VERSION', YD_FW_VERSION);
     $this->setVar('YD_FW_NAMEVERS', YD_FW_NAMEVERS);
     $this->setVar('YD_FW_HOMEPAGE', YD_FW_HOMEPAGE);
     $this->setVar('YD_SELF_SCRIPT', YD_SELF_SCRIPT);
     $this->setVar('YD_SELF_URI', YD_SELF_URI);
     $this->setVar('YD_ACTION_PARAM', YD_ACTION_PARAM);
     // Get the path to the template
     if (is_file($this->_templateDir . '/' . $name . YD_TPL_EXT)) {
         $tplPath = realpath($this->_templateDir . '/' . $name . YD_TPL_EXT);
     } elseif (is_file($this->_templateDir . '/' . $name)) {
         $tplPath = realpath($this->_templateDir . '/' . $name);
     } else {
         $tplPath = realpath($name);
     }
     // Check if the file exists
     if (!is_file($tplPath)) {
         trigger_error('Template not found: ' . $tplPath, YD_ERROR);
     }
     // Include smarty
     require_once YD_DIR_3RDP . '/smarty/Smarty.class.php';
     // Instantiate smarty
     $tpl = new Smarty();
     // Configure smarty
     $tpl->template_dir = dirname($tplPath);
     $tpl->compile_dir = YD_DIR_TEMP;
     $tpl->left_delimiter = '[';
     $tpl->right_delimiter = ']';
     // Trim whitespace
     $tpl->register_outputfilter('YDTemplate_outputfilter_trimwhitespace');
     // Register the custom modifiers
     $tpl->register_modifier('addslashes', 'addslashes');
     $tpl->register_modifier('lower', 'strtolower');
     $tpl->register_modifier('implode', 'YDTemplate_modifier_implode');
     $tpl->register_modifier('fmtfilesize', 'YDTemplate_modifier_fmtfileize');
     $tpl->register_modifier('date_format', 'YDTemplate_modifier_date_format');
     $tpl->register_modifier('dump', 'YDTemplate_modifier_dump');
     // Add the other modifiers
     foreach ($this->_modifiers as $name => $function) {
         $tpl->register_modifier($name, $function);
     }
     // Add the functions
     foreach ($this->_functions as $name => $function) {
         $tpl->register_function($name, $function);
     }
     // Assign the variables
     $tpl->assign($this->_vars);
     // Output the template
     $contents = $tpl->fetch(basename($tplPath), null, md5(dirname($tplPath)));
     // Returns the contents
     return $contents;
 }
Exemple #21
0
 /**
  * sfSmarty::registerModifier()
  * this is an access function to the internal smarty instance
  * to register a modifier
  *
  * @param mixed $tag
  * @param mixed $function
  * @return
  **/
 public static function registerModifier($tag, $function)
 {
     self::$smarty->register_modifier($tag, $function);
 }
Exemple #22
0
require_once dirname(__FILE__) . '/../../dependencies/smarty/Smarty.class.php';
$smarty = new Smarty();
$smarty->template_dir = array(dirname(__FILE__) . '/../../htdocs/templates/' . $sous_site . '/', dirname(__FILE__) . '/../../htdocs/templates/commun/');
$smarty->compile_dir = dirname(__FILE__) . '/../../htdocs/cache/templates';
$smarty->compile_id = $sous_site;
$smarty->use_sub_dirs = true;
$smarty->check_compile = true;
$smarty->php_handling = SMARTY_PHP_ALLOW;
$smarty->assign('url_base', 'http://' . $_SERVER['HTTP_HOST'] . '/');
$smarty->assign('chemin_template', $serveur . $conf->obtenir('web|path') . 'templates/' . $sous_site . '/');
$smarty->assign('chemin_javascript', $serveur . $conf->obtenir('web|path') . 'javascript/');
// Initialisation de la couche d'abstraction de la base de données
require_once dirname(__FILE__) . '/../../sources/Afup/AFUP_Base_De_Donnees.php';
$bdd = new AFUP_Base_De_Donnees($conf->obtenir('bdd|hote'), $conf->obtenir('bdd|base'), $conf->obtenir('bdd|utilisateur'), $conf->obtenir('bdd|mot_de_passe'));
$bdd->executer("SET NAMES 'utf8'");
// Inclusion de la classe permettant l envoi de mail
require_once dirname(__FILE__) . '/../../sources/Afup/AFUP_Mailing.php';
// Inclusion de l'autoload de composer
require_once dirname(__FILE__) . '/../../vendor/autoload.php';
// Configuration du composant de traduction
$lang = 'fr';
$langs = ['fr', 'en'];
if (isset($_GET['lang']) && in_array($_GET['lang'], $langs)) {
    $lang = $_GET['lang'];
}
$translator = new \Symfony\Component\Translation\Translator($lang);
$translator->addLoader('xliff', new \Symfony\Component\Translation\Loader\XliffFileLoader());
$translator->addResource('xliff', dirname(__FILE__) . '/../../translations/inscription.en.xlf', 'en');
$translator->setFallbackLocales(array('fr'));
$smarty->register_modifier('trans', [$translator, 'trans']);
Exemple #23
0
}
$smarty->register_function('hidden_fields', 'smarty_hidden_fields');
function smarty_hidden_fields($params, &$smarty)
{
    if (empty($params['group'])) {
        $params['group'] = 'edit';
    }
    $output = '';
    if (array_key_exists('fields', $params) && !empty($params['fields'])) {
        foreach ($params['fields'] as $name => $value) {
            $output .= "<input type=\"hidden\" name=\"{$params['group']}[{$name}]\" value=\"" . check_form($value) . "\" />\n";
        }
    }
    return $output;
}
$smarty->register_modifier('utf8', 'smarty_modifier_utf8');
function smarty_modifier_utf8($string)
{
    $utf = utf8_encode($string);
    return $utf;
}
require_once 'includes/fillInFormValues.php';
$smarty->register_block('fill_form_values', 'smarty_fill_form_values', false);
/**
 * Smarty {fill_form_values}...{/fill_form_values} extension.
 * Fills in form fields between the tags based on values in Smarty template
 * variables, and shows form errors stored in the template variable
 * "formErrors".
 *
 * @param array $params		Params from smarty template (unused)
 * @param string $content	HTML to filter (it's {...}THIS STUFF{/...}
Exemple #24
0
 /**
  * 注册变量调节器
  * 
  * @param $name 名称
  * @param $functionImpl 调用函数
  */
 public function registModifier($name, $functionImpl)
 {
     $this->_smarty->register_modifier($name, $functionImpl);
 }