ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilWikiUserHTMLExport Class Reference

Class manages user html export. More...

+ Collaboration diagram for ilWikiUserHTMLExport:

Public Member Functions

 __construct (ilObjWiki $a_wiki, ilDBInterface $a_db, ilObjUser $a_user, bool $with_comments=false)
 
 updateStatus (int $a_progress, int $a_status)
 
 getProgress ()
 
 initUserHTMLExport ()
 
 startUserHTMLExport ()
 
 deliverFile ()
 

Data Fields

const PROCESS_OTHER_USER = 0
 
const PROCESS_STARTED = 1
 
const PROCESS_UPTODATE = 2
 
const NOT_RUNNING = 0
 
const RUNNING = 1
 

Protected Member Functions

 read ()
 
 getProcess ()
 
 getLatest ()
 

Protected Attributes

ILIAS components Export HTML ExportFileManager $html_export_file_manager
 
array $data = null
 
ilDBInterface $db
 
ilObjWiki $wiki
 
ilObjUser $user
 
ilLogger $log
 
bool $with_comments = false
 

Detailed Description

Class manages user html export.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 27 of file class.ilWikiUserHTMLExport.php.

Constructor & Destructor Documentation

◆ __construct()

ilWikiUserHTMLExport::__construct ( ilObjWiki  $a_wiki,
ilDBInterface  $a_db,
ilObjUser  $a_user,
bool  $with_comments = false 
)

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

References $DIC, $with_comments, ilLoggerFactory\getLogger(), read(), and ILIAS\Repository\user().

49  {
50  global $DIC;
51 
52  $this->db = $a_db;
53  $this->wiki = $a_wiki;
54  $this->user = $a_user;
55  $this->read();
56  $this->log = ilLoggerFactory::getLogger('wiki');
57  $this->with_comments = $with_comments;
58  $this->log->debug("comments: " . $this->with_comments);
59  $this->html_export_file_manager = $DIC->export()->domain()->html()->fileManager();
60  }
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:

Member Function Documentation

◆ deliverFile()

ilWikiUserHTMLExport::deliverFile ( )

Definition at line 207 of file class.ilWikiUserHTMLExport.php.

207  : void
208  {
209  $this->log->debug("deliver");
210 
211  $exp = new WikiHtmlExport($this->wiki);
212  if ($this->with_comments) {
213  $exp->setMode(WikiHtmlExport::MODE_USER_COMMENTS);
214  } else {
215  $exp->setMode(WikiHtmlExport::MODE_USER);
216  }
217  $exp->deliverLatest();
218  }
Wiki HTML exporter class.

◆ getLatest()

ilWikiUserHTMLExport::getLatest ( )
protected

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

Referenced by getProcess().

196  : ?ExportFile
197  {
198  $exp = new WikiHtmlExport($this->wiki);
199  if ($this->with_comments) {
200  $exp->setMode(WikiHtmlExport::MODE_USER_COMMENTS);
201  } else {
202  $exp->setMode(WikiHtmlExport::MODE_USER);
203  }
204  return $exp->getLatest();
205  }
Wiki HTML exporter class.
+ Here is the caller graph for this function:

◆ getProcess()

ilWikiUserHTMLExport::getProcess ( )
protected

Definition at line 74 of file class.ilWikiUserHTMLExport.php.

References $ilDB, $with_comments, ilPageObject\getLastChangeByParent(), getLatest(), ilDBInterface\manipulate(), ilUtil\now(), ilDBInterface\quote(), read(), and ILIAS\Repository\user().

Referenced by initUserHTMLExport().

