Changeset 1729


Ignore:
Timestamp:
Jan 18, 2007, 12:06:24 AM (17 years ago)
Author:
plg
Message:

Modification: the history summary graph does not use a true image anymore,
CSS divs are faster and don't require GD library.

Location:
trunk
Files:
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/stats.php

    r1727 r1729  
    318318}
    319319
    320 $url_img = PHPWG_ROOT_PATH.'admin/images/stats.img.php';
    321 
    322 if (isset($page['year']))
    323 {
    324   $url_img.= '?year='.$page['year'];
    325 }
    326 
    327 if (isset($page['month']))
    328 {
    329   $url_img.= '&month='.$page['month'];
    330 }
    331 
    332 if (isset($page['day']))
    333 {
    334   $url_img.= '&day='.$page['day'];
    335 }
    336 
    337320$summary_lines = get_summary(
    338321  @$page['year'],
     
    406389  array(
    407390    'L_STAT_TITLE' => implode($conf['level_separator'], $title_parts),
    408     'SRC_REPORT' => $url_img,
    409391    'PERIOD_LABEL' => $period_label,
    410392    )
     
    415397// +-----------------------------------------------------------------------+
    416398
    417 $i = 1;
    418 
     399$max_width = 400;
     400
     401$datas = array();
     402
     403if (isset($page['day']))
     404{
     405  $key = 'hour';
     406  $min_x = 0;
     407  $max_x = 23;
     408}
     409elseif (isset($page['month']))
     410{
     411  $key = 'day';
     412  $min_x = 1;
     413  $max_x = date(
     414    't',
     415    mktime(12, 0, 0, $page['month'], 1, $page['year'])
     416    );
     417}
     418elseif (isset($page['year']))
     419{
     420  $key = 'month';
     421  $min_x = 1;
     422  $max_x = 12;
     423}
     424else
     425{
     426  $key = 'year';
     427}
     428
     429$max_pages = 1;
    419430foreach ($summary_lines as $line)
    420431{
    421   // echo '<pre>'; print_r($line); echo '</pre>';
    422 
    423   $value = '';
    424  
    425   if (isset($line['hour']))
    426   {
    427     $value.= $line['hour'].' '.l10n('hour');
    428   }
    429   else if (isset($line['day']))
     432  if ($line['nb_pages'] > $max_pages)
     433  {
     434    $max_pages = $line['nb_pages'];
     435  }
     436
     437  $datas[ $line[$key] ] = $line['nb_pages'];
     438}
     439
     440if (!isset($min_x) and !isset($max_x))
     441{
     442  $min_x = min(array_keys($datas));
     443  $max_x = max(array_keys($datas));
     444}
     445
     446for ($i = $min_x; $i <= $max_x; $i++)
     447{
     448  if (!isset($datas[$i]))
     449  {
     450    $datas[$i] = 0;
     451  }
     452
     453  $url = null;
     454
     455  if (isset($page['day']))
     456  {
     457    $value = $i.' '.l10n('hour');
     458  }
     459  else if (isset($page['month']))
    430460  {
    431461    $url =
    432462      PHPWG_ROOT_PATH.'admin.php'
    433463      .'?page=stats'
    434       .'&amp;year='.$line['year']
    435       .'&amp;month='.$line['month']
    436       .'&amp;day='.$line['day']
     464      .'&amp;year='.$page['year']
     465      .'&amp;month='.$page['month']
     466      .'&amp;day='.$i
    437467      ;
    438468
    439     $time = mktime(12, 0, 0, $line['month'], $line['day'], $line['year']);
     469    $time = mktime(12, 0, 0, $page['month'], $i, $page['year']);
    440470   
    441     $value = '<a href="'.$url.'">';
    442     $value.= $line['day'].' ('.$lang['day'][date('w', $time)].')';
    443     $value.= "</a>";   
    444   }
    445   else if (isset($line['month']))
     471    $value = $i.' ('.$lang['day'][date('w', $time)].')';
     472  }
     473  else if (isset($page['year']))
    446474  {
    447475    $url =
    448476      PHPWG_ROOT_PATH.'admin.php'
    449477      .'?page=stats'
    450       .'&amp;year='.$line['year']
    451       .'&amp;month='.$line['month']
     478      .'&amp;year='.$page['year']
     479      .'&amp;month='.$i
    452480      ;
    453481   
    454     $value = '<a href="'.$url.'">';
    455     $value.= $lang['month'][$line['month']];
    456     $value.= "</a>";
     482    $value = $lang['month'][$i];
    457483  }
    458484  else
     
    462488      PHPWG_ROOT_PATH.'admin.php'
    463489      .'?page=stats'
    464       .'&amp;year='.$line['year']
     490      .'&amp;year='.$i
    465491      ;
    466492   
    467     $value = '<a href="'.$url.'">';
    468     $value.= $line['year'];
    469     $value.= "</a>";   
     493    $value = $i;
     494  }
     495
     496  if ($datas[$i] != 0 and isset($url))
     497  {
     498    $value = '<a href="'.$url.'">'.$value.'</a>';
    470499  }
    471500 
     
    474503    array(
    475504      'VALUE' => $value,
    476       'PAGES' => $line['nb_pages'],
    477      
    478       'T_CLASS' => ($i++ % 2) ? 'row1' : 'row2'
     505      'PAGES' => $datas[$i],
     506      'WIDTH' => ceil(($datas[$i] * $max_width) / $max_pages ),
    479507      )
    480508    );
  • trunk/template/yoga/admin/default-layout.css

    r1724 r1729  
    144144  color: white;
    145145} /* PWG Graphic charts */
     146
     147
     148.statBar {
     149  height: 10px;
     150  background-color: #66f;
     151  border: 1px solid black;
     152}
  • trunk/template/yoga/admin/stats.tpl

    r1727 r1729  
    44<h3>{L_STAT_TITLE}</h3>
    55
    6 <img class="image" src="{SRC_REPORT}" alt="{lang:history chart}" />
    7 
    86<table class="table2" id="dailyStats">
    97  <tr class="throw">
    108    <th>{PERIOD_LABEL}</th>
    119    <th>{lang:Pages seen}</th>
     10    <th></th>
    1211  </tr>
    1312<!-- BEGIN statrow -->
    14   <tr class="{statrow.T_CLASS}">
    15     <td>{statrow.VALUE}</td>
     13  <tr>
     14    <td style="white-space: nowrap">{statrow.VALUE}</td>
    1615    <td class="number">{statrow.PAGES}</td>
     16    <td><div class="statBar" style="width:{statrow.WIDTH}px" /></td>
    1717  </tr>
    1818<!-- END statrow -->
Note: See TracChangeset for help on using the changeset viewer.