include/SugarTheme/SugarTheme.php

Show: inherited
Table of Contents

Constants

Constant  JSMIN_AS_LIB = true

\SugarTheme

Package: SugarCRM

Class that provides tools for working with a theme.

Api
 

Properties

Propertyprivate  $_clearCacheOnDestroy= 'false'

Controls whether or not to clear the cache on destroy; defaults to false

Default valuefalseDetails
Type
n/a
Propertyprivatearray  $_cssCache= 'array()'

Cache built of all css files locations

Default valuearray()Details
Type
array
Propertyprivatearray  $_imageCache= 'array()'

Cache built of all image files locations

Default valuearray()Details
Type
array
Propertyprivatearray  $_initialCacheSize= 'array( 'cssCache' => 0, 'imageCache' => 0, 'jsCache' => 0, 'templateCache' => 0, 'spriteCache' => 0, )'

Size of the caches after the are initialized in the constructor

Default valuearray( 'cssCache' => 0, 'imageCache' => 0, 'jsCache' => 0, 'templateCache' => 0, 'spriteCache' => 0, )Details
Type
array
Propertyprivatearray  $_jsCache= 'array()'

Cache built of all javascript files locations

Default valuearray()Details
Type
array
Propertyprivatearray  $_spriteCache= 'array()'

Cache built of sprite meta data

Default valuearray()Details
Type
array
Propertyprivatearray  $_templateCache= 'array()'

Cache built of all template files locations

Default valuearray()Details
Type
array
Propertyprotectedarray  $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

Default valuearray( "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
Propertyprotectedarray  $colors= 'array()'

Colors sets provided by the theme

Default valuearray()Details
Type
array
Deprecated
only here for BC during upgrades  
Propertyprotectedstring  $description= ''

Theme description

Details
Type
string
Propertyprotectedstring  $dirName= ''

Theme directory name

Details
Type
string
Propertypublicstring  $directionality= ''ltr''

Defines which parent files to not include

Default value'ltr'Details
Type
string
Propertyprotectedarray  $fonts= 'array()'

Font sets provided by the theme

Default valuearray()Details
Type
array
Deprecated
only here for BC during upgrades  
Propertypublicbool  $group_tabs= ''

Does this theme support group tabs

Details
Type
bool
Propertyprotectedstring  $ignoreParentFiles= 'array()'

Defines which parent files to not include

Default valuearray()Details
Type
string
Propertyprivate  $imageExtensions= 'array( 'gif', 'png', 'jpg', 'tif', 'bmp', )'
Default valuearray( 'gif', 'png', 'jpg', 'tif', 'bmp', )Details
Type
n/a
Propertyprotectedstring  $name= ''

Theme name

Details
Type
string
Propertyprotectedstring  $parentTheme= ''

Parent theme name

Details
Type
string
Propertyprotectedarray  $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

Default valuearray( "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
Propertyprotectedint  $version= ''5.5.1''

Maximum sugar version this theme is for; defaults to 5.5.1 as all the themes without this parameter as assumed to work thru 5.5.1

Default value'5.5.1'Details
Type
int

Methods

methodpublic__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

Parameters
Name Type Description
$defaults \$defaults

string defaults for the current theme

methodpublic__destruct( ) : void

Destructor Here we'll write out the internal file path caches to an external cache of some sort.

methodpublic__get(  $key ) : string

Generic public accessor method for all the properties of the theme ( which are kept protected )

Parameters
Name Type Description
$key
Returns
Type Description
string
methodpublic__isset(  $key ) : void

Parameters
Name Type Description
$key
methodpublic__toString( ) : string

Specifies what is returned when the object is cast to a string, in this case it will be the theme directory name.

Returns
Type Description
string theme directory name
methodpublic__wakeup( ) : void

This is needed to prevent unserialize vulnerability

methodprotected_getImageFileName( string $imageName ) : string

Checks for an image using all of the accepted image extensions

Parameters
Name Type Description
$imageName string

image file name

Returns
Type Description
string path to image
methodpublicclearCache( ) : void

Clears out the caches used for this themes

methodpublicclearJSCache( ) : void

methodpublicgetAllImages( ) : array

Returns an array of all of the images available for the current theme

Returns
Type Description
array
methodpublicgetCSS( \$color $color = null, \$font $font = null ) : string

Returns CSS for the current theme.

Parameters
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

Returns
Type Description
string HTML code
methodpublicgetCSSPath( ) : string

Returns the css path of the current theme

Returns
Type Description
string
methodpublicgetCSSURL( 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.

Parameters
Name Type Description
$cssFileName string

css file name

$returnURL bool

if true, returns URL with unique image mark, otherwise returns path to the file

Returns
Type Description
string path of css file to include
methodpublicgetDefaultCSSPath( ) : string
final

Returns the css path of the theme defaults

Returns
Type Description
string
methodpublicgetDefaultFilePath( ) : string
final

Returns the file path of the theme defaults

Returns
Type Description
string
methodpublicgetDefaultImagePath( ) : string
final

Returns the image path of the theme defaults

Returns
Type Description
string
methodpublicgetDefaultJSPath( ) : string
final

Returns the javascript path of the theme defaults

Returns
Type Description
string
methodpublicgetDefaultTemplatePath( ) : string
final

Returns the template path of the theme defaults

Returns
Type Description
string
methodpublicgetFilePath( ) : string

Returns the file path of the current theme

Returns
Type Description
string
methodpublicgetImage(  $imageName, string $other_attributes = '', string $width = null, string $height = null, string $ext = null, string $alt = '' ) : string

Returns an image tag for the given image.

Parameters
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"

Returns
Type Description
string HTML image tag or sprite
methodpublicgetImagePath( ) : string

Returns the image path of the current theme

Returns
Type Description
string
methodpublicgetImageURL( 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.

Parameters
Name Type Description
$imageName string

image file name

$addJSPath bool

call getJSPath() with the results to add some unique image tracking support

Returns
Type Description
string path to image
methodpublicgetJS( ) : string

Returns javascript for the current theme

Returns
Type Description
string HTML code
methodpublicgetJSPath( ) : string

Returns the javascript path of the current theme

Returns
Type Description
string
methodpublicgetJSURL( 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.

Parameters
Name Type Description
$jsFileName string

js file name

$returnURL bool

if true, returns URL with unique image mark, otherwise returns path to the file

Returns
Type Description
string path to js file
methodpublicgetLink(  $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

Parameters
Name Type Description
$url
$title
$other_attributes
$img_name
$img_other_attributes
$img_width
$img_height
$img_alt
$img_placement
methodpublicgetSprite( string $class, string $attr, string $title ) : string

Returns sprite HTML span tag

Parameters
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)

Returns
Type Description
string HTML span tag
methodpublicgetSpriteMeta( string $imageName ) : array

Returns sprite meta data

Parameters
Name Type Description
$imageName string

Image filename including extension

Returns
Type Description
array Sprite meta data
methodpublicgetTemplate( 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.

Parameters
Name Type Description
$templateName string

tpl file name

Returns
Type Description
string path of tpl file to include
methodpublicgetTemplatePath( ) : string

Returns the tpl path of the current theme

Returns
Type Description
string
methodpublicgetThemeDefFields( ) : array
static

Return array of all valid fields that can be specified in the themedef.php file

Returns
Type Description
array

\SugarThemeRegistry

Package: SugarCRM

Registry for all the current classes in the system

Properties

Propertyprivatestring  $_currentTheme= ''
static

Name of the current theme; corresponds to an index key in SugarThemeRegistry::$_themes

Details
Type
string
Propertyprivatearray  $_themes= 'array()'
static

Array of all themes and thier object

Default valuearray()Details
Type
array

Methods

methodprivate__construct( ) : void

Disable the constructor since this will be a singleton

methodpublicadd( \$themedef $themedef ) : void
static

Adds a new theme to the registry

Parameters
Name Type Description
$themedef \$themedef

array

methodpublicallThemes( ) : array
static

Returns an array of all themes found in the current installation

Returns
Type Description
array
methodpublicavailableThemes( ) : array
static

Returns an array of available themes. Designed to be absorbed into get_select_options_with_id()

Returns
Type Description
array
methodpublicbuildRegistry( ) : void
static

Builds the theme registry

methodpublicclearAllCaches( ) : void
static

Clears out the cached path locations for all themes

methodpubliccurrent( ) : \SugarTheme
static

Returns the current theme object

Returns
Type Description
\SugarTheme object
methodpublicexists( \$themeName $themeName ) : bool
static

Returns true if a theme object specified by the given $themeName exists in the registry

Parameters
Name Type Description
$themeName \$themeName

string

Returns
Type Description
bool
methodpublicget( \$themeName $themeName ) : void
static

Returns a theme object in the registry specified by the given $themeName

Parameters
Name Type Description
$themeName \$themeName

string

methodpublicgetDefault( ) : \SugarTheme
static

Returns the default theme object

Returns
Type Description
\SugarTheme object
methodprivategetDefaultThemeKey( ) : \$defaultThemeKey
static

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.

Returns
Type Description
\$defaultThemeKey String value of the default theme key to use
methodpublicremove( \$themeName $themeName ) : void
static

Removes a new theme from the registry

Parameters
Name Type Description
$themeName \$themeName

string

methodpublicset( \$themeName $themeName ) : void
static

Sets the given $themeName to be the current theme

Parameters
Name Type Description
$themeName \$themeName

string

methodpublicunAvailableThemes( ) : array
static

Returns an array of un-available themes. Designed used with the theme selector in the admin panel

Returns
Type Description
array
Documentation was generated by DocBlox 0.18.1.