ILIAS  release_8 Revision v8.23
ilAsyncPropertyFormGUI Class Reference

Class ilAsyncPropertyFormGUI. More...

+ Inheritance diagram for ilAsyncPropertyFormGUI:
+ Collaboration diagram for ilAsyncPropertyFormGUI:

Public Member Functions

 __construct (RequestWrapper $request_wrapper, array $config=array(), bool $is_async=true)
 
 checkInput ()
 Saves the change input result into a property. More...
 
 getErrors ()
 Return errors of the form as array. More...
 
 hasErrors ()
 Return if there were errors on the last checkInput call. More...
 
 cloneForm (ilPropertyFormGUI $form_to_clone)
 Copies form items, buttons and properties from another form. More...
 
 getHTML ()
 Returns the rendered form content. More...
 
 isSubmitted ()
 Checks if the form was submitted. More...
 
 setFormAction (string $a_formaction)
 Sets the form action If the form is set to async, the cmdMode=asynch is added to the url. More...
 
 getJsPath ()
 
 setJsPath (string $js_path)
 
 getDefaultFormName ()
 
 isAsync ()
 
 setAsync (bool $is_async)
 
 setName (string $a_name)
 
- Public Member Functions inherited from ilPropertyFormGUI
 __construct ()
 
 executeCommand ()
 
 setTableWidth (string $a_width)
 
 getTableWidth ()
 
 setMode (string $a_mode)
 
 getMode ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setTitleIcon (string $a_titleicon)
 
 getTitleIcon ()
 
 setDescription (string $a_val)
 
 getDescription ()
 
 setTopAnchor (string $a_val)
 
 getTopAnchor ()
 
 setShowTopButtons (bool $a_val)
 
 getShowTopButtons ()
 
 setForceTopButtons (bool $a_val)
 
 getForceTopButtons ()
 
 addItem ($a_item)
 
 removeItemByPostVar (string $a_post_var, bool $a_remove_unused_headers=false)
 
 getItemByPostVar (string $a_post_var)
 
 setItems (array $a_items)
 
 getItems ()
 
 getInputItemsRecursive ()
 returns a flat array of all input items including the possibly existing subitems recursively More...
 
 setDisableStandardMessage (bool $a_val)
 
 getDisableStandardMessage ()
 
 getHideLabels ()
 
 setHideLabels (bool $a_value=true)
 
 setValuesByArray (array $a_values, bool $a_restrict_to_value_keys=false)
 
 setValuesByPost ()
 
 checkInput ()
 
 getInput (string $a_post_var, bool $ensureValidation=true)
 Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-POST variable, identified by the passed postvar. More...
 
 addCommandButton (string $a_cmd, string $a_text, string $a_id="")
 
 getCommandButtons ()
 
 clearCommandButtons ()
 
 getContent ()
 
 insertItem ( $item, bool $a_sub_item=false)
 
 addAsyncOnloadCode (string $code)
 
 getHTML ()
 
 getHTMLAsync ()
 
 getFileUpload (string $a_field, ?string $a_index=null, ?string $a_sub_index=null)
 Get file upload data. More...
 
 hasFileUpload (string $a_field, ?string $a_index=null, ?string $a_sub_index=null)
 
 moveFileUpload (string $a_target_directory, string $a_field, ?string $a_target_name=null, ?string $a_index=null, ?string $a_sub_index=null)
 Move upload to target directory. More...
 
- Public Member Functions inherited from ilFormGUI
 setFormAction (string $a_formaction)
 
 getFormAction ()
 
 setTarget (string $a_target)
 
 getTarget ()
 
 setMultipart (bool $a_multipart)
 
 getMultipart ()
 
 setId (string $a_id)
 
 getId ()
 
 setName (string $a_name)
 
 getName ()
 
 setKeepOpen (bool $a_keepopen)
 
 getKeepOpen ()
 
 setOpenTag (bool $a_open)
 
 getOpenTag ()
 
 setCloseTag (bool $a_val)
 
 getCloseTag ()
 
 setPreventDoubleSubmission (bool $a_val)
 
 getPreventDoubleSubmission ()
 
 getHTML ()
 
 getContent ()
 

Static Public Member Functions

static addJavaScript (bool $add_form_loader=false, string $js_base_path=null)
 Adds all needed js By default is called by ilAsyncPropertyFormGUI::getHTML() More...
 
static getErrorMessageTemplate ()
 Returns the error-message template for the client-side validation. More...
 

Static Protected Member Functions

static addOnLoadCode (string $id, string $content)
 Adds onload code to the template. More...
 

Protected Attributes

bool $has_errors = false
 
bool $is_async = true
 
RequestWrapper $request_wrapper
 
- Protected Attributes inherited from ilPropertyFormGUI
bool $required_text = false
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilTemplate $tpl
 
ilObjUser $user = null
 
ilSetting $settings = null
 
string $mode = "std"
 
bool $check_input_called = false
 
bool $disable_standard_message = false
 
string $top_anchor = "il_form_top"
 
string $title = ''
 
string $titleicon = ""
 
string $description = ""
 
string $tbl_width = ""
 
bool $show_top_buttons = true
 
bool $hide_labels = false
 
bool $force_top_buttons = false
 
HTTP Services $http
 
Refinery Factory $refinery = null
 
ilGlobalTemplateInterface $global_tpl = null
 
 $onload_code = []
 
- Protected Attributes inherited from ilFormGUI
string $formaction = ""
 
bool $multipart = false
 
bool $keepopen = false
 
bool $opentag = true
 
string $id = ''
 
string $name = ''
 
string $target = ''
 
bool $prevent_double_submission = false
 

Static Protected Attributes

static string $js_path = "./Modules/StudyProgramme/templates/js/"
 
static string $default_from_name = "async_form"
 
static array $js_on_load_added = array()
 

Additional Inherited Members

- Protected Member Functions inherited from ilPropertyFormGUI
 getRequestedPostVar ()
 
 getFileHash ()
 
 hideRequired (string $a_type)
 
 appendOnloadCode (string $html)
 
 rebuildUploadedFiles ()
 

Detailed Description

Class ilAsyncPropertyFormGUI.

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

Definition at line 29 of file class.ilAsyncPropertyFormGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilAsyncPropertyFormGUI::__construct ( RequestWrapper  $request_wrapper,
array  $config = array(),
bool  $is_async = true 
)

Definition at line 58 of file class.ilAsyncPropertyFormGUI.php.

References $config, ILIAS\LTI\ToolProvider\$key, $request_wrapper, ILIAS\GlobalScreen\Provider\__construct(), setAsync(), and setName().

59  {
61 
62  foreach ($config as $key => $value) {
63  $setterMethod = "set" . ucfirst($key);
64  if (method_exists($this, $setterMethod)) {
65  $setterMethod($value);
66  }
67  }
68 
69  $this->request_wrapper = $request_wrapper;
70  $this->setAsync($is_async);
71  $this->setName(self::$default_from_name);
72  }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
string $key
Consumer key/client ID value.
Definition: System.php:193
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addJavaScript()

static ilAsyncPropertyFormGUI::addJavaScript ( bool  $add_form_loader = false,
string  $js_base_path = null 
)
static

Adds all needed js By default is called by ilAsyncPropertyFormGUI::getHTML()

Definition at line 79 of file class.ilAsyncPropertyFormGUI.php.

References $DIC, and ilPropertyFormGUI\$tpl.

Referenced by ilObjStudyProgrammeTreeGUI\initAsyncUIElements().

