Class Theme

Description

Methods to access properties of a theme

Located in /program/lib/theme.class.php (line 34)


	
			
Direct descendents
Class Description
 class ThemeSchoolyard this class implements the schoolyard theme (based on a design by David Prousch)
 class ThemeFrugal /program/themes/frugal/frugal.class.php - the class that comprises the most minimal theme
 class ThemeRosalina this class implements the rosalina theme (based on HV Menu
Variable Summary
Method Summary
 void Theme (array $theme_record, int $area_id, int $node_id)
 void add_content (string|array $content)
 void add_html_header (string $headerline)
 void add_http_header (string $headerline)
 void add_message (string|array $message)
 void add_meta (array $meta)
 void add_meta_http_equiv (array $meta)
 void add_popup_bottom (string|array $message)
 void add_popup_top (string|array $message)
 void add_stylesheet (string $url)
 array calc_breadcrumb_trail (int $node_id)
 array construct_tree (int $area_id)
 void dump_subtree (int $node_id,  &$tree, array &$tree))
 string get_address ([string $m = ''])
 string get_bottomline ([string $m = ''])
 string get_content ([string $m = ''])
 string get_div_breadcrumbs ([string $m = ''])
 string get_div_messages ([string $m = ''], [string $div_id = 'messages'])
 string get_html ()
 string get_html_head ([string $m = ''])
 string get_jumpmenu ([string $m = ''])
 string get_lines (array $lines, [string $m = ''])
 string get_logo ([string $m = ''])
 string get_menu ([string $m = ''], [int $menu_id = NULL])
 string get_navigation ([string $m = ''], [bool $textonly = FALSE])
 string get_popups (array $messages, [string $m = ''])
 bool|array get_properties (int $theme_id, int $area_id)
 string get_quickbottom ([string $m = ''])
 string get_quicklinks (string $m, string $quick_section_parameter, [string $separator = ''])
 string get_quicktop ([string $m = ''])
 string node2anchor (array $node_record, [array $attributes = NULL], [bool $textonly = FALSE])
 void send_headers ()
 void send_output ()
 void set_preview_mode (bool $is_preview_mode)
 string show_tree_walk ([string $m = ''], int $subtree_id)
Variables
int $area_id = NULL (line 42)
  • var: $area_id the area to display
a $area_record = NULL (line 45)
  • var: copy of the area record from the areas table
array $breadcrumb_addendum = array() (line 90)
  • var: $breadcrumb_addendum holds an array with additional anchors that can be set by the page's module
string $breadcrumb_separator = - (line 105)
  • var: $breadcrumb_separator contains the delimiter between breadcrumbs in the breadcrumb trail
array $config (line 57)
  • var: $config all properties from themes_areas_properties for this combination of theme and area
array $content = array() (line 72)
  • var: collection of items/lines that are part of the content area
string $domain (line 93)
  • var: $domain the language domain where we get our translations from, usually 't_<themename>'
string $dtd = <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> (line 60)
  • var: the standard doctype (default: HTML 4.01 Transitional)
bool $high_visibility = FALSE (line 84)
  • var: this switches the navigation between image-based and text-based
array $html_head = array() (line 69)
  • var: collection of items/lines that will be output as part of the HTML-head section
array $http_headers = array() (line 66)
  • var: collection of individual httP-headers that are to be sent _before_ any HTML is sent
array $jumps = array() (line 96)
  • var: $jumps holds an area_id => area_title pair for every area this user can access
array $messages_bottom = array() (line 81)
  • var: collection of messages that are to be displayed via a javascript alert() at END of page
array $messages_inline = array() (line 78)
  • var: collection of messages that are to be displayed inline, contained within the HTML body
array $messages_top = array() (line 75)
  • var: collection of messages that are to be displayed via a javascript alert() at START of page
int $node_id = NULL (line 48)
  • var: $node_id the node (page) to display
a $node_record = NULL (line 51)
  • var: convenient copy of the node record copied from the area tree
bool $preview_mode = FALSE (line 87)
  • var: $preview_mode if TRUE, we are previewing a page (from pagemanager)
string $quickbottom_separator (line 102)
  • var: $quicktop_separator contains the delimiter between quicklinks at the bottom of the page
string $quicktop_separator (line 99)
  • var: $quicktop_separator contains the delimiter between quicklinks at the top of the page
int $theme_id = NULL (line 39)
  • var: $theme_id primary key of the theme
a $theme_record = NULL (line 36)
  • var: copy of the corresponding record from the themes table
string $title (line 63)
  • var: the title to display in both the title tag and in the page itself (usually the areaname)
array $tree = FALSE (line 54)
  • var: $tree all nodes in area $area_id, keyed by $node_id (see tree_build()).
Methods
Constructor Theme (line 123)

construct a Theme object

this stores the information about this theme from the database. Also, we construct/read the tree of nodes for this area $area_id. This information will be used lateron when constructing the navigation. The node to display is $node_id.

Also, we prepare a list of areas where the current user is allowed to go. This is handy when constructing a jumpmenu and doing it here saves a trip to the database lateron in get_jumpmenu().

void Theme (array $theme_record, int $area_id, int $node_id)
  • array $theme_record: the record straight from the database
  • int $area_id: the area of interest
  • int $node_id: the node that will be displayed
add_content (line 950)

add a line or array of lines to the content part of the document

  • return: and content added to buffer
void add_content (string|array $content)
  • string|array $content: the line(s) of text to add
add_html_header (line 858)

add a header to the HTML head part of the document

void add_html_header (string $headerline)
  • string $headerline: headerline to add
add_http_header (line 848)

add an HTTP-header

void add_http_header (string $headerline)
  • string $headerline: headerline to add
add_message (line 896)

add a message to the list of inline messages, part of the BODY of the document

void add_message (string|array $message)
  • string|array $message: message(s) to add inline
add_meta (line 926)

add a line with meta-information to the HTML head part of the document

  • return: and meta data added to headers
void add_meta (array $meta)
  • array $meta: an array with name-value-pairs that should be added to the HTML head part
add_meta_http_equiv (line 938)

add a line with http-equiv meta-information to the HTML head part of the document

void add_meta_http_equiv (array $meta)
  • array $meta: an array with name-value-pairs that should be added to the HTML head part
add_popup_bottom (line 882)

add a message to the list of popup-messages at the BOTTOM of the document

void add_popup_bottom (string|array $message)
  • string|array $message: message(s) to add
add_popup_top (line 868)

add a message to the list of popup-messages at the TOP of the document

void add_popup_top (string|array $message)
  • string|array $message: message(s) to add
add_stylesheet (line 915)

add a link to a stylesheet to the HTML head part of the document

this adds a link to a stylesheet file to the HTML head part of the document. Note that we qualify the path to prevent problems with incorrect assumptions about relative URLs, see was_url().

  • return: and url added to list of headers
  • uses: was_url()
void add_stylesheet (string $url)
  • string $url: absolute or relative url of the stylesheet (see above)
calc_breadcrumb_trail (line 1020)

set breadcrumbs in tree AND construct list of clickable anchors

Note: the anchors are created with the current setting of the preview mode, so if that changes after we construct a list of anchors we're in trouble. I prefer late binding, so the real list to use should be created in the phase where the HTML-code is constructed. Mmmmm...

  • return: an array with anchors to be used as a clickable path to node $node_id
  • todo: split into two separate routines, one to set the tree, another to construct the list of anchors
array calc_breadcrumb_trail (int $node_id)
  • int $node_id: the node for which to calculate/set the path to the root node
construct_tree (line 998)

read all nodes from table for this area and construct a tree

this constructs the tree for this area, and makes sure that only non-hidden pages and non-empty sections are visible

  • return: an array with the node-records linked as a tree
array construct_tree (int $area_id)
  • int $area_id: the tree is built from nodes within this area
dump_subtree (line 1116)

a helper-routine during development/debugging (currently unused)

  • return: but a dump of the tree in readable form sent to stdout
void dump_subtree (int $node_id,  &$tree, array &$tree))
  • int $node_id: start of the subtree
  • array &$tree): pointer to a tree that was built earlier
  • &$tree
get_address (line 824)

return the reconstructed URL in a single (indented) line

This constructs the exact URL (including the GET-parameters) of the current script. This URL is returned as HTML so it can be displyed. It is NOT meant to be a clickable link, but as a documentation of the actual URL that was used. Note that this URL can be suppressed by an appropriate 'display:none' in the stylesheet, making it an item that only appears on a hardcopy (media="print") and not on screen.

If somehow the input is invalid UTF-8, we replace the offending strings witht the unicode substitution character U+FFFD in UTF-8 encode form (ie. the three character string 0xEF 0xBF 0xBD).

  • return: reconstructed URL as text
string get_address ([string $m = ''])
  • string $m: left margin for increased readability
get_bottomline (line 792)

show 'powered by' and (maybe) report basic performance indicators

This calculates the execution time of the script and the number of queries. Note a special trick: we retrieve the translated string in a dummy variable before calculating the number of queries because otherwise we might miss one or more query from the language/translation subsystem.

Note: for the time being the performance report commented out (2010-12-08). Update: as from 2011-05-20 the performance report only displayed while debug is on,

  • return: performance report
string get_bottomline ([string $m = ''])
  • string $m: left margin for increased readability
get_content (line 375)

get all lines in the content DIV in a single properly indented string

  • return: generated HTML-code
string get_content ([string $m = ''])
  • string $m: left margin for increased readability
get_div_breadcrumbs (line 470)

construct breadcrumb trail

this constructs a breadcrumb trail with clickable links. The crumbs are separated by this->breadcrumb_separator (default '-'). Note that if there is actually a non-empty separator, we append a space for readability.

  • return: ready to use HTML with 1 or more clickable bread crumbs
string get_div_breadcrumbs ([string $m = ''])
  • string $m: left margin for increased readability
get_div_messages (line 411)

get a perhaps bulleted list of messages in a DIV

This constructs an unordered list with messages, if there are any If there is no message at all, an empty string is returned (without DIV). If there is a single message, no bullet is added to the message. If there are two or more messages, bullets are added.

Note that this routine is an exception with respect to the DIV-tags: this helper routine DOES generate its own DIVs whenever there is at least 1 message. This means that there is no DIV at all when there are no messages.

  • return: constructed HTML with message(s) or empty string if no messages
string get_div_messages ([string $m = ''], [string $div_id = 'messages'])
  • string $m: left margin for increased readability
  • string $div_id: contains id of the generated div
get_html (line 244)

construct an output page in HTML

This constructs a full HTML-page, starting at the DTD and ending with the html closing tag.

The page is constructed using nested DIVs, the layout is taken care of in a separate style sheet. All knowledge about the structure of the page is contained in this routine.

The performance of the script (# of queries, execution time) is calculated as late as possible, to catch as much as we can. Therefore the construction is done in two parts and performance is calculated last.

The contents of the various DIVs is constructed in various helper routines in order to make this routine easy to read (by humans that is). The various helper routines all are called with a string of space characters; this should improve the the readability of the page that is generated eventually.

Note that the routine $this->get_div_messages() does in fact generate its own DIV tags. This is done in order to completely get rid of the message DIV, we do not even want to see an empty DIV if there are no messages.

The same logic applies to the breadcrumb trail.

  • return: complete HTML-page, ready for output
string get_html ()

Redefined in descendants as:
get_html_head (line 314)

get all lines in the HTML head section in a single, properly indented string

  • return: generated HTML-code
  • todo: also deal with Bazaar Style Style Sheets at node level in this routine (requires new field 'nodes.style')
string get_html_head ([string $m = ''])
  • string $m: left margin for increased readability
get_jumpmenu (line 746)

construct a simple jumplist to navigate to other areas

this constructs a listbox with areas to which the current user has access. The user can pick an area from the list and press the [Go] button to navigate to that area. Only the active areas are displayed. Private areas are only displayed when the user actually has access to those areas.

This routine always shows the Submit-button even when JavaScript is turned 'off'. If it is 'on', a tiny snippet auto-submits the form whenever the user selects another area; no need press any button anymore. However, pressing the Go button is necessary when Javascript is 'off'. Rationale: the user will find out soon enough that pressing the button is superfluous, and as a benefit we keep the same look and feel no matter the state of Javascript.

We rely on the constructor to provide us with an array of area_id=>area_title pairs in the $this->jumps array.

The special preview-mode is implemented by adding the necessary hash in the preview parameter via a hidden field. This will ultimately lead to ourselves, with the preview code so we can never leave for another area in preview mode.

  • return: properly indented ready-to-use HTML or an empty string on error
  • uses: dialog_get_widget()
string get_jumpmenu ([string $m = ''])
  • string $m: add readabiliy to output
get_lines (line 389)

get lines from an array in a single properly indented string

This is a workhorse to convert an array of lines to a properly indented block of text.

  • return: properly indented block of text
string get_lines (array $lines, [string $m = ''])
  • array $lines: contains the lines to convert to a properly indented string
  • string $m: left margin for increased readability
get_logo (line 505)

construct an image tag with the area logo

This constructs HTML-code that displays the logo.

  • return: constructed image tag
  • todo: should we take path_info into account here too???? how about /area/aaa/node/nnn instead of /aaa/nnn???
string get_logo ([string $m = ''])
  • string $m: left margin for increased readability

Redefined in descendants as:
get_menu (line 645)

construct the submenu starting at $menu_id OR the first breadcrumb in the top level menu

this constructs an 'infinitely' nested set of submenus, starting at $menu_id or at the first breadcrumb in the top level menu (if any). If there are no suitable nodes, an empty string is returned.

string get_menu ([string $m = ''], [int $menu_id = NULL])
  • string $m: left margin for increased readability
  • int $menu_id: indicates where to start the menu (NULL means the first breadcrumb in top level menu)
get_navigation (line 618)

construct a top level menu (navigation bar) as an unnumbered list (UL) of list items (LI)

this simply walks through the top level of the menu tree and creates a link for each node.

  • return: properly indented ready-to-use HTML
string get_navigation ([string $m = ''], [bool $textonly = FALSE])
  • string $m: left margin for increased readability
  • bool $textonly: forces a text-type link even when a navigation image is stipulated in the node record
get_popups (line 446)

construct javascript alerts for messages

This constructs a piece of HTML that yields 0 or more calls to the javascript alert() function, once per message. If no messages need to be displayed an empty string is returned.

  • return: generated HTML-code with Javascript or empty string
string get_popups (array $messages, [string $m = ''])
  • string $m: left margin for increased readability
  • array $messages: @messages a collection of message to display via alert()
get_properties (line 983)

retrieve configuration parameters for this combination of theme and area

bool|array get_properties (int $theme_id, int $area_id)
  • int $theme_id
  • int $area_id
get_quickbottom (line 545)

construct a list of quicklinks for bottom of page (if any)

(see also get_quicktop()).

string get_quickbottom ([string $m = ''])
  • string $m: left margin for increased readability

Redefined in descendants as:
get_quicklinks (line 570)

workhorse for constructing list of quicklinks

This creates HTML-code for links that can be displayed at the top/bottom of the page. These links are the pages (but not subsections) defined in the quicktop_section_id or quickbottom_section_id in $this->config.

Note that this array may or may not exist and also that the section may or may not exist and that the section may or may not contain any visible pages. Mmm, that's a lot of may/maynot's...

Also note that these links are always displayed as text, even if a graphics image is defined in the corresponding node. The contents of the section can be found in $this->tree. If there are two or more links, they are separated with $separator (default '');

string get_quicklinks (string $m, string $quick_section_parameter, [string $separator = ''])
  • string $m: left margin for increased readability
  • string $quick_section_parameter: the name of the property that holds the section containing these quicklinks
  • string $separator: separates individual items in the list
get_quicktop (line 532)

construct a list of quicklinks for top of page (if any)

(see also get_quickbottom()).

string get_quicktop ([string $m = ''])
  • string $m: left margin for increased readability
node2anchor (line 1080)

construct an anchor from a node record

This constructs an array with key-value-pairs that can be used to construct an HTML anchor tag. At least the following keys are created in the resulting array: 'href', 'title' and 'anchor'. The latter is either the text or a referenct to an image that is supposed to go between the opening A-tag and closing A-tag. Furtermore an optional key is created: target. The contents of the input array $attributes is merged into the result.

If the parameter $textonly is TRUE the key 'anchor' is always text. If $textonly is NOT TRUE, the 'anchor' may refer to an image.

Note that the link text is always non-empty. If the node record has an empty link_text, the word 'node' followed by the node_id is returned. (Otherwise it will be hard to make an actual clickable link).

Note that we attempt to create 'friendly' URLs, ie. URLs that look very much like a plain path, e.g. http://www.exemplum.eu/index.php/3/Information_about_the_school.html rather than http://www.exemplum.eu/index.php?node=3 When bookmarking a page, the part 'Information_about_the_school.html' makes it easier to recognise the bookmark than when it is just some number. Choice for friendly URLs is made in the global (site) configuration.

  • return: an HTML A-tag that links to the node OR to the external link (if any)
  • uses: was_node_url()
string node2anchor (array $node_record, [array $attributes = NULL], [bool $textonly = FALSE])
  • array $node_record: the node record to convert
  • array $attributes: optional attributes to add to the HTML A-tag
  • bool $textonly: if TRUE, no clickable images will be returned
send_headers (line 186)

send collected HTTP-headers to user's browser

This sends the headers that still need to be sent. These are collected in the array $this->http_headers. If headers are already sent, this fact is logged (and the collected headers are not sent).

void send_headers ()
send_output (line 209)

send collected output to user's browser

This first sends any pending HTTP-headers and subsequently outputs the page that is constructed by $this->get_html()

  • return: and output sent to browser
void send_output ()
set_preview_mode (line 970)

set the preview mode

this sets the preview mode of the page currently being built. If it is set to TRUE, all internal URLs (such as those pointing to a node in the breadcrumb trail or in menu items) will be equal to '#' which makes it more or less impossible to leave the current page because a bare '#' is considered an unnamed fragment and so no new page is loaded when the link is clicked; just the thing we need.

  • return: and flag set
void set_preview_mode (bool $is_preview_mode)
  • bool $is_preview_mode: TRUE enables preview mode, FALSE disables it
show_tree_walk (line 683)

workhorse for constructing recursive menu (walk the tree) along the breadcrumb trail

this constructs nested (sub)menus along the breadcrumb trail. The effect is that the (sub)menus that lead to the current page ($this->node_id) are 'opened' whereas the other submenus are 'closed'. The (sub)menus are constructed in the form of nested UL's with LI's.

The level of recursion of the list items (LI) is indicated via class='levelNNN'. The type of item is indicated via class='page' or class='section'. Also, the item has an addional class='current' when it is part of the breadcrumb trail. Finally a current item also has the additional class 'activepage' or 'activesection' which makes the CSS easier.

The actual A-tag of the link only indicates being part of the breadcrumb trail via class='current'.

It is up to the style sheet to visualise these items taking all variants into account. Note that we only process visible pages and sections.

string show_tree_walk ([string $m = ''], int $subtree_id)
  • string $m: left margin for increased readability
  • int $subtree_id: indicates where to start this (sub)menu

Documentation generated on Sat, 1 Oct 2011 00:27:39 +0200 by phpDocumentor 1.4.0