ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilBibliograficFileReaderBase.php
Go to the documentation of this file.
1 <?php
2 require_once('./Modules/Bibliographic/interfaces/interface.ilBibliograficFileReader.php');
3 
10 
11  const ENCODING_UTF_8 = 'UTF-8';
12  const ENCODING_ASCII = 'ASCII';
13  const ENCODING_ISO_8859_1 = 'ISO-8859-1';
17  protected $file_content = '';
21  protected $path_to_file = '';
22 
23 
29  public function readContent($path_to_file) {
31  // $this->convertFiletoUTF8();
32  $this->setFileContent($this->convertStringToUTF8(file_get_contents($path_to_file)));
33 
34  return true;
35  }
36 
37 
38  protected function convertFiletoUTF8() {
39  file_put_contents($this->getPathToFile(), $this->convertStringToUTF8(file_get_contents($this->getPathToFile())));
40  }
41 
42 
48  protected function convertStringToUTF8($string) {
49  if (!function_exists('mb_detect_encoding') || !function_exists('mb_detect_order')
50  || !function_exists("mb_convert_encoding")
51  ) {
52  return $string;
53  }
54  ob_end_clean();
55  $mb_detect_encoding = mb_detect_encoding($string);
56  mb_detect_order(array( self::ENCODING_UTF_8, self::ENCODING_ISO_8859_1 ));
57  switch ($mb_detect_encoding) {
58  case self::ENCODING_UTF_8:
59  break;
60  case self::ENCODING_ASCII:
61  $string = utf8_encode(iconv(self::ENCODING_ASCII, 'UTF-8//IGNORE', $string));
62  break;
63  default:
64  $string = mb_convert_encoding($string, self::ENCODING_UTF_8, $mb_detect_encoding);
65  break;
66  }
67 
68  return $string;
69  }
70 
71 
75  public function getFileContent() {
76  return $this->file_content;
77  }
78 
79 
83  public function setFileContent($file_content) {
84  $this->file_content = $file_content;
85  }
86 
87 
91  public function getPathToFile() {
92  return $this->path_to_file;
93  }
94 
95 
99  public function setPathToFile($path_to_file) {
100  $this->path_to_file = $path_to_file;
101  }
102 }
Create styles array
The data for the language used.
Interface ilBibliograficFileReader.
Class ilBibliograficFileReaderBase.