本文整理汇总了PHP中Smarty_Internal_Template::getApplication方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty_Internal_Template::getApplication方法的具体用法?PHP Smarty_Internal_Template::getApplication怎么用?PHP Smarty_Internal_Template::getApplication使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smarty_Internal_Template
的用法示例。
在下文中一共展示了Smarty_Internal_Template::getApplication方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_backendLangMenu
/**
* Displays backend language selection menu
*
* @param array $params
* @param Smarty $smarty
* @return string
*
* @package application.helper.smarty
* @author Integry Systems
*/
function smarty_function_backendLangMenu($params, Smarty_Internal_Template $smarty)
{
if (!$smarty->getApplication()->getLanguageArray()) {
return false;
}
$smarty->assign('currentLang', Language::getInstanceByID($smarty->getApplication()->getLocaleCode())->toArray());
$smarty->assign('returnRoute', base64_encode($smarty->getApplication()->getRouter()->getRequestedRoute()));
return $smarty->display('block/backend/langMenu.tpl');
}
示例2: smarty_function_backendOrderUrl
/**
* Generates order form URL in backend
*
* @param array $params
* @param Smarty $smarty
* @return string
*
* @package application.helper.smarty
* @author Integry Systems
*/
function smarty_function_backendOrderUrl($params, Smarty_Internal_Template $smarty)
{
$urlParams = array('controller' => 'backend.customerOrder', 'action' => 'index');
$url = $smarty->getApplication()->getRouter()->createUrl($urlParams, true) . '#order_' . (isset($params['order']) ? $params['order']['ID'] . '#tabOrderInfo__' : '');
if (isset($params['url'])) {
$url = $smarty->getApplication()->getRouter()->createFullUrl($url);
}
return $url;
}
示例3: smarty_block_tabControl
/**
* Tab container
*
* @package application.helper.smarty
* @author Integry Systems
*
* @package application.helper.smarty
*/
function smarty_block_tabControl($params, $content, Smarty_Internal_Template $smarty, &$repeat)
{
if (!$repeat) {
if (empty($params['noHidden'])) {
$more = '<li class="moreTabs">
<a href="#" class="moreTabsLink"><span class="downArrow">▾ </span><span>' . strtolower($smarty->getApplication()->translate('_more_tabs')) . '</span></a>
<div class="moreTabsMenu" style="display: none;"></div>
</li>';
}
$content = '<ul id="' . $params['id'] . '" class="tabList tabs ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">' . $content . $more . '</ul>';
$content .= '<script type="text/javascript">var tabCust = new TabCustomize($("' . $params['id'] . '")); tabCust.setPrefsSaveUrl("' . $smarty->getApplication()->getRouter()->createUrl(array('controller' => 'backend.index', 'action' => 'setUserPreference')) . '")</script>';
return $content;
}
}
示例4: smarty_function_compiledJs
/**
* ...
*
* @param array $params
* @param Smarty $smarty
* @return string
*
* @package application.helper.smarty
* @author Integry Systems
*/
function smarty_function_compiledJs($params, Smarty_Internal_Template $smarty)
{
$includedJavascriptTimestamp = $smarty->getGlobal("INCLUDED_JAVASCRIPT_TIMESTAMP");
$includedJavascriptFiles = $smarty->getGlobal("INCLUDED_JAVASCRIPT_FILES");
$app = $smarty->getApplication();
if ($includedJavascriptFiles && isset($params['glue']) && $params['glue'] == 'true' && !$smarty->getApplication()->isDevMode() && !$smarty->getApplication()->isTemplateCustomizationMode()) {
$request = $app->getRequest();
if (isset($params['nameMethod']) && 'hash' == $params['nameMethod']) {
$names = array_keys($includedJavascriptFiles);
sort($names);
$compiledFileName = md5(implode("\n", $names)) . '.js';
} else {
$compiledFileName = $request->getControllerName() . '-' . $request->getActionName() . '.js';
}
$compiledFilePath = ClassLoader::getRealPath('public.cache.javascript.') . $compiledFileName;
$baseDir = ClassLoader::getRealPath('public.javascript.');
$compiledFileTimestamp = 0;
if (!is_file($compiledFilePath) || filemtime($compiledFilePath) < $includedJavascriptTimestamp) {
if (!is_dir(ClassLoader::getRealPath('public.cache.javascript'))) {
mkdir(ClassLoader::getRealPath('public.cache.javascript'), 0777, true);
}
// compile
$compiledFileContent = "";
$compiledFilesList = array();
foreach ($includedJavascriptFiles as $jsFile => $fileName) {
$compiledFileContent .= "\n\n\n/***************************************************\n";
$compiledFileContent .= " * " . str_replace($baseDir, '', $jsFile) . "\n";
$compiledFileContent .= " ***************************************************/\n\n";
$compiledFileContent .= file_get_contents($jsFile);
$compiledFilesList[] = basename($jsFile);
}
file_put_contents($compiledFilePath, $compiledFileContent);
if (function_exists('gzencode')) {
file_put_contents($compiledFilePath . '.gz', gzencode($compiledFileContent, 9));
}
}
$compiledFileTimestamp = filemtime($compiledFilePath);
return '<script src="' . $app->getPublicUrl('gzip.php') . '?file=' . $compiledFileName . '&time=' . $compiledFileTimestamp . '" type="text/javascript"></script>';
} else {
if ($includedJavascriptFiles) {
$includeString = "";
$publicPath = ClassLoader::getRealPath('public.');
foreach ($includedJavascriptFiles as $path => $jsFile) {
$urlPath = str_replace('\\', '/', str_replace($publicPath, '', $jsFile));
$includeString .= '<script src="' . $app->getPublicUrl($urlPath) . '?' . filemtime($path) . '" type="text/javascript"></script>' . "\n";
}
return $includeString;
}
}
}
示例5: smarty_function_liveCustomization
/**
* ...
*
* @param array $params
* @param Smarty $smarty
* @return string
*
* @package application.helper.smarty
* @author Integry Systems
*/
function smarty_function_liveCustomization($params, Smarty_Internal_Template $smarty)
{
$app = $smarty->getApplication();
if ($app->isCustomizationMode()) {
// theme dropdown
$themes = array_merge(array('barebone' => 'barebone'), array_diff($app->getRenderer()->getThemeList(), array('barebone')));
$smarty->assign('themes', $themes);
$smarty->assign('currentTheme', $app->getTheme());
if (!isset($params['action'])) {
include_once 'function.includeJs.php';
include_once 'function.includeCss.php';
smarty_function_includeJs(array('file' => "library/prototype/prototype.js"), $smarty);
smarty_function_includeJs(array('file' => "library/livecart.js"), $smarty);
smarty_function_includeJs(array('file' => "library/form/ActiveForm.js"), $smarty);
smarty_function_includeJs(array('file' => "library/form/Validator.js"), $smarty);
smarty_function_includeJs(array('file' => "backend/Backend.js"), $smarty);
smarty_function_includeJs(array('file' => "frontend/Customize.js"), $smarty);
smarty_function_includeCss(array('file' => "frontend/LiveCustomization.css"), $smarty);
} else {
$smarty->assign('mode', $app->getCustomizationModeType());
$smarty->assign('theme', $app->getTheme());
if ('menu' == $params['action']) {
return $smarty->fetch('customize/menu.tpl');
} else {
if ('lang' == $params['action']) {
return $smarty->fetch('customize/translate.tpl');
}
}
}
}
}
示例6: smarty_function_manufacturerUrl
/**
* Generates manufacturer page URL
*
* @param array $params
* @param Smarty $smarty
* @return string
*
* @package application.helper.smarty
* @author Integry Systems
*/
function smarty_function_manufacturerUrl($params, Smarty_Internal_Template $smarty)
{
$manufacturer = $params['data'];
$params['data'] =& Category::getRootNode()->toArray();
$params['addFilter'] = new ManufacturerFilter($manufacturer['ID'], $manufacturer['name']);
return createCategoryUrl($params, $smarty->getApplication());
}
示例7: smarty_function_metricsfield
/**
*
* @package application.helper.smarty.form
* @author Integry Systems
*/
function smarty_function_metricsfield($params, Smarty_Internal_Template $smarty)
{
if (empty($params['name'])) {
$params['name'] = $smarty->getTemplateVars('input_name');
}
$formParams = $smarty->_tag_stack[0][1];
$formHandler = $formParams['handle'];
if (!isset($params['value']) && !$formHandler instanceof Form) {
throw new HelperException('Element must be placed in {form} block');
}
if (!empty($formParams['model'])) {
$params['ng-model'] = $formParams['model'] . '.' . $params['name'];
}
$application = $smarty->getApplication();
$params['m_sw'] = $application->translate('_switch_to_english_units');
$params['en_sw'] = $application->translate('_switch_to_metric_units');
$params['m_hi'] = $application->translate('_units_kg');
$params['m_lo'] = $application->translate('_units_g');
$params['en_hi'] = $application->translate('_units_lbs');
$params['en_lo'] = $application->translate('_units_oz');
$params['type'] = strtolower($application->getConfig()->get('UNIT_SYSTEM'));
$content = '<weight-input ' . $smarty->appendParams($content, $params) . '></weight-input>';
$content = $smarty->formatControl($content, $params);
return $content;
}
示例8: smarty_function_backendUserUrl
/**
* Generates user form URL in backend
*
* @param array $params
* @param Smarty $smarty
* @return string
*
* @package application.helper.smarty
* @author Integry Systems
*/
function smarty_function_backendUserUrl($params, Smarty_Internal_Template $smarty)
{
if (!isset($params['user']) && isset($params['id'])) {
$params['user'] = array('ID' => $params['id']);
}
$urlParams = array('controller' => 'backend.userGroup', 'action' => 'index');
return $smarty->getApplication()->getRouter()->createUrl($urlParams, true) . '#user_' . (isset($params['user']) ? $params['user']['ID'] : '');
}
示例9: smarty_function_renderBlock
/**
* Renders and displays a page content block
*
* @param array $params
* @param Smarty $smarty
* @return string
*
* @package application.helper.smarty
* @author Integry Systems
*/
function smarty_function_renderBlock($params, Smarty_Internal_Template $smarty)
{
$block = $params['block'];
if (substr($block, -1) == '}') {
$block = substr($block, 0, -1);
}
return $smarty->getApplication()->getBlockContent($block, $params);
}
示例10: smarty_function_paginate
/**
* Generates pagination block
*
* @param array $params
* @param Smarty $smarty
* @return string
*
* @package application.helper.smarty
* @author Integry Systems
*/
function smarty_function_paginate($params, Smarty_Internal_Template $smarty)
{
$interval = 2;
if (isset($params['interval'])) {
$interval = $params['interval'];
}
// determine which page numbers will be displayed
$count = ceil($params['count'] / $params['perPage']);
$pages = range(max(1, $params['current'] - $interval), min($count, $params['current'] + $interval));
if (array_search(1, $pages) === false) {
array_unshift($pages, 1);
}
if (array_search($count, $pages) === false) {
$pages[] = $count;
}
// check for any 1-page sized interval breaks
$pr = 0;
foreach ($pages as $k) {
if ($k - 2 == $pr) {
$pages[] = $k - 1;
}
$pr = $k;
}
sort($pages);
// generate output
$out = array();
$application = $smarty->getApplication();
// get variable to replace - _page_ if defined, otherwise 0
$replace = strpos($params['url'], '_000_') ? '_000_' : 0;
$render = array();
if ($params['current'] > 1) {
$urls['previous'] = str_replace($replace, $params['current'] - 1, $params['url']);
}
foreach ($pages as $k) {
$urls[$k] = str_replace($replace, $k, $params['url']);
}
if ($params['current'] < $count) {
$urls['next'] = str_replace($replace, $params['current'] + 1, $params['url']);
}
$smarty->assign('urls', $urls);
$smarty->assign('pages', $pages);
$smarty->assign('current', $params['current']);
return $smarty->fetch($smarty->getApplication()->getRenderer()->getTemplatePath('block/box/paginate.tpl'));
return implode(' ', $out);
}
示例11: smarty_function_backendProductUrl
/**
* Generates product form URL in backend
*
* @param array $params
* @param Smarty $smarty
* @return string
*
* @package application.helper.smarty
* @author Integry Systems
*/
function smarty_function_backendProductUrl($params, Smarty_Internal_Template $smarty)
{
if (!isset($params['product']) && isset($params['id'])) {
$params['product'] = array('ID' => $params['id']);
}
$product = $params['product'];
$urlParams = array('controller' => 'backend.category', 'action' => 'index');
return $smarty->getApplication()->getRouter()->createUrl($urlParams, true) . '#product_' . (!empty($product['Parent']['ID']) ? $product['Parent']['ID'] : $product['ID']);
}
示例12: smarty_function_pageUrl
/**
* Generates static page URL
*
* @param array $params
* @param Smarty $smarty
* @return string
*
* @package application.helper.smarty
* @author Integry Systems
*/
function smarty_function_pageUrl($params, Smarty_Internal_Template $smarty)
{
if (!class_exists('StaticPage', false)) {
ClassLoader::import('application.model.staticpage.StaticPage');
}
if (isset($params['id'])) {
$params['data'] = StaticPage::getInstanceById($params['id'], StaticPage::LOAD_DATA)->toArray();
}
$urlParams = array('controller' => 'staticPage', 'action' => 'view', 'handle' => $params['data']['handle']);
return $smarty->getApplication()->getRouter()->createUrl($urlParams, true);
}
示例13: smarty_function_maketext
/**
* Creates more complex translation strings that depend on and include numeric variables
*
* <code>
* {maketext text="There are [quant,_1,item,items,no items] in your shopping basket." params=$cnt}
* {maketext text="Displaying [_1] to [_2] of [_3] found orders." params=$from,$to,$count}
* </code>
*
* @param array $params
* @param Smarty $smarty
* @return string
*
* @package application.helper.smarty
* @author Integry Systems
*/
function smarty_function_maketext($params, Smarty_Internal_Template $smarty)
{
$application = $smarty->getApplication();
$translation = $application->makeText($params['text'], explode(',', $params['params']));
if ($application->isTranslationMode() && !isset($params['disableLiveTranslation'])) {
$file = $application->getLocale()->translationManager()->getFileByDefKey($params['text']);
$file = '__file_' . base64_encode($file);
$translation = '<span class="transMode __trans_' . $params['text'] . ' ' . $file . '">' . $translation . '</span>';
}
return $translation;
}
示例14: smarty_function_toolTip
/**
* ...
*
* @param array $params
* @param Smarty $smarty
* @return string
*
* @package application.helper.smarty
* @author Integry Systems
*/
function smarty_function_toolTip($params, Smarty_Internal_Template $smarty)
{
$tip = $params['label'];
$hint = !empty($params['hint']) ? $params['hint'] : '_tip' . $tip;
$app = $smarty->getApplication();
$json = json_encode($app->translate($hint));
$json = str_replace('<', '\\u003C', $json);
$json = str_replace('>', '\\u003E', $json);
$json = str_replace("'", '\\u0027', $json);
return '<span class="acronym" onmouseover=\'tooltip.show(' . $json . ', 200);\' onmouseout="tooltip.hide();">' . $app->translate($tip) . '</span>';
}
示例15: smarty_function_weight
/**
* ...
*
* @param array $params
* @param Smarty $smarty
* @return string
*
* @package application.helper.smarty
* @author Integry Systems
*/
function smarty_function_weight($params, Smarty_Internal_Template $smarty)
{
if (!isset($params['value'])) {
throw new ApplicationException("Please use 'value' attribute to specify weight");
}
$application = $smarty->getApplication();
$units_hi = $application->translate($application->getConfig()->get('UNIT_SYSTEM') == 'ENGLISH' ? '_units_pounds' : '_units_kg');
$units_lo = $application->translate($application->getConfig()->get('UNIT_SYSTEM') == 'ENGLISH' ? '_units_ounces' : '_units_g');
$value_hi = (int) $params['value'];
$value_lo = str_replace('0.', '', (string) ($params['value'] - (int) $params['value']));
return sprintf("%s %s %s %s", $value_hi, $units_hi, $value_lo, $units_lo);
}