ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilHTMLToPDFTransformer.php
Go to the documentation of this file.
1 <?php
2  /*
3  +----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +----------------------------------------------------------------------------+
22 */
23 
31 abstract class ilHTMLToPDFTransformer
32 {
33  protected $arrData;
34 
35  function __construct($filename = "")
36  {
37  $this->arrData = array();
38  if (strlen($filename))
39  {
40  $this->filename = $filename;
41  }
42  }
43 
44  public static function transformerAvailable()
45  {
46  $pdfSetting = new ilSetting("pdf");
47  if (strlen($pdfSetting->get('html_to_pdf_method')) && strcmp($pdfSetting->get('html_to_pdf_method'), 'none') != 0)
48  {
49  return true;
50  }
51  else
52  {
53  return false;
54  }
55  }
56 
57  protected function generateFilename()
58  {
59  $filename = ilUtil::ilTempnam() . ".pdf";
60  return basename($filename);
61  }
62 
63  public function __set($name, $value)
64  {
65  switch ($name)
66  {
67  case 'filename':
68  if (strlen($value))
69  {
70  include_once ILIAS_ABSOLUTE_PATH . "/Services/Utilities/classes/class.ilUtil.php";
71  $this->arrData[$name] = ilUtil::getASCIIFilename($value);
72  }
73  else
74  {
75  $this->arrData[$name] = $this->generateFilename();
76  }
77  break;
78  default:
79  $this->arrData[$name] = $value;
80  break;
81  }
82  }
83 
84  public function __get($name)
85  {
86  if (array_key_exists($name, $this->arrData))
87  {
88  switch ($name)
89  {
90  case 'filename':
91  if (!strlen($this->arrData[$name]))
92  {
93  return $this->generateFilename();
94  }
95  else
96  {
97  return $this->arrData[$name];
98  }
99  break;
100  default:
101  return $this->arrData[$name];
102  break;
103  }
104  }
105  return null;
106  }
107 
108  public function __isset($name)
109  {
110  return isset($this->arrData[$name]);
111  }
112 
113  public function __unset($name)
114  {
115  unset($this->arrData[$name]);
116  }
117 
118  abstract function deliverPDFFromHTMLString($a_string);
119  abstract function deliverPDFFromHTMLFile($a_path);
120  abstract function createPDFFileFromHTMLFile($a_source, $a_target);
121 }
122 
123 ?>