ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilShopTopics Class Reference

Class ilShopTopics. More...

+ Collaboration diagram for ilShopTopics:

Public Member Functions

 read ()
 
 getTopics ()
 
 setIdFilter ($a_id_filter)
 
 getIdFilter ()
 
 setSortingType ($a_sorting_type)
 
 getSortingType ()
 
 setSortingDirection ($a_sorting_direction)
 
 getSortingDirection ()
 
 enableCustomSorting ($a_enable_custom_sorting)
 
 isCustomSortingEnabled ()
 
 getCountAssignedTopics ()
 

Static Public Member Functions

static _getInstance ()
 

Data Fields

const TOPICS_SORT_BY_TITLE = 1
 
const TOPICS_SORT_BY_CREATEDATE = 2
 
const TOPICS_SORT_MANUALLY = 3
 
const DEFAULT_SORTING_TYPE = self::TOPICS_SORT_BY_TITLE
 
const DEFAULT_SORTING_DIRECTION = 'ASC'
 

Private Member Functions

 __construct ()
 

Private Attributes

 $db = null
 
 $sorting_type = self::TOPICS_SORT_BY_TITLE
 
 $sorting_direction = 'ASC'
 
 $enable_custom_sorting = false
 
 $id_filter = 0
 
 $topics = array()
 

Static Private Attributes

static $instance
 

Detailed Description

Class ilShopTopics.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilShopTopics::__construct ( )
private

Definition at line 34 of file class.ilShopTopics.php.

35 {
36 global $ilDB;
37
38 $this->db = $ilDB;
39 }
global $ilDB

References $ilDB.

Member Function Documentation

◆ _getInstance()

◆ enableCustomSorting()

ilShopTopics::enableCustomSorting (   $a_enable_custom_sorting)

Definition at line 204 of file class.ilShopTopics.php.

205 {
206 $this->enable_custom_sorting = (bool)$a_enable_custom_sorting;
207 }

◆ getCountAssignedTopics()

ilShopTopics::getCountAssignedTopics ( )

Definition at line 213 of file class.ilShopTopics.php.

214 {
215 global $ilDB;
216
217 $res = $ilDB->query('SELECT pt_topic_fk, count(pt_topic_fk) cnt FROM payment_objects GROUP BY pt_topic_fk');
218
219 $topics_count = array();
220 while($row = $ilDB->fetchAssoc($res))
221 {
222 $topics_count[$row['pt_topic_fk']] = (int)$row['cnt'];
223 }
224
225 return $topics_count;
226 }

References $ilDB, $res, and $row.

◆ getIdFilter()

ilShopTopics::getIdFilter ( )

Definition at line 184 of file class.ilShopTopics.php.

185 {
186 return $this->id_filter;
187 }

References $id_filter.

Referenced by read().

+ Here is the caller graph for this function:

◆ getSortingDirection()

ilShopTopics::getSortingDirection ( )

Definition at line 200 of file class.ilShopTopics.php.

201 {
203 }

References $sorting_direction.

Referenced by read().

+ Here is the caller graph for this function:

◆ getSortingType()

ilShopTopics::getSortingType ( )

Definition at line 192 of file class.ilShopTopics.php.

193 {
194 return $this->sorting_type;
195 }

References $sorting_type.

Referenced by read().

+ Here is the caller graph for this function:

◆ getTopics()

ilShopTopics::getTopics ( )

Definition at line 175 of file class.ilShopTopics.php.

176 {
177 return is_array($this->topics) ? $this->topics : array();
178 }

◆ isCustomSortingEnabled()

ilShopTopics::isCustomSortingEnabled ( )

Definition at line 208 of file class.ilShopTopics.php.

209 {
210 return (bool)$this->enable_custom_sorting;
211 }

References $enable_custom_sorting.

Referenced by read().

+ Here is the caller graph for this function:

◆ read()

ilShopTopics::read ( )

Definition at line 51 of file class.ilShopTopics.php.

