Passed
Push — master ( 994f5c...2ea6c2 )
by Patrick
02:04
created
library/Trapdirector/Tables/TrapDirectorTablePaging.php 2 patches
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -6,72 +6,72 @@  discard block
 block discarded – undo
6 6
 trait TrapDirectorTablePaging
7 7
 {
8 8
    
9
-    /*************** Paging *************/
10
-    protected $maxPerPage = 25;
9
+	/*************** Paging *************/
10
+	protected $maxPerPage = 25;
11 11
     
12
-    protected $currentPage = 0;
12
+	protected $currentPage = 0;
13 13
         
14
-    /**** var & func of TrapDirectorTable used ***/
15
-    protected $query;
16
-    abstract protected function getCurrentURLAndQS(string $caller);
17
-    abstract public function applyFilter();
14
+	/**** var & func of TrapDirectorTable used ***/
15
+	protected $query;
16
+	abstract protected function getCurrentURLAndQS(string $caller);
17
+	abstract public function applyFilter();
18 18
     
19
-    /*****************  Paging and counting *********/
19
+	/*****************  Paging and counting *********/
20 20
     
21
-    public function countQuery()
22
-    {
23
-        $this->query = $this->dbConn->select();
24
-        $this->query = $this->query
25
-            ->from(
26
-                $this->table,
27
-                array('COUNT(*)')
28
-                );
29
-        $this->applyFilter();                   
30
-    }
21
+	public function countQuery()
22
+	{
23
+		$this->query = $this->dbConn->select();
24
+		$this->query = $this->query
25
+			->from(
26
+				$this->table,
27
+				array('COUNT(*)')
28
+				);
29
+		$this->applyFilter();                   
30
+	}
31 31
     
32
-    public function count()
33
-    {
34
-        $this->countQuery();
35
-        return $this->dbConn->fetchOne($this->query);
36
-    }
32
+	public function count()
33
+	{
34
+		$this->countQuery();
35
+		return $this->dbConn->fetchOne($this->query);
36
+	}
37 37
     
38
-    public function setMaxPerPage(int $max)
39
-    {
40
-        $this->maxPerPage = $max;
41
-    }
38
+	public function setMaxPerPage(int $max)
39
+	{
40
+		$this->maxPerPage = $max;
41
+	}
42 42
     
43
-    protected function getPagingQuery(array $getVars)
44
-    {
45
-        if (isset($getVars['page']))
46
-        {
47
-            $this->currentPage = $getVars['page'];
48
-        }
49
-    }
43
+	protected function getPagingQuery(array $getVars)
44
+	{
45
+		if (isset($getVars['page']))
46
+		{
47
+			$this->currentPage = $getVars['page'];
48
+		}
49
+	}
50 50
 
51
-    protected function curPagingQuery()
52
-    {
53
-        if ($this->currentPage == '') return '';
54
-        return 'page='.$this->currentPage;
55
-    }
51
+	protected function curPagingQuery()
52
+	{
53
+		if ($this->currentPage == '') return '';
54
+		return 'page='.$this->currentPage;
55
+	}
56 56
     
57
-    public function renderPagingHeader()
58
-    {
59
-        $count = $this->count();
60
-        if ($count <= $this->maxPerPage )
61
-        {
62
-            return  'count : ' . $this->count() . '<br>';
63
-        }
57
+	public function renderPagingHeader()
58
+	{
59
+		$count = $this->count();
60
+		if ($count <= $this->maxPerPage )
61
+		{
62
+			return  'count : ' . $this->count() . '<br>';
63
+		}
64 64
         
65
-        if ($this->currentPage == 0) $this->currentPage = 1;
65
+		if ($this->currentPage == 0) $this->currentPage = 1;
66 66
         
67
-        $numPages = intdiv($count , $this->maxPerPage);
68
-        if ($count % $this->maxPerPage != 0 ) $numPages++;
67
+		$numPages = intdiv($count , $this->maxPerPage);
68
+		if ($count % $this->maxPerPage != 0 ) $numPages++;
69 69
         
70
-        $html = '<div class="pagination-control" role="navigation">';
71
-        $html .= '<ul class="nav tab-nav">';
72
-        if ($this->currentPage <=1)
73
-        {
74
-            $html .= '
70
+		$html = '<div class="pagination-control" role="navigation">';
71
+		$html .= '<ul class="nav tab-nav">';
72
+		if ($this->currentPage <=1)
73
+		{
74
+			$html .= '
75 75
                 <li class="nav-item disabled" aria-hidden="true">
76 76
                     <span class="previous-page">
77 77
                             <span class="sr-only">Previous page</span>
@@ -79,35 +79,35 @@  discard block
 block discarded – undo
79 79
                      </span>
80 80
                 </li>
81 81
                ';
82
-        }
83
-        else 
84
-        {
85
-            $html .= '
82
+		}
83
+		else 
84
+		{
85
+			$html .= '
86 86
                 <li class="nav-item">
87 87
                     <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage - 1 ).'" class="previous-page" >
88 88
                             <i aria-hidden="true" class="icon-angle-double-left"></i>            
89 89
                      </a>
90 90
                 </li>
91 91
             ';
92
-        }
92
+		}
93 93
         
94
-        for ($i=1; $i <= $numPages ; $i++)
95
-        {
96
-            $active = ($this->currentPage == $i) ? 'active' : '';
97
-            $first = ($i-1)*$this->maxPerPage+1;
98
-            $last = $i * $this->maxPerPage;
99
-            if ($last > $count) $last = $count;
100
-            $display = 'Show rows '. $first . ' to '. $last .' of '. $count;
101
-            $html .= '<li class="' . $active . ' nav-item">
94
+		for ($i=1; $i <= $numPages ; $i++)
95
+		{
96
+			$active = ($this->currentPage == $i) ? 'active' : '';
97
+			$first = ($i-1)*$this->maxPerPage+1;
98
+			$last = $i * $this->maxPerPage;
99
+			if ($last > $count) $last = $count;
100
+			$display = 'Show rows '. $first . ' to '. $last .' of '. $count;
101
+			$html .= '<li class="' . $active . ' nav-item">
102 102
                     <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. $i .'" title="' . $display . '" aria-label="' . $display . '">
103 103
                     '.$i.'                
104 104
                     </a>
105 105
                 </li>';
106
-        }
106
+		}
107 107
         
108
-        if ($this->currentPage == $numPages)
109
-        {
110
-            $html .= '
108
+		if ($this->currentPage == $numPages)
109
+		{
110
+			$html .= '
111 111
                 <li class="nav-item disabled" aria-hidden="true">
112 112
                     <span class="previous-page">
113 113
                             <span class="sr-only">Previous page</span>
@@ -115,28 +115,28 @@  discard block
 block discarded – undo
115 115
                      </span>
116 116
                 </li>
117 117
                ';
118
-        }
119
-        else
120
-        {
121
-            $html .= '
118
+		}
119
+		else
120
+		{
121
+			$html .= '
122 122
                 <li class="nav-item">
123 123
                     <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage + 1 ).'" class="next-page">
124 124
                             <i aria-hidden="true" class="icon-angle-double-right"></i>
125 125
                      </a>
126 126
                 </li>
127 127
             ';
128
-        }
128
+		}
129 129
         
130
-        $html .= '</ul> </div>';
130
+		$html .= '</ul> </div>';
131 131
         
132
-        return $html;
133
-    }
132
+		return $html;
133
+	}
134 134
     
