Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 48
0.00% covered (danger)
0.00%
0 / 16
CRAP
0.00% covered (danger)
0.00%
0 / 1
PFTextWithAutocompleteInput
0.00% covered (danger)
0.00%
0 / 48
0.00% covered (danger)
0.00%
0 / 16
420
0.00% covered (danger)
0.00%
0 / 1
 getName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 __construct
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
12
 getDefaultPropTypes
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getOtherPropTypesHandled
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDefaultPropTypeLists
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getOtherPropTypeListsHandled
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDefaultCargoTypes
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getOtherCargoTypesHandled
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDefaultCargoTypeLists
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getOtherCargoTypeListsHandled
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getHTML
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getAutocompletionParameters
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 1
2
 getParameters
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 getAlias
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 getHtmlText
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
 getResourceModuleNames
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2/**
3 * @file
4 * @ingroup PF
5 */
6
7/**
8 * @ingroup PFFormInput
9 */
10class PFTextWithAutocompleteInput extends PFTextInput {
11    private static $alias;
12
13    public static function getName(): string {
14        return 'text with autocomplete';
15    }
16
17    public function __construct( $input_number, $cur_value, $input_name, $disabled, array $other_args ) {
18        parent::__construct( $input_number, $cur_value, $input_name, $disabled, $other_args );
19        $isList = ( array_key_exists( 'is_list', $other_args ) && $other_args['is_list'] == true );
20        if ( $isList ) {
21            self::$alias = 'PFTokensInput';
22        } else {
23            self::$alias = 'PFComboBoxInput';
24        }
25    }
26
27    public static function getDefaultPropTypes() {
28        return call_user_func( self::getAlias() . "::getDefaultPropTypes" );
29    }
30
31    public static function getOtherPropTypesHandled() {
32        return call_user_func( self::getAlias() . "::getOtherPropTypesHandled" );
33    }
34
35    public static function getDefaultPropTypeLists() {
36        return call_user_func( self::getAlias() . "::getDefaultPropTypeLists" );
37    }
38
39    public static function getOtherPropTypeListsHandled() {
40        return call_user_func( self::getAlias() . "::getOtherPropTypeListsHandled" );
41    }
42
43    public static function getDefaultCargoTypes() {
44        return call_user_func( self::getAlias() . "::getDefaultCargoTypes" );
45    }
46
47    public static function getOtherCargoTypesHandled() {
48        return call_user_func( self::getAlias() . "::getOtherCargoTypesHandled" );
49    }
50
51    public static function getDefaultCargoTypeLists() {
52        return call_user_func( self::getAlias() . "::getDefaultCargoTypeLists" );
53    }
54
55    public static function getOtherCargoTypeListsHandled() {
56        return call_user_func( self::getAlias() . "::getOtherCargoTypeListsHandled" );
57    }
58
59    public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, array $other_args ) {
60        return call_user_func( self::getAlias() . "::getHTML", $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args );
61    }
62
63    public static function getAutocompletionParameters() {
64        $params = PFEnumInput::getValuesParameters();
65        $params[] = [
66            'name' => 'values from url',
67            'type' => 'string',
68            'description' => wfMessage( 'pf_forminputs_valuesfromurl' )->text()
69        ];
70        $params[] = [
71            'name' => 'list',
72            'type' => 'boolean',
73            'description' => wfMessage( 'pf_forminputs_list' )->text()
74        ];
75        $params[] = [
76            'name' => 'delimiter',
77            'type' => 'string',
78            'description' => wfMessage( 'pf_forminputs_delimiter' )->text()
79        ];
80        return $params;
81    }
82
83    public static function getParameters() {
84        $params = parent::getParameters();
85        $params = array_merge( $params, self::getAutocompletionParameters() );
86        return $params;
87    }
88
89    protected static function getAlias() {
90        if ( isset( self::$alias ) ) {
91            return self::$alias;
92        } else {
93            return 'PFComboBoxInput';
94        }
95    }
96
97    /**
98     * Returns the HTML code to be included in the output page for this input.
99     * @return string
100     */
101    public function getHtmlText(): string {
102        return self::getHTML(
103            $this->mCurrentValue,
104            $this->mInputName,
105            $this->mIsMandatory,
106            $this->mIsDisabled,
107            $this->mOtherArgs
108        );
109    }
110
111    public function getResourceModuleNames() {
112        // It would have been better to call the getResourceModuleNames()
113        // methods for these two classes directly, but that's a little
114        // tricky to do because (for no good reason) this is not a
115        // static method.
116        if ( self::$alias == 'PFTokensInput' ) {
117            return [];
118        } else {
119            return [ 'ext.pageforms.ooui.combobox' ];
120        }
121    }
122
123}