Methods summary
public static
Html::clean()
|
#
clean( $value, $striptags = true, $keep_bad = 2 )
Clean display value deleting html tags
Clean display value deleting html tags
Parameters
- $value
- string value
- $striptags
- strip all html tags
- $keep_bad
1 : neutralize tag anb content,
2 : remove tag and neutralize content
Returns
|
public static
array
|
#
entity_decode_deep( $value )
Recursivly execute html_entity_decode on an Array
Recursivly execute html_entity_decode on an Array
Parameters
Returns
array of value (same struct as input)
|
public static
array
|
#
entities_deep( $value )
Recursivly execute htmlentities on an Array
Recursivly execute htmlentities on an Array
Parameters
Returns
array of value (same struct as input)
|
public static
|
#
convDate( $time, $format = null )
Convert a date YY-MM-DD to DD-MM-YY for calendar
Convert a date YY-MM-DD to DD-MM-YY for calendar
Parameters
- $time
- date to convert
- $format
- null)
Returns
$time or $date
|
public static
|
#
convDateTime( $time, $format = null )
Convert a date YY-MM-DD HH:MM to DD-MM-YY HH:MM for display in a html table
Convert a date YY-MM-DD HH:MM to DD-MM-YY HH:MM for display in a html table
Parameters
- $time
- datetime to convert
- $format
- null)
Returns
$time or $date
|
public static
Html::clean()
|
#
cleanInputText( $string )
Clean string for input text field
Clean string for input text field
Parameters
Returns
|
public static
Html::clean()
|
#
cleanParametersURL( $url )
Clean all parameters of an URL. Get a clean URL
Clean all parameters of an URL. Get a clean URL
Parameters
Returns
|
public static
array
|
#
nl2br_deep( $value )
Recursivly execute nl2br on an Array
Recursivly execute nl2br on an Array
Parameters
Returns
array of value (same struct as input)
|
public static
cut
|
#
resume_text( $string, $length = 255 )
Resume text for followup
Parameters
- $string
- string to resume
- $length
- resume length (default 255)
Returns
cut string
|
public static
cut
|
#
resume_name( $string, $length = 255 )
Resume a name for display
Resume a name for display
Parameters
- $string
- string to resume
- $length
- resume length (default 255)
Returns
cut string
|
public static
Html::clean()
|
#
cleanPostForTextArea( $value )
Clean post value for display in textarea
Clean post value for display in textarea
Parameters
Returns
|
public static
formatted
|
#
formatNumber( $number, $edit = false, $forcedecimal = -1 )
Convert a number to correct display
Convert a number to correct display
Parameters
- $number
- Number to display
- $edit
display number for edition ? (id edit use . in all case)
(false by default)
- $forcedecimal
- Force decimal number (do not use default value) (default -1)
Returns
formatted number
|
public static
string
|
#
timestampToString( $time, $display_sec = true, $use_days = true )
Make a good string from the unix timestamp $sec
Make a good string from the unix timestamp $sec
Parameters
- $time
- timestamp
- $display_sec
- display seconds ? (true by default)
- $use_days
- use days for display ? (true by default)
Returns
string
|
public static
string
|
#
timestampToCsvString( integer $time )
Format a timestamp into a normalized string (hh:mm:ss).
Format a timestamp into a normalized string (hh:mm:ss).
Parameters
Returns
string
|
public static
nothing
|
#
back( )
Redirection to $_SERVER['HTTP_REFERER'] page
Redirection to $_SERVER['HTTP_REFERER'] page
Returns
nothing
|
public static
nothing
|
#
redirect( $dest, $http_response_code = 302 )
Redirection hack
Parameters
- $dest
- Redirection destination
- $http_response_code
- Forces the HTTP response code to the specified value
Returns
nothing
|
public static
nothing
|
#
redirectToLogin( $params = '' )
Redirection to Login page
Redirection to Login page
Parameters
- $params
- to add to URL (default '')
Returns
nothing
Since
0.85
|
public static
Nothing
|
#
displayNotFoundError( )
Display common message for item not found
Display common message for item not found
Returns
Nothing
|
public static
Nothing
|
#
displayRightError( )
Display common message for privileges errors
Display common message for privileges errors
Returns
Nothing (die)
|
public static
|
#
displayMessageAfterRedirect( )
Display a div containing messages set in session in the previous page
Display a div containing messages set in session in the previous page
|
public static
|
|
public static
nothing
|
#
displayTitle( $ref_pic_link = "", $ref_pic_text = "", $ref_title = "", $ref_btts = "" )
Common Title Function
Parameters
- $ref_pic_link
- to the image to display (default '')
- $ref_pic_text
- text of the icon (default '')
- $ref_title
- to display (default '')
- $ref_btts
- items to display array(link=>text...) (default '')
Returns
nothing
|
public static
|
|
public static
|
#
displayDebugInfos( boolean $with_session = true, boolean $ajax = false )
Display Debug Information
Display Debug Information
Parameters
- $with_session
- with session information (true by default)
- $ajax
- If we're called from ajax (false by default)
|
public static
|
#
displayBackLink( )
Display a Link to the last page using http_referer if available else use history.back
Display a Link to the last page using http_referer if available else use history.back
|
public static
mixed
|
#
getBackUrl( string $url_in = "" )
Return an url for getting back to previous page.
Remove forcetab parameter if exists to prevent bad tab display
Return an url for getting back to previous page.
Remove forcetab parameter if exists to prevent bad tab display
Parameters
- $url_in
- optional url to return (without forcetab param), if empty, we will user HTTP_REFERER from server
Returns
mixed [string|boolean] false, if failed, else the url string
Since
9.2.2
|
public static
nothing
|
#
displayErrorAndDie( $message, $minimal = false )
Simple Error message page
Simple Error message page
Parameters
- $message
- displayed before dying
- $minimal
- to true do not display app menu (false by default)
Returns
nothing as function kill script
|
public static
nothing
|
#
addConfirmationOnAction( $string, $additionalactions = '' )
Add confirmation on button or link before action
Add confirmation on button or link before action
Parameters
- $string
- to display or array of string for using multilines
- $additionalactions
additional actions to do on success confirmation
(default '')
Returns
nothing
|
public static
confirmation
|
#
getConfirmationOnActionScript( $string, $additionalactions = '' )
Get confirmation on button or link before action
Get confirmation on button or link before action
Parameters
- $string
- to display or array of string for using multilines
- $additionalactions
additional actions to do on success confirmation
(default '')
Returns
confirmation script
Since
0.85
|
public static
nothing
|
#
progressBar( $id, array $options = [] )
Manage progresse bars
Parameters
- $id
- ID of the progress bar
- $options
progress status
- create do we have to create it ?
- message add or change the message
- percent current level
Returns
nothing (display)
Since
0.85
|
public static
nothing
|
#
createProgressBar( $msg = " " )
Create a Dynamic Progress Bar
Create a Dynamic Progress Bar
Parameters
- $msg
- message (under the bar) (default ' ')
Returns
nothing
|
public static
nothing
|
#
changeProgressBarMessage( $msg = " " )
Change the Message under the Progress Bar
Change the Message under the Progress Bar
Parameters
- $msg
- under the bar (default ' ')
Returns
nothing
|
public static
nothing
|
#
changeProgressBarPosition( $crt, $tot, $msg = "" )
Change the Progress Bar Position
Change the Progress Bar Position
Parameters
- $crt
- Value (less then $max)
- $tot
- Value
- $msg
- inside the bar (default is %) (default '')
Returns
nothing
|
public static
nothing
|
#
displayProgressBar( $width, $percent, $options = [] )
Display a simple progress bar
Display a simple progress bar
Parameters
- $width
- of the progress bar
- $percent
- of the progress bar
- $options
of possible options:
- title : string title to display (default Progesssion)
- simple : display a simple progress bar (no title / only percent)
- forcepadding : boolean force str_pad to force refresh (default true)
Returns
nothing
|
public static
|
#
glpi_flush( )
Flushes the system write buffers of PHP and whatever backend PHP is using (CGI, a web server, etc).
This attempts to push current output all the way to the browser with a few caveats.
Flushes the system write buffers of PHP and whatever backend PHP is using (CGI, a web server, etc).
This attempts to push current output all the way to the browser with a few caveats.
See
https://www.sitepoint.com/php-streaming-output-buffering-explained/
|
public static
|
#
openArrowMassives( $formname, $fixed = false, $ontop = false, $onright = false )
show arrow for massives actions : opening
show arrow for massives actions : opening
Deprecated
0.84
Parameters
- $formname
- string
- $fixed
- used tab_cadre_fixe in both tables (false by default)
- $ontop
- on top of the list (false by default)
- $onright
- on right of the list (false by default)
|
public static
|
#
closeArrowMassives( $actions, $confirm = [] )
show arrow for massives actions : closing
show arrow for massives actions : closing
Deprecated
0.84
Parameters
- $actions
- of action : $name -> $label
- $confirm
- of confirmation string (optional)
|
public static
Get
|
#
getCheckAllAsCheckbox( $container_id, $rand = '' )
Get "check All as" checkbox
Get "check All as" checkbox
Parameters
- $container_id
- html of the container of checkboxes link to this check all checkbox
- $rand
- rand value to use (default is auto generated)(default '')
Returns
Get checkbox string
Since
0.84
|
public static
the
|
#
getCriterionForMassiveCheckboxes( array $options )
Get the jquery criterion for massive checkbox update
We can filter checkboxes by a container or by a tag. We can also select checkboxes that have
a given tag and that are contained inside a container
Get the jquery criterion for massive checkbox update
We can filter checkboxes by a container or by a tag. We can also select checkboxes that have
a given tag and that are contained inside a container
Parameters
- $options
of parameters:
- tag_for_massive tag of the checkboxes to update
- container_id if of the container of the checkboxes
Returns
the javascript code for jquery criterion or empty string if it is not a
massive update checkbox
Since
0.85
|
public static
the
|
#
getCheckbox( array $options )
Get a checkbox.
Parameters
- $options
of parameters:
- title its title
- name its name
- id its id
- value the value to set when checked
- readonly can we edit it ?
- massive_tags the tag to set for massive checkbox update
- checked is it checked or not ?
- zero_on_empty do we send 0 on submit when it is not checked ?
- specific_tags HTML5 tags to add
- criterion the criterion for massive checkbox
Returns
the HTML code for the checkbox
Since
0.85
|
public static
nothing
|
#
showCheckbox( array $options = [] )
Parameters
Returns
nothing (display only)
Since
0.85
See
Html::getCheckbox()
Brief
display a checkbox that $_POST 0 or 1 depending on if it is checked or not.
|
public static
get
|
#
getMassiveActionCheckBox( $itemtype, $id, array $options = [] )
Get the massive action checkbox
Get the massive action checkbox
Parameters
- $itemtype
- action itemtype
- $id
- of the item
- $options
- array
Returns
get checkbox
Since
0.84
|
public static
show
|
#
showMassiveActionCheckBox( $itemtype, $id, array $options = [] )
Show the massive action checkbox
Show the massive action checkbox
Parameters
- $itemtype
- action itemtype
- $id
- of the item
- $options
- array
Returns
show checkbox
Since
0.84
|
public static
nothing
|
#
openMassiveActionsForm( $name = '' )
Display open form for massive action
Display open form for massive action
Parameters
- $name
- name/id to the form (default '')
Returns
nothing / display item
Since
0.84
|
public static
open
|
#
getOpenMassiveActionsForm( $name = '' )
Get open form for massive action string
Get open form for massive action string
Parameters
- $name
- name/id to the form (default '')
Returns
open form string
Since
0.84
|
public static
boolean|string
|
#
showMassiveActions( $options = [] )
Display massive actions
Parameters
- $options
of parameters
must contains :
- container : DOM ID of the container of the item checkboxes (since version 0.85)
may contains :
- num_displayed : integer number of displayed items. Permit to check suhosin limit.
(default -1 not to check)
- ontop : boolean true if displayed on top (default true)
- fixed : boolean true if used with fixed table display (default true)
- forcecreate : boolean force creation of modal window (default = false).
Modal is automatically created when displayed the ontop item.
If only a bottom one is displayed use it
- check_itemtype : string alternate itemtype to check right if different from main itemtype
(default empty)
- check_items_id : integer ID of the alternate item used to check right / optional
(default empty)
- is_deleted : boolean is massive actions for deleted items ?
- extraparams : string extra URL parameters to pass to massive actions (default empty)
if ([extraparams]['hidden'] is set : add hidden fields to post)
- specific_actions : array of specific actions (do not use standard one)
- add_actions : array of actions to add (do not use standard one)
- confirm : string of confirm message before massive action
- item : CommonDBTM object that has to be passed to the actions
- tag_to_send : the tag of the elements to send to the ajax window (default: common)
- display : display or return the generated html (default true)
Returns
boolean|string the html if display parameter is false, or true
Since
0.84 (before Search::displayMassiveActions)
0.85 only 1 parameter (in 0.84 $itemtype required)
Todo
replace 'hidden' by data-glpicore-ma-tags ?
|
public static
rand
|
#
showDateField( $name, $options = [] )
Display Date form with calendar
Display Date form with calendar
Parameters
- $name
- of the element
- $options
of possible options:
- value : default value to display (default '')
- maybeempty : may be empty ? (true by default)
- canedit : could not modify element (true by default)
- min : minimum allowed date (default '')
- max : maximum allowed date (default '')
- showyear : should we set/diplay the year? (true by default)
- display : boolean display of return string (default true)
- rand : specific rand value (default generated one)
- yearrange : set a year range to show in drop-down (default '')
Returns
rand value used if displayes else string
Since
0.84
|
public static
|
#
showColorField( $name, $options = [] )
Display Color field
Parameters
- $name
- of the element
- $options
of possible options:
- value : default value to display (default '')
- display : boolean display or get string (default true)
- rand : specific random value (default generated one)
Since
0.85
|
public static
rand
|
#
showDateTimeField( $name, $options = [] )
Display DateTime form with calendar
Display DateTime form with calendar
Parameters
- $name
- of the element
- $options
of possible options:
- value : default value to display (default '')
- timestep : step for time in minute (-1 use default config) (default -1)
- maybeempty : may be empty ? (true by default)
- canedit : could not modify element (true by default)
- mindate : minimum allowed date (default '')
- maxdate : maximum allowed date (default '')
- mintime : minimum allowed time (default '')
- maxtime : maximum allowed time (default '')
- showyear : should we set/diplay the year? (true by default)
- display : boolean display or get string (default true)
- rand : specific random value (default generated one)
- required : required field (will add required attribute)
Returns
rand value used if displayes else string
Since
0.84
|
public static
rand
|
#
showGenericDateTimeSearch( $element, $value = '', $options = [] )
Show generic date search
Parameters
- $element
- of the html element
- $value
- value (default '')
- $options
of possible options:
- with_time display with time selection ? (default false)
- with_future display with future date selection ? (default false)
- with_days display specific days selection TODAY, BEGINMONTH, LASTMONDAY... ? (default true)
Returns
rand value of dropdown
|
public static
array
|
#
getGenericDateTimeSearchItems( $options )
Get items to display for showGenericDateTimeSearch
Get items to display for showGenericDateTimeSearch
Parameters
- $options
of possible options:
- with_time display with time selection ? (default false)
- with_future display with future date selection ? (default false)
- with_days display specific days selection TODAY, BEGINMONTH, LASTMONDAY... ? (default true)
Returns
array of posible values
Since
0.83
See
|
public static
computed
|
#
computeGenericDateTimeSearch( $val, $force_day = false, $specifictime = '' )
Compute date / datetime value resulting of showGenericDateTimeSearch
Compute date / datetime value resulting of showGenericDateTimeSearch
Parameters
- $val
- / datetime value passed
- $force_day
- force computation in days (false by default)
- $specifictime
- set specific timestamp (default '')
Returns
computed date / datetime value
Since
0.83
See
|
public static
array
|
#
showDatesTimelineGraph( $options = [] )
Display or return a list of dates in a vertical way
Display or return a list of dates in a vertical way
Parameters
- $options
of possible options:
- title, do we need to append an H2 title tag
- dates, an array containing a collection of theses keys:
* timestamp
* class, supported: passed, checked, now
* label
- display, boolean to precise if we need to display (true) or return (false) the html
- add_now, boolean to precise if we need to add to dates array, an entry for now time
(with now class)
Returns
array of posible values
Since
9.2
See
|
public static
nothing
|
#
showProfileSelecter( $target )
Print the form used to select profile if several are available
Print the form used to select profile if several are available
Parameters
Returns
nothing
|
public static
nothing
|
#
showToolTip( $content, $options = [] )
Show a tooltip on an item
Show a tooltip on an item
Parameters
- $content
- data to put in the tooltip
- $options
of possible options:
- applyto : string / id of the item to apply tooltip (default empty).
If not set display an icon
- title : string / title to display (default empty)
- contentid : string / id for the content html container (default auto generated) (used for ajax)
- link : string / link to put on displayed image if contentid is empty
- linkid : string / html id to put to the link link (used for ajax)
- linktarget : string / target for the link
- popup : string / popup action : link not needed to use it
- img : string / url of a specific img to use
- display : boolean / display the item : false return the datas
- autoclose : boolean / autoclose the item : default true (false permit to scroll)
Returns
nothing (print out an HTML div)
|
public static
|string
|
#
autocompletionTextField( CommonDBTM $item, strign $field, array $options = [] )
Show div with auto completion
Show div with auto completion
Parameters
- $item
- item object used for create dropdown
- $field
- field to search for autocompletion
- $options
array of possible options:
- name : string / name of the select (default is field parameter)
- value : integer / preselected value (default value of the item object)
- size : integer / size of the text field
- entity : integer / restrict to a defined entity (default entity of the object if define)
set to -1 not to take into account
- user : integer / restrict to a defined user (default -1 : no restriction)
- option : string / options to add to text field
- display : boolean / if false get string
- type : string / html5 field type (number, date, text, ...) defaults to 'text'
- required: boolean / whether the field is required
- rand : integer / pre-exsting random value
- attrs : array of attributes to add (['name' => 'value']
Returns
|string
|
public static
nothing
|
#
initEditorSystem( $name, $rand = '', $display = true, $readonly = false )
Init the Editor System to a textarea
Init the Editor System to a textarea
Parameters
- $name
- of the html textarea to use
- $rand
- of the html textarea to use (if empty no image paste system)(default '')
- $display
- display or get js script (true by default)
- $readonly
- editor will be readonly or not
Returns
nothing
|
public static
|
#
setSimpleTextContent( $content )
Convert rich text content to simple text content
Convert rich text content to simple text content
Parameters
- $content
- content to convert in html
Returns
$content
Since
9.2
|
public static
|
#
setRichTextContent( string $name, string $content, string $rand, boolean $readonly = false )
Convert simple text content to rich text content and init html editor
Convert simple text content to rich text content and init html editor
Parameters
- $name
- name of textarea
- $content
- content to convert in html
- $rand
- used for randomize tinymce dom id
- $readonly
- true will set editor in readonly mode
Returns
$content
Since
9.2
|
public static
nothing
|
#
printCleanArray( $tab, $pad = 0, $jsexpand = false )
Clean Printing of and array in a table
ONLY FOR DEBUG
Clean Printing of and array in a table
ONLY FOR DEBUG
Parameters
- $tab
- array to display
- $pad
- used (default 0)
- $jsexpand
- using JS ? (default false)
Returns
nothing
|
public static
String
|
#
makeTitle( $string, $num, $tot )
Create a title for list, as "List (5 on 35)"
Create a title for list, as "List (5 on 35)"
Parameters
- $string
- text for title
- $num
- number of item displayed
- $tot
- number of item existing
Returns
String
Since
0.83.1
|
public static
|
#
getSimpleForm( $action, $btname, $btlabel, array $fields = [], $btimage = '', $btoption = '', $confirm = '' )
create a minimal form for simple action
create a minimal form for simple action
Parameters
- $action
- URL to call on submit
- $btname
- button name (maybe if name <> value)
- $btlabel
- button label
- $fields
- field name => field value
- $btimage
button image uri (optional) (default '')
If image name starts with "fa-", il will be turned into
a font awesome element rather than an image.
- $btoption
- optional button option (default '')
- $confirm
- optional confirm message (default '')
Since
0.84
|
public static
|
#
showSimpleForm( $action, $btname, $btlabel, array $fields = [], $btimage = '', $btoption = '', $confirm = '' )
create a minimal form for simple action
create a minimal form for simple action
Parameters
- $action
- URL to call on submit
- $btname
- button name
- $btlabel
- button label
- $fields
- field name => field value
- $btimage
- button image uri (optional) (default '')
- $btoption
- optional button option (default '')
- $confirm
- optional confirm message (default '')
Since
0.83.3
|
public static
String
|
#
closeForm( $display = true )
Create a close form part including CSRF token
Create a close form part including CSRF token
Parameters
- $display
- Display or return string (default true)
Returns
String
Since
0.83.
|
public static
String
|
#
jsHide( $id )
Get javascript code for hide an item
Get javascript code for hide an item
Parameters
- $id
- id of the dom element
Returns
String
Since
0.85.
|
public static
String
|
#
jsShow( $id )
Get javascript code for hide an item
Get javascript code for hide an item
Parameters
- $id
- id of the dom element
Returns
String
Since
0.85.
|
public static
String
|
#
jsEnable( $id )
Get javascript code for enable an item
Get javascript code for enable an item
Parameters
- $id
- id of the dom element
Returns
String
Since
0.85.
|
public static
String
|
#
jsDisable( $id )
Get javascript code for disable an item
Get javascript code for disable an item
Parameters
- $id
- id of the dom element
Returns
String
Since
0.85.
|
public static
String
|
#
cleanId( $id )
Clean ID used for HTML elements
Clean ID used for HTML elements
Parameters
- $id
- id of the dom element
Returns
String
Since
0.85.
|
public static
String
|
#
jsGetElementbyID( $id )
Get javascript code to get item by id
Get javascript code to get item by id
Parameters
- $id
- id of the dom element
Returns
String
Since
0.85.
|
public static
string
|
#
jsSetDropdownValue( $id, $value )
Set dropdown value
Parameters
- $id
- id of the dom element
- $value
- value to set
Returns
string
Since
0.85.
|
public static
string
|
#
jsGetDropdownValue( $id )
Get item value
Parameters
- $id
- id of the dom element
Returns
string
Since
0.85.
|
public static
String
|
#
jsAdaptDropdown( $id, $params = [] )
Adapt dropdown to clean JS
Adapt dropdown to clean JS
Parameters
- $id
- id of the dom element
- $params
- of parameters
Returns
String
Since
0.85.
|
public static
String
|
#
jsAjaxDropdown( $name, $field_id, $url, $params = [] )
Create Ajax dropdown to clean JS
Create Ajax dropdown to clean JS
Parameters
- $name
- $field_id
- id of the dom element
- $url
- URL to get datas
- $params
of parameters
must contains :
- 'value' : default value selected
- 'valuename' : default name of selected value
Returns
String
Since
0.85.
|
public static
string
|
#
image( $path, $options = [] )
Creates a formatted IMG element.
Creates a formatted IMG element.
This method will set an empty alt attribute if no alt and no title is not supplied
Parameters
- $path
- to the image file
- $options
of HTML attributes
- url If provided an image link will be generated and the link will point at
$options['url'] .
Returns
string completed img tag
Since
0.85
|
public static
string
|
#
link( $text, $url, $options = [] )
Creates an HTML link.
Parameters
- $text
- content to be wrapped by a tags.
- $url
- parameter
- $options
of HTML attributes:
- confirm JavaScript confirmation message.
- confirmaction optional action to do on confirmation
Returns
string an a element.
Since
0.85
|
public static
string
|
#
hidden( $fieldName, $options = [] )
Creates a hidden input field.
Creates a hidden input field.
If value of options is an array then recursively parse it
to generate as many hidden input as necessary
Parameters
- $fieldName
- of a field
- $options
- of HTML attributes.
Returns
string A generated hidden input
Since
0.85
|
public static
string
|
#
input( $fieldName, $options = [] )
Creates a text input field.
Creates a text input field.
Parameters
- $fieldName
- of a field
- $options
- of HTML attributes.
Returns
string A generated hidden input
Since
0.85
|
public static
string
|
#
select( string $name, array $values, mixed $options = [], array $options,… )
Creates a select tag
Parameters
- $name
- $ame Name of the field
- $values
- Array of the options
- $options
- $selected Current selected option
- $options,…
- Array of HTML attributes
Returns
string
Since
9.3
|
public static
string
|
#
submit( $caption, $options = [] )
Creates a submit button element. This method will generate input elements that
can be used to submit, and reset forms by using $options. Image submits can be created by supplying an
image option
Creates a submit button element. This method will generate input elements that
can be used to submit, and reset forms by using $options. Image submits can be created by supplying an
image option
Parameters
- $caption
- of the input
- $options
of options.
- image : will use a submit image input
- confirm JavaScript confirmation message.
- confirmaction optional action to do on confirmation
Returns
string A HTML submit button
Since
0.85
|
public static
string
|
#
parseAttributes( $options = [] )
Returns a space-delimited string with items of the $options array.
Returns a space-delimited string with items of the $options array.
Parameters
Returns
string Composed attributes.
Since
0.85
|
public static
string
|
#
formatAttribute( $key, $value )
Formats an individual attribute, and returns the string value of the composed attribute.
Formats an individual attribute, and returns the string value of the composed attribute.
Parameters
- $key
- name of the attribute to create
- $value
- value of the attribute to create.
Returns
string The composed attribute.
Since
0.85
|
public static
string
|
#
scriptBlock( $script )
Wrap $script in a script tag.
Wrap $script in a script tag.
Parameters
Returns
string
Since
0.85
|
public static
String
|
#
script( string $url, array $options = [], boolean $minify = true )
Returns one or many script tags depending on the number of scripts given.
Returns one or many script tags depending on the number of scripts given.
Parameters
- $url
- File to include (relative to GLPI_ROOT)
- $options
- Array of HTML attributes
- $minify
- Try to load minified file (defaults to true)
Returns
String of script tags
Since
0.85
9.2 Path is now relative to GLPI_ROOT. Add $minify parameter.
|
public static
string
|
#
css( string $url, array $options = [], boolean $minify = true )
Creates a link element for CSS stylesheets.
Creates a link element for CSS stylesheets.
Parameters
- $url
- File to include (relative to GLPI_ROOT)
- $options
- Array of HTML attributes
- $minify
- Try to load minified file (defaults to true)
Returns
string CSS link tag
Since
0.85
9.2 Path is now relative to GLPI_ROOT. Add $minify parameter.
|
public static
string
|
#
scss( string $url, array $options = [] )
Creates a link element for SCSS stylesheets.
Creates a link element for SCSS stylesheets.
Parameters
- $url
- File to include (relative to GLPI_ROOT)
- $options
- Array of HTML attributes
Returns
string CSS link tag
Since
9.4
|
private static
string
|
#
csslink( sring $url, array $options )
Creates a link element for (S)CSS stylesheets.
Creates a link element for (S)CSS stylesheets.
Parameters
- $url
- File to include (raltive to GLPI_ROOT)
- $options
- Array of HTML attributes
Returns
string CSS link tag
Since
9.4
|
public static
string
|
#
fileForRichText( array $options = [] )
Display a div who reveive a list of uploaded file
Display a div who reveive a list of uploaded file
Parameters
- $options
theses following keys:
- editor_id the dom id of the tinymce editor
Returns
string The Html
Since
version 9.2
|
public static
|string
|
#
file( $options = [] )
Creates an input file field. Send file names in _$name field as array.
Files are uploaded in files/_tmp/ directory
Creates an input file field. Send file names in _$name field as array.
Files are uploaded in files/_tmp/ directory
Parameters
- $options
of options
- name string field name (default filename)
- onlyimages boolean restrict to image files (default false)
- filecontainer string DOM ID of the container showing file uploaded:
use selector to display
- showfilesize boolean show file size with file name
- showtitle boolean show the title above file list
(with max upload size indication)
- enable_richtext boolean switch to richtext fileupload
- pasteZone string DOM ID of the paste zone
- dropZone string DOM ID of the drop zone
- rand string already computed rand value
- display boolean display or return the generated html (default true)
Returns
|string the html if display parameter is false
Since
9.2
|
public static
mixed
|
#
textarea( array $options = [] )
Display an html textarea with extended options
Display an html textarea with extended options
Parameters
- $options
with these keys:
- name (string): corresponding html attribute
- filecontainer (string): dom id for the upload filelist
- rand (string): random param to avoid overriding between textareas
- editor_id (string): id attribute for the textarea
- value (string): value attribute for the textarea
- enable_richtext (bool): enable tinymce for this textarea
- enable_fileupload (bool): enable the inline fileupload system
- display (bool): display or return the generated html
- cols (int): textarea cols attribute (witdh)
- rows (int): textarea rows attribute (height)
Returns
mixed the html if display paremeter is false or true
Since
9.2
|
public static
string
|
|
public static
random
|
#
showCheckboxMatrix( array $columns, array $rows, array $options = [] )
Display choice matrix
Parameters
- $columns
- of column field name => column label
- $rows
of field name => array(
'label' the label of the row
'columns' an array of specific information regaring current row
and given column indexed by column field_name
* a string if only have to display a string
* an array('value' => ???, 'readonly' => ???) that is used to Dropdown::showYesNo()
- $options
possible:
'title' of the matrix
'first_cell' the content of the upper-left cell
'row_check_all' set to true to display a checkbox to check all elements of the row
'col_check_all' set to true to display a checkbox to check all elements of the col
'rand' random number to use for ids
Returns
random value used to generate the ids
Since
0.85
|
public static
|
#
ajaxForm( $selector, $success = "console.log(html);" )
This function provides a mecanism to send html form by ajax
This function provides a mecanism to send html form by ajax
Since
9.1
|
public static
|
#
redefineAlert( )
In this function, we redefine 'window.alert' javascript function
by a jquery-ui dialog equivalent (but prettier).
In this function, we redefine 'window.alert' javascript function
by a jquery-ui dialog equivalent (but prettier).
Since
9.1
|
public static
|
#
jsConfirmCallback( $msg, $title, $yesCallback = null, $noCallback = null )
Summary of confirmCallback
Is a replacement for Javascript native confirm function
Beware that native confirm is synchronous by nature (will block
browser waiting an answer from user, but that this is emulating the confirm behaviour
by using callbacks functions when user presses 'Yes' or 'No' buttons.
Summary of confirmCallback
Is a replacement for Javascript native confirm function
Beware that native confirm is synchronous by nature (will block
browser waiting an answer from user, but that this is emulating the confirm behaviour
by using callbacks functions when user presses 'Yes' or 'No' buttons.
Parameters
- $msg
- message to be shown
- $title
- title for dialog box
- $yesCallback
function that will be called when 'Yes' is pressed
(default null)
- $noCallback
function that will be called when 'No' is pressed
(default null)
Since
9.1
|
public static
|
#
redefineConfirm( )
In this function, we redefine 'window.confirm' javascript function
by a jquery-ui dialog equivalent (but prettier).
This dialog is normally asynchronous and can't return a boolean like naive window.confirm.
We manage this behavior with a global variable 'confirmed' who watchs the acceptation of dialog.
In this case, we trigger a new click on element to return the value (and without display dialog)
In this function, we redefine 'window.confirm' javascript function
by a jquery-ui dialog equivalent (but prettier).
This dialog is normally asynchronous and can't return a boolean like naive window.confirm.
We manage this behavior with a global variable 'confirmed' who watchs the acceptation of dialog.
In this case, we trigger a new click on element to return the value (and without display dialog)
Since
9.1
|
public static
|
#
jsAlertCallback( $msg, $title, $okCallback = null )
Summary of jsAlertCallback
Is a replacement for Javascript native alert function
Beware that native alert is synchronous by nature (will block
browser waiting an answer from user, but that this is emulating the alert behaviour
by using a callback function when user presses 'Ok' button.
Summary of jsAlertCallback
Is a replacement for Javascript native alert function
Beware that native alert is synchronous by nature (will block
browser waiting an answer from user, but that this is emulating the alert behaviour
by using a callback function when user presses 'Ok' button.
Parameters
- $msg
- message to be shown
- $title
- title for dialog box
- $okCallback
function that will be called when 'Ok' is pressed
(default null)
Since
9.1
|
public static
string
|
#
convertTagFromRichTextToImageTag( string|array $tag, integer $width, integer $height, boolean $addLink = true, string $more_link = "" )
Convert tag to image
Deprecated
9.4.3
Parameters
- $tag
- the tag identifier of the document
- $width
- witdh of the final image
- $height
- height of the final image
- $addLink
- boolean, do we need to add an anchor link
- $more_link
- append to the link (ex &test=true)
Returns
string
Since
9.2
|
public static
string
|
#
getImageHtmlTagForDocument( integer $document_id, integer $width, integer $height, boolean $addLink = true, string $more_link = "" )
Get image html tag for image document.
Get image html tag for image document.
Parameters
- $document_id
- identifier of the document
- $width
- witdh of the final image
- $height
- height of the final image
- $addLink
- boolean, do we need to add an anchor link
- $more_link
- append to the link (ex &test=true)
Returns
string
Since
9.4.3
|
public static
string
|
#
getCopyrightMessage( boolean $withVersion = true )
Get copyright message in HTML (used in footers)
Get copyright message in HTML (used in footers)
Parameters
- $withVersion
- include GLPI version ?
Returns
string HTML copyright
Since
9.1
|
public static
|
#
requireJs( string|array $name )
A a required javascript lib
A a required javascript lib
Parameters
- $name
- Either a know name, or an array defining lib
|
private static
|
|
private static
string
|
#
getMiniFile( string $file_path )
Get a stylesheet or javascript path, minified if any
Return minified path if minified file exists and not in
debug mode, else standard path
Get a stylesheet or javascript path, minified if any
Return minified path if minified file exists and not in
debug mode, else standard path
Parameters
- $file_path
- File path part
Returns
string
|
final public static
string
|
#
getPrefixedUrl( string $url )
Return prefixed URL
Parameters
- $url
- Original URL (not prefixed)
Returns
string
Since
9.2
|
public static
string
|
#
manageRefreshPage( integer|false $timer = false, string|null $callback = null )
Add the HTML code to refresh the current page at a define interval of time
Add the HTML code to refresh the current page at a define interval of time
Parameters
- $timer
- The time (in minute) to refresh the page
- $callback
- A javascript callback function to execute on timer
Returns
string
|
public static
nothing
|
#
fuzzySearch( string $action = '' )
Manage events from js/fuzzysearch.js
Manage events from js/fuzzysearch.js
Parameters
- $action
- action to switch (should be actually 'getHtml' or 'getList')
Returns
nothing (display)
Since
9.2
|
private static
|
#
displayMainMenu( boolean $full, array $options = [] )
Display GLPI main menu
Parameters
- $full
- True for full interface, false otherwise
- $options
- Option
|
public static
string
|
#
getInvertedColor( string $hexcolor = "", boolean $bw = true, boolean $sbw = true )
Invert the input color (usefull for label bg on top of a background)
inpiration: https://github.com/onury/invert-color
Invert the input color (usefull for label bg on top of a background)
inpiration: https://github.com/onury/invert-color
Parameters
- $hexcolor
the color, you can pass hex color (prefixed or not by #)
You can also pass a short css color (ex #FFF)
- $bw
- default true, should we invert the color or return black/white function of the input color
- $sbw
- $sb default true, should we soft the black/white to a dark/light grey
Returns
string the inverted color prefixed by #
Since
9.3
|
public static
string
|
#
compileScss( array $args )
Compile SCSS styleshet
Parameters
- $args
Arguments. May contain:
- v: version to append (will default to GLPI_VERSION)
- debug: if present, will not use Crunched formatter
- file: filerepresentation to load
- reload: force reload and recache
- nocache: do not use nor update cache
Returns
string
|
public static
array
|
#
getScssCompilePath( $file )
Get scss compilation path for given file.
Get scss compilation path for given file.
Returns
array
|
public static
string
|
#
getScssCompileDir( )
Get scss compilation directory.
Get scss compilation directory.
Returns
string
|