Admidio API
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Packages

  • com
    • tecnick
      • tcpdf
  • None
  • PHPMailer
    • easypeasyics
  • PHPWavUtils
  • Securimage
    • classes

Classes

  • AutoLogin
  • Component
  • ComponentUpdate
  • ConditionParser
  • Database
  • DateTimeExtended
  • Email
  • Folder
  • FormValidation
  • FunctionClass
  • Htaccess
  • HtmlDiv
  • HtmlElement
  • HtmlForm
  • HtmlFormBasic
  • HtmlFormInstallation
  • HtmlList
  • HtmlNavbar
  • HtmlPage
  • HtmlTable
  • HtmlTableBasic
  • Image
  • Inventory
  • InventoryFields
  • Language
  • LanguageData
  • ListConfiguration
  • Menu
  • Message
  • ModuleAnnouncements
  • ModuleDates
  • ModuleLists
  • ModuleMenu
  • ModuleMessages
  • Modules
  • ModuleWeblinks
  • MyFiles
  • Navigation
  • ntlm_sasl_client_class
  • Organization
  • Participants
  • PasswordHash
  • PasswordHashing
  • ProfileFields
  • RoleDependency
  • RolesRights
  • RSSfeed
  • Session
  • SystemMail
  • TableAccess
  • TableAnnouncement
  • TableCategory
  • TableDate
  • TableFile
  • TableFolder
  • TableGuestbook
  • TableGuestbookComment
  • TableInventory
  • TableInventoryField
  • TableLists
  • TableMembers
  • TableMessage
  • TablePhotos
  • TableRoles
  • TableRooms
  • TableText
  • TableUserField
  • TableUsers
  • TableWeblink
  • UploadHandlerDownload
  • UploadHandlerPhoto
  • User
  • UserRegistration

Exceptions

  • AdmException
  • WavFileException
  • WavFormatException

Functions

  • admFuncAutoload
  • admFuncGeneratePagination
  • admFuncGetBytesFromSize
  • admFuncGetDirectoryEntries
  • admFuncMaxUploadSize
  • admFuncProcessableImageSize
  • admFuncShowCreateChangeInfoById
  • admFuncShowCreateChangeInfoByName
  • admFuncVariableIsValid
  • admReadTemplateFile
  • admStrIsValidFileName
  • admStrStripTagsSpecial
  • admStrToLower
  • admStrToUpper
  • bzip2Version
  • checkDatabaseVersion
  • checkPhpVersion
  • EmailAttachment
  • FileSizeNiceDisplay
  • FormattedTimeRemaining
  • FunctionIsDisabled
  • getFormerRolesFromDatabase
  • getFutureRolesFromDatabase
  • getmicrotime
  • getRoleMemberships
  • getRolesFromDatabase
  • gzipVersion
  • hasRole
  • hl_attrval
  • hl_bal
  • hl_cmtcd
  • hl_ent
  • hl_prot
  • hl_regex
  • hl_spec
  • hl_tag
  • hl_tag2
  • hl_tidy
  • hl_version
  • htmLawed
  • HTMLFilter
  • isGroupLeader
  • isMember
  • kses
  • kses_hook
  • MySQLdumpVersion
  • OutputInformation
  • SafeExec
  • showNotice
  • strAddSlashesDeep
  • strNextLetter
  • strStripSlashesDeep
  • strStripTags
  • strValidCharacters
  • tln_body2div
  • tln_casenormalize
  • tln_deent
  • tln_defang
  • tln_findnxreg
  • tln_findnxstr
  • tln_fixatts
  • tln_fixstyle
  • tln_fixurl
  • tln_getnxtag
  • tln_sanitize
  • tln_skipspace
  • tln_tagprint
  • tln_unspace
  • version_compare_replacement
  • version_compare_replacement_sub

Class HtmlTableBasic

HtmlElement
Extended by HtmlTableBasic

Direct known subclasses

HtmlTable

Copyright: 2004-2016 The Admidio Team
License: GNU General Public License v2.0 only **********************************************************************************************
Brief:

Create html tables

This class creates html tables. Create a table object, define the elements with optional attributes and pass your content. Several methods allows you to set table rows, columns, header and footer element. Also you can define an array with column widths. The class provides changing class in table rows of body elements using modulo. You can define the class names and the row number for line change. CSS classes are needed using this option for class change ! This class supports strings, arrays, bi dimensional arrays and associative arrays for creating the table content.


Class: HtmlTableBasic
Code: $dataArray = array('Data 1', 'Data 2', 'Data 3');
Code:

