ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 {
102 $this->data['items'][$i]['language'] = $iso2_language_code;
103 $this->data['items'][$i]['agreement'] = false;
104 $this->data['items'][$i]['agreement_document'] = null;
105 $this->data['items'][$i]['agreement_document_modification_ts'] = null;
106
107 foreach($this->getSourceDirectories() as $directory)
108 {
109 $file = $directory . '/agreement_' . $iso2_language_code . '.html';
110 if(is_file($file) && is_readable($file))
111 {
112 $this->data['items'][$i]['agreement_document'] = $file;
113 $this->data['items'][$i]['agreement_document_modification_ts'] = filemtime($file);
114 $this->data['items'][$i]['agreement'] = true;
115 break;
116 }
117 }
118
119 ++$i;
120 }
121
122 $this->data['cnt'] = $i;
123 }
124}
print $file
language handling
$params
Definition: example_049.php:96