FOSSology  4.4.0
Open Source License Compliance by Open Source Software
common-ui.php File Reference

Common function for UI operations. More...

Go to the source code of this file.

Functions

 Array2SingleSelect ($KeyValArray, $SLName="unnamed", $SelectedVal="", $FirstEmpty=false, $SelElt=true, $Options="", $ReturnKey=true)
 Build a single choice select pulldown. More...
 
 Fatal ($msg, $filenm, $lineno)
 Write message to stdout and die. More...
 
 debugbacktrace ()
 Debug back trace.
 
 debugprint ($val, $title)
 Print debug message. More...
 
 HumanSize ( $bytes)
 Translate a byte number to a proper type, xxx bytes to xxx B/KB/MB/GB/TB/PB. More...
 
 HumanDuration (DateInterval $duration)
 Convert DateInterval to Human readable format. More...
 
 GetFileExt ($fname)
 Get File Extension (text after last period) More...
 
 GetArrayVal ($Key, $Arr)
 Get the value from a array(map) More...
 
 HostListOption ()
 Get host list. More...
 
 DownloadString2File ($text, $name, $contentType)
 Send a string to a user as a download file. More...
 
 GetUploadtreeTableName ($upload_pk)
 Get the uploadtree table name for this upload_pk If upload_pk does not exist, return "uploadtree". More...
 
 GetUploadName ($upload_pk)
 Get Upload Name through upload id. More...
 
 GetUploadID ($uploadtreeid)
 Get upload id through uploadtreeid. More...
 
 Get1stUploadtreeID ($upload)
 Get 1st uploadtree id through upload id. More...
 
 Convert2BrowserTime ($server_time)
 Convert the server time to browser time. More...
 

Detailed Description

Common function for UI operations.

Definition in file common-ui.php.

Function Documentation

◆ Array2SingleSelect()

Array2SingleSelect (   $KeyValArray,
  $SLName = "unnamed",
  $SelectedVal = "",
  $FirstEmpty = false,
  $SelElt = true,
  $Options = "",
  $ReturnKey = true 
)

Build a single choice select pulldown.

Parameters
array$KeyValArrayAssoc array. Use key/val pairs for list
string$SLNameSelect list name (default is "unnamed"),
string$SelectedValInitially selected value or key, depends on $SelElt
bool$FirstEmptyTrue if the list starts off with an empty choice (default is false)
bool$SelEltTrue (default) if $SelectedVal is a value False if $SelectedVal is a key
string$OptionsOptional. Options to add to the select statement. For example, "id=myid onclick= ..."
bool$ReturnKeyTrue (default) return the Key as value, if False return the Value
Returns
A string of select HTML
Examples
/home/runner/work/fossology/fossology/src/www/ui/ui-picker.php.

Definition at line 32 of file common-ui.php.

◆ Convert2BrowserTime()

Convert2BrowserTime (   $server_time)

Convert the server time to browser time.

Parameters
time$server_timeto be converted

Definition at line 312 of file common-ui.php.

◆ debugprint()

debugprint (   $val,
  $title 
)

Print debug message.

Parameters
mixed$valVariable to be printed
string$titleTitle of the variable

Definition at line 89 of file common-ui.php.

◆ DownloadString2File()

DownloadString2File (   $text,
  $name,
  $contentType 
)

Send a string to a user as a download file.

Parameters
string$textText to download as file
string$nameFile name
string$contentTypeDownload file Content-Type
Returns
True on success, error message on failure.

Definition at line 198 of file common-ui.php.

◆ Fatal()

Fatal (   $msg,
  $filenm,
  $lineno 
)

Write message to stdout and die.

Parameters
string$msgMessage to write
string$filenmFile name (FILE)
int$linenoLine number of the caller (LINE)
Returns
None, prints error, file, and line number, then exits(1)
See also
debugbacktrace()

Definition at line 66 of file common-ui.php.

◆ Get1stUploadtreeID()

Get1stUploadtreeID (   $upload)

Get 1st uploadtree id through upload id.

Parameters
int$uploadUpload id
Returns
1st uploadtree id

Definition at line 293 of file common-ui.php.

◆ GetArrayVal()

GetArrayVal (   $Key,
  $Arr 
)

Get the value from a array(map)

Parameters
mixed$KeyKey to look
array$ArrWithin the Array, you can get value according to the key
Returns
An array value, or "" if the array key does not exist

Definition at line 157 of file common-ui.php.

◆ GetFileExt()

GetFileExt (   $fname)

Get File Extension (text after last period)

Parameters
string$fnameFile name
Returns
The file extension of the specified file name
Examples
/home/runner/work/fossology/fossology/src/www/ui/ui-picker.php.

Definition at line 142 of file common-ui.php.

◆ GetUploadID()

GetUploadID (   $uploadtreeid)

Get upload id through uploadtreeid.

Parameters
int$uploadtreeidUploadtree id
Returns
Upload id

Definition at line 272 of file common-ui.php.

◆ GetUploadName()

GetUploadName (   $upload_pk)

Get Upload Name through upload id.

Parameters
int$upload_idUpload ID
Returns
Upload name, "" if upload does not exists

Definition at line 251 of file common-ui.php.

◆ GetUploadtreeTableName()

GetUploadtreeTableName (   $upload_pk)

Get the uploadtree table name for this upload_pk If upload_pk does not exist, return "uploadtree".

Parameters
int$upload_pk
Returns
Uploadtree table name

Definition at line 233 of file common-ui.php.

◆ HostListOption()

HostListOption ( )

Get host list.

Returns
Return HTML of the host name tree

Definition at line 174 of file common-ui.php.

◆ HumanDuration()

HumanDuration ( DateInterval  $duration)

Convert DateInterval to Human readable format.

If DateInterval is more than 1 year, then return years, else return months, else return days. If duration is less than 1 day, then return hours and minutes.

Parameters
DateInterval$durationDuration to convert
Returns
string Formatted duration

Definition at line 120 of file common-ui.php.

◆ HumanSize()

HumanSize (   $bytes)

Translate a byte number to a proper type, xxx bytes to xxx B/KB/MB/GB/TB/PB.

Parameters
int$bytesBytes to be converted

Definition at line 100 of file common-ui.php.