Redbean + Smarty update

This commit is contained in:
Robin Kloppe 2014-10-13 11:24:53 +02:00
parent c1b8226466
commit eb0835ff74
122 changed files with 12653 additions and 11637 deletions

View file

@ -2,16 +2,16 @@
/**
* Smarty Internal Plugin
*
* @package Smarty
* @package Smarty
* @subpackage Cacher
*/
/**
* Cache Handler API
*
* @package Smarty
* @package Smarty
* @subpackage Cacher
* @author Rodney Rehm
* @author Rodney Rehm
*/
abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
{
@ -24,20 +24,21 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
* @param string $compile_id compile id
* @param string $content cached content
* @param integer $mtime cache modification timestamp (epoch)
*
* @return void
*/
abstract protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime);
/**
* Fetch cached content's modification timestamp from data source
*
* {@internal implementing this method is optional.
* Only implement it if modification times can be accessed faster than loading the complete cached content.}}
*
* @param string $id unique cache content identifier
* @param string $name template name
* @param string $cache_id cache id
* @param string $compile_id compile id
* @param string $id unique cache content identifier
* @param string $name template name
* @param string $cache_id cache id
* @param string $compile_id compile id
*
* @return integer|boolean timestamp (epoch) the template was modified, or false if not found
*/
protected function fetchTimestamp($id, $name, $cache_id, $compile_id)
@ -54,6 +55,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
* @param string $compile_id compile id
* @param integer|null $exp_time seconds till expiration or null
* @param string $content content to cache
*
* @return boolean success
*/
abstract protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content);
@ -65,6 +67,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
* @param string $cache_id cache id
* @param string $compile_id compile id
* @param integer|null $exp_time seconds till expiration time in seconds or null
*
* @return integer number of deleted caches
*/
abstract protected function delete($name, $cache_id, $compile_id, $exp_time);
@ -74,6 +77,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
*
* @param Smarty_Template_Cached $cached cached object
* @param Smarty_Internal_Template $_template template object
*
* @return void
*/
public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template)
@ -88,7 +92,8 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
/**
* populate Cached Object with timestamp and exists from Resource
*
* @param Smarty_Template_Cached $source cached object
* @param Smarty_Template_Cached $cached
*
* @return void
*/
public function populateTimestamp(Smarty_Template_Cached $cached)
@ -111,9 +116,10 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
*
* @param Smarty_Internal_Template $_template template object
* @param Smarty_Template_Cached $cached cached object
* @return booelan true or false if the cached content does not exist
*
* @return boolean true or false if the cached content does not exist
*/
public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached=null)
public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null)
{
if (!$cached) {
$cached = $_template->cached;
@ -131,6 +137,9 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
);
}
if (isset($content)) {
/** @var Smarty_Internal_Template $_smarty_tpl
* used in evaluated code
*/
$_smarty_tpl = $_template;
eval("?>" . $content);
@ -145,6 +154,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
*
* @param Smarty_Internal_Template $_template template object
* @param string $content content to cache
*
* @return boolean success
*/
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
@ -164,9 +174,10 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
*
* @param Smarty $smarty Smarty object
* @param integer $exp_time expiration time (number of seconds, not timestamp)
*
* @return integer number of cache files deleted
*/
public function clearAll(Smarty $smarty, $exp_time=null)
public function clearAll(Smarty $smarty, $exp_time = null)
{
$this->cache = array();
@ -181,13 +192,40 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
* @param string $cache_id cache id
* @param string $compile_id compile id
* @param integer $exp_time expiration time (number of seconds, not timestamp)
*
* @return integer number of cache files deleted
*/
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
{
$this->cache = array();
$cache_name = null;
return $this->delete($resource_name, $cache_id, $compile_id, $exp_time);
if (isset($resource_name)) {
$_save_stat = $smarty->caching;
$smarty->caching = true;
$tpl = new $smarty->template_class($resource_name, $smarty);
$smarty->caching = $_save_stat;
if ($tpl->source->exists) {
$cache_name = $tpl->source->name;
} else {
return 0;
}
// remove from template cache
if ($smarty->allow_ambiguous_resources) {
$_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
} else {
$_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
}
if (isset($_templateId[150])) {
$_templateId = sha1($_templateId);
}
unset($smarty->template_objects[$_templateId]);
// template object no longer needed
unset($tpl);
}
return $this->delete($cache_name, $cache_id, $compile_id, $exp_time);
}
/**
@ -195,7 +233,8 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
*
* @param Smarty $smarty Smarty object
* @param Smarty_Template_Cached $cached cached object
* @return booelan true or false if cache is locked
*
* @return boolean true or false if cache is locked
*/
public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
{
@ -215,6 +254,8 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
*
* @param Smarty $smarty Smarty object
* @param Smarty_Template_Cached $cached cached object
*
* @return bool|void
*/
public function acquireLock(Smarty $smarty, Smarty_Template_Cached $cached)
{
@ -230,6 +271,8 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
*
* @param Smarty $smarty Smarty object
* @param Smarty_Template_Cached $cached cached object
*
* @return bool|void
*/
public function releaseLock(Smarty $smarty, Smarty_Template_Cached $cached)
{