ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCharSelectorConfig.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
5 {
10  const INACTIVE = 0; // default for admin: deactivates the whole tool
11  const INHERIT = 0; // default for user and test: take the plattform default
12  const ENABLED = 1; // enable the selector
13  const DISABLED = 2; // disable the selector
14 
18  const CONTEXT_NONE = ''; // no context => no initialisation
19  const CONTEXT_ADMIN = 'admin'; // administrative settings
20  const CONTEXT_USER = 'user'; // user specific settings
21  const CONTEXT_TEST = 'test'; // test specific settings
22 
27  public static $unicode_blocks = array(
28  'basic_latin' => array('Basic Latin', '0020', '007F'), // only printing characters
29  'latin_1_supplement' => array('Latin-1 Supplement', '00A0', '00FF'), // only printing characters
30  'latin_extended_a' => array('Latin Extended-A', '0100', '017F'),
31  'latin_extended_b' => array('Latin Extended-B', '0180', '024F'),
32  'ipa_extensions' => array('IPA Extensions', '0250', '02AF'),
33  'spacing_modifier_letters' => array('Spacing Modifier Letters', '02B0', '02FF'),
34  'combining_diacritical_marks' => array('Combining Diacritical Marks', '0300', '036F'),
35  'greek_and_coptic' => array('Greek and Coptic', '0370', '03FF'),
36  'cyrillic' => array('Cyrillic', '0400', '04FF'),
37  'cyrillic_supplement' => array('Cyrillic Supplement', '0500', '052F'),
38  'armenian' => array('Armenian', '0530', '058F'),
39  'hebrew' => array('Hebrew', '0590', '05FF'),
40  'arabic' => array('Arabic', '0600', '06FF'),
41  'syriac' => array('Syriac', '0700', '074F'),
42  'arabic_supplement' => array('Arabic Supplement', '0750', '077F'),
43  'thaana' => array('Thaana', '0780', '07BF'),
44  'nko' => array('NKo', '07C0', '07FF'),
45  'samaritan' => array('Samaritan', '0800', '083F'),
46  'mandaic' => array('Mandaic', '0840', '085F'),
47  'arabic_extended_a' => array('Arabic Extended-A', '08A0', '08FF'),
48  'devanagari' => array('Devanagari', '0900', '097F'),
49  'bengali' => array('Bengali', '0980', '09FF'),
50  'gurmukhi' => array('Gurmukhi', '0A00', '0A7F'),
51  'gujarati' => array('Gujarati', '0A80', '0AFF'),
52  'oriya' => array('Oriya', '0B00', '0B7F'),
53  'tamil' => array('Tamil', '0B80', '0BFF'),
54  'telugu' => array('Telugu', '0C00', '0C7F'),
55  'kannada' => array('Kannada', '0C80', '0CFF'),
56  'malayalam' => array('Malayalam', '0D00', '0D7F'),
57  'sinhala' => array('Sinhala', '0D80', '0DFF'),
58  'thai' => array('Thai', '0E00', '0E7F'),
59  'lao' => array('Lao', '0E80', '0EFF'),
60  'tibetan' => array('Tibetan', '0F00', '0FFF'),
61  'myanmar' => array('Myanmar', '1000', '109F'),
62  'georgian' => array('Georgian', '10A0', '10FF'),
63  'hangul_jamo' => array('Hangul Jamo', '1100', '11FF'),
64  'ethiopic' => array('Ethiopic', '1200', '137F'),
65  'ethiopic_supplement' => array('Ethiopic Supplement', '1380', '139F'),
66  'cherokee' => array('Cherokee', '13A0', '13FF'),
67  'unified_canadian_aboriginal_syllabics' => array('Unified Canadian Aboriginal Syllabics', '1400', '167F'),
68  'ogham' => array('Ogham', '1680', '169F'),
69  'runic' => array('Runic', '16A0', '16FF'),
70  'tagalog' => array('Tagalog', '1700', '171F'),
71  'hanunoo' => array('Hanunoo', '1720', '173F'),
72  'buhid' => array('Buhid', '1740', '175F'),
73  'tagbanwa' => array('Tagbanwa', '1760', '177F'),
74  'khmer' => array('Khmer', '1780', '17FF'),
75  'mongolian' => array('Mongolian', '1800', '18AF'),
76  'unified_canadian_aboriginal_syllabics_extended' => array('Unified Canadian Aboriginal Syllabics Extended', '18B0', '18FF'),
77  'limbu' => array('Limbu', '1900', '194F'),
78  'tai_le' => array('Tai Le', '1950', '197F'),
79  'new_tai_lue' => array('New Tai Lue', '1980', '19DF'),
80  'khmer_symbols' => array('Khmer Symbols', '19E0', '19FF'),
81  'buginese' => array('Buginese', '1A00', '1A1F'),
82  'tai_tham' => array('Tai Tham', '1A20', '1AAF'),
83  'balinese' => array('Balinese', '1B00', '1B7F'),
84  'sundanese' => array('Sundanese', '1B80', '1BBF'),
85  'batak' => array('Batak', '1BC0', '1BFF'),
86  'lepcha' => array('Lepcha', '1C00', '1C4F'),
87  'ol_chiki' => array('Ol Chiki', '1C50', '1C7F'),
88  'sundanese_supplement' => array('Sundanese Supplement', '1CC0', '1CCF'),
89  'vedic_extensions' => array('Vedic Extensions', '1CD0', '1CFF'),
90  'phonetic_extensions' => array('Phonetic Extensions', '1D00', '1D7F'),
91  'phonetic_extensions_supplement' => array('Phonetic Extensions Supplement', '1D80', '1DBF'),
92  'combining_diacritical_marks_supplement' => array('Combining Diacritical Marks Supplement', '1DC0', '1DFF'),
93  'latin_extended_additional' => array('Latin Extended Additional', '1E00', '1EFF'),
94  'greek_extended' => array('Greek Extended', '1F00', '1FFF'),
95  'general_punctuation' => array('General Punctuation', '2000', '206F'),
96  'superscripts_and_subscripts' => array('Superscripts and Subscripts', '2070', '209F'),
97  'currency_symbols' => array('Currency Symbols', '20A0', '20CF'),
98  'combining_diacritical_marks_for_symbols' => array('Combining Diacritical Marks for Symbols', '20D0', '20FF'),
99  'letterlike_symbols' => array('Letterlike Symbols', '2100', '214F'),
100  'number_forms' => array('Number Forms', '2150', '218F'),
101  'arrows' => array('Arrows', '2190', '21FF'),
102  'mathematical_operators' => array('Mathematical Operators', '2200', '22FF'),
103  'miscellaneous_technical' => array('Miscellaneous Technical', '2300', '23FF'),
104  'control_pictures' => array('Control Pictures', '2400', '243F'),
105  'optical_character_recognition' => array('Optical Character Recognition', '2440', '245F'),
106  'enclosed_alphanumerics' => array('Enclosed Alphanumerics', '2460', '24FF'),
107  'box_drawing' => array('Box Drawing', '2500', '257F'),
108  'block_elements' => array('Block Elements', '2580', '259F'),
109  'geometric_shapes' => array('Geometric Shapes', '25A0', '25FF'),
110  'miscellaneous_symbols' => array('Miscellaneous Symbols', '2600', '26FF'),
111  'dingbats' => array('Dingbats', '2700', '27BF'),
112  'miscellaneous_mathematical_symbols_a' => array('Miscellaneous Mathematical Symbols-A', '27C0', '27EF'),
113  'supplemental_arrows_a' => array('Supplemental Arrows-A', '27F0', '27FF'),
114  'braille_patterns' => array('Braille Patterns', '2800', '28FF'),
115  'supplemental_arrows_b' => array('Supplemental Arrows-B', '2900', '297F'),
116  'miscellaneous_mathematical_symbols_b' => array('Miscellaneous Mathematical Symbols-B', '2980', '29FF'),
117  'supplemental_mathematical_operators' => array('Supplemental Mathematical Operators', '2A00', '2AFF'),
118  'miscellaneous_symbols_and_arrows' => array('Miscellaneous Symbols and Arrows', '2B00', '2BFF'),
119  'glagolitic' => array('Glagolitic', '2C00', '2C5F'),
120  'latin_extended_c' => array('Latin Extended-C', '2C60', '2C7F'),
121  'coptic' => array('Coptic', '2C80', '2CFF'),
122  'georgian_supplement' => array('Georgian Supplement', '2D00', '2D2F'),
123  'tifinagh' => array('Tifinagh', '2D30', '2D7F'),
124  'ethiopic_extended' => array('Ethiopic Extended', '2D80', '2DDF'),
125  'cyrillic_extended_a' => array('Cyrillic Extended-A', '2DE0', '2DFF'),
126  'supplemental_punctuation' => array('Supplemental Punctuation', '2E00', '2E7F'),
127  'cjk_radicals_supplement' => array('CJK Radicals Supplement', '2E80', '2EFF'),
128  'kangxi_radicals' => array('Kangxi Radicals', '2F00', '2FDF'),
129  'ideographic_description_characters' => array('Ideographic Description Characters', '2FF0', '2FFF'),
130  'cjk_symbols_and_punctuation' => array('CJK Symbols and Punctuation', '3000', '303F'),
131  'hiragana' => array('Hiragana', '3040', '309F'),
132  'katakana' => array('Katakana', '30A0', '30FF'),
133  'bopomofo' => array('Bopomofo', '3100', '312F'),
134  'hangul_compatibility_jamo' => array('Hangul Compatibility Jamo', '3130', '318F'),
135  'kanbun' => array('Kanbun', '3190', '319F'),
136  'bopomofo_extended' => array('Bopomofo Extended', '31A0', '31BF'),
137  'cjk_strokes' => array('CJK Strokes', '31C0', '31EF'),
138  'katakana_phonetic_extensions' => array('Katakana Phonetic Extensions', '31F0', '31FF'),
139  'enclosed_cjk_letters_and_months' => array('Enclosed CJK Letters and Months', '3200', '32FF'),
140  'cjk_compatibility' => array('CJK Compatibility', '3300', '33FF'),
141  'cjk_unified_ideographs_extension_a' => array('CJK Unified Ideographs Extension A', '3400', '4DBF'),
142  'yijing_hexagram_symbols' => array('Yijing Hexagram Symbols', '4DC0', '4DFF'),
143  'cjk_unified_ideographs' => array('CJK Unified Ideographs', '4E00', '9FFF'),
144  'yi_syllables' => array('Yi Syllables', 'A000', 'A48F'),
145  'yi_radicals' => array('Yi Radicals', 'A490', 'A4CF'),
146  'lisu' => array('Lisu', 'A4D0', 'A4FF'),
147  'vai' => array('Vai', 'A500', 'A63F'),
148  'cyrillic_extended_b' => array('Cyrillic Extended-B', 'A640', 'A69F'),
149  'bamum' => array('Bamum', 'A6A0', 'A6FF'),
150  'modifier_tone_letters' => array('Modifier Tone Letters', 'A700', 'A71F'),
151  'latin_extended_d' => array('Latin Extended-D', 'A720', 'A7FF'),
152  'syloti_nagri' => array('Syloti Nagri', 'A800', 'A82F'),
153  'common_indic_number_forms' => array('Common Indic Number Forms', 'A830', 'A83F'),
154  'phags_pa' => array('Phags-pa', 'A840', 'A87F'),
155  'saurashtra' => array('Saurashtra', 'A880', 'A8DF'),
156  'devanagari_extended' => array('Devanagari Extended', 'A8E0', 'A8FF'),
157  'kayah_li' => array('Kayah Li', 'A900', 'A92F'),
158  'rejang' => array('Rejang', 'A930', 'A95F'),
159  'hangul_jamo_extended_a' => array('Hangul Jamo Extended-A', 'A960', 'A97F'),
160  'javanese' => array('Javanese', 'A980', 'A9DF'),
161  'cham' => array('Cham', 'AA00', 'AA5F'),
162  'myanmar_extended_a' => array('Myanmar Extended-A', 'AA60', 'AA7F'),
163  'tai_viet' => array('Tai Viet', 'AA80', 'AADF'),
164  'meetei_mayek_extensions' => array('Meetei Mayek Extensions', 'AAE0', 'AAFF'),
165  'ethiopic_extended_a' => array('Ethiopic Extended-A', 'AB00', 'AB2F'),
166  'meetei_mayek' => array('Meetei Mayek', 'ABC0', 'ABFF'),
167  'hangul_syllables' => array('Hangul Syllables', 'AC00', 'D7AF'),
168  'hangul_jamo_extended_b' => array('Hangul Jamo Extended-B', 'D7B0', 'D7FF'),
169  'high_surrogates' => array('High Surrogates', 'D800', 'DB7F'),
170  'high_private_use_surrogates' => array('High Private Use Surrogates', 'DB80', 'DBFF'),
171  'low_surrogates' => array('Low Surrogates', 'DC00', 'DFFF'),
172  'private_use_area' => array('Private Use Area', 'E000', 'F8FF'),
173  'cjk_compatibility_ideographs' => array('CJK Compatibility Ideographs', 'F900', 'FAFF'),
174  'alphabetic_presentation_forms' => array('Alphabetic Presentation Forms', 'FB00', 'FB4F'),
175  'arabic_presentation_forms_a' => array('Arabic Presentation Forms-A', 'FB50', 'FDFF'),
176  'variation_selectors' => array('Variation Selectors', 'FE00', 'FE0F'),
177  'vertical_forms' => array('Vertical Forms', 'FE10', 'FE1F'),
178  'combining_half_marks' => array('Combining Half Marks', 'FE20', 'FE2F'),
179  'cjk_compatibility_forms' => array('CJK Compatibility Forms', 'FE30', 'FE4F'),
180  'small_form_variants' => array('Small Form Variants', 'FE50', 'FE6F'),
181  'arabic_presentation_forms_b' => array('Arabic Presentation Forms-B', 'FE70', 'FEFF'),
182  'halfwidth_and_fullwidth_forms' => array('Halfwidth and Fullwidth Forms', 'FF00', 'FFEF'),
183  'specials' => array('Specials', 'FFF0', 'FFFF'),
184  /* here ends the Basic Multilinguage Plane (BMP) */
185 
186  /*
187  * The following blocks are not yet supported well.
188  * It seems that the chars are taken from the BMP instead
189  *
190  'linear_b_syllabary' => array('Linear B Syllabary', '10000', '1007F'),
191  'linear_b_ideograms' => array('Linear B Ideograms', '10080', '100FF'),
192  'aegean_numbers' => array('Aegean Numbers', '10100', '1013F'),
193  'ancient_greek_numbers' => array('Ancient Greek Numbers', '10140', '1018F'),
194  'ancient_symbols' => array('Ancient Symbols', '10190', '101CF'),
195  'phaistos_disc' => array('Phaistos Disc', '101D0', '101FF'),
196  'lycian' => array('Lycian', '10280', '1029F'),
197  'carian' => array('Carian', '102A0', '102DF'),
198  'old_italic' => array('Old Italic', '10300', '1032F'),
199  'gothic' => array('Gothic', '10330', '1034F'),
200  'ugaritic' => array('Ugaritic', '10380', '1039F'),
201  'old_persian' => array('Old Persian', '103A0', '103DF'),
202  'deseret' => array('Deseret', '10400', '1044F'),
203  'shavian' => array('Shavian', '10450', '1047F'),
204  'osmanya' => array('Osmanya', '10480', '104AF'),
205  'cypriot_syllabary' => array('Cypriot Syllabary', '10800', '1083F'),
206  'imperial_aramaic' => array('Imperial Aramaic', '10840', '1085F'),
207  'phoenician' => array('Phoenician', '10900', '1091F'),
208  'lydian' => array('Lydian', '10920', '1093F'),
209  'meroitic_hieroglyphs' => array('Meroitic Hieroglyphs', '10980', '1099F'),
210  'meroitic_cursive' => array('Meroitic Cursive', '109A0', '109FF'),
211  'kharoshthi' => array('Kharoshthi', '10A00', '10A5F'),
212  'old_south_arabian' => array('Old South Arabian', '10A60', '10A7F'),
213  'avestan' => array('Avestan', '10B00', '10B3F'),
214  'inscriptional_parthian' => array('Inscriptional Parthian', '10B40', '10B5F'),
215  'inscriptional_pahlavi' => array('Inscriptional Pahlavi', '10B60', '10B7F'),
216  'old_turkic' => array('Old Turkic', '10C00', '10C4F'),
217  'rumi_numeral_symbols' => array('Rumi Numeral Symbols', '10E60', '10E7F'),
218  'brahmi' => array('Brahmi', '11000', '1107F'),
219  'kaithi' => array('Kaithi', '11080', '110CF'),
220  'sora_sompeng' => array('Sora Sompeng', '110D0', '110FF'),
221  'chakma' => array('Chakma', '11100', '1114F'),
222  'sharada' => array('Sharada', '11180', '111DF'),
223  'takri' => array('Takri', '11680', '116CF'),
224  'cuneiform' => array('Cuneiform', '12000', '123FF'),
225  'cuneiform_numbers_and_punctuation' => array('Cuneiform Numbers and Punctuation', '12400', '1247F'),
226  'egyptian_hieroglyphs' => array('Egyptian Hieroglyphs', '13000', '1342F'),
227  'bamum_supplement' => array('Bamum Supplement', '16800', '16A3F'),
228  'miao' => array('Miao', '16F00', '16F9F'),
229  'kana_supplement' => array('Kana Supplement', '1B000', '1B0FF'),
230  'byzantine_musical_symbols' => array('Byzantine Musical Symbols', '1D000', '1D0FF'),
231  'musical_symbols' => array('Musical Symbols', '1D100', '1D1FF'),
232  'ancient_greek_musical_notation' => array('Ancient Greek Musical Notation', '1D200', '1D24F'),
233  'tai_xuan_jing_symbols' => array('Tai Xuan Jing Symbols', '1D300', '1D35F'),
234  'counting_rod_numerals' => array('Counting Rod Numerals', '1D360', '1D37F'),
235  'mathematical_alphanumeric_symbols' => array('Mathematical Alphanumeric Symbols', '1D400', '1D7FF'),
236  'arabic_mathematical_alphabetic_symbols' => array('Arabic Mathematical Alphabetic Symbols', '1EE00', '1EEFF'),
237  'mahjong_tiles' => array('Mahjong Tiles', '1F000', '1F02F'),
238  'domino_tiles' => array('Domino Tiles', '1F030', '1F09F'),
239  'playing_cards' => array('Playing Cards', '1F0A0', '1F0FF'),
240  'enclosed_alphanumeric_supplement' => array('Enclosed Alphanumeric Supplement', '1F100', '1F1FF'),
241  'enclosed_ideographic_supplement' => array('Enclosed Ideographic Supplement', '1F200', '1F2FF'),
242  'miscellaneous_symbols_and_pictographs' => array('Miscellaneous Symbols And Pictographs', '1F300', '1F5FF'),
243  'emoticons' => array('Emoticons', '1F600', '1F64F'),
244  'transport_and_map_symbols' => array('Transport And Map Symbols', '1F680', '1F6FF'),
245  'alchemical_symbols' => array('Alchemical Symbols', '1F700', '1F77F'),
246  'cjk_unified_ideographs_extension_b' => array('CJK Unified Ideographs Extension B', '20000', '2A6DF'),
247  'cjk_unified_ideographs_extension_c' => array('CJK Unified Ideographs Extension C', '2A700', '2B73F'),
248  'cjk_unified_ideographs_extension_d' => array('CJK Unified Ideographs Extension D', '2B740', '2B81F'),
249  'cjk_compatibility_ideographs_supplement' => array('CJK Compatibility Ideographs Supplement', '2F800', '2FA1F'),
250  'tags' => array('Tags', 'E0000', 'E007F'),
251  'variation_selectors_supplement' => array('Variation Selectors Supplement', 'E0100', 'E01EF'),
252  'supplementary_private_use_area_a' => array('Supplementary Private Use Area-A', 'F0000', 'FFFFF'),
253  'supplementary_private_use_area_b' => array('Supplementary Private Use Area-B', '100000', '10FFFF')
254  */
255  );
256 
260  private $context = self::CONTEXT_NONE;
261 
265  private $availability = self::INHERIT;
266 
270  private $added_blocks = array();
271 
275  private $custom_items = array();
276 
277 
283  public function __construct($a_context = self::CONTEXT_NONE)
284  {
285  switch ($a_context) {
286  case self::CONTEXT_ADMIN:
287  case self::CONTEXT_TEST:
288  case self::CONTEXT_USER:
289  $this->context = $a_context;
290  break;
291  default:
292  $this->context = self::CONTEXT_NONE;
293  }
294  }
295 
301  public static function _getCurrentConfig(ilObjTest $a_test_obj = null)
302  {
303  global $ilSetting, $ilUser;
304 
305  // check configuration from administration settings
306  $admin_config = new self(self::CONTEXT_ADMIN, true);
307  $admin_config->setAvailability($ilSetting->get('char_selector_availability'));
308  $admin_config->setDefinition($ilSetting->get('char_selector_definition'));
309  if ($admin_config->getAvailability() == self::INACTIVE) {
310  // a globally inactive selector can't be overwritten by users or tests
311  return $admin_config;
312  }
313 
314  // a test configuration is relevant for test runs
315  if (isset($a_test_obj)) {
316  $test_config = new self(self::CONTEXT_TEST, false);
317  $test_config->setAvailability($a_test_obj->getCharSelectorAvailability());
318  $test_config->setDefinition($a_test_obj->getCharSelectorDefinition());
319  if ($test_config->getAvailability() != self::INHERIT) {
320  // a specific test configuration has precedence over user configuration
321  return $test_config;
322  }
323  }
324 
325  // check configuration from user settings
326  $user_config = new self(self::CONTEXT_USER, true);
327  $user_config->setAvailability($ilUser->getPref('char_selector_availability'));
328  $user_config->setDefinition($ilUser->getPref('char_selector_definition'));
329  if ($user_config->getAvailability() != self::INHERIT) {
330  // take user specific config
331  return $user_config;
332  } else {
333  // take admin config as default
334  return $admin_config;
335  }
336  }
337 
338 
344  public function getContext()
345  {
346  return $this->context;
347  }
348 
349 
354  public function setAvailability($a_availability)
355  {
356  switch ((int) $a_availability) {
357  case self::INACTIVE:
358  case self::INHERIT:
359  case self::ENABLED:
360  case self::DISABLED:
361  $this->availability = (int) $a_availability;
362  break;
363  default:
364  $this->availability = self::INHERIT;
365  }
366  }
367 
368 
373  public function getAvailability()
374  {
375  return $this->availability;
376  }
377 
382  public function setAddedBlocks($a_blocks = array())
383  {
384  $this->added_blocks = array();
385  foreach ($a_blocks as $block_name) {
386  if ($block_name == "all" or
387  in_array($block_name, array_keys(self::$unicode_blocks))) {
388  array_push($this->added_blocks, $block_name);
389  }
390  }
391  }
392 
397  public function getAddedBlocks()
398  {
399  return $this->added_blocks;
400  }
401 
407  public function setCustomItems($a_items = '')
408  {
409  $this->custom_items = explode(' ', $a_items);
410  }
411 
417  public function getCustomItems()
418  {
419  return implode(' ', $this->custom_items);
420  }
421 
438  public function setDefinition($a_definition = '')
439  {
440  // first reset all previous settings
441  $this->added_blocks = array();
442  $this->custom_items = array();
443 
444  // set the default definition to all unicode blocks
445  if (trim($a_definition) == '') {
446  $a_definition = "[all]";
447  }
448 
449  // analyze definition items
450  $items = explode(' ', $a_definition);
451  foreach ($items as $item) {
452  if (strlen($block_name = $this->extractUnicodeBlock($item))) {
453  array_push($this->added_blocks, $block_name);
454  } elseif ($item != '') {
455  array_push($this->custom_items, trim($item));
456  }
457  }
458  }
459 
465  public function getDefinition()
466  {
467  $definition = implode(' ', $this->custom_items);
468  foreach ($this->added_blocks as $block_name) {
469  $definition = $definition . ' [' . $block_name . ']';
470  }
471  return trim($definition);
472  }
473 
474 
479  public function getBlockOptions()
480  {
481  global $lng;
482 
483  $options = array(
484  '' => $lng->txt('please_select'),
485  'all' => $lng->txt('char_selector_unicode_all')
486  );
487  foreach (array_keys(self::$unicode_blocks) as $block_name) {
488  $options[$block_name] = $this->getBlockTitle($block_name);
489  }
490  return $options;
491  }
492 
493 
501  public function getBlockTitle($a_block_name)
502  {
503  global $lng;
504 
505  $langvar = 'char_selector_unicode_' . $a_block_name;
506  if ($lng->txt($langvar) != '-' . $langvar . '-') {
507  return $lng->txt($langvar);
508  } else {
509  return self::$unicode_blocks[$a_block_name][0];
510  }
511  }
512 
519  private function extractUnicodeBlock($a_item = '')
520  {
521  $a_item = trim($a_item);
522  $matches = array();
523  if (preg_match('/^\[(.+)\]$/', $a_item, $matches)) {
524  $block_name = $matches[1];
525  if ($block_name == 'all'
526  or in_array($block_name, array_keys(self::$unicode_blocks))) {
527  return $block_name;
528  }
529  }
530  return '';
531  }
532 
533 
539  public function getCharPages()
540  {
541  global $lng;
542 
543  $pages = array();
544 
545  // add custom block
546  //
547  $page = array($lng->txt('char_selector_custom_items'));
548  foreach ($this->custom_items as $item) {
549  if (strpos($item, '-') > 0) {
550  // handle range
551  $subitems = explode('-', $item);
552  $start = $this->getItemCodepoint($subitems[0]);
553  $end = $this->getItemCodepoint($subitems[1]);
554  array_push($page, array($start, $end));
555  } else {
556  // handle normal item
557  array_push($page, $this->getItemParsed($item));
558  }
559  }
560  if (count($page) > 1) {
561  array_push($pages, $page);
562  }
563 
564  // add unicode blocks
565  //
566  $blocks = in_array('all', $this->added_blocks) ?
567  array_keys(self::$unicode_blocks) :
569 
570  foreach ($blocks as $block_name) {
571  $start = hexdec(self::$unicode_blocks[$block_name][1]);
572  $end = hexdec(self::$unicode_blocks[$block_name][2]);
573  $page = array($this->getBlockTitle($block_name), array($start, $end));
574  array_push($pages, $page);
575  }
576 
577  return $pages;
578  }
579 
580 
585  private function getItemCodepoint($a_item)
586  {
587  if (preg_match('/^[uU]\+[0-9a-fA-F]+$/', $a_item)) {
588  return (int) hexdec(substr($a_item, 2));
589  } else {
590  //take the codepoint of the first character
591  require_once "include/Unicode/UtfNormalUtil.php";
592  return (int) utf8ToCodepoint($a_item);
593  }
594  }
595 
601  private function getItemParsed($a_item)
602  {
603  return preg_replace_callback(
604  '/[uU]\+[0-9a-fA-F]+/',
605  array($this,'getItemParsedCallback'),
606  $a_item
607  );
608  }
609 
615  private function getItemParsedCallback($matches)
616  {
617  require_once "include/Unicode/UtfNormalUtil.php";
618  return codepointToUtf8(hexdec(substr($matches[0], 2)));
619  }
620 }
utf8ToCodepoint($char)
Determine the Unicode codepoint of a single-character UTF-8 sequence.
getAddedBlocks()
set the added unicode blocks
getItemParsedCallback($matches)
callback for replacement of unicode notations
getBlockOptions()
get the options for a block selection
const CONTEXT_NONE
Configuration contexts.
static _getCurrentConfig(ilObjTest $a_test_obj=null)
Get the configuration that should be used for the current selector.
$end
Definition: saml1-acs.php:18
getItemCodepoint($a_item)
get the unicode index of an item
getAvailability()
get the availability of the selector
setDefinition($a_definition='')
const INACTIVE
Availabilities INACTIVE/INHERIT corresponds to an unconfigured selector (no database entries) ...
setCustomItems($a_items='')
set the custom items
extractUnicodeBlock($a_item='')
Extract the unicode block name from a definition item.
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
__construct($a_context=self::CONTEXT_NONE)
Constructor.
getDefinition()
Set the definition of the available characters.
global $ilSetting
Definition: privfeed.php:17
global $lng
Definition: privfeed.php:17
setAvailability($a_availability)
set the availability of the selector
codepointToUtf8($codepoint)
Return UTF-8 sequence for a given Unicode code point.
getItemParsed($a_item)
replace unicode notations with their utf8 chars in a string
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.
getCustomItems()
set the custom items
getContext()
get the context of the configuration (the context is set at initialisation and can&#39;t be changed) ...
setAddedBlocks($a_blocks=array())
set the added unicode blocks
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20