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
56b2eb23
Commit
56b2eb23
authored
11 months ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
added type declarations; update php docs
parent
3ab6ee51
Branches
Branches containing commit
No related tags found
1 merge request
!18
Update renderer class
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
public_html/classes/htmlelements.class.php
+32
-18
32 additions, 18 deletions
public_html/classes/htmlelements.class.php
with
32 additions
and
18 deletions
public_html/classes/htmlelements.class.php
+
32
−
18
View file @
56b2eb23
...
...
@@ -15,19 +15,30 @@
* - icon - will be added as <i class="[icon value]"></i> to the label
*
* @author Axel
*
* 2024-07-04 <axel.hahn@unibe.ch> added type declarations; update php docs
*/
class
htmlelements
{
/**
* set of auto generated icon prefixes
* @var
type
* @var
array
*/
var
$_aIcons
=
array
(
// 'fa-'=>'fa ',
);
/**
* label of an html tag (pseudo attribute)
* @var string
*/
var
$_sLabel
=
''
;
/**
* hash of attributes and values of an html tag
* @var array
*/
var
$_aAttributes
=
array
();
...
...
@@ -51,7 +62,7 @@ class htmlelements
* generate html attibutes with all internal attributes key -> values
* @return string
*/
protected
function
_addAttributes
()
protected
function
_addAttributes
()
:
string
{
$sReturn
=
''
;
foreach
(
$this
->
_aAttributes
as
$sAttr
=>
$sValue
)
{
...
...
@@ -74,7 +85,7 @@ class htmlelements
* @param array $aAttributes
* @return boolean
*/
protected
function
_setAttributes
(
$aAttributes
)
protected
function
_setAttributes
(
array
$aAttributes
)
:
bool
{
$this
->
_sLabel
=
''
;
if
(
isset
(
$aAttributes
[
'icon'
])
&&
$aAttributes
[
'icon'
])
{
...
...
@@ -104,7 +115,7 @@ 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
(
string
$sTag
,
array
$aAttributes
,
bool
$bCloseTag
=
true
)
:
string
{
$sTpl
=
$bCloseTag
?
"<
$sTag
%s>%s</
$sTag
>"
:
"<
$sTag
%s/>%s"
;
$this
->
_setAttributes
(
$aAttributes
);
...
...
@@ -119,13 +130,14 @@ class htmlelements
// ----------------------------------------------------------------------
/**
* helper detect prefix of a string add prefix of a framework
* get html code for an icon
* includes a helper detect prefix of a string add prefix of a framework
* i.e. value "fa-close" detects font awesome and adds "fa " as prefix
*
* @param string $sIconclass
* @return
boolean
* @param string $sIconclass
name of the icon
* @return
string
*/
public
function
getIcon
(
$sIconclass
=
false
)
public
function
getIcon
(
string
$sIconclass
=
''
):
string
{
if
(
!
$sIconclass
)
{
return
''
;
...
...
@@ -137,8 +149,6 @@ class htmlelements
continue
;
}
}
// do not use this .. it overrides internal attribute vars
// return $this->getTag('i', array('class'=>$sPrefix.$sIconclass));
return
'<i class="'
.
$sPrefix
.
$sIconclass
.
'"></i> '
;
}
...
...
@@ -168,7 +178,7 @@ class htmlelements
* @param array $aAttributes attributes of the option tag
* @return string
*/
public
function
getFormOption
(
$aAttributes
)
public
function
getFormOption
(
array
$aAttributes
)
:
string
{
$sTpl
=
'<option %s>%s</option>'
;
$this
->
_setAttributes
(
$aAttributes
);
...
...
@@ -181,7 +191,7 @@ class htmlelements
* @param array $aOptions array for all option fields
* @return string
*/
public
function
getFormSelect
(
$aAttributes
,
$aOptions
=
array
())
public
function
getFormSelect
(
array
$aAttributes
,
array
$aOptions
=
array
())
{
// $sTpl = '<select %s>%s</select>';
...
...
@@ -195,14 +205,18 @@ class htmlelements
}
$aAttributes
[
'label'
]
=
$sOptions
;
return
$this
->
getTag
(
'select'
,
$aAttributes
);
/*
$this->_setAttributes($aAttributes);
return sprintf($sTpl, $this->_addAttributes(), $sOptions);
*
*/
}
public
function
getTable
(
$aHead
,
$aBody
,
$aTableAttributes
=
array
())
/**
* Generates an HTML table based on the provided header and body arrays.
*
* @param array $aHead An array of strings representing the table headers.
* @param array $aBody A 2-dimensional array of strings representing the table body rows and cells.
* @param array $aTableAttributes An optional array of attributes to be applied to the table element.
* @return string The HTML code for the generated table.
*/
public
function
getTable
(
array
$aHead
,
array
$aBody
,
array
$aTableAttributes
=
[]):
string
{
$sReturn
=
''
;
$sTdata
=
''
;
...
...
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