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 HtmlElement

Direct known subclasses

HtmlDiv, HtmlFormBasic, HtmlList, HtmlTableBasic

Indirect known subclasses

HtmlForm, HtmlFormInstallation, HtmlTable

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

This @b abstract @b class parses html elements

This abstract class is designed to parse html elements. It is only allowed to use extensions of this class. Create a html object and add your elements programmatically . Calling as parent instance just define the element you need and add all inline elements or child elements. Also it is possible to define attributes and value for each added element. Content data can be passed as string or as array. The class supports also reading the data from assoc arrays and bi dimensional arrays.


Class: HtmlElement
Code:

// Example content arrays $dataArray = array('Data 1', 'Data 2', 'Data 3');


Code:

// create as parent instance parent::HtmlElement('ul','class', 'unordered'); // Parameters( element, attribute, value, nesting (true/false )) // we want to have further attributes for the element and set an id, for example HtmlElement::addAttribute('id','mainelement'); // set a list element with content as string HtmlElement::addElement('li', 'list 1'); // if you need attributes for your setted element then first define the element, set the attributes and after that // pass the content. // Example: Arrays are also supported for content values. HtmlElement::addElement('li'); HtmlElement::addAttribute('class', 'from array'); HtmlElement::addData($dataArray); // As result you get 3

  • elements with same class and content from the array // Next example defines a list element with data list, data terms and data descriptions. Therefor we use method addParentElement(); // This method logs the selected elements because the endtags must be set later. HtmlElement::addParentElement('li'); HtmlElement::addAttribute('class', 'link_1'); HtmlElement::addParentElement('dl'); HtmlElement::addAttribute('class', 'datalist_1'); // now the elements with start and endtags HtmlElement::addElement('dt', 'term'); HtmlElement::addElement('dd', 'description'); // finally set the endtags for all opened parent elements HtmlElement::closeParentElement('dl'); HtmlElement::closeParentElement('li'); // Repeat with next list elements HtmlElement::addParentElement('li'); HtmlElement::addParentElement('dl'); HtmlElement::addElement('dt', 'term2'); HtmlElement::addElement('dd', 'description2'); HtmlElement::closeParentElement('dl'); HtmlElement::closeParentElement('li'); $htmlList = HtmlElement::getHtmlElement(); echo $htmlList;


    Code:

    // Creating block elements with nested divs. // Example using nesting mode for html elements // Setting mode to true you are allowed to set the main element ('div' in this example) further times // Default false it is not possible to set the main element again

    parent::HtmlElement ('div', 'class', 'pagewrap', true); // now we can nest a second div element with a paragaph. // Because of div is the parent of the paragraph element, we must tell the class using method addParentElement(); HtmlElement::addParentElement('div'); // We want to set an Id for the div element, for example HtmlElement::addAttribute('id', 'Paragraphs', 'div'); // Define a paragrph HtmlElement::addElement('p', 'Hello World'); // Nested div element must be closed ! HtmlElement::closeParentElement('div'); // Get the block element $htmlBlock = HtmlElement::getHtmlElement(); echo $htmlBlock;


    Code:

    parent::HtmlElement(); HtmlElement::addElement('a'); HtmlElement::addAttribute('href', 'http://www.admidio.org'); HtmlElement::addData('Admidio Homepage'); $hyperlink = HtmlElement::getHtmlElement(); echo $hyperlink;


    Code:

    // Create a form element parent::HtmlElement('form', 'name', 'testform'); HtmlElement::addAttribute('action', 'test.php'); HtmlElement::addAttribute('method', 'post'); HtmlElement::addAttribute('enctype', 'text/html'); // add an input field with label HtmlElement::addElement('input'); HtmlElement::addAttribute('type', 'text'); HtmlElement::addAttribute('name', 'input'); HtmlElement::addHtml('Inputfield:'); // pass a whitespace because element has no content HtmlElement::addData(' ', true); // true for self closing element (default: false) // add a checkbox HtmlElement::addElement('input'); HtmlElement::addAttribute('type', 'checkbox'); HtmlElement::addAttribute('name', 'checkbox'); HtmlElement::addHtml('Checkbox:'); // pass a whitespace because element has no content HtmlElement::addData(' ', true); // true for self closing element (default: false) // add a submit button HtmlElement::addElement('input'); HtmlElement::addAttribute('type', 'submit'); HtmlElement::addAttribute('value', 'submit'); // pass a whitespace because element has no content HtmlElement::addData(' ', true);

    echo HtmlElement::getHtmlElement();


    Endcode
    Endcode
    Endcode
    Endcode
    Endcode
    Par: Testarray with data
    Par: Example_1: @b unorderedlist
    Par: Example_2 Nested Div Elements using nesting mode
    Par: Example_3 Hyperlinks
    Par: Example_4 Form element
    Located at htmlelement.php
  • Methods summary

    public
    # __construct( string $element, boolean $nesting = false )

    Constructor initializing all class variables

    Constructor initializing all class variables

    Parameters

    $element
    The html element to be defined
    $nesting
    Enables nesting of main elements ( Default: False )
    public
    # addAttribute( string $attrKey, string $attrValue, string $element = null )

    Add attributes to the selected element. If that attribute is already added than the new value will be attached to the current value.

    Add attributes to the selected element. If that attribute is already added than the new value will be attached to the current value.

    Parameters

    $attrKey
    Name of the html attribute
    $attrValue
    Value of the attribute
    $element

    Optional the element for which the attribute should be set, if this is not the current element

    protected
    # setAttributesFromArray( array $arrAttributes )

    Set attributes from associative array.

    Set attributes from associative array.

    Parameters

    $arrAttributes

    An array that contains all attribute names as array key and all attribute content as array value

    public
    # addData( string|string[] $data, boolean $selfClosing = false )

    Add data to current element

    Add data to current element

    Parameters

    $data
    Content for the element as string, or array
    $selfClosing
    Element has self closing tag ( default: false)
    public
    # addElement( string $childElement, string $attrKey = '', string $attrValue = '', string $data = '', boolean $selfClosing = false )

    Parameters

    $childElement
    valid child tags for element object
    $attrKey
    Attribute name
    $attrValue
    Value for the attribute
    $data
    content values can be passed as string, array, bidimensional Array and assoc. Array. ( Default: no data )
    $selfClosing
    Element has self closing tag ( default: false)

    Par

    Add new child element. This method defines the next child element to be written in the output string. If a parent element was defined before, the syntax with all setted attributes is written first from internal buffer to the string. After that, the new element is defined. The method determines that the element has @b no @b own @b child @b elements and has a closing tag. If you need a parent element like a \<div> with some \<p> elements, use method addParentElement(); instead and then add the paragraph elements. If nesting mode is active you are allowed to set the main element called with object instance again. Dafault: false


    public
    # addHtml( string $string = '' )

    Add any string to the html output. If the main element wasn't written to the html string than this will be done before your string will be added.

    Add any string to the html output. If the main element wasn't written to the html string than this will be done before your string will be added.

    Parameters

    $string
    Text as string in current string position
    public
    # addParentElement( string $parentElement, string $attrKey = '', string $attrValue = '' )

    Parameters

    $parentElement
    Parent element to be set
    $attrKey
    Attribute name
    $attrValue
    Value for the attribute

    Par

    Add a parent element that has own child's. This method is needed if an element can have several child elements and the closing tag must be set after own child elements. It logs the setted element in an array. Each time you define a new parent element, the function checks the log array, if the element already was set. If the current element already was defined, then the function determines that the still opened tag must be closed first until it can be set again. The method closeParentElement(); is called automatically to close the previous element. By default it is not allowed to define several elements from same type. If needed use option @b nesting @b mode @b true!


    public boolean
    # closeParentElement( string $parentElement )

    Parameters

    $parentElement
    Parent element to be closed

    Returns

    boolean

    Par

    Close parent element. This method sets the endtag of the selected element and removes the entry from log array. If nesting mode is not used, the methods looks for the entry in the array and determines that all setted elements after the selected element must be closed as well. All end tags to position are closed automatically starting with last setted element tag.


    private string
    # getElementAttributesString( array $elementAttributes )

    Create a valid html compatible string with all attributes and their values of the given element.

    Create a valid html compatible string with all attributes and their values of the given element.

    Parameters

    $elementAttributes

    Returns

    string
    Returns a string with all attributes and values.
    private string
    # getCurrentElementAttributesString( )

    Create a valid html compatible string with all attributes and their values of the last added element.

    Create a valid html compatible string with all attributes and their values of the last added element.

    Returns

    string
    Returns a string with all attributes and values.
    private string
    # getMainElementAttributesString( )

    Create a valid html compatible string with all attributes and their values of the main element.

    Create a valid html compatible string with all attributes and their values of the main element.

    Returns

    string
    Returns a string with all attributes and values.
    public string
    # getHtmlElement( )

    Return the element as string

    Return the element as string

    Returns

    string
    Returns the parsed html as string

    Properties summary

    protected $nesting
    #
    protected $mainElement
    #
    protected $mainElementAttributes
    #
    protected $mainElementWritten
    #
    protected $currentElement
    #
    protected $currentElementAttributes
    #
    protected $currentElementDataWritten
    #
    protected $htmlString
    #
    protected $parentFlag
    #
    protected $arrParentElements
    #
    Admidio API API documentation generated by ApiGen