/** * Recursively check when the dir and all * subfolders have been modified for the last time. * * @return int */ public function modified($format = null) { $modified = filemtime($this->root); $items = $this->scan(array('.', '..')); foreach ($items as $item) { if (!is_dir($this->root . DS . $item)) { continue; } $object = new static($this->root . DS . $item); $newModified = $object->modified(); $modified = $newModified > $modified ? $newModified : $modified; } return !is_null($format) ? date($format, $modified) : $modified; }
/** * Recursively check when the dir and all * subfolders have been modified for the last time. * * @return int */ public function modified($format = null, $handler = 'date') { $modified = filemtime($this->root); $items = $this->scan(array('.', '..')); foreach ($items as $item) { if (is_file($this->root . DS . $item)) { $newModified = filemtime($this->root . DS . $item); } else { $object = new static($this->root . DS . $item); $newModified = $object->modified(); } $modified = $newModified > $modified ? $newModified : $modified; } return !is_null($format) ? $handler($format, $modified) : $modified; }
/** * @ mixed $value * @ ...string * @return mixed * @throws \BadMethodCallException */ public static function set() { $input = func_get_args(); if (count($input) < 2) { throw new \BadMethodCallException('Please pass at least two parameters to session::set'); } static::start(); static::$modified = true; $value = array_shift($input); $final = array_pop($input); $var =& $_SESSION; foreach ($input as $key) { if (!isset($var[$key])) { $var[$key] = []; } $var =& $var[$key]; } $var[$final] = $value; }
/** * Loops through the provided nocache names and injects their executed values * into the content * */ public static function addNoCacheAreas($names, $content, $context) { if (count($names) === 0 || !$names) { return $content; } static::$modified = true; // Set up the twig environment for rendering the non-cached parts \View_Twig::initLoader(); $env = \View_Twig::parser(); $template = new \CMF\Twig\TemplateInclude($env); if (empty($context)) { $context = array(); } if (!empty($context['template'])) { $module = @$context['module']; // Determine whether the ViewModel class exists... if ($viewClass = \CMF::hasViewModel($context['template'])) { $context['view'] = new $viewClass('view', false, $context['template']); } else { try { $viewClass = ucfirst($module) . '\\View_Base'; if (!class_exists($viewClass)) { $viewClass = '\\View_Base'; } $context['view'] = new $viewClass('view', false, $context['template']); } catch (\Exception $e) { } } } foreach ($names as $name => $include) { $content = preg_replace('/<!-- nocache_' . $name . ' .*<!-- endnocache_' . $name . ' -->/sU', $template->renderInclude($include, $context), $content); } return $content; }