Пример #1
0
 public function setupSmarty()
 {
     /** SMARTY **/
     $theme = get_setting('theme');
     $theme = !empty($theme) && file_exists(BASE_ROOT . '/themes/' . $theme . '/') ? get_setting('theme') : 'default';
     $this->settings[17]['value'] = $theme;
     $this->smarty->template_dir = BASE_ROOT . '/themes/' . $theme . '/';
     $this->smarty->compile_dir = BASE_ROOT . '/templates_c/';
     $this->smarty->config_dir = BASE_ROOT . '/configs/';
     $this->smarty->cache_dir = BASE_ROOT . '/cache/';
     require_once LIB_ROOT . '/functions/smarty-gettext.php';
     $this->smarty->register_block('t', 'smarty_translate');
     $this->smarty->assign('tpl_cfg', $GLOBALS['TPL_CFG']);
 }
Пример #2
0
 /**
  * Create a Smarty instance.
  *
  * @return \Smarty
  */
 public function createSmarty()
 {
     $base = dirname(dirname(dirname(dirname(__DIR__))));
     require_once 'Smarty/Smarty.class.php';
     $smarty = new Smarty();
     $smarty->template_dir = "{$base}/xml/templates";
     $smarty->plugins_dir = array("{$base}/packages/Smarty/plugins", "{$base}/CRM/Core/Smarty/plugins");
     $smarty->compile_dir = $this->getCompileDir();
     $smarty->clear_all_cache();
     // CRM-5308 / CRM-3507 - we need {localize} to work in the templates
     require_once 'CRM/Core/Smarty/plugins/block.localize.php';
     $smarty->register_block('localize', 'smarty_block_localize');
     return $smarty;
 }
Пример #3
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;
 }
Пример #4
0
$_SESSION['pastaAmbiente'] = $temp_variaveis[2];
$_SESSION['sistema'] = "Peladinha";
$_SESSION['sistemaInterface'] = "Peladinha";
// configuracao do smarty
require 'bibliotecas/smarty/libs/Smarty.class.php';
$smarty = new Smarty();
function smarty_block_dynamic($param, $content, &$smarty)
{
    return $content;
}
$smarty->compile_dir = "./html/tmp";
$smarty->caching = true;
$smarty->cache_lifetime = 86400;
$smarty->allow_php_tag = true;
$smarty->clear_all_cache();
$smarty->register_block('dynamic', 'smarty_block_dynamic', false);
$smarty->template_dir = dirname(__FILE__) . '/html/';
// adicionando as variaveis globais para usar nos templates
$smarty->assign('globals', $GLOBALS);
$_POST["d"] = "index";
$_POST["a"] = "index";
$_POST["f"] = "logado";
// criando as variaveis, atribuindo $_GET para uma $var apenas para nao ficar usando o $_GET toda hora
$d = isset($_REQUEST["d"]) ? $_REQUEST["d"] : $_POST["d"];
$a = isset($_REQUEST["a"]) ? $_REQUEST["a"] : $_POST["a"];
$f = isset($_REQUEST["f"]) ? $_REQUEST["f"] : $_POST["f"];
// se nao estiver com as variaveis requeridas, ele redireciona
if (!isset($d) && !isset($a) && !isset($f)) {
    require_once 'redirect.php';
}
if (!$d || !$a || !$f) {
Пример #5
0
include_once "includes/topbar.php";
$tpl->assign('topbar', getGroupTopBar($group_title, $function));
/**
 * SSL Check
 */
if (array_key_exists("HTTPS", $_SERVER) && $_SERVER["HTTPS"] == "on") {
    $tpl->assign('ssl_check', true);
} else {
    $tpl->assign('ssl_check', false);
}
/**
 * Just before displaying Smarty template
 * we register a Smarty function
 * to translate blocks of texts
 */
$tpl->register_block('translate', 'do_smarty_translation');
function do_smarty_translation($params, $content, &$tpl, &$repeat)
{
    global $treng;
    $content = trim($content);
    $res = $treng->_($content, "grouppage");
    return $res;
}
// old-
// hacks
if ($group_template[0] == 'm' && is_ie_less_than_7()) {
    switch ($group_template) {
        case 'minimalistic-red':
        case 'minimalistic-rww':
            $group_template = 'igloored';
            break;
Пример #6
0
 /**
  * Registers block function to be used in templates
  *
  * @param string $block Name of template block
  * @param string|array $blockImpl PHP function to register
  * @param boll $cacheable Default is true. When registering a plugin with $cacheable=false the plugin is 
  *                        called everytime the page is displayed, even if the page comes from the cache
  * @param array $cacheAttrs Default is null. An array of attribute-names that should be cached     * 
  * @return void
  * 
  * @example 
  *        - register in register() function:
  *             $this->registerBlock('blockName', array('NameofRegisterClass', 'functionOfRegisterClass'));
  *        - using in template:
  *              {{* template with Smarty engine *}}
  *              {{blockName}}This is content...{{/blockName}}
  */
 public function registerBlock($block, $blockImpl, $cacheable = true, $cacheAttrs = null)
 {
     $this->_smarty->register_block($block, $blockImpl, $cacheable, $cacheAttrs);
 }
Пример #7
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;
 }
Пример #8
0
    $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{/...}
 * @param Smarty $smarty
 * @return string		$content with form vars set properly.
 */
function smarty_fill_form_values($params, $content, &$smarty)
{
    if ($content === null) {
        return "";
Пример #9
0
 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);
 }
Пример #10
0
 /**
  * sfSmarty::registerBlock()
  * this is an access function to the internal smarty instance
  * to register a block function
  *
  * @param mixed $tag
  * @param mixed $function
  * @return
  **/
 public static function registerBlock($tag, $function)
 {
     self::$smarty->register_block($tag, $function);
 }