ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 ()
 
 doesFileExist ()
 

Protected Attributes

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 26 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 42 of file class.ilWikiUserHTMLExport.php.

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

47  {
48  $this->db = $a_db;
49  $this->wiki = $a_wiki;
50  $this->user = $a_user;
51  $this->read();
52  $this->log = ilLoggerFactory::getLogger('wiki');
53  $this->with_comments = $with_comments;
54  $this->log->debug("comments: " . $this->with_comments);
55  }
static getLogger(string $a_component_id)
Get component logger.
+ Here is the call graph for this function:

Member Function Documentation

◆ deliverFile()

ilWikiUserHTMLExport::deliverFile ( )

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

References ilFileDelivery\deliverFileLegacy().

203  : void
204  {
205  $this->log->debug("deliver");
206 
207  $exp = new WikiHtmlExport($this->wiki);
208  if ($this->with_comments) {
209  $exp->setMode(WikiHtmlExport::MODE_USER_COMMENTS);
210  } else {
211  $exp->setMode(WikiHtmlExport::MODE_USER);
212  }
213  $file = $exp->getUserExportFile();
214  $this->log->debug("file: " . $file);
215  ilFileDelivery::deliverFileLegacy($file, pathinfo($file, PATHINFO_BASENAME));
216  }
Wiki HTML exporter class.
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
+ Here is the call graph for this function:

◆ doesFileExist()

ilWikiUserHTMLExport::doesFileExist ( )
protected

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

Referenced by getProcess().

191  : bool
192  {
193  $exp = new WikiHtmlExport($this->wiki);
194  if ($this->with_comments) {
195  $exp->setMode(WikiHtmlExport::MODE_USER_COMMENTS);
196  } else {
197  $exp->setMode(WikiHtmlExport::MODE_USER);
198  }
199  $file = $exp->getUserExportFile();
200  return is_file($file);
201  }
Wiki HTML exporter class.
+ Here is the caller graph for this function:

◆ getProcess()

ilWikiUserHTMLExport::getProcess ( )
protected

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

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

Referenced by initUserHTMLExport().

69  : int
70  {
71  $this->log->debug("getProcess");
72  $last_change = ilPageObject::getLastChangeByParent("wpg", $this->wiki->getId());
73  $file_exists = $this->doesFileExist();
74 
75  $ilAtomQuery = $this->db->buildAtomQuery();
76  $ilAtomQuery->addTableLock('wiki_user_html_export');
77 
78  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDB) use ($last_change, &$ret, $file_exists) {
79  $this->log->debug("atom query start");
80 
81  $this->read();
82  $ts = ilUtil::now();
83 
84  if (($this->data["start_ts"] ?? "") != "" &&
85  $this->data["start_ts"] > $last_change) {
86  if ($file_exists) {
87  $ret = self::PROCESS_UPTODATE;
88  $this->log->debug("return: " . self::PROCESS_UPTODATE);
89  return;
90  }
91  }
92 
93  if (!isset($this->data["wiki_id"])) {
94  $this->log->debug("insert, wiki id: " . $this->wiki->getId() . ", user id: " . $this->user->getId() .
95  ", ts: " . $ts . ", with_comments: " . $this->with_comments);
96  $ilDB->manipulate("INSERT INTO wiki_user_html_export " .
97  "(wiki_id, usr_id, progress, start_ts, status, with_comments) VALUES (" .
98  $ilDB->quote($this->wiki->getId(), "integer") . "," .
99  $ilDB->quote($this->user->getId(), "integer") . "," .
100  $ilDB->quote(0, "integer") . "," .
101  $ilDB->quote($ts, "timestamp") . "," .
102  $ilDB->quote(self::RUNNING, "integer") . "," .
103  $ilDB->quote($this->with_comments, "integer") .
104  ")");
105  } else {
106  $this->log->debug("update, wiki id: " . $this->wiki->getId() . ", user id: " . $this->user->getId() .
107  ", ts: " . $ts . ", with_comments: " . $this->with_comments);
108  $ilDB->manipulate(
109  "UPDATE wiki_user_html_export SET " .
110  " start_ts = " . $ilDB->quote($ts, "timestamp") . "," .
111  " usr_id = " . $ilDB->quote($this->user->getId(), "integer") . "," .
112  " progress = " . $ilDB->quote(0, "integer") . "," .
113  " status = " . $ilDB->quote(self::RUNNING, "integer") .
114  " WHERE status = " . $ilDB->quote(self::NOT_RUNNING, "integer") .
115  " AND wiki_id = " . $ilDB->quote($this->wiki->getId(), "integer") .
116  " AND with_comments = " . $ilDB->quote($this->with_comments, "integer")
117  );
118  $this->read();
119  }
120 
121  if (($this->data["start_ts"] ?? "") == $ts && $this->data["usr_id"] == $this->user->getId()) {
122  // we started the process
123  $ret = self::PROCESS_STARTED;
124  $this->log->debug("return: " . self::PROCESS_STARTED);
125  return;
126  }
127 
128  // process was already running
129  $ret = self::PROCESS_OTHER_USER;
130  $this->log->debug("return: " . self::PROCESS_OTHER_USER);
131  });
132 
133  $ilAtomQuery->run();
134 
135  $this->log->debug("outer return: " . $ret);
136 
137  return $ret;
138  }
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 156 of file class.ilWikiUserHTMLExport.php.

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

