| 1: | <?php
|
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: |
|
| 8: |
|
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: |
|
| 16: | abstract class Smarty_CacheResource
|
| 17: | {
|
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: |
|
| 23: | protected static $sysplugins = array('file' => 'smarty_internal_cacheresource_file.php',);
|
| 24: |
|
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: |
|
| 33: | abstract public function populate(\Smarty_Template_Cached $cached, Smarty_Internal_Template $_template);
|
| 34: |
|
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: |
|
| 42: | abstract public function populateTimestamp(Smarty_Template_Cached $cached);
|
| 43: |
|
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | |
| 50: | |
| 51: | |
| 52: |
|
| 53: | abstract public function process(
|
| 54: | Smarty_Internal_Template $_template,
|
| 55: | Smarty_Template_Cached $cached = null,
|
| 56: | $update = false
|
| 57: | );
|
| 58: |
|
| 59: | |
| 60: | |
| 61: | |
| 62: | |
| 63: | |
| 64: | |
| 65: | |
| 66: |
|
| 67: | abstract public function writeCachedContent(Smarty_Internal_Template $_template, $content);
|
| 68: |
|
| 69: | |
| 70: | |
| 71: | |
| 72: | |
| 73: | |
| 74: | |
| 75: |
|
| 76: | abstract public function readCachedContent(Smarty_Internal_Template $_template);
|
| 77: |
|
| 78: | |
| 79: | |
| 80: | |
| 81: | |
| 82: | |
| 83: | |
| 84: |
|
| 85: | public function getCachedContent(Smarty_Internal_Template $_template)
|
| 86: | {
|
| 87: | if ($_template->cached->handler->process($_template)) {
|
| 88: | ob_start();
|
| 89: | $unifunc = $_template->cached->unifunc;
|
| 90: | $unifunc($_template);
|
| 91: | return ob_get_clean();
|
| 92: | }
|
| 93: | return null;
|
| 94: | }
|
| 95: |
|
| 96: | |
| 97: | |
| 98: | |
| 99: | |
| 100: | |
| 101: | |
| 102: | |
| 103: |
|
| 104: | abstract public function clearAll(Smarty $smarty, $exp_time = null);
|
| 105: |
|
| 106: | |
| 107: | |
| 108: | |
| 109: | |
| 110: | |
| 111: | |
| 112: | |
| 113: | |
| 114: | |
| 115: | |
| 116: |
|
| 117: | abstract public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time);
|
| 118: |
|
| 119: | |
| 120: | |
| 121: | |
| 122: | |
| 123: | |
| 124: |
|
| 125: | public function locked(Smarty $smarty, Smarty_Template_Cached $cached)
|
| 126: | {
|
| 127: |
|
| 128: | $start = microtime(true);
|
| 129: | $hadLock = null;
|
| 130: | while ($this->hasLock($smarty, $cached)) {
|
| 131: | $hadLock = true;
|
| 132: | if (microtime(true) - $start > $smarty->locking_timeout) {
|
| 133: |
|
| 134: | return false;
|
| 135: | }
|
| 136: | sleep(1);
|
| 137: | }
|
| 138: | return $hadLock;
|
| 139: | }
|
| 140: |
|
| 141: | |
| 142: | |
| 143: | |
| 144: | |
| 145: | |
| 146: | |
| 147: | |
| 148: |
|
| 149: | public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
| 150: | {
|
| 151: |
|
| 152: | return false;
|
| 153: | }
|
| 154: |
|
| 155: | |
| 156: | |
| 157: | |
| 158: | |
| 159: | |
| 160: | |
| 161: | |
| 162: |
|
| 163: | public function acquireLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
| 164: | {
|
| 165: |
|
| 166: | return true;
|
| 167: | }
|
| 168: |
|
| 169: | |
| 170: | |
| 171: | |
| 172: | |
| 173: | |
| 174: | |
| 175: | |
| 176: |
|
| 177: | public function releaseLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
| 178: | {
|
| 179: |
|
| 180: | return true;
|
| 181: | }
|
| 182: |
|
| 183: | |
| 184: | |
| 185: | |
| 186: | |
| 187: | |
| 188: | |
| 189: | |
| 190: | |
| 191: |
|
| 192: | public static function load(Smarty $smarty, $type = null)
|
| 193: | {
|
| 194: | if (!isset($type)) {
|
| 195: | $type = $smarty->caching_type;
|
| 196: | }
|
| 197: |
|
| 198: | if (isset($smarty->_cache[ 'cacheresource_handlers' ][ $type ])) {
|
| 199: | return $smarty->_cache[ 'cacheresource_handlers' ][ $type ];
|
| 200: | }
|
| 201: |
|
| 202: | if (isset($smarty->registered_cache_resources[ $type ])) {
|
| 203: |
|
| 204: | return $smarty->_cache[ 'cacheresource_handlers' ][ $type ] = $smarty->registered_cache_resources[ $type ];
|
| 205: | }
|
| 206: |
|
| 207: | if (isset(self::$sysplugins[ $type ])) {
|
| 208: | $cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
|
| 209: | return $smarty->_cache[ 'cacheresource_handlers' ][ $type ] = new $cache_resource_class();
|
| 210: | }
|
| 211: |
|
| 212: | $cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type);
|
| 213: | if ($smarty->loadPlugin($cache_resource_class)) {
|
| 214: | return $smarty->_cache[ 'cacheresource_handlers' ][ $type ] = new $cache_resource_class();
|
| 215: | }
|
| 216: |
|
| 217: | throw new SmartyException("Unable to load cache resource '{$type}'");
|
| 218: | }
|
| 219: | }
|
| 220: | |