ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilBibliograficFileReaderBase.php
Go to the documentation of this file.
1 <?php
2 
9 {
10  const ENCODING_UTF_8 = 'UTF-8';
11  const ENCODING_ASCII = 'ASCII';
12  const ENCODING_ISO_8859_1 = 'ISO-8859-1';
16  protected $file_content = '';
20  protected $path_to_file = '';
21 
22 
28  public function readContent($path_to_file)
29  {
30  global $DIC;
34  $filesystem = $DIC["filesystem"];
36  $this->setFileContent($this->convertStringToUTF8($filesystem->storage()->read($path_to_file)));
37 
38  return true;
39  }
40 
46  protected function convertStringToUTF8($string)
47  {
48  if (!function_exists('mb_detect_encoding') || !function_exists('mb_detect_order')
49  || !function_exists("mb_convert_encoding")
50  ) {
51  return $string;
52  }
53  ob_end_clean();
54  $mb_detect_encoding = mb_detect_encoding($string);
55  mb_detect_order(array( self::ENCODING_UTF_8, self::ENCODING_ISO_8859_1 ));
56  switch ($mb_detect_encoding) {
57  case self::ENCODING_UTF_8:
58  break;
59  case self::ENCODING_ASCII:
60  $string = utf8_encode(iconv(self::ENCODING_ASCII, 'UTF-8//IGNORE', $string));
61  break;
62  default:
63  $string = mb_convert_encoding($string, self::ENCODING_UTF_8, $mb_detect_encoding);
64  break;
65  }
66 
67  return $string;
68  }
69 
70 
74  public function getFileContent()
75  {
76  return $this->file_content;
77  }
78 
79 
83  public function setFileContent($file_content)
84  {
85  $this->file_content = $file_content;
86  }
87 
88 
92  public function getPathToFile()
93  {
94  return $this->path_to_file;
95  }
96 
97 
101  public function setPathToFile($path_to_file)
102  {
103  $this->path_to_file = $path_to_file;
104  }
105 }
global $DIC
Definition: saml.php:7
readContent($path_to_file)
Create styles array
The data for the language used.
Interface ilBibliograficFileReader.
Class ilBibliograficFileReaderBase.