ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilTermsOfServiceFileSystemDocument.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/TermsOfService/interfaces/interface.ilTermsOfServiceSignableDocument.php';
5
11{
15 protected $lng;
16
20 protected $has_content = false;
21
25 protected $content = '';
26
30 protected $iso2_language_code = '';
31
35 protected $source = '';
36
40 protected $source_files = array();
41
45 public function __construct(ilLanguage $lng)
46 {
47 $this->setLanguageAdapter($lng);
48 $this->initSourceFiles();
49 }
50
54 public function determine()
55 {
56 foreach($this->getSourceFiles() as $file => $iso2_language_code)
57 {
58 if(is_file($file) && is_readable($file))
59 {
60 $lines = file($file);
61 $this->content = '';
62 foreach($lines as $line)
63 {
64 $this->content .= trim(nl2br($line));
65 }
66 $this->source = $file;
67 $this->has_content = (bool)strlen($this->content);
68 $this->iso2_language_code = $iso2_language_code;
69 return;
70 }
71 }
72
73 require_once 'Services/TermsOfService/exceptions/class.ilTermsOfServiceNoSignableDocumentFoundException.php';
74 throw new ilTermsOfServiceNoSignableDocumentFoundException('Could not find any terms of service document for the passed language object');
75 }
76
80 protected function initSourceFiles()
81 {
82 $this->source_files = array(
83 implode('/', array('.', 'Customizing', 'clients', CLIENT_ID, 'agreement', 'agreement_' . $this->getLanguageAdapter()->getLangKey() . '.html')) => $this->getLanguageAdapter()->getLangKey(),
84 implode('/', array('.', 'Customizing', 'clients', CLIENT_ID, 'agreement', 'agreement_' . $this->getLanguageAdapter()->getDefaultLanguage() . '.html')) => $this->getLanguageAdapter()->getDefaultLanguage(),
85 implode('/', array('.', 'Customizing', 'clients', CLIENT_ID, 'agreement', 'agreement_en.html')) => 'en',
86 implode('/', array('.', 'Customizing', 'global', 'agreement', 'agreement_' . $this->getLanguageAdapter()->getLangKey() . '.html')) => $this->getLanguageAdapter()->getLangKey(),
87 implode('/', array('.', 'Customizing', 'global', 'agreement', 'agreement_' . $this->getLanguageAdapter()->getDefaultLanguage() . '.html')) => $this->getLanguageAdapter()->getDefaultLanguage(),
88 implode('/', array('.', 'Customizing', 'global', 'agreement', 'agreement_en.html')) => 'en'
89 );
90 }
91
95 public function setLanguageAdapter($lng)
96 {
97 $this->lng = $lng;
98 }
99
103 public function getLanguageAdapter()
104 {
105 return $this->lng;
106 }
107
111 public function setSourceFiles($source_directories)
112 {
113 $this->source_files = $source_directories;
114 }
115
119 public function getSourceFiles()
120 {
121 return $this->source_files;
122 }
123
127 public function hasContent()
128 {
129 return $this->has_content;
130 }
131
135 public function getContent()
136 {
137 return $this->content;
138 }
139
143 public function getSource()
144 {
145 return $this->source;
146 }
147
151 public function getSourceType()
152 {
154 }
155
159 public function getIso2LanguageCode()
160 {
162 }
163}
print $file
language handling