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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
AdminLTE renderer
Commits
a9d7b2ae
Commit
a9d7b2ae
authored
11 months ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
reformat classes
parent
2023b30d
Branches
Branches containing commit
No related tags found
1 merge request
!18
Update renderer class
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
public_html/classes/htmlelements.class.php
+73
-62
73 additions, 62 deletions
public_html/classes/htmlelements.class.php
public_html/classes/render-adminlte.class.php
+921
-785
921 additions, 785 deletions
public_html/classes/render-adminlte.class.php
with
994 additions
and
847 deletions
public_html/classes/htmlelements.class.php
+
73
−
62
View file @
a9d7b2ae
...
...
@@ -16,25 +16,27 @@
*
* @author Axel
*/
class
htmlelements
{
class
htmlelements
{
/**
* set of auto generated icon prefixes
* @var type
*/
var
$_aIcons
=
array
(
// 'fa-'=>'fa ',
);
var
$_aIcons
=
array
(
// 'fa-'=>'fa ',
);
var
$_sLabel
=
''
;
var
$_aAttributes
=
array
();
// ----------------------------------------------------------------------
// CONSTRUCTOR
// ----------------------------------------------------------------------
public
function
__construct
()
{
public
function
__construct
()
{
return
true
;
}
...
...
@@ -43,25 +45,26 @@ class htmlelements {
// PRIVATE FUNCTIONS
//
// ----------------------------------------------------------------------
/**
* generate html attibutes with all internal attributes key -> values
* @return string
*/
protected
function
_addAttributes
()
{
protected
function
_addAttributes
()
{
$sReturn
=
''
;
foreach
(
$this
->
_aAttributes
as
$sAttr
=>
$sValue
)
{
if
(
is_array
(
$sValue
)){
echo
"ERROR: an html tag was defined with array in attribute [
$sAttr
]:<br><pre>"
.
print_r
(
$this
->
_aAttributes
,
1
)
.
"</pre>"
;
if
(
is_array
(
$sValue
))
{
echo
"ERROR: an html tag was defined with array in attribute [
$sAttr
]:<br><pre>"
.
print_r
(
$this
->
_aAttributes
,
1
)
.
"</pre>"
;
}
$sReturn
.
=
' '
.
$sAttr
.
'="'
.
$sValue
.
'"'
;
$sReturn
.
=
' '
.
$sAttr
.
'="'
.
$sValue
.
'"'
;
}
return
$sReturn
;
}
/**
* internal helper: fetch all attributes from key-value hash;
* Specialties here:
...
...
@@ -71,17 +74,18 @@ class htmlelements {
* @param array $aAttributes
* @return boolean
*/
protected
function
_setAttributes
(
$aAttributes
){
$this
->
_sLabel
=
''
;
if
(
isset
(
$aAttributes
[
'icon'
])
&&
$aAttributes
[
'icon'
]){
$this
->
_sLabel
.
=
$this
->
getIcon
(
$aAttributes
[
'icon'
]);
protected
function
_setAttributes
(
$aAttributes
)
{
$this
->
_sLabel
=
''
;
if
(
isset
(
$aAttributes
[
'icon'
])
&&
$aAttributes
[
'icon'
])
{
$this
->
_sLabel
.
=
$this
->
getIcon
(
$aAttributes
[
'icon'
]);
unset
(
$aAttributes
[
'icon'
]);
}
if
(
isset
(
$aAttributes
[
'label'
])
&&
$aAttributes
[
'label'
]){
if
(
isset
(
$aAttributes
[
'label'
])
&&
$aAttributes
[
'label'
])
{
$this
->
_sLabel
.
=
$aAttributes
[
'label'
];
unset
(
$aAttributes
[
'label'
]);
}
$this
->
_aAttributes
=
$aAttributes
;
$this
->
_aAttributes
=
$aAttributes
;
return
true
;
}
...
...
@@ -91,7 +95,7 @@ class htmlelements {
// HTML GENERIC
//
// ----------------------------------------------------------------------
/**
* generic function to get html code for a single tag
*
...
...
@@ -100,12 +104,13 @@ class htmlelements {
* @param boolean $bCloseTag optional: set false if tag has no closing tag (= ending with "/>")
* @return type
*/
public
function
getTag
(
$sTag
,
$aAttributes
,
$bCloseTag
=
true
){
public
function
getTag
(
$sTag
,
$aAttributes
,
$bCloseTag
=
true
)
{
$sTpl
=
$bCloseTag
?
"<
$sTag
%s>%s</
$sTag
>"
:
"<
$sTag
%s/>%s"
;
$this
->
_setAttributes
(
$aAttributes
);
return
sprintf
(
$sTpl
,
$this
->
_addAttributes
(),
$this
->
_sLabel
);
}
// ----------------------------------------------------------------------
//
// PUBLIC FUNCTIONS
...
...
@@ -120,22 +125,23 @@ class htmlelements {
* @param string $sIconclass
* @return boolean
*/
public
function
getIcon
(
$sIconclass
=
false
){
if
(
!
$sIconclass
){
public
function
getIcon
(
$sIconclass
=
false
)
{
if
(
!
$sIconclass
)
{
return
''
;
}
$sPrefix
=
''
;
foreach
(
$this
->
_aIcons
as
$sPrefix
=>
$add
)
{
if
(
strpos
(
$sIconclass
,
$sPrefix
)
===
0
){
$sPrefix
=
$add
;
$sPrefix
=
''
;
foreach
(
$this
->
_aIcons
as
$sPrefix
=>
$add
)
{
if
(
strpos
(
$sIconclass
,
$sPrefix
)
===
0
)
{
$sPrefix
=
$add
;
continue
;
}
}
// do not use this .. it overrides internal attribute vars
// return $this->getTag('i', array('class'=>$sPrefix.$sIconclass));
return
'<i class="'
.
$sPrefix
.
$sIconclass
.
'"></i> '
;
return
'<i class="'
.
$sPrefix
.
$sIconclass
.
'"></i> '
;
}
// ----------------------------------------------------------------------
//
...
...
@@ -150,7 +156,8 @@ class htmlelements {
* @param array $aAttributes attributes of the select tag
* @return string
*/
public
function
getFormInput
(
$aAttributes
){
public
function
getFormInput
(
$aAttributes
)
{
$sTpl
=
'<input %s/>'
;
$this
->
_setAttributes
(
$aAttributes
);
return
sprintf
(
$sTpl
,
$this
->
_addAttributes
());
...
...
@@ -161,7 +168,8 @@ class htmlelements {
* @param array $aAttributes attributes of the option tag
* @return string
*/
public
function
getFormOption
(
$aAttributes
){
public
function
getFormOption
(
$aAttributes
)
{
$sTpl
=
'<option %s>%s</option>'
;
$this
->
_setAttributes
(
$aAttributes
);
return
sprintf
(
$sTpl
,
$this
->
_addAttributes
(),
$this
->
_sLabel
);
...
...
@@ -173,18 +181,19 @@ class htmlelements {
* @param array $aOptions array for all option fields
* @return string
*/
public
function
getFormSelect
(
$aAttributes
,
$aOptions
=
array
()){
public
function
getFormSelect
(
$aAttributes
,
$aOptions
=
array
())
{
// $sTpl = '<select %s>%s</select>';
if
(
!
count
(
$aOptions
)){
if
(
!
count
(
$aOptions
))
{
return
false
;
}
$sOptions
=
''
;
foreach
(
$aOptions
as
$aOptionAttributes
){
$sOptions
=
''
;
foreach
(
$aOptions
as
$aOptionAttributes
)
{
// $sOptions.=$this->getFormOption($aOptionAttributes);
$sOptions
.
=
$this
->
getTag
(
'option'
,
$aOptionAttributes
);
$sOptions
.
=
$this
->
getTag
(
'option'
,
$aOptionAttributes
);
}
$aAttributes
[
'label'
]
=
$sOptions
;
$aAttributes
[
'label'
]
=
$sOptions
;
return
$this
->
getTag
(
'select'
,
$aAttributes
);
/*
$this->_setAttributes($aAttributes);
...
...
@@ -193,30 +202,32 @@ class htmlelements {
*/
}
public
function
getTable
(
$aHead
,
$aBody
,
$aTableAttributes
=
array
()){
$sReturn
=
''
;
$sTdata
=
''
;
$sThead
=
''
;
public
function
getTable
(
$aHead
,
$aBody
,
$aTableAttributes
=
array
())
{
$sReturn
=
''
;
$sTdata
=
''
;
$sThead
=
''
;
$sTpl
=
'<table %s>'
.
'<thead><tr>%s</tr></thead>'
.
'<tbody>%s</tbody>'
.
'</table>'
;
foreach
(
$aHead
as
$sTh
){
$sThead
.
=
'<th>'
.
$sTh
.
'</th>'
;
.
'<thead><tr>%s</tr></thead>'
.
'<tbody>%s</tbody>'
.
'</table>'
;
foreach
(
$aHead
as
$sTh
)
{
$sThead
.
=
'<th>'
.
$sTh
.
'</th>'
;
}
foreach
(
$aBody
as
$aTr
){
$sTdata
.
=
'<tr>'
;
foreach
(
$aTr
as
$sTd
){
$sTdata
.
=
'<td>'
.
$sTd
.
'</td>'
;
foreach
(
$aBody
as
$aTr
)
{
$sTdata
.
=
'<tr>'
;
foreach
(
$aTr
as
$sTd
)
{
$sTdata
.
=
'<td>'
.
$sTd
.
'</td>'
;
}
$sTdata
.
=
'</tr>'
;
$sTdata
.
=
'</tr>'
;
}
$this
->
_setAttributes
(
$aTableAttributes
);
return
sprintf
(
$sTpl
,
$this
->
_addAttributes
(),
$sThead
,
$sTdata
);
return
sprintf
(
$sTpl
,
$this
->
_addAttributes
(),
$sThead
,
$sTdata
);
}
}
This diff is collapsed.
Click to expand it.
public_html/classes/render-adminlte.class.php
+
921
−
785
View file @
a9d7b2ae
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