Example #1
0
 /** 
  * Constructor
  *
  * Instantiates Smarty for later awesomeness
  */
 public function __construct()
 {
     $this->smarty = new Smarty();
     $this->smarty->template_dir = './app/views/';
     $this->smarty->compile_dir = './var/cache/';
     $this->smarty->config_dir = './var/cache/';
     $this->smarty->cache_dir = './var/cache/';
     $this->smarty->register_function('error', array('ASO_Error', 'formatError'));
 }
 /**
  * 构造函数
  *
  * @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'));
 }
Example #4
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'));
 }
 /**
  * Assigns values to the template
  *
  */
 protected function setupTemplate()
 {
     global $cfg;
     //Get the required utilities
     $sess = Session::getInstance();
     //Flag indicating if the session is newly created
     $sessData['isNew'] = $sess->isSessionNew();
     $auth = Auth::getInstance();
     $this->auth['user'] = $auth->getUser();
     //Assign to smarty variables
     $this->template->assign('DATA', $this->fieldData);
     $this->template->assign('ERRORS', $this->invalidFields);
     $this->template->assign('SESSION', $sessData);
     $this->template->assign('CONFIG', $cfg);
     $this->template->assign('AUTH', $this->auth);
     //Assign formName and templateID. Notice that $this->assign is used, ()
     //not $this->template->assign(). Assignments done this way will end up
     //in the $VIEWER smarty variable array. This is the mechanism though
     //which a viewer sends data to a template.
     $this->assign('formName', $this->formName);
     $this->assign('templateID', end($this->templateIDStack));
     $this->assign('templateIDStack', $this->templateIDStack);
     //Setup file handler. This allows multiple directories to be searched,
     //instead of using smarties one directory default.
     $this->template->register_resource('rfile', array('SmartyResources', 'smarty_resource_rfile_source', 'smarty_resource_rfile_timestamp', 'smarty_resource_rfile_secure', 'smarty_resource_rfile_trusted'));
     //Set this template access method as default. This makes this
     //process transparent to the smarty coder.
     $this->template->default_resource_type = 'rfile';
     //Register functions specific to this application. These may be
     //found in SmartyFunctions.class.php.
     $this->template->register_function('getTemplateID', array('SmartyFunctions', 'SMARTY_getTemplateID'));
     $this->template->register_function('templateLink', array('SmartyFunctions', 'SMARTY_templateLink'));
     $this->template->register_function('use', array($this, 'SMARTY_use'));
 }
/**
 * 处理分页导航模板
 * 
 * 输出的模板变量
 * $pagenav {array}
 * {{$pagenav.~}}
 * 
 * nums: {array} 页码列表
 * currpage: {int} 当前页面
 * recordcount: {int} 记录数
 * pagecount: {int} 总页数
 * query: {array} 页面传递参数
 * next: {int} 下一页的页码
 * prev: {int} 前一页页码
 * 
 * @param array $params
 *      currpage:当前分页
 *      recordcount: 记录总数
 *      pagecount: 分页总数
 *      template: 模板文件
 *      numcount: 分页数字的个数
 *      url: 跳转url
 *      query: 页面跳转传递的参数
 * @param Smarty $smarty
 * @return void
 */
