forked from textpattern/textpattern
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm.php
More file actions
174 lines (145 loc) · 4.6 KB
/
Copy pathForm.php
File metadata and controls
174 lines (145 loc) · 4.6 KB
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
/*
* Textpattern Content Management System
* https://textpattern.com/
*
* Copyright (C) 2020 The Textpattern Development Team
*
* This file is part of Textpattern.
*
* Textpattern is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, version 2.
*
* Textpattern is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Textpattern. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* Form
*
* Manages Form.
*
* @since 4.7.0
* @package Skin
*/
namespace Textpattern\Skin;
class Form extends AssetBase implements FormInterface, \Textpattern\Container\FactorableInterface
{
/**
* {@inheritdoc}
*/
protected static $dir = 'forms';
/**
* {@inheritdoc}
*/
protected static $subdirField = 'type';
/**
* The expected subdirs for this asset type.
*
* Note the order of the values is the order the blocks appear in the
* Presentation->Forms panel.
*
* @var array
*/
protected static $subdirValues = array('article', 'misc', 'category', 'comment', 'file', 'link', 'section');
/**
* {@inheritdoc}
*/
protected static $defaultSubdir = 'misc';
/**
* {@inheritdoc}
*/
protected static $fileContentsField = 'Form';
/**
* {@inheritdoc}
*/
protected static $essential = array(
array(
'name' => 'comments',
'type' => 'comment',
'Form' => '<!-- Default contents of the comments tag goes here. See https://docs.textpattern.com/tags/comments. -->',
),
array(
'name' => 'comments_display',
'type' => 'comment',
'Form' => '<!-- Default contents of the popup_comments tag goes here. See https://docs.textpattern.com/tags/popup_comments. -->',
),
array(
'name' => 'comment_form',
'type' => 'comment',
'Form' => '<!-- Default contents of the comments_form tag goes here. See https://docs.textpattern.com/tags/comments_form. -->',
),
array(
'name' => 'default',
'type' => 'article',
'Form' => '<!-- Default contents of the article tag goes here. See https://docs.textpattern.com/tags/article. -->',
),
array(
'name' => 'plainlinks',
'type' => 'link',
'Form' => '<!-- Default contents of the linklist tag goes here. See https://docs.textpattern.com/tags/linklist. -->',
),
array(
'name' => 'files',
'type' => 'file',
'Form' => '<!-- Default contents of the file_download tag goes here. See https://docs.textpattern.com/tags/file_download. -->',
),
);
/**
* Constructor
*/
public function getInstance()
{
global $lang_ui;
$textarray = array();
if ($custom_types = parse_ini_string(get_pref('custom_form_types'), true)) {
foreach ($custom_types as $type => $langpack) {
if (!empty($langpack['mediatype'])) {
static::$mimeTypes[$type] = $langpack['mediatype'];
}
$textarray[$type] = isset($langpack[$lang_ui]) ?
$langpack[$lang_ui] :
(isset($langpack['title']) ?
$langpack['title'] :
(isset(static::$mimeTypes[$type]) ?
strtoupper($type)." (".static::$mimeTypes[$type].")"
: $type
)
);
}
} else {
$custom_types = array();
}
\Txp::get('\Textpattern\L10n\Lang')->setPack($textarray, true);
static::$subdirValues = array_unique(array_merge(
static::$subdirValues,
array_keys($custom_types),
array_keys(static::$mimeTypes)
));
return $this;
}
/**
* {@inheritdoc}
*/
public function setInfos(
$name,
$type = null,
$Form = null
) {
$name = $this->setName($name)->getName();
$this->infos = compact('name', 'type', 'Form');
return $this;
}
/**
* $defaultSubdir property getter.
*/
public static function getTypes()
{
return static::$subdirValues;
}
}