include/SugarTheme/SugarTheme.php
Constants
\SugarTheme
Class that provides tools for working with a theme.
- Api
Properties

$_clearCacheOnDestroy= 'false'
Controls whether or not to clear the cache on destroy; defaults to false
falseDetails- Type
- n/a

array
$_cssCache= 'array()'
Cache built of all css files locations
array()Details- Type
- array

array
$_imageCache= 'array()'
Cache built of all image files locations
array()Details- Type
- array

array
$_initialCacheSize= 'array(
'cssCache' => 0,
'imageCache' => 0,
'jsCache' => 0,
'templateCache' => 0,
'spriteCache' => 0,
)'
Size of the caches after the are initialized in the constructor
array(
'cssCache' => 0,
'imageCache' => 0,
'jsCache' => 0,
'templateCache' => 0,
'spriteCache' => 0,
)Details- Type
- array

array
$_jsCache= 'array()'
Cache built of all javascript files locations
array()Details- Type
- array

array
$_spriteCache= 'array()'
Cache built of sprite meta data
array()Details- Type
- array

array
$_templateCache= 'array()'
Cache built of all template files locations
array()Details- Type
- array

array
$barChartColors= 'array(
"docBorder" => "0xffffff",
"docBg1" => "0xffffff",
"docBg2" => "0xffffff",
"xText" => "0x33485c",
"yText" => "0x33485c",
"title" => "0x333333",
"misc" => "0x999999",
"altBorder" => "0xffffff",
"altBg" => "0xffffff",
"altText" => "0x666666",
"graphBorder" => "0xcccccc",
"graphBg1" => "0xf6f6f6",
"graphBg2" => "0xf6f6f6",
"graphLines" => "0xcccccc",
"graphText" => "0x333333",
"graphTextShadow" => "0xf9f9f9",
"barBorder" => "0xeeeeee",
"barBorderHilite" => "0x333333",
"legendBorder" => "0xffffff",
"legendBg1" => "0xffffff",
"legendBg2" => "0xffffff",
"legendText" => "0x444444",
"legendColorKeyBorder" => "0x777777",
"scrollBar" => "0xcccccc",
"scrollBarBorder" => "0xeeeeee",
"scrollBarTrack" => "0xeeeeee",
"scrollBarTrackBorder" => "0xcccccc",
)'
Colors used in bar charts
array(
"docBorder" => "0xffffff",
"docBg1" => "0xffffff",
"docBg2" => "0xffffff",
"xText" => "0x33485c",
"yText" => "0x33485c",
"title" => "0x333333",
"misc" => "0x999999",
"altBorder" => "0xffffff",
"altBg" => "0xffffff",
"altText" => "0x666666",
"graphBorder" => "0xcccccc",
"graphBg1" => "0xf6f6f6",
"graphBg2" => "0xf6f6f6",
"graphLines" => "0xcccccc",
"graphText" => "0x333333",
"graphTextShadow" => "0xf9f9f9",
"barBorder" => "0xeeeeee",
"barBorderHilite" => "0x333333",
"legendBorder" => "0xffffff",
"legendBg1" => "0xffffff",
"legendBg2" => "0xffffff",
"legendText" => "0x444444",
"legendColorKeyBorder" => "0x777777",
"scrollBar" => "0xcccccc",
"scrollBarBorder" => "0xeeeeee",
"scrollBarTrack" => "0xeeeeee",
"scrollBarTrackBorder" => "0xcccccc",
)Details- Type
- array

array
$colors= 'array()'
Colors sets provided by the theme
array()Details- Type
- array
- Deprecated
- only here for BC during upgrades

string
$directionality= ''ltr''
Defines which parent files to not include
'ltr'Details- Type
- string

array
$fonts= 'array()'
Font sets provided by the theme
array()Details- Type
- array
- Deprecated
- only here for BC during upgrades

string
$ignoreParentFiles= 'array()'
Defines which parent files to not include
array()Details- Type
- string

$imageExtensions= 'array(
'gif',
'png',
'jpg',
'tif',
'bmp',
)'
array(
'gif',
'png',
'jpg',
'tif',
'bmp',
)Details- Type
- n/a

