class SetupPage extends FormPage (View source)

SetupPage class

Properties

protected string $head from Page
protected string $title from Page
protected string $access_permission from Page
protected array $tabs from Page
protected array $main_subtitle from Page
protected string $tabs_picture from Page
protected string $tabs_title from Page
protected string $active_tab from Page
protected boolean $close_form from Page
protected boolean $close_table from Page
protected boolean $add_fiche_end from Page
protected string $rights_class from Page
protected string $modulepart from Page
protected array $assets from Page
object $form from FormPage
protected string $body from FormPage
protected array $fields from FormPage
protected boolean $odd
protected string $const_name_prefix
protected string $num_model_const_name
protected string $doc_model_const_name
protected string $doc_model_type
protected string $doc_model_preview_picture
protected string $doc_object_class
protected string $doc_object_path
protected boolean $disable_default_actions
$title_link
protected boolean $add_extrafields_tab
protected boolean $add_changelog_tab
protected boolean $use_ajax_to_switch_on_off

Methods

__construct($page_title = 'Setup', $access_perm = '$user->admin', $disable_default_actions = false, $add_extrafields_tab = false, $add_changelog_tab = false, $const_name_prefix = '', $doc_model_type = '', $doc_object_class = '', $doc_object_path = '')

Constructor

$this
setTitle($page_title)

Set page title.

from Page
$this
setMainSubtitle($title, $picture = 'title_generic.png')

Set page main subtitle.

from Page
$this
loadLang($lang_file, $is_module_file = true)

Load a language file

from Page
$this
loadLangs($lang_files_array, $from_module = false)

Load an array of language files

from Page
$this
appendToHead($content)

Append content to page head.

from Page
$this
addJsFile($js_file)

Add JS file to page head.

from Page
$this
addJsFiles($js_files_array)

Add an array of JS files.

from Page
$this
addCssFile($css_file)

Add CSS file to page head.

from Page
$this
addCssFiles($css_files_array)

Add an array of CSS files.

from Page
$this
addTab($title, $url, $is_active = false, $position = -1)

Add a tab to the page.

from Page
$this
setTabsPicture($picture)

Set tabs picture.

from Page
$this
setTabsTitle($title)

Set tabs title.

from Page
generateTabs($noheader = -1)

Generate tabs

$this
addSubTitle($title, $picture = 'title_generic.png', $morehtmlright = '')

Add a subtitle

from Page
$this
openForm($action = 'create', $enctype = '')

Open a form only if not already opened

from Page
$this
closeForm()

Close an opened form

from Page
$this
openTable($header_columns = array(), $attr = 'class="noborder allwidth"', $print_fiche_head = false, $summary = '')

Opens a new html table

from Page
$this
closeTable($print_fiche_end = false)

Close an opened html table

from Page
$this
openRow($odd = true, $more_attr = '')

Open a table row

from Page
$this
closeRow()

Close a table row

from Page
$this
addColumn($content, $attr = '')

Add a table column

from Page
$this
addLineBreak($repeat)

Add a line break (or many)

from Page
string
getTemplatePath($template)

Return template absolute path

from Page
$this
showTemplate($template_path, $path_is_absolute = false, $use_require_once = false, $template_params = array())

Include a template into the page.

from Page
$this
underConstruction()

Show page_under_construction template (only once)

from Page
$this
notFound()

Show page_not_found template (only once)

from Page
loadDefaultActions()

Load default actions

$this
begin()

Generate page beginning

from Page
generate()

Generate page body

redirect($url)

Redirect to a url (alias for dolibase_redirect function).

from Page
end()

Generate page end.

from Page
$this
setFields($fields)

Set page fields

from FormPage
boolean
checkFields()

Check page fields

from FormPage
boolean|int
checkField($field_name, $field_trans = '', $field_validation_rules = '', $return_err_number = false)

Check specified field

from FormPage
Field|empty
getField($field_name)

Return specified field if found

from FormPage
$this
askForConfirmation($url, $title, $question, $action, $question_param = '', $dialog_id_suffix = '')

