Add sort order form field
authorMatthias Schmidt <gravatronics@live.com>
Mon, 28 May 2018 18:41:06 +0000 (20:41 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 28 May 2018 18:41:06 +0000 (20:41 +0200)
See #2509

wcfsetup/install/files/lib/system/form/builder/field/SortOrderFormField.class.php [new file with mode: 0644]

diff --git a/wcfsetup/install/files/lib/system/form/builder/field/SortOrderFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/SortOrderFormField.class.php
new file mode 100644 (file)
index 0000000..d7f9985
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+namespace wcf\system\form\builder\field;
+
+/**
+ * Implementation of a form field to set the sort order.
+ * 
+ * This field uses the `wcf.global.showOrder` language item as the default
+ * form field label and uses `ASC` and `DESC` as the default options.
+ * 
+ * @author     Matthias Schmidt
+ * @copyright  2001-2018 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\Form\Builder\Field
+ * @since      3.2
+ */
+class SortOrderFormField extends SingleSelectionFormField {
+       use TDefaultIdFormField;
+       
+       /**
+        * @inheritDoc
+        */
+       public function __construct() {
+               $this->label('wcf.global.showOrder');
+               $this->options([
+                       'ASC' => 'wcf.global.sortOrder.ascending',
+                       'DESC' => 'wcf.global.sortOrder.descending',
+               ]);
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       protected static function getDefaultId(): string {
+               return 'sortOrder';
+       }
+}