@@ -137,8 +137,9 @@ discard block |
||
| 137 | 137 | protected function MustacheRender($items, $mustache_template) |
| 138 | 138 | { |
| 139 | 139 | $m = new \Mustache_Engine(array('escape' => function($value) { |
| 140 | - if (str_replace('*[[DONOTESCAPE]]*', '', $value) != $value) |
|
| 141 | - return str_replace('*[[DONOTESCAPE]]*', '', $value); |
|
| 140 | + if (str_replace('*[[DONOTESCAPE]]*', '', $value) != $value) { |
|
| 141 | + return str_replace('*[[DONOTESCAPE]]*', '', $value); |
|
| 142 | + } |
|
| 142 | 143 | return htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); |
| 143 | 144 | })); |
| 144 | 145 | return $m->render($mustache_template, $items); |
@@ -163,8 +164,9 @@ discard block |
||
| 163 | 164 | $jpeg_already_set = false; |
| 164 | 165 | foreach ($ct_file as $ct) |
| 165 | 166 | { |
| 166 | - if ((string) $ct_file->Default[$i]['Extension'] == "jpeg") |
|
| 167 | - $jpeg_already_set = true; |
|
| 167 | + if ((string) $ct_file->Default[$i]['Extension'] == "jpeg") { |
|
| 168 | + $jpeg_already_set = true; |
|
| 169 | + } |
|
| 168 | 170 | $i++; |
| 169 | 171 | } |
| 170 | 172 | |
@@ -293,10 +295,11 @@ discard block |
||
| 293 | 295 | $img_rework = \Image::make($this->storagePath($this->local_path.'word/media/'.$imgs[$k]['img_file_src'])); |
| 294 | 296 | $w = $img['width']; |
| 295 | 297 | $h = $img['height']; |
| 296 | - if ($w > $h) |
|
| 297 | - $h = null; |
|
| 298 | - else |
|
| 299 | - $w = null; |
|
| 298 | + if ($w > $h) { |
|
| 299 | + $h = null; |
|
| 300 | + } else { |
|
| 301 | + $w = null; |
|
| 302 | + } |
|
| 300 | 303 | $img_rework->resize($w, $h, function($constraint) { |
| 301 | 304 | $constraint->aspectRatio(); |
| 302 | 305 | $constraint->upsize(); |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | $sxe->addAttribute('Extension', 'jpeg'); |
| 172 | 172 | $sxe->addAttribute('ContentType', 'image/jpeg'); |
| 173 | 173 | |
| 174 | - if($ct_file_xml = $ct_file->asXML()) |
|
| 174 | + if ($ct_file_xml = $ct_file->asXML()) |
|
| 175 | 175 | { |
| 176 | 176 | \Storage::disk($this->storageDisk)->put($this->local_path.'[Content_Types].xml', $ct_file_xml); |
| 177 | 177 | $this->zipper->add($this->storagePath($this->local_path.'[Content_Types].xml')); |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - if($rels_file_xml = $rels_file->asXML()) |
|
| 338 | + if ($rels_file_xml = $rels_file->asXML()) |
|
| 339 | 339 | { |
| 340 | 340 | \Storage::disk($this->storageDisk)->put($this->local_path.'word/_rels/document.xml.rels', $rels_file_xml); |
| 341 | 341 | $this->zipper->folder('word/_rels')->add($this->storagePath($this->local_path.'word/_rels/document.xml.rels')); |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | throw new Exception('canot generate xml for word/_rels/document.xml.rels.'); |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - if($main_file_xml = $main_file->asXML()) |
|
| 347 | + if ($main_file_xml = $main_file->asXML()) |
|
| 348 | 348 | { |
| 349 | 349 | $this->word_doc = $main_file_xml; |
| 350 | 350 | } else |
@@ -426,10 +426,10 @@ discard block |
||
| 426 | 426 | $value_array[] = $tag_open_values[0]; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - $value = implode('',$value_array); |
|
| 429 | + $value = implode('', $value_array); |
|
| 430 | 430 | |
| 431 | - if($run_again) { |
|
| 432 | - $value = $this->convertHtmlToOpenXMLTag($value,$tag); |
|
| 431 | + if ($run_again) { |
|
| 432 | + $value = $this->convertHtmlToOpenXMLTag($value, $tag); |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | return $value; |
@@ -440,8 +440,8 @@ discard block |
||
| 440 | 440 | */ |
| 441 | 441 | protected function convertHtmlToOpenXML($value) |
| 442 | 442 | { |
| 443 | - $line_breaks = array("<br />","<br/>","<br>","<br />","<br/>","<br>"); |
|
| 444 | - $value = str_replace($line_breaks,'<w:br/>',$value); |
|
| 443 | + $line_breaks = array("<br />", "<br/>", "<br>", "<br />", "<br/>", "<br>"); |
|
| 444 | + $value = str_replace($line_breaks, '<w:br/>', $value); |
|
| 445 | 445 | |
| 446 | 446 | $value = $this->convertHtmlToOpenXMLTag($value, "b"); |
| 447 | 447 | $value = $this->convertHtmlToOpenXMLTag($value, "i"); |
@@ -119,12 +119,19 @@ |
||
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | + /** |
|
| 123 | + * @param string $content |
|
| 124 | + */ |
|
| 122 | 125 | protected function MustacheTagCleaner($content) |
| 123 | 126 | { |
| 124 | 127 | //kills all xml tags within curly mustache brackets |
| 125 | 128 | //this is necessary, as word might produce unnecesary xml tage inbetween curly backets. |
| 126 | 129 | return preg_replace_callback( |
| 127 | 130 | '/{{(.*?)}}/', |
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * @param string $treffer |
|
| 134 | + */ |
|
| 128 | 135 | function($treffer) { |
| 129 | 136 | return strip_tags($treffer[0]); |
| 130 | 137 | }, |