Add the new variable `FileProcessorFormField::$bigPreview` with getter and setter.
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / data / I18nDatabaseObjectList.class.php
1 <?php
2
3 namespace wcf\data;
4
5 use wcf\system\WCF;
6
7 /**
8 * Abstract class for a list of database objects with better sorting of i18n-based columns.
9 *
10 * @author Florian Gail
11 * @copyright 2001-2019 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @since 3.1
14 */
15 abstract class I18nDatabaseObjectList extends DatabaseObjectList
16 {
17 /**
18 * Array of column names, that are eventually filled with language items.
19 * Those additional joins are going to slow down the system; you should use this
20 * class only when it's really needed.
21 * The key represents the original field name.
22 * The value represents the new field name containing the localized field-value.
23 *
24 * @example [ 'title' => 'titleSortField' ]
25 *
26 * @var string[]
27 */
28 public $i18nFields = [];
29
30 /**
31 * @inheritDoc
32 * @param int $languageID id of the language that should be used
33 * @throws \DomainException
34 */
35 public function __construct($languageID = null)
36 {
37 parent::__construct();
38
39 if ($languageID === null) {
40 $languageID = WCF::getLanguage()->languageID;
41 }
42
43 if (!empty($this->i18nFields)) {
44 if (\count($this->i18nFields) !== \count(\array_flip($this->i18nFields))) {
45 throw new \DomainException("Array values of '" . $this->className . "::\$i18nFields' must be unique.");
46 }
47
48 foreach ($this->i18nFields as $key => $value) {
49 if (!\preg_match('/^[a-z][a-zA-Z0-9]*$/', $key) || !\preg_match('/^[a-z][a-zA-Z0-9]*$/', $value)) {
50 throw new \DomainException("Array keys and values of '" . $this->className . "::\$i18nFields' must start with a small letter and consist of letters and number only.");
51 }
52
53 $matchTable = 'i18n_' . \sha1($key);
54
55 $this->sqlSelects .= (!empty($this->sqlSelects) ? ', ' : '') . "COALESCE(" . $matchTable . ".languageItemValue, " . $this->getDatabaseTableAlias() . "." . $key . ") AS " . $value;
56 $this->sqlJoins .= "
57 LEFT JOIN wcf" . WCF_N . "_language_item " . $matchTable . "
58 ON " . $matchTable . ".languageItem = " . $this->getDatabaseTableAlias() . "." . $key . "
59 AND " . $matchTable . ".languageID = " . $languageID;
60 }
61 }
62 }
63 }