79  : void
80  {
81  global $DIC;
82  $tpl = $DIC['tpl'];
83 
84  $js_path = $js_base_path ?? self::$js_path;
85 
86  $tpl->addJavaScript($js_path . 'ilAsyncPropertyFormGUI.js');
87 
88  $global_config =
89  "$.ilAsyncPropertyForm.global_config.error_message_template = '" .
90  self::getErrorMessageTemplate() .
91  "'; $.ilAsyncPropertyForm.global_config.async_form_name = '" .
92  self::$default_from_name . "';"
93  ;
94 
95  self::addOnLoadCode('global_config', $global_config);
96 
97  if ($add_form_loader) {
98  self::addOnLoadCode('form_loader', '$("body").ilAsyncPropertyForm();');
99  }
100  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ addOnLoadCode()

static ilAsyncPropertyFormGUI::addOnLoadCode ( string  $id,
string  $content 
)
staticprotected

Adds onload code to the template.

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

References $DIC, ilFormGUI\$id, and ilPropertyFormGUI\$tpl.

192  : void
193  {
194  global $DIC;
195  $tpl = $DIC['tpl'];
196 
197  if (!isset(self::$js_on_load_added[$id])) {
198  $tpl->addOnLoadCode($content);
199  self::$js_on_load_added[$id] = $content;
200  }
201  }
global $DIC
Definition: feed.php:28

◆ checkInput()

ilAsyncPropertyFormGUI::checkInput ( )

Saves the change input result into a property.

Definition at line 105 of file class.ilAsyncPropertyFormGUI.php.

Referenced by getErrors().

105  : bool
106  {
107  $result = parent::checkInput();
108  $this->has_errors = $result;
109 
110  return $result;
111  }
+ Here is the caller graph for this function:

◆ cloneForm()

ilAsyncPropertyFormGUI::cloneForm ( ilPropertyFormGUI  $form_to_clone)

Copies form items, buttons and properties from another form.

Definition at line 165 of file class.ilAsyncPropertyFormGUI.php.

References ilPropertyFormGUI\addCommandButton(), ilPropertyFormGUI\addItem(), ilPropertyFormGUI\getCommandButtons(), and ilPropertyFormGUI\getItems().

166  {
167  if (count($this->getItems()) > 0) {
168  throw new ilException("You cannot clone into a already filled form!");
169  }
170 
171  $reflect = new ReflectionClass($this);
172  $properties = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
173 
174  foreach ($properties as $property) {
175  $this->{$property->getName()} = $property->getValue($form_to_clone);
176  }
177 
178  foreach ($form_to_clone->getItems() as $item) {
179  $this->addItem($item);
180  }
181 
182  foreach ($form_to_clone->getCommandButtons() as $button) {
183  $this->addCommandButton($button['cmd'], $button['text']);
184  }
185 
186  return $this;
187  }
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
Class ilAsyncPropertyFormGUI.
+ Here is the call graph for this function:

◆ getDefaultFormName()

ilAsyncPropertyFormGUI::getDefaultFormName ( )

Definition at line 247 of file class.ilAsyncPropertyFormGUI.php.

247  : string
248  {
249  return self::$default_from_name;
250  }

◆ getErrorMessageTemplate()

static ilAsyncPropertyFormGUI::getErrorMessageTemplate ( )
static

Returns the error-message template for the client-side validation.

Definition at line 146 of file class.ilAsyncPropertyFormGUI.php.

References $DIC, ilPropertyFormGUI\$lng, ilPropertyFormGUI\$tpl, ilTemplate\get(), ilUtil\getImagePath(), ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), and ilLanguage\txt().