Show a confirmation message

from FormPage
$this
appendToBody($content)

Append a content to page body

from FormPage
$this
setTitleLink($link, $label, $enable = '$user->admin')

Set Title link

$this
setDocModelPreviewPicture($picture)

Set Document model(s) preview picture

$this
useAjaxToSwitchOnOff()

Set $use_ajax_to_switch_on_off attribute to true

$this
setupNotAvailable()

Show setup_not_available template (only once)

$this
newOptionsTable($first_column_name = 'Option')

Create a new table for options

$this
addOption($option_desc, $option_content, $const_name = '', $morehtmlright = '', $width = 300, $form_enctype = '')

Add a new option

$this
addSwitchOption($option_desc, $const_name, $disabled = false, $morehtmlright = '')

Add a new switch option

$this
addTextOption($option_desc, $const_name, $morehtmlright = '', $size = 16, $width = 300)

Add a new text option

$this
addNumberOption($option_desc, $const_name, $min, $max = 100, $morehtmlright = '', $width = 300)

Add a new number only option

$this
addRangeOption($option_desc, $const_name, $min, $max = 100, $morehtmlright = '', $width = 300)

Add a new range option

$this
addListOption($option_desc, $const_name, $list, $morehtmlright = '', $width = 300)

Add a new list option

$this
addMultiSelectListOption($option_desc, $const_name, $list, $morehtmlright = '', $width = 300)

Add a new multi select list option

$this
addColorOption($option_desc, $const_name, $morehtmlright = '', $width = 300)

Add a new color picker option

openButtonsDiv()

Open buttons div (if not already opened)

closeButtonsDiv()

Close buttons div (if opened)

$this
addButton($name, $href = '#', $target = '_self', $class = 'butAction', $close_parent_div = false)

Add a button to the page

$this
addConfirmButton($name, $id, $href = '#', $target = '_self', $class = 'butAction', $close_parent_div = false)

Add a confirmation button to the page

$this
printNumModels($model_name = '')

Print numbering models

$this
printDocModels()

Print document models

Details

__construct($page_title = 'Setup', $access_perm = '$user->admin', $disable_default_actions = false, $add_extrafields_tab = false, $add_changelog_tab = false, $const_name_prefix = '', $doc_model_type = '', $doc_object_class = '', $doc_object_path = '')

Constructor

Parameters

$page_title HTML page title
$access_perm Access permission
$disable_default_actions Disable default actions
$add_extrafields_tab Add extrafields tab
$add_changelog_tab Add changelog tab
$const_name_prefix Constant name prefix
$doc_model_type Document model type
$doc_object_class Document object class
$doc_object_path Document object path

$this setTitle($page_title)

Set page title.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$page_title Page title

Return Value

$this

$this setMainSubtitle($title, $picture = 'title_generic.png')

Set page main subtitle.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$title title
$picture subtitle picture

Return Value

$this

$this loadLang($lang_file, $is_module_file = true)

Load a language file

Parameters

$lang_file Language file
$is_module_file File is in module 'langs' directory or not

Return Value

$this

$this loadLangs($lang_files_array, $from_module = false)

Load an array of language files

Parameters

$lang_files_array Language files array
$from_module Files should be loaded from module 'langs' directory or not

Return Value

$this

$this appendToHead($content)

Append content to page head.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$content content to add

Return Value

$this

$this addJsFile($js_file)

Add JS file to page head.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$js_file Javascript file

Return Value

$this

$this addJsFiles($js_files_array)

Add an array of JS files.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$js_files_array Javascript files array

Return Value

$this

$this addCssFile($css_file)

Add CSS file to page head.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$css_file CSS file

Return Value

$this

$this addCssFiles($css_files_array)

Add an array of CSS files.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$css_files_array CSS files array

Return Value

$this

$this addTab($title, $url, $is_active = false, $position = -1)

Add a tab to the page.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$title tab title
$url tab url
$is_active should this tab be the activated one (true or false)
$position tab position (-1 means add to the end)

