ILIAS  release_7 Revision v7.30-3-g800a261c036
ilWorkspaceFolderSorting Class Reference
+ Collaboration diagram for ilWorkspaceFolderSorting:

Public Member Functions

 __construct (ilLanguage $lng=null)
 Constructor. More...
 
 getOptionsByType ($wsp_type, $selected, $parent_effective)
 Get options by type. More...
 
 sortNodes ($nodes, $sorting)
 Sort nodes. More...
 

Data Fields

const SORT_DERIVED = 0
 
const SORT_ALPHABETICAL_ASC = 1
 
const SORT_ALPHABETICAL_DESC = 2
 
const SORT_CREATION_ASC = 3
 
const SORT_CREATION_DESC = 4
 

Protected Member Functions

 getLabel (int $option)
 Get label. More...
 

Protected Attributes

 $lng
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilWorkspaceFolderSorting::__construct ( ilLanguage  $lng = null)

Constructor.

Definition at line 27 of file class.ilWorkspaceFolderSorting.php.

28 {
29 global $DIC;
30
31 $this->lng = ($lng != null)
32 ? $lng
33 : $DIC->language();
34
35 $this->lng->loadLanguageModule("wfld");
36 }
global $DIC
Definition: goto.php:24

References $DIC, and $lng.

Member Function Documentation

◆ getLabel()

ilWorkspaceFolderSorting::getLabel ( int  $option)
protected

Get label.

Parameters
int$option
Returns
string

Definition at line 74 of file class.ilWorkspaceFolderSorting.php.

75 {
76 switch ($option) {
77 case self::SORT_DERIVED: return $this->lng->txt("wfld_derive");
78 case self::SORT_ALPHABETICAL_ASC: return $this->lng->txt("wfld_alphabetically_asc");
79 case self::SORT_ALPHABETICAL_DESC: return $this->lng->txt("wfld_alphabetically_desc");
80 case self::SORT_CREATION_ASC: return $this->lng->txt("wfld_creation_asc");
81 case self::SORT_CREATION_DESC: return $this->lng->txt("wfld_creation_desc");
82 }
83 return "";
84 }

References SORT_ALPHABETICAL_ASC, SORT_ALPHABETICAL_DESC, SORT_CREATION_ASC, SORT_CREATION_DESC, and SORT_DERIVED.

Referenced by getOptionsByType().

+ Here is the caller graph for this function:

◆ getOptionsByType()

ilWorkspaceFolderSorting::getOptionsByType (   $wsp_type,
  $selected,
  $parent_effective 
)

Get options by type.

Parameters
$wsp_type
$selected
$parent_effective
Returns
array

Definition at line 46 of file class.ilWorkspaceFolderSorting.php.

47 {
48 $sort_options = ($wsp_type == "wfld")
49 ? [self::SORT_DERIVED => $this->lng->txt("wfld_derive")]
50 : [];
51 if (in_array($wsp_type, ["wfld", "wsrt"])) {
52 $sort_options[self::SORT_ALPHABETICAL_ASC] = $this->getLabel(self::SORT_ALPHABETICAL_ASC);
53 $sort_options[self::SORT_ALPHABETICAL_DESC] = $this->getLabel(self::SORT_ALPHABETICAL_DESC);
54 $sort_options[self::SORT_CREATION_ASC] = $this->getLabel(self::SORT_CREATION_ASC);
55 $sort_options[self::SORT_CREATION_DESC] = $this->getLabel(self::SORT_CREATION_DESC);
56 }
57
58 if (isset($sort_options[self::SORT_DERIVED])) {
59 $sort_options[self::SORT_DERIVED] .= " (" . $this->getLabel($parent_effective) . ")";
60 }
61
62 if (isset($sort_options[$selected])) {
63 $sort_options[$selected] = "<strong>" . $sort_options[$selected] . "</strong>";
64 }
65 return $sort_options;
66 }

References getLabel(), SORT_ALPHABETICAL_ASC, SORT_ALPHABETICAL_DESC, SORT_CREATION_ASC, SORT_CREATION_DESC, and SORT_DERIVED.

+ Here is the call graph for this function:

◆ sortNodes()

ilWorkspaceFolderSorting::sortNodes (   $nodes,
  $sorting 
)

Sort nodes.

Parameters
$nodes
$sorting
Returns
array

Definition at line 93 of file class.ilWorkspaceFolderSorting.php.

94 {
95 switch ($sorting) {
97 $nodes = ilUtil::sortArray($nodes, "title", "asc");
98 break;
100 $nodes = ilUtil::sortArray($nodes, "title", "desc");
101 break;
102
104 $nodes = ilUtil::sortArray($nodes, "create_date", "asc");
105 break;
106
108 $nodes = ilUtil::sortArray($nodes, "create_date", "desc");
109 break;
110
111 }
112 return $nodes;
113 }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray

References SORT_ALPHABETICAL_ASC, SORT_ALPHABETICAL_DESC, SORT_CREATION_ASC, SORT_CREATION_DESC, and ilUtil\sortArray().

+ Here is the call graph for this function:

Field Documentation

◆ $lng

ilWorkspaceFolderSorting::$lng
protected

Definition at line 22 of file class.ilWorkspaceFolderSorting.php.

Referenced by __construct().

◆ SORT_ALPHABETICAL_ASC

const ilWorkspaceFolderSorting::SORT_ALPHABETICAL_ASC = 1

◆ SORT_ALPHABETICAL_DESC

const ilWorkspaceFolderSorting::SORT_ALPHABETICAL_DESC = 2

Definition at line 15 of file class.ilWorkspaceFolderSorting.php.

Referenced by getLabel(), getOptionsByType(), and sortNodes().

◆ SORT_CREATION_ASC

const ilWorkspaceFolderSorting::SORT_CREATION_ASC = 3

Definition at line 16 of file class.ilWorkspaceFolderSorting.php.

Referenced by getLabel(), getOptionsByType(), and sortNodes().

◆ SORT_CREATION_DESC

const ilWorkspaceFolderSorting::SORT_CREATION_DESC = 4

Definition at line 17 of file class.ilWorkspaceFolderSorting.php.

Referenced by getLabel(), getOptionsByType(), and sortNodes().

◆ SORT_DERIVED

const ilWorkspaceFolderSorting::SORT_DERIVED = 0

The documentation for this class was generated from the following file: