Author: ornicar2
Date: 2010-01-27 12:38:31 +0100 (Wed, 27 Jan 2010)
New Revision: 27233

Modified:
   plugins/diemPlugin/trunk/dmAdminPlugin/config/dm/services.yml
   plugins/diemPlugin/trunk/dmAdminPlugin/lib/log/dmRequestLogView.php
   plugins/diemPlugin/trunk/dmAdminPlugin/lib/log/dmRequestLogViewLittle.php
   plugins/diemPlugin/trunk/dmAdminPlugin/lib/view/html/log/dmLogView.php
Log:
[Diem]
- added log_view.options parameter to the admin log_view service
- made possible to hide user IP from the log_view by changing the show_ip option

Modified: plugins/diemPlugin/trunk/dmAdminPlugin/config/dm/services.yml
===================================================================
--- plugins/diemPlugin/trunk/dmAdminPlugin/config/dm/services.yml       
2010-01-27 11:26:45 UTC (rev 27232)
+++ plugins/diemPlugin/trunk/dmAdminPlugin/config/dm/services.yml       
2010-01-27 11:38:31 UTC (rev 27233)
@@ -65,6 +65,8 @@
 
   log_view.class:                                 # Renders a diem log
   log_view.log:                                   # The log to render
+  log_view.options:
+    show_ip:                  true                # whether to show users IP
  
 services:
 
@@ -151,4 +153,4 @@
   log_view:
     class:                    %log_view.class%
     shared:                   false
-    arguments:                [ %log_view.log%, @i18n, @user, @helper ]
\ No newline at end of file
+    arguments:                [ %log_view.log%, @i18n, @user, @helper, 
%log_view.options% ]
\ No newline at end of file

Modified: plugins/diemPlugin/trunk/dmAdminPlugin/lib/log/dmRequestLogView.php
===================================================================
--- plugins/diemPlugin/trunk/dmAdminPlugin/lib/log/dmRequestLogView.php 
2010-01-27 11:26:45 UTC (rev 27232)
+++ plugins/diemPlugin/trunk/dmAdminPlugin/lib/log/dmRequestLogView.php 
2010-01-27 11:38:31 UTC (rev 27233)
@@ -19,9 +19,20 @@
   {
     return sprintf('%s%s',
       ($username = $entry->get('username')) ? sprintf('<strong 
class="mr10">%s</strong><br />', $username) : '',
-      $entry->get('ip')
+      $this->renderIp($entry->get('ip'))
     );
   }
+
+  protected function renderIp($ip)
+  {
+    if ($this->getOption('show_ip'))
+    {
+      return $ip;
+    }
+
+    $ipParts = explode('.', $ip);
+    return 4 === count($ipParts) ? $ipParts[0].'.'.$ipParts[1].'.xx.xx' : $ip;
+  }
   
   protected function renderBrowser(dmRequestLogEntry $entry)
   {

Modified: 
plugins/diemPlugin/trunk/dmAdminPlugin/lib/log/dmRequestLogViewLittle.php
===================================================================
--- plugins/diemPlugin/trunk/dmAdminPlugin/lib/log/dmRequestLogViewLittle.php   
2010-01-27 11:26:45 UTC (rev 27232)
+++ plugins/diemPlugin/trunk/dmAdminPlugin/lib/log/dmRequestLogViewLittle.php   
2010-01-27 11:38:31 UTC (rev 27233)
@@ -6,7 +6,6 @@
 {
   protected
   $rows = array(
-//    'time'     => 'renderTime',
     'user'     => 'renderUserAndBrowser',
     'location' => 'renderLocation',
   );
@@ -18,7 +17,7 @@
       $this->getBrowserIcon($browser),
       ($username = $entry->get('username'))
       ? '<strong class="mr5">'.$username.'</strong>'
-      : $entry->get('ip'),
+      : $this->renderIp($entry->get('ip')),
       ucfirst($browser->getName()),
       $browser->getVersion()
     );

Modified: plugins/diemPlugin/trunk/dmAdminPlugin/lib/view/html/log/dmLogView.php
===================================================================
--- plugins/diemPlugin/trunk/dmAdminPlugin/lib/view/html/log/dmLogView.php      
2010-01-27 11:26:45 UTC (rev 27232)
+++ plugins/diemPlugin/trunk/dmAdminPlugin/lib/view/html/log/dmLogView.php      
2010-01-27 11:38:31 UTC (rev 27233)
@@ -1,6 +1,6 @@
 <?php
 
-abstract class dmLogView
+abstract class dmLogView extends dmConfigurable
 {
   protected
   $log,
@@ -11,14 +11,29 @@
   $maxEntries = 10,
   $entries;
   
-  public function __construct(dmLog $log, dmI18n $i18n, dmCoreUser $user, 
dmHelper $helper)
+  public function __construct(dmLog $log, dmI18n $i18n, dmCoreUser $user, 
dmHelper $helper, array $options = array())
   {
     $this->log = $log;
     $this->i18n = $i18n;
     $this->user = $user;
     $this->helper = $helper;
-    $this->dateFormat = new sfDateFormat($user->getCulture());
+
+    $this->initialize($options);
   }
+
+  public function getDefaultOptions()
+  {
+    return array(
+      'show_ip' => true
+    );
+  }
+
+  protected function initialize(array $options)
+  {
+    $this->configure($options);
+
+    $this->dateFormat = new sfDateFormat($this->user->getCulture());
+  }
   
   public function setMax($max)
   {
@@ -48,17 +63,6 @@
   {
     $html = '<table>';
     
-//    $html .= '<thead><tr>';
-//    
-//    foreach($this->rows as $name => $method)
-//    {
-//      $html .= '<th>'.$this->i18n->__(dmString::humanize($name)).'</th>';
-//    }
-//    
-//    $html .= '</tr>';
-    
-//    $html .= '</thead>';
-    
     return $html;
   }
   

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to