ILIAS  release_4-4 Revision
ilShopNewsItemList Class Reference
+ Inheritance diagram for ilShopNewsItemList:
+ Collaboration diagram for ilShopNewsItemList:

Public Member Functions

 hasItems ()
 
 rewind ()
 
 valid ()
 
 current ()
 
 key ()
 
 next ()
 
 _getInstance ()
 
 read ()
 
 reload ()
 
 setArchiveDate ($a_archive_date)
 
 getArchiveDate ()
 
 setPublicSection ($a_public_section)
 
 isPublicSection ()
 
 setMode ($a_mode)
 
 getMode ()
 

Data Fields

const TYPE_NEWS = 1
 
const TYPE_ARCHIVE = 2
 

Private Member Functions

 __construct ()
 
 __clone ()
 

Private Attributes

 $news = array()
 
 $mode = self::TYPE_NEWS
 
 $archive_date = null
 
 $public_section = false
 

Static Private Attributes

static $instance = null
 

Detailed Description

Author
Nadia Ahmad nahma.nosp@m.d@da.nosp@m.tabay.nosp@m..de
Version
$Id$

Definition at line 9 of file class.ilShopNewsItemList.php.

Constructor & Destructor Documentation

◆ __construct()

ilShopNewsItemList::__construct ( )
private

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

22  {
23  }

Member Function Documentation

◆ __clone()

ilShopNewsItemList::__clone ( )
private

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

26  {
27  }

◆ _getInstance()

ilShopNewsItemList::_getInstance ( )

Definition at line 59 of file class.ilShopNewsItemList.php.

Referenced by ilShopNewsGUI\showArchive(), and ilShopNewsGUI\showNews().

60  {
61  if(!isset(self::$instance))
62  {
63  self::$instance = new ilShopNewsItemList();
64  }
65 
66  return self::$instance;
67  }
+ Here is the caller graph for this function:

◆ current()

ilShopNewsItemList::current ( )

Definition at line 44 of file class.ilShopNewsItemList.php.

Referenced by valid().

45  {
46  return current($this->news);
47  }
+ Here is the caller graph for this function:

◆ getArchiveDate()

ilShopNewsItemList::getArchiveDate ( )

Definition at line 136 of file class.ilShopNewsItemList.php.

References $archive_date.

Referenced by read().

137  {
138  return $this->archive_date;
139  }
+ Here is the caller graph for this function:

◆ getMode()

ilShopNewsItemList::getMode ( )

Definition at line 156 of file class.ilShopNewsItemList.php.

References $mode.

Referenced by read().

157  {
158  return $this->mode;
159  }
+ Here is the caller graph for this function:

◆ hasItems()

ilShopNewsItemList::hasItems ( )

Definition at line 29 of file class.ilShopNewsItemList.php.

30  {
31  return (bool)count($this->news);
32  }

◆ isPublicSection()

ilShopNewsItemList::isPublicSection ( )

Definition at line 146 of file class.ilShopNewsItemList.php.

References $public_section.

Referenced by read().

147  {
148  return $this->public_section;
149  }
+ Here is the caller graph for this function:

◆ key()

ilShopNewsItemList::key ( )

Definition at line 49 of file class.ilShopNewsItemList.php.

50  {
51  return key($this->news);
52  }

◆ next()

ilShopNewsItemList::next ( )

Definition at line 54 of file class.ilShopNewsItemList.php.

55  {
56  return next($this->news);
57  }

◆ read()

ilShopNewsItemList::read ( )

Definition at line 69 of file class.ilShopNewsItemList.php.

References $data, $query, $result, getArchiveDate(), getMode(), and isPublicSection().

Referenced by reload().

