ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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

ilShopTopics::__construct ( )
private

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

References $ilDB.

{
global $ilDB;
$this->db = $ilDB;
}

Member Function Documentation

static ilShopTopics::_getInstance ( )
static
ilShopTopics::enableCustomSorting (   $a_enable_custom_sorting)

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

{
$this->enable_custom_sorting = (bool)$a_enable_custom_sorting;
}
ilShopTopics::getIdFilter ( )

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

References $id_filter.

Referenced by read().

{
}

+ Here is the caller graph for this function:

ilShopTopics::getSortingDirection ( )

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

References $sorting_direction.

Referenced by read().

+ Here is the caller graph for this function:

ilShopTopics::getSortingType ( )

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

References $sorting_type.

Referenced by read().

{
}

+ Here is the caller graph for this function:

ilShopTopics::getTopics ( )

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

{
return is_array($this->topics) ? $this->topics : array();
}
ilShopTopics::isCustomSortingEnabled ( )

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

References $enable_custom_sorting.

Referenced by read().

{
}

+ Here is the caller graph for this function:

ilShopTopics::read ( )

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

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

{
global $ilUser;
$oSettings = new ilGeneralSettings();
$this->topics = array();
if(!in_array($this->getSortingType(), array(self::TOPICS_SORT_BY_TITLE, self::TOPICS_SORT_BY_CREATEDATE, self::TOPICS_SORT_MANUALLY)))
{
$this->setSortingType(self::DEFAULT_SORTING_TYPE);
}
if(!in_array(strtoupper($this->getSortingDirection()), array('ASC', 'DESC')))
{
$this->setSortingDirection(self::DEFAULT_SORTING_DIRECTION);
}
if(!$this->isCustomSortingEnabled())
{
$data_types = array();
$data_values = array();
$query = 'SELECT * FROM payment_topics WHERE 1 = 1 ';
if((int)$this->getIdFilter() > 0)
{
$query .= ' AND pt_topic_pk = %s';
array_push($data_types, 'integer');
array_push($data_values, $this->getIdFilter());
}
switch($this->getSortingType())
{
case 3:
$query .= ' ORDER BY pt_topic_sort ';
break;
case 2:
$query .= ' ORDER BY pt_topic_created ';
break;
case 1:
default:
$query .= ' ORDER BY pt_topic_title ';
break;
}
$query .= ' '.strtoupper($this->getSortingDirection()).' ';
$query .= " , pt_topic_title ";
$query .= ' '.strtoupper($this->getSortingDirection()).' ';
}
else
{
$data_types = array();
$data_values = array();
$query = 'SELECT * FROM payment_topics ';
switch($this->getSortingType())
{
case 3:
$query .= ' LEFT JOIN payment_topic_usr_sort ON
ptus_pt_topic_fk = pt_topic_pk AND
ptus_usr_id = %s';
array_push($data_types, 'integer');
array_push($data_values, $ilUser->getId());
break;
}
$query .= ' WHERE 1 = 1 ';
if((int)$this->id_filter > 0)
{
$query .= ' AND pt_topic_pk = %s';
array_push($data_types, 'integer');
array_push($data_values, $this->getIdFilter());
}
switch($this->getSortingType())
{
case 3:
$query .= ' ORDER BY ptus_sorting ';
break;
case 2:
$query .= ' ORDER BY pt_topic_created ';
break;
case 1:
default:
$query .= ' ORDER BY pt_topic_title ';
break;
}
$query .= ' '.strtoupper($this->getSortingDirection()).' ';
$query .= " , pt_topic_sort ";
$query .= ' '.strtoupper($this->getSortingDirection()).' ';
}
if(count($data_types) > 0 && count($data_values > 0))
{
$res = $this->db->queryf($query, $data_types, $data_values);
}
else
{
$res = $this->db->query($query);
}
$counter = 0;
while($row = $this->db->fetchObject($res))
{
$oTopic = new ilShopTopic();
$oTopic->setId($row->pt_topic_pk);
$oTopic->setTitle($row->pt_topic_title);
$oTopic->setSorting($row->pt_topic_sort);
$oTopic->setCustomSorting((int)$row->ptus_sorting);
$oTopic->setCreateDate($row->pt_topic_created);
$oTopic->setChangeDate($row->pt_topic_changed);
$this->topics[$row->pt_topic_pk] = $oTopic;
++$counter;
}
return $this;
}

+ Here is the call graph for this function:

ilShopTopics::setIdFilter (   $a_id_filter)

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

{
$this->id_filter = $a_id_filter;
}
ilShopTopics::setSortingDirection (   $a_sorting_direction)

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

Referenced by read().

{
$this->sorting_direction = $a_sorting_direction;
}

+ Here is the caller graph for this function:

ilShopTopics::setSortingType (   $a_sorting_type)

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

Referenced by read().

{
$this->sorting_type = $a_sorting_type;
}

+ Here is the caller graph for this function:

Field Documentation

ilShopTopics::$db = null
private

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

ilShopTopics::$enable_custom_sorting = false
private

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

Referenced by isCustomSortingEnabled().

ilShopTopics::$id_filter = 0
private

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

Referenced by getIdFilter().

ilShopTopics::$instance
staticprivate

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

Referenced by _getInstance().

ilShopTopics::$sorting_direction = 'ASC'
private

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

Referenced by getSortingDirection().

ilShopTopics::$sorting_type = self::TOPICS_SORT_BY_TITLE
private

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

Referenced by getSortingType().

ilShopTopics::$topics = array()
private

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

const ilShopTopics::DEFAULT_SORTING_DIRECTION = 'ASC'

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

Referenced by ilShopAdvancedSearchGUI\showForm().

const ilShopTopics::DEFAULT_SORTING_TYPE = self::TOPICS_SORT_BY_TITLE

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

const ilShopTopics::TOPICS_SORT_BY_CREATEDATE = 2

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