Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
8a309525
Commit
8a309525
authored
Feb 02, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(mvc) add easier model wrapper for default search behavior
parent
3592b64f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
UIModelGrid.php
src/opnsense/mvc/app/library/OPNsense/Base/UIModelGrid.php
+25
-0
No files found.
src/opnsense/mvc/app/library/OPNsense/Base/UIModelGrid.php
View file @
8a309525
...
@@ -49,6 +49,31 @@ class UIModelGrid
...
@@ -49,6 +49,31 @@ class UIModelGrid
$this
->
DataField
=
$DataField
;
$this
->
DataField
=
$DataField
;
}
}
/**
* default model search
* @param $request request variable
* @param array $fields to collect
* @param null|string $defaultSort default sort order
* @return array
*/
public
function
fetchBindRequest
(
$request
,
$fields
,
$defaultSort
=
null
)
{
$itemsPerPage
=
$request
->
get
(
'rowCount'
,
'int'
,
9999
);
$currentPage
=
$request
->
get
(
'current'
,
'int'
,
1
);
$sortBy
=
array
(
$defaultSort
);
$sortDescending
=
false
;
if
(
$request
->
has
(
'sort'
)
&&
is_array
(
$request
->
get
(
"sort"
)))
{
$sortBy
=
array_keys
(
$request
->
get
(
"sort"
));
if
(
$request
->
get
(
"sort"
)[
$sortBy
[
0
]]
==
"desc"
)
{
$sortDescending
=
true
;
}
}
$searchPhrase
=
$request
->
get
(
'searchPhrase'
,
'string'
,
''
);
return
$this
->
fetch
(
$fields
,
$itemsPerPage
,
$currentPage
,
$sortBy
,
$sortDescending
,
$searchPhrase
);
}
/**
/**
* Fetch data from Array type field (Base\FieldTypes\ArrayField), sorted by specified fields and optionally filtered
* Fetch data from Array type field (Base\FieldTypes\ArrayField), sorted by specified fields and optionally filtered
* @param array $fields select fieldnames
* @param array $fields select fieldnames
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment