10 defined(
'JPATH_PLATFORM') or die;
37 public function call()
40 $args = func_get_args();
41 $callback = array_shift($args);
43 return $this->
get($callback, $args);
59 public function get($callback, $args = array(), $id =
false, $wrkarounds =
false, $woptions = array())
63 if (is_array($callback))
67 elseif (strstr($callback,
'::'))
70 list ($class, $method) = explode(
'::', $callback);
71 $callback = array(trim($class), trim($method));
73 elseif (strstr($callback,
'->'))
82 list ($object_123456789, $method) = explode(
'->', $callback);
83 global $$object_123456789;
84 $callback = array($$object_123456789, $method);
94 $id = $this->_makeId($callback, $args);
97 $data = $this->cache->get($id);
99 $locktest =
new stdClass;
100 $locktest->locked = null;
101 $locktest->locklooped = null;
105 $locktest = $this->cache->lock($id);
106 if ($locktest->locked ==
true && $locktest->locklooped ==
true)
108 $data = $this->cache->get($id);
117 $cached = unserialize(trim($data));
118 $coptions[
'mergehead'] = isset($woptions[
'mergehead']) ? $woptions[
'mergehead'] : 0;
119 $output = ($wrkarounds ==
false) ? $cached[
'output'] :
JCache::getWorkarounds($cached[
'output'], $coptions);
120 $result = $cached[
'result'];
121 if ($locktest->locked ==
true)
123 $this->cache->unlock($id);
130 if (!is_array($args))
132 $Args = !empty($args) ? array(&$args) : array();
139 if ($locktest->locked ==
false)
141 $locktest = $this->cache->lock($id);
144 if (isset($woptions[
'modulemode']) && $woptions[
'modulemode'] == 1)
147 $coptions[
'modulemode'] = 1;
148 $coptions[
'headerbefore'] = $document->getHeadData();
152 $coptions[
'modulemode'] = 0;
156 ob_implicit_flush(
false);
158 $result = call_user_func_array($callback, $Args);
159 $output = ob_get_contents();
165 $coptions[
'nopathway'] = isset($woptions[
'nopathway']) ? $woptions[
'nopathway'] : 1;
166 $coptions[
'nohead'] = isset($woptions[
'nohead']) ? $woptions[
'nohead'] : 1;
167 $coptions[
'nomodules'] = isset($woptions[
'nomodules']) ? $woptions[
'nomodules'] : 1;
170 $cached[
'result'] = $result;
173 $this->cache->store(serialize($cached), $id);
174 if ($locktest->locked ==
true)
176 $this->cache->unlock($id);
194 protected function _makeId($callback, $args)
196 if (is_array($callback) && is_object($callback[0]))
198 $vars = get_object_vars($callback[0]);
199 $vars[] = strtolower(get_class($callback[0]));
200 $callback[0] = $vars;
203 return md5(serialize(array($callback, $args)));