ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
DocProps.php
Go to the documentation of this file.
1 <?php
30 if (!defined('PHPEXCEL_ROOT')) {
34  define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
35 }
36 
38 require_once PHPEXCEL_ROOT . 'PHPExcel.php';
39 
41 require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007.php';
42 
44 require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/WriterPart.php';
45 
47 require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
48 
49 
58 {
66  public function writeDocPropsApp(PHPExcel $pPHPExcel = null)
67  {
68  // Create XML writer
69  $objWriter = null;
70  if ($this->getParentWriter()->getUseDiskCaching()) {
71  $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
72  } else {
74  }
75 
76  // XML header
77  $objWriter->startDocument('1.0','UTF-8','yes');
78 
79  // Properties
80  $objWriter->startElement('Properties');
81  $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties');
82  $objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
83 
84  // Application
85  $objWriter->writeElement('Application', 'Microsoft Excel');
86 
87  // DocSecurity
88  $objWriter->writeElement('DocSecurity', '0');
89 
90  // ScaleCrop
91  $objWriter->writeElement('ScaleCrop', 'false');
92 
93  // HeadingPairs
94  $objWriter->startElement('HeadingPairs');
95 
96  // Vector
97  $objWriter->startElement('vt:vector');
98  $objWriter->writeAttribute('size', '2');
99  $objWriter->writeAttribute('baseType', 'variant');
100 
101 
102  // Variant
103  $objWriter->startElement('vt:variant');
104  $objWriter->writeElement('vt:lpstr', 'Worksheets');
105  $objWriter->endElement();
106 
107  // Variant
108  $objWriter->startElement('vt:variant');
109  $objWriter->writeElement('vt:i4', $pPHPExcel->getSheetCount());
110  $objWriter->endElement();
111 
112  $objWriter->endElement();
113 
114  $objWriter->endElement();
115 
116  // TitlesOfParts
117  $objWriter->startElement('TitlesOfParts');
118 
119  // Vector
120  $objWriter->startElement('vt:vector');
121  $objWriter->writeAttribute('size', $pPHPExcel->getSheetCount());
122  $objWriter->writeAttribute('baseType', 'lpstr');
123 
124  $sheetCount = $pPHPExcel->getSheetCount();
125  for ($i = 0; $i < $sheetCount; ++$i) {
126  $objWriter->writeElement('vt:lpstr', $pPHPExcel->getSheet($i)->getTitle());
127  }
128 
129  $objWriter->endElement();
130 
131  $objWriter->endElement();
132 
133  // Company
134  $objWriter->writeElement('Company', $pPHPExcel->getProperties()->getCompany());
135 
136  // LinksUpToDate
137  $objWriter->writeElement('LinksUpToDate', 'false');
138 
139  // SharedDoc
140  $objWriter->writeElement('SharedDoc', 'false');
141 
142  // HyperlinksChanged
143  $objWriter->writeElement('HyperlinksChanged', 'false');
144 
145  // AppVersion
146  $objWriter->writeElement('AppVersion', '12.0000');
147 
148  $objWriter->endElement();
149 
150  // Return
151  return $objWriter->getData();
152  }
153 
161  public function writeDocPropsCore(PHPExcel $pPHPExcel = null)
162  {
163  // Create XML writer
164  $objWriter = null;
165  if ($this->getParentWriter()->getUseDiskCaching()) {
166  $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
167  } else {
169  }
170 
171  // XML header
172  $objWriter->startDocument('1.0','UTF-8','yes');
173 
174  // cp:coreProperties
175  $objWriter->startElement('cp:coreProperties');
176  $objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
177  $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
178  $objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
179  $objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
180  $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
181 
182  // dc:creator
183  $objWriter->writeElement('dc:creator', $pPHPExcel->getProperties()->getCreator());
184 
185  // cp:lastModifiedBy
186  $objWriter->writeElement('cp:lastModifiedBy', $pPHPExcel->getProperties()->getLastModifiedBy());
187 
188  // dcterms:created
189  $objWriter->startElement('dcterms:created');
190  $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
191  $objWriter->writeRaw(date(DATE_W3C, $pPHPExcel->getProperties()->getCreated()));
192  $objWriter->endElement();
193 
194  // dcterms:modified
195  $objWriter->startElement('dcterms:modified');
196  $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
197  $objWriter->writeRaw(date(DATE_W3C, $pPHPExcel->getProperties()->getModified()));
198  $objWriter->endElement();
199 
200  // dc:title
201  $objWriter->writeElement('dc:title', $pPHPExcel->getProperties()->getTitle());
202 
203  // dc:description
204  $objWriter->writeElement('dc:description', $pPHPExcel->getProperties()->getDescription());
205 
206  // dc:subject
207  $objWriter->writeElement('dc:subject', $pPHPExcel->getProperties()->getSubject());
208 
209  // cp:keywords
210  $objWriter->writeElement('cp:keywords', $pPHPExcel->getProperties()->getKeywords());
211 
212  // cp:category
213  $objWriter->writeElement('cp:category', $pPHPExcel->getProperties()->getCategory());
214 
215  $objWriter->endElement();
216 
217  // Return
218  return $objWriter->getData();
219  }
220 }