ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilBackgroundTaskJson Class Reference

Background task JSON helper. More...

+ Collaboration diagram for ilBackgroundTaskJson:

Static Public Member Functions

static getFailedJson ($a_message)
 Get json for failed task. More...
 
static getBlockedJson ($a_task_id)
 Get json for blocked task. More...
 
static getProcessingJson ($a_task_id, $a_message, $a_steps)
 Get json for processing task. More...
 
static getProgressJson (ilBackgroundTask $a_task, $a_finished_cmd=null, $a_finished_result=null)
 Get json for task progress. More...
 
static getFinishedJson ($a_task_id, $a_cmd, $a_result)
 Get json for finished task. More...
 

Static Protected Member Functions

static jsonSafeString ($a_text)
 Makes the specified string safe for JSON. More...
 

Detailed Description

Background task JSON helper.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 10 of file class.ilBackgroundTaskJson.php.

Member Function Documentation

◆ getBlockedJson()

static ilBackgroundTaskJson::getBlockedJson (   $a_task_id)
static

Get json for blocked task.

Parameters
int$a_task_id
Returns
\stdClass

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

40 {
41 global $DIC;
42 $lng = $DIC['lng'];
43
44 $json = new stdClass();
45
46 $json->status = "block";
47 $json->task_id = $a_task_id;
48 $json->title = self::jsonSafeString($lng->txt("bgtask_blocked"));
49 $json->message = self::jsonSafeString($lng->txt("bgtask_blocked_info"));
50 $json->button_old = self::jsonSafeString($lng->txt("bgtask_blocked_cancel_old"));
51 $json->button_new = self::jsonSafeString($lng->txt("bgtask_blocked_cancel_new"));
52
53 return $json;
54 }
static jsonSafeString($a_text)
Makes the specified string safe for JSON.
global $lng
Definition: privfeed.php:17
global $DIC
Definition: saml.php:7

References $DIC, $lng, and jsonSafeString().

Referenced by ilFolderDownloadBackgroundTaskHandler\init().

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

◆ getFailedJson()

static ilBackgroundTaskJson::getFailedJson (   $a_message)
static

Get json for failed task.

Parameters
string$a_message
Returns
\stdClass

Definition at line 18 of file class.ilBackgroundTaskJson.php.

19 {
20 global $DIC;
21 $lng = $DIC['lng'];
22
23 $json = new stdClass();
24
25 $json->status = "fail";
26 $json->title = self::jsonSafeString($lng->txt("bgtask_failure"));
27 $json->message = self::jsonSafeString($a_message);
28 $json->button = self::jsonSafeString($lng->txt("ok"));
29
30 return $json;
31 }

References $DIC, $lng, and jsonSafeString().

Referenced by ilFolderDownloadBackgroundTaskHandler\init().

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

◆ getFinishedJson()

static ilBackgroundTaskJson::getFinishedJson (   $a_task_id,
  $a_cmd,
  $a_result 
)
static

Get json for finished task.

Parameters
int$a_task_id
string$a_cmd
string$a_result
Returns
\stdClass

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

115 {
116 $json = new stdClass();
117
118 $json->status = "finished";
119 $json->task_id = $a_task_id;
120 $json->result_cmd = $a_cmd;
121 $json->result = $a_result;
122
123 return $json;
124 }

Referenced by ilFolderDownloadBackgroundTaskHandler\init().

+ Here is the caller graph for this function:

◆ getProcessingJson()

static ilBackgroundTaskJson::getProcessingJson (   $a_task_id,
  $a_message,
  $a_steps 
)
static

Get json for processing task.

Parameters
int$a_task_id
string$a_message
int$a_steps
Returns
\stdClass

Definition at line 64 of file class.ilBackgroundTaskJson.php.

65 {
66 global $DIC;
67 $lng = $DIC['lng'];
68
69 $json = new stdClass();
70
71 $json->status = "bg";
72 $json->task_id = $a_task_id;
73 $json->title = self::jsonSafeString($lng->txt("bgtask_processing"));
74 $json->message = self::jsonSafeString($a_message);
75 $json->button = self::jsonSafeString($lng->txt("cancel"));
76 $json->steps = (int) $a_steps;
77
78 return $json;
79 }

References $DIC, $lng, and jsonSafeString().

Referenced by ilFolderDownloadBackgroundTaskHandler\init().

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

◆ getProgressJson()

static ilBackgroundTaskJson::getProgressJson ( ilBackgroundTask  $a_task,
  $a_finished_cmd = null,
  $a_finished_result = null 
)
static

Get json for task progress.

Parameters
ilBackgroundTask$a_message
string$a_finished_cmd
string$a_finished_result
Returns
\stdClass

Definition at line 89 of file class.ilBackgroundTaskJson.php.

90 {
91 $json = new stdClass();
92
93 $json->status = $a_task->getStatus();
94 $json->steps = $a_task->getSteps();
95 $json->current = $a_task->getCurrentStep();
96
97 // if task has been finished, get result action
98 if ($a_finished_cmd) {
99 $json->result_cmd = $a_finished_cmd;
100 $json->result = $a_finished_result;
101 }
102
103 return $json;
104 }
getSteps()
Gets the steps.
getStatus()
Gets the status.
getCurrentStep()
Gets the current step.

References ilBackgroundTask\getCurrentStep(), ilBackgroundTask\getStatus(), and ilBackgroundTask\getSteps().

Referenced by ilBackgroundTaskHub\progress().

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

◆ jsonSafeString()

static ilBackgroundTaskJson::jsonSafeString (   $a_text)
staticprotected

Makes the specified string safe for JSON.

Parameters
string$a_text
Returns
string

Definition at line 132 of file class.ilBackgroundTaskJson.php.

133 {
134 if (!is_string($a_text)) {
135 return $a_text;
136 }
137
138 $a_text = htmlentities($a_text, ENT_COMPAT | ENT_HTML401, "UTF-8");
139 $a_text = str_replace("'", "'", $a_text);
140
141 return $a_text;
142 }

Referenced by getBlockedJson(), getFailedJson(), and getProcessingJson().

+ Here is the caller graph for this function:

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