1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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
|
<?php
namespace SMW\MediaWiki\Specials\Browse;
use Html;
use SMW\Message;
use SpecialPage;
/**
* @private
*
* This class should eventually be injected instead of relying on static methods,
* for now this is the easiest way to unclutter the mammoth Browse class and
* splitting up responsibilities.
*
* @license GNU GPL v2+
* @since 2.5
*
* @author mwjames
*/
class FieldBuilder {
/**
* Creates the query form in order to quickly switch to a specific article.
*
* @since 2.5
*
* @return string
*/
public static function createQueryForm( $articletext = '' ) {
$title = SpecialPage::getTitleFor( 'Browse' );
$dir = $title->getPageLanguage()->isRTL() ? 'rtl' : 'ltr';
$html = "<div class=\"smwb-form\">". Html::rawElement(
'div',
[ 'style' => 'margin-top:15px;' ],
''
);
$html .= Html::rawElement(
'form',
[
'name' => 'smwbrowse',
'action' => htmlspecialchars( $title->getLocalURL() ),
'method' => 'get'
],
Html::rawElement(
'input',
[
'type' => 'hidden',
'name' => 'title',
'value' => $title->getPrefixedText()
],
Message::get( 'smw_browse_article', Message::ESCAPED, Message::USER_LANGUAGE )
) .
Html::rawElement(
'div',
[
'class' => 'smwb-input'
],
Html::rawElement(
'div',
[
'class' => 'input-field'
],
Html::rawElement(
'input',
[
'type' => 'text',
'dir' => $dir,
'name' => 'article',
'size' => 40,
'id' => 'smw-page-input',
'class' => 'input smw-page-input autocomplete-arrow mw-ui-input',
'value' => htmlspecialchars( $articletext )
]
)
) .
Html::rawElement(
'div',
[
'class' => 'button-field'
],
Html::rawElement(
'input',
[
'type' => 'submit',
'class' => 'input-button mw-ui-button',
'value' => Message::get( 'smw_browse_go', Message::ESCAPED, Message::USER_LANGUAGE )
]
)
)
)
);
return $html . "</div>";
}
/**
* Creates the HTML for a link to this page, with some parameters set.
*
* @since 2.5
*
* @param string $linkMsg
* @param array $parameters
*
* @return string
*/
public static function createLink( $linkMsg, array $parameters ) {
$title = SpecialPage::getSafeTitleFor( 'Browse' );
$fragment = $linkMsg === 'smw_browse_show_incoming' ? '#smw_browse_incoming' : '';
return Html::element(
'a',
[
'href' => $title->getLocalURL( $parameters ) . $fragment,
'class' => $linkMsg
],
Message::get( $linkMsg, Message::TEXT, Message::USER_LANGUAGE )
);
}
}
|