Exemplo n.º 1
0
 /**
  * Get smarty template
  * @return Smarty smarty object
  */
 public static function getSmartyTemplate()
 {
     $smarty = new \SmartyBC();
     $useTheme = !defined('OPENBIZ_USE_THEME') ? 0 : OPENBIZ_USE_THEME;
     if ($useTheme) {
         $theme = Openbizx::$app->getCurrentTheme();
         $themePath = $theme;
         // Openbizx::$app->getConfiguration()->GetThemePath($theme);
         if (is_dir(OPENBIZ_THEME_PATH . "/" . $themePath . "/template")) {
             $templateRoot = OPENBIZ_THEME_PATH . "/" . $themePath . "/template";
         } else {
             $templateRoot = OPENBIZ_THEME_PATH . "/" . $themePath . "/templates";
         }
         $smarty->setTemplateDir($templateRoot);
         $compileDir = defined('OPENBIZ_SMARTY_CPL_PATH') ? OPENBIZ_SMARTY_CPL_PATH . "/" . $themePath : $templateRoot . "/cpl";
         $smarty->setCompileDir($compileDir);
         $smarty->setConfigDir($templateRoot . "/cfg");
         $smarty->config_load('tpl.conf');
     } else {
         if (defined('SMARTY_TPL_PATH')) {
             $smarty->setTemplateDir(SMARTY_TPL_PATH);
         }
         if (defined('OPENBIZ_SMARTY_CPL_PATH')) {
             $smarty->setCompileDir(OPENBIZ_SMARTY_CPL_PATH . "/" . $themePath);
         }
         if (defined('SMARTY_CFG_PATH')) {
             $smarty->setConfigDir(SMARTY_CFG_PATH);
         }
     }
     if (!is_dir($smarty->compile_dir)) {
         mkdir($smarty->compile_dir, 0777);
     }
     // load the config file which has the images and css url defined
     $smarty->assign('app_url', OPENBIZ_APP_URL);
     $smarty->assign('app_index', OPENBIZ_APP_INDEX_URL);
     $smarty->assign('js_url', OPENBIZ_JS_URL);
     $smarty->assign('css_url', OPENBIZ_THEME_URL . "/" . $theme . "/css");
     $smarty->assign('resource_url', OPENBIZ_RESOURCE_URL);
     $smarty->assign('resource_php', OPENBIZ_RESOURCE_PHP);
     $smarty->assign('theme_js_url', OPENBIZ_THEME_URL . "/" . $theme . "/js");
     $smarty->assign('theme_url', OPENBIZ_THEME_URL . "/" . $theme);
     $smarty->assign('image_url', OPENBIZ_THEME_URL . "/" . $theme . "/images");
     $smarty->assign('lang', strtolower(I18n::getCurrentLangCode()));
     $smarty->assign('lang_name', I18n::getCurrentLangCode());
     return $smarty;
 }
Exemplo n.º 2
0
<?php

define('SMARTY_DIR', 'extlibs/smarty/');
define('TEMPLATES_DIR', 'templates');
require_once SMARTY_DIR . 'SmartyBC.class.php';
$smarty = new SmartyBC();
$smarty->setTemplateDir(array(TEMPLATES_DIR, TEMPLATES_DIR . '/partials', TEMPLATES_DIR . '/layouts'));
$smarty->setCompileDir(SMARTY_DIR . 'templates_c/')->setConfigDir(SMARTY_DIR . 'configs/')->setCacheDir(SMARTY_DIR . 'cache/');
$smarty->caching = false;
$smarty->cache_lifetime = 120;
//$smarty->force_compile = true;
//$smarty->debugging = true;
$smarty->assign('site', array('author' => 'Julia Kurnia', 'url' => 'http://zidisha.org', 'email_contact' => '*****@*****.**'));
$smarty->assign('twitter', array('screenname' => 'bestpsdfreebies', 'key' => 'BOmazbuKUiXqpvcdBtuXbw', 'secret' => 'mCt9uC3hi8W7QhzNHRBisg6cEqLKa5bKtmSzQ3Jwc', 'token' => '478633957-N08fggOglJNe5GUMTYeng4xcpc1gvLOe4U4W0u1g', 'token_secret' => 'eb7vaneoNRizPwIDOQktv8wgmNeSKBMdxUXzmHuRQ', 'cache_expire' => 3600, 'tweets' => 3));
// Need to make template_c and cache folders writeable.
// Navigate to libs folder and run these commands in terminal:
// sudo chown nobody:nobody templates_c
// sudo chmod 775 templates_c
// sudo chown nobody:nobody cache
// sudo chmod 775 cache
function smarty_modifier_url($url, $code = null)
{
    return language_url($url, $code);
}
function smarty_function_mixpanel($params, Smarty_Internal_Template $template)
{
    $params += array('script' => 'head');
    if ($params['script'] == 'head') {
        return Mixpanel::head_script();
    }
    return Mixpanel::body_script();
<?php

require_once $basedir . "/vendor/autoload.php";
$smarty = new SmartyBC();
$smarty->setTemplateDir($basedir . '/templates');
$smarty->setCompileDir($basedir . '/templates_c');
$smarty->setCacheDir($basedir . '/cache');
$smarty->setConfigDir($basedir . '/configs');
$smarty->security = false;
$smarty->setCaching(Smarty::CACHING_LIFETIME_SAVED);
$smarty->assign('baseurl', $baseurl);
Exemplo n.º 4
0
 public function smart_view($view, $vars = array(), $return = FALSE)
 {
     $orgin_view = $view;
     if (!strpos($view, ".php") && !strpos($view, ".tpl")) {
         $view .= ".tpl";
     }
     PC::preparing_view($view);
     $view_name = $view;
     $smarty = new SmartyBC();
     $config =& get_config();
     $this->caching = 1;
     $smarty->setCompileDir(APPPATH . '/third_party/Smarty-3.1.8/templates_c');
     $smarty->setConfigDir(APPPATH . '/third_party/Smarty-3.1.8/configs');
     $smarty->setCacheDir(APPPATH . '/cache');
     if (strpos($this->_module, '_child') !== false) {
         list($path, $_view) = Modules::find($view, $this->_module, 'views/');
         if ($path == FALSE) {
             list($path, $_view) = Modules::find($view, str_replace("_child", "", $this->_module), 'views/');
         }
     } else {
         list($path, $_view) = Modules::find($view, $this->_module . "_child", 'views/');
         if ($path == FALSE) {
             list($path, $_view) = Modules::find($view, $this->_module, 'views/');
         }
     }
     if ($path == FALSE) {
         list($path, $_view) = Modules::find($orgin_view . ".php", $this->_module, 'views/');
         if ($path != FALSE) {
             $view = $orgin_view . ".php";
             $view_name = $view;
         }
     }
     if ($path == FALSE && strpos($this->_module, '_child') !== false) {
         list($path, $_view) = Modules::find($view, str_replace("_child", "", $this->_module), 'views/');
     }
     if ($path != FALSE) {
         $this->_ci_view_paths = array($path => TRUE) + $this->_ci_view_paths;
         $view = $_view;
     }
     $path_fragment = explode("/", $path);
     if ($path_fragment[0] == "modules") {
         global $active_show;
         $controller =& $active_show->controller;
         $theme_path = "themes/" . $controller->BuilderEngine->get_option('active_frontend_theme') . "/modules/" . $this->_module;
         $theme_file = $theme_path . "/" . $_view . ".php";
         if (file_exists($theme_file)) {
             $path = "../../" . $theme_path;
             $this->_ci_view_paths = array($path => TRUE) + $this->_ci_view_paths;
             $view = $path . "/" . $_view;
         }
         // To be updated
         $view_name = basename($view_name);
     }
     global $active_show;
     global $BuilderEngine;
     $vars['BuilderEngine'] =& $BuilderEngine;
     $vars['versions'] =& $active_show->controller->versions;
     $vars['user'] =& $active_show->controller->user;
     $vars['this'] =& $this;
     $smarty->setTemplateDir($path);
     foreach ($vars as $key => $value) {
         $smarty->assign($key, $value);
     }
     $smarty->assign("test_var", "qweqweqwe");
     if ($return) {
         ob_start();
         $smarty->display($view_name);
         $output = ob_get_contents();
         ob_end_clean();
         return $output;
     } else {
         $smarty->display($view_name);
     }
     /*
     global $active_show;
     global $BuilderEngine;
     $vars['BuilderEngine'] = &$BuilderEngine;
     
     
     
     $vars['versions'] = &$active_show->controller->versions;
     
     $vars['user'] = &$active_show->controller->user;
     
     return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
     */
 }
Exemplo n.º 5
0
<?php

ini_set("display_errors", 1);
error_reporting(E_ALL);
require "setup.php";
define("PROJECT_DIR", $local_project_dir);
define("SMARTY_DIR", "smarty-3.1.27/libs/");
require SMARTY_DIR . "Smarty.class.php";
$smarty = new SmartyBC();
$smarty->setTemplateDir(PROJECT_DIR . "smarty/templates");
$smarty->setCompileDir(PROJECT_DIR . "smarty/templates_c");
$smarty->setCacheDir(PROJECT_DIR . "smarty/cache");
$smarty->setConfigDir(PROJECT_DIR . "smarty/config");
$smarty->assign('lbr', '{');
$smarty->assign('rbr', '}');