function smarty_function_pagenavigator($params, &$smarty)
{
    if (empty($params['template'])) {
        $smarty->trigger_error('Undefined pagenavigator template file');
    }
    if (!isset($params['recordcount'])) {
        //$smarty->trigger_error('Undefined recordcount');
        return;
    }
    if (!isset($params['pagecount'])) {
        //$smarty->trigger_error('Undefined pagecount');
        return;
    }
    $currpage = max(1, (int) @$params['currpage']);
    $pagecount = (int) $params['pagecount'];
    $recordcount = (int) $params['recordcount'];
    $numcount = (int) @$params['numcount'];
    // 模板变量
    $tplvar = array('pagecount' => $pagecount, 'recordcount' => $recordcount, 'currpage' => $currpage, 'next' => $currpage < $pagecount ? $currpage + 1 : null, 'prev' => $currpage > 1 ? $currpage - 1 : null, 'url' => empty($params['url']) ? $_SERVER['SCRIPT_NAME'] : $params['url'], 'jsfunc' => @$params['jsfunc']);
    // 输出页码
    if ($numcount > 0) {
        $lbound = $currpage > intval($numcount / 2) ? $currpage - intval($numcount / 2) : 1;
        $ubound = $lbound + $numcount - 1 > $pagecount ? $pagecount : $lbound + $numcount - 1;
        $nums = array();
        for ($i = $lbound; $i <= $ubound; $i++) {
            $nums[] = $i;
        }
        $tplvar['nums'] = $nums;
    }
    if (!empty($params['query']) && is_array($params['query'])) {
        $tplvar['query'] = $params['query'];
    }
    $array = array('smarty_include_vars' => array('pagenav' => $tplvar), 'smarty_include_tpl_file' => $params['template']);
    $smarty->register_function('page_url', 'smarty_function_pagenavigator_buildurl');
    $smarty->register_function('page_jsfunc', 'smarty_function_pagenavigator_buildjsfunc');
    $smarty->_smarty_include($array);
}
 /**
  * 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]);
             }
         }
     }
 }
Example #8
0
 private function loadSmarty()
 {
     if (isset(self::$i_smarty)) {
         return self::$i_smarty;
     }
     cmsCore::includeFile('/includes/smarty/libs/Smarty.class.php');
     $smarty = new Smarty();
     $smarty->compile_dir = PATH . '/cache';
     $smarty->register_function('wysiwyg', 'cmsSmartyWysiwyg');
     $smarty->register_function('profile_url', 'cmsSmartyProfileURL');
     $smarty->register_function('component', 'cmsSmartyCurrentComponent');
     $smarty->register_function('template', 'cmsSmartyCurrentTemplate');
     $smarty->register_function('add_js', 'cmsSmartyAddJS');
     $smarty->register_function('add_css', 'cmsSmartyAddCSS');
     $smarty->register_function('comments', 'cmsSmartyComments');
     $smarty->assign('is_ajax', cmsCore::isAjax());
     self::$i_smarty = $smarty;
     return $smarty;
 }
Example #9
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;
 }
 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);
 }
Example #11
0
 $tableexists = checkfortable(table_prefix . 'feed_import');
 if (!$tableexists) {
     echo "Creating Tables<hr />";
     include_once 'create_mysql_tables.php';
     die("<hr />If there are no errors then refresh this page to continue");
 }
 $filename = 'create_mysql_tables.php';
 if (file_exists($filename)) {
     die("Please delete or rename the file /rss/create_mysql_tables.php, then refresh this page");
 }
 include_once '../Smarty.class.php';
 $smarty = new Smarty();
 $smarty->compile_dir = "templates_c/";
 $smarty->template_dir = "templates/";
 $smarty->config_dir = "";
 $smarty->register_function('feedsListFeeds', 'smarty_function_feedsListFeeds');
 $smarty->register_function('feedsListFeedLinks', 'smarty_function_feedsListFeedLinks');
 $smarty->register_function('feedsListFeedFields', 'smarty_function_feedsListFeedFields');
 $smarty->register_function('feedsListPliggLinkFields', 'smarty_function_feedsListPliggLinkFields');
 $QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_name', 'key' => 'feed_id');
 // a unique identifier for the row
 $smarty->assign('qeip_FeedName', $QEIPA);
 $QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_url', 'key' => 'feed_id');
 // a unique identifier for the row
 $smarty->assign('qeip_FeedURL', $QEIPA);
 $QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_category', 'key' => 'feed_id');
 // a unique identifier for the row
 $smarty->assign('qeip_FeedCategory', $QEIPA);
 $QEIPA = array('table_name' => table_prefix . 'feeds', 'field_name' => 'feed_freq_hours', 'key' => 'feed_id', 'field_type' => 'number');
 // the type of database field we are reading from / writing to
 $smarty->assign('qeip_FeedFreqHours', $QEIPA);
Example #12
0
File: init.php Project: cwcw/cms
    exit;
}
@set_magic_quotes_runtime(0);
global $db, $smarty, $nowTime, $thisYear, $thisMonth, $thisDay, $nowDate, $astroInfo, $weeklyInfo;
$astroInfo = array('ĵÑò×ù', '½ðÅ£×ù', 'Ë«×Ó×ù', '¾Þз×ù', 'ʨ×Ó×ù', '´¦Å®×ù', 'Ìì³Ó×ù', 'ÌìЫ×ù', 'ÉäÊÖ×ù', 'ħôÉ×ù', 'ˮƿ×ù', 'Ë«Óã×ù');
$weeklyInfo = array('ÐÇÆÚÈÕ', 'ÐÇÆÚÒ»', 'ÐÇÆÚ¶þ', 'ÐÇÆÚÈý', 'ÐÇÆÚËÄ', 'ÐÇÆÚÎå', 'ÐÇÆÚÁù');
define('ROOT_PATH', dirname(dirname(__FILE__)) . '/');
define('SMARTY_DIR', ROOT_PATH . "inc/smarty/");
define('YE_TABLE_PREFIX', '');
require_once ROOT_PATH . 'inc/inc.php';
writecookies();
$db = new YE_database();
$sql = "set names 'gbk'";
$db->query($sql);
$smarty = new Smarty();
$smarty->register_function('selectStepOptions', 'selectStepOptions');
$smarty->template_dir = ROOT_PATH . 'templates/';
$smarty->compile_dir = ROOT_PATH . 'templates_c/';
$smarty->left_delimiter = '<?';
$smarty->right_delimiter = '?>';
$nowTime = time() + (800 - (int) date('O')) * 36;
$thisYear = date("Y", $nowTime);
$thisMonth = date("n", $nowTime);
$thisDay = date("j", $nowTime);
$nowDate = date('Y-n-j', $nowTime);
$smarty->assign('_thisYear', $thisYear);
$smarty->assign('_thisMonth', $thisMonth);
$smarty->assign('_thisDay', $thisDay);
$smarty->assign('_nowDate', $nowDate);
//»ñÈ¡Óû§cookiesÐÅÏ¢
global $xing, $ming, $xingbie, $xuexing, $nian1, $yue1, $ri1, $hh1, $mm1, $nian2, $yue2, $ri2, $hh2, $mm2, $sx;
 /**
  *	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;
 }
Example #14
0
 /**
  * Method fills the given template with given template params; return the resulting text
  *
  * @param string $templateName
  * @param array $templateParams
  */
 public function fillTemplate($templateName, $templateParams)
 {
     // when xref is installed by composer, Smarty is loaded as dependency.
     // otherwise, use config to find out where it's installed.
     if (!class_exists('Smarty')) {
         $smartyClassPath = self::getConfigValue("xref.smarty-class");
         require_once $smartyClassPath;
     }
     $smartyTmpDir = self::getConfigValue("xref.data-dir");
     self::createDirIfNotExist($smartyTmpDir);
     self::createDirIfNotExist("{$smartyTmpDir}/smarty");
     self::createDirIfNotExist("{$smartyTmpDir}/smarty/templates_c");
     self::createDirIfNotExist("{$smartyTmpDir}/smarty/cache");
     self::createDirIfNotExist("{$smartyTmpDir}/smarty/configs");
     $defaultTemplateDir = "@data_dir@" == "@" . "data_dir@" ? dirname(__FILE__) . "/templates/smarty" : "@data_dir@/XRef/templates/smarty";
     $templateDir = self::getConfigValue("xref.template-dir", $defaultTemplateDir);
     $smarty = new Smarty();
     if (defined("Smarty::SMARTY_VERSION")) {
         // smarty v. 3+
         $smarty->setTemplateDir($templateDir);
         $smarty->setCompileDir("{$smartyTmpDir}/smarty/templates_c");
         $smarty->setCacheDir("{$smartyTmpDir}/smarty/cache/");
         $smarty->setConfigDir("{$smartyTmpDir}/smarty/configs");
         // our functions
         $smarty->registerPlugin('function', 'xref_report_link', array($this, "xref_report_link"));
         $smarty->registerPlugin('function', 'xref_severity_str', array($this, "xref_severity_str"));
     } else {
         // smarty v. 2+
         $smarty->template_dir = $templateDir;
         $smarty->compile_dir = "{$smartyTmpDir}/smarty/templates_c";
         $smarty->cache_dir = "{$smartyTmpDir}/smarty/cache";
         $smarty->config_dir = "{$smartyTmpDir}/smarty/configs";
         // our functions
         $smarty->register_function('xref_report_link', array($this, "xref_report_link"));
         $smarty->register_function('xref_severity_str', array($this, "xref_severity_str"));
     }
     // default params
     $smarty->assign('config', self::getConfig());
     $smarty->assign('version', self::version());
     // template params
     foreach ($templateParams as $k => $v) {
         $smarty->assign($k, $v);
     }
     $result = $smarty->fetch($templateName);
     $smarty->template_objects = array();
     // otherwise Smarty v3 leaks memory
     return $result;
 }