135
-    public function applyPaging()
136
-    {
137
-        $this->query->limitPage($this->currentPage,$this->maxPerPage);
138
-        return $this;
139
-    }
135
+	public function applyPaging()
136
+	{
137
+		$this->query->limitPage($this->currentPage,$this->maxPerPage);
138
+		return $this;
139
+	}
140 140
     
141 141
     
142 142
 }
143 143
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
 {
8 8
    
9 9
     /*************** Paging *************/
10
-    protected $maxPerPage = 25;
10
+    protected $maxPerPage=25;
11 11
     
12
-    protected $currentPage = 0;
12
+    protected $currentPage=0;
13 13
         
14 14
     /**** var & func of TrapDirectorTable used ***/
15 15
     protected $query;
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
     
21 21
     public function countQuery()
22 22
     {
23
-        $this->query = $this->dbConn->select();
24
-        $this->query = $this->query
23
+        $this->query=$this->dbConn->select();
24
+        $this->query=$this->query
25 25
             ->from(
26 26
                 $this->table,
27 27
                 array('COUNT(*)')
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
     
38 38
     public function setMaxPerPage(int $max)
39 39
     {
40
-        $this->maxPerPage = $max;
40
+        $this->maxPerPage=$max;
41 41
     }
42 42
     
43 43
     protected function getPagingQuery(array $getVars)
44 44
     {
45 45
         if (isset($getVars['page']))
46 46
         {
47
-            $this->currentPage = $getVars['page'];
47
+            $this->currentPage=$getVars['page'];
48 48
         }
49 49
     }
50 50
 
@@ -56,22 +56,22 @@  discard block
 block discarded – undo
56 56
     
57 57
     public function renderPagingHeader()
58 58
     {
59
-        $count = $this->count();
60
-        if ($count <= $this->maxPerPage )
59
+        $count=$this->count();
60
+        if ($count <= $this->maxPerPage)
61 61
         {
62
-            return  'count : ' . $this->count() . '<br>';
62
+            return  'count : '.$this->count().'<br>';
63 63
         }
64 64
         
65
-        if ($this->currentPage == 0) $this->currentPage = 1;
65
+        if ($this->currentPage == 0) $this->currentPage=1;
66 66
         
67
-        $numPages = intdiv($count , $this->maxPerPage);
68
-        if ($count % $this->maxPerPage != 0 ) $numPages++;
67
+        $numPages=intdiv($count, $this->maxPerPage);
68
+        if ($count % $this->maxPerPage != 0) $numPages++;
69 69
         
70
-        $html = '<div class="pagination-control" role="navigation">';
71
-        $html .= '<ul class="nav tab-nav">';
72
-        if ($this->currentPage <=1)
70
+        $html='<div class="pagination-control" role="navigation">';
71
+        $html.='<ul class="nav tab-nav">';
72
+        if ($this->currentPage <= 1)
73 73
         {
74
-            $html .= '
74
+            $html.='
75 75
                 <li class="nav-item disabled" aria-hidden="true">
76 76
                     <span class="previous-page">
77 77
                             <span class="sr-only">Previous page</span>
@@ -82,24 +82,24 @@  discard block
 block discarded – undo
82 82
         }
83 83
         else 
84 84
         {
85
-            $html .= '
85
+            $html.='
86 86
                 <li class="nav-item">
87
-                    <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage - 1 ).'" class="previous-page" >
87
+                    <a href="'. $this->getCurrentURLAndQS('paging').'&page='.($this->currentPage - 1).'" class="previous-page" >
88 88
                             <i aria-hidden="true" class="icon-angle-double-left"></i>            
89 89
                      </a>
90 90
                 </li>
91 91
             ';
92 92
         }
93 93
         
94
-        for ($i=1; $i <= $numPages ; $i++)
94
+        for ($i=1; $i <= $numPages; $i++)
95 95
         {
96
-            $active = ($this->currentPage == $i) ? 'active' : '';
97
-            $first = ($i-1)*$this->maxPerPage+1;
98
-            $last = $i * $this->maxPerPage;
99
-            if ($last > $count) $last = $count;
100
-            $display = 'Show rows '. $first . ' to '. $last .' of '. $count;
101
-            $html .= '<li class="' . $active . ' nav-item">
102
-                    <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. $i .'" title="' . $display . '" aria-label="' . $display . '">
96
+            $active=($this->currentPage == $i) ? 'active' : '';
97
+            $first=($i - 1) * $this->maxPerPage + 1;
98
+            $last=$i * $this->maxPerPage;
99
+            if ($last > $count) $last=$count;
100
+            $display='Show rows '.$first.' to '.$last.' of '.$count;
101
+            $html.='<li class="'.$active.' nav-item">
102
+                    <a href="'. $this->getCurrentURLAndQS('paging').'&page='.$i.'" title="'.$display.'" aria-label="'.$display.'">
103 103
                     '.$i.'                
104 104
                     </a>
105 105
                 </li>';
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         
108 108
         if ($this->currentPage == $numPages)
109 109
         {
110
-            $html .= '
110
+            $html.='
111 111
                 <li class="nav-item disabled" aria-hidden="true">
112 112
                     <span class="previous-page">
113 113
                             <span class="sr-only">Previous page</span>
@@ -118,23 +118,23 @@  discard block
 block discarded – undo
118 118
         }
119 119
         else
120 120
         {
121
-            $html .= '
121
+            $html.='
122 122
                 <li class="nav-item">
123
-                    <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage + 1 ).'" class="next-page">
123
+                    <a href="'. $this->getCurrentURLAndQS('paging').'&page='.($this->currentPage + 1).'" class="next-page">
124 124
                             <i aria-hidden="true" class="icon-angle-double-right"></i>
125 125
                      </a>
126 126
                 </li>
127 127
             ';
128 128
         }
129 129
         
130
-        $html .= '</ul> </div>';
130
+        $html.='</ul> </div>';
131 131
         
132 132
         return $html;
133 133
     }
134 134
     
135 135
     public function applyPaging()
136 136
     {
137
-        $this->query->limitPage($this->currentPage,$this->maxPerPage);
137
+        $this->query->limitPage($this->currentPage, $this->maxPerPage);
138 138
         return $this;
139 139
     }
140 140
     
Please login to merge, or discard this patch.
library/Trapdirector/Tables/TrapDirectorTableFilter.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -6,75 +6,75 @@
 block discarded – undo
6 6
 trait TrapDirectorTableFilter
7 7
 {
8 8
     
9
-    /********* Filter ********/
10
-    /** @var string $filterString : string filter for db columns */
11
-    protected $filterString = '';
9
+	/********* Filter ********/
10
+	/** @var string $filterString : string filter for db columns */
11
+	protected $filterString = '';
12 12
     
13
-    /** @var array $filterColumn : columns to apply filter to */
14
-    protected $filterColumn = array();
13
+	/** @var array $filterColumn : columns to apply filter to */
14
+	protected $filterColumn = array();
15 15
     
16
-    protected $filterQuery='';
16
+	protected $filterQuery='';
17 17
     
18
-    /**** var & func of TrapDirectorTable used ***/
19
-    protected $query;
20
-    abstract protected function getCurrentURLAndQS(string $caller);
18
+	/**** var & func of TrapDirectorTable used ***/
19
+	protected $query;
20
+	abstract protected function getCurrentURLAndQS(string $caller);
21 21
     
22
-    /**************** Filtering ******************/
22
+	/**************** Filtering ******************/
23 23
     
24
-    public function applyFilter()
25
-    {
26
-        if ($this->filterString == '' || count($this->filterColumn) == 0)
27
-        {
28
-            return $this;
29
-        }
30
-        $filter='';
31
-        foreach ($this->filterColumn as $column)
32
-        {
33
-            if ($filter != "") $filter.=' OR ';
34
-            //$filter .= "'" . $column . "' LIKE '%" . $this->filterString. "%'";
35
-            $filter .= $column  . " LIKE '%" . $this->filterString. "%'";
36
-        }
37
-        //echo $filter;
24
+	public function applyFilter()
25
+	{
26
+		if ($this->filterString == '' || count($this->filterColumn) == 0)
27
+		{
28
+			return $this;
29
+		}
30
+		$filter='';
31
+		foreach ($this->filterColumn as $column)
32
+		{
33
+			if ($filter != "") $filter.=' OR ';
34
+			//$filter .= "'" . $column . "' LIKE '%" . $this->filterString. "%'";
35
+			$filter .= $column  . " LIKE '%" . $this->filterString. "%'";
36
+		}
37
+		//echo $filter;
38 38
         
39
-        $this->query=$this->query->where($filter);
39
+		$this->query=$this->query->where($filter);
40 40
 
41
-        return $this;
42
-    }
41
+		return $this;
42
+	}
43 43
 
44
-    public function setFilter(string $filter, array $filterCol)
45
-    {
46
-        $this->filterString = $filter;
47
-        $this->filterColumn = $filterCol;
48
-        return $this;
49
-    }
44
+	public function setFilter(string $filter, array $filterCol)
45
+	{
46
+		$this->filterString = $filter;
47
+		$this->filterColumn = $filterCol;
48
+		return $this;
49
+	}
50 50
    
51
-    public function renderFilter()
52
-    {
51
+	public function renderFilter()
52
+	{
53 53
         
54
-        $html=' <form id="genfilter" name="mainFilterGen"
54
+		$html=' <form id="genfilter" name="mainFilterGen"
55 55
 			enctype="application/x-www-form-urlencoded"
56 56
 			action="'.$this->getCurrentURLAndQS('filter').'"
57 57
 			method="get">';
58
-        $html.='<input type="text" name="f" title="Search is simple! Try to combine multiple words"
58
+		$html.='<input type="text" name="f" title="Search is simple! Try to combine multiple words"
59 59
 	placeholder="Search..."  value="'.$this->filterQuery.'">';
60 60
 
61
-        $html.='</form>';
62
-        return $html;
63
-    }
61
+		$html.='</form>';
62
+		return $html;
63
+	}
64 64
  
65
-    public function getFilterQuery(array $getVars)
66
-    {
67
-        if (isset($getVars['f']))
68
-        {
69
-            $this->filterQuery = $getVars['f'];
70
-            $this->setFilter(html_entity_decode($getVars['f']), $this->columnNames);
71
-        }
72
-    }
65
+	public function getFilterQuery(array $getVars)
66
+	{
67
+		if (isset($getVars['f']))
68
+		{
69
+			$this->filterQuery = $getVars['f'];
70
+			$this->setFilter(html_entity_decode($getVars['f']), $this->columnNames);
71
+		}
72
+	}
73 73
     
74
-    protected function curFilterQuery()
75
-    {
76
-        if ($this->filterQuery == '') return '';
77
-        return 'f='.$this->filterQuery;
78
-    }
74
+	protected function curFilterQuery()
75
+	{
76
+		if ($this->filterQuery == '') return '';
77
+		return 'f='.$this->filterQuery;
78
+	}
79 79
     
80 80
 }
81 81
\ No newline at end of file
Please login to merge, or discard this patch.
library/Trapdirector/Tables/HandlerTable.php 2 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -7,137 +7,137 @@
 block discarded – undo
7 7
 class HandlerTable extends TrapDirectorTable
8 8
 {
9 9
 
10
-    protected $status_display=array(
11
-        -2	=>'ignore',
12
-        -1 => '-',
13
-        0	=> 'OK',
14
-        1	=> 'warning',
15
-        2	=> 'critical',
16
-        3	=> 'unknown',);
10
+	protected $status_display=array(
11
+		-2	=>'ignore',
12
+		-1 => '-',
13
+		0	=> 'OK',
14
+		1	=> 'warning',
15
+		2	=> 'critical',
16
+		3	=> 'unknown',);
17 17
     
18
-    // translate
19
-    protected $doTranslate=false;
20
-    protected $MIB;
18
+	// translate
19
+	protected $doTranslate=false;
20
+	protected $MIB;
21 21
     
22
-    // categories
23
-    protected $categories = NULL;
22
+	// categories
23
+	protected $categories = NULL;
24 24
     
25
-    public function setCategoriesArray(array $categories)
26
-    {
27
-        $this->categories = $categories;
28
-    }
25
+	public function setCategoriesArray(array $categories)
26
+	{
27
+		$this->categories = $categories;
28
+	}
29 29
     
30
-    public function groupingPrintData( string $value)
31
-    {
32
-        if ($this->groupingColumn == 'rule_type')
33
-        {
34
-            if ($this->categories == NULL || (! isset($this->categories[$value])))
35
-                return 'Unknown category ('.$value.')';
36
-            return 'Category : '. $this->categories[$value];
37
-        }
38
-        $html = "$value";
39
-        return $html;
40
-    }
30
+	public function groupingPrintData( string $value)
31
+	{
32
+		if ($this->groupingColumn == 'rule_type')
33
+		{
34
+			if ($this->categories == NULL || (! isset($this->categories[$value])))
35
+				return 'Unknown category ('.$value.')';
36
+			return 'Category : '. $this->categories[$value];
37
+		}
38
+		$html = "$value";
39
+		return $html;
40
+	}
41 41
     
42
-    public function setMibloader($mibloader)
43
-    {
44
-        $this->MIB=$mibloader;
45
-        $this->doTranslate=true;
46
-    }
42
+	public function setMibloader($mibloader)
43
+	{
44
+		$this->MIB=$mibloader;
45
+		$this->doTranslate=true;
46
+	}
47 47
 
48
-    public function titleOrder($name)
49
-    {
50
-        switch ($name)
51
-        {
52
-            case 'host_name' : return $this->content[$name]; break;
53
-            case 'source_ip' : return 'ip4'; break;
54
-            default: return $this->content[$name];	
55
-        }
56
-        return NULL;
57
-    }
48
+	public function titleOrder($name)
49
+	{
50
+		switch ($name)
51
+		{
52
+			case 'host_name' : return $this->content[$name]; break;
53
+			case 'source_ip' : return 'ip4'; break;
54
+			default: return $this->content[$name];	
55
+		}
56
+		return NULL;
57
+	}
58 58
     
59
-    public function getCurrentURL()
60
-    {
61
-        return Url::fromPath($this->urlPath . '/handler');
62
-    }
59
+	public function getCurrentURL()
60
+	{
61
+		return Url::fromPath($this->urlPath . '/handler');
62
+	}
63 63
     
64
-    public function renderLine($row)
65
-      {
66
-          $html = '';
67
-          $firstCol = true;
64
+	public function renderLine($row)
65
+	  {
66
+		  $html = '';
67
+		  $firstCol = true;
68 68
                
69
-          $titleNames = array_keys($this->titles);
70
-          foreach ($titleNames as $rowkey )
71
-          {        
72
-              // Check missing value
73
-              if (property_exists($row, $rowkey))
74
-              {
75
-                  switch ($rowkey)
76
-                  {
77
-                      case 'action_match': // display text levels
78
-                      case 'action_nomatch':
79
-                          $val=$this->status_display[$row->$rowkey];
80
-                          break;
81
-                      case 'trap_oid': // try to traslate oids.
69
+		  $titleNames = array_keys($this->titles);
70
+		  foreach ($titleNames as $rowkey )
71
+		  {        
72
+			  // Check missing value
73
+			  if (property_exists($row, $rowkey))
74
+			  {
75
+				  switch ($rowkey)
76
+				  {
77
+					  case 'action_match': // display text levels
78
+					  case 'action_nomatch':
79
+						  $val=$this->status_display[$row->$rowkey];
80
+						  break;
81
+					  case 'trap_oid': // try to traslate oids.
82 82
                           
83
-                          if ($this->doTranslate === true)
84
-                          {
85
-                              $oidName = $this->MIB->translateOID($row->$rowkey);
86
-                              if (isset($oidName['name']))
87
-                              {
88
-                                  $val=$oidName['name'];
89
-                              }
90
-                              else
91
-                              {
92
-                                  $val = $row->$rowkey;
93
-                              }
94
-                          }
95
-                          else
96
-                          {
97
-                              $val = $row->$rowkey;
98
-                          }
99
-                          break;
100
-                      case 'host_name': // switch to hostgroup if name is null
101
-                          if ($row->$rowkey == null)
102
-                          {
103
-                              $val = $row->host_group_name;
104
-                          }
105
-                          else
106
-                          {
107
-                              $val = $row->$rowkey;
108
-                          }
109
-                          break;
110
-                      default:
111
-                          $val = $row->$rowkey;
112
-                  }
113
-                  if ($rowkey == 'trap_oid' && $this->doTranslate===true)
114
-                  {
83
+						  if ($this->doTranslate === true)
84
+						  {
85
+							  $oidName = $this->MIB->translateOID($row->$rowkey);
86
+							  if (isset($oidName['name']))
87
+							  {
88
+								  $val=$oidName['name'];
89
+							  }
90
+							  else
91
+							  {
92
+								  $val = $row->$rowkey;
93
+							  }
94
+						  }
95
+						  else
96
+						  {
97
+							  $val = $row->$rowkey;
98
+						  }
99
+						  break;
100
+					  case 'host_name': // switch to hostgroup if name is null
101
+						  if ($row->$rowkey == null)
102
+						  {
103
+							  $val = $row->host_group_name;
104
+						  }
105
+						  else
106
+						  {
107
+							  $val = $row->$rowkey;
108
+						  }
109
+						  break;
110
+					  default:
111
+						  $val = $row->$rowkey;
112
+				  }
113
+				  if ($rowkey == 'trap_oid' && $this->doTranslate===true)
114
+				  {
115 115
                       
116
-                  }
117
-              } else {
118
-                  $val = '-';
119
-              }
120
-              if ($firstCol === true) { // Put link in first column for trap detail.
121
-                  $html .= '<td class="traphover">'
122
-                      . $this->view->qlink(
123
-                          $this->view->escape($val),
124
-                          Url::fromPath(
125
-                              $this->urlPath . '/handler/add',
126
-                              array('ruleid' => $row->id)
127
-                              )
128
-                          );
129
-                  if ($row->comment != '')
130
-                  {
131
-                      $html.= '<span class="tohover">'. $row->comment .'</span></td>';
132
-                  }
133
-                  $html.= '</td>';
134
-              } else {
135
-                  $html .= '<td>' . $this->view->escape($val) . '</td>';
136
-              }
137
-              $firstCol=false;
116
+				  }
117
+			  } else {
118
+				  $val = '-';
119
+			  }
120
+			  if ($firstCol === true) { // Put link in first column for trap detail.
121
+				  $html .= '<td class="traphover">'
122
+					  . $this->view->qlink(
123
+						  $this->view->escape($val),
124
+						  Url::fromPath(
125
+							  $this->urlPath . '/handler/add',
126
+							  array('ruleid' => $row->id)
127
+							  )
128
+						  );
129
+				  if ($row->comment != '')
130
+				  {
131
+					  $html.= '<span class="tohover">'. $row->comment .'</span></td>';
132
+				  }
133
+				  $html.= '</td>';
134
+			  } else {
135
+				  $html .= '<td>' . $this->view->escape($val) . '</td>';
136
+			  }
137
+			  $firstCol=false;
138 138
               
139
-          }
140
-          return $html;
141
-      }
139
+		  }
140
+		  return $html;
141
+	  }
142 142
 
143 143
 }
144 144
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -20,22 +20,22 @@  discard block
 block discarded – undo
20 20
     protected $MIB;
21 21
     
22 22
     // categories
23
-    protected $categories = NULL;
23
+    protected $categories=NULL;
24 24
     
25 25
     public function setCategoriesArray(array $categories)
26 26
     {
27
-        $this->categories = $categories;
27
+        $this->categories=$categories;
28 28
     }
29 29
     
30
-    public function groupingPrintData( string $value)
30
+    public function groupingPrintData(string $value)
31 31
     {
32 32
         if ($this->groupingColumn == 'rule_type')
33 33
         {
34
-            if ($this->categories == NULL || (! isset($this->categories[$value])))
34
+            if ($this->categories == NULL || (!isset($this->categories[$value])))
35 35
                 return 'Unknown category ('.$value.')';
36
-            return 'Category : '. $this->categories[$value];
36
+            return 'Category : '.$this->categories[$value];
37 37
         }
38
-        $html = "$value";
38
+        $html="$value";
39 39
         return $html;
40 40
     }
41 41
     
@@ -58,16 +58,16 @@  discard block
 block discarded – undo
58 58
     
59 59
     public function getCurrentURL()
60 60
     {
61
-        return Url::fromPath($this->urlPath . '/handler');
61
+        return Url::fromPath($this->urlPath.'/handler');
62 62
     }
63 63
     
64 64
     public function renderLine($row)
65 65
       {
66
-          $html = '';
67
-          $firstCol = true;
66
+          $html='';
67
+          $firstCol=true;
68 68
                
69
-          $titleNames = array_keys($this->titles);
70
-          foreach ($titleNames as $rowkey )
69
+          $titleNames=array_keys($this->titles);
70
+          foreach ($titleNames as $rowkey)
71 71
           {        
72 72
               // Check missing value
73 73
               if (property_exists($row, $rowkey))
@@ -82,57 +82,57 @@  discard block
 block discarded – undo
82 82
                           
83 83
                           if ($this->doTranslate === true)
84 84
                           {
85
-                              $oidName = $this->MIB->translateOID($row->$rowkey);
85
+                              $oidName=$this->MIB->translateOID($row->$rowkey);
86 86
                               if (isset($oidName['name']))
87 87
                               {
88 88
                                   $val=$oidName['name'];
89 89
                               }
90 90
                               else
91 91
                               {
92
-                                  $val = $row->$rowkey;
92
+                                  $val=$row->$rowkey;
93 93
                               }
94 94
                           }
95 95
                           else
96 96
                           {
97
-                              $val = $row->$rowkey;
97
+                              $val=$row->$rowkey;
98 98
                           }
99 99
                           break;
100 100
                       case 'host_name': // switch to hostgroup if name is null
101 101
                           if ($row->$rowkey == null)
102 102
                           {
103
-                              $val = $row->host_group_name;
103
+                              $val=$row->host_group_name;
104 104
                           }
105 105
                           else
106 106
                           {
107
-                              $val = $row->$rowkey;
107
+                              $val=$row->$rowkey;
108 108
                           }
109 109
                           break;
110 110
                       default:
111
-                          $val = $row->$rowkey;
111
+                          $val=$row->$rowkey;
112 112
                   }
113
-                  if ($rowkey == 'trap_oid' && $this->doTranslate===true)
113
+                  if ($rowkey == 'trap_oid' && $this->doTranslate === true)
114 114
                   {
115 115
                       
116 116
                   }
117 117
               } else {
118
-                  $val = '-';
118
+                  $val='-';
119 119
               }
120 120
               if ($firstCol === true) { // Put link in first column for trap detail.
121
-                  $html .= '<td class="traphover">'
121
+                  $html.='<td class="traphover">'
122 122
                       . $this->view->qlink(
123 123
                           $this->view->escape($val),
124 124
                           Url::fromPath(
125
-                              $this->urlPath . '/handler/add',
125
+                              $this->urlPath.'/handler/add',
126 126
                               array('ruleid' => $row->id)
127 127
                               )
128 128
                           );
129 129
                   if ($row->comment != '')
130 130
                   {
131
-                      $html.= '<span class="tohover">'. $row->comment .'</span></td>';
131
+                      $html.='<span class="tohover">'.$row->comment.'</span></td>';
132 132
                   }
133
-                  $html.= '</td>';
133
+                  $html.='</td>';
134 134
               } else {
135
-                  $html .= '<td>' . $this->view->escape($val) . '</td>';
135
+                  $html.='<td>'.$this->view->escape($val).'</td>';
136 136
               }
137 137
               $firstCol=false;
138 138
               
Please login to merge, or discard this patch.
library/Trapdirector/Tables/TrapDirectorTableGrouping.php 3 patches
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -7,85 +7,85 @@
 block discarded – undo
7 7
 {
8 8
     
9 9
   
10
-    /*************** Grouping ************/
10
+	/*************** Grouping ************/
11 11
     
12
-    /** @var boolean $grouppingActive set to true if grouping is active by query or function call */
13
-    protected $grouppingActive=false;
12
+	/** @var boolean $grouppingActive set to true if grouping is active by query or function call */
13
+	protected $grouppingActive=false;
14 14
     
15
-    /** @var string $groupingColumn Name of column (can be hidden) for grouping */
16
-    protected $groupingColumn='';
15
+	/** @var string $groupingColumn Name of column (can be hidden) for grouping */
16
+	protected $groupingColumn='';
17 17
     
18
-    /**@var string $groupingVal Current value of grouping column in row (used while rendering) */
19
-    protected $groupingVal='';
18
+	/**@var string $groupingVal Current value of grouping column in row (used while rendering) */
19
+	protected $groupingVal='';
20 20
     
21
-    /** @var integer $groupingColSpan colspan of grouping line : set to table titles in init */
22
-    protected $groupingColSpan=1;
21
+	/** @var integer $groupingColSpan colspan of grouping line : set to table titles in init */
22
+	protected $groupingColSpan=1;
23 23
       
24
-    /*****************  Grouping ****************/
24
+	/*****************  Grouping ****************/
25 25
     
26
-    /**
27
-     * Set grouping. column must be DB name
28
-     * @param string $columnDBName
29
-     */
30
-    public function setGrouping(string $columnDBName)
31
-    {
32
-        $this->groupingColumn = $columnDBName;
33
-        $this->grouppingActive = TRUE;
34
-    }
26
+	/**
27
+	 * Set grouping. column must be DB name
28
+	 * @param string $columnDBName
29
+	 */
30
+	public function setGrouping(string $columnDBName)
31
+	{
32
+		$this->groupingColumn = $columnDBName;
33
+		$this->grouppingActive = TRUE;
34
+	}
35 35
     
36
-    /**
37
-     * Init of grouping before rendering
38
-     */
39
-    public function initGrouping()
40
-    {
41
-        $this->groupingVal = '';
42
-        $this->groupingColSpan = count($this->titles);
43
-    }
36
+	/**
37
+	 * Init of grouping before rendering
38
+	 */
39
+	public function initGrouping()
40
+	{
41
+		$this->groupingVal = '';
42
+		$this->groupingColSpan = count($this->titles);
43
+	}
44 44
     
45
-    /**
46
-     * Function to print grouping value (for ovveride in specific tables)
47
-     * @param string $value
48
-     * @return string
49
-     */
50
-    public function groupingPrintData( string $value )
51
-    {
52
-        $html = "$value";
53
-        return $html;
54
-    }
45
+	/**
46
+	 * Function to print grouping value (for ovveride in specific tables)
47
+	 * @param string $value
48
+	 * @return string
49
+	 */
50
+	public function groupingPrintData( string $value )
51
+	{
52
+		$html = "$value";
53
+		return $html;
54
+	}
55 55
     
56
-    /**
57
-     * When to display new grouping line  (for ovveride in specific tables)
58
-     * @param string $val1 Current value in grouping
59
-     * @param string $val2 Value of current line
60
-     * @return boolean TRUE if a new grouping line is needed.
61
-     */
62
-    public function groupingEvalNext(string $val1, string $val2)
63
-    {
64
-        if ($val1 != $val2)
65
-            return TRUE;
66
-        else
67
-            return FALSE;
68
-    }
56
+	/**
57
+	 * When to display new grouping line  (for ovveride in specific tables)
58
+	 * @param string $val1 Current value in grouping
59
+	 * @param string $val2 Value of current line
60
+	 * @return boolean TRUE if a new grouping line is needed.
61
+	 */
62
+	public function groupingEvalNext(string $val1, string $val2)
63
+	{
64
+		if ($val1 != $val2)
65
+			return TRUE;
66
+		else
67
+			return FALSE;
68
+	}
69 69
     
70
-    /**
71
-     * Called before each line to check if grouping line is needed.
72
-     * @param mixed $values
73
-     * @return string with line or empty.
74
-     */
75
-    public function groupingNextLine( $values)
76
-    {
77
-        if ($this->grouppingActive === FALSE) return '';
70
+	/**
71
+	 * Called before each line to check if grouping line is needed.
72
+	 * @param mixed $values
73
+	 * @return string with line or empty.
74
+	 */
75
+	public function groupingNextLine( $values)
76
+	{
77
+		if ($this->grouppingActive === FALSE) return '';
78 78
         
79
-        $dbcol = $this->groupingColumn;
80
-        if ($this->groupingVal == '' || $this->groupingEvalNext($this->groupingVal ,$values->$dbcol) === TRUE )
81
-        {
82
-            $this->groupingVal = $values->$dbcol;
83
-            $html = '<tr><th colspan="'. $this->groupingColSpan .'">'. $this->groupingPrintData($this->groupingVal) .'</th></tr>';
84
-            return $html;
85
-        }
86
-        return '';
79
+		$dbcol = $this->groupingColumn;
80
+		if ($this->groupingVal == '' || $this->groupingEvalNext($this->groupingVal ,$values->$dbcol) === TRUE )
81
+		{
82
+			$this->groupingVal = $values->$dbcol;
83
+			$html = '<tr><th colspan="'. $this->groupingColSpan .'">'. $this->groupingPrintData($this->groupingVal) .'</th></tr>';
84
+			return $html;
85
+		}
86
+		return '';
87 87
         
88
-    }
88
+	}
89 89
     
90 90
   
91 91
 }
92 92
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public function setGrouping(string $columnDBName)
31 31
     {
32
-        $this->groupingColumn = $columnDBName;
33
-        $this->grouppingActive = TRUE;
32
+        $this->groupingColumn=$columnDBName;
33
+        $this->grouppingActive=TRUE;
34 34
     }
35 35
     
36 36
     /**
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function initGrouping()
40 40
     {
41
-        $this->groupingVal = '';
42
-        $this->groupingColSpan = count($this->titles);
41
+        $this->groupingVal='';
42
+        $this->groupingColSpan=count($this->titles);
43 43
     }
44 44
     
45 45
     /**
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
      * @param string $value
48 48
      * @return string
49 49
      */
50
-    public function groupingPrintData( string $value )
50
+    public function groupingPrintData(string $value)
51 51
     {
52
-        $html = "$value";
52
+        $html="$value";
53 53
         return $html;
54 54
     }
55 55
     
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
      * @param mixed $values
73 73
      * @return string with line or empty.
74 74
      */
75
-    public function groupingNextLine( $values)
75
+    public function groupingNextLine($values)
76 76
     {
77 77
         if ($this->grouppingActive === FALSE) return '';
78 78
         
79
-        $dbcol = $this->groupingColumn;
80
-        if ($this->groupingVal == '' || $this->groupingEvalNext($this->groupingVal ,$values->$dbcol) === TRUE )
79
+        $dbcol=$this->groupingColumn;
80
+        if ($this->groupingVal == '' || $this->groupingEvalNext($this->groupingVal, $values->$dbcol) === TRUE)
81 81
         {
82
-            $this->groupingVal = $values->$dbcol;
83
-            $html = '<tr><th colspan="'. $this->groupingColSpan .'">'. $this->groupingPrintData($this->groupingVal) .'</th></tr>';
82
+            $this->groupingVal=$values->$dbcol;
83
+            $html='<tr><th colspan="'.$this->groupingColSpan.'">'.$this->groupingPrintData($this->groupingVal).'</th></tr>';
84 84
             return $html;
85 85
         }
86 86
         return '';
Please login to merge, or discard this patch.
Braces   +8 added lines, -5 removed lines patch added patch discarded remove patch
@@ -61,10 +61,11 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function groupingEvalNext(string $val1, string $val2)
63 63
     {
64
-        if ($val1 != $val2)
65
-            return TRUE;
66
-        else
67
-            return FALSE;
64
+        if ($val1 != $val2) {
65
+                    return TRUE;
66
+        } else {
67
+                    return FALSE;
68
+        }
68 69
     }
69 70
     
70 71
     /**
@@ -74,7 +75,9 @@  discard block
 block discarded – undo
74 75
      */
75 76
     public function groupingNextLine( $values)
76 77
     {
77
-        if ($this->grouppingActive === FALSE) return '';
78
+        if ($this->grouppingActive === FALSE) {
79
+        	return '';
80
+        }
78 81
         
79 82
         $dbcol = $this->groupingColumn;
80 83
         if ($this->groupingVal == '' || $this->groupingEvalNext($this->groupingVal ,$values->$dbcol) === TRUE )
Please login to merge, or discard this patch.
library/Trapdirector/Tables/TrapDirectorTableOrder.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -5,65 +5,65 @@
 block discarded – undo
5 5
 
6 6
 trait TrapDirectorTableOrder
7 7
 { 
8
-    /** @var array $order : (db column, 'ASC' | 'DESC') */
9
-    protected $order = array();
10
-    /** @var string $orderQuery passed by GET */
11
-    protected $orderQuery = '';   
8
+	/** @var array $order : (db column, 'ASC' | 'DESC') */
9
+	protected $order = array();
10
+	/** @var string $orderQuery passed by GET */
11
+	protected $orderQuery = '';   
12 12
     
13
-    /** used var & functions of trapDirectorTable **/
14
-    protected $query;
13
+	/** used var & functions of trapDirectorTable **/
14
+	protected $query;
15 15
     
16 16
    /***************** Ordering ********************/
17 17
     
18
-    public function applyOrder()
19
-    {
20
-        if (count($this->order) == 0)
21
-        {
22
-            return $this;
23
-        }
24
-        $orderSQL='';
25
-        foreach ($this->order as $column => $direction)
26
-        {
27
-            if ($orderSQL != "") $orderSQL.=',';
18
+	public function applyOrder()
19
+	{
20
+		if (count($this->order) == 0)
21
+		{
22
+			return $this;
23
+		}
24
+		$orderSQL='';
25
+		foreach ($this->order as $column => $direction)
26
+		{
27
+			if ($orderSQL != "") $orderSQL.=',';
28 28
             
29
-            $orderSQL .= $column . ' ' . $direction;
30
-        }
31
-        $this->query = $this->query->order($orderSQL);
29
+			$orderSQL .= $column . ' ' . $direction;
30
+		}
31
+		$this->query = $this->query->order($orderSQL);
32 32
         
33
-        return $this;
34
-    }
33
+		return $this;
34
+	}
35 35
     
36
-    public function setOrder(array $order)
37
-    {
38
-        $this->order = $order;
39
-        return $this;
40
-    }
36
+	public function setOrder(array $order)
37
+	{
38
+		$this->order = $order;
39
+		return $this;
40
+	}
41 41
 
42
-    public function isOrderSet()
43
-    {
44
-        if (count($this->order) == 0) return FALSE;
45
-        return TRUE;
46
-    }
42
+	public function isOrderSet()
43
+	{
44
+		if (count($this->order) == 0) return FALSE;
45
+		return TRUE;
46
+	}
47 47
     
48
-    public function getOrderQuery(array $getVars)
49
-    {
50
-        if (isset($getVars['o']))
51
-        {
52
-            $this->orderQuery = $getVars['o'];
53
-            $match = array();
54
-            if (preg_match('/(.*)(ASC|DESC)$/', $this->orderQuery , $match))
55
-            {
56
-                $orderArray=array($match[1] => $match[2]);
57
-                echo "$match[1] => $match[2]";
58
-                $this->setOrder($orderArray);
59
-            }
60
-        }
61
-    }
48
+	public function getOrderQuery(array $getVars)
49
+	{
50
+		if (isset($getVars['o']))
51
+		{
52
+			$this->orderQuery = $getVars['o'];
53
+			$match = array();
54
+			if (preg_match('/(.*)(ASC|DESC)$/', $this->orderQuery , $match))
55
+			{
56
+				$orderArray=array($match[1] => $match[2]);
57
+				echo "$match[1] => $match[2]";
58
+				$this->setOrder($orderArray);
59
+			}
60
+		}
61
+	}
62 62
     
63
-    protected function curOrderQuery()
64
-    {
65
-        if ($this->orderQuery == '') return '';
66
-        return 'o='.$this->orderQuery;
67
-    }
63
+	protected function curOrderQuery()
64
+	{
65
+		if ($this->orderQuery == '') return '';
66
+		return 'o='.$this->orderQuery;
67
+	}
68 68
         
69 69
 }
70 70
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,9 +6,9 @@  discard block
 block discarded – undo
6 6
 trait TrapDirectorTableOrder
7 7
 { 
8 8
     /** @var array $order : (db column, 'ASC' | 'DESC') */
9
-    protected $order = array();
9
+    protected $order=array();
10 10
     /** @var string $orderQuery passed by GET */
11
-    protected $orderQuery = '';   
11
+    protected $orderQuery='';   
12 12
     
13 13
     /** used var & functions of trapDirectorTable **/
14 14
     protected $query;
@@ -26,16 +26,16 @@  discard block
 block discarded – undo
26 26
         {
27 27
             if ($orderSQL != "") $orderSQL.=',';
28 28
             
29
-            $orderSQL .= $column . ' ' . $direction;
29
+            $orderSQL.=$column.' '.$direction;
30 30
         }
31
-        $this->query = $this->query->order($orderSQL);
31
+        $this->query=$this->query->order($orderSQL);
32 32
         
33 33
         return $this;
34 34
     }
35 35
     
36 36
     public function setOrder(array $order)
37 37
     {
38
-        $this->order = $order;
38
+        $this->order=$order;
39 39
         return $this;
40 40
     }
41 41
 
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
     {
50 50
         if (isset($getVars['o']))
51 51
         {
52
-            $this->orderQuery = $getVars['o'];
53
-            $match = array();
54
-            if (preg_match('/(.*)(ASC|DESC)$/', $this->orderQuery , $match))
52
+            $this->orderQuery=$getVars['o'];
53
+            $match=array();
54
+            if (preg_match('/(.*)(ASC|DESC)$/', $this->orderQuery, $match))
55 55
             {
56 56
                 $orderArray=array($match[1] => $match[2]);
57 57
                 echo "$match[1] => $match[2]";
Please login to merge, or discard this patch.