ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilAsyncOutputHandler Class Reference

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

+ Collaboration diagram for ilAsyncOutputHandler:

Public Member Functions

 __construct ($content=null, $heading=null, $windows_properties=array())
 
 terminate ($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 ($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 ($normal_content, $async_content=null, $apply_to_tpl=true)
 Handles async output. More...
 

Data Fields

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

Protected Attributes

 $content
 
 $heading
 
 $window_properties
 

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 11 of file class.ilAsyncOutputHandler.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

References $content, and $heading.

21  {
22  $this->content = $content;
23  $this->heading = $heading;
24 
25  $this->window_properties = $windows_properties;
26  }

Member Function Documentation

◆ encodeAsyncResponse()

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

Encode data as json for async output.

Parameters
array$data
Returns
string

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

References $data, $DIC, and $ilCtrl.

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

69  {
70  global $DIC;
71  $ilCtrl = $DIC['ilCtrl'];
72 
73  $data['cmd'] = $ilCtrl->getCmd();
74 
75  return json_encode($data);
76  }
global $ilCtrl
Definition: ilias.php:18
global $DIC
+ Here is the caller graph for this function:

◆ getContent()

ilAsyncOutputHandler::getContent ( )

Returns the content of the modal output.

Returns
mixed

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

References $content.

Referenced by terminate().

111  {
112  return $this->content;
113  }
+ Here is the caller graph for this function:

◆ getHeading()

ilAsyncOutputHandler::getHeading ( )

Return the heading of a modal.

Returns
mixed

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

References $heading.

Referenced by terminate().

131  {
132  return $this->heading;
133  }
+ Here is the caller graph for this function:

◆ getWindowProperties()

ilAsyncOutputHandler::getWindowProperties ( )

Return all window properties.

Returns
mixed

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

References $window_properties.

◆ handleAsyncOutput()

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

Handles async output.

Parameters
$normal_content
null$async_content
bool$apply_to_tpl
Returns
null

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

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

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

87  {
88  global $DIC;
89  $ilCtrl = $DIC['ilCtrl'];
90  $tpl = $DIC['tpl'];
91 
92  $content = ($ilCtrl->isAsynch() && $async_content != null)? $async_content : $normal_content;
93 
94  if($ilCtrl->isAsynch()) {
95  echo $content;
96  exit();
97  } else {
98  if($apply_to_tpl) {
99  $tpl->setContent($content);
100  } else {
101  return $content;
102  }
103  }
104  }
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
global $DIC
+ 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 121 of file class.ilAsyncOutputHandler.php.

References $content.

121  {
122  $this->content = $content;
123  }

◆ setHeading()

ilAsyncOutputHandler::setHeading (   $heading)

Sets the heading of a modal-output.

Parameters
mixed$heading

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

References $heading.

141  {
142  $this->heading = $heading;
143  }

◆ setWindowProperties()

ilAsyncOutputHandler::setWindowProperties (   $window_properties)

Set windows properties.

Parameters
mixed$window_properties

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

References $window_properties.

161  {
162  $this->window_properties = $window_properties;
163  }

◆ terminate()

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

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

Parameters
string$type

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

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

36  {
37  if($type == self::OUTPUT_MODAL) {
38  $tpl = new ilTemplate('tpl.modal_content.html', false, false, 'Modules/StudyProgramme');
39  $tpl->setVariable('HEADING', $this->getHeading());
40  $tpl->setVariable('BODY', $this->getContent());
41 
42  //TODO: implement window properties
43  /*foreach($this->window_properties as $key => $value) {
44  if($value) {
45  $tpl->activeBlock($key);
46  } else {
47  $tpl->removeBlockData($key);
48  }
49  }*/
50 
51  echo $tpl->get();
52  exit();
53 
54  } else if($type == self::OUTPUT_EMPTY) {
55 
56  echo $this->getContent();
57  exit();
58  }
59  }
getHeading()
Return the heading of a modal.
global $tpl
Definition: ilias.php:8
getContent()
Returns the content of the modal output.
special template class to simplify handling of ITX/PEAR
+ Here is the call graph for this function:

Field Documentation

◆ $content

ilAsyncOutputHandler::$content
protected

◆ $heading

ilAsyncOutputHandler::$heading
protected

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

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

◆ $window_properties

ilAsyncOutputHandler::$window_properties
protected

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

Referenced by getWindowProperties(), and setWindowProperties().

◆ OUTPUT_EMPTY

const ilAsyncOutputHandler::OUTPUT_EMPTY = "output_empty"

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

◆ OUTPUT_MODAL

const ilAsyncOutputHandler::OUTPUT_MODAL = "output_modal"

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


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