Class Theme

Description

Methods to access properties of a theme

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


	
			
Direct descendents
Class Description
 class ThemeFrugal /program/themes/frugal/frugal.class.php - the class that comprises the most minimal theme
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)
 void calc_tree_visibility ( $node_id,  &$tree, [ $force_invisibility = FALSE])
 void construct_tree ( $area_id)
 void dump_subtree ( $node_id,  &$tree)
 string friendly_bookmark (string $title)
 string get_address ([string $m = ''])
 string get_bottomline ([string $m = ''])
 string get_content ([string $m = ''])
 void get_div_breadcrumbs ([ $m = ''])
 string get_div_messages ([string $m = ''])
 string get_html ()
 string get_html_head ([string $m = ''])
 string get_jumpmenu ([string $m = ''])
 string get_lines ( $a, [string $m = ''])
 string get_logo ([string $m = ''])
 void get_menu ([ $m = ''])
 void get_navigation ([ $m = ''], [ $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_id)
 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 ( $is_preview_mode)
 void show_tree_walk ([ $m = ''],  $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 93)
  • var: $breadcrumb_addendum holds an array with additional anchors that can be set by the page's module
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 96)
  • 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 $friendly_url = TRUE (line 90)
  • var: $friendly_url if TRUE, links via index.php/nnn/book_mark_friendly_text otherwise index.php?node=nnn
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 $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)
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 build_tree()).
Methods
Constructor Theme (line 110)

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.

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 890)

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

void add_content (string|array $content)
  • string|array $content: the line(s) of text to add
add_html_header (line 804)

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 795)

add an HTTP-header

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

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 867)

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

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 879)

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 828)

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 814)

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 856)

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

void add_stylesheet (string $url)
  • string $url: url of the stylesheet
calc_breadcrumb_trail (line 1048)

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
calc_tree_visibility (line 1000)

calculate the visibility of the nodes in the tree

  • todo: how about making all nodes under embargo visible when previewing a page or at least the path from the node to display?
void calc_tree_visibility ( $node_id,  &$tree, [ $force_invisibility = FALSE])
  • $node_id
  • &$tree
  • $force_invisibility
construct_tree (line 955)
void construct_tree ( $area_id)
  • $area_id
dump_subtree (line 966)
void dump_subtree ( $node_id,  &$tree)
  • $node_id
  • &$tree
friendly_bookmark (line 1142)

construct an alphanumeric string from a node title (for a readable bookmark)

this strips everything from $title except alphanumerics and spaces. The spaces are translated to an underscore. Length of result is limited to an arbitrary length of 50 characters.

  • return: string with only alphanumerics and underscores, mas 50 chars
string friendly_bookmark (string $title)
  • string $title: input text
get_address (line 773)

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.

  • return: reconstructed URL as text
  • todo: should we add additional text to the address, e.g. prefix 'URL: ' or something? now it is just a plain old URL without any commments whatsoever.
string get_address ([string $m = ''])
  • string $m: left margin for increased readability
get_bottomline (line 747)

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).

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

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 447)

construct breadcrumb trail

  • todo: how about adding a title to the items? or do we do that already?
void get_div_breadcrumbs ([ $m = ''])
  • $m
get_div_messages (line 393)

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 $m: left margin for increased readability
get_html (line 222)

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 message.

The same logic applies to the breadcrumb trail.

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

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
string get_html_head ([string $m = ''])
  • string $m: left margin for increased readability
get_jumpmenu (line 689)

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.

  • return: properly indented ready-to-use HTML
string get_jumpmenu ([string $m = ''])
  • string $m: add readabiliy to output
get_lines (line 367)

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 ( $a, [string $m = ''])
  • string $m: left margin for increased readability
  • $a
get_logo (line 486)

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
get_menu (line 627)
void get_menu ([ $m = ''])
  • $m
get_navigation (line 607)
void get_navigation ([ $m = ''], [ $textonly = FALSE])
  • $m
  • $textonly
get_popups (line 428)

construct javascript alerts for messages

This constructs a piece of HTML that yields 0 or more calles 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 946)

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 539)

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
get_quicklinks (line 563)

workhorse for constructing list of quicklinks

This creates HTML-code for links that can be displayed at the top of the page. These links are the pages (but not subsections) defined in the quicktop_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.

string get_quicklinks (string $m, string $quick_section_id)
  • string $m: left margin for increased readability
  • string $quick_section_id: the name of the property that holds the section containing these quicklinks
get_quicktop (line 526)

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 1092)

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 tag and closing 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).

  • return: an HTML A-tag that links to the node OR to the external link (if any)
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 162)

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 188)

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()

void send_output ()
set_preview_mode (line 910)
void set_preview_mode ( $is_preview_mode)
  • $is_preview_mode
show_tree_walk (line 647)
void show_tree_walk ([ $m = ''],  $subtree_id)
  • $m
  • $subtree_id

Documentation generated on Wed, 11 May 2011 23:45:37 +0200 by phpDocumentor 1.4.0