HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

ocPortal Developer's Guide: Themes

» Return to Contents



sources/themes.php

Global_functions_themes.php

Function summary

void init__themes ()
URLPATH find_theme_image (ID_TEXT id, boolean silent_fail, boolean leave_local, ?ID_TEXT theme, ?LANGUAGE_NAME lang, ?object db, boolean pure_only)
URLPATH cdn_filter (URLPATH path)
?string _search_img_file (ID_TEXT theme, ?LANGUAGE_NAME lang, ID_TEXT id, ID_TEXT dir)

void init__themes()

Standard code module initialisation function.

Parameters…

(No return value)


Return to the function index for this class Expand: View the source code to this function

URLPATH find_theme_image(ID_TEXT id, boolean silent_fail, boolean leave_local, ?ID_TEXT theme, ?LANGUAGE_NAME lang, ?object db, boolean pure_only)

Find the URL to the theme image of the specified ID. It searches various priorities, including language and theme overrides.

Parameters…

Name id
Description The theme image ID
Type ID_TEXT

Name silent_fail
Description Whether to silently fail (i.e. not give out an error message when a theme image cannot be found)
Default value boolean-false
Type boolean

Name leave_local
Description Whether to leave URLs as relative local URLs
Default value boolean-false
Type boolean

Name theme
Description The theme to search in (NULL: users current theme)
Default value
Type ?ID_TEXT

Name lang
Description The language to search for (NULL: users current language)
Default value
Type ?LANGUAGE_NAME

Name db
Description The database to use (NULL: site database)
Default value
Type ?object

Name pure_only
Description Whether to only search the default 'images' filesystem
Default value boolean-false
Type boolean

Returns…

Description The URL found (blank: not found)
Type URLPATH

Return to the function index for this class Expand: View the source code to this function

URLPATH cdn_filter(URLPATH path)

Filter a path so it runs through a CDN.

Parameters…

Name path
Description Input URL
Type URLPATH

Returns…

Description Output URL
Type URLPATH

Return to the function index for this class Expand: View the source code to this function

?string _search_img_file(ID_TEXT theme, ?LANGUAGE_NAME lang, ID_TEXT id, ID_TEXT dir)

Search for a specified image file within a theme for a specified language.

Parameters…

Name theme
Description The theme
Type ID_TEXT

Name lang
Description The language (NULL: try generally, under no specific language)
Type ?LANGUAGE_NAME

Name id
Description The theme image ID
Type ID_TEXT

Name dir
Description Directory to search
Default value images
Type ID_TEXT

Returns…

Description The path to the image (NULL: was not found)
Type ?string

Return to the function index for this class Expand: View the source code to this function

sources/themes2.php

Global_functions_themes2.php

Function summary

void actual_edit_theme_image (SHORT_TEXT old_id, ID_TEXT theme, LANGUAGE_NAME lang, SHORT_TEXT id, URLPATH path, boolean quick)
string css_preg (array matches)
void actual_add_theme (ID_TEXT name)
void actual_add_theme_image (ID_TEXT theme, LANGUAGE_NAME lang, SHORT_TEXT id, URLPATH path, boolean fail_ok)
ID_TEXT get_theme_img_code (ID_TEXT type, boolean allow_skip, ID_TEXT field_file, ID_TEXT field_choose)
array find_images_do_dir (ID_TEXT theme, string subdir, array langs)
array get_all_image_ids_type (ID_TEXT type, boolean recurse, ?object db, ?ID_TEXT theme)
void _get_all_image_ids_type (array ids, ID_TEXT dir, ID_TEXT type, boolean recurse)
tempcode combo_get_image_paths (string selected_path, URLPATH base_url, PATH base_path)
array get_image_paths (URLPATH base_url, PATH base_path)
array get_all_image_codes (PATH base_path, PATH search_under, boolean recurse)
tempcode nice_get_theme_images (?ID_TEXT it, ?string filter, boolean do_id, boolean include_all, string under)
tempcode nice_get_themes (?ID_TEXT theme, boolean no_rely, boolean show_everything, ID_TEXT default_message_string)
array find_all_themes (boolean full_details)
void tidy_theme_img_code (?ID_TEXT new, ID_TEXT old, ID_TEXT table, ID_TEXT field, ?object db)