146  : string
147  {
148  global $DIC;
149  $lng = $DIC['lng'];
150 
151  $tpl = new ilTemplate("tpl.property_form.html", true, true, "Services/Form");
152 
153  $tpl->setCurrentBlock("alert");
154  // TODO: DW -> refactor getImagePath
155  $tpl->setVariable("IMG_ALERT", ilUtil::getImagePath("icon_alert.svg"));
156  $tpl->setVariable("ALT_ALERT", $lng->txt("alert"));
157  $tpl->setVariable("TXT_ALERT", "[TXT_ALERT]");
159  return trim($tpl->get("alert"));
160  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
get(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: feed.php:28
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:

◆ getErrors()

ilAsyncPropertyFormGUI::getErrors ( )

Return errors of the form as array.

Returns
array Array with field id and error message: array([]=>array('key'=>fieldId, 'message'=>error-message))

Definition at line 118 of file class.ilAsyncPropertyFormGUI.php.

References $errors, checkInput(), and ilPropertyFormGUI\getItems().

118  : array
119  {
120  if (!$this->check_input_called) {
121  $this->checkInput();
122  }
123 
124  $errors = array();
125  foreach ($this->getItems() as $item) {
126  // We call method exists as there are items in the form (ilFormSectionHeaderGUI)
127  // that do not have alerts. (#16956)
128  if (method_exists($item, "getAlert") && $item->getAlert() !== "") {
129  $errors[] = array('key' => $item->getFieldId(), 'message' => $item->getAlert());
130  }
131  }
132  return $errors;
133  }
$errors
Definition: imgupload.php:65
checkInput()
Saves the change input result into a property.
+ Here is the call graph for this function:

◆ getHTML()

ilAsyncPropertyFormGUI::getHTML ( )

Returns the rendered form content.

Definition at line 206 of file class.ilAsyncPropertyFormGUI.php.

References isAsync().

206  : string
207  {
208  self::addJavaScript($this->isAsync());
209 
210  return parent::getHTML();
211  }
+ Here is the call graph for this function:

◆ getJsPath()

ilAsyncPropertyFormGUI::getJsPath ( )

Definition at line 237 of file class.ilAsyncPropertyFormGUI.php.

237  : ?string
238  {
239  return self::$js_path;
240  }

◆ hasErrors()

ilAsyncPropertyFormGUI::hasErrors ( )

Return if there were errors on the last checkInput call.

Definition at line 138 of file class.ilAsyncPropertyFormGUI.php.

References $has_errors.

138  : bool
139  {
140  return $this->has_errors;
141  }

◆ isAsync()

ilAsyncPropertyFormGUI::isAsync ( )

Definition at line 252 of file class.ilAsyncPropertyFormGUI.php.

References $is_async.

Referenced by getHTML(), and setFormAction().

252  : bool
253  {
254  return $this->is_async;
255  }
+ Here is the caller graph for this function:

◆ isSubmitted()

ilAsyncPropertyFormGUI::isSubmitted ( )

Checks if the form was submitted.

Definition at line 216 of file class.ilAsyncPropertyFormGUI.php.

216  : bool
217  {
218  if ($this->request_wrapper->has("cmd")) {
219  return true;
220  }
221  return false;
222  }

◆ setAsync()

ilAsyncPropertyFormGUI::setAsync ( bool  $is_async)

Definition at line 257 of file class.ilAsyncPropertyFormGUI.php.

References $is_async.

Referenced by __construct().

257  : void
258  {
259  $this->is_async = $is_async;
260  }
+ Here is the caller graph for this function:

◆ setFormAction()

ilAsyncPropertyFormGUI::setFormAction ( string  $a_formaction)

Sets the form action If the form is set to async, the cmdMode=asynch is added to the url.

Definition at line 228 of file class.ilAsyncPropertyFormGUI.php.

References isAsync().

228  : void
229  {
230  if ($this->isAsync()) {
231  $a_formaction .= "&cmdMode=asynch";
232  }
233 
234  $this->formaction = $a_formaction;
235  }
+ Here is the call graph for this function:

◆ setJsPath()

ilAsyncPropertyFormGUI::setJsPath ( string  $js_path)

Definition at line 242 of file class.ilAsyncPropertyFormGUI.php.

References $js_path.

242  : void
243  {
244  self::$js_path = $js_path;
245  }

◆ setName()

ilAsyncPropertyFormGUI::setName ( string  $a_name)
Parameters
string$a_name

Definition at line 265 of file class.ilAsyncPropertyFormGUI.php.

Referenced by __construct().

265  : void
266  {
267  self::$default_from_name = $a_name;
268 
269  parent::setName($a_name);
270  }
+ Here is the caller graph for this function:

Field Documentation

◆ $default_from_name

string ilAsyncPropertyFormGUI::$default_from_name = "async_form"
staticprotected

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

◆ $has_errors

bool ilAsyncPropertyFormGUI::$has_errors = false
protected

Definition at line 49 of file class.ilAsyncPropertyFormGUI.php.

Referenced by hasErrors().

◆ $is_async

bool ilAsyncPropertyFormGUI::$is_async = true
protected

Definition at line 54 of file class.ilAsyncPropertyFormGUI.php.

Referenced by isAsync(), and setAsync().

◆ $js_on_load_added

array ilAsyncPropertyFormGUI::$js_on_load_added = array()
staticprotected

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

◆ $js_path

string ilAsyncPropertyFormGUI::$js_path = "./Modules/StudyProgramme/templates/js/"
staticprotected

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

Referenced by setJsPath().

◆ $request_wrapper

RequestWrapper ilAsyncPropertyFormGUI::$request_wrapper
protected

Definition at line 56 of file class.ilAsyncPropertyFormGUI.php.

Referenced by __construct().


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