Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
12 / 12 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| AttachmentCollection | |
100.00% |
12 / 12 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getBreadcrumbs | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Attachment collection class. |
| 5 | * |
| 6 | * This Source Code Form is subject to the terms of the Mozilla Public License, |
| 7 | * v. 2.0. If a copy of the MPL was not distributed with this file, You can |
| 8 | * obtain one at https://mozilla.org/MPL/2.0/. |
| 9 | * |
| 10 | * @package phpMyFAQ |
| 11 | * @author Anatoliy Belsky <ab@php.net> |
| 12 | * @copyright 2010-2026 phpMyFAQ Team |
| 13 | * @license https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 |
| 14 | * @link https://www.phpmyfaq.de |
| 15 | * @since 2010-12-13 |
| 16 | */ |
| 17 | |
| 18 | declare(strict_types=1); |
| 19 | |
| 20 | namespace phpMyFAQ\Attachment; |
| 21 | |
| 22 | use phpMyFAQ\Configuration; |
| 23 | use phpMyFAQ\Database; |
| 24 | |
| 25 | /** |
| 26 | * Class Collection |
| 27 | * |
| 28 | * @package phpMyFAQ\Attachment |
| 29 | */ |
| 30 | class AttachmentCollection |
| 31 | { |
| 32 | /** |
| 33 | * Constructor. |
| 34 | */ |
| 35 | public function __construct( |
| 36 | protected Configuration $configuration, |
| 37 | ) { |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Get an array with minimalistic attachment metadata. |
| 42 | */ |
| 43 | public function getBreadcrumbs(): array |
| 44 | { |
| 45 | $breadCrumbs = []; |
| 46 | |
| 47 | $query = sprintf( |
| 48 | ' |
| 49 | SELECT |
| 50 | fa.id AS id, |
| 51 | fa.record_id AS record_id, |
| 52 | fa.record_lang AS record_lang, |
| 53 | fa.filename AS filename, |
| 54 | fa.filesize AS filesize, |
| 55 | fa.mime_type AS mime_type, |
| 56 | fd.thema AS thema |
| 57 | FROM |
| 58 | %s fa |
| 59 | JOIN |
| 60 | %s fd |
| 61 | ON |
| 62 | fa.record_id = fd.id |
| 63 | GROUP BY |
| 64 | fa.id,fa.record_id,fa.record_lang,fa.filename,fa.filesize,fa.mime_type,fd.thema', |
| 65 | Database::getTablePrefix() . 'faqattachment', |
| 66 | Database::getTablePrefix() . 'faqdata', |
| 67 | ); |
| 68 | |
| 69 | $result = $this->configuration->getDb()->query($query); |
| 70 | |
| 71 | if ($result) { |
| 72 | return $this->configuration->getDb()->fetchAll($result) ?? []; |
| 73 | } |
| 74 | |
| 75 | return $breadCrumbs; |
| 76 | } |
| 77 | } |