ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCharSelectorGUI Class Reference

This shows a character selector. More...

+ Collaboration diagram for ilCharSelectorGUI:

Public Member Functions

 __construct ($a_context=ilCharSelectorConfig::CONTEXT_NONE)
 Constructor.
 setConfig (ilCharSelectorConfig $a_config)
 Set the configuraton object.
 getConfig ()
 Get the configuraton object.
 addFormProperties (ilPropertyFormGUI $a_form)
 add the configuration elements to a property form
 setFormValues (ilPropertyFormGUI $a_form)
 Set the values in a property form based on the configuration.
 getFormValues (ilPropertyFormGUI $a_form)
 Set the configuration based on the values of a property form.
 addToPage ()
 Adds the the character selector to the ilias page Initializes the selector according to the state saved in the user session.
 getSelectorHTML ()
 Get the HTML code of the selector panel.
 saveState ()
 Save the selector panel state in the user session (This keeps the panel state between page moves)
 executeCommand ()
 execute command

Static Public Member Functions

static _isAllowed ()
 Check if the CharSelector is allowed for the current GUI.
static _getCurrentGUI (ilObjTest $a_test_obj=null)
 Get the GUI that is used for the currently available selector (other GUI instances may exist for configuration in property forms)

Private Attributes

 $config = null
 $added_to_page = false

Static Private Attributes

static $allowed_guis
 list of command classes for which the char selector is allowed (can also be a parent class of the actual command class)
static $current_gui
 ilCharSelectorGUI instance used for the current selector

Detailed Description

This shows a character selector.

Definition at line 10 of file class.ilCharSelectorGUI.php.

Constructor & Destructor Documentation

ilCharSelectorGUI::__construct (   $a_context = ilCharSelectorConfig::CONTEXT_NONE)

Constructor.

Parameters
stringconfiguration context

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

{
$this->config = new ilCharSelectorConfig($a_context);
}

Member Function Documentation

static ilCharSelectorGUI::_getCurrentGUI ( ilObjTest  $a_test_obj = null)
static

Get the GUI that is used for the currently available selector (other GUI instances may exist for configuration in property forms)

Parameters
object(optional) current running test
Returns
object

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

References $current_gui, and ilCharSelectorConfig\_getCurrentConfig().

Referenced by ilPropertyFormGUI\getContent(), and ilTestPlayerAbstractGUI\populateCharSelector().

{
if (!isset(self::$current_gui))
{
self::$current_gui = new ilCharSelectorGUI();
self::$current_gui->setConfig(ilCharSelectorConfig::_getCurrentConfig($a_test_obj));
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilCharSelectorGUI::_isAllowed ( )
static

Check if the CharSelector is allowed for the current GUI.

Returns
boolean CharSelector is allowed

Definition at line 53 of file class.ilCharSelectorGUI.php.

References $ilCtrl.

Referenced by ilPropertyFormGUI\getContent().

{
global $ilCtrl;
// get the command class
// with correct case for checking parent classes
foreach ($ilCtrl->getCallHistory() as $call)
{
if ($call['mode'] == 'execComm')
{
$class = $call['class'];
}
}
// check the class and her parent classes
while ($class != false)
{
if (in_array($class, self::$allowed_guis))
{
return true;
}
$class = get_parent_class($class);
}
return false;
}

+ Here is the caller graph for this function:

ilCharSelectorGUI::addFormProperties ( ilPropertyFormGUI  $a_form)

add the configuration elements to a property form

Parameters
objectproperty form

Definition at line 119 of file class.ilCharSelectorGUI.php.

References $lng, $tpl, ilPropertyFormGUI\addItem(), ilCharSelectorConfig\CONTEXT_ADMIN, ilCharSelectorConfig\CONTEXT_TEST, ilCharSelectorConfig\CONTEXT_USER, ilCharSelectorConfig\DISABLED, ilCharSelectorConfig\ENABLED, ilCharSelectorConfig\INACTIVE, ilCharSelectorConfig\INHERIT, ilRadioOption\setInfo(), and ilFormPropertyGUI\setInfo().

Referenced by ilObjAdvancedEditingGUI\initCharSelectorSettingsForm().

{
global $lng;
$lng->loadLanguageModule('adve');
require_once ('Services/UIComponent/CharSelector/classes/class.ilCharSelectorRadioGroupInputGUI.php');
$availability = new ilCharSelectorRadioGroupInputGUI($lng->txt('char_selector'), 'char_selector_availability');
$inactive = new ilRadioOption($lng->txt('char_selector_inactive'),ilCharSelectorConfig::INACTIVE);
$inactive->setInfo($lng->txt('char_selector_inactive_info_'.$this->config->getContext()));
$inherit = new ilRadioOption($lng->txt('char_selector_inherit'),ilCharSelectorConfig::INHERIT);
$inherit->setInfo($lng->txt('char_selector_inherit_info_'.$this->config->getContext()));
$enabled = new ilRadioOption($lng->txt('char_selector_enabled'), ilCharSelectorConfig::ENABLED);
$enabled->setInfo($lng->txt('char_selector_enabled_info_'.$this->config->getContext()));
$disabled = new ilRadioOption($lng->txt('char_selector_disabled'), ilCharSelectorConfig::DISABLED);
$disabled->setInfo($lng->txt('char_selector_disabled_info_'.$this->config->getContext()));
$blocks = new ilSelectInputGUI($lng->txt('char_selector_blocks'), 'char_selector_blocks');
$blocks->setInfo($lng->txt('char_selector_blocks_info'));
$blocks->setOptions($this->config->getBlockOptions());
$blocks->setMulti(true);
$enabled->addSubItem($blocks);
$custom_items = new ilTextAreaInputGUI($lng->txt('char_selector_custom_items'),'char_selector_custom_items');
$tpl = new ilTemplate("tpl.char_selector_custom_info.html", true, true, "Services/UIComponent/CharSelector");
$tpl->setVariable('1',$lng->txt('char_selector_custom_items_info1'));
$tpl->setVariable('2a',$lng->txt('char_selector_custom_items_info2a'));
$tpl->setVariable('2b',$lng->txt('char_selector_custom_items_info2b'));
$tpl->setVariable('3a',$lng->txt('char_selector_custom_items_info3a'));
$tpl->setVariable('3b',$lng->txt('char_selector_custom_items_info3b'));
$tpl->setVariable('4a',$lng->txt('char_selector_custom_items_info4a'));
$tpl->setVariable('4b',$lng->txt('char_selector_custom_items_info4b'));
$tpl->setVariable('5a',$lng->txt('char_selector_custom_items_info5a'));
$tpl->setVariable('5b',$lng->txt('char_selector_custom_items_info5b'));
$tpl->setVariable('6a',$lng->txt('char_selector_custom_items_info6a'));
$tpl->setVariable('6b',$lng->txt('char_selector_custom_items_info6b'));
$custom_items->setInfo($tpl->get());
$enabled->addSubItem($custom_items);
switch($this->config->getContext())
{
$availability->addOption($inactive);
$availability->addOption($enabled);
$availability->addOption($disabled);
$a_form->addItem($availability);
break;
$availability->addOption($inherit);
$availability->addOption($enabled);
$availability->addOption($disabled);
$a_form->addItem($availability);
break;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCharSelectorGUI::addToPage ( )

Adds the the character selector to the ilias page Initializes the selector according to the state saved in the user session.

See Also
self::saveState()

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

References $_SESSION, $ilCtrl, $lng, $tpl, getSelectorHTML(), and ilUtil\getStyleSheetLocation().

{
global $ilCtrl, $tpl, $lng;
// don't add the panel twice
if ($this->added_to_page)
{
return;
}
$lng->loadLanguageModule('adve');
// prepare the configuration for the js script
$this->jsconfig = new stdClass();
$this->jsconfig->pages = $this->config->getCharPages();
$this->jsconfig->ajax_url = $ilCtrl->getLinkTargetByClass("ilcharselectorgui", "saveState", "", true);
$this->jsconfig->open = (int) $_SESSION['char_selector_open'];
$this->jsconfig->current_page = (int) $_SESSION['char_selector_current_page'];
$this->jsconfig->current_subpage = (int) $_SESSION['char_selector_current_subpage'];
// provide texts to be dynamically rendered in the js script
$this->jstexts = new stdClass();
$this->jstexts->page = $lng->txt('page');
// add everything neded to the page
// addLightbox() is just used to add the panel template outside the body
// The panel template is added as <script> to be not included in the DOM by default
// It will be included by js below the main header when the selector is switched on
$tpl->addCss(ilUtil::getStyleSheetLocation('','char_selector_position.css','Services/UIComponent/CharSelector'));
$tpl->addCss(ilUtil::getStyleSheetLocation('','char_selector_style.css','Services/UIComponent/CharSelector'));
$tpl->addJavascript('./Services/UIComponent/CharSelector/js/ilCharSelector.js');
$tpl->addLightbox($this->getSelectorHTML(),2);
$tpl->addOnLoadCode('il.CharSelector.init('.json_encode($this->jsconfig).','.json_encode($this->jstexts).')');
$this->added_to_page = true;
}

+ Here is the call graph for this function:

ilCharSelectorGUI::executeCommand ( )

execute command

Definition at line 297 of file class.ilCharSelectorGUI.php.

References $cmd, and $ilCtrl.

{
global $ilCtrl;
$cmd = $ilCtrl->getCmd("saveState");
switch($cmd)
{
case 'saveState':
$this->$cmd();
break;
default:
return;
}
}
ilCharSelectorGUI::getConfig ( )

Get the configuraton object.

Returns
ilCharSelectorConfig

Definition at line 110 of file class.ilCharSelectorGUI.php.

References $config.

{
return $this->config;
}
ilCharSelectorGUI::getFormValues ( ilPropertyFormGUI  $a_form)

Set the configuration based on the values of a property form.

Parameters
objectproperty form
stringcontext of the form

Definition at line 195 of file class.ilCharSelectorGUI.php.

References ilPropertyFormGUI\getInput().

{
$this->config->setAvailability($a_form->getInput('char_selector_availability'));
$this->config->setAddedBlocks($a_form->getInput('char_selector_blocks'));
$this->config->setCustomItems($a_form->getInput('char_selector_custom_items'));
}

+ Here is the call graph for this function:

ilCharSelectorGUI::getSelectorHTML ( )

Get the HTML code of the selector panel.

Returns
string panel html code

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

References $lng, and $tpl.

Referenced by addToPage().

{
global $lng;
$tpl = new ilTemplate("tpl.char_selector_panel.html", true, true, "Services/UIComponent/CharSelector");
if (count($this->jsconfig->pages) > 1)
{
$index = 0;
foreach ($this->jsconfig->pages as $page)
{
$tpl->setCurrentBlock('page_option');
$tpl->setVariable("PAGE_INDEX", $index);
$tpl->setVariable("PAGE_NAME", $page[0]);
$tpl->parseCurrentBlock();
$index++;
}
$tpl->setVariable('TXT_PREVIOUS_PAGE', $lng->txt('previous'));
$tpl->setVariable('TXT_NEXT_PAGE', $lng->txt('next'));
$tpl->setVariable('TXT_PAGE', $lng->txt('page'));
}
$tpl->touchBlock('chars');
return '<script type="text/html" id="ilCharSelectorTemplate">'.$tpl->get().'</script>';
}

+ Here is the caller graph for this function:

ilCharSelectorGUI::saveState ( )

Save the selector panel state in the user session (This keeps the panel state between page moves)

See Also
self::addToPage()

Definition at line 279 of file class.ilCharSelectorGUI.php.

References $_GET, $_SESSION, and exit.

{
$_SESSION['char_selector_open'] = (int) $_GET['open'];
$_SESSION['char_selector_current_page'] = (int) $_GET['current_page'];
$_SESSION['char_selector_current_subpage'] = (int) $_GET['current_subpage'];
// debugging output (normally ignored by the js part)
echo json_encode(array(
'open' => $_SESSION['char_selector_open'],
'current_page' => $_SESSION['char_selector_current_page'],
'current_subpage' => $_SESSION['char_selector_current_subpage'],
));
}
ilCharSelectorGUI::setConfig ( ilCharSelectorConfig  $a_config)

Set the configuraton object.

Parameters
ilCharSelectorConfig

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

{
$this->config = $a_config;
}
ilCharSelectorGUI::setFormValues ( ilPropertyFormGUI  $a_form)

Set the values in a property form based on the configuration.

Parameters
objectproperty form
stringcontext of the form

Definition at line 182 of file class.ilCharSelectorGUI.php.

References ilPropertyFormGUI\getItemByPostVar().

{
$a_form->getItemByPostVar('char_selector_availability')->setValue($this->config->getAvailability());
$a_form->getItemByPostVar('char_selector_blocks')->setValue($this->config->getAddedBlocks());
$a_form->getItemByPostVar('char_selector_custom_items')->setValue($this->config->getCustomItems());
}

+ Here is the call graph for this function:

Field Documentation

ilCharSelectorGUI::$added_to_page = false
private

Definition at line 37 of file class.ilCharSelectorGUI.php.

ilCharSelectorGUI::$allowed_guis
staticprivate
Initial value:
array (
'assQuestionGUI',
'ilAssQuestionFeedbackEditingGUI',
'ilAssQuestionHintGUI',
'ilObjTestSettingsGeneralGUI',
'ilTestScoringGUI'
)

list of command classes for which the char selector is allowed (can also be a parent class of the actual command class)

Definition at line 16 of file class.ilCharSelectorGUI.php.

ilCharSelectorGUI::$config = null
private

Definition at line 32 of file class.ilCharSelectorGUI.php.

Referenced by getConfig().

ilCharSelectorGUI::$current_gui
staticprivate

ilCharSelectorGUI instance used for the current selector

Definition at line 27 of file class.ilCharSelectorGUI.php.

Referenced by _getCurrentGUI().


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