ILIAS  trunk Revision v12.0_alpha-1541-g23eaa5e013d
ILIAS\COPage\History\HistoryRetrieval Class Reference
+ Inheritance diagram for ILIAS\COPage\History\HistoryRetrieval:
+ Collaboration diagram for ILIAS\COPage\History\HistoryRetrieval:

Public Member Functions

 __construct (HistoryDBRepository $history_repo, \ilDBInterface $db, int $page_id, string $parent_type, string $lang)
 
 getData (array $fields, ?Range $range=null, ?Order $order=null, array $filter=[], array $parameters=[])
 
 count (array $filter, array $parameters)
 
 isFieldNumeric (string $field)
 
 getData (array $fields, ?Range $range=null, ?Order $order=null, array $filter=[], array $parameters=[])
 
 count (array $filter, array $parameters)
 
 isFieldNumeric (string $field)
 

Protected Attributes

HistoryDBRepository $history_repo
 
ilDBInterface $db
 
int $page_id
 
string $parent_type
 
string $lang
 

Detailed Description

Definition at line 28 of file class.HistoryRetrieval.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\COPage\History\HistoryRetrieval::__construct ( HistoryDBRepository  $history_repo,
\ilDBInterface  $db,
int  $page_id,
string  $parent_type,
string  $lang 
)

Member Function Documentation

◆ count()

ILIAS\COPage\History\HistoryRetrieval::count ( array  $filter,
array  $parameters 
)

Implements ILIAS\Repository\RetrievalInterface.

Definition at line 102 of file class.HistoryRetrieval.php.

105 : int {
106 $q = "SELECT count(*) cnt FROM page_history WHERE page_id = %s" .
107 " AND parent_type = %s" .
108 " AND lang = %s";
109 $res = $this->db->queryF($q, ["integer", "text", "text"], [$this->page_id, $this->parent_type, $this->lang]);
110 $row = $this->db->fetchAssoc($res);
111 return (int) $row["cnt"] + 1;
112 }
$res
Definition: ltiservices.php:69
$q
Definition: shib_logout.php:25

◆ getData()

ILIAS\COPage\History\HistoryRetrieval::getData ( array  $fields,
?Range  $range = null,
?Order  $order = null,
array  $filter = [],
array  $parameters = [] 
)

Implements ILIAS\Repository\RetrievalInterface.

Definition at line 52 of file class.HistoryRetrieval.php.

58 : \Generator {
59 $rows = [];
60
61 // Current version (nr=0)
62 $q = "SELECT page_id, last_change hdate, parent_type, parent_id, last_change_user user_id, content, lang " .
63 "FROM page_object WHERE page_id = %s" .
64 " AND parent_type = %s" .
65 " AND lang = %s";
66 $res = $this->db->queryF($q, ["integer", "text", "text"], [$this->page_id, $this->parent_type, $this->lang]);
67 if ($row = $this->db->fetchAssoc($res)) {
68 $row["nr"] = 0;
69 $row["sortkey"] = 999999999;
70 $row["user"] = (int) $row["user_id"];
71 $row["id"] = "0";
72 $rows[] = $row;
73 }
74
75 // History entries
76 $q = "SELECT * FROM page_history WHERE page_id = %s" .
77 " AND parent_type = %s" .
78 " AND lang = %s";
79
80 $res = $this->db->queryF($q, ["integer", "text", "text"], [$this->page_id, $this->parent_type, $this->lang]);
81 while ($row = $this->db->fetchAssoc($res)) {
82 $row["sortkey"] = (int) $row["nr"];
83 $row["user"] = (int) $row["user_id"];
84 $row["id"] = (string) $row["nr"];
85 $rows[] = $row;
86 }
87
88 array_multisort(
89 array_column($rows, "sortkey"),
90 SORT_DESC,
91 SORT_NUMERIC,
92 $rows
93 );
94
95 $rows = $this->applyRange($rows, $range);
96
97 foreach ($rows as $row) {
98 yield $row;
99 }
100 }

References ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ isFieldNumeric()

ILIAS\COPage\History\HistoryRetrieval::isFieldNumeric ( string  $field)

Implements ILIAS\Repository\RetrievalInterface.

Definition at line 114 of file class.HistoryRetrieval.php.

116 : bool {
117 if ($field === "sortkey" || $field === "nr") {
118 return true;
119 }
120 return false;
121 }

Field Documentation

◆ $db

ilDBInterface ILIAS\COPage\History\HistoryRetrieval::$db
protected

◆ $history_repo

HistoryDBRepository ILIAS\COPage\History\HistoryRetrieval::$history_repo
protected

◆ $lang

string ILIAS\COPage\History\HistoryRetrieval::$lang
protected

◆ $page_id

int ILIAS\COPage\History\HistoryRetrieval::$page_id
protected

◆ $parent_type

string ILIAS\COPage\History\HistoryRetrieval::$parent_type
protected

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