◆ initUserHTMLExport()

ilWikiUserHTMLExport::initUserHTMLExport ( )

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

References exit, and getProcess().

168  : void
169  {
170  // get process, if not already running or export is up-to-date, return corresponding status
171  echo $this->getProcess();
172  exit;
173  }
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ read()

ilWikiUserHTMLExport::read ( )
protected

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

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

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

◆ startUserHTMLExport()

ilWikiUserHTMLExport::startUserHTMLExport ( )

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

References exit, and updateStatus().

175  : void
176  {
177  ignore_user_abort(true);
178  // do the export
179  $exp = new WikiHtmlExport($this->wiki);
180  if (!$this->with_comments) {
181  $exp->setMode(WikiHtmlExport::MODE_USER);
182  } else {
183  $exp->setMode(WikiHtmlExport::MODE_USER_COMMENTS);
184  }
185  $exp->buildExportFile();
186  // reset user export status
187  $this->updateStatus(100, self::NOT_RUNNING);
188  exit;
189  }
Wiki HTML exporter class.
updateStatus(int $a_progress, int $a_status)
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ updateStatus()

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

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

References read().

Referenced by startUserHTMLExport().

143  : void {
144  $this->db->manipulate(
145  "UPDATE wiki_user_html_export SET " .
146  " progress = " . $this->db->quote($a_progress, "integer") . "," .
147  " status = " . $this->db->quote($a_status, "integer") .
148  " WHERE wiki_id = " . $this->db->quote($this->wiki->getId(), "integer") .
149  " AND usr_id = " . $this->db->quote($this->user->getId(), "integer") .
150  " AND with_comments = " . $this->db->quote($this->with_comments, "integer")
151  );
152 
153  $this->read();
154  }
+ 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 35 of file class.ilWikiUserHTMLExport.php.

◆ $db

ilDBInterface ilWikiUserHTMLExport::$db
protected

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

◆ $log

ilLogger ilWikiUserHTMLExport::$log
protected

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

◆ $user

ilObjUser ilWikiUserHTMLExport::$user
protected

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

◆ $wiki

ilObjWiki ilWikiUserHTMLExport::$wiki
protected

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

◆ $with_comments

bool ilWikiUserHTMLExport::$with_comments = false
protected

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

Referenced by __construct(), and getProcess().

◆ NOT_RUNNING

const ilWikiUserHTMLExport::NOT_RUNNING = 0

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

◆ PROCESS_OTHER_USER

const ilWikiUserHTMLExport::PROCESS_OTHER_USER = 0

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

◆ PROCESS_STARTED

const ilWikiUserHTMLExport::PROCESS_STARTED = 1

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

◆ PROCESS_UPTODATE

const ilWikiUserHTMLExport::PROCESS_UPTODATE = 2

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

◆ RUNNING


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