ILIAS  release_4-4 Revision
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 ()
 

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  }

Member Function Documentation

◆ _getInstance()

static ilShopTopics::_getInstance ( )
static

◆ enableCustomSorting()

ilShopTopics::enableCustomSorting (   $a_enable_custom_sorting)

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

207  {
208  $this->enable_custom_sorting = (bool)$a_enable_custom_sorting;
209  }

◆ getIdFilter()

ilShopTopics::getIdFilter ( )

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

References $id_filter.

Referenced by read().

187  {
188  return $this->id_filter;
189  }
+ Here is the caller graph for this function:

◆ getSortingDirection()

ilShopTopics::getSortingDirection ( )

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

References $sorting_direction.

Referenced by read().

203  {
205  }
+ Here is the caller graph for this function:

◆ getSortingType()

ilShopTopics::getSortingType ( )

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

References $sorting_type.

Referenced by read().

195  {
196  return $this->sorting_type;
197  }
+ Here is the caller graph for this function:

◆ getTopics()

ilShopTopics::getTopics ( )

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

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

◆ isCustomSortingEnabled()

ilShopTopics::isCustomSortingEnabled ( )

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

References $enable_custom_sorting.

Referenced by read().

211  {
212  return (bool)$this->enable_custom_sorting;
213  }
+ Here is the caller graph for this function:

◆ read()

ilShopTopics::read ( )

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

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

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

◆ setIdFilter()

ilShopTopics::setIdFilter (   $a_id_filter)

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

183  {
184  $this->id_filter = $a_id_filter;
185  }

◆ setSortingDirection()

ilShopTopics::setSortingDirection (   $a_sorting_direction)

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

Referenced by read().

199  {
200  $this->sorting_direction = $a_sorting_direction;
201  }
+ Here is the caller graph for this function:

◆ setSortingType()

ilShopTopics::setSortingType (   $a_sorting_type)

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

Referenced by read().

191  {
192  $this->sorting_type = $a_sorting_type;
193  }
+ 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.

◆ $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.

Referenced by ilShopAdvancedSearchGUI\showForm().

◆ 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: