ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilAsyncOutputHandler Class Reference

Class ilAsyncOutputHandler Handles the output for async-requests. More...

+ Collaboration diagram for ilAsyncOutputHandler:

Public Member Functions

 __construct ($content=null, $heading=null, array $windows_properties=array())
 
 terminate (string $type=self::OUTPUT_MODAL)
 Output content in different ways self::OUTPUT_MODAL: Output as bootstrap modal self::OUTPUT_EMPTY: Only content without ILIAS-layout. More...
 
 getContent ()
 Returns the content of the modal output. More...
 
 setContent ($content)
 Sets the content of the modal output. More...
 
 getHeading ()
 Return the heading of a modal. More...
 
 setHeading ($heading)
 Sets the heading of a modal-output. More...
 
 getWindowProperties ()
 Return all window properties. More...
 
 setWindowProperties (array $window_properties)
 Set windows properties. More...
 

Static Public Member Functions

static encodeAsyncResponse (array $data=array())
 Encode data as json for async output. More...
 
static handleAsyncOutput (string $normal_content, string $async_content=null, bool $apply_to_tpl=true)
 Handles async output. More...
 

Protected Attributes

 $content
 
 $heading
 
array $window_properties
 

Private Attributes

const OUTPUT_MODAL = "output_modal"
 
const OUTPUT_EMPTY = "output_empty"
 

Detailed Description

Class ilAsyncOutputHandler Handles the output for async-requests.

The class allows to generate the basic structure of a bootstrap-modal (for modal-content)

Author
Michael Herren mh@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
1.0.0

Definition at line 31 of file class.ilAsyncOutputHandler.php.

Constructor & Destructor Documentation

◆ __construct()

ilAsyncOutputHandler::__construct (   $content = null,
  $heading = null,
array  $windows_properties = array() 
)

Definition at line 48 of file class.ilAsyncOutputHandler.php.

References $content, and $heading.

49  {
50  $this->content = $content;
51  $this->heading = $heading;
52  $this->window_properties = $windows_properties;
53  }

Member Function Documentation

◆ encodeAsyncResponse()

static ilAsyncOutputHandler::encodeAsyncResponse ( array  $data = array())
static

Encode data as json for async output.

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

References $data, and $DIC.

Referenced by ilObjStudyProgrammeGUI\afterSave(), ilObjStudyProgrammeTreeGUI\cancel(), ilObjStudyProgrammeGUI\cancel(), ilObjStudyProgrammeTreeGUI\cancelDelete(), ilObjStudyProgrammeTreeGUI\confirmedDelete(), ilObjStudyProgrammeTreeGUI\createNewLeaf(), ilObjStudyProgrammeGUI\save(), ilObjStudyProgrammeTreeGUI\saveTreeOrder(), and ilObjStudyProgrammeSettingsGUI\update().

89  : string
90  {
91  global $DIC;
92  $ilCtrl = $DIC['ilCtrl'];
93 
94  $data['cmd'] = $ilCtrl->getCmd();
95 
96  return json_encode($data, JSON_THROW_ON_ERROR);
97  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getContent()

ilAsyncOutputHandler::getContent ( )

Returns the content of the modal output.

Returns
mixed

Definition at line 137 of file class.ilAsyncOutputHandler.php.

References $content.

Referenced by terminate().

138  {
139  return $this->content;
140  }
+ Here is the caller graph for this function:

◆ getHeading()

ilAsyncOutputHandler::getHeading ( )

Return the heading of a modal.

Returns
mixed

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

References $heading.

Referenced by terminate().

158  {
159  return $this->heading;
160  }
+ Here is the caller graph for this function:

◆ getWindowProperties()

ilAsyncOutputHandler::getWindowProperties ( )

Return all window properties.

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

References $window_properties.

175  : array
176  {
178  }

◆ handleAsyncOutput()

static ilAsyncOutputHandler::handleAsyncOutput ( string  $normal_content,
string  $async_content = null,
bool  $apply_to_tpl = true 
)
static

Handles async output.

Returns
string|void

Definition at line 104 of file class.ilAsyncOutputHandler.php.

References $content, $DIC, $http, $tpl, and exit.

Referenced by ilObjStudyProgrammeGUI\afterSave(), ilObjStudyProgrammeGUI\cancel(), ilObjStudyProgrammeTreeGUI\executeCommand(), and ilObjStudyProgrammeSettingsGUI\update().

108  {
109  global $DIC;
110  $ilCtrl = $DIC['ilCtrl'];
111  $tpl = $DIC['tpl'];
112  $http = $DIC['http'];
113 
114  $content = ($ilCtrl->isAsynch() && $async_content !== null) ? $async_content : $normal_content;
115 
116  if ($ilCtrl->isAsynch()) {
117  $http->saveResponse(
118  $http->response()
119  ->withHeader(ResponseHeader::CONTENT_TYPE, 'text/html')
120  ->withBody(Streams::ofString($content))
121  );
122  $http->sendResponse();
123  $http->close();
124  exit();
125  } elseif ($apply_to_tpl) {
126  $tpl->setContent($content);
127  } else {
128  return $content;
129  }
130  }
exit
Definition: login.php:28
global $DIC
Definition: feed.php:28
$http
Definition: raiseError.php:7
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
+ Here is the caller graph for this function:

◆ setContent()

ilAsyncOutputHandler::setContent (   $content)

Sets the content of the modal output.

Parameters
mixed$content

Definition at line 147 of file class.ilAsyncOutputHandler.php.

References $content.

147  : void
148  {
149  $this->content = $content;
150  }

◆ setHeading()

ilAsyncOutputHandler::setHeading (   $heading)

Sets the heading of a modal-output.

Parameters
mixed$heading

Definition at line 167 of file class.ilAsyncOutputHandler.php.

References $heading.

167  : void
168  {
169  $this->heading = $heading;
170  }

◆ setWindowProperties()

ilAsyncOutputHandler::setWindowProperties ( array  $window_properties)

Set windows properties.

Definition at line 183 of file class.ilAsyncOutputHandler.php.

References $window_properties.

183  : void
184  {
185  $this->window_properties = $window_properties;
186  }

◆ terminate()

ilAsyncOutputHandler::terminate ( string  $type = self::OUTPUT_MODAL)

Output content in different ways self::OUTPUT_MODAL: Output as bootstrap modal self::OUTPUT_EMPTY: Only content without ILIAS-layout.

Definition at line 60 of file class.ilAsyncOutputHandler.php.

References $tpl, $type, exit, getContent(), and getHeading().

60  : void
61  {
62  if ($type === self::OUTPUT_MODAL) {
63  $tpl = new ilTemplate('tpl.modal_content.html', false, false, 'Modules/StudyProgramme');
64  $tpl->setVariable('HEADING', $this->getHeading());
65  $tpl->setVariable('BODY', $this->getContent());
66 
67  //TODO: implement window properties
68  /*foreach($this->window_properties as $key => $value) {
69  if($value) {
70  $tpl->activeBlock($key);
71  } else {
72  $tpl->removeBlockData($key);
73  }
74  }*/
75 
76  echo $tpl->get();
77  exit();
78  }
79 
80  if ($type === self::OUTPUT_EMPTY) {
81  echo $this->getContent();// TODO PHP8-REVIEW I sugges to use the HTTP service instead of echo/exit
82  exit();
83  }
84  }
getHeading()
Return the heading of a modal.
exit
Definition: login.php:28
$type
getContent()
Returns the content of the modal output.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
+ Here is the call graph for this function:

Field Documentation

◆ $content

ilAsyncOutputHandler::$content
protected

◆ $heading

ilAsyncOutputHandler::$heading
protected

Definition at line 44 of file class.ilAsyncOutputHandler.php.

Referenced by __construct(), getHeading(), and setHeading().

◆ $window_properties

array ilAsyncOutputHandler::$window_properties
protected

Definition at line 46 of file class.ilAsyncOutputHandler.php.

Referenced by getWindowProperties(), and setWindowProperties().

◆ OUTPUT_EMPTY

const ilAsyncOutputHandler::OUTPUT_EMPTY = "output_empty"
private

Definition at line 34 of file class.ilAsyncOutputHandler.php.

◆ OUTPUT_MODAL

const ilAsyncOutputHandler::OUTPUT_MODAL = "output_modal"
private

Definition at line 33 of file class.ilAsyncOutputHandler.php.


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