70  {
71  global $ilDB;
72 
73  $this->news = array();
74 
75  $types = array();
76  $data = array();
77 
78  $query = 'SELECT * FROM payment_news WHERE 1 = 1 ';
79  if($this->isPublicSection())
80  {
81  $query .= "AND visibility = %s ";
82  $types[] = 'text';
83  $data[] = 'public';
84  }
85  if($this->getArchiveDate() !== null && $this->getArchiveDate() > 0)
86  {
87  switch($this->getMode())
88  {
89  case self::TYPE_NEWS:
90  $query .= "AND creation_date >= %s ";
91  $types[] = 'timestamp';
92  $data[] = date('Y-m-d H:i:s', $this->getArchiveDate());
93  break;
94 
95  case self::TYPE_ARCHIVE:
96  $query .= "AND creation_date < %s ";
97  $types[] = 'timestamp';
98  $data[] = date('Y-m-d H:i:s', $this->getArchiveDate());
99  break;
100  }
101  }
102  $query .= 'ORDER BY update_date DESC ';
103 
104  $result = $ilDB->queryF($query, $types, $data);
105 
106  while($record = $ilDB->fetchAssoc($result))
107  {
108  $oNewsItem = new ilShopNewsItem();
109  $oNewsItem->setId($record['news_id']);
110  $oNewsItem->setCreationDate($record['creation_date']);
111  $oNewsItem->setUpdateDate($record['update_date']);
112  $oNewsItem->setTitle($record['news_title']);
113  $oNewsItem->setContent($record['news_content']);
114  $oNewsItem->setVisibility($record['visibility']);
115  $oNewsItem->setUserId($record['user_id']);
116 
117  $this->news[] = $oNewsItem;
118  }
119 
120  return $this;
121  }
$result
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reload()

ilShopNewsItemList::reload ( )

Definition at line 123 of file class.ilShopNewsItemList.php.

References read().

124  {
125  $this->read();
126 
127  return $this;
128  }
+ Here is the call graph for this function:

◆ rewind()

ilShopNewsItemList::rewind ( )

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

35  {
36  return reset($this->news);
37  }

◆ setArchiveDate()

ilShopNewsItemList::setArchiveDate (   $a_archive_date)

Definition at line 130 of file class.ilShopNewsItemList.php.

131  {
132  $this->archive_date = $a_archive_date;
133 
134  return $this;
135  }

◆ setMode()

ilShopNewsItemList::setMode (   $a_mode)

Definition at line 150 of file class.ilShopNewsItemList.php.

151  {
152  $this->mode = $a_mode;
153 
154  return $this;
155  }

◆ setPublicSection()

ilShopNewsItemList::setPublicSection (   $a_public_section)

Definition at line 140 of file class.ilShopNewsItemList.php.

141  {
142  $this->public_section = $a_public_section;
143 
144  return $this;
145  }

◆ valid()

ilShopNewsItemList::valid ( )

Definition at line 39 of file class.ilShopNewsItemList.php.

References current().

40  {
41  return (bool)current($this->news);
42  }
+ Here is the call graph for this function:

Field Documentation

◆ $archive_date

ilShopNewsItemList::$archive_date = null
private

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

Referenced by getArchiveDate().

◆ $instance

ilShopNewsItemList::$instance = null
staticprivate

Definition at line 14 of file class.ilShopNewsItemList.php.

◆ $mode

ilShopNewsItemList::$mode = self::TYPE_NEWS
private

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

Referenced by getMode().

◆ $news

ilShopNewsItemList::$news = array()
private

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

◆ $public_section

ilShopNewsItemList::$public_section = false
private

Definition at line 19 of file class.ilShopNewsItemList.php.

Referenced by isPublicSection().

◆ TYPE_ARCHIVE

const ilShopNewsItemList::TYPE_ARCHIVE = 2

Definition at line 12 of file class.ilShopNewsItemList.php.

Referenced by ilShopNewsGUI\showArchive().

◆ TYPE_NEWS

const ilShopNewsItemList::TYPE_NEWS = 1

Definition at line 11 of file class.ilShopNewsItemList.php.

Referenced by ilShopNewsGUI\showNews().


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