ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Json.php
Go to the documentation of this file.
1 <?php
3 
4 class Json extends Exporter
5 {
10  protected static function getEncodeOptions()
11  {
12  $result = 0;
13  if (defined('\JSON_UNESCAPED_SLASHES')) {
14  $result |= \JSON_UNESCAPED_SLASHES;
15  }
16  if (defined('\JSON_UNESCAPED_UNICODE')) {
17  $result |= \JSON_UNESCAPED_UNICODE;
18  }
19 
20  return $result;
21  }
25  protected static function toStringDo($languages)
26  {
27  $list = array();
28  foreach ($languages as $language) {
29  $item = array();
30  $item['name'] = $language->name;
31  if (isset($language->supersededBy)) {
32  $item['supersededBy'] = $language->supersededBy;
33  }
34  if (isset($language->script)) {
35  $item['script'] = $language->script;
36  }
37  if (isset($language->territory)) {
38  $item['territory'] = $language->territory;
39  }
40  if (isset($language->baseLanguage)) {
41  $item['baseLanguage'] = $language->baseLanguage;
42  }
43  $item['formula'] = $language->formula;
44  $item['plurals'] = count($language->categories);
45  $item['cases'] = array();
46  $item['examples'] = array();
47  foreach ($language->categories as $category) {
48  $item['cases'][] = $category->id;
49  $item['examples'][$category->id] = $category->examples;
50  }
51  $list[$language->id] = $item;
52  }
53 
54  return json_encode($list, static::getEncodeOptions());
55  }
59  public static function getDescription()
60  {
61  return 'Build a compressed JSON-encoded file';
62  }
63 }
Base class for all the exporters.
Definition: Exporter.php:10
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
$result
static getEncodeOptions()
Return the options for json_encode.
Definition: Json.php:10
static toStringDo($languages)
Definition: Json.php:25
$languages
Definition: cssgen2.php:34