Return Value

$this

$this setTabsPicture($picture)

Set tabs picture.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$picture tabs picture

Return Value

$this

$this setTabsTitle($title)

Set tabs title.

Note: this function should be called before $page->begin() function, otherwise it will not work as expected.

Parameters

$title tabs title

Return Value

$this

protected generateTabs($noheader = -1)

Generate tabs

Parameters

$noheader -1 or 0=Add tab header, 1=no tab header.

$this addSubTitle($title, $picture = 'title_generic.png', $morehtmlright = '')

Add a subtitle

Parameters

$title subtitle title
$picture subtitle picture
$morehtmlright more HTML to show on the right

Return Value

$this

$this openForm($action = 'create', $enctype = '')

Open a form only if not already opened

Parameters

$action form action
$enctype form enctype attribute

Return Value

$this

$this closeForm()

Close an opened form

Return Value

$this

$this openTable($header_columns = array(), $attr = 'class="noborder allwidth"', $print_fiche_head = false, $summary = '')

Opens a new html table

Parameters

$header_columns table header columns, e.: array( array('name' => 'Column1', 'attr' => 'align="center"'), array('name' => 'Column2', 'attr' => 'align="center" width="20"') )
$attr table attributes
$print_fiche_head print Dolibarr fiche head
$summary table summary

Return Value

$this

$this closeTable($print_fiche_end = false)

Close an opened html table

Parameters

$print_fiche_end print Dolibarr fiche end

Return Value

$this

$this openRow($odd = true, $more_attr = '')

Open a table row

Parameters

$odd row is odd or peer
$more_attr more attributes to add

Return Value

$this

$this closeRow()

Close a table row

Return Value

$this

$this addColumn($content, $attr = '')

Add a table column

Parameters

$content column content
$attr column attributes

Return Value

$this

$this addLineBreak($repeat)

Add a line break (or many)

Parameters

$repeat repeat line breaks

Return Value

$this

protected string getTemplatePath($template)

Return template absolute path

Parameters

$template template relative path or name

Return Value

string template absolute path

$this showTemplate($template_path, $path_is_absolute = false, $use_require_once = false, $template_params = array())

Include a template into the page.

Note: the template should be inside module tpl folder when $path_is_absolute parameter equal false.

Parameters

$template_path template path
$path_is_absolute define whether the template path is absolute or not
$use_require_once permit to avoid including the template many times on the same page
$template_params template parameters

Return Value

$this

$this underConstruction()

Show page_under_construction template (only once)

Return Value

$this

$this notFound()

Show page_not_found template (only once)

Return Value

$this

protected loadDefaultActions()

Load default actions

$this begin()

Generate page beginning

Return Value

$this

protected generate()

Generate page body

redirect($url)

Redirect to a url (alias for dolibase_redirect function).

Note: this function should be called before any output, so before $page->begin() function.

Parameters

$url

end()

Generate page end.

Note: this function should be called after $page->begin() call.

$this setFields($fields)

Set page fields

Parameters

$fields array of fields

Return Value

$this

boolean checkFields()

Check page fields

Return Value

boolean true or false

boolean|int checkField($field_name, $field_trans = '', $field_validation_rules = '', $return_err_number = false)

Check specified field

Parameters

$field_name Field name
$field_trans Field translation
$field_validation_rules Field validatin rules
$return_err_number return errors number or boolean value

Return Value

boolean|int true/false | errors number

protected Field|empty getField($field_name)

Return specified field if found

Parameters

$field_name

Return Value

Field|empty field object or empty value

$this askForConfirmation($url, $title, $question, $action, $question_param = '', $dialog_id_suffix = '')

Show a confirmation message

Parameters

$url Page url
$title Message title
$question Message question / content
$action Action to do after confirmation
$question_param Question parameter
$dialog_id_suffix Dialog id suffix (used to show the dialog without reloading the page)

Return Value

$this

$this appendToBody($content)

Append a content to page body

Parameters

