public function get(&$view, $method, $id = false, $wrkarounds = true) { if ($id == false) { $id = $this->_makeId($view, $method); } $data = false; $data = $this->cache->get($id); $locktest = new stdClass(); $locktest->locked = null; $locktest->locklooped = null; if ($data === false) { $locktest = $this->cache->lock($id, null); if ($locktest->locked == true && $locktest->locklooped == true) { $data = $this->cache->get($id); } } if ($data !== false) { $data = unserialize(trim($data)); if ($wrkarounds === true) { echo MCache::getWorkarounds($data); } else { echo isset($data) ? $data : null; } if ($locktest->locked == true) { $this->cache->unlock($id); } return true; } if (method_exists($view, $method)) { if ($locktest->locked == false) { $locktest = $this->cache->lock($id); } ob_start(); ob_implicit_flush(false); $view->{$method}(); $data = ob_get_contents(); ob_end_clean(); echo $data; $cached = array(); $cached = $wrkarounds == true ? MCache::setWorkarounds($data) : $data; $this->cache->store(serialize($cached), $id); if ($locktest->locked == true) { $this->cache->unlock($id); } } return false; }
public function get($id = false, $group = 'page', $wrkarounds = true) { $data = false; if ($id == false) { $id = $this->_makeId(); } if (!headers_sent() && isset($_SERVER['HTTP_IF_NONE_MATCH'])) { $etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']); if ($etag == $id) { $browserCache = isset($this->options['browsercache']) ? $this->options['browsercache'] : false; if ($browserCache) { $this->_noChange(); } } } $data = $this->cache->get($id, $group); $this->_locktest = new stdClass(); $this->_locktest->locked = null; $this->_locktest->locklooped = null; if ($data === false) { $this->_locktest = $this->cache->lock($id, $group); if ($this->_locktest->locked == true && $this->_locktest->locklooped == true) { $data = $this->cache->get($id, $group); } } if ($data !== false) { $data = unserialize(trim($data)); if ($wrkarounds === true) { $data = MCache::getWorkarounds($data); } $this->_setEtag($id); if ($this->_locktest->locked == true) { $this->cache->unlock($id, $group); } return $data; } $this->_id = $id; $this->_group = $group; return false; }
public function getBuffer($type = null, $name = null, $attribs = array()) { // If no type is specified, return the whole buffer if ($type === null) { return parent::$_buffer; } $result = null; if (isset(parent::$_buffer[$type][$name])) { return parent::$_buffer[$type][$name]; } // If the buffer has been explicitly turned off don't display or attempt to render if ($result === false) { return null; } $renderer = $this->loadRenderer($type); if ($this->_caching == true && $type == 'modules') { $cache = MFactory::getCache('com_modules', ''); $hash = md5(serialize(array($name, $attribs, $result, $renderer))); $cbuffer = $cache->get('cbuffer_' . $type); if (isset($cbuffer[$hash])) { return MCache::getWorkarounds($cbuffer[$hash], array('mergehead' => 1)); } else { $options = array(); $options['nopathway'] = 1; $options['nomodules'] = 1; $options['modulemode'] = 1; $this->setBuffer($renderer->render($name, $attribs, $result), $type, $name); $data = parent::$_buffer[$type][$name]; $tmpdata = MCache::setWorkarounds($data, $options); $cbuffer[$hash] = $tmpdata; $cache->store($cbuffer, 'cbuffer_' . $type); } } else { $this->setBuffer($renderer->render($name, $attribs, $result), $type, $name); } return parent::$_buffer[$type][$name]; }
public function get($callback, $args = array(), $id = false, $wrkarounds = false, $woptions = array()) { if (is_array($callback)) { // We have a standard php callback array -- do nothing } elseif (strstr($callback, '::')) { list($class, $method) = explode('::', $callback); $callback = array(trim($class), trim($method)); } elseif (strstr($callback, '->')) { list($object_123456789, $method) = explode('->', $callback); global ${$object_123456789}; $callback = array(${$object_123456789}, $method); } else { // We have just a standard function -- do nothing } if (!$id) { $id = $this->_makeId($callback, $args); } $data = false; $data = $this->cache->get($id); $locktest = new stdClass(); $locktest->locked = null; $locktest->locklooped = null; if ($data === false) { $locktest = $this->cache->lock($id); if ($locktest->locked == true && $locktest->locklooped == true) { $data = $this->cache->get($id); } } $coptions = array(); if ($data !== false) { $cached = unserialize(trim($data)); $coptions['mergehead'] = isset($woptions['mergehead']) ? $woptions['mergehead'] : 0; $output = $wrkarounds == false ? $cached['output'] : MCache::getWorkarounds($cached['output'], $coptions); $result = $cached['result']; if ($locktest->locked == true) { $this->cache->unlock($id); } } else { if (!is_array($args)) { $Args = !empty($args) ? array(&$args) : array(); } else { $Args =& $args; } if ($locktest->locked == false) { $locktest = $this->cache->lock($id); } if (isset($woptions['modulemode'])) { $document = MFactory::getDocument(); $coptions['modulemode'] = $woptions['modulemode']; $coptions['headerbefore'] = $document->getHeadData(); } else { $coptions['modulemode'] = 0; } ob_start(); ob_implicit_flush(false); $result = call_user_func_array($callback, $Args); $output = ob_get_contents(); ob_end_clean(); $cached = array(); $coptions['nopathway'] = isset($woptions['nopathway']) ? $woptions['nopathway'] : 1; $coptions['nohead'] = isset($woptions['nohead']) ? $woptions['nohead'] : 1; $coptions['nomodules'] = isset($woptions['nomodules']) ? $woptions['nomodules'] : 1; $cached['output'] = $wrkarounds == false ? $output : MCache::setWorkarounds($output, $coptions); $cached['result'] = $result; $this->cache->store(serialize($cached), $id); if ($locktest->locked == true) { $this->cache->unlock($id); } } echo $output; return $result; }