*/
protected $cache = array();
- /**
- * A list of the number of times each template has been used
- * @var array
- */
- protected $usage = array();
-
/**
* A list of templates that weren't cached, but are still used
* @var array
$template = $this->_parseTemplate($this->_loadTemplate($name));
}
- $this->cache["$name"] = $template;
- $this->usage["$name"] = 0;
+ $this->cache[$name] = $template;
}
}
}
*/
public function fetch($name)
{
- if (isset($this->cache["$name"]))
+ if (isset($this->cache[$name]))
{
- $template = $this->cache["$name"];
+ $template = $this->cache[$name];
}
else
{
- $this->uncached[] = $name;
+ $this->uncached[$name]++;
BSApp::Debug("Manually loading template '$name'");
$template = $this->_loadTemplate($name);
$template = $this->_parseTemplate($template);
}
- if (!isset($this->usage["$name"]))
- {
- $this->usage["$name"] = 0;
- }
-
- $this->usage["$name"]++;
-
return $template;
}
$debugBlock .= "\n<div align=\"center\">Executed in " . round(BSFunctions::FetchMicrotimeDiff($_SERVER['REQUEST_TIME']), 10) . ' seconds</div>';
$debugBlock .= "\n<br /><div align=\"center\">" . BSApp::GetDebugList() . "</div>";
- $optlist = array();
- $usage = array();
- foreach ($this->usage AS $name => $count)
+ if (sizeof($this->uncached) > 0)
{
- if (in_array($name, $this->uncached))
+ foreach ($this->uncached AS $name => $count)
{
- $optlist[] = $name . '[' . $count . ']';
+ $tpls[] = $name . "($count)";
}
- $usage[] = $name . " ($count)";
- }
- $sizeof = sizeof($this->uncached);
- if ($sizeof > 0)
- {
- $debugBlock .= "<br /><div style=\"color: red\" align=\"center\"><strong>Uncached Template(s):</strong> $sizeof ( " . implode(' ', $optlist) . " )</div>\n";
- }
-
- $debugBlock .= (sizeof($this->uncached) < 1 ? "<br />\n" : '') . "<div align=\"center\"><select><option>Template Usage (" . array_sum($this->usage) . ")</option>";
- foreach ($usage AS $tpl)
- {
- $debugBlock .= "<option>--- $tpl</option>";
+ $debugBlock .= "<br /><div style=\"color: red\" align=\"center\"><strong>Uncached Templates:</strong>" . implode(', ', $tpls) . " )</div>\n";
}
- $debugBlock .= "</select></div>\n";
if (BSApp::GetType('Db'))
{