ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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)
 Construct. More...
 
 updateStatus ($a_progress, $a_status)
 Update status. More...
 
 getProgress ()
 Get Progress. More...
 
 initUserHTMLExport ()
 Init user html export. More...
 
 startUserHTMLExport ()
 Start user html export. More...
 
 deliverFile ()
 Deliver file. More...
 

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 ()
 Read. More...
 
 getProcess ()
 Get process. More...
 

Protected Attributes

 $data
 
 $db
 
 $wiki
 
 $user
 
 $log
 

Detailed Description

Class manages user html export.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilWikiUserHTMLExport::__construct ( ilObjWiki  $a_wiki,
ilDBInterface  $a_db,
ilObjUser  $a_user 
)

Construct.

Parameters

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

References ilLoggerFactory\getLogger(), read(), and user().

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  }
user()
Definition: user.php:4
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

Member Function Documentation

◆ deliverFile()

ilWikiUserHTMLExport::deliverFile ( )

Deliver file.

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

References $file, ilUtil\deliverFile(), and ilWikiHTMLExport\MODE_USER.

216  {
217  $this->log->debug("deliver");
218  include_once("./Modules/Wiki/classes/class.ilWikiHTMLExport.php");
219  $exp = new ilWikiHTMLExport($this->wiki);
220  $exp->setMode(ilWikiHTMLExport::MODE_USER);
221  $file = $exp->getUserExportFile();
222  $this->log->debug("file: " . $file);
223  ilUtil::deliverFile($file, pathinfo($file, PATHINFO_BASENAME));
224  }
Wiki HTML exporter class.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
+ Here is the call graph for this function:

◆ getProcess()

ilWikiUserHTMLExport::getProcess ( )
protected

Get process.

Parameters

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

References $ilDB, $ret, data, ilPageObject\getLastChangeByParent(), ilDBInterface\manipulate(), ilUtil\now(), ilDBInterface\quote(), read(), and user().

Referenced by initUserHTMLExport().

