Public Member Functions | Protected Attributes | Private Attributes

ilPropertyFormGUI Class Reference
[Services/Form]

This class represents a property form user interface. More...

Inheritance diagram for ilPropertyFormGUI:
Collaboration diagram for ilPropertyFormGUI:

Public Member Functions

 ilPropertyFormGUI ()
 Constructor.
 setTableWidth ($a_width)
 Set table width.
 getTableWidth ()
 get table width
 setMode ($a_mode)
 Set Mode ('std', 'subform').
 getMode ()
 Get Mode ('std', 'subform').
 setTitle ($a_title)
 Set Title.
 getTitle ()
 Get Title.
 setSubformMode ($a_subformmode)
 Set Subform Mode.
 getSubformMode ()
 Get Subform Mode.
 setTitleIcon ($a_titleicon)
 Set TitleIcon.
 getTitleIcon ()
 Get TitleIcon.
 addItem ($a_item)
 Add Item (Property, SectionHeader).
 removeItemByPostVar ($a_post_var)
 Remove Item.
 getItemByPostVar ($a_post_var)
 Get Item by POST variable.
 setItems ($a_items)
 Set Items.
 getItems ()
 Get Items.
 setValuesByArray ($a_values)
 Set form values from an array.
 setValuesByPost ()
 Set form values from POST values.
 checkInput ()
 Check Post Input.
 getInput ($a_post_var)
 addCustomProperty ($a_title, $a_html, $a_info="", $a_alert="", $a_required=false)
 Add a custom property.
 addCommandButton ($a_cmd, $a_text)
 Add Command button.
 getContent ()
 Get Content.
 insertItem ($item, $a_sub_item=false)

Protected Attributes

 $mode = "std"
 $check_input_called = false
 $subformmode = "bottom"

Private Attributes

 $buttons = array()
 $items = array()

Detailed Description

This class represents a property form user interface.

Author:
Alex Killing <alex.killing@gmx.de>
Version:
$Id$

Definition at line 52 of file class.ilPropertyFormGUI.php.


Member Function Documentation

ilPropertyFormGUI::addCommandButton ( a_cmd,
a_text 
)

Add Command button.

Parameters:
string Command
string Text

Definition at line 328 of file class.ilPropertyFormGUI.php.

        {
                $this->buttons[] = array("cmd" => $a_cmd, "text" => $a_text);
        }

ilPropertyFormGUI::addCustomProperty ( a_title,
a_html,
a_info = "",
a_alert = "",
a_required = false 
)

Add a custom property.

Parameters:
string Title
string HTML.
string Info text.
string Alert text.
boolean Required field. (Default false)

Definition at line 313 of file class.ilPropertyFormGUI.php.

        {
                $this->properties[] = array ("type" => "custom",
                        "title" => $a_title,
                        "html" => $a_html,
                        "info" => $a_info);
        }

ilPropertyFormGUI::addItem ( a_item  ) 

Add Item (Property, SectionHeader).

Parameters:
object $a_property Item object

Definition at line 181 of file class.ilPropertyFormGUI.php.

        {
                return $this->items[] = $a_item;
        }

ilPropertyFormGUI::checkInput (  ) 

Check Post Input.

This method also strips slashes and html from input and sets the alert texts for the items, if the input was not ok.

Returns:
boolean ok true/false

Definition at line 271 of file class.ilPropertyFormGUI.php.

References $ok.

        {
                if ($this->check_input_called)
                {
                        die ("Error: ilPropertyFormGUI->checkInput() called twice.");
                }
                
                $ok = true;
                foreach($this->items as $item)
                {
                        $item_ok = $item->checkInput();
                        if(!$item_ok)
                        {
                                $ok = false;
                        }
                }
                
                $this->check_input_called = true;
                
                return $ok;
        }

ilPropertyFormGUI::getContent (  ) 

Get Content.

Reimplemented from ilFormGUI.

Definition at line 336 of file class.ilPropertyFormGUI.php.

