Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Imldeployment
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
Container registry
Model registry
Operate
Environments
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
Imldeployment
Commits
4a09688a
Commit
4a09688a
authored
9 months ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
update inc_functions.php
parent
b07e6046
No related branches found
No related tags found
1 merge request
!66
php8 only; added variable types; short array syntax; remove glyphicons
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
public_html/deployment/inc_functions.php
+76
-38
76 additions, 38 deletions
public_html/deployment/inc_functions.php
with
76 additions
and
38 deletions
public_html/deployment/inc_functions.php
+
76
−
38
View file @
4a09688a
...
...
@@ -8,10 +8,12 @@
---------------------------------------------------------------------
2013-11-08 Axel <axel.hahn@iml.unibe.ch>
...
2024-09-03 Axel <axel.hahn@unibe.ch> php8 only; added variable types; short array syntax
###################################################################### */
global
$aParams
;
$aParams
=
array
()
;
$aParams
=
[]
;
// remark: $_SERVER does not exist in CLI
...
...
@@ -49,7 +51,7 @@ if (isset($_SERVER) && is_array($_SERVER) && array_key_exists("REQUEST_URI", $_S
$aParams
[
$key
]
=
$value
;
/* force integer params
foreach (
array(
"id"
)
as $sKey) {
foreach (
[
"id"
]
as $sKey) {
if (array_key_exists($sKey, $aParams)) {
$aParams[$sKey]=(int)$aParams[$sKey];
}
...
...
@@ -58,34 +60,45 @@ if (isset($_SERVER) && is_array($_SERVER) && array_key_exists("REQUEST_URI", $_S
foreach
(
array_keys
(
$aParams
)
as
$sKey
)
{
$aParams
[
$sKey
]
=
is_string
(
$aParams
[
$sKey
])
?
str_replace
(
array
(
'\\'
,
"
\0
"
,
"
\n
"
,
"
\r
"
,
"'"
,
'"'
,
"
\x1a
"
)
,
array
(
'\\\\'
,
'\\0'
,
'\\n'
,
'\\r'
,
"
\\
'"
,
'\\"'
,
'\\Z'
)
,
$aParams
[
$sKey
])
?
str_replace
(
[
'\\'
,
"
\0
"
,
"
\n
"
,
"
\r
"
,
"'"
,
'"'
,
"
\x1a
"
]
,
[
'\\\\'
,
'\\0'
,
'\\n'
,
'\\r'
,
"
\\
'"
,
'\\"'
,
'\\Z'
]
,
$aParams
[
$sKey
])
:
$aParams
[
$sKey
];
}
}
/**
* get home link as button
* Get home link as button
*
* @global object $oHtml
*
* @param string $sClass css class for the button; default: "btn btn-default"
* @return string
*/
function
aHome
(
$sClass
=
"btn btn-default"
)
function
aHome
(
string
$sClass
=
"btn btn-default"
)
:
string
{
global
$oHtml
;
// if (!array_key_exists("prj", $aParams)) return false;
return
$oHtml
->
getLinkButton
(
array
(
return
$oHtml
->
getLinkButton
(
[
'href'
=>
'/deployment/?'
,
'icon'
=>
'overview'
,
'class'
=>
$sClass
,
'label'
=>
t
(
"menu-overview"
),
)
);
]
);
}
/**
* get project Home link as button
* @return string
* Get project Home link as button.
* It returns false if no project is selected (GET param "prj" is missing)
*
* @global object $oHtml
* @global array $aParams
*
* @param string $sClass css class for the button; default: "btn btn-default"
* @return bool|string
*/
function
aPrjHome
(
$sClass
=
"btn btn-default"
)
function
aPrjHome
(
string
$sClass
=
"btn btn-default"
)
:
bool
|
string
{
global
$aParams
,
$oHtml
;
if
(
!
array_key_exists
(
"prj"
,
$aParams
))
{
return
false
;
}
...
...
@@ -96,51 +109,65 @@ function aPrjHome($sClass = "btn btn-default")
require_once
(
"./classes/project.class.php"
);
$oPrj
=
new
project
(
$aParams
[
"prj"
]);
return
$oHtml
->
getLinkButton
(
array
(
return
$oHtml
->
getLinkButton
(
[
'href'
=>
'/deployment/'
.
$aParams
[
"prj"
]
.
'/'
,
'icon'
=>
'project'
,
'class'
=>
$sClass
,
'label'
=>
$oPrj
->
getLabel
(),
)
);
]
);
}
/**
* get go back link as button
* Get go back link as button
*
* @global object $oHtml
*
* @param string $sClass css class for the button; default: "btn btn-default"
* @return string
*/
function
aGoback
(
$sClass
=
"btn btn-default"
)
function
aGoback
(
string
$sClass
=
"btn btn-default"
)
:
string
{
global
$oHtml
;
return
$oHtml
->
getLinkButton
(
array
(
return
$oHtml
->
getLinkButton
(
[
'href'
=>
'#'
,
'onclick'
=>
'history.back();'
,
'title'
=>
t
(
"back"
),
'icon'
=>
'back'
,
'class'
=>
$sClass
,
'label'
=>
t
(
"back"
)
)
);
]
);
}
/**
* get go top link as button
* Get go top link as button
*
* @global object $oHtml
*
* @param string $sClass css class for the button; default: "scroll-link btn btn-default"
* @return string
*/
function
aGotop
(
$sClass
=
"scroll-link btn btn-default"
)
function
aGotop
(
$sClass
=
"scroll-link btn btn-default"
)
:
string
{
global
$oHtml
;
return
$oHtml
->
getLinkButton
(
array
(
return
$oHtml
->
getLinkButton
(
[
'href'
=>
'#top'
,
'class'
=>
$sClass
,
'title'
=>
t
(
"gotop"
),
'icon'
=>
'gotop'
,
'label'
=>
' '
)
);
]
);
}
/**
* get array top left navigation
* Get array for top left navigation.
* It is an empty array if no authenticated user was found.
*
* @global object $oHtml
* @global array $aParams
*
* @return array
*/
function
getTopNavLeft
(
$aEmbed
=
[])
function
getTopNavLeft
(
):
array
{
global
$aParams
,
$oHtml
;
$aReturn
=
[];
...
...
@@ -227,10 +254,14 @@ function getTopNavLeft($aEmbed = [])
}
/**
* get array top left navigation
* Get array for top right navigation.
*
* @global object $oHtml
* @global array $aParams
*
* @return array
*/
function
getTopNavRight
()
function
getTopNavRight
()
:
array
{
global
$aParams
,
$oHtml
;
$aReturn
=
[];
...
...
@@ -273,12 +304,14 @@ function getTopNavRight()
}
/**
* get h2 headline with action
* @global type $aParams
* Gett h2 headline with action
*
* @global array $aParams
*
* @param string $sLinkClass classname for links; default: "" (adds class="btn btn-default")
* @return string
*/
function
getBreadcrumb
(
$sLinkClass
=
""
)
function
getBreadcrumb
(
string
$sLinkClass
=
""
)
:
string
{
global
$aParams
,
$oHtml
;
$sReturn
=
''
;
...
...
@@ -309,10 +342,10 @@ function getBreadcrumb($sLinkClass = "")
}
/**
*
g
et version info
*
G
et version info
by detecting a json file in approot
* @return string
*/
function
getVersioninfo
()
function
getVersioninfo
()
:
string
{
$sMyRev
=
""
;
...
...
@@ -324,19 +357,22 @@ function getVersioninfo()
}
return
(
$sMyRev
?
$sMyRev
.
' @ '
:
''
)
.
php_uname
(
"n"
);
}
/**
* translate function
* @global type $aConfig
* translate function. Get translated text by given key.
*
* @global array $aConfig
* @staticvar array $aLang
*
* @param string $s text
* @return string
*/
function
t
(
$s
)
function
t
(
string
$s
):
string
{
global
$aConfig
;
static
$aLang
=
array
()
;
static
$aLang
=
[]
;
if
(
!
is
_array
(
$aConfig
)
||
!
array_key_exists
(
"lang"
,
$aConfig
))
{
if
(
!
is
set
(
$aConfig
[
"lang"
]
))
{
die
(
"ERROR:
\$
aConfig[
\"
lang
\"
] does not exist.
\n
"
);
}
if
(
!
count
(
$aLang
))
{
...
...
@@ -355,11 +391,13 @@ function t($s)
}
/**
* enter user and comment
* @global type $aParams
* @return string
* Get html code for a form to enter user and comment
*
* @global array $aParams
*
* @return string The HTML code
*/
function
enterDeployinfos
()
function
enterDeployinfos
()
:
string
{
global
$aParams
;
$sIdUser
=
"inputUser"
;
...
...
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