Overview
Comment:Fix issues with changing file content
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1: 95618822faa39a6d93b9d9ac1e511efbf29cc70d
User & Date: bohwaz on 2020-12-15 02:42:52
Other Links: branch diff | manifest | tags
Context
2020-12-18
19:47
Refactor parent category chooser check-in: b0536631ef user: bohwaz tags: dev
2020-12-15
02:42
Fix issues with changing file content check-in: 95618822fa user: bohwaz tags: dev
02:30
Improve editor UX check-in: e728bcd203 user: bohwaz tags: dev
Changes

Modified src/include/lib/Garradin/Entities/Files/File.php from [24a98efb6a] to [f3f6bcc8c0].

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
		return $return;
	}

	public function store(string $source_path = null, $source_content = null): self
	{
		if ($source_path && !$source_content)
		{
			$this->hash = sha1_file($source_path);
			$this->size = filesize($source_path);
		}
		else
		{
			$this->hash = sha1($source_content);
			$this->size = strlen($source_content);
		}

		// Check that it's a real image
		if ($this->image) {
			try {
				if ($source_path && !$source_content) {
					$i = new Image($source_path);
				}
				else {
					$i = Image::createFromBlob($source_content);
				}

				// Recompress PNG files from base64, assuming they are coming
				// from JS canvas which doesn't know how to gzip (d'oh!)
				if ($i->format() == 'png' && null !== $source_content) {
					$source_content = $i->output('png', true);
					$this->hash = sha1($source_content);
					$this->size = strlen($source_content);
				}

				unset($i);
			}
			catch (\RuntimeException $e) {
				if (strstr($e->getMessage(), 'No suitable image library found')) {
					throw new \RuntimeException('Le serveur n\'a aucune bibliothèque de gestion d\'image installée, et ne peut donc pas accepter les images. Installez Imagick ou GD.');







|
|



|
|
















|
|







108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
		return $return;
	}

	public function store(string $source_path = null, $source_content = null): self
	{
		if ($source_path && !$source_content)
		{
			$this->set('hash', sha1_file($source_path));
			$this->set('size', filesize($source_path));
		}
		else
		{
			$this->set('hash', sha1($source_content));
			$this->set('size', strlen($source_content));
		}

		// Check that it's a real image
		if ($this->image) {
			try {
				if ($source_path && !$source_content) {
					$i = new Image($source_path);
				}
				else {
					$i = Image::createFromBlob($source_content);
				}

				// Recompress PNG files from base64, assuming they are coming
				// from JS canvas which doesn't know how to gzip (d'oh!)
				if ($i->format() == 'png' && null !== $source_content) {
					$source_content = $i->output('png', true);
					$this->set('hash', sha1($source_content));
					$this->set('size', strlen($source_content));
				}

				unset($i);
			}
			catch (\RuntimeException $e) {
				if (strstr($e->getMessage(), 'No suitable image library found')) {
					throw new \RuntimeException('Le serveur n\'a aucune bibliothèque de gestion d\'image installée, et ne peut donc pas accepter les images. Installez Imagick ou GD.');

Modified src/include/lib/Garradin/Web/Render/Skriv.php from [2301b08c1b] to [f2817d6077].

1
2
3
4
5
6
7
8

9
10
11
12
13
14
15
<?php

namespace Garradin\Web\Render;

use Garradin\Entities\Files\File;

use Garradin\Squelette_Filtres;
use Garradin\Plugin;

use Garradin\Files\Files;

use KD2\SkrivLite;

class Skriv
{
	static protected $skriv;








>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php

namespace Garradin\Web\Render;

use Garradin\Entities\Files\File;

use Garradin\Squelette_Filtres;
use Garradin\Plugin;
use Garradin\Utils;
use Garradin\Files\Files;

use KD2\SkrivLite;

class Skriv
{
	static protected $skriv;
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
		}, $str);

		$str = self::$skriv->render($str);

		$str = Squelette_Filtres::typo_fr($str);

		$str = preg_replace_callback('!<a href="([^/.:@]+)">!i', function ($matches) use ($options) {
			return sprintf('<a href="%s%s">', $options['prefix'], self::transformTitleToURI($matches[1]));
		}, $str);

		return $str;
	}

	/**
	 * Callback utilisé pour l'extension <<fichier>> dans le wiki-texte







|







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
		}, $str);

		$str = self::$skriv->render($str);

		$str = Squelette_Filtres::typo_fr($str);

		$str = preg_replace_callback('!<a href="([^/.:@]+)">!i', function ($matches) use ($options) {
			return sprintf('<a href="%s%s">', $options['prefix'], Utils::transformTitleToURI($matches[1]));
		}, $str);

		return $str;
	}

	/**
	 * Callback utilisé pour l'extension <<fichier>> dans le wiki-texte