Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
fusiondirectory
fusiondirectory
Commits
16159bb9
Commit
16159bb9
authored
Aug 08, 2013
by
Côme Bernigaud
Committed by
Benoit Mortier
Sep 20, 2013
Browse files
Fixes:
#2595
The code should follow code guidelines
parent
3dc68d99
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/class_departmentSortIterator.inc
View file @
16159bb9
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2003-2010 Cajus Pollmeier
...
...
@@ -38,25 +37,26 @@ class departmentSortIterator implements Iterator {
*
* \param $direction Direction
*/
public
function
__construct
(
$data
,
$direction
)
{
function
depSort
(
$ao
,
$bo
)
{
public
function
__construct
(
$data
,
$direction
)
{
function
depSort
(
$ao
,
$bo
)
{
// Override sort attribute from data if needed
$attribute_a
=
$ao
[
'sort-attribute'
];
$attribute_b
=
$bo
[
'sort-attribute'
];
$attribute_a
=
$ao
[
'sort-attribute'
];
$attribute_b
=
$bo
[
'sort-attribute'
];
// Extract values from ao and bo
$a
=
$b
=
""
;
$a
=
$b
=
""
;
if
(
isset
(
$ao
[
$attribute_a
]))
{
$a
=
$ao
[
$attribute_a
];
$a
=
$ao
[
$attribute_a
];
if
(
is_array
(
$a
))
{
$a
=
$a
[
0
];
$a
=
$a
[
0
];
}
}
if
(
isset
(
$bo
[
$attribute_b
]))
{
$b
=
$bo
[
$attribute_b
];
$b
=
$bo
[
$attribute_b
];
if
(
is_array
(
$b
))
{
$b
=
$b
[
0
];
$b
=
$b
[
0
];
}
}
...
...
@@ -69,9 +69,9 @@ class departmentSortIterator implements Iterator {
// Invert if direction is set
if
(
$direction
)
{
$this
->
data
=
array_reverse
(
$data
,
true
);
$this
->
data
=
array_reverse
(
$data
,
TRUE
);
}
else
{
$this
->
data
=
$data
;
$this
->
data
=
$data
;
}
}
...
...
@@ -80,7 +80,8 @@ class departmentSortIterator implements Iterator {
*
* \return the first element of the array
*/
function
rewind
()
{
function
rewind
()
{
return
reset
(
$this
->
data
);
}
...
...
@@ -89,7 +90,8 @@ class departmentSortIterator implements Iterator {
*
* \return The current element pointed by array pointer
*/
function
current
()
{
function
current
()
{
return
current
(
$this
->
data
);
}
...
...
@@ -98,7 +100,8 @@ class departmentSortIterator implements Iterator {
*
* \return the key element of the array
*/
function
key
()
{
function
key
()
{
return
key
(
$this
->
data
);
}
...
...
@@ -107,7 +110,8 @@ class departmentSortIterator implements Iterator {
*
* \return The next element pointed by array pointer
*/
function
next
()
{
function
next
()
{
return
next
(
$this
->
data
);
}
...
...
@@ -116,9 +120,9 @@ class departmentSortIterator implements Iterator {
*
* \return TRUE if the array is valid, return FALSE otherwise
*/
function
valid
()
{
return
key
(
$this
->
data
)
!==
null
;
function
valid
()
{
return
(
key
(
$this
->
data
)
!==
NULL
);
}
}
?>
include/class_listingSortIterator.inc
View file @
16159bb9
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2003-2010 Cajus Pollmeier
...
...
@@ -43,29 +42,31 @@ class listingSortIterator implements Iterator {
*
* \param string $type
*/
public
function
__construct
(
$data
,
$direction
,
$attribute
,
$type
=
"string"
)
{
public
function
__construct
(
$data
,
$direction
,
$attribute
,
$type
=
"string"
)
{
global
$_sortAttribute
;
global
$_sortType
;
$_sortAttribute
=
$attribute
;
$_sortType
=
$type
;
$_sortAttribute
=
$attribute
;
$_sortType
=
$type
;
// Inline function to
function
attrSort
(
$ao
,
$bo
)
{
function
attrSort
(
$ao
,
$bo
)
{
global
$_sortAttribute
;
global
$_sortType
;
// Extract values from ao and bo
$a
=
$b
=
""
;
$a
=
$b
=
""
;
if
(
isset
(
$ao
[
$_sortAttribute
]))
{
$a
=
$ao
[
$_sortAttribute
];
$a
=
$ao
[
$_sortAttribute
];
if
(
is_array
(
$a
))
{
$a
=
$a
[
0
];
$a
=
$a
[
0
];
}
}
if
(
isset
(
$bo
[
$_sortAttribute
]))
{
$b
=
$bo
[
$_sortAttribute
];
$b
=
$bo
[
$_sortAttribute
];
if
(
is_array
(
$b
))
{
$b
=
$b
[
0
];
$b
=
$b
[
0
];
}
}
...
...
@@ -79,16 +80,16 @@ class listingSortIterator implements Iterator {
case
'date'
:
if
(
$a
==
""
)
{
$a
=
"31.12.0000"
;
$a
=
"31.12.0000"
;
}
if
(
$b
==
""
)
{
$b
=
"31.12.0000"
;
$b
=
"31.12.0000"
;
}
list
(
$d
,
$m
,
$y
)
=
explode
(
'.'
,
$a
);
$a
=
(
int
)
sprintf
(
"%04d%02d%02d"
,
$y
,
$m
,
$d
);
list
(
$d
,
$m
,
$y
)
=
explode
(
'.'
,
$b
);
$b
=
(
int
)
sprintf
(
"%04d%02d%02d"
,
$y
,
$m
,
$d
);
return
$b
-
$a
;
list
(
$d
,
$m
,
$y
)
=
explode
(
'.'
,
$a
);
$a
=
(
int
)
sprintf
(
"%04d%02d%02d"
,
$y
,
$m
,
$d
);
list
(
$d
,
$m
,
$y
)
=
explode
(
'.'
,
$b
);
$b
=
(
int
)
sprintf
(
"%04d%02d%02d"
,
$y
,
$m
,
$d
);
return
$b
-
$a
;
// Sort for string by default
default
:
...
...
@@ -103,9 +104,9 @@ class listingSortIterator implements Iterator {
// Invert if direction is set
if
(
$direction
)
{
$this
->
data
=
array_reverse
(
$data
,
true
);
$this
->
data
=
array_reverse
(
$data
,
TRUE
);
}
else
{
$this
->
data
=
$data
;
$this
->
data
=
$data
;
}
}
...
...
@@ -114,7 +115,8 @@ class listingSortIterator implements Iterator {
*
* \return the first element of the array
*/
function
rewind
()
{
function
rewind
()
{
return
reset
(
$this
->
data
);
}
...
...
@@ -123,7 +125,8 @@ class listingSortIterator implements Iterator {
*
* \return The current element pointed by array pointer
*/
function
current
()
{
function
current
()
{
return
current
(
$this
->
data
);
}
...
...
@@ -132,7 +135,8 @@ class listingSortIterator implements Iterator {
*
* \return the key element of the array
*/
function
key
()
{
function
key
()
{
return
key
(
$this
->
data
);
}
...
...
@@ -141,7 +145,8 @@ class listingSortIterator implements Iterator {
*
* \return The next element pointed by array pointer
*/
function
next
()
{
function
next
()
{
return
next
(
$this
->
data
);
}
...
...
@@ -150,9 +155,9 @@ class listingSortIterator implements Iterator {
*
* \return TRUE if the array is valid, return FALSE otherwise
*/
function
valid
()
{
return
key
(
$this
->
data
)
!==
null
;
function
valid
()
{
return
(
key
(
$this
->
data
)
!==
NULL
);
}
}
?>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment