ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCharSelectorConfig Class Reference
+ Collaboration diagram for ilCharSelectorConfig:

Public Member Functions

 __construct ($a_context=self::CONTEXT_NONE)
 Constructor.
 getContext ()
 get the context of the configuration (the context is set at initialisation and can't be changed)
 setAvailability ($a_availability)
 set the availability of the selector
 getAvailability ()
 get the availability of the selector
 setAddedBlocks ($a_blocks=array())
 set the added unicode blocks
 getAddedBlocks ()
 set the added unicode blocks
 setCustomItems ($a_items= '')
 set the custom items
 getCustomItems ()
 set the custom items
 setDefinition ($a_definition= '')
 getDefinition ()
 Set the definition of the available characters.
 getBlockOptions ()
 get the options for a block selection
 getBlockTitle ($a_block_name)
 Get the title of a unicode block for display or selection A translation is used if it exists.
 getCharPages ()
 Get the character pages.

Static Public Member Functions

static _getCurrentConfig (ilObjTest $a_test_obj=null)
 Get the configuration that should be used for the current selector.

Data Fields

const INACTIVE = 0
 Availabilities INACTIVE/INHERIT corresponds to an unconfigured selector (no database entries)
const INHERIT = 0
const ENABLED = 1
const DISABLED = 2
const CONTEXT_NONE = ''
 Configuration contexts.
const CONTEXT_ADMIN = 'admin'
const CONTEXT_USER = 'user'
const CONTEXT_TEST = 'test'

Static Public Attributes

static $unicode_blocks

Private Member Functions

 extractUnicodeBlock ($a_item= '')
 Extract the unicode block name from a definition item.
 getItemCodepoint ($a_item)
 get the unicode index of an item
 getItemParsed ($a_item)
 replace unicode notations with their utf8 chars in a string
 getItemParsedCallback ($matches)
 callback for replacement of unicode notations

Private Attributes

 $context = self::CONTEXT_NONE
 $availability = self::INHERIT
 $added_blocks = array()
 $custom_items = array()

Detailed Description

Definition at line 4 of file ilCharSelectorConfig.php.

Constructor & Destructor Documentation

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

Constructor.

Parameters
stringcontext identifier
boolread the settings for the given context

Definition at line 284 of file ilCharSelectorConfig.php.

References CONTEXT_NONE.

{
switch($a_context)
{
case self::CONTEXT_ADMIN:
case self::CONTEXT_TEST:
case self::CONTEXT_USER:
$this->context = $a_context;
break;
default:
$this->context = self::CONTEXT_NONE;
}
}

Member Function Documentation

static ilCharSelectorConfig::_getCurrentConfig ( ilObjTest  $a_test_obj = null)
static

Get the configuration that should be used for the current selector.

Parameters
object(optional) current running test
Returns
ilCharSelectorConfig

Definition at line 303 of file ilCharSelectorConfig.php.

References $ilSetting, $ilUser, CONTEXT_ADMIN, CONTEXT_TEST, CONTEXT_USER, INACTIVE, and INHERIT.

Referenced by ilCharSelectorGUI\_getCurrentGUI().

{
// check configuration from administration settings
$admin_config = new self(self::CONTEXT_ADMIN, true);
$admin_config->setAvailability($ilSetting->get('char_selector_availability'));
$admin_config->setDefinition($ilSetting->get('char_selector_definition'));
if ($admin_config->getAvailability() == self::INACTIVE)
{
// a globally inactive selector can't be overwritten by users or tests
return $admin_config;
}
// a test configuration is relevant for test runs
if (isset($a_test_obj))
{
$test_config = new self(self::CONTEXT_TEST, false);
$test_config->setAvailability($a_test_obj->getCharSelectorAvailability());
$test_config->setDefinition($a_test_obj->getCharSelectorDefinition());
if ($test_config->getAvailability() != self::INHERIT)
{
// a specific test configuration has precedence over user configuration
return $test_config;
}
}
// check configuration from user settings
$user_config = new self(self::CONTEXT_USER, true);
$user_config->setAvailability($ilUser->getPref('char_selector_availability'));
$user_config->setDefinition($ilUser->getPref('char_selector_definition'));
if ($user_config->getAvailability() != self::INHERIT)
{
// take user specific config
return $user_config;
}
else
{
// take admin config as default
return $admin_config;
}
}

+ Here is the caller graph for this function:

ilCharSelectorConfig::extractUnicodeBlock (   $a_item = '')
private

Extract the unicode block name from a definition item.

Parameters
stringdefinition item
Returns
string unicode block name

Definition at line 540 of file ilCharSelectorConfig.php.

Referenced by setDefinition().

{
$a_item = trim($a_item);
$matches = array();
if (preg_match('/^\[(.+)\]$/', $a_item, $matches))
{
$block_name = $matches[1];
if ($block_name == 'all'
or in_array($block_name, array_keys(self::$unicode_blocks)))
{
return $block_name;
}
}
return '';
}

+ Here is the caller graph for this function:

ilCharSelectorConfig::getAddedBlocks ( )

set the added unicode blocks

Returns
array list of block names

Definition at line 408 of file ilCharSelectorConfig.php.

References $added_blocks.

{
}
ilCharSelectorConfig::getAvailability ( )

get the availability of the selector

Returns
int availability

Definition at line 382 of file ilCharSelectorConfig.php.

References $availability.

{
}
ilCharSelectorConfig::getBlockOptions ( )

get the options for a block selection

Returns
array options

Definition at line 496 of file ilCharSelectorConfig.php.

References $lng, $options, and getBlockTitle().

{
global $lng;
$options = array(
'' => $lng->txt('please_select'),
'all' => $lng->txt('char_selector_unicode_all')
);
foreach (array_keys(self::$unicode_blocks) as $block_name)
{
$options[$block_name] = $this->getBlockTitle($block_name);
}
return $options;
}

+ Here is the call graph for this function:

ilCharSelectorConfig::getBlockTitle (   $a_block_name)

Get the title of a unicode block for display or selection A translation is used if it exists.

Parameters
stringblock name
Returns
string title

Definition at line 519 of file ilCharSelectorConfig.php.

References $lng.

Referenced by getBlockOptions(), and getCharPages().

{
global $lng;
$langvar = 'char_selector_unicode_'. $a_block_name;
if ($lng->txt($langvar) != '-'.$langvar.'-' )
{
return $lng->txt($langvar);
}
else
{
return self::$unicode_blocks[$a_block_name][0];
}
}

+ Here is the caller graph for this function:

ilCharSelectorConfig::getCharPages ( )

Get the character pages.

Returns
array [["page1", "A", "BC", [123,456], ...], ["page2], "X", ...], ...]

Definition at line 562 of file ilCharSelectorConfig.php.

References $added_blocks, $lng, getBlockTitle(), getItemCodepoint(), and getItemParsed().

{
global $lng;
$pages = array();
// add custom block
//
$page = array($lng->txt('char_selector_custom_items'));
foreach ($this->custom_items as $item)
{
if (strpos($item, '-') > 0)
{
// handle range
$subitems = explode('-', $item);
$start = $this->getItemCodepoint($subitems[0]);
$end = $this->getItemCodepoint($subitems[1]);
array_push($page, array($start, $end));
}
else
{
// handle normal item
array_push($page, $this->getItemParsed($item));
}
}
if (count($page) > 1)
{
array_push($pages, $page);
}
// add unicode blocks
//
$blocks = in_array('all', $this->added_blocks) ?
array_keys(self::$unicode_blocks) :
$this->added_blocks;
foreach ($blocks as $block_name)
{
$start = hexdec(self::$unicode_blocks[$block_name][1]);
$end = hexdec(self::$unicode_blocks[$block_name][2]);
$page = array($this->getBlockTitle($block_name), array($start, $end));
array_push($pages, $page);
}
return $pages;
}

+ Here is the call graph for this function:

ilCharSelectorConfig::getContext ( )

get the context of the configuration (the context is set at initialisation and can't be changed)

Returns
string context identifier

Definition at line 352 of file ilCharSelectorConfig.php.

References $context.

{
}
ilCharSelectorConfig::getCustomItems ( )

set the custom items

Returns
array list of strings
See Also
self::setDefinition() for item syntax

Definition at line 428 of file ilCharSelectorConfig.php.

{
return implode(' ', $this->custom_items);
}
ilCharSelectorConfig::getDefinition ( )

Set the definition of the available characters.

Returns
string
See Also
self::setDefinition()

Definition at line 481 of file ilCharSelectorConfig.php.

{
$definition = implode(' ', $this->custom_items);
foreach($this->added_blocks as $block_name)
{
$definition = $definition . ' [' . $block_name . ']';
}
return trim($definition);
}
ilCharSelectorConfig::getItemCodepoint (   $a_item)
private

get the unicode index of an item

Parameters
string$a_item

Definition at line 614 of file ilCharSelectorConfig.php.

References utf8ToCodepoint().

Referenced by getCharPages().

{
if (preg_match('/^[uU]\+[0-9a-fA-F]+$/', $a_item))
{
return (int) hexdec(substr($a_item, 2));
}
else
{
//take the codepoint of the first character
require_once "include/Unicode/UtfNormalUtil.php";
return (int) utf8ToCodepoint($a_item);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCharSelectorConfig::getItemParsed (   $a_item)
private

replace unicode notations with their utf8 chars in a string

Parameters
string$a_item
Returns
string parsed string

Definition at line 633 of file ilCharSelectorConfig.php.

Referenced by getCharPages().

{
return preg_replace_callback(
'/[uU]\+[0-9a-fA-F]+/',
array($this,'getItemParsedCallback'),
$a_item
);
}

+ Here is the caller graph for this function:

ilCharSelectorConfig::getItemParsedCallback (   $matches)
private

callback for replacement of unicode notations

Parameters
arraypreg matches
Returns
string replacement string

Definition at line 647 of file ilCharSelectorConfig.php.

References codepointToUtf8().

{
require_once "include/Unicode/UtfNormalUtil.php";
return codepointToUtf8(hexdec(substr($matches[0], 2)));
}

+ Here is the call graph for this function:

ilCharSelectorConfig::setAddedBlocks (   $a_blocks = array())

set the added unicode blocks

Parameters
arraylist of block names

Definition at line 391 of file ilCharSelectorConfig.php.

{
$this->added_blocks = array();
foreach ($a_blocks as $block_name)
{
if ($block_name == "all" or
in_array($block_name, array_keys(self::$unicode_blocks)))
{
array_push($this->added_blocks, $block_name);
}
}
}
ilCharSelectorConfig::setAvailability (   $a_availability)

set the availability of the selector

Parameters
intavailability

Definition at line 362 of file ilCharSelectorConfig.php.

References INHERIT.

{
switch((int) $a_availability)
{
case self::INACTIVE:
case self::INHERIT:
case self::ENABLED:
case self::DISABLED:
$this->availability = (int) $a_availability;
break;
default:
$this->availability = self::INHERIT;
}
}
ilCharSelectorConfig::setCustomItems (   $a_items = '')

set the custom items

Parameters
arraylist of strings
See Also
self::setDefinition() for item syntax

Definition at line 418 of file ilCharSelectorConfig.php.

{
$this->custom_items = explode(' ', $a_items);
}
ilCharSelectorConfig::setDefinition (   $a_definition = '')

Definition at line 449 of file ilCharSelectorConfig.php.

References extractUnicodeBlock().

{
// first reset all previous settings
$this->added_blocks = array();
$this->custom_items = array();
// set the default definition to all unicode blocks
if (trim($a_definition) == '')
{
$a_definition = "[all]";
}
// analyze definition items
$items = explode(' ', $a_definition);
foreach ($items as $item)
{
if (strlen($block_name = $this->extractUnicodeBlock($item)))
{
array_push($this->added_blocks, $block_name);
}
else if ($item != '')
{
array_push($this->custom_items, trim($item));
}
}
}

+ Here is the call graph for this function:

Field Documentation

ilCharSelectorConfig::$added_blocks = array()
private

Definition at line 271 of file ilCharSelectorConfig.php.

Referenced by getAddedBlocks(), and getCharPages().

ilCharSelectorConfig::$availability = self::INHERIT
private

Definition at line 266 of file ilCharSelectorConfig.php.

Referenced by getAvailability().

ilCharSelectorConfig::$context = self::CONTEXT_NONE
private

Definition at line 261 of file ilCharSelectorConfig.php.

Referenced by getContext().

ilCharSelectorConfig::$custom_items = array()
private

Definition at line 276 of file ilCharSelectorConfig.php.

ilCharSelectorConfig::$unicode_blocks
static

Definition at line 27 of file ilCharSelectorConfig.php.

const ilCharSelectorConfig::CONTEXT_NONE = ''

Configuration contexts.

Definition at line 18 of file ilCharSelectorConfig.php.

Referenced by __construct().

const ilCharSelectorConfig::DISABLED = 2

Definition at line 13 of file ilCharSelectorConfig.php.

Referenced by ilCharSelectorGUI\addFormProperties().

const ilCharSelectorConfig::INACTIVE = 0

Availabilities INACTIVE/INHERIT corresponds to an unconfigured selector (no database entries)

Definition at line 10 of file ilCharSelectorConfig.php.

Referenced by _getCurrentConfig(), and ilCharSelectorGUI\addFormProperties().

const ilCharSelectorConfig::INHERIT = 0

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