74  : int
75  {
76  $this->log->debug("getProcess");
77  $last_change = ilPageObject::getLastChangeByParent("wpg", $this->wiki->getId());
78  $latest = $this->getLatest();
79 
80  $ilAtomQuery = $this->db->buildAtomQuery();
81  $ilAtomQuery->addTableLock('wiki_user_html_export');
82 
83  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDB) use ($last_change, &$ret, $latest) {
84  $this->log->debug("atom query start");
85 
86  $this->read();
87  $ts = ilUtil::now();
88 
89  if (($this->data["start_ts"] ?? "") != "" &&
90  $this->data["start_ts"] > $last_change) {
91  if ($latest) {
92  $ret = self::PROCESS_UPTODATE;
93  $this->log->debug("return: " . self::PROCESS_UPTODATE);
94  return;
95  }
96  }
97 
98  if (!isset($this->data["wiki_id"])) {
99  $this->log->debug("insert, wiki id: " . $this->wiki->getId() . ", user id: " . $this->user->getId() .
100  ", ts: " . $ts . ", with_comments: " . $this->with_comments);
101  $ilDB->manipulate("INSERT INTO wiki_user_html_export " .
102  "(wiki_id, usr_id, progress, start_ts, status, with_comments) VALUES (" .
103  $ilDB->quote($this->wiki->getId(), "integer") . "," .
104  $ilDB->quote($this->user->getId(), "integer") . "," .
105  $ilDB->quote(0, "integer") . "," .
106  $ilDB->quote($ts, "timestamp") . "," .
107  $ilDB->quote(self::RUNNING, "integer") . "," .
108  $ilDB->quote($this->with_comments, "integer") .
109  ")");
110  } else {
111  $this->log->debug("update, wiki id: " . $this->wiki->getId() . ", user id: " . $this->user->getId() .
112  ", ts: " . $ts . ", with_comments: " . $this->with_comments);
113  $ilDB->manipulate(
114  "UPDATE wiki_user_html_export SET " .
115  " start_ts = " . $ilDB->quote($ts, "timestamp") . "," .
116  " usr_id = " . $ilDB->quote($this->user->getId(), "integer") . "," .
117  " progress = " . $ilDB->quote(0, "integer") . "," .
118  " status = " . $ilDB->quote(self::RUNNING, "integer") .
119  " WHERE status = " . $ilDB->quote(self::NOT_RUNNING, "integer") .
120  " AND wiki_id = " . $ilDB->quote($this->wiki->getId(), "integer") .
121  " AND with_comments = " . $ilDB->quote($this->with_comments, "integer")
122  );
123  $this->read();
124  }
125 
126  if (($this->data["start_ts"] ?? "") == $ts && $this->data["usr_id"] == $this->user->getId()) {
127  // we started the process
128  $ret = self::PROCESS_STARTED;
129  $this->log->debug("return: " . self::PROCESS_STARTED);
130  return;
131  }
132 
133  // process was already running
134  $ret = self::PROCESS_OTHER_USER;
135  $this->log->debug("return: " . self::PROCESS_OTHER_USER);
136  });
137 
138  $ilAtomQuery->run();
139 
140  $this->log->debug("outer return: " . $ret);
141 
142  return $ret;
143  }
quote($value, string $type)
static now()
Return current timestamp in Y-m-d H:i:s format.
static getLastChangeByParent(string $a_parent_type, int $a_parent_id, string $a_lang="")
Get all pages for parent object.
manipulate(string $query)
Run a (write) Query on the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getProgress()

ilWikiUserHTMLExport::getProgress ( )

Definition at line 161 of file class.ilWikiUserHTMLExport.php.

161  : array
162  {
163  $set = $this->db->query(
164  "SELECT progress, status FROM wiki_user_html_export " .
165  " WHERE wiki_id = " . $this->db->quote($this->wiki->getId(), "integer") .
166  " AND with_comments = " . $this->db->quote($this->with_comments, "integer")
167  );
168  $rec = $this->db->fetchAssoc($set);
169 
170  return array("progress" => (int) $rec["progress"], "status" => (int) $rec["status"]);
171  }

◆ initUserHTMLExport()

ilWikiUserHTMLExport::initUserHTMLExport ( )

Definition at line 173 of file class.ilWikiUserHTMLExport.php.

References exit, and getProcess().

173  : void
174  {
175  // get process, if not already running or export is up-to-date, return corresponding status
176  echo $this->getProcess();
177  exit;
178  }
exit
+ Here is the call graph for this function:

