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
ded69cf6
Commit
ded69cf6
authored
Feb 08, 2016
by
Ad Schellevis
Committed by
Franco Fichtner
Feb 14, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(mvc) add ChangeCase to base field type, enforces case on change event
(cherry picked from commit
c3358d74
)
parent
ab143f7e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
BaseField.php
...nse/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php
+39
-0
No files found.
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php
View file @
ded69cf6
...
...
@@ -102,6 +102,11 @@ abstract class BaseField
*/
protected
$internalAttributes
=
array
();
/**
* @var string $internalToLower
*/
private
$internalChangeCase
=
null
;
/**
* generate a new UUID v4 number
* @return string uuid v4 number
...
...
@@ -274,6 +279,11 @@ abstract class BaseField
$this
->
internalInitialValue
=
$value
;
}
$this
->
internalValue
=
$value
;
// apply filters, may be extended later.
$filters
=
array
(
'applyFilterChangeCase'
);
foreach
(
$filters
as
$filter
)
{
$this
->
$filter
();
}
}
/**
...
...
@@ -539,6 +549,35 @@ abstract class BaseField
}
}
/**
* change character case on save
* @param string $value set case type, upper, lower, null (don't change)
*/
public
function
setChangeCase
(
$value
)
{
if
(
strtoupper
(
trim
(
$value
))
==
'UPPER'
)
{
$this
->
internalChangeCase
=
'UPPER'
;
}
elseif
(
strtoupper
(
trim
(
$value
))
==
'LOWER'
)
{
$this
->
internalChangeCase
=
'LOWER'
;
}
else
{
$this
->
internalChangeCase
=
null
;
}
}
/**
* apply change case to this node, called by setValue
*/
private
function
applyFilterChangeCase
()
{
if
(
!
empty
(
$this
->
internalValue
))
{
if
(
$this
->
internalChangeCase
==
'UPPER'
)
{
$this
->
internalValue
=
strtoupper
(
$this
->
internalValue
);
}
elseif
(
$this
->
internalChangeCase
==
'LOWER'
)
{
$this
->
internalValue
=
strtolower
(
$this
->
internalValue
);
}
}
}
/**
* return object type as string
* @return string
...
...
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