ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilTermsOfServiceAgreementByLanguageProvider.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/TermsOfService/interfaces/interface.ilTermsOfServiceTableDataProvider.php';
5
11{
15 protected $lng;
16
20 protected $data = array();
21
25 protected $source_directories = array();
26
30 public function __construct(ilLanguage $lng)
31 {
32 $this->setLanguageAdapter($lng);
33 $this->initSourceDirectories();
34 }
35
39 public function setSourceDirectories($terms_of_service_source_directories)
40 {
41 $this->source_directories = $terms_of_service_source_directories;
42 }
43
47 public function getSourceDirectories()
48 {
50 }
51
55 public function setLanguageAdapter($lng)
56 {
57 $this->lng = $lng;
58 }
59
63 public function getLanguageAdapter()
64 {
65 return $this->lng;
66 }
67
71 protected function initSourceDirectories()
72 {
73 $this->source_directories = array(
74 implode('/', array('.', 'Customizing', 'clients', CLIENT_ID, 'agreement')),
75 implode('/', array('.', 'Customizing', 'global', 'agreement'))
76 );
77 }
78
82 public function getList(array $params, array $filter)
83 {
84 $this->data = array(
85 'items' => array(),
86 'cnt' => 0
87 );
88
89 $this->collectData();
90
91 return $this->data;
92 }
93
97 protected function collectData()
98 {
99 $i = 0;
100 foreach ($this->getLanguageAdapter()->getInstalledLanguages() as $iso2_language_code) {
101 $this->data['items'][$i]['language'] = $iso2_language_code;
102 $this->data['items'][$i]['agreement'] = false;
103 $this->data['items'][$i]['agreement_document'] = null;
104 $this->data['items'][$i]['agreement_document_modification_ts'] = null;
105
106 foreach ($this->getSourceDirectories() as $directory) {
107 $file = $directory . '/agreement_' . $iso2_language_code . '.html';
108 if (is_file($file) && is_readable($file)) {
109 $this->data['items'][$i]['agreement_document'] = $file;
110 $this->data['items'][$i]['agreement_document_modification_ts'] = filemtime($file);
111 $this->data['items'][$i]['agreement'] = true;
112 break;
113 }
114 }
115
116 ++$i;
117 }
118
119 $this->data['cnt'] = $i;
120 }
121}
An exception for terminatinating execution or to throw for unit testing.
language handling
$i
Definition: disco.tpl.php:19
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
$this data['403_header']
$params
Definition: disable.php:11