<commit_before><?php

class dmRequestLogView extends dmLogView
{
  protected
  $rows = array(
    'time'     => 'renderTime',
    'user'     => 'renderUser',
    'browser'  => 'renderBrowser',
    'location' => 'renderLocation',
    'app'      => 'renderApp'
  );
  
  /*
   * Row renderers
   */
  
  protected function renderUser(dmRequestLogEntry $entry)
  {
    return sprintf('%s%s',
      ($username = $entry->get('username')) ? sprintf('<strong class="mr10">%s</strong><br />', $username) : '',
      $entry->get('ip')
    );
  }
  
  protected function renderBrowser(dmRequestLogEntry $entry)
  {
    $browser = $entry->get('browser');

    return sprintf('<div class="clearfix"><div class="browser browser_block %s fleft"></div><strong class="mr10">%s %s</strong><span class="light">%s</span>',
      $this->getBrowserIcon($browser),
      ucfirst($browser->getName()),
      $browser->getVersion(),
      str_replace('Linux', '<strong>Linux</strong>', $entry->get('user_agent'))
    );
  }

  protected function getBrowserIcon($browser)
  {
    if(in_array($browser->getName(), array('googlebot', 'yahoobot', 'msnbot')))
    {
      $icon = $browser. 'browser_bot';
    }
    else
    {
      $icon = $browser;
    }

    return $icon;
  }
  
  protected function renderLocation(dmRequestLogEntry $entry)
  {
    return sprintf('<span class="dm_nowrap">%s</span><br />%s<span class="light">%s ms</span>&nbsp;<span class="light">%s Mb</span>',
      $this->renderLink($entry),
      sprintf('<span class="s16 s16_%s">%s</span>',
        'status_'.$entry->getStatus(),
        $entry->renderCodeOrNull().' '
      ),
      $entry->get('timer'),
      round($entry->get('mem') / (1024*1024))
    );
  }
  
  protected function renderLink(dmRequestLogEntry $entry)
  {
    $uri = ltrim($entry->get('uri'), '/');
    $text = $uri ? $uri : $entry->get('app').' home';
    
    return $this->helper->£link('app:'.$entry->get('app').'/'.$uri)->text($text);
  }
  
  protected function renderTime(dmRequestLogEntry $entry)
  {
    return str_replace(' CEST', '', $this->dateFormat->format($entry->get('time')));
//    return date('Y/m/d H:m:s', $entry->get('time'));
  }
  
  protected function renderApp(dmRequestLogEntry $entry)
  {
    $env = $entry->get('env');
    
    return $entry->get('app').('prod' !== $env ? ' '.$env : '');
  }
  
  protected function doGetEntries(array $options)
  {
    return $this->log->getEntries($this->maxEntries, array_merge($options, array('filter' => array($this, 'filterEntry'))));
  }
  
  public function filterEntry(array $data)
  {
    if (!empty($data['xhr']))
    {
      return (dmRequestLogEntry::isAlert($data) || dmRequestLogEntry::isError($data)) && $this->user->can('error_log');
    }
    
    return true;
  }
}<commit_msg>[Diem] - fixed dmRequestLogView browser icon for bots<commit_after><?php

class dmRequestLogView extends dmLogView
{
  protected
  $rows = array(
    'time'     => 'renderTime',
    'user'     => 'renderUser',
    'browser'  => 'renderBrowser',
    'location' => 'renderLocation',
    'app'      => 'renderApp'
  );
  
  /*
   * Row renderers
   */
  
  protected function renderUser(dmRequestLogEntry $entry)
  {
    return sprintf('%s%s',
      ($username = $entry->get('username')) ? sprintf('<strong class="mr10">%s</strong><br />', $username) : '',
      $entry->get('ip')
    );
  }
  
  protected function renderBrowser(dmRequestLogEntry $entry)
  {
    $browser = $entry->get('browser');

    return sprintf('<div class="clearfix"><div class="browser browser_block %s fleft"></div><strong class="mr10">%s %s</strong><span class="light">%s</span>',
      $this->getBrowserIcon($browser),
      ucfirst($browser->getName()),
      $browser->getVersion(),
      str_replace('Linux', '<strong>Linux</strong>', $entry->get('user_agent'))
    );
  }

  protected function getBrowserIcon($browser)
  {
    if(in_array($browser->getName(), array('googlebot', 'yahoobot', 'msnbot')))
    {
      $icon = $browser->getName(). ' browser_bot';
    }
    else
    {
      $icon = $browser->getName();
    }

    return $icon;
  }
  
  protected function renderLocation(dmRequestLogEntry $entry)
  {
    return sprintf('<span class="dm_nowrap">%s</span><br />%s<span class="light">%s ms</span>&nbsp;<span class="light">%s Mb</span>',
      $this->renderLink($entry),
      sprintf('<span class="s16 s16_%s">%s</span>',
        'status_'.$entry->getStatus(),
        $entry->renderCodeOrNull().' '
      ),
      $entry->get('timer'),
      round($entry->get('mem') / (1024*1024))
    );
  }
  
  protected function renderLink(dmRequestLogEntry $entry)
  {
    $uri = ltrim($entry->get('uri'), '/');
    $text = $uri ? $uri : $entry->get('app').' home';
    
    return $this->helper->£link('app:'.$entry->get('app').'/'.$uri)->text($text);
  }
  
  protected function renderTime(dmRequestLogEntry $entry)
  {
    return str_replace(' CEST', '', $this->dateFormat->format($entry->get('time')));
//    return date('Y/m/d H:m:s', $entry->get('time'));
  }
  
  protected function renderApp(dmRequestLogEntry $entry)
  {
    $env = $entry->get('env');
    
    return $entry->get('app').('prod' !== $env ? ' '.$env : '');
  }
  
  protected function doGetEntries(array $options)
  {
    return $this->log->getEntries($this->maxEntries, array_merge($options, array('filter' => array($this, 'filterEntry'))));
  }
  
  public function filterEntry(array $data)
  {
    if (!empty($data['xhr']))
    {
      return (dmRequestLogEntry::isAlert($data) || dmRequestLogEntry::isError($data)) && $this->user->can('error_log');
    }
    
    return true;
  }
}
{'fraction_non_alphanumeric': 0.20840007118704396, 'fraction_numerical': 0.005694963516639971, 'mean_word_length': 3.4745222929936306, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 119, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2490302', 'n_tokens_mistral': 1898, 'n_tokens_neox': 1880, 'n_words': 300}