// Example without defining table head and table foot elements. // Starting a row directly, all missing table elements are set automatically for semantic table. // Create an table instance with optional table ID, table class. $table = new HtmlTableBasic('Id_Example_1', 'tableClass'); // For each key => value a column is to be defined in a table row. $table->addRow($dataArray); // get validated table echo $table->getHtmlTable();


Code:

// Create an table instance with optional table ID, table class and border $table = new HtmlTableBasic('Id_Example_2', 'tableClass', 1); // we can also set further attributes for the table $table->addAttribute('style', 'width: 100%;'); $table->addAttribute('summary', 'Example'); // add table header with class attribute and a column as string $table->addTableHeader('class', 'name', 'columntext', 'th'); // $col paremeter 'th' is set by dafault to 'td' // add next row to the header $table->addRow('... some more text ...'); // optional parameters ( $content, $attribute, $value, $col = 'td') // Third row we can also pass single arrays, bidimensional arrays, and assoc. arrays // For each key => value a column is to be defined in a table row $table->addRow($dataArray); // add the table footer $table->addTableFooter('class', 'foot', 'Licensed by Admidio'); // add a body element $table->addTableBody('class', 'body', $dataArray); // also we can set further body elements $table->addTableBody('class', 'nextBody', $dataArray); // in this body elemtent for example, we want to define the cols in a table row programmatically // define a new row $table->addRow(); // no data and no attributes for this row $table->addColumn('col1'); $table->addColumn('col2', array('class' => 'secondColumn')); // this col has a class attribute $table->addColumn('col3'); // also we can pass our Array at the end $table->addColumn($dataArray); // get validated table echo $table->getHtmlTable();


Code:

// Example with fixed columns width and changing classes for rows in body element and table border $table = new HtmlTableBasic('Id_Example_3', 'tableClass', 1); // Set table width to 600px. Ok, we should do this in the class or id in CSS ! However,... $table->addAttribute('style', 'width: 600px;'); // Define columms width as array $table->setColumnsWidth(array('20%', '20%', '60%')); // We also want to have changing class in every 3rd table row in the table body $table->setClassChange('class_1', 'class_2', 3); // Parameters: class names and integer for the line ( Default: 2 ) // Define a table header with class="head" and define a column string (arrays are also possible) // and Set a header element for the column (Default: 'td') $table->addTableHeader('class', 'head', 'Headline_1', 'th'); // 2 more columns ... $table->addColumn('Headline_2', null, 'th'); // no attribute/value in this example $table->addColumn('Headline_3', null, 'th'); // no attribute/value in this example // Define the footer with a string in center position $table->addTableFooter(); // First mention that we do not want to have fixed columns in the footer. So we clear the array and set the text to center positon! $table->setColumnsWidth(array()); // Define a new table row $table->addRow(); // Add the column with colspan attribute $table->addColumn('', array('colspan' => '3')); // no data here, because first do the settings and after finishend pass the content ! // Define center position for the text $table->addAttribute('align', 'center'); // ok, it is worse style! // Now we can set the data if all settings are done! $table->addData('Tablefooter'); // Now set the body element of the table // Remember we deleted the columns width array, so we need to set it again $table->setColumnsWidth(array('20%', '20%', '60%')); // Define a table row with array or string for first column $table->addTableBody('class', 'body', $dataArray); // Some more rows with changeclass mode in body element $table->addRow($dataArray); $table->addRow($dataArray); $table->addRow($dataArray); $table->addRow($dataArray); echo $table->getHtmlTable();


Endcode
Endcode
Endcode
Endcode
Par:

Notice Tables should be styled by CSS ! Attributes, like 'align', 'bgcolor',... are worse style, and deprecated in HTML5. Please check the reference.


Par: Data array for example
Par: Example_1
Par: Example_2
Par: Example 3
Located at htmltablebasic.php

Methods summary

public
# __construct( string $id = null, string $class = null, integer $border = 0 )

Constructor initializing all class variables

Constructor initializing all class variables

Parameters

$id
Id of the table
$class
Class name of the table
$border
Set the table border width

Overrides

HtmlElement::__construct
public
# addColumn( string|array $data = '', array $arrAttributes = null, string $col = 'td' )

Add Columns to current table row. This method defines the columns for the current table row. The data can be passed as string or array. Using Arrays, for each key/value a new column is set. You can define an attribute for each column. If you need further attributes for the column first do the settings with addAttribute(); If all settings are done for the column use the addData(); to define your column content.

Add Columns to current table row. This method defines the columns for the current table row. The data can be passed as string or array. Using Arrays, for each key/value a new column is set. You can define an attribute for each column. If you need further attributes for the column first do the settings with addAttribute(); If all settings are done for the column use the addData(); to define your column content.

Parameters

