Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AdminLTE renderer
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
AdminLTE renderer
Commits
272da4e7
Commit
272da4e7
authored
2 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
component view more dynamic; showing loops
parent
d0ec225b
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
public_html/classes/render-adminlte.class.php
+64
-1
64 additions, 1 deletion
public_html/classes/render-adminlte.class.php
public_html/inc_functions.php
+8
-2
8 additions, 2 deletions
public_html/inc_functions.php
public_html/pages/component.php
+152
-32
152 additions, 32 deletions
public_html/pages/component.php
with
224 additions
and
35 deletions
public_html/classes/render-adminlte.class.php
+
64
−
1
View file @
272da4e7
...
...
@@ -21,6 +21,7 @@ class renderadminlte {
'bgcolor'
=>
[
// for colors see https://adminlte.io/docs/3.2/layout.html
''
,
// none
'primary'
,
'blue'
,
'secondary'
,
'success'
,
'green'
,
...
...
@@ -76,6 +77,15 @@ class renderadminlte {
],
];
var
$_aValueMappings
=
[
'shadow'
=>
[
'default'
=>
''
,
'none'
=>
'shadow-none'
,
'small'
=>
'shadow-small'
,
'regular'
=>
'shadow'
,
'large'
=>
'shadow-lg'
,
],
];
/**
* instance of htmlelements
* @var object
...
...
@@ -625,6 +635,59 @@ class renderadminlte {
*/
public
function
getInfobox
(
$aOptions
){
$aOptions
=
$this
->
_ensureOptions
(
$aOptions
,
[
'type'
,
'bgcolor'
,
'shadow'
,
'icon'
,
'text'
,
'number'
,
'progressvalue'
,
'progresstext'
]);
// print_r($aOptions);
$sClass
=
'info-box'
.
(
$aOptions
[
'class'
]
?
' '
.
$aOptions
[
'class'
]
:
''
)
.
(
$aOptions
[
'type'
]
?
' bg-'
.
$aOptions
[
'type'
]
:
''
)
.
(
$aOptions
[
'shadow'
]
&&
isset
(
$this
->
_aValueMappings
[
'shadow'
][
$aOptions
[
'shadow'
]])
?
' '
.
$this
->
_aValueMappings
[
'shadow'
][
$aOptions
[
'shadow'
]]
:
''
)
;
// build parts
$sIcon
=
$aOptions
[
'icon'
]
?
$this
->
addWrapper
(
"span"
,
[
'class'
=>
'info-box-icon'
.
(
$aOptions
[
'iconbg'
]
?
' bg-'
.
$aOptions
[
'iconbg'
]
:
''
)
],
$this
->
_tag
(
'i'
,[
'class'
=>
$aOptions
[
'icon'
]]))
:
''
;
$sContent
=
$this
->
addWrapper
(
"div"
,
[
'class'
=>
'info-box-content'
],
''
.
(
$aOptions
[
'text'
]
?
$this
->
_tag
(
'span'
,
[
'class'
=>
'info-box-text'
,
'label'
=>
$aOptions
[
'text'
]])
:
''
)
.
(
$aOptions
[
'number'
]
?
$this
->
_tag
(
'span'
,
[
'class'
=>
'info-box-number'
,
'label'
=>
$aOptions
[
'number'
]])
:
''
)
.
(
$aOptions
[
'progressvalue'
]
!==
false
&&
$aOptions
[
'progressvalue'
]
!==
''
?
$this
->
addWrapper
(
'div'
,
[
'class'
=>
'progress'
],
$this
->
_tag
(
'div'
,
[
'class'
=>
'progress-bar'
.
(
$aOptions
[
'iconbg'
]
?
' bg-'
.
$aOptions
[
'iconbg'
]
:
''
),
'style'
=>
'width: '
.
(
int
)
$aOptions
[
'progressvalue'
]
.
'%'
])
)
.
(
$aOptions
[
'progresstext'
]
?
$this
->
_tag
(
'span'
,
[
'class'
=>
'progress-description'
,
'label'
=>
$aOptions
[
'progresstext'
]])
:
''
)
:
''
)
);
// merge all
return
$this
->
_tag
(
'div'
,
[
'class'
=>
$sClass
],
$sIcon
.
$sContent
);
}
/**
* return an info-box:
* A colored box with large icon, text and a value.
* https://adminlte.io/docs/3.2/components/boxes.html
*
* @param type $aOptions hash with keys for all options
* styling:
* - type - color of the box; one of [none]|danger|dark|info|primary|secondary|success|warning
* content
* - icon - icon class for icon on the right
* - text - information text
* - number - value (comes in bold text)
* - url - integer: progress bar; range: 0..100
* - linktext- text below progress bar
* @return string
*/
public
function
getSmallbox
(
$aOptions
){
$aOptions
=
$this
->
_ensureOptions
(
$aOptions
,
[
'type'
,
'bgcolor'
,
'shadow'
,
'icon'
,
'text'
,
'number'
,
'progressvalue'
,
'progresstext'
]);
$aShadows
=
[
'default'
=>
''
,
'none'
=>
'shadow-none'
,
...
...
@@ -943,7 +1006,7 @@ class renderadminlte {
* - url
* @return string
*/
public
function
getSmallBox
(
$aOptions
)
{
public
function
MIGRATED__
getSmallBox
(
$aOptions
)
{
foreach
(
array
(
'bgcolor'
,
'color'
,
'title'
,
'text'
,
'icon'
,
'footer'
)
as
$sKey
){
if
(
!
isset
(
$aOptions
[
$sKey
])){
$aOptions
[
$sKey
]
=
false
;
...
...
This diff is collapsed.
Click to expand it.
public_html/inc_functions.php
+
8
−
2
View file @
272da4e7
<?php
function
showExample
(
$sPhpcode
){
function
getOutput
(
$sPhpcode
){
global
$renderAdminLTE
;
$sOut
=
''
;
eval
(
"
\$
sOut=
$sPhpcode
;"
);
return
$sOut
;
}
function
showExample
(
$sPhpcode
){
// global $renderAdminLTE;
$sOut
=
getOutput
(
$sPhpcode
);
return
'
<table class="table">
...
...
@@ -26,7 +32,7 @@ function showExample($sPhpcode){
'
.
$sOut
.
'
</td>
<td>
<pre>'
.
htmlentities
(
str_replace
([
">"
,
"</"
],
[
">
\n
"
,
"
\n
</"
],
$sOut
))
.
'</pre>
<pre>'
.
htmlentities
(
str_replace
([
">"
,
"</"
,
"
\n\n
"
],
[
">
\n
"
,
"
\n
</"
,
"
\n
"
],
$sOut
))
.
'</pre>
</td>
</tr>
</tbody>
...
...
This diff is collapsed.
Click to expand it.
public_html/pages/component.php
+
152
−
32
View file @
272da4e7
<?php
$sComponent
=
(
isset
(
$_GET
[
'id'
])
?
preg_replace
(
'/[^a-z]/'
,
''
,
$_GET
[
'id'
])
:
''
);
echo
"DEBUG: sComponent =
$sComponent
<br>"
;
// ----------------------------------------------------------------------
// pre defined values - used for dropdowns
// ----------------------------------------------------------------------
$aPresets
=
[
'yesno'
=>
[
''
=>
'no value'
,
'0'
=>
'no'
,
'1'
=>
'yes'
,
],
'type'
=>
[
''
=>
'no value'
,
'danger'
=>
'red'
,
'dark'
=>
'dark gray'
,
'gray'
=>
'gray'
,
'info'
=>
'aqua'
,
'primary'
=>
'blue'
,
'secondary'
=>
'gray'
,
'success'
=>
'green'
,
'warning'
=>
'yellow'
,
],
'shadow'
=>
[
''
=>
'no value'
,
'none'
=>
'none'
,
'small'
=>
'small'
,
'regular'
=>
'regular'
,
'large'
=>
'large'
]
];
// ----------------------------------------------------------------------
// definition of a component
// ----------------------------------------------------------------------
$aComponents
=
[
// ------------------------------------------------------------
'alert'
=>
[
'label'
=>
'Alert'
,
'description'
=>
''
,
'method'
=>
'getAlert'
,
'params'
=>
[
'type'
=>
[
'select'
=>
$aPresets
[
'type'
],
'default'
=>
'warning'
],
'dismissible'
=>
[
'select'
=>
$aPresets
[
'yesno'
],
'default'
=>
''
],
'title'
=>
[
'default'
=>
' I need your attention'
],
'text'
=>
[
'default'
=>
'Please check it. Maybe there is something wrong here.'
],
]
],
// ------------------------------------------------------------
'infobox'
=>
[
'label'
=>
'Infobox'
,
'description'
=>
''
,
'method'
=>
'getInfobox'
,
'examples'
=>
[
[
'description'
=>
'Success infobox with progress'
,
'params'
=>
[
'type'
=>
'success'
,
'iconbg'
=>
''
,
'shadow'
=>
''
,
'icon'
=>
'far fa-thumbs-up'
,
'text'
=>
'Likes'
,
'number'
=>
"41,410"
,
'progressvalue'
=>
70
,
'progresstext'
=>
'70% Increase in 30 Days'
]
],
'type'
=>
[
'select'
=>
$aPresets
[
'type'
],
'default'
=>
''
],
'iconbg'
=>
[
'select'
=>
$aPresets
[
'type'
],
'default'
=>
'info'
],
'shadow'
=>
[
'select'
=>
$aPresets
[
'shadow'
],
'default'
=>
''
],
'icon'
=>
[
'default'
=>
'far fa-thumbs-up'
],
'text'
=>
[
'default'
=>
'Likes'
],
'number'
=>
[
'default'
=>
"41,410"
],
'progressvalue'
=>
[
'default'
=>
70
],
'progresstext'
=>
[
'default'
=>
'70% Increase in 30 Days'
]
]
],
];
...
...
@@ -36,25 +79,102 @@ if(!isset($aComponents[$sComponent])){
$aComp
=
$aComponents
[
$sComponent
];
// --------- prepare output for parameter Testing
$sTester
=
'<form
method="GET"
action="?"
>
<input type="hidden" name="id" value="'
.
$sComponent
.
'">
<table class="table">
<tbody>
'
;
$aWidgetOptions
=
[];
foreach
(
$aComp
[
'params'
]
as
$sOptionkey
=>
$aParam
){
$sInput
=
''
;
$sValue
=
(
isset
(
$_GET
[
$sOptionkey
])
?
$_GET
[
$sOptionkey
]
:
(
isset
(
$aParam
[
'default'
])
?
$aParam
[
'default'
]
:
''
));
$aWidgetOptions
[
$sOptionkey
]
=
$sValue
;
if
(
isset
(
$aParam
[
'select'
])){
foreach
(
$aParam
[
'select'
]
as
$sSelectItem
=>
$sLabel
){
// $sInput.='<option value="'.$sSelectItem.'">'.($sSelectItem ? $sSelectItem : '-- none --').'</option>';
$sInput
.
=
'<option value="'
.
$sSelectItem
.
'"'
.
(
$sValue
==
$sSelectItem
?
' selected="selected"'
:
''
)
.
'>'
.
$sSelectItem
.
' -> '
.
$sLabel
.
'</option>'
;
}
$sInput
=
'<select size="1" name="'
.
$sOptionkey
.
'" onchange="form.submit();">'
.
$sInput
.
'</select>'
.
' <button name="doloop" value="'
.
$sOptionkey
.
'">Loop</button><br>'
;
}
else
{
$sInput
.
=
'<input type="text" name="'
.
$sOptionkey
.
'" value="'
.
$sValue
.
'"/>'
;
}
$sTester
.
=
'<tr><td>'
.
$sOptionkey
.
'</td><td colspan="2">'
.
$sInput
.
'</td></tr>'
;
}
$sTester
.
=
'
<tr><td><button>Submit</button></td></tr>
</tbody></table>
</form>
'
;
// --------- loop over a single var
$sLooper
=
''
;
if
(
isset
(
$_GET
[
'doloop'
])
&&
isset
(
$aComp
[
'params'
][
$_GET
[
'doloop'
]])){
$sLoopvar
=
$_GET
[
'doloop'
];
/*
$sLooper.=$renderAdminLTE->addRow(
'<h3 id="#loops">Loop over option key ['.$sLoopvar.']</h3>'
. implode(" | ", array_keys($aComp['params'][$sLoopvar]['select']))
);
*/
foreach
(
array_keys
(
$aComp
[
'params'
][
$sLoopvar
][
'select'
])
as
$sLoopValue
){
$aLoopoptions
=
$aWidgetOptions
;
$aLoopoptions
[
$sLoopvar
]
=
$sLoopValue
;
$sLooper
.
=
$renderAdminLTE
->
addCol
(
'<h4>"'
.
$sLoopvar
.
'" => "'
.
$sLoopValue
.
'"</h4>'
.
getOutput
(
'$renderAdminLTE->'
.
$aComp
[
'method'
]
.
'('
.
var_export
(
$aLoopoptions
,
1
)
.
')'
),
3
);
}
}
// ---------- output
echo
$renderAdminLTE
->
addRow
(
'<h2>'
.
$aComp
[
'label'
]
.
'</h2>'
)
.
$renderAdminLTE
->
addRow
(
'<h3>Syntax</h3>
<code>echo $renderAdminLTE-><strong>'
.
$aComp
[
'method'
]
.
'</strong>($aOptions)</code>
'
);
$renderAdminLTE
->
getCard
([
'title'
=>
'Syntax'
,
'text'
=>
'<pre>echo $renderAdminLTE-><strong>'
.
$aComp
[
'method'
]
.
'</strong>($aOptions)</pre>'
])
)
foreach
(
$aComp
[
'examples'
]
as
$aExample
){
echo
$renderAdminLTE
->
addRow
(
'<h4>'
.
$aExample
[
'description'
]
.
'</h4>'
.
$renderAdminLTE
->
addRow
(
'<h3>Testing section</h3>'
)
.
$renderAdminLTE
->
addRow
(
showExample
(
'$renderAdminLTE->'
.
$aComp
[
'method'
]
.
'('
.
var_export
(
$aExample
[
'params'
],
1
)
.
')'
)
);
}
$renderAdminLTE
->
addCol
(
$renderAdminLTE
->
getCard
([
'title'
=>
'Parameter keys for '
.
$sComponent
,
'text'
=>
$sTester
]),
3
)
.
$renderAdminLTE
->
addCol
(
showExample
(
'$renderAdminLTE->'
.
$aComp
[
'method'
]
.
'('
.
var_export
(
$aWidgetOptions
,
1
)
.
')'
)
,
9
)
)
.
(
$sLooper
?
$renderAdminLTE
->
addRow
(
$sLooper
)
:
''
)
;
}
\ No newline at end of file
;
\ No newline at end of file
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