Themes extends AppModel
Company Theme Settings
Table of Contents
Properties
| $client_theme_colors | |
| $staff_theme_colors |
Methods
| __construct() | Initialize Themes |
| add() | Adds a theme to this company |
| change() | Changes the theme to another theme for the given company |
| cloneThemes() | Clones the themes from one company and adds them to another |
| delete() | Deletes a theme belonging to this company |
| edit() | Updates a theme belonging to this company |
| formatMissingColors() | Formats the given color codes to set blank hex codes to 'transparent' |
| get() | Fetches a specific theme |
| getAll() | Fetches all themes in the system |
| getAvailableColors() | Retrieves a list of available theme color keys |
| getCurrent() | Fetches the current theme in use by a given company. The theme is inherited in the order of company settings -> system settings where "->" represents the left item inheriting (and overwriting in the case of duplicates) values found in the right item. |
| getDefault() | Fetches the default theme of the given type (limit 1) |
| getTypes() | Retrieves a list of the theme types and their language |
| validateColorsSet() | Validates that the given theme $colors exist and are set |
| validateCompanySet() | Validates that the given $company_id belongs to the given theme |
| formatData() | Formats the given theme's serialized and encoded data into useful fields |
| getRules() | Retrieves a list of rules for adding/editing/deleting a theme |
| validateHexCode() | Validates that the given string is a valid 6-character hex code |
Properties
$client_theme_colors
private
Available
$client_theme_colors
= ['theme_header_bg_color' => ['theme_header_bg_color_top', 'theme_header_bg_color_bottom'], 'theme_page_title_background_color' => ['theme_page_title_background_color_top', 'theme_page_title_background_color_bottom'], 'theme_page_title_text_color' => ['theme_page_title_text_color'], 'theme_navigation_background_color' => ['theme_navigation_background_color_top', 'theme_navigation_background_color_bottom'], 'theme_navigation_text_color' => ['theme_navigation_text_color'], 'theme_navigation_text_active_color' => ['theme_navigation_text_active_color'], 'theme_page_background_color' => ['theme_page_background_color'], 'theme_panel_header_background_color' => ['theme_panel_header_background_color_top', 'theme_panel_header_background_color_bottom'], 'theme_panel_header_text_color' => ['theme_panel_header_text_color'], 'theme_link_color' => ['theme_link_color'], 'theme_link_settings_color' => ['theme_link_settings_color'], 'theme_highlight_hover_color' => ['theme_highlight_hover_color'], 'theme_highlight_navigation_text_color_top' => ['theme_highlight_navigation_text_color_top'], 'theme_highlight_navigation_hover_text_color_top' => ['theme_highlight_navigation_hover_text_color_top'], 'theme_primary_alert_color' => ['theme_primary_alert_text_color', 'theme_primary_alert_background_color', 'theme_primary_alert_border_color'], 'theme_secondary_alert_color' => ['theme_secondary_alert_text_color', 'theme_secondary_alert_background_color', 'theme_secondary_alert_border_color'], 'theme_success_alert_color' => ['theme_success_alert_text_color', 'theme_success_alert_background_color', 'theme_success_alert_border_color'], 'theme_info_alert_color' => ['theme_info_alert_text_color', 'theme_info_alert_background_color', 'theme_info_alert_border_color'], 'theme_warning_alert_color' => ['theme_warning_alert_text_color', 'theme_warning_alert_background_color', 'theme_warning_alert_border_color'], 'theme_danger_alert_color' => ['theme_danger_alert_text_color', 'theme_danger_alert_background_color', 'theme_danger_alert_border_color'], 'theme_light_alert_color' => ['theme_light_alert_text_color', 'theme_light_alert_background_color', 'theme_light_alert_border_color'], 'theme_primary_button_color' => ['theme_primary_button_text_color', 'theme_primary_button_background_color', 'theme_primary_button_hover_color'], 'theme_secondary_button_color' => ['theme_secondary_button_text_color', 'theme_secondary_button_background_color', 'theme_secondary_button_hover_color'], 'theme_success_button_color' => ['theme_success_button_text_color', 'theme_success_button_background_color', 'theme_success_button_hover_color'], 'theme_info_button_color' => ['theme_info_button_text_color', 'theme_info_button_background_color', 'theme_info_button_hover_color'], 'theme_warning_button_color' => ['theme_warning_button_text_color', 'theme_warning_button_background_color', 'theme_warning_button_hover_color'], 'theme_danger_button_color' => ['theme_danger_button_text_color', 'theme_danger_button_background_color', 'theme_danger_button_hover_color'], 'theme_light_button_color' => ['theme_light_button_text_color', 'theme_light_button_background_color', 'theme_light_button_hover_color']]
Client Theme color fields. Each array value must be unique
$staff_theme_colors
private
Available
$staff_theme_colors
= ['theme_header_bg_color' => ['theme_header_bg_color_top', 'theme_header_bg_color_bottom'], 'theme_header_text_color' => ['theme_header_text_color'], 'theme_navigation_background_color' => ['theme_navigation_background_color_top', 'theme_navigation_background_color_bottom'], 'theme_navigation_text_color' => ['theme_navigation_text_color'], 'theme_navigation_text_hover_color' => ['theme_navigation_text_hover_color'], 'theme_subnavigation_bg_color' => ['theme_subnavigation_bg_color_top', 'theme_subnavigation_bg_color_bottom'], 'theme_subnavigation_text_color' => ['theme_subnavigation_text_color'], 'theme_subnavigation_text_active_color' => ['theme_subnavigation_text_active_color'], 'theme_widget_heading_bg_color' => ['theme_widget_heading_bg_color_top', 'theme_widget_heading_bg_color_bottom'], 'theme_widget_icon_heading_bg_color' => ['theme_widget_icon_heading_bg_color_top', 'theme_widget_icon_heading_bg_color_bottom'], 'theme_box_text_color' => ['theme_box_text_color'], 'theme_text_shadow' => ['theme_text_shadow'], 'theme_actions_text_color' => ['theme_actions_text_color'], 'theme_highlight_bg_color' => ['theme_highlight_bg_color'], 'theme_box_shadow_color' => ['theme_box_shadow_color']]
Staff Theme color fields. Each array VALUE must be unique
Methods
__construct()
Initialize Themes
public
__construct() : mixed
add()
Adds a theme to this company
public
add(array<string|int, mixed> $vars[, int $company_id = null ]) : int
Parameters
- $vars : array<string|int, mixed>
-
An array of theme info including:
- name The name of the theme
- logo_url The URL to the header logo
- custom_css The custom CSS code for the theme
- type The type of theme ("admin", or "client")
- colors An array of color fields dependent on vars type, including:
- Type 'admin':
- theme_header_bg_color_top The header background hex code for the top gradient
- theme_header_bg_color_bottom The header background hex code for the bottom gradient
- theme_header_text_color The header text hex code
- theme_navigation_background_color_top The header navigation background hex code top gradient
- theme_navigation_background_color_bottom The header navigation background hex code bottom gradient
- theme_navigation_text_color The header navigation text hex code
- theme_navigation_text_hover_color The header navigation text hex code on hover
- theme_subnavigation_bg_color_top The header subnavigation background color top gradient
- theme_subnavigation_bg_color_bottom The header subnavigation background color bottom gradient
- theme_subnavigation_text_color The header subnavigation text color
- theme_subnavigation_text_active_color The header subnavigation text active color
- theme_widget_heading_bg_color_top The widget heading background color top gradient
- theme_widget_heading_bg_color_bottom The widget heading background color bottom gradient
- theme_widget_icon_heading_bg_color_top The widget heading icon background color top gradient
- theme_widget_icon_heading_bg_color_bottom The widget heading icon background color bottom gradient
- theme_box_text_color General box hex code
- theme_text_shadow General text shadow hex code
- theme_actions_text_color General links hex code
- theme_highlight_bg_color General text highlight/active-link hex code
- theme_box_shadow_color The color of shadows shown under boxes
- Type 'client':
- theme_header_bg_color_top The header background hex code for the top gradient
- theme_header_bg_color_bottom The header background hex code for the bottom gradient
- theme_page_title_background_color_top The page title background hex code for the top gradient
- theme_page_title_background_color_bottom The page title background hex code for the bottom gradient
- theme_page_title_text_color The text color hex code for the page title
- theme_navigation_background_color_top The navigation background hex code for the top gradient
- theme_navigation_background_color_bottom The navigation background hex code for the bottom gradient
- theme_navigation_text_color The hex code for the navigation text
- theme_navigation_text_active_color The hex code for the navigation text when active
- theme_page_background_color The page background hex code
- theme_panel_header_background_color_top The page content header background hex code for the top gradient
- theme_panel_header_background_color_bottom The page content header background hex code for the bottom gradient
- theme_panel_header_text_color The text color of the page content header
- theme_link_color General links hex code
- theme_link_settings_color The settings links hex code
- theme_highlight_hover_color General text highlight/hover hex code
- Type 'admin':
- $company_id : int = null
-
The ID of the company to add this theme to (optional, defaults to the current company)
Return values
int —The ID of the theme added
change()
Changes the theme to another theme for the given company
public
change(int $id[, string $type = 'admin' ]) : mixed
Parameters
- $id : int
-
The theme ID of the theme to change to
- $type : string = 'admin'
-
The theme type ("admin" or "client", optional, default "admin")
cloneThemes()
Clones the themes from one company and adds them to another
public
cloneThemes(int $from_company_id, int $to_company_id) : mixed
Parameters
- $from_company_id : int
-
The ID of the company to duplicate the themes from
- $to_company_id : int
-
The ID of the company to add the themes to
delete()
Deletes a theme belonging to this company
public
delete(int $theme_id) : mixed
Parameters
- $theme_id : int
-
The theme ID of the theme to delete
edit()
Updates a theme belonging to this company
public
edit(int $theme_id, array<string|int, mixed> $vars) : mixed
Parameters
- $theme_id : int
-
The ID of the theme to update
- $vars : array<string|int, mixed>
-
An array of theme info including:
- name The name of the theme
- logo_url The URL to the header logo
- custom_css The custom CSS code for the theme
- type The type of theme ("admin", "client")
- colors An array of color fields including:
- Type 'admin':
- theme_header_bg_color_top The header background hex code for the top gradient
- theme_header_bg_color_bottom The header background hex code for the bottom gradient
- theme_header_text_color The header text hex code
- theme_navigation_background_color_top The header navigation background hex code top gradient
- theme_navigation_background_color_bottom The header navigation background hex code bottom gradient
- theme_navigation_text_color The header navigation text hex code
- theme_navigation_text_hover_color The header navigation text hex code on hover
- theme_subnavigation_bg_color_top The header subnavigation background color top gradient
- theme_subnavigation_bg_color_bottom The header subnavigation background color bottom gradient
- theme_subnavigation_text_color The header subnavigation text color
- theme_subnavigation_text_active_color The header subnavigation text active color
- theme_widget_heading_bg_color_top The widget heading background color top gradient
- theme_widget_heading_bg_color_bottom The widget heading background color bottom gradient
- theme_widget_icon_heading_bg_color_top The widget heading icon background color top gradient
- theme_widget_icon_heading_bg_color_bottom The widget heading icon background color bottom gradient
- theme_box_text_color General box hex code
- theme_text_shadow General text shadow hex code
- theme_actions_text_color General links hex code
- theme_highlight_bg_color General text highlight/active-link hex code
- theme_box_shadow_color The color of shadows shown under boxes
- Type 'client':
- theme_header_bg_color_top The header background hex code for the top gradient
- theme_header_bg_color_bottom The header background hex code for the bottom gradient
- theme_page_title_background_color_top The page title background hex code for the top gradient
- theme_page_title_background_color_bottom The page title background hex code for the bottom gradient
- theme_page_title_text_color The text color hex code for the page title
- theme_navigation_background_color_top The navigation background hex code for the top gradient
- theme_navigation_background_color_bottom The navigation background hex code for the bottom gradient
- theme_navigation_text_color The hex code for the navigation text
- theme_navigation_text_active_color The hex code for the navigation text when active
- theme_page_background_color The page background hex code
- theme_panel_header_background_color_top The page content header background hex code for the top gradient
- theme_panel_header_background_color_bottom The page content header background hex code for the bottom gradient
- theme_panel_header_text_color The text color of the page content header
- theme_link_color General links hex code
- theme_link_settings_color The settings links hex code
- theme_highlight_hover_color General text highlight/hover hex code
- Type 'admin':
formatMissingColors()
Formats the given color codes to set blank hex codes to 'transparent'
public
formatMissingColors(array<string|int, mixed> $colors) : array<string|int, mixed>
Parameters
- $colors : array<string|int, mixed>
-
A key/value array of admin/client colors
Return values
array<string|int, mixed> —An array of updated colors
get()
Fetches a specific theme
public
get(int $id) : mixed
Parameters
- $id : int
-
The theme ID
Return values
mixed —An stdClass object representing the theme, or false if no results.
getAll()
Fetches all themes in the system
public
getAll([string $type = null ][, mixed $company_id = null ]) : array<string|int, mixed>
Parameters
- $type : string = null
-
The type of themes to get (i.e. "admin", "client", or null for all. optional, default null)
- $company_id : mixed = null
-
The ID of the company whose themes to fetch (optional, defaults to the current company's themes)
Return values
array<string|int, mixed> —An array of stdClass objects representing each theme
getAvailableColors()
Retrieves a list of available theme color keys
public
getAvailableColors([string $type = 'admin' ]) : array<string|int, mixed>
Parameters
- $type : string = 'admin'
-
The type of theme colors to fetch (i.e. "admin" or "client", optional, default "admin")
Return values
array<string|int, mixed> —A list of available theme color keys
getCurrent()
Fetches the current theme in use by a given company. The theme is inherited in the order of company settings -> system settings where "->" represents the left item inheriting (and overwriting in the case of duplicates) values found in the right item.
public
getCurrent(int $company_id[, string $type = 'admin' ]) : mixed
Parameters
- $company_id : int
-
The company ID
- $type : string = 'admin'
-
The type of theme to fetch (i.e. "admin" or "client", optional, default "admin")
Return values
mixed —An array of objects containg key/values for the theme, false if no records found
getDefault()
Fetches the default theme of the given type (limit 1)
public
getDefault([string $type = 'admin' ]) : mixed
Parameters
- $type : string = 'admin'
-
The type of theme to fetch ("admin", or "client"; optional, default "admin")
Return values
mixed —An stdClass object representing the default theme of the given type, or false if none exist
getTypes()
Retrieves a list of the theme types and their language
public
getTypes() : array<string|int, mixed>
Return values
array<string|int, mixed> —A key/value list of theme types and their language
validateColorsSet()
Validates that the given theme $colors exist and are set
public
validateColorsSet(array<string|int, mixed> $colors[, string $type = 'admin' ]) : bool
Parameters
- $colors : array<string|int, mixed>
-
An array of colors including:
- Type 'admin':
- theme_header_bg_color_top The header background hex code for the top gradient
- theme_header_bg_color_bottom The header background hex code for the bottom gradient
- theme_header_text_color The header text hex code
- theme_navigation_background_color_top The header navigation background hex code top gradient
- theme_navigation_background_color_bottom The header navigation background hex code bottom gradient
- theme_navigation_text_color The header navigation text hex code
- theme_navigation_text_hover_color The header navigation text hex code on hover
- theme_subnavigation_bg_color_top The header subnavigation background color top gradient
- theme_subnavigation_bg_color_bottom The header subnavigation background color bottom gradient
- theme_subnavigation_text_color The header subnavigation text color
- theme_subnavigation_text_active_color The header subnavigation text active color
- theme_widget_heading_bg_color_top The widget heading background color top gradient
- theme_widget_heading_bg_color_bottom The widget heading background color bottom gradient
- theme_widget_icon_heading_bg_color_top The widget heading icon background color top gradient
- theme_widget_icon_heading_bg_color_bottom The widget heading icon background color bottom gradient
- theme_box_text_color General box hex code
- theme_text_shadow General text shadow hex code
- theme_actions_text_color General links hex code
- theme_highlight_bg_color General text highlight/active-link hex code
- theme_box_shadow_color The color of shadows shown under boxes
- Type 'client':
- theme_header_bg_color_top The header background hex code for the top gradient
- theme_header_bg_color_bottom The header background hex code for the bottom gradient
- theme_page_title_background_color_top The page title background hex code for the top gradient
- theme_page_title_background_color_bottom The page title background hex code for the bottom gradient
- theme_page_title_text_color The text color hex code for the page title
- theme_navigation_background_color_top The navigation background hex code for the top gradient
- theme_navigation_background_color_bottom The navigation background hex code for the bottom gradient
- theme_navigation_text_color The hex code for the navigation text
- theme_navigation_text_active_color The hex code for the navigation text when active
- theme_page_background_color The page background hex code
- theme_panel_header_background_color_top The page content header background hex code for the top gradient
- theme_panel_header_background_color_bottom The page content header background hex code for the bottom gradient
- theme_panel_header_text_color The text color of the page content header
- theme_link_color General links hex code
- theme_link_settings_color The settings links hex code
- theme_highlight_hover_color General text highlight/hover hex code
- Type 'admin':
- $type : string = 'admin'
-
The theme type ("admin" or "client", optional, default "admin")
Return values
bool —True if the colors exist and are set, false otherwise
validateCompanySet()
Validates that the given $company_id belongs to the given theme
public
validateCompanySet(int $company_id, int $theme_id) : bool
Parameters
- $company_id : int
-
The company ID
- $theme_id : int
-
The theme ID
Return values
bool —True if the given company ID belongs to the given theme, or false otherwise
formatData()
Formats the given theme's serialized and encoded data into useful fields
private
formatData(stdClass $theme) : stdClass
Parameters
- $theme : stdClass
-
An stdClass representing the theme
Return values
stdClass —An updated theme object
getRules()
Retrieves a list of rules for adding/editing/deleting a theme
private
getRules([array<string|int, mixed> $vars = [] ][, bool $edit = false ]) : array<string|int, mixed>
Parameters
- $vars : array<string|int, mixed> = []
-
A list of input vars for use with the rules
- $edit : bool = false
-
True when editing a theme, false when adding
Return values
array<string|int, mixed> —The rules for adding or editing a theme
validateHexCode()
Validates that the given string is a valid 6-character hex code
private
validateHexCode(string $hex_code) : bool
Parameters
- $hex_code : string
-
A hex color code
Return values
bool —True if the given hex code is a valid 6-character hex code, or false otherwise