$data
Content for the column as string, or array
$arrAttributes
Further attributes as array with key/value pairs
$col
Column element 'td' or 'th' (Default: 'td')
private
# addColumnsData( string|array $data = '', string $col = 'td' )

Parameters

$data
Content for the table row as string, or array
$col
Column element 'td' or 'th' (Default: 'td')
public
# addRow( string|array $data = '', array $arrAttributes = null, string $col = 'td' )

Add new table row. Starting the table directly with a row, the class automatically defines 'thead' and 'tfoot' element with an empty row. The method checks if a row is already defined and must be closed first. You can define 1 attribute/value pair for the row, calling the method. If you need further attributes for the new row, use method addAttribute(), before passing the content. The element and attributes are stored in buffer first and will be parsed and written in the output string if the content is defined. After all settings are done use addColumn(); to define your columns with content.

Add new table row. Starting the table directly with a row, the class automatically defines 'thead' and 'tfoot' element with an empty row. The method checks if a row is already defined and must be closed first. You can define 1 attribute/value pair for the row, calling the method. If you need further attributes for the new row, use method addAttribute(), before passing the content. The element and attributes are stored in buffer first and will be parsed and written in the output string if the content is defined. After all settings are done use addColumn(); to define your columns with content.

Parameters

$data
Content for the table row as string, or array
$arrAttributes
Further attributes as array with key/value pairs
$col
Column element 'td' or 'th' (Default: 'td')
private
# addTableSection( string $element, string $attribute = null, string $value = null, string|array $data = '', string $col = 'td' )

Parameters

$element
Element (thead, tbody, tfoot)
$attribute
Attribute
$value
Value of the attribute
$data
Content for the element as string, or array
$col
public
# addTableBody( string $attribute = null, string $value = null, string|array $data = '', string $col = 'td' )

Define table body. Please have a look at the description addRow(); and addColumn(); how you can define further attribute settings

Define table body. Please have a look at the description addRow(); and addColumn(); how you can define further attribute settings

Parameters

$attribute
Attribute
$value
Value of the attribute
$data
Content for the element as string, or array
$col
public boolean
# addTableFooter( string $attribute = null, string $value = null, string|array $data = '', string $col = 'td' )

Parameters

$attribute
Attribute
$value
Value of the attribute
$data
Content for the element as string, or array
$col

Returns

boolean
Returns @b false if tfoot element is already set

Par

Define table footer Please have a look at the description addRow(); and addColumn(); how you can define further attribute settings


public boolean
# addTableHeader( string $attribute = null, string $value = null, string|array $data = '', string $col = 'td' )

Define table header Please have a look at the description addRow(); and addColumn(); how you can define further attribute settings

Define table header Please have a look at the description addRow(); and addColumn(); how you can define further attribute settings

Parameters

$attribute
Attribute
$value
Value of the attribute
$data
Content for the element as string, or array
$col

Returns

boolean
Returns @b false if thead element is already set
public string
# getHtmlTable( )

Get the parsed html table

Get the parsed html table

Returns

string
Returns the validated html table as string
public
# setRowClasses( array $rowClasses )

Parameters

$rowClasses
Name of the standard class used for lineChange mode

Par

Set line Change mode In body elements you can use this option. You have to define class names.


public
# setColumnsWidth( array $array )

Set a specific width for all columns of the table. This is useful if the automatically that will be set by the browser doesn't fit your needs.

Set a specific width for all columns of the table. This is useful if the automatically that will be set by the browser doesn't fit your needs.

Parameters

$array
Array with all width values of each column. Here you can set all valid CSS values e.g. '100%' or '300px'
public
# setColumnWidth( integer $column, string $width )

Set a specific width for one column of the table. This is useful if you have one column that will not get a useful width automatically by the browser.

Set a specific width for one column of the table. This is useful if you have one column that will not get a useful width automatically by the browser.

Parameters

$column
The column number where you want to set the width. The columns of the table starts with 1 (not 0).
$width
The new width of the column. Here you can set all valid CSS values e.g. '100%' or '300px'

Methods inherited from HtmlElement

addAttribute(), addData(), addElement(), addHtml(), addParentElement(), closeParentElement(), getHtmlElement(), setAttributesFromArray()

Properties summary

protected $border
#
protected $rowClasses
#
protected $columnsWidth
#
protected $thead
#
protected $tfoot
#
protected $tbody
#
protected $columnCount
#
protected $rowCount
#

Properties inherited from HtmlElement

$arrParentElements, $currentElement, $currentElementAttributes, $currentElementDataWritten, $htmlString, $mainElement, $mainElementAttributes, $mainElementWritten, $nesting, $parentFlag

Admidio API API documentation generated by ApiGen