/layout.php

Description

This file contains a number of useful functions for generating HTML and formatting data.

  • author: KavaSoft
Includes
include ("../catalog/info.php") (line 13)
Functions
abbreviate (line 297)

Truncates a string to a given number of characters, adding an ellipsis if necessary.

  • return: the truncated string
string abbreviate (string $value, [integer $length = 40])
  • string $value: a string
  • integer $length: the number of characters
div (line 116)

Returns a <div> tag.

  • return: the <div> tag
string div (string $class, string $text)
  • string $class: the class
  • string $text: the text
frame (line 143)

Returns a <frame> tag.

  • return: the <frame> tag
string frame (string $src, string $name, string $scrolling, [string $class = NULL])
  • string $src: the path to the source file
  • string $name: the name of the frame
  • string $scrolling: whether scrolling is allowed, 'yes'|'no'|'auto'
  • string $class: the class
frameset (line 128)

Returns a <frameset> tag.

  • return: the <frameset> tag
string frameset (string $dimension, string $sizes, array $frames)
  • string $dimension: either 'rows' or 'cols'
  • string $sizes: the size in pixels of the frames, e.g. '30,*,10'
  • array $frames: the frames or framesets
head (line 21)

Prints a <head> tag with title, generator, author, and stylesheet attributes.

void head (string $title, [string $styles = 'styles.css'])
  • string $title: the title of the page
  • string $styles: the name of the stylesheet
hyperlink (line 72)

Returns a <a> hyperlink tag.

  • return: the <a> tag
string hyperlink (string $path, string $text, [string $stuff = ''])
  • string $path: the path to the destination file
  • string $text: the text or image to be linked
  • string $stuff: extra attributes to be included in the tag
iframe (line 158)

Returns an <iframe> inline frame tag.

  • return: the <iframe> tag
string iframe (string $src, string $name, integer $width, integer $height, [string $scrolling = FALSE])
  • string $src: the path to the source file
  • string $name: the name of the frame
  • integer $width: the width in pixels
  • integer $height: the height in pixels
  • string $scrolling: whether scrolling is allowed, 'yes'|'no'|'auto'
img (line 101)

Returns an <img> image tag.

  • return: the <img> tag
string img (string $path, string $alt, [integer $width = 0], [integer $height = 0], [string $stuff = ''])
  • string $path: the path to the image file
  • string $alt: the alternate text
  • integer $width: the width in pixels
  • integer $height: the height in pixels
  • string $stuff: extra attributes to be included in the tag
load_time (line 330)

Returns the time it took to load the page in seconds and milliseconds.

Set $start_time to microtime() when beginning to load the page, then call load_time($start_time) after loading the page.

  • return: the time elapsed since $start_time in seconds and milliseconds
float load_time (string $start_time)
  • string $start_time: the start time from calling microtime()
local_format (line 252)

Returns the number formatted in the local format with the specified number of decimal places.

  • return: the formatted number, e.g. '5.234,23' in the German locale
string local_format (double $number, [integer $places = 0])
  • double $number: a number
  • integer $places: the number of decimal places
path_with_args (line 193)

Composes a GET URL from a path, arguments, and optionally an anchor.

For example, if $string is 'file.php' and $args are { 'artist' => 'pink_floyd', 'album' => 'pulse' }, will return 'file.php?artist=pink_floyd&artist=pulse'

  • return: the full path
string path_with_args (string $path, array $args, [string $anchor = ''])
  • string $path: the path to the file
  • array $args: a keyed array
  • string $anchor: an anchor to append to the end, e.g. '#selected'
popup (line 176)

Returns an <a> hyperlink that will open a popup window.

This method is preferable to creating popups with JavaScript functions, as these are blocked by many browsers.

  • return: the <a> tag
string popup (string $path, string $windowname, integer $width, integer $height, string $text, [string $stuff = ''])
  • string $path: the path to the destination file
  • string $windowname: the name of the popup window
  • integer $width: the width of the window in pixels
  • integer $height: the height of the window in pixels
  • string $text: the text or image to be linked
  • string $stuff: extra attributes to be included in the tag
quicktime_player (line 346)

Returns the code for a QuickTime player plugin.

  • return: the <object> tag for the player
string quicktime_player (string $source, integer $width, bool $autoplay)
  • string $source: the path to the audio file
  • integer $width: the width in pixels
  • bool $autoplay: whether the player should start automatically
rating (line 281)

Returns a formatted rating.

  • return: the rating in HTML, e.g. rating(60) would return '&#9733;&#9733;&#9733;'
string rating (integer $stars)
  • integer $stars: the rating number, between 0 and 100
scramble_email (line 365)

Converts an email address into HTML entities to make it more difficult for spambots to harvest.

  • return: the encoded address
string scramble_email (string $string)
  • string $string: the email address
size_format (line 262)

Returns a formatted size.

  • return: the formatted size, e.g. '123 KB', '12.3 MB', or '1.23 GB'
string size_format (double $size)
  • double $size: the size in kilobytes
songs_plural (line 317)

Returns the word 'song' or 'songs' depending upon whether $count is plural.

  • return: 'song' if $count is 1, 'songs' otherwise
string songs_plural (integer $count)
  • integer $count: the number of songs
td (line 42)

Returns a <td> table cell tag.

  • return: the <td> tag
string td (string $class, string $content, [integer $width = NULL], [integer $height = NULL], [integer $colspan = 1], [integer $rowspan = 1], [string $stuff = ''])
  • string $class: the class
  • string $content: the content that should be included inside the tag
  • integer $width: the width in pixels
  • integer $height: the height in pixels
  • integer $colspan: the number of columns
  • integer $rowspan: the number of rows
  • string $stuff: extra attributes to be included in the tag
time_format (line 211)

Returns the total time in days, hours, minutes and seconds.

  • return: the time represented in the format 'dd:hh:mm:ss'
string time_format (integer $time)
  • integer $time: the the time in seconds
time_format_simple (line 232)

Returns the total time in days, hours or minutes.

  • return: the time represented in the format '5.7 hours'
string time_format_simple (integer $time)
  • integer $time: the the time in seconds
tr (line 58)

Returns a <tr> table row tag.

  • return: the <tr> tag
string tr (array $rows)
  • array $rows: an array of <td> tags

Documentation generated on Sun, 12 Feb 2006 19:27:52 +0100 by phpDocumentor 1.2.3