Example #15
0
 /**
  * 注册Smarty模板调用函数
  *
  * @param string function 模板调用函数的名称
  * @param string|array function 调用函数
  * @param boolean function cacheable 是否缓存结果
  * @param mix cacheAttrs
  * @return Oray_View_Smarty
  */
 public function registFunction($function, $functionImpl, $cacheable = true, $cacheAttrs = null)
 {
     $this->_smarty->register_function($function, $functionImpl, $cacheable, $cacheAttrs);
     return $this;
 }
Example #16
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;
 }
Example #17
0
 /**
  * Register custom function to be used in templates
  *
  * @param string $function The name of the template function
  * @param string $functionImpl The name of the 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->registerFunction('funcName', array('NameofRegisterClass', 'functionOfRegisterClass'));
  *        - using in template:
  *              {{* template with Smarty engine *}}
  *              {{funcName param1='This is param1' param2='This is param2'}}
  */
 function registerFunction($function, $functionImpl, $cacheable = true, $cacheAttrs = null)
 {
     $this->_smarty->register_function($function, $functionImpl, $cacheable, $cacheAttrs);
 }
    } else {
        $ico = '';
    }
    if (isset($params['end'])) {
        $end = $params['end'];
    } else {
        $end = '.png';
    }
    if (isset($params['extra'])) {
        $extra = ' ' . $params['extra'];
    } else {
        $extra = '';
    }
    return iconHTML($ico, $end, $extra);
}
$smarty->register_function('iconHTML', 'templateIconHtml');
// MySQL-connect
require "configs/mysql_connect.php";
// Sjekker innloggingsstatus
/* INNLOGGING ER AV
if(!$krever_innlogging && isset($krever_innlogging))
{
	
}
else
{
	if($_SESSION['bruker_id'] == '' || $_SESSION['bruker_passord_md5'] == '')
	{
		session_destroy(); // Logges ut
		$smarty->assign('error','ikke innlogget');
		$smarty->display('error.tpl');
Example #19
0
<?php

global $smarty;
global $CONFIG;
require_once $CONFIG['smarty']['smarty_path'] . '/Smarty.class.php';
$smarty = new Smarty();
$smarty->template_dir = $CONFIG['smarty']['template_dir'];
$smarty->compile_dir = $CONFIG['smarty']['compile_dir'];
$smarty->cache_dir = $CONFIG['smarty']['cache_dir'];
#$smarty->config_dir  = $CONFIG['smarty']['config_dir'];
$smarty->register_function('lr_url', 'smarty_lr_url');
function smarty_lr_url($params, &$smarty)
{
    if (empty($params['path'])) {
        $path = NULL;
    } else {
        $path = $params['path'];
    }
    if (empty($params['query'])) {
        $query = NULL;
    } else {
        $query = $params['query'];
    }
    return url($path, $query);
}
$smarty->register_function('hidden_fields', 'smarty_hidden_fields');
function smarty_hidden_fields($params, &$smarty)
{
    if (empty($params['group'])) {
        $params['group'] = 'edit';
    }
 public function __construct($tmplPath = null, $extraParams = array())
 {
     // オブジェクト生成
     $this->_smarty = new Smarty();
     // テンプレートパス設定
     if (null !== $tmplPath) {
         $this->setScriptPath($tmplPath);
     }
     // 設定情報をメンバ変数へ
     foreach ($extraParams as $key => $value) {
         //----------------------------------------
         // 設定情報読み込み
         //----------------------------------------
         // array
         if (is_array($value)) {
             foreach ($value as $key2 => $value2) {
                 // 出力時の関数指定
                 if ($key === "outputfilter") {
                     $this->_smarty->autoload_filters['output'][] = $value2;
                 } elseif ($key === "register_function") {
                     $func = explode('/', $value2);
                     if (count($func) > 1) {
                         $registFunc = array($func[0], $func[1]);
                     } else {
                         $registFunc = $func[0];
                     }
                     $this->_smarty->register_function($key2, $registFunc);
                 } else {
                     $this->_smarty->{$key}[] = $value2;
                 }
             }
         } else {
             // smarty のメンバ変数にはないので。。。
             if ($key === "cache_id") {
                 $this->_cache_id = $value;
             } elseif ($key === "debug_mode") {
                 $this->_debug_mode = $value;
             } elseif ($key === "cache_target") {
                 $this->setCacheFile($value);
             } else {
                 $this->_smarty->{$key} = $value;
             }
         }
     }
     //----------------------------------------
     // ディレクトリチェック
     //----------------------------------------
     if (!is_dir($this->_smarty->cache_dir) || !is_writable($this->_smarty->cache_dir)) {
         throw new Zend_Exception('smartyキャッシュディレクトリに書き込みできません。' . $this->_smarty->cache_dir);
     }
     if (!is_dir($this->_smarty->compile_dir) || !is_writable($this->_smarty->compile_dir)) {
         throw new Zend_Exception('smartyコンパイルディレクトリに書き込みできません。' . $this->_smarty->compile_dir);
     }
     //----------------------------------------
     // キャッシュ対象情報読み込み
     //----------------------------------------
     // ロックファイル作成
     $this->_lock_file = $this->_smarty->cache_dir . $_SERVER['HTTP_HOST'] . '/cache.lock';
     // Zend_Db_Table_Rowsetをコンバートしてしますため一旦保留
     //$this->_smarty->default_modifiers = 'escape : "html"';
     $this->_smarty->php_handling = SMARTY_PHP_PASSTHRU;
     // LayOutは使わない
     //$this->assign('layout', $this->layout());
     $this->assign('helper', $this);
 }
Example #21
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");
//}
Example #22
0
function errors()
{
    header("HTTP/1.0 404 Not Found");
    $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->display("404.tpl");
}
Example #23
0
    }
    $smarty->display('installer_start.tpl');
    $smarty->display('pagestart.tpl');
    $smarty->display('installer_end.tpl');
    exit;
} else {
    if (!isset($_SESSION['test'])) {
        installerShowErrorPage('Session not working, you have problem with some modules and functionality! Ask your provider, exiting!', 'Session_not_working');
    }
}
// First checks ok
if (isset($_POST['default_cms_lang'])) {
    $frontendlang = $_POST['default_cms_lang'];
}
require_once cms_join_path(CMS_INSTALL_BASE, 'lang.php');
$smarty->register_function('lang_install', 'smarty_lang');
$smarty->assign('default_cms_lang', $frontendlang);
$smarty->assign('languages', $installer->dropdown_lang());
$help_lang = installerHelpLanguage($frontendlang, 'en_US');
$help_lang = empty($help_lang) ? '' : '/' . $help_lang;
$smarty->assign('cms_upgrade_help_url', CMS_UPGRADE_HELP_URL . $help_lang);
$installer->run($process);
function get_file_contents($filename)
{
    if (!function_exists('file_get_contents')) {
        $fhandle = fopen($filename, "r");
        $fcontents = fread($fhandle, filesize($filename));
        fclose($fhandle);
    } else {
        $fcontents = file_get_contents($filename);
    }
Example #24
0
<?php

//
// Copyright (C) 2011 Cyril Bouthors <*****@*****.**>
//
// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later
// version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
//
require 'smarty/libs/Smarty.class.php';
$smarty = new Smarty();
$smarty_home = dirname(__FILE__) . '/../../template/';
$smarty->template_dir = $smarty_home . '/template';
$smarty->compile_dir = $smarty->config_dir = $smarty->cache_dir = $smarty_home . '/cache';
$smarty->register_function('money_format', 'smarty_money_format');
function smarty_money_format($params, &$smarty)
{
    if (empty($params['price'])) {
        $params['price'] = 0;
    }
    return money_format('%.2n', $params['price']);
}
Example #25
0
            $modKey = '<{' . $params['mod'] . '}' . _THEME_NAME_ . '>' . $key;
        } else {
            $translationsFile = _PS_MODULE_DIR_ . $params['mod'] . '/' . $iso . '.php';
            $modKey = '<{' . $params['mod'] . '}prestashop>' . $key;
        }
        if (@(include_once $translationsFile)) {
            $_MODULES = array_merge($_MODULES, $_MODULE);
        }
        $msg = (is_array($_MODULES) and key_exists($modKey, $_MODULES)) ? $params['js'] ? addslashes($_MODULES[$modKey]) : stripslashes($_MODULES[$modKey]) : false;
    }
    if (!$msg) {
        $msg = (is_array($_LANG) and key_exists($key, $_LANG)) ? $params['js'] ? addslashes($_LANG[$key]) : stripslashes($_LANG[$key]) : $params['s'];
    }
    return $params['js'] ? $msg : Tools::htmlentitiesUTF8($msg);
}
$smarty->register_function('l', 'smartyTranslate');
function smartyDieObject($params, &$smarty)
{
    return Tools::d($params['var']);
}
$smarty->register_function('d', 'smartyDieObject');
function smartyShowObject($params, &$smarty)
{
    return Tools::p($params['var']);
}
$smarty->register_function('p', 'smartyShowObject');
function smartyMaxWords($params, &$smarty)
{
    $params['s'] = str_replace('...', ' ...', html_entity_decode($params['s'], ENT_QUOTES, 'UTF-8'));
    $words = explode(' ', $params['s']);
    foreach ($words as &$word) {
Example #26
0
 /**
  * sfSmarty::registerFunction()
  * this is an access function to the internal smarty instance
  * to register a function
  *
  * @param mixed $tag
  * @param mixed $function
  * @return
  **/
 public static function registerFunction($tag, $function)
 {
     self::$smarty->register_function($tag, $function);
 }
Example #27
0
    $show_all_ads = $db->select("SELECT ad_id, email, ad_title FROM ad");
    if (!empty($show_all_ads)) {
        foreach ($show_all_ads as $show_ad) {
            echo '<a href="HW10.php?id=' . $show_ad['ad_id'] . '">' . $show_ad['ad_title'] . '</a>' . ' | ' . $show_ad['email'] . ' |  <a href="HW10.php?delete=' . $show_ad['ad_id'] . '">Удалить</a><br>';
        }
    } else {
        echo "Объявлений нет";
    }
}
$city_array = option('cities', 'city');
$category_array = option('categories', 'category');
$type_array = option('types', 'type');
$smarty->assign('city_array', $city_array);
$smarty->assign('category_array', $category_array);
$smarty->assign('type_array', $type_array);
$smarty->register_function('showAd', 'showAd');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $_POST['user_name'] = clear($_POST['user_name']);
    $_POST['phone'] = clear($_POST['phone']);
    $_POST['ad_title'] = clear($_POST['ad_title']);
    $_POST['ad_description'] = clear($_POST['ad_description']);
    $row = $_POST;
    $db->query('INSERT INTO ad(?#) VALUES(?a)', array_keys($row), array_values($row));
    header("Location: hw10.php");
} elseif (isset($_GET['delete'])) {
    $db->query("DELETE FROM ad WHERE ad_id=?d", $_GET['delete']);
    header("Location: HW10.php");
} elseif (isset($_GET['id'])) {
    $selected_ads = $db->selectRow("SELECT * FROM ad " . "LEFT JOIN cities on ad.id_city=cities.id_city " . "LEFT JOIN categories on ad.id_category=categories.id_category " . "LEFT JOIN types on ad.id_type=types.id_type " . "WHERE ad_id = ?d", $_GET['id']);
    $smarty->assign('selected_ads', $selected_ads);
}
Example #28
0
* MySQL连接
*/
$mysql = new mysql($config['mysql_user'], $config['mysql_pass'], $config['mysql_db'], $config['mysql_host']);
global $mysql;
/*
 * Smarty设置
 */