array
$pieChartColors= 'array(
"docBorder" => "0xffffff",
"docBg1" => "0xffffff",
"docBg2" => "0xffffff",
"title" => "0x333333",
"subtitle" => "0x666666",
"misc" => "0x999999",
"altBorder" => "0xffffff",
"altBg" => "0xffffff",
"altText" => "0x666666",
"graphText" => "0x33485c",
"graphTextShadow" => "0xf9f9f9",
"pieBorder" => "0xffffff",
"pieBorderHilite" => "0x333333",
"legendBorder" => "0xffffff",
"legendBg1" => "0xffffff",
"legendBg2" => "0xffffff",
"legendText" => "0x444444",
"legendColorKeyBorder" => "0x777777",
"scrollBar" => "0xdfdfdf",
"scrollBarBorder" => "0xfafafa",
"scrollBarTrack" => "0xeeeeee",
"scrollBarTrackBorder" => "0xcccccc",
)'
Colors used in pie charts
array(
"docBorder" => "0xffffff",
"docBg1" => "0xffffff",
"docBg2" => "0xffffff",
"title" => "0x333333",
"subtitle" => "0x666666",
"misc" => "0x999999",
"altBorder" => "0xffffff",
"altBg" => "0xffffff",
"altText" => "0x666666",
"graphText" => "0x33485c",
"graphTextShadow" => "0xf9f9f9",
"pieBorder" => "0xffffff",
"pieBorderHilite" => "0x333333",
"legendBorder" => "0xffffff",
"legendBg1" => "0xffffff",
"legendBg2" => "0xffffff",
"legendText" => "0x444444",
"legendColorKeyBorder" => "0x777777",
"scrollBar" => "0xdfdfdf",
"scrollBarBorder" => "0xfafafa",
"scrollBarTrack" => "0xeeeeee",
"scrollBarTrackBorder" => "0xcccccc",
)Details- Type
- array
Methods

__construct(
\$defaults $defaults
)
:
voidConstructor
Sets the theme properties from the defaults passed to it, and loads the file path cache from an external cache
| Name | Type | Description |
|---|---|---|
| $defaults | \$defaults | string defaults for the current theme |

__destruct(
)
:
voidDestructor Here we'll write out the internal file path caches to an external cache of some sort.

__get(
$key
)
:
stringGeneric public accessor method for all the properties of the theme ( which are kept protected )
| Name | Type | Description |
|---|---|---|
| $key |
| Type | Description |
|---|---|
| string |

__toString(
)
:
stringSpecifies what is returned when the object is cast to a string, in this case it will be the theme directory name.
| Type | Description |
|---|---|
| string | theme directory name |

_getImageFileName(
string $imageName
)
:
stringChecks for an image using all of the accepted image extensions
| Name | Type | Description |
|---|---|---|
| $imageName | string | image file name |
| Type | Description |
|---|---|
| string | path to image |

getAllImages(
)
:
arrayReturns an array of all of the images available for the current theme
| Type | Description |
|---|---|
| array |

getCSS(
\$color $color
=
null, \$font $font
=
null
)
:
stringReturns CSS for the current theme.
| Name | Type | Description |
|---|---|---|
| $color | \$color | string optional, specifies the css color file to use if the theme supports it; defaults to cookie value or theme default |
| $font | \$font | string optional, specifies the css font file to use if the theme supports it; defaults to cookie value or theme default |
| Type | Description |
|---|---|
| string | HTML code |

getCSSURL(
string $cssFileName, bool $returnURL
=
true
)
:
stringReturns the URL for the css file in the current theme. If not found in the current theme, will revert to looking in the base theme.
| Name | Type | Description |
|---|---|---|
| $cssFileName | string | css file name |
| $returnURL | bool | if true, returns URL with unique image mark, otherwise returns path to the file |
| Type | Description |
|---|---|
| string | path of css file to include |

getDefaultCSSPath(
)
:
stringReturns the css path of the theme defaults
| Type | Description |
|---|---|
| string |

getDefaultFilePath(
)
:
stringReturns the file path of the theme defaults
| Type | Description |
|---|---|
| string |

getDefaultImagePath(
)
:
stringReturns the image path of the theme defaults
| Type | Description |
|---|---|
| string |

getDefaultJSPath(
)
:
stringReturns the javascript path of the theme defaults
| Type | Description |
|---|---|
| string |

getDefaultTemplatePath(
)
:
stringReturns the template path of the theme defaults
| Type | Description |
|---|---|
| string |

getImage(
$imageName, string $other_attributes
=
'', string $width
=
null, string $height
=
null, string $ext
=
null, string $alt
=
''
)
:
stringReturns an image tag for the given image.
| Name | Type | Description |
|---|---|---|
| $imageName | ||
| $other_attributes | string | optional, other attributes to add to the image tag, not cached |
| $width | string | optional, defaults to the actual image's width |
| $height | string | optional, defaults to the actual image's height |
| $ext | string | optional, image extension (TODO can we deprecate this one ?) |
| $alt | string | optional, only used when image contains something useful, i.e. "Sally's profile pic" |
| Type | Description |
|---|---|
| string | HTML image tag or sprite |

getImageURL(
string $imageName, bool $addJSPath
=
true
)
:
stringReturns the URL for an image in the current theme. If not found in the current theme, will revert to looking in the base theme.
| Name | Type | Description |
|---|---|---|
| $imageName | string | image file name |
| $addJSPath | bool | call getJSPath() with the results to add some unique image tracking support |
| Type | Description |
|---|---|
| string | path to image |

getJSPath(
)
:
stringReturns the javascript path of the current theme
| Type | Description |
|---|---|
| string |

getJSURL(
string $jsFileName, bool $returnURL
=
true
)
:
stringReturns the URL for an image in the current theme. If not found in the current theme, will revert to looking in the base theme.
| Name | Type | Description |
|---|---|---|
| $jsFileName | string | js file name |
| $returnURL | bool | if true, returns URL with unique image mark, otherwise returns path to the file |
| Type | Description |
|---|---|
| string | path to js file |

getLink(
$url, $title, $other_attributes
=
'', $img_name
=
'', $img_other_attributes
=
'', $img_width
=
null, $img_height
=
null, $img_alt
=
'', $img_placement
=
'imageonly'
)
:
voidReturns a link HTML tag with or without an embedded image
| Name | Type | Description |
|---|---|---|
| $url | ||
| $title | ||
| $other_attributes | ||
| $img_name | ||
| $img_other_attributes | ||
| $img_width | ||
| $img_height | ||
| $img_alt | ||
| $img_placement |

getSprite(
string $class, string $attr, string $title
)
:
stringReturns sprite HTML span tag
| Name | Type | Description |
|---|---|---|
| $class | string | class The md5 id used in the CSS sprites class |
| $attr | string | attr optional, list of additional html attributes |
| $title | string | title optional, the title (equivalent to alt on img) |
| Type | Description |
|---|---|
| string | HTML span tag |

getSpriteMeta(
string $imageName
)
:
arrayReturns sprite meta data
| Name | Type | Description |
|---|---|---|
| $imageName | string | Image filename including extension |
| Type | Description |
|---|---|
| array | Sprite meta data |

getTemplate(
string $templateName
)
:
stringReturns the path for the tpl file in the current theme. If not found in the current theme, will revert to looking in the base theme.
| Name | Type | Description |
|---|---|---|
| $templateName | string | tpl file name |
| Type | Description |
|---|---|
| string | path of tpl file to include |

getTemplatePath(
)
:
stringReturns the tpl path of the current theme
| Type | Description |
|---|---|
| string |
\SugarThemeRegistry
Registry for all the current classes in the system
Properties

string
$_currentTheme= ''
Name of the current theme; corresponds to an index key in SugarThemeRegistry::$_themes
- Type
- string
Methods

add(
\$themedef $themedef
)
:
voidAdds a new theme to the registry
| Name | Type | Description |
|---|---|---|
| $themedef | \$themedef | array |

allThemes(
)
:
arrayReturns an array of all themes found in the current installation
| Type | Description |
|---|---|
| array |

availableThemes(
)
:
arrayReturns an array of available themes. Designed to be absorbed into get_select_options_with_id()
| Type | Description |
|---|---|
| array |

current(
)
:
\SugarThemeReturns the current theme object
| Type | Description |
|---|---|
| \SugarTheme | object |

exists(
\$themeName $themeName
)
:
boolReturns true if a theme object specified by the given $themeName exists in the registry
| Name | Type | Description |
|---|---|---|
| $themeName | \$themeName | string |
| Type | Description |
|---|---|
| bool |

get(
\$themeName $themeName
)
:
voidReturns a theme object in the registry specified by the given $themeName
| Name | Type | Description |
|---|---|---|
| $themeName | \$themeName | string |

getDefault(
)
:
\SugarThemeReturns the default theme object
| Type | Description |
|---|---|
| \SugarTheme | object |

getDefaultThemeKey(
)
:
\$defaultThemeKeygetDefaultThemeKey
This function returns the default theme key. It takes into account string casing issues that may arise from upgrades. It attempts to look for the Sugar theme and if not found, defaults to return the name of the last theme in the array of available themes loaded.
| Type | Description |
|---|---|
| \$defaultThemeKey | String value of the default theme key to use |

remove(
\$themeName $themeName
)
:
voidRemoves a new theme from the registry
| Name | Type | Description |
|---|---|---|
| $themeName | \$themeName | string |

set(
\$themeName $themeName
)
:
voidSets the given $themeName to be the current theme
| Name | Type | Description |
|---|---|---|
| $themeName | \$themeName | string |