52 {
53 global $ilUser;
54
55 $this->topics = array();
56
57 if(!in_array($this->getSortingType(), array(self::TOPICS_SORT_BY_TITLE, self::TOPICS_SORT_BY_CREATEDATE, self::TOPICS_SORT_MANUALLY)))
58 {
59 $this->setSortingType(self::DEFAULT_SORTING_TYPE);
60 }
61 if(!in_array(strtoupper($this->getSortingDirection()), array('ASC', 'DESC')))
62 {
63 $this->setSortingDirection(self::DEFAULT_SORTING_DIRECTION);
64 }
65
66 if(!$this->isCustomSortingEnabled())
67 {
68
69 $data_types = array();
70 $data_values = array();
71
72 $query = 'SELECT * FROM payment_topics WHERE 1 = 1 ';
73 if((int)$this->getIdFilter() > 0)
74 {
75 $query .= ' AND pt_topic_pk = %s';
76 array_push($data_types, 'integer');
77 array_push($data_values, $this->getIdFilter());
78 }
79
80 switch($this->getSortingType())
81 {
82 case 3:
83 $query .= ' ORDER BY pt_topic_sort ';
84 break;
85
86 case 2:
87 $query .= ' ORDER BY pt_topic_created ';
88 break;
89
90 case 1:
91 default:
92 $query .= ' ORDER BY pt_topic_title ';
93 break;
94 }
95 $query .= ' '.strtoupper($this->getSortingDirection()).' ';
96 $query .= " , pt_topic_title ";
97 $query .= ' '.strtoupper($this->getSortingDirection()).' ';
98
99
100 }
101 else
102 {
103
104 $data_types = array();
105 $data_values = array();
106
107 $query = 'SELECT * FROM payment_topics ';
108 switch($this->getSortingType())
109 {
110 case 3:
111 $query .= ' LEFT JOIN payment_topic_usr_sort ON
112 ptus_pt_topic_fk = pt_topic_pk AND
113 ptus_usr_id = %s';
114 array_push($data_types, 'integer');
115 array_push($data_values, $ilUser->getId());
116
117 break;
118 }
119 $query .= ' WHERE 1 = 1 ';
120
121 if((int)$this->id_filter > 0)
122 {
123 $query .= ' AND pt_topic_pk = %s';
124 array_push($data_types, 'integer');
125 array_push($data_values, $this->getIdFilter());
126 }
127
128 switch($this->getSortingType())
129 {
130 case 3:
131 $query .= ' ORDER BY ptus_sorting ';
132 break;
133
134 case 2:
135 $query .= ' ORDER BY pt_topic_created ';
136 break;
137
138 case 1:
139 default:
140 $query .= ' ORDER BY pt_topic_title ';
141 break;
142 }
143 $query .= ' '.strtoupper($this->getSortingDirection()).' ';
144 $query .= " , pt_topic_sort ";
145 $query .= ' '.strtoupper($this->getSortingDirection()).' ';
146 }
147
148 if(count($data_types) > 0 && count($data_values > 0))
149 {
150 $res = $this->db->queryf($query, $data_types, $data_values);
151 }
152 else
153 {
154 $res = $this->db->query($query);
155 }
156
157 $counter = 0;
158 while($row = $this->db->fetchObject($res))
159 {
160 $oTopic = new ilShopTopic();
161 $oTopic->setId($row->pt_topic_pk);
162 $oTopic->setTitle($row->pt_topic_title);
163 $oTopic->setSorting($row->pt_topic_sort);
164 $oTopic->setCustomSorting((int)$row->ptus_sorting);
165 $oTopic->setCreateDate($row->pt_topic_created);
166 $oTopic->setChangeDate($row->pt_topic_changed);
167 $this->topics[$row->pt_topic_pk] = $oTopic;
168
169 ++$counter;
170 }
171
172 return $this;
173 }
Class ilShopTopic.
setSortingDirection($a_sorting_direction)
setSortingType($a_sorting_type)
global $ilUser
Definition: imgupload.php:15

References $ilUser, $query, $res, $row, getIdFilter(), getSortingDirection(), getSortingType(), isCustomSortingEnabled(), setSortingDirection(), and setSortingType().

+ Here is the call graph for this function:

◆ setIdFilter()

ilShopTopics::setIdFilter (   $a_id_filter)

Definition at line 180 of file class.ilShopTopics.php.

181 {
182 $this->id_filter = $a_id_filter;
183 }

◆ setSortingDirection()

ilShopTopics::setSortingDirection (   $a_sorting_direction)

Definition at line 196 of file class.ilShopTopics.php.

197 {
198 $this->sorting_direction = $a_sorting_direction;
199 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setSortingType()

ilShopTopics::setSortingType (   $a_sorting_type)

Definition at line 188 of file class.ilShopTopics.php.

189 {
190 $this->sorting_type = $a_sorting_type;
191 }

Referenced by read().

+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilShopTopics::$db = null
private

Definition at line 20 of file class.ilShopTopics.php.

◆ $enable_custom_sorting

ilShopTopics::$enable_custom_sorting = false
private

Definition at line 23 of file class.ilShopTopics.php.

Referenced by isCustomSortingEnabled().

◆ $id_filter

ilShopTopics::$id_filter = 0
private

Definition at line 24 of file class.ilShopTopics.php.

Referenced by getIdFilter().

◆ $instance

ilShopTopics::$instance
staticprivate

Definition at line 18 of file class.ilShopTopics.php.

Referenced by _getInstance().

◆ $sorting_direction

ilShopTopics::$sorting_direction = 'ASC'
private

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

Referenced by getSortingDirection().

◆ $sorting_type

ilShopTopics::$sorting_type = self::TOPICS_SORT_BY_TITLE
private

Definition at line 21 of file class.ilShopTopics.php.

Referenced by getSortingType().

◆ $topics

ilShopTopics::$topics = array()
private

Definition at line 25 of file class.ilShopTopics.php.

◆ DEFAULT_SORTING_DIRECTION

const ilShopTopics::DEFAULT_SORTING_DIRECTION = 'ASC'

Definition at line 32 of file class.ilShopTopics.php.

◆ DEFAULT_SORTING_TYPE

const ilShopTopics::DEFAULT_SORTING_TYPE = self::TOPICS_SORT_BY_TITLE

Definition at line 31 of file class.ilShopTopics.php.

◆ TOPICS_SORT_BY_CREATEDATE

const ilShopTopics::TOPICS_SORT_BY_CREATEDATE = 2

◆ TOPICS_SORT_BY_TITLE

◆ TOPICS_SORT_MANUALLY


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