$_layoutFile = '';
$_templateFile = '';
define('SMARTY_DIR', ENGINE_PATH . "classes/Smarty/");
include_once SMARTY_DIR . "Smarty.class.php";
$smarty = new Smarty();
$smarty->compile_dir = CACHE . "/templates_cache/";
$smarty->compile_check = true;
$smarty->debugging = false;
$smarty->register_function('createEditor', 'createTextAreaEditor');
global $smarty;
#END;
//模板设置
require_once ROOT_PATH . '/apps/system/models/system.class.php';
$systemClass = new system();
$currency = $systemClass->getActiveCurrency();
abr('currency', $currency);
#元数据
$meta = $systemClass->getAllKeyValue();
$smarty->assign('title', $meta['meta_title']);
$smarty->assign('meta_keywords', $meta['meta_keywords']);
$smarty->assign('meta_description', $meta['meta_description']);
$smarty->assign('site_logo', $meta['site_logo']);
/*
* 包含模板设置文件
Example #29
0
 private function _mvc()
 {
     require_once PATH_THIRDPARTY . 'smarty/libs/Smarty.class.php';
     // put full path to Smarty.class.php
     require_once PATH_GULLIVER_HOME . 'includes' . PATH_SEP . 'smarty_plugins' . PATH_SEP . 'function.pmos.php';
     G::LoadClass('serverConfiguration');
     $oServerConf =& serverConf::getSingleton();
     $oHeadPublisher =& headPublisher::getSingleton();
     $smarty = new Smarty();
     $smarty->compile_dir = PATH_SMARTY_C;
     $smarty->cache_dir = PATH_SMARTY_CACHE;
     $smarty->config_dir = PATH_THIRDPARTY . 'smarty/configs';
     $smarty->register_function('translate', 'translate');
     $viewVars = $oHeadPublisher->getVars();
     // verify if is using extJs engine
     if (count($oHeadPublisher->extJsScript) > 0) {
         $header = $oHeadPublisher->getExtJsStylesheets($this->cssFileName . '-extJs');
         $header .= $oHeadPublisher->includeExtJs();
         $smarty->assign('_header', $header);
     }
     $contentFiles = $oHeadPublisher->getContent();
     $viewFile = isset($contentFiles[0]) ? $contentFiles[0] : '';
     if (empty($this->layout)) {
         $smarty->template_dir = PATH_TPL;
         $tpl = $viewFile . '.html';
     } else {
         $smarty->template_dir = $this->layoutFile['dirname'];
         $tpl = 'layout-' . $this->layout . '.html';
         //die($smarty->template_dir.PATH_SEP.$tpl);
         if (!file_exists($smarty->template_dir . PATH_SEP . $tpl)) {
             $e = new Exception("Layout {$tpl} does not exist!", SE_LAYOUT_NOT_FOUND);
             $e->layoutFile = $smarty->template_dir . PATH_SEP . $tpl;
             throw $e;
         }
         $smarty->assign('_content_file', $viewFile);
     }
     if (strpos($viewFile, '.') === false) {
         $viewFile .= '.html';
     }
     foreach ($viewVars as $key => $value) {
         $smarty->assign($key, $value);
     }
     if (defined('DEBUG') && DEBUG) {
         $smarty->force_compile = true;
     }
     $smarty->assign('_skin', $this->mainSkin);
     $smarty->display($tpl);
 }
Example #30
0
function smarty_setup($compile_dir)
{
    global $DBVARS, $PLUGINS;
    $smarty = new Smarty();
    $smarty->left_delimiter = '{{';
    $smarty->right_delimiter = '}}';
    $smarty->assign('WEBSITE_TITLE', htmlspecialchars($DBVARS['site_title']));
    $smarty->assign('WEBSITE_SUBTITLE', htmlspecialchars($DBVARS['site_subtitle']));
    $smarty->assign('GLOBALS', $GLOBALS);
    $smarty->register_function('BREADCRUMBS', 'Template_breadcrumbs');
    $smarty->register_function('LOGO', 'Template_logoDisplay');
    $smarty->register_function('MENU', 'menuDisplay');
    $smarty->register_function('nuMENU', 'menu_show_fg');
    foreach ($PLUGINS as $pname => $plugin) {
        if (isset($plugin['frontend']['template_functions'])) {
            foreach ($plugin['frontend']['template_functions'] as $fname => $vals) {
                $smarty->register_function($fname, $vals['function']);
            }
        }
    }
    $smarty->compile_dir = $compile_dir;
    return $smarty;
}