Overview
Comment:Fix [9de0e8bedad3d7f412b66ed6e1fd892bee3eccf1] fix links to images and files from other pages
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA3-256: e35246d917a442db3002672c2220641ade0ef2c602eec9baf8a68ed5aba21055
User & Date: bohwaz on 2021-04-07 14:08:53
Other Links: branch diff | manifest | tags
Context
2021-04-07
18:58
Fix in case string is null check-in: 82ea8f2e97 user: bohwaz tags: dev
14:08
Fix [9de0e8bedad3d7f412b66ed6e1fd892bee3eccf1] fix links to images and files from other pages check-in: e35246d917 user: bohwaz tags: dev
2021-04-06
19:12
Improve account selector search check-in: 605e25ef2f user: bohwaz tags: dev
Changes

Modified src/include/lib/Garradin/Upgrade.php from [0eaf6a479e] to [9dcecc2edd].

93
94
95
96
97
98
99
100


101
102
103


104











105

106
107
108
109
110
111
112
			}

			if (version_compare($v, '1.1.0-beta1', '<'))
			{
				// Missing trigger
				$db->beginSchemaUpdate();

				$attachments = $db->getAssoc('SELECT id, id || \'_\' || nom FROM fichiers;');



				// Update Skriv content for attachments
				foreach ($db->iterate('SELECT rowid, contenu FROM wiki_revisions;') as $r) {


					$content = preg_replace_callback('!<<(image|fichier)\s*\|\s*(\d+)\s*(?:\|\s*(gauche|droite|centre))?\s*(?:\|\s*(.+)\s*)?>>!', function ($match) use ($attachments) {











						$name = $attachments[$match[2]] ?? '_ERREUR_fichier_inconnu_' . $match[2];


						if (isset($match[3])) {
							$align = '|' . ($match[3] == 'centre' ? 'center' : ($match[3] == 'gauche' ? 'left' : 'right'));
						}
						else {
							$align = '';
						}







|
>
>


<
>
>
|
>
>
>
>
>
>
>
>
>
>
>
|
>







93
94
95
96
97
98
99
100
101
102
103
104

105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
			}

			if (version_compare($v, '1.1.0-beta1', '<'))
			{
				// Missing trigger
				$db->beginSchemaUpdate();

				$attachments = $db->getAssoc('SELECT f.id, w.uri || \'/\' || f.id || \'_\' || f.nom FROM fichiers f
					INNER JOIN fichiers_wiki_pages fw ON fw.fichier = f.id
					INNER JOIN wiki_pages w ON w.id = fw.id;');

				// Update Skriv content for attachments

				foreach ($db->iterate('SELECT r.rowid, r.contenu, p.uri FROM wiki_revisions r INNER JOIN wiki_pages p ON p.revision = r.revision AND p.id = r.id_page;') as $r) {
					$uri = $r->uri;
					$content = preg_replace_callback('!<<(image|fichier)\s*\|\s*(\d+)\s*(?:\|\s*(gauche|droite|centre))?\s*(?:\|\s*(.+)\s*)?>>!', function ($match) use ($attachments, $uri) {
						if (isset($attachments[$match[2]])) {
							$name = $attachments[$match[2]];

							if (dirname($name) == $uri) {
								$name = basename($name);
							}
							else {
								$name = '../' . $name;
							}
						}
						else {
							$name = '_ERREUR_fichier_inconnu_' . $match[2];
						}

						if (isset($match[3])) {
							$align = '|' . ($match[3] == 'centre' ? 'center' : ($match[3] == 'gauche' ? 'left' : 'right'));
						}
						else {
							$align = '';
						}