diff options
Diffstat (limited to 'lib/private/Preview/MarkDown.php')
-rw-r--r-- | lib/private/Preview/MarkDown.php | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/lib/private/Preview/MarkDown.php b/lib/private/Preview/MarkDown.php index d809c6a9443..c20433a1ac0 100644 --- a/lib/private/Preview/MarkDown.php +++ b/lib/private/Preview/MarkDown.php @@ -1,27 +1,10 @@ <?php + /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Joas Schilling <coding@schilljs.com> - * @author Robin Appelman <robin@icewind.nl> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ - namespace OC\Preview; use OCP\Files\File; @@ -42,7 +25,7 @@ class MarkDown extends TXT { return null; } - $content = stream_get_contents($content,3000); + $content = stream_get_contents($content, 3000); //don't create previews of empty text files if (trim($content) === '') { @@ -69,14 +52,14 @@ class MarkDown extends TXT { $lines = preg_split("/\r\n|\n|\r/", $content); // Define text size of text file preview - $fontSize = $maxX ? (int) ((1 / ($maxX >= 512 ? 60 : 40) * $maxX)) : 10; + $fontSize = $maxX ? (int)((1 / ($maxX >= 512 ? 60 : 40) * $maxX)) : 10; $image = imagecreate($maxX, $maxY); imagecolorallocate($image, 255, 255, 255); $textColor = imagecolorallocate($image, 0, 0, 0); - $fontFile = __DIR__ . '/../../../core/fonts/NotoSans-Regular.ttf'; - $fontFileBold = __DIR__ . '/../../../core/fonts/NotoSans-Bold.ttf'; + $fontFile = __DIR__ . '/../../../core/fonts/NotoSans-Regular.ttf'; + $fontFileBold = __DIR__ . '/../../../core/fonts/NotoSans-Bold.ttf'; $canUseTTF = function_exists('imagettftext'); @@ -118,7 +101,7 @@ class MarkDown extends TXT { // Get rid of markdown symbols that we still needed for the font size $line = preg_replace('/^#*\s/', '', $line); - $wrappedText = wordwrap($line, $wordWrap,"\n"); + $wrappedText = wordwrap($line, $wordWrap, "\n"); $linesWrapped = count(explode("\n", $wrappedText)); imagettftext($image, $actualFontSize, 0, $x, $y, $textColor, $actualFontSize === $fontSize ? $fontFile : $fontFileBold, $wrappedText); $nextLineStart = (int)($linesWrapped * ceil($actualFontSize * 2)); @@ -136,7 +119,7 @@ class MarkDown extends TXT { } } - $imageObject = new \OC_Image(); + $imageObject = new \OCP\Image(); $imageObject->setResource($image); return $imageObject->valid() ? $imageObject : null; |