class Page (View source)

Page class

Properties

protected string $head
protected string $title
protected string $access_permission
protected array $tabs
protected array $main_subtitle
protected string $tabs_picture
protected string $tabs_title
protected string $active_tab
protected boolean $close_form
protected boolean $close_table
protected boolean $add_fiche_end
protected string $rights_class
protected string $modulepart
protected array $assets

Methods

__construct($page_title, $access_perm = '')

Constructor

$this
setTitle($page_title)

Set page title.

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

Set page main subtitle.

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

Load a language file

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

Load an array of language files

$this
appendToHead($content)

Append content to page head.

$this
addJsFile($js_file)

Add JS file to page head.

$this
addJsFiles($js_files_array)

Add an array of JS files.

$this
addCssFile($css_file)

Add CSS file to page head.

$this
addCssFiles($css_files_array)

Add an array of CSS files.

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

Add a tab to the page.

$this
setTabsPicture($picture)

Set tabs picture.

$this
setTabsTitle($title)

Set tabs title.

generateTabs($noheader)

Generate tabs

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

Add a subtitle

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

Open a form only if not already opened

$this
closeForm()

Close an opened form

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

Opens a new html table

$this
closeTable($print_fiche_end = false)

Close an opened html table

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

Open a table row

$this
closeRow()

Close a table row

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

Add a table column

$this
addLineBreak($repeat)

Add a line break (or many)

string
getTemplatePath($template)

Return template absolute path

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

Include a template into the page.

$this
underConstruction()

Show page_under_construction template (only once)

$this
notFound()

Show page_not_found template (only once)

loadDefaultActions()

Load default actions

$this
begin()

Generate page beginning

generate()

Generate page body

redirect($url)

Redirect to a url (alias for dolibase_redirect function).

end()

Generate page end.

Details

__construct($page_title, $access_perm = '')

Constructor

Parameters

$page_title HTML page title
$access_perm Access permission

$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)

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.