$content content to add

Return Value

$this

Set Title link

Parameters

$link Link href
$label Link label
$enable Condition to enable

Return Value

$this

$this setDocModelPreviewPicture($picture)

Set Document model(s) preview picture

Parameters

$picture Document model preview picture

Return Value

$this

$this useAjaxToSwitchOnOff()

Set $use_ajax_to_switch_on_off attribute to true

Return Value

$this

$this setupNotAvailable()

Show setup_not_available template (only once)

Return Value

$this

$this newOptionsTable($first_column_name = 'Option')

Create a new table for options

Parameters

$first_column_name First column name

Return Value

$this

$this addOption($option_desc, $option_content, $const_name = '', $morehtmlright = '', $width = 300, $form_enctype = '')

Add a new option

Parameters

$option_desc Option description
$option_content Option content, it can be HTML or even a string
$const_name Option constant name
$morehtmlright more HTML to add on the right of the option description
$width Option last column/td width
$form_enctype Form enctype attribute

Return Value

$this

$this addSwitchOption($option_desc, $const_name, $disabled = false, $morehtmlright = '')

Add a new switch option

Parameters

$option_desc Option description
$const_name Option constant name
$disabled disable option or not
$morehtmlright more HTML to add on the right of the option description

Return Value

$this

$this addTextOption($option_desc, $const_name, $morehtmlright = '', $size = 16, $width = 300)

Add a new text option

Parameters

$option_desc Option description
$const_name Option constant name
$morehtmlright more HTML to add on the right of the option description
$size Option textbox size
$width Option last column/td width

Return Value

$this

$this addNumberOption($option_desc, $const_name, $min, $max = 100, $morehtmlright = '', $width = 300)

Add a new number only option

Parameters

$option_desc Option description
$const_name Option constant name
$min Option minimum number
$max Option maximum number
$morehtmlright more HTML to add on the right of the option description
$width Option last column/td width

Return Value

$this

$this addRangeOption($option_desc, $const_name, $min, $max = 100, $morehtmlright = '', $width = 300)

Add a new range option

Parameters

$option_desc Option description
$const_name Option constant name
$min Option minimum value
$max Option maximum value
$morehtmlright more HTML to add on the right of the option description
$width Option last column/td width

Return Value

$this

$this addListOption($option_desc, $const_name, $list, $morehtmlright = '', $width = 300)

Add a new list option

Parameters

$option_desc Option description
$const_name Option constant name
$list Options list array
$morehtmlright more HTML to add on the right of the option description
$width Option last column/td width

Return Value

$this

$this addMultiSelectListOption($option_desc, $const_name, $list, $morehtmlright = '', $width = 300)

Add a new multi select list option

Parameters

$option_desc Option description
$const_name Option constant name
$list Options list array
$morehtmlright more HTML to add on the right of the option description
$width Option last column/td width

Return Value

$this

$this addColorOption($option_desc, $const_name, $morehtmlright = '', $width = 300)

Add a new color picker option

Parameters

$option_desc Option description
$const_name Option constant name
$morehtmlright more HTML to add on the right of the option description
$width Option last column/td width

Return Value

$this

protected openButtonsDiv()

Open buttons div (if not already opened)

protected closeButtonsDiv()

Close buttons div (if opened)

$this addButton($name, $href = '#', $target = '_self', $class = 'butAction', $close_parent_div = false)

Add a button to the page

Parameters

$name button name
$href button href
$target button target
$class button class
$close_parent_div should close parent div or not

Return Value

$this

$this addConfirmButton($name, $id, $href = '#', $target = '_self', $class = 'butAction', $close_parent_div = false)

Add a confirmation button to the page

Parameters

$name button name
$id button id (used to display the confirmation dialog)
$href button href
$target button target
$class button class
$close_parent_div should close parent div or not

Return Value

$this

$this printNumModels($model_name = '')

Print numbering models

Parameters

$model_name Numbering model name

Return Value

$this

$this printDocModels()

Print document models

Return Value

$this