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
34c211ce
Commit
34c211ce
authored
7 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
Advanced Search: Describe Search Field
Add DateTimeField search descriptions options for supported methods
parent
1f37c778
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/class.forms.php
+47
-17
47 additions, 17 deletions
include/class.forms.php
with
47 additions
and
17 deletions
include/class.forms.php
+
47
−
17
View file @
34c211ce
...
...
@@ -999,10 +999,17 @@ class FormField {
return
__
(
'%s not in (%s)'
);
}
}
function
describeSearch
(
$method
,
$value
,
$name
=
false
)
{
$name
=
$name
?:
$this
->
get
(
'name'
);
$desc
=
$this
->
describeSearchMethod
(
$method
);
$value
=
$this
->
toString
(
$value
);
return
sprintf
(
$desc
,
$name
,
$value
);
switch
(
$method
)
{
case
'set'
:
case
'nset'
:
return
sprintf
(
$desc
,
$name
);
default
:
return
sprintf
(
$desc
,
$name
,
$this
->
toString
(
$value
));
}
}
function
addToQuery
(
$query
,
$name
=
false
)
{
...
...
@@ -1935,6 +1942,18 @@ class DatetimeField extends FormField {
var
$min
=
null
;
var
$max
=
null
;
static
function
intervals
(
$count
=
2
,
$i
=
''
)
{
$intervals
=
array
(
'i'
=>
_N
(
'minute'
,
'minutes'
,
$count
),
'h'
=>
_N
(
'hour'
,
'hours'
,
$count
),
'd'
=>
_N
(
'day'
,
'days'
,
$count
),
'w'
=>
_N
(
'week'
,
'weeks'
,
$count
),
'm'
=>
_N
(
'month'
,
'months'
,
$count
),
);
return
$i
?
$intervals
[
$i
]
:
$intervals
;
}
// Get php DatateTime object of the field - null if value is empty
function
getDateTime
(
$value
=
null
)
{
return
Format
::
parseDateTime
(
$value
?:
$this
->
value
);
...
...
@@ -2154,21 +2173,14 @@ class DatetimeField extends FormField {
function
getSearchMethodWidgets
()
{
$config_notime
=
$config
=
$this
->
getConfiguration
();
$config_notime
[
'time'
]
=
false
;
$nday_form
=
function
()
{
$intervals
=
array
(
'i'
=>
_N
(
'minute'
,
'minutes'
,
5
),
'h'
=>
_N
(
'hour'
,
'hours'
,
5
),
'd'
=>
_N
(
'day'
,
'days'
,
5
),
'w'
=>
_N
(
'week'
,
'weeks'
,
5
),
'm'
=>
_N
(
'month'
,
'months'
,
5
),
);
$nday_form
=
function
(
$x
=
5
)
{
return
array
(
'until'
=>
new
TextboxField
(
array
(
'configuration'
=>
array
(
'validator'
=>
'number'
,
'size'
=>
4
))
),
'int'
=>
new
ChoiceField
(
array
(
'default'
=>
'd'
,
'choices'
=>
$
intervals
,
'choices'
=>
self
::
intervals
(
$x
)
,
)),
);
};
...
...
@@ -2312,13 +2324,31 @@ class DatetimeField extends FormField {
}
function
describeSearch
(
$method
,
$value
,
$name
=
false
)
{
if
(
$method
===
'between'
)
{
$l
=
$this
->
toString
(
$value
[
'left'
]);
$r
=
$this
->
toString
(
$value
[
'right'
]);
$desc
=
$this
->
describeSearchMethod
(
$method
);
return
sprintf
(
$desc
,
$name
,
$l
,
$r
);
$name
=
$name
?:
$this
->
get
(
'name'
);
$desc
=
$this
->
describeSearchMethod
(
$method
);
switch
(
$method
)
{
case
'between'
:
return
sprintf
(
$desc
,
$name
,
$this
->
toString
(
$value
[
'left'
]),
$this
->
toString
(
$value
[
'right'
]));
case
'ndays'
:
case
'ndaysago'
:
case
'distfut'
:
case
'distpast'
:
$interval
=
sprintf
(
'%s %s'
,
$value
[
'until'
],
self
::
intervals
(
$value
[
'until'
],
$value
[
'int'
]));
return
sprintf
(
$desc
,
$name
,
$interval
);
break
;
case
'future'
:
case
'past'
:
return
sprintf
(
$desc
,
$name
);
case
'before'
:
case
'after'
:
return
sprintf
(
$desc
,
$name
,
$this
->
toString
(
$value
));
default
:
return
parent
::
describeSearch
(
$method
,
$value
,
$name
);
}
return
parent
::
describeSearch
(
$method
,
$value
,
$name
);
}
function
supportsQuickFilter
()
{
...
...
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