ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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

return

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

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.

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

+ Here is the call graph for this function:

Member Function Documentation

◆ deliverFile()

ilWikiUserHTMLExport::deliverFile ( )

Deliver file.

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

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

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

+ Here is the call graph for this function:

◆ getProcess()

ilWikiUserHTMLExport::getProcess ( )
protected

Get process.

Parameters

return

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

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
92 $this->log->debug("atom query start");
93
94 $this->read();
95 $ts = ilUtil::now();
96
97 if ($this->data["start_ts"] != "" &&
98 $this->data["start_ts"] > $last_change)
99 {
101 $this->log->debug("return: ".self::PROCESS_UPTODATE);
102 return;
103 }
104
105 if (!isset($this->data["wiki_id"]))
106 {
107 $this->log->debug("insert, wiki id: ".$this->wiki->getId().", user id: ".$this->user->getId().", ts: ".$ts);
108 $ilDB->manipulate("INSERT INTO wiki_user_html_export ".
109 "(wiki_id, usr_id, progress, start_ts, status) VALUES (".
110 $ilDB->quote($this->wiki->getId(), "integer").",".
111 $ilDB->quote($this->user->getId(), "integer").",".
112 $ilDB->quote(0, "integer").",".
113 $ilDB->quote($ts, "timestamp").",".
114 $ilDB->quote(self::RUNNING, "integer").
115 ")");
116 }
117 else
118 {
119 $this->log->debug("update, wiki id: ".$this->wiki->getId().", user id: ".$this->user->getId().", ts: ".$ts);
120 $ilDB->manipulate("UPDATE wiki_user_html_export SET ".
121 " start_ts = ".$ilDB->quote($ts, "timestamp").",".
122 " usr_id = ".$ilDB->quote($this->user->getId(), "integer").",".
123 " progress = ".$ilDB->quote(0, "integer").",".
124 " status = ".$ilDB->quote(self::RUNNING, "integer").
125 " WHERE status = ".$ilDB->quote(self::NOT_RUNNING, "integer").
126 " AND wiki_id = ".$ilDB->quote($this->wiki->getId(), "integer")
127 );
128 $this->read();
129 }
130
131 if ($this->data["start_ts"] == $ts && $this->data["usr_id"] == $this->user->getId())
132 {
133 // we started the process
135 $this->log->debug("return: ".self::PROCESS_STARTED);
136 return;
137 }
138
139 // process was already running
141 $this->log->debug("return: ".self::PROCESS_OTHER_USER);
142 });
143
144 $ilAtomQuery->run();
145
146 $this->log->debug("outer return: ".$ret);
147
148 return $ret;
149 }
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.
Interface ilDBInterface.
$ret
Definition: parser.php:6
global $ilDB

References $ilDB, $ret, ilPageObject\getLastChangeByParent(), ilUtil\now(), PROCESS_OTHER_USER, PROCESS_STARTED, PROCESS_UPTODATE, read(), and user().

Referenced by initUserHTMLExport().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getProgress()

ilWikiUserHTMLExport::getProgress ( )

Get Progress.

Parameters

return

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

176 {
177 $set = $this->db->query("SELECT progress, status FROM wiki_user_html_export ".
178 " WHERE wiki_id = ".$this->db->quote($this->wiki->getId(), "integer")
179 );
180 $rec = $this->db->fetchAssoc($set);
181
182 return array("progress" => (int) $rec["progress"], "status" => (int) $rec["status"]);
183 }

◆ initUserHTMLExport()

ilWikiUserHTMLExport::initUserHTMLExport ( )

Init user html export.

Parameters

return

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

193 {
194 // get process, if not already running or export is up-to-date, return corresponding status
195 echo $this->getProcess();
196 exit;
197 }

References exit, and getProcess().

+ Here is the call graph for this function:

◆ read()

ilWikiUserHTMLExport::read ( )
protected

Read.

Parameters

return

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

66 {
67 $set = $this->db->query("SELECT * FROM wiki_user_html_export ".
68 " WHERE wiki_id = ".$this->db->quote($this->wiki->getId(), "integer")
69 );
70 if (!$this->data = $this->db->fetchAssoc($set))
71 {
72 $this->data = array();
73 }
74 }

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

+ Here is the caller graph for this function:

◆ startUserHTMLExport()

ilWikiUserHTMLExport::startUserHTMLExport ( )

Start user html export.

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

203 {
204 ignore_user_abort(true);
205 // do the export
206 include_once("./Modules/Wiki/classes/class.ilWikiHTMLExport.php");
207 $exp = new ilWikiHTMLExport($this->wiki);
208 $exp->setMode(ilWikiHTMLExport::MODE_USER);
209 $exp->buildExportFile();
210 // reset user export status
211 $this->updateStatus(100, self::NOT_RUNNING);
212 exit;
213 }
updateStatus($a_progress, $a_status)
Update status.

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

+ Here is the call graph for this function:

◆ updateStatus()

ilWikiUserHTMLExport::updateStatus (   $a_progress,
  $a_status 
)

Update status.

Parameters

return

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

158 {
159 $this->db->manipulate("UPDATE wiki_user_html_export SET ".
160 " progress = ".$this->db->quote((int) $a_progress, "integer").",".
161 " status = ".$this->db->quote((int) $a_status, "integer").
162 " WHERE wiki_id = ".$this->db->quote($this->wiki->getId(), "integer").
163 " AND usr_id = ".$this->db->quote($this->user->getId(), "integer")
164 );
165
166 $this->read();
167 }

References read().

Referenced by startUserHTMLExport().

+ 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.

Referenced by getProcess().

◆ PROCESS_STARTED

const ilWikiUserHTMLExport::PROCESS_STARTED = 1

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

Referenced by getProcess().

◆ PROCESS_UPTODATE

const ilWikiUserHTMLExport::PROCESS_UPTODATE = 2

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

Referenced by getProcess().

◆ RUNNING

const ilWikiUserHTMLExport::RUNNING = 1

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