void actual_edit_theme_image(SHORT_TEXT old_id, ID_TEXT theme, LANGUAGE_NAME lang, SHORT_TEXT id, URLPATH path, boolean quick)

Edit a theme image.

Parameters…

Name old_id
Description The current theme image ID
Type SHORT_TEXT

Name theme
Description The theme the theme image is in
Type ID_TEXT

Name lang
Description The language the theme image is for (blank: all languages)
Type LANGUAGE_NAME

Name id
Description The new theme image ID
Type SHORT_TEXT

Name path
Description The URL to the theme image
Type URLPATH

Name quick
Description Whether to avoid cleanup, etc
Default value boolean-false
Type boolean

(No return value)


Return to the function index for this class Expand: View the source code to this function

string css_preg(array matches)

Replace colour codes with references (helper callback function)

Parameters…

Name matches
Description List of found regular expression matches (only index 0 relevant).
Type array

Returns…

Description Replacement.
Type string

Return to the function index for this class Expand: View the source code to this function

void actual_add_theme(ID_TEXT name)

Add a theme.

Parameters…

Name name
Description The theme name
Type ID_TEXT

(No return value)


Return to the function index for this class Expand: View the source code to this function

void actual_add_theme_image(ID_TEXT theme, LANGUAGE_NAME lang, SHORT_TEXT id, URLPATH path, boolean fail_ok)

Add a theme image.

Parameters…

Name theme
Description The theme the theme image is in
Type ID_TEXT

Name lang
Description The language the theme image is for
Type LANGUAGE_NAME

Name id
Description The theme image ID
Type SHORT_TEXT

Name path
Description The URL to the theme image
Type URLPATH

Name fail_ok
Description Whether to allow failure without bombing out
Default value boolean-false
Type boolean

(No return value)


Return to the function index for this class Expand: View the source code to this function

ID_TEXT get_theme_img_code(ID_TEXT type, boolean allow_skip, ID_TEXT field_file, ID_TEXT field_choose)

A theme image has been passed through by POST, either as a file (a new theme image), or as a reference to an existing one. Get the image code from the POST data.

Parameters…

Name type
Description The type of theme image
Default value ocf_emoticons
Type ID_TEXT

Name allow_skip
Description Allow no code to be given
Default value boolean-false
Type boolean

Name field_file
Description Form field for uploading
Default value file
Type ID_TEXT

Name field_choose
Description Form field for choosing
Default value theme_img_code
Type ID_TEXT

Returns…

Description The (possibly randomised) theme image code
Type ID_TEXT

Return to the function index for this class Expand: View the source code to this function

array find_images_do_dir(ID_TEXT theme, string subdir, array langs)

Recursively find theme images under the specified details. Does not find custom theme images, as it doesn't check the DB.

Parameters…

Name theme
Description The theme
Type ID_TEXT

Name subdir
Description The subdirectory to search under
Type string

Name langs
Description A map (lang=>1) of the languages in the system, so the codes may be filtered out of the image codes in our result list
Type array

Returns…

Description A map, theme-image-code=>URL
Type array

Return to the function index for this class Expand: View the source code to this function

array get_all_image_ids_type(ID_TEXT type, boolean recurse, ?object db, ?ID_TEXT theme)

Get all the image IDs (both already known, and those uncached) of a certain type (i.e. under a subdirectory).

Parameters…

Name type
Description The type of image (e.g. 'ocf_emoticons')
Type ID_TEXT

Name recurse
Description Whether to search recursively; i.e. in subdirectories of the type subdirectory
Default value boolean-false
Type boolean

Name db
Description The database connection to work over (NULL: site db)
Default value
Type ?object

Name theme
Description The theme to search in, in addition to the default theme (NULL: current theme)
Default value
Type ?ID_TEXT

Returns…

Description The list of image IDs
Type array

Return to the function index for this class Expand: View the source code to this function

void _get_all_image_ids_type(array ids, ID_TEXT dir, ID_TEXT type, boolean recurse)

Get all the image IDs (both already known, and those uncached) of a certain type (i.e. under a subdirectory).

Parameters…

Name ids
Description The list of image IDs found so far. This list will be appended as we proceed
Type array

Name dir
Description The specific theme image subdirectory we are currently looking under
Type ID_TEXT

Name type
Description The type of image (e.g. 'ocf_emoticons')
Type ID_TEXT

