ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 38 of file class.ilBackgroundTaskJson.php.

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

References $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 $lng;
21
22 $json = new stdClass();
23
24 $json->status = "fail";
25 $json->title = self::jsonSafeString($lng->txt("bgtask_failure"));
26 $json->message = self::jsonSafeString($a_message);
27 $json->button = self::jsonSafeString($lng->txt("ok"));
28
29 return $json;
30 }

References $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 112 of file class.ilBackgroundTaskJson.php.

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

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 62 of file class.ilBackgroundTaskJson.php.

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

References $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 86 of file class.ilBackgroundTaskJson.php.

87 {
88 $json = new stdClass();
89
90 $json->status = $a_task->getStatus();
91 $json->steps = $a_task->getSteps();
92 $json->current = $a_task->getCurrentStep();
93
94 // if task has been finished, get result action
95 if($a_finished_cmd)
96 {
97 $json->result_cmd = $a_finished_cmd;
98 $json->result = $a_finished_result;
99 }
100
101 return $json;
102 }
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 130 of file class.ilBackgroundTaskJson.php.

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

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: