Properties

$_jshead

$_jshead : array

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

Type

array

$_jsfiles

$_jsfiles : array

Array with all JavaScript file inclusions.

Type

array

$_prepend_jshead

$_prepend_jshead : array

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

Type

array

$_jquery_enabled

$_jquery_enabled : boolean

Boolean showing if jQuery is enabled

Type

boolean

$_jquery_init_scripts

$_jquery_init_scripts : 

Type

$_jquery_states

$_jquery_states : array

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

Type

array

$_linkhrefs

$_linkhrefs : Array

Array with all linked URLs for HEAD.

Type

Array

$_jsonload

$_jsonload : Array

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

Type

Array

$_meta_head

$_meta_head : string

string with all metatags to go into the page head.

Type

string

$_object_head

$_object_head : string

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

Type

string

$_style_head

$_style_head : string

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

Type

string

$_link_head

$_link_head : array

Array with all link elements to be included in a page's head.

Type

array

Methods

set_pagetitle()

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

The title to set.

add_jsfile()

add_jsfile(string  $url, boolean  $prepend = false) 

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.

Parameters

string $url

The URL to the file to-be referenced.

boolean $prepend

Whether to add the JS include to beginning of includes

add_jscript()

add_jscript(string  $script,   $defer = '',   $prepend = false) 

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.

Parameters

string $script

The code to be included directly in the page.

$defer
$prepend

add_jquery_state_script()

add_jquery_state_script(string  $script, string  $state = 'document.ready') 

Register JavaScript snippets to jQuery states.

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

Parameters

string $script

The code to be included in the state.

string $state

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

add_object_head()

add_object_head(string  $script, array  $attributes = null) 

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.

Parameters

string $script

The input between the tags.

array $attributes

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

add_meta_head()

add_meta_head(array  $attributes = null) 

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

array $attributes

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

add_style_head()

add_style_head(string  $script, array  $attributes = null) 

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.

Parameters

string $script

The input between the tags.

array $attributes

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

add_link_head()

add_link_head(array  $attributes) 

Register a link element to be placed in the page head.

This allows components to register extra CSS links. Example to use this to include a CSS link: $attributes = array ('rel' => 'stylesheet', 'type' => 'text/css', 'href' => '/style.css' ); midcom::get()->head->add_link_head($attributes);

Each URL will only be added once. When trying to add the same URL a second time, it will be moved to the end of the stack, so that CSS overrides behave as the developer intended

Parameters

array $attributes

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

add_stylesheet()

add_stylesheet(string  $url, string  $media = false) 

Convenience shortcut for adding CSS files

Parameters

string $url

The stylesheet URL

string $media

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

add_jsonload()

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.

Parameters

string $method

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

print_jsonload()

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:

head->print_jsonload();?>>

print_head_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

get_jshead_elements()

get_jshead_elements() 

get_link_head()

get_link_head() 

enable_jquery()

enable_jquery(  $version = null) 

Init jQuery

This method adds jQuery support to the page

Parameters

$version

print_jquery_statuses()

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.

enable_jquery_ui()

enable_jquery_ui(array  $components = array()) 

Add jquery ui components

core and widget are loaded automatically. Also loads jquery.ui theme, either the configured theme one or a hardcoded default (base theme)

Parameters

array $components

The components that should be loaded

_get_attribute_string()

_get_attribute_string(  $attributes) 

Parameters

$attributes

_print_js()

_print_js(array  $js_call) 

Parameters

array $js_call