Helper functions for managing HTML head

package midcom.helper

 Methods

add_jquery_state_script (string $script, string $state)

Register JavaScript snippets to jQuery states.

This allows components to register JavaScript code to the jQuery states. Possible ready states: document.ready

see \print_jquery_statuses()

Parameters

$script

stringThe code to be included in the state.

$state

stringThe state where to include the code to. Defaults to document.ready

add_jquery_ui_theme (array $components)

Loads jquery.ui theme file(s).

This will either add the configured theme file or load individual component files from the default theme

Parameters

$components

arrayThe components that should be loaded

add_jscript (string $script, $defer, $prepend)

Register JavaScript Code for output directly in the page.

This allows components to register JavaScript code during page processing. The site style can then query this queued-up code at anytime it likes. The queue-up SHOULD be done during the code-init phase, while the print_head_elements output SHOULD be included in the HTML HEAD area and the HTTP onload attribute returned by print_jsonload SHOULD be included in the BODY-tag. Note, that these suggestions are not enforced

The sequence of the add_jsfile and add_jscript commands is kept stable.

see \add_jsfile()
see \add_jsonload()
see \print_head_elements()
see \print_jsonload()

Parameters

$script

stringThe code to be included directly in the page.

$defer

$prepend

add_jsfile (string $url, boolean $prepend)

Register JavaScript File for referring in the page.

This allows MidCOM components to register JavaScript code during page processing. The site style code can then query this queued-up code at anytime it likes. The queue-up SHOULD be done during the code-init phase, while the print_head_elements output SHOULD be included in the HTML HEAD area and the HTTP onload attribute returned by print_jsonload SHOULD be included in the BODY-tag. Note, that these suggestions are not enforced, if you want a JScript clean site, just omit the print calls and you should be fine in almost all cases.

The sequence of the add_jsfile and add_jscript commands is kept stable.

see \add_jscript()
see \add_jsonload()
see \print_head_elements()
see \print_jsonload()

Parameters

$url

stringThe URL to the file to-be referenced.

$prepend

booleanWhether to add the JS include to beginning of includes

add_jsonload (string $method)

Register a JavaScript method for the body onload event

This allows components to register JavaScript code during page processing. The site style can then query this queued-up code at anytime it likes. The queue-up SHOULD be done during the code-init phase, while the print_head_elements output SHOULD be included in the HTML HEAD area and the HTTP onload attribute returned by print_jsonload SHOULD be included in the BODY-tag. Note that these suggestions are not enforced.

see \add_jsfile()
see \add_jscript()
see \print_head_elements()
see \print_jsonload()

Parameters

$method

stringThe name of the method to be called on page startup, including parameters but excluding the ';'.

add_meta_head (array $attributes)

Register a metatag to be added to the head element.

This allows components to register metatags to be placed in the head section of the page.

Parameters

$attributes

arrayArray of attribute => value pairs to be placed in the tag. @see print_head_elements()

add_object_head (string $script, array $attributes)

Register some object tags to be added to the head element.

This allows components to register object tags to be placed in the head section of the page.

see \print_head_elements()

Parameters

$script

stringThe input between the tags.

$attributes

arrayArray of attribute=> value pairs to be placed in the tag.

add_style_head (string $script, array $attributes)

Register a styleblock / style link to be added to the head element.

This allows components to register extra CSS sheets they wants to include. in the head section of the page.

see \print_head_elements()

Parameters

$script

stringThe input between the tags.

$attributes

arrayArray of attribute=> value pairs to be placed in the tag.

add_stylesheet (string $url, string $media)

Convenience shortcut for adding CSS files

Parameters

$url

stringThe stylesheet URL

$media

stringThe media type(s) for the stylesheet, if any

enable_jquery ($version)

Init jQuery

This method adds jQuery support to the page

Parameters

$version

get_jshead_elements ()

print_head_elements ()

Echo the _head elements added.

This function echos the elements added by the add_(style|meta|link|object)_head methods.

Place the method within the section of your page.

This allows components to register HEAD elements during page processing. The site style can then query this queued-up code at anytime it likes. The queue-up SHOULD be done during the code-init phase, while the print_head_elements output SHOULD be included in the HTML HEAD area and the HTTP onload attribute returned by print_jsonload SHOULD be included in the BODY tag. Note that these suggestions are not enforced

see \add_link_head
see \add_object_head
see \add_style_head
see \add_meta_head
see \add_jsfile()
see \add_jscript()

print_jquery_statuses ()

Echo the jquery statuses

This function echos the scripts added by the add_jquery_state_script method.

This method is called from print_head_elements method.

see \add_jquery_state_script
see \print_head_elements

print_jsonload ()

Echo the registered javascript code.

This allows components to register JavaScript code during page processing. The site style code can then query this queued-up code at anytime it likes. The queue-up SHOULD be done during the code-init phase, while the print_head_elements output SHOULD be included in the HTML HEAD area and the HTTP onload attribute returned by print_jsonload SHOULD be included in the BODY-tag. Note, that these suggestions are not enforced

The sequence of the add_jsfile and add_jscript commands is kept stable.

This is usually called during the BODY region of your style:


    print_jsonload();?>>
           
    

see \add_jsfile()
see \add_jscript()
see \add_jsonload()
see \print_head_elements()

set_pagetitle (string $string)

Sets the page title for the current context.

This can be retrieved by accessing the component context key MIDCOM_CONTEXT_PAGETITLE.

Parameters

$string

stringThe title to set.

_get_attribute_string ($attributes)

Parameters

$attributes

_print_js (array $js_call)

Parameters

$js_call

 Properties

 

boolean $_jquery_enabled

Boolean showing if jQuery is enabled
 

mixed $_jquery_init_scripts

 

array $_jquery_states

Array with all JQuery state scripts for the page's head.
 

array $_jsfiles

Array with all JavaScript file inclusions.
 

array $_jshead

Array with all JavaScript declarations for the page's head.
 

Array $_jsonload

Array with all methods for the BODY's onload event.
   

Array $_linkhrefs

Array with all linked URLs for HEAD.
 

string $_meta_head

string with all metatags to go into the page head.
 

string $_object_head

string with all object tags to go into a page's head.
 

array $_prepend_jshead

Array with all prepend JavaScript declarations for the page's head.
 

string $_style_head

String with all css styles to go into a page's head.