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

Class ilAsyncPropertyFormGUI. More...

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

Public Member Functions

 __construct (array $config=array(), $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 ($a_formaction)
 Sets the form action If the form is set to async, the cmdMode=asynch is added to the url. More...
 
 getJsPath ()
 
 setJsPath ($js_path)
 
 getDefaultFormName ()
 
 isAsync ()
 
 setAsync ($is_async)
 
 setName ($a_name)
 
- Public Member Functions inherited from ilPropertyFormGUI
 __construct ()
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 setTableWidth ($a_width)
 Set table width. More...
 
 getTableWidth ()
 get table width More...
 
 setMode ($a_mode)
 Set Mode ('std', 'subform'). More...
 
 getMode ()
 Get Mode ('std', 'subform'). More...
 
 setTitle ($a_title)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 setTitleIcon ($a_titleicon)
 Set TitleIcon. More...
 
 getTitleIcon ()
 Get TitleIcon. More...
 
 setDescription ($a_val)
 Set description. More...
 
 getDescription ()
 Get description. More...
 
 setTopAnchor ($a_val)
 Set top anchor. More...
 
 getTopAnchor ()
 Get top anchor. More...
 
 setShowTopButtons ($a_val)
 Get show top buttons. More...
 
 getShowTopButtons ()
 Set show top buttons. More...
 
 addItem ($a_item)
 Add Item (Property, SectionHeader). More...
 
 removeItemByPostVar ($a_post_var)
 Remove Item. More...
 
 getItemByPostVar ($a_post_var)
 Get Item by POST variable. More...
 
 setItems ($a_items)
 Set Items. More...
 
 getItems ()
 Get Items. More...
 
 getInputItemsRecursive ()
 returns a flat array of all input items including the possibly existing subitems recursively More...
 
 setDisableStandardMessage ($a_val)
 Set disable standard message. More...
 
 getDisableStandardMessage ()
 Get disable standard message. More...
 
 getHideLabels ()
 Get a value indicating whether the labels should be hidden or not. More...
 
 setHideLabels ($a_value=true)
 Set a value indicating whether the labels should be hidden or not. More...
 
 setValuesByArray ($a_values, $a_restrict_to_value_keys=false)
 Set form values from an array. More...
 
 setValuesByPost ()
 Set form values from POST values. More...
 
 checkInput ()
 Check Post Input. More...
 
 getInput ($a_post_var, $ensureValidation=true)
 Returns the value of a HTTP-POST variable, identified by the passed id. More...
 
 addCustomProperty ($a_title, $a_html, $a_info="", $a_alert="", $a_required=false)
 Add a custom property. More...
 
 addCommandButton ($a_cmd, $a_text, $a_id="")
 Add Command button. More...
 
 getCommandButtons ()
 Return all Command buttons. More...
 
 clearCommandButtons ()
 Remove all command buttons. More...
 
 getContent ()
 Get Content. More...
 
 insertItem ($item, $a_sub_item=false)
 
 getHTML ()
 
 getFileUpload ($a_field, $a_index=null, $a_sub_index=null)
 Get file upload data. More...
 
 hasFileUpload ($a_field, $a_index=null, $a_sub_index=null)
 Was any file uploaded? More...
 
 moveFileUpload ($a_target_directory, $a_field, $a_target_name=null, $a_index=null, $a_sub_index=null)
 Move upload to target directory. More...
 
- Public Member Functions inherited from ilFormGUI
 setFormAction ($a_formaction)
 Set FormAction. More...
 
 getFormAction ()
 Get FormAction. More...
 
 setTarget ($a_target)
 Set Target. More...
 
 getTarget ()
 Get Target. More...
 
 setMultipart ($a_multipart)
 Set Enctype Multipart/Formdata true/false. More...
 
 getMultipart ()
 Get Enctype Multipart/Formdata true/false. More...
 
 setId ($a_id)
 Set Id. More...
 
 getId ()
 Get Id. More...
 
 setName ($a_name)
 Set Name. More...
 
 getName ()
 Get Name. More...
 
 setKeepOpen ($a_keepopen)
 Set Keep Form Tag Open. More...
 
 getKeepOpen ()
 Get Keep Form Tag Open. More...
 
 setOpenTag ($a_open)
 Enable/Disable Open Form Tag. More...
 
 getOpenTag ()
 Get Open Form Tag Enabled. More...
 
 setCloseTag ($a_val)
 Set close tag. More...
 
 getCloseTag ()
 Get close tag. More...
 
 setPreventDoubleSubmission ($a_val)
 Set prevent double submission. More...
 
 getPreventDoubleSubmission ()
 Get prevent double submission. More...
 
 getHTML ()
 Get HTML. More...
 
 getContent ()
 Get Content. More...
 

Static Public Member Functions

static addJavaScript ($add_form_loader=false, $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 ($id, $content)
 Adds onload code to the template. More...
 

Protected Attributes

 $has_errors = false
 
 $is_async = true
 
- Protected Attributes inherited from ilPropertyFormGUI
 $mode = "std"
 
 $check_input_called = false
 
 $disable_standard_message = false
 
 $top_anchor = "il_form_top"
 
 $titleicon = false
 
 $description = ""
 
 $tbl_width = false
 
 $show_top_buttons = true
 
 $hide_labels = false
 
- Protected Attributes inherited from ilFormGUI
 $formaction
 
 $multipart = false
 
 $keepopen = false
 
 $opentag = true
 
 $id
 
 $name
 
 $prevent_double_submission = false
 

Static Protected Attributes

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

Additional Inherited Members

- Protected Member Functions inherited from ilPropertyFormGUI
 hideRequired ($a_type)
 
 rebuildUploadedFiles ()
 try to rebuild files More...
 

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 10 of file class.ilAsyncPropertyFormGUI.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

References $config, $is_async, setAsync(), and setName().

36  {
37  parent::__construct();
38 
39  foreach($config as $key=>$value) {
40  $setterMethod = "set".ucfirst($key);
41  if(method_exists($this, $setterMethod)) {
42  $setterMethod($value);
43  }
44  }
45 
46  $this->setAsync($is_async);
47  $this->setName(self::$default_from_name);
48  }
+ Here is the call graph for this function:

Member Function Documentation

◆ addJavaScript()

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

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

Parameters
bool$add_form_loader
null$js_base_path

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

References $DIC, $js_path, and $tpl.

Referenced by ilObjStudyProgrammeTreeGUI\initAsyncUIElements().

58  {
59  global $DIC;
60  $tpl = $DIC['tpl'];
61 
62  $js_path = (isset($js_base_path))? $js_base_path : self::$js_path;
63 
64  $tpl->addJavaScript($js_path.'ilAsyncPropertyFormGUI.js');
65 
66  $global_config = "$.ilAsyncPropertyForm.global_config.error_message_template = '".self::getErrorMessageTemplate()."'; $.ilAsyncPropertyForm.global_config.async_form_name = '".self::$default_from_name."';";
67  self::addOnLoadCode('global_config', $global_config);
68 
69  if($add_form_loader) {
70  self::addOnLoadCode('form_loader', '$("body").ilAsyncPropertyForm();');
71  }
72  }
global $tpl
Definition: ilias.php:8
global $DIC
+ Here is the caller graph for this function:

◆ addOnLoadCode()

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

Adds onload code to the template.

Parameters
$id
$content

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

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

177  {
178  global $DIC;
179  $tpl = $DIC['tpl'];
180 
181  if(!isset(self::$js_on_load_added[$id])) {
182  $tpl->addOnLoadCode($content);
183  self::$js_on_load_added[$id] = $content;
184  }
185  }
global $tpl
Definition: ilias.php:8
global $DIC

◆ checkInput()

ilAsyncPropertyFormGUI::checkInput ( )

Saves the change input result into a property.

Returns
bool

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

References $result.

Referenced by getErrors().

80  {
81  $result = parent::checkInput();
82  $this->has_errors = $result;
83 
84  return $result;
85  }
$result
+ Here is the caller graph for this function:

◆ cloneForm()

ilAsyncPropertyFormGUI::cloneForm ( ilPropertyFormGUI  $form_to_clone)

Copies form items, buttons and properties from another form.

Parameters
ilPropertyFormGUI$form_to_clone
Returns
$this
Exceptions
ilException

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

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

147  {
148  if(count($this->getItems()) > 0) {
149  throw new ilException("You cannot clone into a already filled form!");
150  }
151 
152  $reflect = new ReflectionClass($this);
153  $properties = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
154 
155  foreach($properties as $property) {
156  $this->{$property->getName()} = $property->getValue($form_to_clone);
157  }
158 
159  foreach($form_to_clone->getItems() as $item) {
160  $this->addItem($item);
161  }
162 
163  foreach($form_to_clone->getCommandButtons() as $button) {
164  $this->addCommandButton($button['cmd'], $button['text']);
165  }
166 
167  return $this;
168  }
Base class for ILIAS Exception handling.
addItem($a_item)
Add Item (Property, SectionHeader).
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
getCommandButtons()
Return all Command buttons.
+ Here is the call graph for this function:

◆ getDefaultFormName()

ilAsyncPropertyFormGUI::getDefaultFormName ( )
Returns
mixed

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

242  {
243  return self::$default_from_name;
244  }

◆ getErrorMessageTemplate()

static ilAsyncPropertyFormGUI::getErrorMessageTemplate ( )
static

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

Returns
string

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

References $DIC, $lng, $tpl, and ilUtil\getImagePath().

123  {
124  global $DIC;
125  $lng = $DIC['lng'];
126 
127  $tpl = new ilTemplate("tpl.property_form.html", true, true, "Services/Form");
128 
129  $tpl->setCurrentBlock("alert");
130  $tpl->setVariable("IMG_ALERT", ilUtil::getImagePath("icon_alert.svg"));
131  $tpl->setVariable("ALT_ALERT", $lng->txt("alert"));
132  $tpl->setVariable("TXT_ALERT", "[TXT_ALERT]");
133  $tpl->parseCurrentBlock();
134  $content = trim($tpl->get("alert"));
135 
136  return $content;
137  }
global $tpl
Definition: ilias.php:8
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
global $lng
Definition: privfeed.php:17
global $DIC
+ 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 92 of file class.ilAsyncPropertyFormGUI.php.

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

92  {
93  if(!$this->check_input_called) {
94  $this->checkInput();
95  }
96 
97  $errors = array();
98  foreach($this->getItems() as $item) {
99  // We call method exists as there are items in the form (ilFormSectionHeaderGUI)
100  // that do not have alerts. (#16956)
101  if(method_exists($item, "getAlert") && $item->getAlert() != "") {
102  $errors[] = array('key'=>$item->getFieldId(), 'message'=>$item->getAlert());
103  }
104  }
105  return $errors;
106  }
checkInput()
Saves the change input result into a property.
Create styles array
The data for the language used.
$errors
+ Here is the call graph for this function:

◆ getHTML()

ilAsyncPropertyFormGUI::getHTML ( )

Returns the rendered form content.

Returns
string

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

References isAsync().

192  {
193  self::addJavaScript($this->isAsync());
194 
195  return parent::getHTML();
196  }
+ Here is the call graph for this function:

◆ getJsPath()

ilAsyncPropertyFormGUI::getJsPath ( )
Returns
mixed

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

References $js_path.

228  {
229  return $this->js_path;
230  }

◆ hasErrors()

ilAsyncPropertyFormGUI::hasErrors ( )

Return if there were errors on the last checkInput call.

Returns
boolean

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

References $has_errors.

◆ isAsync()

ilAsyncPropertyFormGUI::isAsync ( )
Returns
boolean

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

References $is_async.

Referenced by getHTML(), and setFormAction().

+ Here is the caller graph for this function:

◆ isSubmitted()

ilAsyncPropertyFormGUI::isSubmitted ( )

Checks if the form was submitted.

Returns
bool

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

References $_POST.

203  {
204  if(isset($_POST['cmd'])) {
205  return true;
206  }
207  return false;
208  }
$_POST["username"]

◆ setAsync()

ilAsyncPropertyFormGUI::setAsync (   $is_async)
Parameters
boolean$is_async

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

References $is_async.

Referenced by __construct().

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

◆ setFormAction()

ilAsyncPropertyFormGUI::setFormAction (   $a_formaction)

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

Parameters
string$a_formaction

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

References isAsync().

217  {
218  if($this->isAsync()) {
219  $a_formaction .= "&cmdMode=asynch";
220  }
221 
222  $this->formaction = $a_formaction;
223  }
+ Here is the call graph for this function:

◆ setJsPath()

ilAsyncPropertyFormGUI::setJsPath (   $js_path)
Parameters
mixed$js_path

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

References $js_path.

235  {
236  $this->js_path = $js_path;
237  }

◆ setName()

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

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

Referenced by __construct().

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

Field Documentation

◆ $default_from_name

ilAsyncPropertyFormGUI::$default_from_name = "async_form"
staticprotected

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

◆ $has_errors

ilAsyncPropertyFormGUI::$has_errors = false
protected

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

Referenced by hasErrors().

◆ $is_async

ilAsyncPropertyFormGUI::$is_async = true
protected

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

Referenced by __construct(), isAsync(), and setAsync().

◆ $js_on_load_added

ilAsyncPropertyFormGUI::$js_on_load_added = array()
staticprotected

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

◆ $js_path

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

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

Referenced by addJavaScript(), getJsPath(), and setJsPath().


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