Name recurse
Description Whether to search recursively; i.e. in subdirectories of the type subdirectory
Type boolean

(No return value)


Return to the function index for this class Expand: View the source code to this function

tempcode combo_get_image_paths(string selected_path, URLPATH base_url, PATH base_path)

Get tempcode for a radio list to choose an image from the image FILES in the theme.

Parameters…

Name selected_path
Description The currently selected image path (blank for none)
Type string

Name base_url
Description The base-URL to where we are searching for images
Type URLPATH

Name base_path
Description The base-path to where we are searching for images
Type PATH

Returns…

Description The generated tempcode
Type tempcode

Return to the function index for this class Expand: View the source code to this function

array get_image_paths(URLPATH base_url, PATH base_path)

Search under a base path for image FILE URLs (not actually paths as function name would suggest).

Parameters…

Name base_url
Description The base-URL to where we are searching for images
Type URLPATH

Name base_path
Description The base-path to where we are searching for images
Type PATH

Returns…

Description path->url map of found images
Type array

Return to the function index for this class Expand: View the source code to this function

array get_all_image_codes(PATH base_path, PATH search_under, boolean recurse)

Get all the themes image codes. THIS DOES NOT SEARCH THE DB - DO NOT USE UNLESS IT'S ON A PURE PACKAGED THEME

Parameters…

Name base_path
Description The base-path to where we are searching for images
Type PATH

Name search_under
Description The path to search under, relative to the base-path. This is not the same as the base-path, as we are cropping paths to the base-path
Type PATH

Name recurse
Description Whether to search recursively from the given directory
Default value boolean-true
Type boolean

Returns…

Description A list of image codes
Type array

Return to the function index for this class Expand: View the source code to this function

tempcode nice_get_theme_images(?ID_TEXT it, ?string filter, boolean do_id, boolean include_all, string under)

Get tempcode for a dropdown to choose a theme from the themes present.

Parameters…

Name it
Description The currently selected image ID (NULL: none selected)
Default value
Type ?ID_TEXT

Name filter
Description An SQL where clause (including the WHERE), that filters the query somehow (NULL: none)
Default value
Type ?string

Name do_id
Description Whether to show IDs as the list entry captions, rather than paths
Default value boolean-false
Type boolean

Name include_all
Description Whether to include images not yet used (i.e not in theme_images map yet)
Default value boolean-false
Type boolean

Name under
Description Only include images under this path. Including a trailing slash unless you specifically want to filter allowing filename stubs as well as paths (blank: no limitation)
Default value
Type string

Returns…

Description Tempcode for a list selection of theme images
Type tempcode

Return to the function index for this class Expand: View the source code to this function

tempcode nice_get_themes(?ID_TEXT theme, boolean no_rely, boolean show_everything, ID_TEXT default_message_string)

Get a UI list for choosing a theme.

Parameters…

Name theme
Description The theme to select by default (NULL: no specific default)
Default value
Type ?ID_TEXT

Name no_rely
Description Whether to skip the 'rely on forums' entry
Default value boolean-false
Type boolean

Name show_everything
Description Whether to forget about permissions for this list
Default value boolean-false
Type boolean

Name default_message_string
Description The language string to use for the default answer
Default value RELY_FORUMS
Type ID_TEXT

Returns…

Description The list
Type tempcode

Return to the function index for this class Expand: View the source code to this function

array find_all_themes(boolean full_details)

Get an array listing all the themes present.

Parameters…

Name full_details
Description Whether to gather full details for each theme
Default value boolean-false
Type boolean

Returns…

Description A map of all themes (name=>title) OR if requested a map of theme name to full theme details
Type array

Return to the function index for this class Expand: View the source code to this function

void tidy_theme_img_code(?ID_TEXT new, ID_TEXT old, ID_TEXT table, ID_TEXT field, ?object db)

Delete a theme image used for a resource that was added, but only if the theme image is now unused.

Parameters…

Name new
Description The new theme image (NULL: no new one)
Type ?ID_TEXT

Name old
Description The old theme image we might be tidying up
Type ID_TEXT

Name table
Description Table to check against
Type ID_TEXT

Name field
Description Field in table
Type ID_TEXT

Name db
Description Database connection to check against (NULL: site database)
Default value
Type ?object

(No return value)


Return to the function index for this class Expand: View the source code to this function