References $lng, $tpl, getMode(), getSubformMode(), getTableWidth(), getTitle(), getTitleIcon(), and insertItem().

        {
                global $lng, $tpl;
                
                $this->tpl = new ilTemplate("tpl.property_form.html", true, true, "Services/Form");

                // title icon
                if ($this->getTitleIcon() != "" && @is_file($this->getTitleIcon()))
                {
                        $this->tpl->setCurrentBlock("title_icon");
                        $this->tpl->setVariable("IMG_ICON", $this->getTitleIcon());
                        $this->tpl->parseCurrentBlock();
                }

                // title
                if ($this->getTitle() != "")
                {
                        $this->tpl->setCurrentBlock("header");
                        $this->tpl->setVariable("TXT_TITLE", $this->getTitle());
                        if ($this->getSubformMode() == "right")
                        {
                                $this->tpl->setVariable("HEAD_COLSPAN", "3");
                        }
                        else
                        {
                                $this->tpl->setVariable("HEAD_COLSPAN", "2");
                        }               
                        $this->tpl->parseCurrentBlock();
                }
                $this->tpl->touchBlock("item");
                
                // properties
                $this->required_text = false;
                foreach($this->items as $item)
                {
                        $this->insertItem($item);
                }

                // required
                if ($this->required_text)
                {
                        $this->tpl->setCurrentBlock("required_text");
                        $this->tpl->setVariable("TXT_REQUIRED", $lng->txt("required_field"));
                        $this->tpl->parseCurrentBlock();                        
                }
                
                // command buttons
                foreach($this->buttons as $button)
                {
                        $this->tpl->setCurrentBlock("cmd");
                        $this->tpl->setVariable("CMD", $button["cmd"]);
                        $this->tpl->setVariable("CMD_TXT", $button["text"]);
                        $this->tpl->parseCurrentBlock();
                }
                
                if ($required_text || count($this->buttons) > 0)
                {
                        $this->tpl->setCurrentBlock("commands");
                        $this->tpl->parseCurrentBlock();
                }
                
                if ($this->getMode() == "subform")
                {
                        $this->tpl->touchBlock("sub_table");
                }
                else
                {
                        $this->tpl->touchBlock("std_table");
                        $this->tpl->setVariable('STD_TABLE_WIDTH',$this->getTableWidth());
                }
                
                return $this->tpl->get();
        }

Here is the call graph for this function:

ilPropertyFormGUI::getInput ( a_post_var  ) 

Definition at line 293 of file class.ilPropertyFormGUI.php.

        {
                // this check ensures, that checkInput has been called (incl. stripSlashes())
                if (!$this->check_input_called)
                {
                        die ("Error: ilPropertyFormGUI->getInput() called without calling checkInput() first.");
                }
                
                return $_POST[$a_post_var];
        }

ilPropertyFormGUI::getItemByPostVar ( a_post_var  ) 

Get Item by POST variable.

Parameters:
string $a_postvar Post Var

Definition at line 207 of file class.ilPropertyFormGUI.php.

        {
                foreach ($this->items as $key => $item)
                {
                        if ($item->getPostVar() == $a_post_var)
                        {
                                return $this->items[$key];
                        }
                }
                
                return false;
        }

ilPropertyFormGUI::getItems (  ) 

Get Items.

Returns:
array array of item objects

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

        {
                return $this->items;
        }

ilPropertyFormGUI::getMode (  ) 

Get Mode ('std', 'subform').

Returns:
string Mode ('std', 'subform')

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

Referenced by getContent(), and insertItem().

        {
                return $this->mode;
        }

Here is the caller graph for this function:

ilPropertyFormGUI::getSubformMode (  ) 

Get Subform Mode.

("bottom" | "right")

Returns:
string Subform Mode

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

Referenced by getContent(), and insertItem().

        {
                return $this->subformmode;
        }

Here is the caller graph for this function:

ilPropertyFormGUI::getTableWidth (  )  [final]

get table width

public

Definition at line 91 of file class.ilPropertyFormGUI.php.

Referenced by getContent().

        {
                return $this->tbl_width;
        }

Here is the caller graph for this function:

ilPropertyFormGUI::getTitle (  ) 

Get Title.

Returns:
string Title

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

Referenced by getContent().

        {
                return $this->title;
        }

Here is the caller graph for this function:

ilPropertyFormGUI::getTitleIcon (  ) 

Get TitleIcon.

Returns:
string TitleIcon

Definition at line 171 of file class.ilPropertyFormGUI.php.

Referenced by getContent().

        {
                return $this->titleicon;
        }

Here is the caller graph for this function:

ilPropertyFormGUI::ilPropertyFormGUI (  ) 

Constructor.

Parameters:
 

Definition at line 65 of file class.ilPropertyFormGUI.php.

References $lng, and ilFormGUI::ilFormGUI().

        {
                global $lng;
                
                $lng->loadLanguageModule("form");
                parent::ilFormGUI();
        }

Here is the call graph for this function:

ilPropertyFormGUI::insertItem ( item,
a_sub_item = false 
)

Definition at line 410 of file class.ilPropertyFormGUI.php.

References $lng, $tpl, ilUtil::getImagePath(), getMode(), getSubformMode(), and ilFormGUI::setMultipart().

Referenced by getContent().

        {
                global $tpl, $lng;
                
                $item->insert($this->tpl);
                if ($item->getType() == "file" || $item->getType() == "image_file")
                {
                        $this->setMultipart(true);
                }
                
                if ($item->getType() != "section_header")
                {
                        // info text
                        if ($item->getInfo() != "")
                        {
                                $tpl->addJavaScript("Services/JavaScript/js/Basic.js");
                                $tpl->addJavaScript("Services/Form/js/ServiceForm.js");
                                $this->tpl->setCurrentBlock("description");
                                //$this->tpl->setVariable("IMG_INFO",
                                //      ilUtil::getImagePath("icon_info_s.gif"));
                                //$this->tpl->setVariable("ALT_INFO",
                                //      $lng->txt("info_short"));
                                $this->tpl->setVariable("PROPERTY_DESCRIPTION",
                                        $item->getInfo());
                                $this->tpl->parseCurrentBlock();
                        }

                        if ($this->getMode() == "subform")
                        {
                                // required
                                if ($item->getType() != "non_editable_value")
                                {
                                        if ($item->getRequired())
                                        {
                                                $this->tpl->touchBlock("sub_required");
                                                $this->required_text = true;
                                        }
                                }
                                $this->tpl->setCurrentBlock("sub_prop_start");
                                $this->tpl->setVariable("PROPERTY_TITLE", $item->getTitle());
                                if ($item->getType() != "non_editable_value")
                                {
                                        $this->tpl->setVariable("LAB_ID", $item->getFieldId());
                                }
                                if ($this->getSubformMode() != "right")
                                {
                                        $this->tpl->setVariable("PS_STYLE", "padding-left:40px; vertical-align:top;");
                                }
                                else
                                {
                                        $this->tpl->setVariable("PS_STYLE", "vertical-align:top;");
                                }
                                $this->tpl->parseCurrentBlock();
                        }
                        else
                        {
                                // required
                                if ($item->getType() != "non_editable_value")
                                {
                                        if ($item->getRequired())
                                        {
                                                $this->tpl->touchBlock("required");
                                                $this->required_text = true;
                                        }
                                }
                                $this->tpl->setCurrentBlock("std_prop_start");
                                $this->tpl->setVariable("PROPERTY_TITLE", $item->getTitle());
                                if ($item->getType() != "non_editable_value")
                                {
                                        $this->tpl->setVariable("LAB_ID", $item->getFieldId());
                                }
                                $this->tpl->parseCurrentBlock();
                        }
                        
                        // alert
                        if ($item->getType() != "non_editable_value" && $item->getAlert() != "")
                        {
                                $this->tpl->setCurrentBlock("alert");
                                $this->tpl->setVariable("IMG_ALERT",
                                        ilUtil::getImagePath("icon_alert_s.gif"));
                                $this->tpl->setVariable("ALT_ALERT",
                                        $lng->txt("alert"));
                                $this->tpl->setVariable("TXT_ALERT",
                                        $item->getAlert());
                                $this->tpl->parseCurrentBlock();
                        }
                        
                        $this->tpl->setCurrentBlock("prop");
                        
                        // subitems
                        $sf = "";
                        if ($item->getType() != "non_editable_value")
                        {
                                $sf = $item->getSubForm();
                        }

                        if ($this->getSubformMode() == "right")
                        {
                                if ($sf != "")
                                {
                                        $this->tpl->setVariable("PROP_SUB_FORM",
                                                '</td><td class="option_value">'.$sf);
                                }
                                else
                                {
                                        if ($this->getMode() != "subform")
                                        {
                                                $this->tpl->setVariable("PROP_SUB_FORM",
                                                        '</td><td class="option_value">&nbsp;');
                                        }
                                }
                        }
                        else
                        {
                                $this->tpl->setVariable("PROP_SUB_FORM", $item->getSubForm());
                        }

                        $this->tpl->parseCurrentBlock();
                }
                
                $this->tpl->touchBlock("item");
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilPropertyFormGUI::removeItemByPostVar ( a_post_var  ) 

Remove Item.

Parameters:
string $a_postvar Post Var

Definition at line 191 of file class.ilPropertyFormGUI.php.

        {
                foreach ($this->items as $key => $item)
                {
                        if ($item->getPostVar() == $a_post_var)
                        {
                                unset($this->items[$key]);
                        }
                }
        }

ilPropertyFormGUI::setItems ( a_items  ) 

Set Items.

Parameters:
array $a_items array of item objects

Definition at line 225 of file class.ilPropertyFormGUI.php.

        {
                $this->items = $a_items;
        }

ilPropertyFormGUI::setMode ( a_mode  ) 

Set Mode ('std', 'subform').

Parameters:
string $a_mode Mode ('std', 'subform')

Definition at line 101 of file class.ilPropertyFormGUI.php.

        {
                $this->mode = $a_mode;
        }

ilPropertyFormGUI::setSubformMode ( a_subformmode  ) 

Set Subform Mode.

("bottom" | "right")

Parameters:
string $a_subformmode Subform Mode

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

        {
                $this->subformmode = $a_subformmode;
        }

ilPropertyFormGUI::setTableWidth ( a_width  )  [final]

Set table width.

public

Parameters:
string table width

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

        {
                $this->tbl_width = $a_width;
        }

ilPropertyFormGUI::setTitle ( a_title  ) 

Set Title.

Parameters:
string $a_title Title

Definition at line 121 of file class.ilPropertyFormGUI.php.

        {
                $this->title = $a_title;
        }

ilPropertyFormGUI::setTitleIcon ( a_titleicon  ) 

Set TitleIcon.

Parameters:
string $a_titleicon TitleIcon

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

        {
                $this->titleicon = $a_titleicon;
        }

ilPropertyFormGUI::setValuesByArray ( a_values  ) 

Set form values from an array.

Parameters:
array $a_values Value array (key is post variable name, value is value)

Definition at line 245 of file class.ilPropertyFormGUI.php.

        {
                foreach($this->items as $item)
                {
                        $item->setValueByArray($a_values);
                }
        }

ilPropertyFormGUI::setValuesByPost (  ) 

Set form values from POST values.

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

        {
                foreach($this->items as $item)
                {
                        $item->setValueByArray($_POST);
                }
        }


Field Documentation

ilPropertyFormGUI::$buttons = array() [private]

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

ilPropertyFormGUI::$check_input_called = false [protected]

Definition at line 57 of file class.ilPropertyFormGUI.php.

ilPropertyFormGUI::$items = array() [private]

Definition at line 55 of file class.ilPropertyFormGUI.php.

ilPropertyFormGUI::$mode = "std" [protected]

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

ilPropertyFormGUI::$subformmode = "bottom" [protected]

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


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