本文整理汇总了PHP中Smarty::muteExpectedErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty::muteExpectedErrors方法的具体用法?PHP Smarty::muteExpectedErrors怎么用?PHP Smarty::muteExpectedErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smarty
的用法示例。
在下文中一共展示了Smarty::muteExpectedErrors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initTemplateEngine
/**
* Initialise Twig
*
* @return void
*/
protected function initTemplateEngine()
{
$this->loader = new \Smarty();
$this->loader->muteExpectedErrors();
$this->loader->setTemplateDir($this->getTemplateDir());
$this->loader->addPluginsDir(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'SmartyPlugins');
$this->initSmartyCache();
Logger::debug("Smarty Cache: " . $this->loader->getCacheDir());
}
示例2: run
public static function run($action)
{
ConfigurationChecks::loadChecks();
ConfigurationChecks::performChecks();
$smarty = new Smarty();
$smarty->muteExpectedErrors();
$smarty->setCacheDir(SYSTEM_ROOT . '/classes/smarty/cache/');
$smarty->setCompileDir(SYSTEM_ROOT . '/classes/smarty/templates_c/');
$smarty->setTemplateDir(SYSTEM_ROOT . '/install/view/');
$smarty->caching = Smarty::CACHING_OFF;
$smarty->force_compile = true;
$smarty->assign('title', 'Installation');
switch ($action) {
case 'tables':
self::insertTables($smarty);
break;
case 'user':
self::createUser($smarty);
break;
case 'success':
self::success($smarty);
break;
default:
self::checkRequirements($smarty);
break;
}
}
示例3: _muteErrors
protected function _muteErrors()
{
if ($this->nMuteErrorsCnt <= 0) {
$this->oSmarty->muteExpectedErrors();
$this->nMuteErrorsCnt++;
}
}
示例4: populateTimestamp
/**
* populate Source Object with timestamp and exists from Resource
*
* @param Smarty_Template_Source $source source object
* @return void
*/
public function populateTimestamp(Smarty_Template_Source $source)
{
Smarty::muteExpectedErrors();
$source->timestamp = @filemtime($source->filepath);
Smarty::unmuteExpectedErrors();
$source->exists = !!$source->timestamp;
}
示例5: populateTimestamp
/**
* populate Cached Object with timestamp and exists from Resource
*
* @param Smarty_Template_Cached $cached cached object
* @return void
*/
public function populateTimestamp(Smarty_Template_Cached $cached)
{
Smarty::muteExpectedErrors();
$cached->timestamp = @filemtime($cached->filepath);
Smarty::unmuteExpectedErrors();
$cached->exists = !!$cached->timestamp;
}
示例6: render
public function render(string $path, array $attributes) : string
{
$smarty = new \Smarty();
$smarty->setCompileDir($this->tempPath . "/smarty/templates_c/")->setCacheDir($this->tempPath . "/smarty/cache/")->error_reporting = E_ALL & ~E_NOTICE;
\Smarty::muteExpectedErrors();
$smarty->assign($attributes);
$result = $smarty->fetch($path);
return $result;
}
示例7: __construct
public function __construct()
{
ob_start();
$logErrors = (new Config())->get('dev');
if ($logErrors) {
set_error_handler(function ($errNo, $errStr, $errFile, $errLine) {
self::addError("{$errStr} occurred on {$errFile}:{$errLine}");
});
set_exception_handler(function ($exception) {
self::addError($exception->__toString());
});
\Smarty::muteExpectedErrors();
}
}
示例8: testMutedCaching
public function testMutedCaching()
{
$this->_errors = array();
set_error_handler(array($this, 'error_handler'));
Smarty::muteExpectedErrors();
$this->smarty->caching = true;
$this->smarty->clearCache('default.tpl');
$this->smarty->clearCompiledTemplate('default.tpl');
$this->smarty->fetch('default.tpl');
$this->assertEquals($this->_errors, array());
@filemtime('ckxladanwijicajscaslyxck');
$error = array(__FILE__ . ' line ' . (__LINE__ - 1));
$this->assertEquals($error, $this->_errors);
Smarty::unmuteExpectedErrors();
restore_error_handler();
}
示例9: getSmarty
/**
* @return \Smarty
*/
public static function getSmarty()
{
if (!static::$smarty) {
require_once DOCROOT . '../vendor/smarty/smarty/libs/Smarty.class.php';
$smarty = new \Smarty();
$smarty->template_dir = DOCROOT . '../app/views';
$smarty->compile_dir = DOCROOT . '../templates_c';
$smarty->error_reporting = E_ALL & ~E_NOTICE;
$smarty->error_unassigned = false;
//$smarty->force_compile = true;
// Странно что это вообще понядобилось
$smarty->muteExpectedErrors();
$smarty->registerPlugin('modifier', 'e', 'htmlspecialchars');
$smarty->assign(array('url' => DI::getDefault()->get('url')));
static::$smarty = $smarty;
}
return static::$smarty;
}
示例10: __construct
public function __construct()
{
parent::__construct();
// Store the Codeigniter super global instance... whatever
$CI = get_instance();
// Load the Smarty config file
$CI->load->config('smarty');
// Turn on/off debug
$this->debugging = $CI->config->item('smarty.smarty_debug');
// Set some pretty standard Smarty directories
$this->setCompileDir($CI->config->item('smarty.compile_directory'));
$this->setCacheDir($CI->config->item('smarty.cache_directory'));
$this->setConfigDir($CI->config->item('smarty.config_directory'));
// Default template extension
$this->template_ext = $CI->config->item('smarty.template_ext');
// How long to cache templates for
$this->cache_lifetime = $CI->config->item('smarty.cache_lifetime');
// Disable Smarty security policy
$this->disableSecurity();
// If caching is enabled, then disable force compile and enable cache
if ($CI->config->item('smarty.cache_status') === TRUE) {
$this->enable_caching();
} else {
$this->disable_caching();
}
// Set the error reporting level
$this->error_reporting = $CI->config->item('smarty.template_error_reporting');
// This will fix various issues like filemtime errors that some people experience
// The cause of this is most likely setting the error_reporting value above
// This is a static function in the main Smarty class
Smarty::muteExpectedErrors();
// Should let us access Codeigniter stuff in views
// This means we can go for example {$this->session->userdata('item')}
// just like we normally would in standard CI views
$this->assign("this", $CI);
}
示例11: __construct
function __construct($path)
{
$this->path = $path;
Gongo_Locator::load($this->libraryPath, 'Smarty');
Smarty::muteExpectedErrors();
}
示例12: getCompiled
/**
* get a Compiled Object of this source
*
* @param Smarty_Internal_Template $_template template objet
* @return Smarty_Template_Compiled compiled object
*/
public function getCompiled(Smarty_Internal_Template $_template)
{
// check runtime cache
$_cache_key_dir = join(DIRECTORY_SEPARATOR, $_template->smarty->getTemplateDir());
$_cache_key = $_template->template_resource . '#' . $_template->compile_id;
if (!isset(Smarty_Resource::$compileds[$_cache_key_dir])) {
Smarty_Resource::$compileds[$_cache_key_dir] = array();
}
if (isset(Smarty_Resource::$compileds[$_cache_key_dir][$_cache_key])) {
return Smarty_Resource::$compileds[$_cache_key_dir][$_cache_key];
}
$compiled = new Smarty_Template_Compiled($this);
$this->handler->populateCompiledFilepath($compiled, $_template);
Smarty::muteExpectedErrors();
$compiled->timestamp = @filemtime($compiled->filepath);
Smarty::unmuteExpectedErrors();
$compiled->exists = !!$compiled->timestamp;
// runtime cache
Smarty_Resource::$compileds[$_cache_key_dir][$_cache_key] = $compiled;
return $compiled;
}
示例13: _parse
private function _parse($pid)
{
$tpl = new Template();
$template = $tpl->getTemplateDefinitionByPageId($pid);
if ((int) $template->templatetype != 1) {
throw $this->throwException(7008);
}
$_SESSION['language'] = 'tpl';
$page = new Page();
$opage = $page->getPageById($pid, false, true);
$tn = new OTreeNode();
$tn->page = $opage;
$tname = $template->itemtype;
if (!file_exists(BASEPATH . '/bright/site/views/' . $tname . 'View.php')) {
throw $this->throwException(7010, array($tname . 'View'));
}
// include_once('views/' . $tname . 'View.php');
$viewclass = $tname . 'View';
$view = new $viewclass($tn);
// Simplify page for parsing
// @deprecated Should not be used anymore
foreach ($opage->content as $cfield => $value) {
$opage->{$cfield} = $value;
}
$deactivationlink = BASEURL . 'bright/';
if (defined('USEACTIONDIR') && USEACTIONDIR) {
$deactivationlink .= 'actions/';
}
$deactivationlink .= 'registration.php?action=deactivate&email={email}&code={code}';
$view->deactivationlink = $deactivationlink;
define('DEACTIVATIONLINK', $deactivationlink);
if (method_exists($view, 'parseTemplate')) {
// Bright parser
$parsed = $view->parseTemplate($view, $template->itemtype);
} else {
// Smarty parser
\Smarty::muteExpectedErrors();
$parsed = $view->output();
\Smarty::unmuteExpectedErrors();
}
$parsed = preg_replace_callback('/<img([^>]*)src="\\/([^"]*)"([^>]*)\\/>/ism', array($this, '_replaceImage'), $parsed);
$result = new \stdClass();
$result->page = $opage;
$result->parsed = $parsed;
return $result;
}
示例14: clearCache
/**
* Empty cache for a specific template
*
* @param string $template_name template name
* @param string $cache_id cache id
* @param string $compile_id compile id
* @param integer $exp_time expiration time
* @param string $type resource type
* @return integer number of cache files deleted
*/
public function clearCache($template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null)
{
Smarty::muteExpectedErrors();
// load cache resource and call clear
$_cache_resource = Smarty_CacheResource::load($this, $type);
Smarty_CacheResource::invalidLoadedCache($this);
$t = $_cache_resource->clear($this, $template_name, $cache_id, $compile_id, $exp_time);
Smarty::unmuteExpectedErrors();
return $t;
}
示例15: __construct
/**
* Constructor.
*
* @param \Smarty $smarty A \Smarty instance
* @param TemplateLocator $locator A TemplateLocator instance
* @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance
* @param LoaderInterface $loader A LoaderInterface instance
* @param array $options An array of \Smarty properties
* @param GlobalVariables|null $globals A GlobalVariables instance or null
* @param LoggerInterface|null $logger A LoggerInterface instance or null
*/
public function __construct(\Smarty $smarty, TemplateLocator $locator, TemplateNameParserInterface $parser, LoaderInterface $loader, array $options = array(), GlobalVariables $globals = null, LoggerInterface $logger = null)
{
$this->smarty = $smarty;
$this->locator = $locator;
$this->parser = $parser;
$this->loader = $loader;
$this->globals = array();
$this->logger = null;
// There are no default extensions.
$this->extensions = array();
/*
* Register an handler for 'logical' filenames of the type:
* <code>file:Application:index:index.html.smarty</code>
*/
$this->smarty->default_template_handler_func = array($this, 'smartyDefaultTemplateHandler');
/*
* Define a set of template dirs to look for. This will allow the
* usage of the following syntax:
* <code>file:[Application]/index/index.html.tpl</code>
*
* See {@link http://www.smarty.net/docs/en/resources.tpl} for details
*/
$this->smarty->setTemplateDir($this->locator->getAppPath());
$this->smarty->addTemplateDir($this->locator->getModulesPath());
foreach ($options as $property => $value) {
$this->smarty->{$this->smartyPropertyToSetter($property)}($value);
}
if (null !== $globals) {
$this->addGlobal('app', $globals);
}
/*
* @note muteExpectedErrors() was activated to workaround the following issue:
*
* <code>Warning: filemtime(): stat failed for /path/to/smarty/cache/3ab50a623e65185c49bf17c63c90cc56070ea85c.one.tpl.php
* in /path/to/smarty/libs/sysplugins/smarty_resource.php</code>
*
* This means that your application registered a custom error hander
* (using set_error_handler()) which is not respecting the given $errno
* as it should. If, for whatever reason, this is the desired behaviour
* of your custom error handler, please call muteExpectedErrors() after
* you've registered your custom error handler.
*
* muteExpectedErrors() registers a custom error handler using
* set_error_handler(). The error handler merely inspects $errno and
* $errfile to determine if the given error was produced deliberately
* and must be ignored, or should be passed on to the next error handler.
*/
$smarty->muteExpectedErrors();
}