You are here

public function OpCacheDataModel::getScriptStatusRows in Production check & Production monitor 6

Same name and namespace in other branches
  1. 7 includes/prod_check.opcache.inc \OpCacheDataModel::getScriptStatusRows()

File

includes/prod_check.opcache.inc, line 103

Class

OpCacheDataModel

Code

public function getScriptStatusRows() {
  foreach ($this->_status['scripts'] as $key => $data) {
    $dirs[dirname($key)][basename($key)] = $data;
    $this
      ->_arrayPset($this->_d3Scripts, $key, array(
      'name' => basename($key),
      'size' => $data['memory_consumption'],
    ));
  }
  asort($dirs);
  $basename = '';
  while (true) {
    if (count($this->_d3Scripts) != 1) {
      break;
    }
    $basename .= DIRECTORY_SEPARATOR . key($this->_d3Scripts);
    $this->_d3Scripts = reset($this->_d3Scripts);
  }
  $this->_d3Scripts = $this
    ->_processPartition($this->_d3Scripts, $basename);
  $id = 1;
  $rows = array();
  foreach ($dirs as $dir => $files) {
    $count = count($files);
    $file_plural = $count > 1 ? 's' : null;
    $m = 0;
    foreach ($files as $file => $data) {
      $m += $data["memory_consumption"];
    }
    $m = $this
      ->_size_for_humans($m);
    if ($count > 1) {
      $rows[] = '<tr>';
      $rows[] = "<th class=\"clickable\" id=\"head-{$id}\" colspan=\"3\" onclick=\"toggleVisible('#head-{$id}', '#row-{$id}')\">{$dir} ({$count} file{$file_plural}, {$m})</th>";
      $rows[] = '</tr>';
    }
    foreach ($files as $file => $data) {
      $rows[] = "<tr id=\"row-{$id}\">";
      $rows[] = "<td>" . $this
        ->_format_value($data["hits"]) . "</td>";
      $rows[] = "<td>" . $this
        ->_size_for_humans($data["memory_consumption"]) . "</td>";
      $rows[] = $count > 1 ? "<td>{$file}</td>" : "<td>{$dir}/{$file}</td>";
      $rows[] = '</tr>';
    }
    ++$id;
  }
  return implode("\n", $rows);
}