Beispiel #1
0
  public function Load($name)
  {
    if (Profiling::IsProfilingEnabled() && !isset($this->usage[$name]))
      $this->usage[$name] = 0;

    // First check the memory cache.
    if (isset($this->cache[$name]))
      return clone $this->cache[$name];

    // Then check if the cache backend has it.
    $template = $this->_QueryCache($name);
    if ($template) {
      $this->cache[$name] = $template;
      return clone $template;
    }

    // Finally, parse and cache the template.
    $template = $this->_Load($name);
    $this->cache[$name] = $template;
    return clone $template;
  }
Beispiel #2
0
  public function ConstructHTMLDebugBlock()
  {
    $debug = '';

    $debug .= "<br />\n";
    $debug .= '<table cellpadding="4" cellspacing="1" border="0" align="center" width="30%" ' .
        'style="background-color: rgb(60, 60, 60); color: white">' . "\n\t";
    $debug .= '<tr><td><strong>Query Debug: ' . sizeof($this->traces) . ' Total </strong></td></tr>';
    foreach ($this->traces as $query) {
      $italic = isset($query['prepare']) && $query['prepare'] ? 'font-style: italic' : '';
      $debug .= "\n\t<tr style=\"background-color: rgb(230, 230, 230); color: black; $italic\">";
      $debug .= "\n\t\t<td>";
      $debug .= "\n\t\t\t$query[query]\n\n";
      if (isset($query['params'])) {
        $debug .= "\t\t\t<ol>\n\t\t\t\t<li>";
        $debug .= implode("</li>\n\t\t\t\t<li>", $query['params']);
        $debug .= "</li>\n\t\t\t</ol>\n";
      }
      $debug .= "\n\t\t\t<div style=\"font-size: 9px;\">(" .
          ($query['end'] - $query['start']) . ")</div>\n";
      $debug .= "<!--\n" . implode("\n", Profiling::FormatDebugBacktrace($query['trace'])) .
          "\n-->\n\t\t</td>\n\t</tr>";
    }

    $debug .= "\n</table>\n\n\n";

    return $debug;
  }
Beispiel #3
0
  public function Render($vars = array())
  {
    $__template_data = $this->data;
    $__template_vars = array_merge($this->vars, $vars);
    $render = function () use ($__template_data, $__template_vars) {
      extract($__template_vars);
      eval('?>' . $__template_data . '<' . '?');
    };

    ob_start();

    $error = error_reporting();
    error_reporting($error & ~E_NOTICE);

    $render();

    error_reporting($error);

    if (Profiling::IsProfilingEnabled())
      TemplateLoader::GetInstance()->MarkTemplateRendered($this->name);

    $data = ob_get_contents();
    ob_end_clean();
    return $data;
  }