Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker
osticket
Commits
90210e2b
Commit
90210e2b
authored
8 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
Add Timezone Field
parent
4cc6a353
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/class.forms.php
+80
-0
80 additions, 0 deletions
include/class.forms.php
with
80 additions
and
0 deletions
include/class.forms.php
+
80
−
0
View file @
90210e2b
...
...
@@ -529,6 +529,7 @@ class FormField {
'memo'
=>
array
(
/* @trans */
'Long Answer'
,
'TextareaField'
),
'thread'
=>
array
(
/* @trans */
'Thread Entry'
,
'ThreadEntryField'
,
false
),
'datetime'
=>
array
(
/* @trans */
'Date and Time'
,
'DatetimeField'
),
'timezone'
=>
array
(
/* @trans */
'Timezone'
,
'TimezoneField'
),
'phone'
=>
array
(
/* @trans */
'Phone Number'
,
'PhoneField'
),
'bool'
=>
array
(
/* @trans */
'Checkbox'
,
'BooleanField'
),
'choices'
=>
array
(
/* @trans */
'Choices'
,
'ChoiceField'
),
...
...
@@ -2177,6 +2178,44 @@ FormField::addFieldTypes(/*@trans*/ 'Dynamic Fields', function() {
});
class
TimezoneField
extends
ChoiceField
{
static
$widget
=
'TimezoneWidget'
;
function
hasIdValue
()
{
return
false
;
}
function
getChoices
(
$verbose
=
false
)
{
global
$cfg
;
$choices
=
array
();
foreach
(
DateTimeZone
::
listIdentifiers
()
as
$zone
)
$choices
[
$zone
]
=
str_replace
(
'/'
,
' / '
,
$zone
);
return
$choices
;
}
function
searchable
(
$value
)
{
return
null
;
}
function
getConfigurationOptions
()
{
return
array
(
'autodetect'
=>
new
BooleanField
(
array
(
'id'
=>
1
,
'label'
=>
__
(
'Auto Detect'
),
'required'
=>
false
,
'default'
=>
true
,
'configuration'
=>
array
(
'desc'
=>
__
(
'Add Auto Detect Button'
))
)),
'prompt'
=>
new
TextboxField
(
array
(
'id'
=>
2
,
'label'
=>
__
(
'Prompt'
),
'required'
=>
false
,
'default'
=>
''
,
'hint'
=>
__
(
'Leading text shown before a value is selected'
),
'configuration'
=>
array
(
'size'
=>
40
,
'length'
=>
40
),
)),
);
}
}
class
DepartmentField
extends
ChoiceField
{
function
getWidget
(
$widgetClass
=
false
)
{
$widget
=
parent
::
getWidget
(
$widgetClass
);
...
...
@@ -3463,6 +3502,47 @@ class TabbedBoxChoicesWidget extends BoxChoicesWidget {
}
}
/**
* TimezoneWidget extends ChoicesWidget to add auto-detect and select2 search
* options
*
**/
class
TimezoneWidget
extends
ChoicesWidget
{
function
render
(
$options
=
array
())
{
parent
::
render
(
$options
);
$config
=
$this
->
field
->
getConfiguration
();
if
(
@
$config
[
'autodetect'
])
{
?>
<button
type=
"button"
class=
"action-button"
onclick=
"javascript:
$('head').append($('<script>').attr('src', '
<?php
echo
ROOT_PATH
;
?>
js/jstz.min.js'));
var recheck = setInterval(function() {
if (window.jstz !== undefined) {
clearInterval(recheck);
var zone = jstz.determine();
$('#
<?php
echo
$this
->
id
;
?>
').val(zone.name()).trigger('change');
}
}, 100);
return false;"
style=
"vertical-align:middle"
>
<i
class=
"icon-map-marker"
></i>
<?php
echo
__
(
'Auto Detect'
);
?>
</button>
<?php
}
?>
<script
type=
"text/javascript"
>
$
(
function
()
{
$
(
'
#
<?php
echo
$this
->
id
;
?>
'
).
select2
({
allowClear
:
true
,
width
:
'
300px
'
});
});
</script>
<?php
}
}
class
CheckboxWidget
extends
Widget
{
function
__construct
(
$field
)
{
parent
::
__construct
(
$field
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment