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
false
Details- 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
)
:
void
Constructor
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(
)
:
void
Destructor Here we'll write out the internal file path caches to an external cache of some sort.
__get(
$key
)
:
string
Generic public accessor method for all the properties of the theme ( which are kept protected )
Name | Type | Description |
---|---|---|
$key |
Type | Description |
---|---|
string |
__toString(
)
:
string
Specifies 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
)
:
string
Checks 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(
)
:
array
Returns an array of all of the images available for the current theme
Type | Description |
---|---|
array |
getCSS(
\$color $color
=
null, \$font $font
=
null
)
:
string
Returns 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
)
:
string
Returns 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(
)
:
string
Returns the css path of the theme defaults
Type | Description |
---|---|
string |
getDefaultFilePath(
)
:
string
Returns the file path of the theme defaults
Type | Description |
---|---|
string |
getDefaultImagePath(
)
:
string
Returns the image path of the theme defaults
Type | Description |
---|---|
string |
getDefaultJSPath(
)
:
string
Returns the javascript path of the theme defaults
Type | Description |
---|---|
string |
getDefaultTemplatePath(
)
:
string
Returns 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
=
''
)
:
string
Returns 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
)
:
string
Returns 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(
)
:
string
Returns the javascript path of the current theme
Type | Description |
---|---|
string |
getJSURL(
string $jsFileName, bool $returnURL
=
true
)
:
string
Returns 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'
)
:
void
Returns 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
)
:
string
Returns 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
)
:
array
Returns sprite meta data
Name | Type | Description |
---|---|---|
$imageName | string | Image filename including extension |
Type | Description |
---|---|
array | Sprite meta data |
getTemplate(
string $templateName
)
:
string
Returns 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(
)
:
string
Returns 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
)
:
void
Adds a new theme to the registry
Name | Type | Description |
---|---|---|
$themedef | \$themedef | array |
allThemes(
)
:
array
Returns an array of all themes found in the current installation
Type | Description |
---|---|
array |
availableThemes(
)
:
array
Returns an array of available themes. Designed to be absorbed into get_select_options_with_id()
Type | Description |
---|---|
array |
current(
)
:
\SugarTheme
Returns the current theme object
Type | Description |
---|---|
\SugarTheme | object |
exists(
\$themeName $themeName
)
:
bool
Returns 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
)
:
void
Returns a theme object in the registry specified by the given $themeName
Name | Type | Description |
---|---|---|
$themeName | \$themeName | string |
getDefault(
)
:
\SugarTheme
Returns the default theme object
Type | Description |
---|---|
\SugarTheme | object |
getDefaultThemeKey(
)
:
\$defaultThemeKey
getDefaultThemeKey
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
)
:
void
Removes a new theme from the registry
Name | Type | Description |
---|---|---|
$themeName | \$themeName | string |
set(
\$themeName $themeName
)
:
void
Sets the given $themeName to be the current theme
Name | Type | Description |
---|---|---|
$themeName | \$themeName | string |