ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
4 require_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  $this->content = '';
61 
62  $content = file_get_contents($file);
63  if(strip_tags($content) === $content)
64  {
65  $lines = file($file);
66  foreach($lines as $line)
67  {
68  $this->content .= nl2br(trim($line));
69  }
70  }
71  else
72  {
73  $this->content = $content;
74  }
75 
76  $this->source = $file;
77  $this->has_content = (bool)strlen($this->content);
78  $this->iso2_language_code = $iso2_language_code;
79  return;
80  }
81  }
82 
83  require_once 'Services/TermsOfService/exceptions/class.ilTermsOfServiceNoSignableDocumentFoundException.php';
84  throw new ilTermsOfServiceNoSignableDocumentFoundException('Could not find any terms of service document for the passed language object');
85  }
86 
90  public function exists()
91  {
92  return true;
93  }
94 
98  protected function initSourceFiles()
99  {
100  $this->source_files = array(
101  implode('/', array('.', 'Customizing', 'clients', CLIENT_ID, 'agreement', 'agreement_' . $this->getLanguageAdapter()->getLangKey() . '.html')) => $this->getLanguageAdapter()->getLangKey(),
102  implode('/', array('.', 'Customizing', 'clients', CLIENT_ID, 'agreement', 'agreement_' . $this->getLanguageAdapter()->getDefaultLanguage() . '.html')) => $this->getLanguageAdapter()->getDefaultLanguage(),
103  implode('/', array('.', 'Customizing', 'clients', CLIENT_ID, 'agreement', 'agreement_en.html')) => 'en',
104  implode('/', array('.', 'Customizing', 'global', 'agreement', 'agreement_' . $this->getLanguageAdapter()->getLangKey() . '.html')) => $this->getLanguageAdapter()->getLangKey(),
105  implode('/', array('.', 'Customizing', 'global', 'agreement', 'agreement_' . $this->getLanguageAdapter()->getDefaultLanguage() . '.html')) => $this->getLanguageAdapter()->getDefaultLanguage(),
106  implode('/', array('.', 'Customizing', 'global', 'agreement', 'agreement_en.html')) => 'en'
107  );
108  }
109 
113  public function setLanguageAdapter($lng)
114  {
115  $this->lng = $lng;
116  }
117 
121  public function getLanguageAdapter()
122  {
123  return $this->lng;
124  }
125 
129  public function setSourceFiles($source_directories)
130  {
131  $this->source_files = $source_directories;
132  }
133 
137  public function getSourceFiles()
138  {
139  return $this->source_files;
140  }
141 
145  public function hasContent()
146  {
147  return $this->has_content;
148  }
149 
153  public function getContent()
154  {
155  return $this->content;
156  }
157 
161  public function getSource()
162  {
163  return $this->source;
164  }
165 
169  public function getSourceType()
170  {
171  return self::SRC_TYPE_FILE_SYSTEM_PATH;
172  }
173 
177  public function getIso2LanguageCode()
178  {
180  }
181 }
Reload workbook from saved file
Create styles array
The data for the language used.
language handling
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file