◆ read()

ilWikiUserHTMLExport::read ( )
protected

Definition at line 62 of file class.ilWikiUserHTMLExport.php.

Referenced by __construct(), getProcess(), and updateStatus().

62  : void
63  {
64  $set = $this->db->query(
65  "SELECT * FROM wiki_user_html_export " .
66  " WHERE wiki_id = " . $this->db->quote($this->wiki->getId(), "integer") .
67  " AND with_comments = " . $this->db->quote($this->with_comments, "integer")
68  );
69  if (!$this->data = $this->db->fetchAssoc($set)) {
70  $this->data = array();
71  }
72  }
+ Here is the caller graph for this function:

◆ startUserHTMLExport()

ilWikiUserHTMLExport::startUserHTMLExport ( )

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

References exit, and updateStatus().

180  : void
181  {
182  ignore_user_abort(true);
183  // do the export
184  $exp = new WikiHtmlExport($this->wiki);
185  if (!$this->with_comments) {
186  $exp->setMode(WikiHtmlExport::MODE_USER);
187  } else {
188  $exp->setMode(WikiHtmlExport::MODE_USER_COMMENTS);
189  }
190  $exp = $exp->buildExportFile();
191  // reset user export status
192  $this->updateStatus(100, self::NOT_RUNNING);
193  exit;
194  }
Wiki HTML exporter class.
exit
updateStatus(int $a_progress, int $a_status)
+ Here is the call graph for this function:

◆ updateStatus()

ilWikiUserHTMLExport::updateStatus ( int  $a_progress,
int  $a_status 
)

Definition at line 145 of file class.ilWikiUserHTMLExport.php.

References read().

Referenced by startUserHTMLExport().

148  : void {
149  $this->db->manipulate(
150  "UPDATE wiki_user_html_export SET " .
151  " progress = " . $this->db->quote($a_progress, "integer") . "," .
152  " status = " . $this->db->quote($a_status, "integer") .
153  " WHERE wiki_id = " . $this->db->quote($this->wiki->getId(), "integer") .
154  " AND usr_id = " . $this->db->quote($this->user->getId(), "integer") .
155  " AND with_comments = " . $this->db->quote($this->with_comments, "integer")
156  );
157 
158  $this->read();
159  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $data

array ilWikiUserHTMLExport::$data = null
protected

Definition at line 37 of file class.ilWikiUserHTMLExport.php.

◆ $db

ilDBInterface ilWikiUserHTMLExport::$db
protected

Definition at line 38 of file class.ilWikiUserHTMLExport.php.

◆ $html_export_file_manager

ILIAS components Export HTML ExportFileManager ilWikiUserHTMLExport::$html_export_file_manager
protected

Definition at line 35 of file class.ilWikiUserHTMLExport.php.

◆ $log

ilLogger ilWikiUserHTMLExport::$log
protected

Definition at line 41 of file class.ilWikiUserHTMLExport.php.

◆ $user

ilObjUser ilWikiUserHTMLExport::$user
protected

Definition at line 40 of file class.ilWikiUserHTMLExport.php.

◆ $wiki

ilObjWiki ilWikiUserHTMLExport::$wiki
protected

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

◆ $with_comments

bool ilWikiUserHTMLExport::$with_comments = false
protected

Definition at line 42 of file class.ilWikiUserHTMLExport.php.

Referenced by __construct(), and getProcess().

◆ NOT_RUNNING

const ilWikiUserHTMLExport::NOT_RUNNING = 0

Definition at line 33 of file class.ilWikiUserHTMLExport.php.

◆ PROCESS_OTHER_USER

const ilWikiUserHTMLExport::PROCESS_OTHER_USER = 0

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

◆ PROCESS_STARTED

const ilWikiUserHTMLExport::PROCESS_STARTED = 1

Definition at line 30 of file class.ilWikiUserHTMLExport.php.

◆ PROCESS_UPTODATE

const ilWikiUserHTMLExport::PROCESS_UPTODATE = 2

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

◆ RUNNING


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