83  {
84  $this->log->debug("getProcess");
85  $last_change = ilPageObject::getLastChangeByParent("wpg", $this->wiki->getId());
86 
87  $ilAtomQuery = $this->db->buildAtomQuery();
88  $ilAtomQuery->addTableLock('wiki_user_html_export');
89 
90  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDB) use ($last_change, &$ret) {
91  $this->log->debug("atom query start");
92 
93  $this->read();
94  $ts = ilUtil::now();
95 
96  if ($this->data["start_ts"] != "" &&
97  $this->data["start_ts"] > $last_change) {
98  $ret = self::PROCESS_UPTODATE;
99  $this->log->debug("return: " . self::PROCESS_UPTODATE);
100  return;
101  }
102 
103  if (!isset($this->data["wiki_id"])) {
104  $this->log->debug("insert, wiki id: " . $this->wiki->getId() . ", user id: " . $this->user->getId() . ", ts: " . $ts);
105  $ilDB->manipulate("INSERT INTO wiki_user_html_export " .
106  "(wiki_id, usr_id, progress, start_ts, status) VALUES (" .
107  $ilDB->quote($this->wiki->getId(), "integer") . "," .
108  $ilDB->quote($this->user->getId(), "integer") . "," .
109  $ilDB->quote(0, "integer") . "," .
110  $ilDB->quote($ts, "timestamp") . "," .
111  $ilDB->quote(self::RUNNING, "integer") .
112  ")");
113  } else {
114  $this->log->debug("update, wiki id: " . $this->wiki->getId() . ", user id: " . $this->user->getId() . ", ts: " . $ts);
115  $ilDB->manipulate(
116  "UPDATE wiki_user_html_export SET " .
117  " start_ts = " . $ilDB->quote($ts, "timestamp") . "," .
118  " usr_id = " . $ilDB->quote($this->user->getId(), "integer") . "," .
119  " progress = " . $ilDB->quote(0, "integer") . "," .
120  " status = " . $ilDB->quote(self::RUNNING, "integer") .
121  " WHERE status = " . $ilDB->quote(self::NOT_RUNNING, "integer") .
122  " AND wiki_id = " . $ilDB->quote($this->wiki->getId(), "integer")
123  );
124  $this->read();
125  }
126 
127  if ($this->data["start_ts"] == $ts && $this->data["usr_id"] == $this->user->getId()) {
128  // we started the process
129  $ret = self::PROCESS_STARTED;
130  $this->log->debug("return: " . self::PROCESS_STARTED);
131  return;
132  }
133 
134  // process was already running
135  $ret = self::PROCESS_OTHER_USER;
136  $this->log->debug("return: " . self::PROCESS_OTHER_USER);
137  });
138 
139  $ilAtomQuery->run();
140 
141  $this->log->debug("outer return: " . $ret);
142 
143  return $ret;
144  }
Add some data
static getLastChangeByParent($a_parent_type, $a_parent_id, $a_lang="")
Get all pages for parent object.
static now()
Return current timestamp in Y-m-d H:i:s format.
user()
Definition: user.php:4
Interface ilDBInterface.
quote($value, $type)
global $ilDB
$ret
Definition: parser.php:6
manipulate($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 ( )

Get Progress.

Parameters

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

References array.

172  {
173  $set = $this->db->query(
174  "SELECT progress, status FROM wiki_user_html_export " .
175  " WHERE wiki_id = " . $this->db->quote($this->wiki->getId(), "integer")
176  );
177  $rec = $this->db->fetchAssoc($set);
178 
179  return array("progress" => (int) $rec["progress"], "status" => (int) $rec["status"]);
180  }
Create styles array
The data for the language used.

◆ initUserHTMLExport()

ilWikiUserHTMLExport::initUserHTMLExport ( )

Init user html export.

Parameters

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

References exit, and getProcess().

190  {
191  // get process, if not already running or export is up-to-date, return corresponding status
192  echo $this->getProcess();
193  exit;
194  }
+ Here is the call graph for this function:

◆ read()

ilWikiUserHTMLExport::read ( )
protected

Read.

Parameters

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

References array, and data.

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

66  {
67  $set = $this->db->query(
68  "SELECT * FROM wiki_user_html_export " .
69  " WHERE wiki_id = " . $this->db->quote($this->wiki->getId(), "integer")
70  );
71  if (!$this->data = $this->db->fetchAssoc($set)) {
72  $this->data = array();
73  }
74  }
Add some data
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ startUserHTMLExport()

ilWikiUserHTMLExport::startUserHTMLExport ( )

Start user html export.

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

References exit, ilWikiHTMLExport\MODE_USER, and updateStatus().

200  {
201  ignore_user_abort(true);
202  // do the export
203  include_once("./Modules/Wiki/classes/class.ilWikiHTMLExport.php");
204  $exp = new ilWikiHTMLExport($this->wiki);
205  $exp->setMode(ilWikiHTMLExport::MODE_USER);
206  $exp->buildExportFile();
207  // reset user export status
208  $this->updateStatus(100, self::NOT_RUNNING);
209  exit;
210  }
updateStatus($a_progress, $a_status)
Update status.
Wiki HTML exporter class.
+ Here is the call graph for this function:

◆ updateStatus()

ilWikiUserHTMLExport::updateStatus (   $a_progress,
  $a_status 
)

Update status.

Parameters

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

References read().

Referenced by startUserHTMLExport().

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

Field Documentation

◆ $data

ilWikiUserHTMLExport::$data
protected

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

◆ $db

ilWikiUserHTMLExport::$db
protected

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

◆ $log

ilWikiUserHTMLExport::$log
protected

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

◆ $user

ilWikiUserHTMLExport::$user
protected

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

◆ $wiki

ilWikiUserHTMLExport::$wiki
protected

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

◆ NOT_RUNNING

const ilWikiUserHTMLExport::NOT_RUNNING = 0

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

◆ PROCESS_OTHER_USER

const ilWikiUserHTMLExport::PROCESS_OTHER_USER = 0

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

◆ PROCESS_STARTED

const ilWikiUserHTMLExport::PROCESS_STARTED = 1

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

◆ PROCESS_UPTODATE

const ilWikiUserHTMLExport::PROCESS_UPTODATE = 2

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

◆ RUNNING

const ilWikiUserHTMLExport::RUNNING = 1

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