@@ -246,12 +246,12 @@ discard block |
||
246 | 246 | */ |
247 | 247 | private $_templateCache = array(); |
248 | 248 | |
249 | - /** |
|
250 | - * Cache built of sprite meta data |
|
251 | - * |
|
252 | - * @var array |
|
253 | - */ |
|
254 | - private $_spriteCache = array(); |
|
249 | + /** |
|
250 | + * Cache built of sprite meta data |
|
251 | + * |
|
252 | + * @var array |
|
253 | + */ |
|
254 | + private $_spriteCache = array(); |
|
255 | 255 | |
256 | 256 | /** |
257 | 257 | * Size of the caches after the are initialized in the constructor |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | 'imageCache' => 0, |
264 | 264 | 'jsCache' => 0, |
265 | 265 | 'templateCache' => 0, |
266 | - 'spriteCache' => 0, |
|
266 | + 'spriteCache' => 0, |
|
267 | 267 | ); |
268 | 268 | |
269 | 269 | /** |
@@ -329,21 +329,21 @@ discard block |
||
329 | 329 | $this->_templateCache = $caches['templateCache']; |
330 | 330 | } |
331 | 331 | $cachedfile = sugar_cached($this->getFilePath().'/spriteCache.php'); |
332 | - if(!empty($GLOBALS['sugar_config']['use_sprites']) && sugar_is_file($cachedfile)) { |
|
333 | - $this->_spriteCache = unserialize(sugar_file_get_contents($cachedfile)); |
|
334 | - } |
|
332 | + if(!empty($GLOBALS['sugar_config']['use_sprites']) && sugar_is_file($cachedfile)) { |
|
333 | + $this->_spriteCache = unserialize(sugar_file_get_contents($cachedfile)); |
|
334 | + } |
|
335 | 335 | } |
336 | 336 | $this->_initialCacheSize = array( |
337 | 337 | 'jsCache' => count($this->_jsCache), |
338 | 338 | 'cssCache' => count($this->_cssCache), |
339 | 339 | 'imageCache' => count($this->_imageCache), |
340 | 340 | 'templateCache' => count($this->_templateCache), |
341 | - 'spriteCache' => count($this->_spriteCache), |
|
341 | + 'spriteCache' => count($this->_spriteCache), |
|
342 | 342 | ); |
343 | 343 | } |
344 | 344 | |
345 | 345 | /** |
346 | - * This is needed to prevent unserialize vulnerability |
|
346 | + * This is needed to prevent unserialize vulnerability |
|
347 | 347 | */ |
348 | 348 | public function __wakeup() |
349 | 349 | { |
@@ -380,8 +380,8 @@ discard block |
||
380 | 380 | |
381 | 381 | if (is_file("$cachedir/pathCache.php")) |
382 | 382 | unlink("$cachedir/pathCache.php"); |
383 | - if (is_file("$cachedir/spriteCache.php")) |
|
384 | - unlink("$cachedir/spriteCache.php"); |
|
383 | + if (is_file("$cachedir/spriteCache.php")) |
|
384 | + unlink("$cachedir/spriteCache.php"); |
|
385 | 385 | |
386 | 386 | } |
387 | 387 | elseif ( !inDeveloperMode() ) { |
@@ -404,12 +404,12 @@ discard block |
||
404 | 404 | ); |
405 | 405 | |
406 | 406 | } |
407 | - if ( count($this->_spriteCache) != $this->_initialCacheSize['spriteCache']) { |
|
408 | - sugar_file_put_contents( |
|
409 | - "$cachedir/spriteCache.php", |
|
410 | - serialize($this->_spriteCache) |
|
411 | - ); |
|
412 | - } |
|
407 | + if ( count($this->_spriteCache) != $this->_initialCacheSize['spriteCache']) { |
|
408 | + sugar_file_put_contents( |
|
409 | + "$cachedir/spriteCache.php", |
|
410 | + serialize($this->_spriteCache) |
|
411 | + ); |
|
412 | + } |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | } |
439 | 439 | |
440 | 440 | public function __isset($key){ |
441 | - return isset($this->$key); |
|
441 | + return isset($this->$key); |
|
442 | 442 | |
443 | 443 | } |
444 | 444 | |
@@ -603,27 +603,27 @@ discard block |
||
603 | 603 | $html .= '<link rel="stylesheet" type="text/css" href="'.$this->getCSSURL('style.css').'" />'; |
604 | 604 | |
605 | 605 | |
606 | - // sprites |
|
607 | - if(!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) { |
|
606 | + // sprites |
|
607 | + if(!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) { |
|
608 | 608 | |
609 | - // system wide sprites |
|
610 | - if(file_exists("cache/sprites/default/sprites.css")) |
|
611 | - $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/default/sprites.css').'" />'; |
|
609 | + // system wide sprites |
|
610 | + if(file_exists("cache/sprites/default/sprites.css")) |
|
611 | + $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/default/sprites.css').'" />'; |
|
612 | 612 | |
613 | - // theme specific sprites |
|
614 | - if(file_exists("cache/sprites/{$this->dirName}/sprites.css")) |
|
615 | - $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/'.$this->dirName.'/sprites.css').'" />'; |
|
613 | + // theme specific sprites |
|
614 | + if(file_exists("cache/sprites/{$this->dirName}/sprites.css")) |
|
615 | + $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/'.$this->dirName.'/sprites.css').'" />'; |
|
616 | 616 | |
617 | - // parent sprites |
|
618 | - if($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) { |
|
619 | - if(file_exists("cache/sprites/{$parent->dirName}/sprites.css")) |
|
620 | - $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/'.$parent->dirName.'/sprites.css').'" />'; |
|
621 | - } |
|
617 | + // parent sprites |
|
618 | + if($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) { |
|
619 | + if(file_exists("cache/sprites/{$parent->dirName}/sprites.css")) |
|
620 | + $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/'.$parent->dirName.'/sprites.css').'" />'; |
|
621 | + } |
|
622 | 622 | |
623 | - // repeatable sprites |
|
624 | - if(file_exists("cache/sprites/Repeatable/sprites.css")) |
|
625 | - $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/Repeatable/sprites.css').'" />'; |
|
626 | - } |
|
623 | + // repeatable sprites |
|
624 | + if(file_exists("cache/sprites/Repeatable/sprites.css")) |
|
625 | + $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/Repeatable/sprites.css').'" />'; |
|
626 | + } |
|
627 | 627 | |
628 | 628 | // for BC during upgrade |
629 | 629 | if ( !empty($this->colors) ) { |
@@ -700,180 +700,180 @@ discard block |
||
700 | 700 | * |
701 | 701 | * @param string $image image name |
702 | 702 | * @param string $other_attributes optional, other attributes to add to the image tag, not cached |
703 | - * @param string $width optional, defaults to the actual image's width |
|
704 | - * @param string $height optional, defaults to the actual image's height |
|
705 | - * @param string $ext optional, image extension (TODO can we deprecate this one ?) |
|
703 | + * @param string $width optional, defaults to the actual image's width |
|
704 | + * @param string $height optional, defaults to the actual image's height |
|
705 | + * @param string $ext optional, image extension (TODO can we deprecate this one ?) |
|
706 | 706 | * @param string $alt optional, only used when image contains something useful, i.e. "Sally's profile pic" |
707 | 707 | * @return string HTML image tag or sprite |
708 | 708 | */ |
709 | 709 | public function getImage( |
710 | 710 | $imageName, |
711 | 711 | $other_attributes = '', |
712 | - $width = null, |
|
713 | - $height = null, |
|
714 | - $ext = null, |
|
712 | + $width = null, |
|
713 | + $height = null, |
|
714 | + $ext = null, |
|
715 | 715 | $alt = '' |
716 | 716 | ) |
717 | 717 | { |
718 | 718 | |
719 | 719 | static $cached_results = array(); |
720 | 720 | |
721 | - // trap deprecated use of image extension |
|
722 | - if(is_null($ext)) { |
|
723 | - $imageNameExp = explode('.',$imageName); |
|
724 | - if(count($imageNameExp) == 1) |
|
725 | - $imageName .= '.gif'; |
|
726 | - } else { |
|
727 | - $imageName .= $ext; |
|
728 | - } |
|
729 | - |
|
730 | - // trap alt attributes in other_attributes |
|
731 | - if(preg_match('/alt=["\']([^\'"]+)["\']/i', $other_attributes)) |
|
732 | - $GLOBALS['log']->debug("Sprites: alt attribute detected for $imageName"); |
|
733 | - // sprite handler, makes use of own caching mechanism |
|
734 | - if(!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) { |
|
735 | - // get sprite metadata |
|
736 | - if($sp = $this->getSpriteMeta($imageName)) { |
|
737 | - // requested size should match |
|
738 | - if( (!is_null($width) && $sp['width'] == $width) || (is_null($width)) && |
|
739 | - (!is_null($height) && $sp['height'] == $height) || (is_null($height)) ) |
|
740 | - { |
|
721 | + // trap deprecated use of image extension |
|
722 | + if(is_null($ext)) { |
|
723 | + $imageNameExp = explode('.',$imageName); |
|
724 | + if(count($imageNameExp) == 1) |
|
725 | + $imageName .= '.gif'; |
|
726 | + } else { |
|
727 | + $imageName .= $ext; |
|
728 | + } |
|
729 | + |
|
730 | + // trap alt attributes in other_attributes |
|
731 | + if(preg_match('/alt=["\']([^\'"]+)["\']/i', $other_attributes)) |
|
732 | + $GLOBALS['log']->debug("Sprites: alt attribute detected for $imageName"); |
|
733 | + // sprite handler, makes use of own caching mechanism |
|
734 | + if(!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) { |
|
735 | + // get sprite metadata |
|
736 | + if($sp = $this->getSpriteMeta($imageName)) { |
|
737 | + // requested size should match |
|
738 | + if( (!is_null($width) && $sp['width'] == $width) || (is_null($width)) && |
|
739 | + (!is_null($height) && $sp['height'] == $height) || (is_null($height)) ) |
|
740 | + { |
|
741 | 741 | $other_attributes .= ' data-orig="'.$imageName.'"'; |
742 | 742 | |
743 | - if($sprite = $this->getSprite($sp['class'], $other_attributes, $alt)) |
|
744 | - { |
|
745 | - return $sprite; |
|
746 | - } |
|
747 | - } |
|
748 | - } |
|
749 | - } |
|
750 | - |
|
751 | - // img caching |
|
752 | - if(empty($cached_results[$imageName])) { |
|
753 | - $imageURL = $this->getImageURL($imageName,false); |
|
754 | - if ( empty($imageURL) ) |
|
755 | - return false; |
|
743 | + if($sprite = $this->getSprite($sp['class'], $other_attributes, $alt)) |
|
744 | + { |
|
745 | + return $sprite; |
|
746 | + } |
|
747 | + } |
|
748 | + } |
|
749 | + } |
|
750 | + |
|
751 | + // img caching |
|
752 | + if(empty($cached_results[$imageName])) { |
|
753 | + $imageURL = $this->getImageURL($imageName,false); |
|
754 | + if ( empty($imageURL) ) |
|
755 | + return false; |
|
756 | 756 | if(strpos($imageURL, '.svg', strlen($imageURL)-4)){ |
757 | 757 | $cached_results[$imageName] = file_get_contents($imageURL); |
758 | 758 | } else { |
759 | 759 | $cached_results[$imageName] = '<img src="'.getJSPath($imageURL).'" '; |
760 | 760 | } |
761 | 761 | |
762 | - } |
|
762 | + } |
|
763 | 763 | |
764 | - $attr_width = (is_null($width)) ? "" : "width=\"$width\""; |
|
765 | - $attr_height = (is_null($height)) ? "" : "height=\"$height\""; |
|
764 | + $attr_width = (is_null($width)) ? "" : "width=\"$width\""; |
|
765 | + $attr_height = (is_null($height)) ? "" : "height=\"$height\""; |
|
766 | 766 | |
767 | 767 | if(strpos($cached_results[$imageName], 'svg') !== false){ |
768 | 768 | return $cached_results[$imageName]; |
769 | 769 | } |
770 | - return $cached_results[$imageName] . " $attr_width $attr_height $other_attributes alt=\"$alt\" />"; |
|
770 | + return $cached_results[$imageName] . " $attr_width $attr_height $other_attributes alt=\"$alt\" />"; |
|
771 | + } |
|
772 | + |
|
773 | + /** |
|
774 | + * Returns sprite meta data |
|
775 | + * |
|
776 | + * @param string $imageName Image filename including extension |
|
777 | + * @return array Sprite meta data |
|
778 | + */ |
|
779 | + public function getSpriteMeta($imageName) { |
|
780 | + |
|
781 | + // return from cache |
|
782 | + if(isset($this->_spriteCache[$imageName])) |
|
783 | + return $this->_spriteCache[$imageName]; |
|
784 | + |
|
785 | + // sprite keys are base on imageURL |
|
786 | + $imageURL = $this->getImageURL($imageName,false); |
|
787 | + if(empty($imageURL)) { |
|
788 | + $this->_spriteCache[$imageName] = false; |
|
789 | + return false; |
|
790 | + } |
|
791 | + |
|
792 | + // load meta data, includes default images |
|
793 | + require_once("include/SugarTheme/SugarSprites.php"); |
|
794 | + $meta = SugarSprites::getInstance(); |
|
795 | + // add current theme dir |
|
796 | + $meta->loadSpriteMeta($this->dirName); |
|
797 | + // add parent theme dir |
|
798 | + if($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) { |
|
799 | + $meta->loadSpriteMeta($parent->dirName); |
|
800 | + } |
|
801 | + |
|
802 | + // add to cache |
|
803 | + if(isset($meta->sprites[$imageURL])) { |
|
804 | + $this->_spriteCache[$imageName] = $meta->sprites[$imageURL]; |
|
805 | + // add imageURL to cache |
|
806 | + //$this->_spriteCache[$imageName]['imageURL'] = $imageURL; |
|
807 | + } else { |
|
808 | + $this->_spriteCache[$imageName] = false; |
|
809 | + $GLOBALS['log']->debug("Sprites: miss for $imageURL"); |
|
810 | + } |
|
811 | + return $this->_spriteCache[$imageName]; |
|
812 | + } |
|
813 | + |
|
814 | + /** |
|
815 | + * Returns sprite HTML span tag |
|
816 | + * |
|
817 | + * @param string class The md5 id used in the CSS sprites class |
|
818 | + * @param string attr optional, list of additional html attributes |
|
819 | + * @param string title optional, the title (equivalent to alt on img) |
|
820 | + * @return string HTML span tag |
|
821 | + */ |
|
822 | + public function getSprite($class, $attr, $title) { |
|
823 | + |
|
824 | + // handle multiple class tags |
|
825 | + $class_regex = '/class=["\']([^\'"]+)["\']/i'; |
|
826 | + preg_match($class_regex, $attr, $match); |
|
827 | + if(isset($match[1])) { |
|
828 | + $attr = preg_replace($class_regex, 'class="spr_'.$class.' ${1}"', $attr); |
|
829 | + |
|
830 | + // single class |
|
831 | + } else { |
|
832 | + $attr .= ' class="spr_'.$class.'"'; |
|
833 | + } |
|
834 | + |
|
835 | + if($title) |
|
836 | + $attr .= ' title="'.$title.'"'; |
|
837 | + |
|
838 | + // use </span> instead of /> to prevent weird UI results |
|
839 | + $GLOBALS['log']->debug("Sprites: generated sprite -> $attr"); |
|
840 | + return "<span {$attr}></span>"; |
|
771 | 841 | } |
772 | 842 | |
773 | - /** |
|
774 | - * Returns sprite meta data |
|
775 | - * |
|
776 | - * @param string $imageName Image filename including extension |
|
777 | - * @return array Sprite meta data |
|
778 | - */ |
|
779 | - public function getSpriteMeta($imageName) { |
|
780 | - |
|
781 | - // return from cache |
|
782 | - if(isset($this->_spriteCache[$imageName])) |
|
783 | - return $this->_spriteCache[$imageName]; |
|
784 | - |
|
785 | - // sprite keys are base on imageURL |
|
786 | - $imageURL = $this->getImageURL($imageName,false); |
|
787 | - if(empty($imageURL)) { |
|
788 | - $this->_spriteCache[$imageName] = false; |
|
789 | - return false; |
|
790 | - } |
|
791 | - |
|
792 | - // load meta data, includes default images |
|
793 | - require_once("include/SugarTheme/SugarSprites.php"); |
|
794 | - $meta = SugarSprites::getInstance(); |
|
795 | - // add current theme dir |
|
796 | - $meta->loadSpriteMeta($this->dirName); |
|
797 | - // add parent theme dir |
|
798 | - if($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) { |
|
799 | - $meta->loadSpriteMeta($parent->dirName); |
|
800 | - } |
|
801 | - |
|
802 | - // add to cache |
|
803 | - if(isset($meta->sprites[$imageURL])) { |
|
804 | - $this->_spriteCache[$imageName] = $meta->sprites[$imageURL]; |
|
805 | - // add imageURL to cache |
|
806 | - //$this->_spriteCache[$imageName]['imageURL'] = $imageURL; |
|
807 | - } else { |
|
808 | - $this->_spriteCache[$imageName] = false; |
|
809 | - $GLOBALS['log']->debug("Sprites: miss for $imageURL"); |
|
810 | - } |
|
811 | - return $this->_spriteCache[$imageName]; |
|
812 | - } |
|
813 | - |
|
814 | - /** |
|
815 | - * Returns sprite HTML span tag |
|
816 | - * |
|
817 | - * @param string class The md5 id used in the CSS sprites class |
|
818 | - * @param string attr optional, list of additional html attributes |
|
819 | - * @param string title optional, the title (equivalent to alt on img) |
|
820 | - * @return string HTML span tag |
|
821 | - */ |
|
822 | - public function getSprite($class, $attr, $title) { |
|
823 | - |
|
824 | - // handle multiple class tags |
|
825 | - $class_regex = '/class=["\']([^\'"]+)["\']/i'; |
|
826 | - preg_match($class_regex, $attr, $match); |
|
827 | - if(isset($match[1])) { |
|
828 | - $attr = preg_replace($class_regex, 'class="spr_'.$class.' ${1}"', $attr); |
|
829 | - |
|
830 | - // single class |
|
831 | - } else { |
|
832 | - $attr .= ' class="spr_'.$class.'"'; |
|
833 | - } |
|
834 | - |
|
835 | - if($title) |
|
836 | - $attr .= ' title="'.$title.'"'; |
|
837 | - |
|
838 | - // use </span> instead of /> to prevent weird UI results |
|
839 | - $GLOBALS['log']->debug("Sprites: generated sprite -> $attr"); |
|
840 | - return "<span {$attr}></span>"; |
|
841 | - } |
|
842 | - |
|
843 | - /** |
|
844 | - * Returns a link HTML tag with or without an embedded image |
|
845 | - */ |
|
843 | + /** |
|
844 | + * Returns a link HTML tag with or without an embedded image |
|
845 | + */ |
|
846 | 846 | public function getLink( |
847 | - $url, |
|
848 | - $title, |
|
849 | - $other_attributes = '', |
|
847 | + $url, |
|
848 | + $title, |
|
849 | + $other_attributes = '', |
|
850 | 850 | $img_name = '', |
851 | 851 | $img_other_attributes = '', |
852 | - $img_width = null, |
|
853 | - $img_height = null, |
|
854 | - $img_alt = '', |
|
855 | - $img_placement = 'imageonly' |
|
852 | + $img_width = null, |
|
853 | + $img_height = null, |
|
854 | + $img_alt = '', |
|
855 | + $img_placement = 'imageonly' |
|
856 | 856 | ) |
857 | 857 | { |
858 | 858 | |
859 | - if($img_name) { |
|
860 | - $img = $this->getImage($img_name, $img_other_attributes, $img_width, $img_height, null, $img_alt); |
|
861 | - if($img == false) { |
|
862 | - $GLOBALS['log']->debug('Sprites: unknown image getLink'); |
|
863 | - $img = 'unknown'; |
|
864 | - } |
|
865 | - switch($img_placement) { |
|
866 | - case 'left': $inner_html = $img."<span class='title'>".$title."</span>"; break; |
|
867 | - case 'right': $inner_html = "<span class='title'>".$title."</span>".$img; break; |
|
868 | - default: $inner_html = $img; break; |
|
869 | - } |
|
870 | - } else { |
|
871 | - $inner_html = $title; |
|
872 | - } |
|
859 | + if($img_name) { |
|
860 | + $img = $this->getImage($img_name, $img_other_attributes, $img_width, $img_height, null, $img_alt); |
|
861 | + if($img == false) { |
|
862 | + $GLOBALS['log']->debug('Sprites: unknown image getLink'); |
|
863 | + $img = 'unknown'; |
|
864 | + } |
|
865 | + switch($img_placement) { |
|
866 | + case 'left': $inner_html = $img."<span class='title'>".$title."</span>"; break; |
|
867 | + case 'right': $inner_html = "<span class='title'>".$title."</span>".$img; break; |
|
868 | + default: $inner_html = $img; break; |
|
869 | + } |
|
870 | + } else { |
|
871 | + $inner_html = $title; |
|
872 | + } |
|
873 | 873 | |
874 | - return '<a href="'.$url.'" title="'.$title.'" '.$other_attributes.'>'.$inner_html.'</a>'; |
|
874 | + return '<a href="'.$url.'" title="'.$title.'" '.$other_attributes.'>'.$inner_html.'</a>'; |
|
875 | 875 | |
876 | - } |
|
876 | + } |
|
877 | 877 | |
878 | 878 | /** |
879 | 879 | * Returns the URL for an image in the current theme. If not found in the current theme, will revert |
@@ -905,8 +905,8 @@ discard block |
||
905 | 905 | $imagePath = $filename; |
906 | 906 | elseif (($filename = $this->_getImageFileName($this->getDefaultImagePath().'/'.$imageName)) != '') |
907 | 907 | $imagePath = $filename; |
908 | - elseif (($filename = $this->_getImageFileName('include/images/'.$imageName)) != '') |
|
909 | - $imagePath = $filename; |
|
908 | + elseif (($filename = $this->_getImageFileName('include/images/'.$imageName)) != '') |
|
909 | + $imagePath = $filename; |
|
910 | 910 | else { |
911 | 911 | $GLOBALS['log']->warn("Image $imageName not found"); |
912 | 912 | return false; |
@@ -1040,8 +1040,8 @@ discard block |
||
1040 | 1040 | if (isset($this->parentTheme) |
1041 | 1041 | && SugarThemeRegistry::get($this->parentTheme) instanceOf SugarTheme |
1042 | 1042 | && ($filename = SugarThemeRegistry::get($this->parentTheme)->getJSURL($jsFileName,false)) != '' && !in_array($jsFileName,$this->ignoreParentFiles)) { |
1043 | - $jsFileContents .= file_get_contents($filename); |
|
1044 | - } else { |
|
1043 | + $jsFileContents .= file_get_contents($filename); |
|
1044 | + } else { |
|
1045 | 1045 | if (sugar_is_file($defaultFileName)) |
1046 | 1046 | $jsFileContents .= file_get_contents($defaultFileName); |
1047 | 1047 | if (sugar_is_file('custom/'.$defaultFileName)) |
@@ -44,226 +44,226 @@ discard block |
||
44 | 44 | class LanguageManager |
45 | 45 | { |
46 | 46 | |
47 | - /** |
|
48 | - * Called from VardefManager to allow for caching a lang file for a module |
|
49 | - * @param module - the name of the module we are working with |
|
50 | - * @param templates - an array of templates this module uses |
|
51 | - */ |
|
52 | - static function createLanguageFile($module , $templates=array('default'), $refresh = false){ |
|
53 | - global $mod_strings, $current_language; |
|
54 | - if(inDeveloperMode() || !empty($_SESSION['developerMode'])){ |
|
55 | - $refresh = true; |
|
56 | - } |
|
57 | - $temp_mod_strings = $mod_strings; |
|
58 | - $lang = $current_language; |
|
47 | + /** |
|
48 | + * Called from VardefManager to allow for caching a lang file for a module |
|
49 | + * @param module - the name of the module we are working with |
|
50 | + * @param templates - an array of templates this module uses |
|
51 | + */ |
|
52 | + static function createLanguageFile($module , $templates=array('default'), $refresh = false){ |
|
53 | + global $mod_strings, $current_language; |
|
54 | + if(inDeveloperMode() || !empty($_SESSION['developerMode'])){ |
|
55 | + $refresh = true; |
|
56 | + } |
|
57 | + $temp_mod_strings = $mod_strings; |
|
58 | + $lang = $current_language; |
|
59 | 59 | if(empty($lang)) |
60 | 60 | $lang = $GLOBALS['sugar_config']['default_language']; |
61 | - static $createdModules = array(); |
|
62 | - if(empty($createdModules[$module]) && ($refresh || !file_exists(sugar_cached('modules/').$module.'/language/'.$lang.'.lang.php'))){ |
|
63 | - $loaded_mod_strings = array(); |
|
64 | - $loaded_mod_strings = LanguageManager::loadTemplateLanguage($module , $templates, $lang , $loaded_mod_strings); |
|
65 | - $createdModules[$module] = true; |
|
66 | - LanguageManager::refreshLanguage($module,$lang, $loaded_mod_strings); |
|
67 | - } |
|
68 | - } |
|
61 | + static $createdModules = array(); |
|
62 | + if(empty($createdModules[$module]) && ($refresh || !file_exists(sugar_cached('modules/').$module.'/language/'.$lang.'.lang.php'))){ |
|
63 | + $loaded_mod_strings = array(); |
|
64 | + $loaded_mod_strings = LanguageManager::loadTemplateLanguage($module , $templates, $lang , $loaded_mod_strings); |
|
65 | + $createdModules[$module] = true; |
|
66 | + LanguageManager::refreshLanguage($module,$lang, $loaded_mod_strings); |
|
67 | + } |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Load the module tempalte lauguage files |
|
72 | - * @param module - the name of the module we are working with |
|
73 | - * @param templates - an array of templates this module uses |
|
74 | - * @param lang - current language this module use |
|
75 | - * @param loaded_mod_strings - the string that we will add the module template language into |
|
76 | - */ |
|
77 | - static function loadTemplateLanguage($module , $templates , $lang, $loaded_mod_strings){ |
|
78 | - $templates = array_reverse($templates); |
|
79 | - foreach($templates as $template){ |
|
80 | - $temp = LanguageManager::addTemplate($module,$lang, $template); |
|
81 | - $loaded_mod_strings = sugarLangArrayMerge($loaded_mod_strings, $temp); |
|
82 | - } |
|
83 | - return $loaded_mod_strings; |
|
84 | - } |
|
70 | + /** |
|
71 | + * Load the module tempalte lauguage files |
|
72 | + * @param module - the name of the module we are working with |
|
73 | + * @param templates - an array of templates this module uses |
|
74 | + * @param lang - current language this module use |
|
75 | + * @param loaded_mod_strings - the string that we will add the module template language into |
|
76 | + */ |
|
77 | + static function loadTemplateLanguage($module , $templates , $lang, $loaded_mod_strings){ |
|
78 | + $templates = array_reverse($templates); |
|
79 | + foreach($templates as $template){ |
|
80 | + $temp = LanguageManager::addTemplate($module,$lang, $template); |
|
81 | + $loaded_mod_strings = sugarLangArrayMerge($loaded_mod_strings, $temp); |
|
82 | + } |
|
83 | + return $loaded_mod_strings; |
|
84 | + } |
|
85 | 85 | |
86 | - static function addTemplate($module, $lang, $template){ |
|
87 | - if($template == 'default')$template = 'basic'; |
|
88 | - $templates = array(); |
|
89 | - $fields = array(); |
|
90 | - if(empty($templates[$template])){ |
|
91 | - $path = 'include/SugarObjects/templates/' . $template . '/language/'.$lang.'.lang.php'; |
|
92 | - if(file_exists($path)){ |
|
93 | - require($path); |
|
94 | - $templates[$template] = $mod_strings; |
|
95 | - }else{ |
|
96 | - $path = 'include/SugarObjects/implements/' . $template . '/language/'.$lang.'.lang.php'; |
|
97 | - if(file_exists($path)){ |
|
98 | - require($path); |
|
99 | - $templates[$template] = $mod_strings; |
|
100 | - } |
|
101 | - } |
|
102 | - } |
|
103 | - if(!empty($templates[$template])){ |
|
104 | - return $templates[$template]; |
|
105 | - } |
|
106 | - } |
|
86 | + static function addTemplate($module, $lang, $template){ |
|
87 | + if($template == 'default')$template = 'basic'; |
|
88 | + $templates = array(); |
|
89 | + $fields = array(); |
|
90 | + if(empty($templates[$template])){ |
|
91 | + $path = 'include/SugarObjects/templates/' . $template . '/language/'.$lang.'.lang.php'; |
|
92 | + if(file_exists($path)){ |
|
93 | + require($path); |
|
94 | + $templates[$template] = $mod_strings; |
|
95 | + }else{ |
|
96 | + $path = 'include/SugarObjects/implements/' . $template . '/language/'.$lang.'.lang.php'; |
|
97 | + if(file_exists($path)){ |
|
98 | + require($path); |
|
99 | + $templates[$template] = $mod_strings; |
|
100 | + } |
|
101 | + } |
|
102 | + } |
|
103 | + if(!empty($templates[$template])){ |
|
104 | + return $templates[$template]; |
|
105 | + } |
|
106 | + } |
|
107 | 107 | |
108 | - static function saveCache($module,$lang, $loaded_mod_strings, $additonal_objects= array()){ |
|
109 | - if(empty($lang)) |
|
110 | - $lang = $GLOBALS['sugar_config']['default_language']; |
|
108 | + static function saveCache($module,$lang, $loaded_mod_strings, $additonal_objects= array()){ |
|
109 | + if(empty($lang)) |
|
110 | + $lang = $GLOBALS['sugar_config']['default_language']; |
|
111 | 111 | |
112 | - $file = create_cache_directory('modules/' . $module . '/language/'.$lang.'.lang.php'); |
|
113 | - write_array_to_file('mod_strings',$loaded_mod_strings, $file); |
|
114 | - include($file); |
|
112 | + $file = create_cache_directory('modules/' . $module . '/language/'.$lang.'.lang.php'); |
|
113 | + write_array_to_file('mod_strings',$loaded_mod_strings, $file); |
|
114 | + include($file); |
|
115 | 115 | |
116 | - // put the item in the sugar cache. |
|
117 | - $key = self::getLanguageCacheKey($module,$lang); |
|
118 | - sugar_cache_put($key,$loaded_mod_strings); |
|
119 | - } |
|
116 | + // put the item in the sugar cache. |
|
117 | + $key = self::getLanguageCacheKey($module,$lang); |
|
118 | + sugar_cache_put($key,$loaded_mod_strings); |
|
119 | + } |
|
120 | 120 | |
121 | - /** |
|
122 | - * clear out the language cache. |
|
123 | - * @param string module_dir the module_dir to clear, if not specified then clear |
|
124 | - * clear language cache for all modules. |
|
125 | - * @param string lang the name of the object we are clearing this is for sugar_cache |
|
126 | - */ |
|
127 | - static function clearLanguageCache($module_dir = '', $lang = ''){ |
|
128 | - if(empty($lang)) { |
|
129 | - $languages = array_keys($GLOBALS['sugar_config']['languages']); |
|
130 | - } else { |
|
131 | - $languages = array($lang); |
|
132 | - } |
|
133 | - //if we have a module name specified then just remove that language file |
|
134 | - //otherwise go through each module and clean up the language |
|
135 | - if(!empty($module_dir)) { |
|
136 | - foreach($languages as $clean_lang) { |
|
137 | - LanguageManager::_clearCache($module_dir, $clean_lang); |
|
138 | - } |
|
139 | - } else { |
|
140 | - $cache_dir = sugar_cached('modules/'); |
|
141 | - if(file_exists($cache_dir) && $dir = @opendir($cache_dir)) { |
|
142 | - while(($entry = readdir($dir)) !== false) { |
|
143 | - if ($entry == "." || $entry == "..") continue; |
|
144 | - foreach($languages as $clean_lang) { |
|
145 | - LanguageManager::_clearCache($entry, $clean_lang); |
|
146 | - } |
|
147 | - } |
|
148 | - closedir($dir); |
|
149 | - } |
|
150 | - } |
|
151 | - } |
|
121 | + /** |
|
122 | + * clear out the language cache. |
|
123 | + * @param string module_dir the module_dir to clear, if not specified then clear |
|
124 | + * clear language cache for all modules. |
|
125 | + * @param string lang the name of the object we are clearing this is for sugar_cache |
|
126 | + */ |
|
127 | + static function clearLanguageCache($module_dir = '', $lang = ''){ |
|
128 | + if(empty($lang)) { |
|
129 | + $languages = array_keys($GLOBALS['sugar_config']['languages']); |
|
130 | + } else { |
|
131 | + $languages = array($lang); |
|
132 | + } |
|
133 | + //if we have a module name specified then just remove that language file |
|
134 | + //otherwise go through each module and clean up the language |
|
135 | + if(!empty($module_dir)) { |
|
136 | + foreach($languages as $clean_lang) { |
|
137 | + LanguageManager::_clearCache($module_dir, $clean_lang); |
|
138 | + } |
|
139 | + } else { |
|
140 | + $cache_dir = sugar_cached('modules/'); |
|
141 | + if(file_exists($cache_dir) && $dir = @opendir($cache_dir)) { |
|
142 | + while(($entry = readdir($dir)) !== false) { |
|
143 | + if ($entry == "." || $entry == "..") continue; |
|
144 | + foreach($languages as $clean_lang) { |
|
145 | + LanguageManager::_clearCache($entry, $clean_lang); |
|
146 | + } |
|
147 | + } |
|
148 | + closedir($dir); |
|
149 | + } |
|
150 | + } |
|
151 | + } |
|
152 | 152 | |
153 | - /** |
|
154 | - * PRIVATE function used within clearLanguageCache so we do not repeat logic |
|
155 | - * @param string module_dir the module_dir to clear |
|
156 | - * @param string lang the name of the language file we are clearing this is for sugar_cache |
|
157 | - */ |
|
158 | - static function _clearCache($module_dir = '', $lang){ |
|
159 | - if(!empty($module_dir) && !empty($lang)){ |
|
160 | - $file = sugar_cached('modules/').$module_dir.'/language/'.$lang.'.lang.php'; |
|
161 | - if(file_exists($file)){ |
|
162 | - unlink($file); |
|
163 | - $key = self::getLanguageCacheKey($module_dir,$lang); |
|
164 | - sugar_cache_clear($key); |
|
165 | - } |
|
166 | - } |
|
167 | - } |
|
153 | + /** |
|
154 | + * PRIVATE function used within clearLanguageCache so we do not repeat logic |
|
155 | + * @param string module_dir the module_dir to clear |
|
156 | + * @param string lang the name of the language file we are clearing this is for sugar_cache |
|
157 | + */ |
|
158 | + static function _clearCache($module_dir = '', $lang){ |
|
159 | + if(!empty($module_dir) && !empty($lang)){ |
|
160 | + $file = sugar_cached('modules/').$module_dir.'/language/'.$lang.'.lang.php'; |
|
161 | + if(file_exists($file)){ |
|
162 | + unlink($file); |
|
163 | + $key = self::getLanguageCacheKey($module_dir,$lang); |
|
164 | + sugar_cache_clear($key); |
|
165 | + } |
|
166 | + } |
|
167 | + } |
|
168 | 168 | |
169 | - /** |
|
170 | - * Given a module, search all of the specified locations, and any others as specified |
|
171 | - * in order to refresh the cache file |
|
172 | - * |
|
173 | - * @param string $module the given module we want to load the vardefs for |
|
174 | - * @param string $lang the given language we wish to load |
|
175 | - * @param array $additional_search_paths an array which allows a consumer to pass in additional vardef locations to search |
|
176 | - */ |
|
177 | - static function refreshLanguage($module, $lang, $loaded_mod_strings = array(), $additional_search_paths = null){ |
|
178 | - // Some of the vardefs do not correctly define dictionary as global. Declare it first. |
|
179 | - $lang_paths = array( |
|
180 | - 'modules/'.$module.'/language/'.$lang.'.lang.php', |
|
181 | - 'modules/'.$module.'/language/'.$lang.'.lang.override.php', |
|
182 | - 'custom/modules/'.$module.'/language/'.$lang.'.lang.php', |
|
183 | - 'custom/modules/'.$module.'/Ext/Language/'.$lang.'.lang.ext.php', |
|
184 | - ); |
|
169 | + /** |
|
170 | + * Given a module, search all of the specified locations, and any others as specified |
|
171 | + * in order to refresh the cache file |
|
172 | + * |
|
173 | + * @param string $module the given module we want to load the vardefs for |
|
174 | + * @param string $lang the given language we wish to load |
|
175 | + * @param array $additional_search_paths an array which allows a consumer to pass in additional vardef locations to search |
|
176 | + */ |
|
177 | + static function refreshLanguage($module, $lang, $loaded_mod_strings = array(), $additional_search_paths = null){ |
|
178 | + // Some of the vardefs do not correctly define dictionary as global. Declare it first. |
|
179 | + $lang_paths = array( |
|
180 | + 'modules/'.$module.'/language/'.$lang.'.lang.php', |
|
181 | + 'modules/'.$module.'/language/'.$lang.'.lang.override.php', |
|
182 | + 'custom/modules/'.$module.'/language/'.$lang.'.lang.php', |
|
183 | + 'custom/modules/'.$module.'/Ext/Language/'.$lang.'.lang.ext.php', |
|
184 | + ); |
|
185 | 185 | |
186 | - #27023, if this module template language file was not attached , get the template from this module vardef cache file if exsits and load the template language files. |
|
187 | - static $createdModules; |
|
188 | - if(empty($createdModules[$module]) && isset($GLOBALS['beanList'][$module])){ |
|
189 | - $object = $GLOBALS['beanList'][$module]; |
|
186 | + #27023, if this module template language file was not attached , get the template from this module vardef cache file if exsits and load the template language files. |
|
187 | + static $createdModules; |
|
188 | + if(empty($createdModules[$module]) && isset($GLOBALS['beanList'][$module])){ |
|
189 | + $object = $GLOBALS['beanList'][$module]; |
|
190 | 190 | |
191 | - if ($object == 'aCase') |
|
192 | - $object = 'Case'; |
|
191 | + if ($object == 'aCase') |
|
192 | + $object = 'Case'; |
|
193 | 193 | |
194 | - if(!empty($GLOBALS["dictionary"]["$object"]["templates"])){ |
|
195 | - $templates = $GLOBALS["dictionary"]["$object"]["templates"]; |
|
196 | - $loaded_mod_strings = LanguageManager::loadTemplateLanguage($module , $templates, $lang , $loaded_mod_strings); |
|
197 | - $createdModules[$module] = true; |
|
198 | - } |
|
199 | - } |
|
200 | - //end of fix #27023 |
|
194 | + if(!empty($GLOBALS["dictionary"]["$object"]["templates"])){ |
|
195 | + $templates = $GLOBALS["dictionary"]["$object"]["templates"]; |
|
196 | + $loaded_mod_strings = LanguageManager::loadTemplateLanguage($module , $templates, $lang , $loaded_mod_strings); |
|
197 | + $createdModules[$module] = true; |
|
198 | + } |
|
199 | + } |
|
200 | + //end of fix #27023 |
|
201 | 201 | |
202 | - // Add in additional search paths if they were provided. |
|
203 | - if(!empty($additional_search_paths) && is_array($additional_search_paths)) |
|
204 | - { |
|
205 | - $lang_paths = array_merge($lang_paths, $additional_search_paths); |
|
206 | - } |
|
202 | + // Add in additional search paths if they were provided. |
|
203 | + if(!empty($additional_search_paths) && is_array($additional_search_paths)) |
|
204 | + { |
|
205 | + $lang_paths = array_merge($lang_paths, $additional_search_paths); |
|
206 | + } |
|
207 | 207 | |
208 | - //search a predefined set of locations for the vardef files |
|
209 | - foreach($lang_paths as $path){ |
|
210 | - if(file_exists($path)){ |
|
211 | - require($path); |
|
212 | - if(!empty($mod_strings)){ |
|
213 | - if (function_exists('sugarArrayMergeRecursive')){ |
|
214 | - $loaded_mod_strings = sugarArrayMergeRecursive($loaded_mod_strings, $mod_strings); |
|
215 | - } |
|
216 | - else{ |
|
217 | - $loaded_mod_strings = sugarLangArrayMerge($loaded_mod_strings, $mod_strings); |
|
218 | - } |
|
219 | - } |
|
220 | - } |
|
221 | - } |
|
208 | + //search a predefined set of locations for the vardef files |
|
209 | + foreach($lang_paths as $path){ |
|
210 | + if(file_exists($path)){ |
|
211 | + require($path); |
|
212 | + if(!empty($mod_strings)){ |
|
213 | + if (function_exists('sugarArrayMergeRecursive')){ |
|
214 | + $loaded_mod_strings = sugarArrayMergeRecursive($loaded_mod_strings, $mod_strings); |
|
215 | + } |
|
216 | + else{ |
|
217 | + $loaded_mod_strings = sugarLangArrayMerge($loaded_mod_strings, $mod_strings); |
|
218 | + } |
|
219 | + } |
|
220 | + } |
|
221 | + } |
|
222 | 222 | |
223 | - //great! now that we have loaded all of our vardefs. |
|
224 | - //let's go save them to the cache file. |
|
225 | - if(!empty($loaded_mod_strings)) |
|
226 | - LanguageManager::saveCache($module, $lang, $loaded_mod_strings); |
|
227 | - } |
|
223 | + //great! now that we have loaded all of our vardefs. |
|
224 | + //let's go save them to the cache file. |
|
225 | + if(!empty($loaded_mod_strings)) |
|
226 | + LanguageManager::saveCache($module, $lang, $loaded_mod_strings); |
|
227 | + } |
|
228 | 228 | |
229 | - static function loadModuleLanguage($module, $lang, $refresh=false){ |
|
230 | - //here check if the cache file exists, if it does then load it, if it doesn't |
|
231 | - //then call refreshVardef |
|
232 | - //if either our session or the system is set to developerMode then refresh is set to true |
|
229 | + static function loadModuleLanguage($module, $lang, $refresh=false){ |
|
230 | + //here check if the cache file exists, if it does then load it, if it doesn't |
|
231 | + //then call refreshVardef |
|
232 | + //if either our session or the system is set to developerMode then refresh is set to true |
|
233 | 233 | |
234 | - // Retrieve the vardefs from cache. |
|
235 | - $key = self::getLanguageCacheKey($module,$lang); |
|
234 | + // Retrieve the vardefs from cache. |
|
235 | + $key = self::getLanguageCacheKey($module,$lang); |
|
236 | 236 | |
237 | - if(!$refresh) |
|
238 | - { |
|
239 | - $return_result = sugar_cache_retrieve($key); |
|
240 | - if(!empty($return_result) && is_array($return_result)){ |
|
241 | - return $return_result; |
|
242 | - } |
|
243 | - } |
|
237 | + if(!$refresh) |
|
238 | + { |
|
239 | + $return_result = sugar_cache_retrieve($key); |
|
240 | + if(!empty($return_result) && is_array($return_result)){ |
|
241 | + return $return_result; |
|
242 | + } |
|
243 | + } |
|
244 | 244 | |
245 | - // Some of the vardefs do not correctly define dictionary as global. Declare it first. |
|
246 | - $cachedfile = sugar_cached('modules/').$module.'/language/'.$lang.'.lang.php'; |
|
247 | - if($refresh || !file_exists($cachedfile)){ |
|
248 | - LanguageManager::refreshLanguage($module, $lang); |
|
249 | - } |
|
245 | + // Some of the vardefs do not correctly define dictionary as global. Declare it first. |
|
246 | + $cachedfile = sugar_cached('modules/').$module.'/language/'.$lang.'.lang.php'; |
|
247 | + if($refresh || !file_exists($cachedfile)){ |
|
248 | + LanguageManager::refreshLanguage($module, $lang); |
|
249 | + } |
|
250 | 250 | |
251 | - //at this point we should have the cache/modules/... file |
|
252 | - //which was created from the refreshVardefs so let's try to load it. |
|
253 | - if(file_exists($cachedfile)){ |
|
254 | - global $mod_strings; |
|
251 | + //at this point we should have the cache/modules/... file |
|
252 | + //which was created from the refreshVardefs so let's try to load it. |
|
253 | + if(file_exists($cachedfile)){ |
|
254 | + global $mod_strings; |
|
255 | 255 | |
256 | - require $cachedfile; |
|
256 | + require $cachedfile; |
|
257 | 257 | |
258 | - // now that we hae loaded the data from disk, put it in the cache. |
|
259 | - if(!empty($mod_strings)) |
|
260 | - sugar_cache_put($key,$mod_strings); |
|
261 | - if(!empty($_SESSION['translation_mode'])){ |
|
262 | - $mod_strings = array_map('translated_prefix', $mod_strings); |
|
263 | - } |
|
264 | - return $mod_strings; |
|
265 | - } |
|
266 | - } |
|
258 | + // now that we hae loaded the data from disk, put it in the cache. |
|
259 | + if(!empty($mod_strings)) |
|
260 | + sugar_cache_put($key,$mod_strings); |
|
261 | + if(!empty($_SESSION['translation_mode'])){ |
|
262 | + $mod_strings = array_map('translated_prefix', $mod_strings); |
|
263 | + } |
|
264 | + return $mod_strings; |
|
265 | + } |
|
266 | + } |
|
267 | 267 | |
268 | 268 | /** |
269 | 269 | * Return the cache key for the module language definition |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | * @return string |
275 | 275 | */ |
276 | 276 | public static function getLanguageCacheKey($module, $lang) |
277 | - { |
|
278 | - return "LanguageManager.$module.$lang"; |
|
279 | - } |
|
277 | + { |
|
278 | + return "LanguageManager.$module.$lang"; |
|
279 | + } |
|
280 | 280 | |
281 | 281 | /** |
282 | 282 | * Remove any cached js language strings. |
@@ -302,5 +302,5 @@ discard block |
||
302 | 302 | } |
303 | 303 | |
304 | 304 | function translated_prefix($key){ |
305 | - return '[translated]' . $key; |
|
305 | + return '[translated]' . $key; |
|
306 | 306 | } |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public static function setCustomAllowedForModule($module, $enable) { |
91 | 91 | if ($enable && isset($custom_disabled_modules[$module])) { |
92 | - unset($custom_disabled_modules[$module]); |
|
92 | + unset($custom_disabled_modules[$module]); |
|
93 | 93 | } else if (!$enable) { |
94 | - $custom_disabled_modules[$module] = true; |
|
94 | + $custom_disabled_modules[$module] = true; |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | 'modules/'.$module.'/vardefs.php', |
237 | 237 | 'custom/modules/'.$module.'/Ext/Vardefs/vardefs.ext.php', |
238 | 238 | 'custom/Extension/modules/'.$module.'/Ext/Vardefs/vardefs.php' |
239 | - ); |
|
239 | + ); |
|
240 | 240 | |
241 | 241 | // Add in additional search paths if they were provided. |
242 | 242 | if(!empty($additional_search_paths) && is_array($additional_search_paths)) |
@@ -426,10 +426,10 @@ discard block |
||
426 | 426 | //if the consumer has demanded a refresh or the cache/modules... file |
427 | 427 | //does not exist, then we should do out and try to reload things |
428 | 428 | |
429 | - $cachedfile = sugar_cached('modules/'). $module . '/' . $object . 'vardefs.php'; |
|
430 | - if($refresh || !file_exists($cachedfile)){ |
|
431 | - VardefManager::refreshVardefs($module, $object, null, true, $params); |
|
432 | - } |
|
429 | + $cachedfile = sugar_cached('modules/'). $module . '/' . $object . 'vardefs.php'; |
|
430 | + if($refresh || !file_exists($cachedfile)){ |
|
431 | + VardefManager::refreshVardefs($module, $object, null, true, $params); |
|
432 | + } |
|
433 | 433 | |
434 | 434 | //at this point we should have the cache/modules/... file |
435 | 435 | //which was created from the refreshVardefs so let's try to load it. |
@@ -39,141 +39,141 @@ discard block |
||
39 | 39 | |
40 | 40 | $vardefs = array( |
41 | 41 | 'fields' => array ( |
42 | - 'id' => |
|
43 | - array ( |
|
44 | - 'name' => 'id', |
|
45 | - 'vname' => 'LBL_ID', |
|
46 | - 'type' => 'id', |
|
47 | - 'required'=>true, |
|
48 | - 'reportable'=>true, |
|
49 | - 'comment' => 'Unique identifier', |
|
50 | - 'inline_edit' => false, |
|
51 | - ), |
|
52 | - 'name'=> |
|
53 | - array( |
|
54 | - 'name'=>'name', |
|
55 | - 'vname'=> 'LBL_NAME', |
|
56 | - 'type'=>'name', |
|
57 | - 'link' => true, // bug 39288 |
|
58 | - 'dbType' => 'varchar', |
|
59 | - 'len'=>255, |
|
42 | + 'id' => |
|
43 | + array ( |
|
44 | + 'name' => 'id', |
|
45 | + 'vname' => 'LBL_ID', |
|
46 | + 'type' => 'id', |
|
47 | + 'required'=>true, |
|
48 | + 'reportable'=>true, |
|
49 | + 'comment' => 'Unique identifier', |
|
50 | + 'inline_edit' => false, |
|
51 | + ), |
|
52 | + 'name'=> |
|
53 | + array( |
|
54 | + 'name'=>'name', |
|
55 | + 'vname'=> 'LBL_NAME', |
|
56 | + 'type'=>'name', |
|
57 | + 'link' => true, // bug 39288 |
|
58 | + 'dbType' => 'varchar', |
|
59 | + 'len'=>255, |
|
60 | 60 | 'unified_search' => true, |
61 | 61 | 'full_text_search' => array('boost' => 3), |
62 | 62 | 'required'=>true, |
63 | - 'importable' => 'required', |
|
63 | + 'importable' => 'required', |
|
64 | 64 | 'duplicate_merge' => 'enabled', |
65 | 65 | //'duplicate_merge_dom_value' => '3', |
66 | 66 | 'merge_filter' => 'selected', |
67 | - ), |
|
68 | - 'date_entered' => |
|
69 | - array ( |
|
70 | - 'name' => 'date_entered', |
|
71 | - 'vname' => 'LBL_DATE_ENTERED', |
|
72 | - 'type' => 'datetime', |
|
73 | - 'group'=>'created_by_name', |
|
74 | - 'comment' => 'Date record created', |
|
75 | - 'enable_range_search' => true, |
|
76 | - 'options' => 'date_range_search_dom', |
|
77 | - 'inline_edit' => false, |
|
78 | - ), |
|
79 | - 'date_modified' => |
|
80 | - array ( |
|
81 | - 'name' => 'date_modified', |
|
82 | - 'vname' => 'LBL_DATE_MODIFIED', |
|
83 | - 'type' => 'datetime', |
|
84 | - 'group'=>'modified_by_name', |
|
85 | - 'comment' => 'Date record last modified', |
|
86 | - 'enable_range_search' => true, |
|
87 | - 'options' => 'date_range_search_dom', |
|
88 | - 'inline_edit' => false, |
|
89 | - ), |
|
90 | - 'modified_user_id' => |
|
91 | - array ( |
|
92 | - 'name' => 'modified_user_id', |
|
93 | - 'rname' => 'user_name', |
|
94 | - 'id_name' => 'modified_user_id', |
|
95 | - 'vname' => 'LBL_MODIFIED', |
|
96 | - 'type' => 'assigned_user_name', |
|
97 | - 'table' => 'users', |
|
98 | - 'isnull' => 'false', |
|
99 | - 'group'=>'modified_by_name', |
|
100 | - 'dbType' => 'id', |
|
101 | - 'reportable'=>true, |
|
102 | - 'comment' => 'User who last modified record', |
|
67 | + ), |
|
68 | + 'date_entered' => |
|
69 | + array ( |
|
70 | + 'name' => 'date_entered', |
|
71 | + 'vname' => 'LBL_DATE_ENTERED', |
|
72 | + 'type' => 'datetime', |
|
73 | + 'group'=>'created_by_name', |
|
74 | + 'comment' => 'Date record created', |
|
75 | + 'enable_range_search' => true, |
|
76 | + 'options' => 'date_range_search_dom', |
|
77 | + 'inline_edit' => false, |
|
78 | + ), |
|
79 | + 'date_modified' => |
|
80 | + array ( |
|
81 | + 'name' => 'date_modified', |
|
82 | + 'vname' => 'LBL_DATE_MODIFIED', |
|
83 | + 'type' => 'datetime', |
|
84 | + 'group'=>'modified_by_name', |
|
85 | + 'comment' => 'Date record last modified', |
|
86 | + 'enable_range_search' => true, |
|
87 | + 'options' => 'date_range_search_dom', |
|
88 | + 'inline_edit' => false, |
|
89 | + ), |
|
90 | + 'modified_user_id' => |
|
91 | + array ( |
|
92 | + 'name' => 'modified_user_id', |
|
93 | + 'rname' => 'user_name', |
|
94 | + 'id_name' => 'modified_user_id', |
|
95 | + 'vname' => 'LBL_MODIFIED', |
|
96 | + 'type' => 'assigned_user_name', |
|
97 | + 'table' => 'users', |
|
98 | + 'isnull' => 'false', |
|
99 | + 'group'=>'modified_by_name', |
|
100 | + 'dbType' => 'id', |
|
101 | + 'reportable'=>true, |
|
102 | + 'comment' => 'User who last modified record', |
|
103 | 103 | 'massupdate' => false, |
104 | - 'inline_edit' => false, |
|
105 | - ), |
|
106 | - 'modified_by_name' => |
|
107 | - array ( |
|
108 | - 'name' => 'modified_by_name', |
|
109 | - 'vname' => 'LBL_MODIFIED_NAME', |
|
110 | - 'type' => 'relate', |
|
111 | - 'reportable'=>false, |
|
112 | - 'source'=>'non-db', |
|
113 | - 'rname'=>'user_name', |
|
114 | - 'table' => 'users', |
|
115 | - 'id_name' => 'modified_user_id', |
|
116 | - 'module'=>'Users', |
|
117 | - 'link'=>'modified_user_link', |
|
118 | - 'duplicate_merge'=>'disabled', |
|
104 | + 'inline_edit' => false, |
|
105 | + ), |
|
106 | + 'modified_by_name' => |
|
107 | + array ( |
|
108 | + 'name' => 'modified_by_name', |
|
109 | + 'vname' => 'LBL_MODIFIED_NAME', |
|
110 | + 'type' => 'relate', |
|
111 | + 'reportable'=>false, |
|
112 | + 'source'=>'non-db', |
|
113 | + 'rname'=>'user_name', |
|
114 | + 'table' => 'users', |
|
115 | + 'id_name' => 'modified_user_id', |
|
116 | + 'module'=>'Users', |
|
117 | + 'link'=>'modified_user_link', |
|
118 | + 'duplicate_merge'=>'disabled', |
|
119 | 119 | 'massupdate' => false, |
120 | - 'inline_edit' => false, |
|
121 | - ), |
|
122 | - 'created_by' => |
|
123 | - array ( |
|
124 | - 'name' => 'created_by', |
|
125 | - 'rname' => 'user_name', |
|
126 | - 'id_name' => 'modified_user_id', |
|
127 | - 'vname' => 'LBL_CREATED', |
|
128 | - 'type' => 'assigned_user_name', |
|
129 | - 'table' => 'users', |
|
130 | - 'isnull' => 'false', |
|
131 | - 'dbType' => 'id', |
|
132 | - 'group'=>'created_by_name', |
|
133 | - 'comment' => 'User who created record', |
|
120 | + 'inline_edit' => false, |
|
121 | + ), |
|
122 | + 'created_by' => |
|
123 | + array ( |
|
124 | + 'name' => 'created_by', |
|
125 | + 'rname' => 'user_name', |
|
126 | + 'id_name' => 'modified_user_id', |
|
127 | + 'vname' => 'LBL_CREATED', |
|
128 | + 'type' => 'assigned_user_name', |
|
129 | + 'table' => 'users', |
|
130 | + 'isnull' => 'false', |
|
131 | + 'dbType' => 'id', |
|
132 | + 'group'=>'created_by_name', |
|
133 | + 'comment' => 'User who created record', |
|
134 | 134 | 'massupdate' => false, |
135 | - 'inline_edit' => false, |
|
136 | - ), |
|
137 | - 'created_by_name' => |
|
138 | - array ( |
|
139 | - 'name' => 'created_by_name', |
|
140 | - 'vname' => 'LBL_CREATED', |
|
141 | - 'type' => 'relate', |
|
142 | - 'reportable'=>false, |
|
143 | - 'link' => 'created_by_link', |
|
144 | - 'rname' => 'user_name', |
|
145 | - 'source'=>'non-db', |
|
146 | - 'table' => 'users', |
|
147 | - 'id_name' => 'created_by', |
|
148 | - 'module'=>'Users', |
|
149 | - 'duplicate_merge'=>'disabled', |
|
135 | + 'inline_edit' => false, |
|
136 | + ), |
|
137 | + 'created_by_name' => |
|
138 | + array ( |
|
139 | + 'name' => 'created_by_name', |
|
140 | + 'vname' => 'LBL_CREATED', |
|
141 | + 'type' => 'relate', |
|
142 | + 'reportable'=>false, |
|
143 | + 'link' => 'created_by_link', |
|
144 | + 'rname' => 'user_name', |
|
145 | + 'source'=>'non-db', |
|
146 | + 'table' => 'users', |
|
147 | + 'id_name' => 'created_by', |
|
148 | + 'module'=>'Users', |
|
149 | + 'duplicate_merge'=>'disabled', |
|
150 | 150 | 'importable' => 'false', |
151 | 151 | 'massupdate' => false, |
152 | - 'inline_edit' => false, |
|
153 | - ), |
|
154 | - 'description' => |
|
155 | - array ( |
|
156 | - 'name' => 'description', |
|
157 | - 'vname' => 'LBL_DESCRIPTION', |
|
158 | - 'type' => 'text', |
|
159 | - 'comment' => 'Full text of the note', |
|
160 | - 'rows' => 6, |
|
161 | - 'cols' => 80, |
|
162 | - ), |
|
163 | - 'deleted' => |
|
164 | - array ( |
|
165 | - 'name' => 'deleted', |
|
166 | - 'vname' => 'LBL_DELETED', |
|
167 | - 'type' => 'bool', |
|
168 | - 'default' => '0', |
|
169 | - 'reportable'=>false, |
|
170 | - 'comment' => 'Record deletion indicator' |
|
171 | - ), |
|
152 | + 'inline_edit' => false, |
|
153 | + ), |
|
154 | + 'description' => |
|
155 | + array ( |
|
156 | + 'name' => 'description', |
|
157 | + 'vname' => 'LBL_DESCRIPTION', |
|
158 | + 'type' => 'text', |
|
159 | + 'comment' => 'Full text of the note', |
|
160 | + 'rows' => 6, |
|
161 | + 'cols' => 80, |
|
162 | + ), |
|
163 | + 'deleted' => |
|
164 | + array ( |
|
165 | + 'name' => 'deleted', |
|
166 | + 'vname' => 'LBL_DELETED', |
|
167 | + 'type' => 'bool', |
|
168 | + 'default' => '0', |
|
169 | + 'reportable'=>false, |
|
170 | + 'comment' => 'Record deletion indicator' |
|
171 | + ), |
|
172 | 172 | |
173 | 173 | /////////////////RELATIONSHIP LINKS//////////////////////////// |
174 | - 'created_by_link' => |
|
175 | - array ( |
|
176 | - 'name' => 'created_by_link', |
|
174 | + 'created_by_link' => |
|
175 | + array ( |
|
176 | + 'name' => 'created_by_link', |
|
177 | 177 | 'type' => 'link', |
178 | 178 | 'relationship' => strtolower($module) . '_created_by', |
179 | 179 | 'vname' => 'LBL_CREATED_USER', |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | 'module'=>'Users', |
182 | 182 | 'bean_name'=>'User', |
183 | 183 | 'source'=>'non-db', |
184 | - ), |
|
185 | - 'modified_user_link' => |
|
186 | - array ( |
|
184 | + ), |
|
185 | + 'modified_user_link' => |
|
186 | + array ( |
|
187 | 187 | 'name' => 'modified_user_link', |
188 | 188 | 'type' => 'link', |
189 | 189 | 'relationship' => strtolower($module). '_modified_user', |
@@ -192,21 +192,21 @@ discard block |
||
192 | 192 | 'module'=>'Users', |
193 | 193 | 'bean_name'=>'User', |
194 | 194 | 'source'=>'non-db', |
195 | - ), |
|
195 | + ), |
|
196 | 196 | |
197 | 197 | ), |
198 | 198 | 'indices' => array ( |
199 | - 'id'=>array('name' =>strtolower($module).'pk', 'type' =>'primary', 'fields'=>array('id')), |
|
200 | - ), |
|
199 | + 'id'=>array('name' =>strtolower($module).'pk', 'type' =>'primary', 'fields'=>array('id')), |
|
200 | + ), |
|
201 | 201 | 'relationships'=>array( |
202 | - strtolower($module).'_modified_user' => |
|
203 | - array('lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id', |
|
204 | - 'rhs_module'=> $module, 'rhs_table'=> strtolower($module), 'rhs_key' => 'modified_user_id', |
|
205 | - 'relationship_type'=>'one-to-many') |
|
206 | - ,strtolower($module).'_created_by' => |
|
207 | - array('lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id', |
|
208 | - 'rhs_module'=> $module, 'rhs_table'=> strtolower($module), 'rhs_key' => 'created_by', |
|
209 | - 'relationship_type'=>'one-to-many') |
|
202 | + strtolower($module).'_modified_user' => |
|
203 | + array('lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id', |
|
204 | + 'rhs_module'=> $module, 'rhs_table'=> strtolower($module), 'rhs_key' => 'modified_user_id', |
|
205 | + 'relationship_type'=>'one-to-many') |
|
206 | + ,strtolower($module).'_created_by' => |
|
207 | + array('lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id', |
|
208 | + 'rhs_module'=> $module, 'rhs_table'=> strtolower($module), 'rhs_key' => 'created_by', |
|
209 | + 'relationship_type'=>'one-to-many') |
|
210 | 210 | ), |
211 | 211 | |
212 | 212 |
@@ -54,7 +54,7 @@ |
||
54 | 54 | 'LBL_MODIFIED_USER'=>'Modified by User', |
55 | 55 | 'LBL_LIST_NAME'=>'Name', |
56 | 56 | 'LBL_EDIT_BUTTON' => 'Edit', |
57 | - 'LBL_REMOVE' => 'Remove', |
|
57 | + 'LBL_REMOVE' => 'Remove', |
|
58 | 58 | |
59 | 59 | |
60 | 60 | ); |
61 | 61 | \ No newline at end of file |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | 'url' => 'nvarchar', |
144 | 144 | 'encrypt' => 'nvarchar', |
145 | 145 | 'file' => 'nvarchar', |
146 | - 'decimal_tpl' => 'decimal(%d, %d)', |
|
146 | + 'decimal_tpl' => 'decimal(%d, %d)', |
|
147 | 147 | ); |
148 | 148 | |
149 | - /** |
|
149 | + /** |
|
150 | 150 | * @see DBManager::connect() |
151 | 151 | */ |
152 | 152 | public function connect(array $configOptions = null, $dieOnError = false) |
@@ -203,10 +203,10 @@ discard block |
||
203 | 203 | return true; |
204 | 204 | } |
205 | 205 | |
206 | - /** |
|
206 | + /** |
|
207 | 207 | * @see DBManager::query() |
208 | - */ |
|
209 | - public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) |
|
208 | + */ |
|
209 | + public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) |
|
210 | 210 | { |
211 | 211 | if(is_array($sql)) { |
212 | 212 | return $this->queryArray($sql, $dieOnError, $msg, $suppress); |
@@ -232,15 +232,15 @@ discard block |
||
232 | 232 | return $result; |
233 | 233 | } |
234 | 234 | |
235 | - /** |
|
235 | + /** |
|
236 | 236 | * @see DBManager::getFieldsArray() |
237 | 237 | */ |
238 | - public function getFieldsArray($result, $make_lower_case = false) |
|
239 | - { |
|
238 | + public function getFieldsArray($result, $make_lower_case = false) |
|
239 | + { |
|
240 | 240 | $field_array = array(); |
241 | 241 | |
242 | 242 | if ( !$result ) { |
243 | - return false; |
|
243 | + return false; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | foreach ( sqlsrv_field_metadata($result) as $fieldMetadata ) { |
@@ -252,16 +252,16 @@ discard block |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | return $field_array; |
255 | - } |
|
255 | + } |
|
256 | 256 | |
257 | - /** |
|
258 | - * @see DBManager::fetchRow() |
|
259 | - */ |
|
260 | - public function fetchRow($result) |
|
261 | - { |
|
262 | - if (empty($result)) return false; |
|
257 | + /** |
|
258 | + * @see DBManager::fetchRow() |
|
259 | + */ |
|
260 | + public function fetchRow($result) |
|
261 | + { |
|
262 | + if (empty($result)) return false; |
|
263 | 263 | |
264 | - $row = sqlsrv_fetch_array($result,SQLSRV_FETCH_ASSOC); |
|
264 | + $row = sqlsrv_fetch_array($result,SQLSRV_FETCH_ASSOC); |
|
265 | 265 | if (empty($row)) { |
266 | 266 | return false; |
267 | 267 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | return $row; |
280 | - } |
|
280 | + } |
|
281 | 281 | |
282 | 282 | /** |
283 | 283 | * @see DBManager::convert() |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | return parent::convert($string, $type, $additional_parameters); |
292 | 292 | } |
293 | 293 | |
294 | - /** |
|
294 | + /** |
|
295 | 295 | * Compares two vardefs. Overriding 39098 due to bug: 39098 . IN 6.0 we changed the id columns to dbType = 'id' |
296 | 296 | * for example emails_beans. In 554 the field email_id was nvarchar but in 6.0 since it id dbType = 'id' we would want to alter |
297 | 297 | * it to varchar. This code will prevent it. |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function disconnect() |
319 | 319 | { |
320 | - $GLOBALS['log']->debug('Calling Mssql::disconnect()'); |
|
320 | + $GLOBALS['log']->debug('Calling Mssql::disconnect()'); |
|
321 | 321 | if(!empty($this->database)){ |
322 | 322 | $this->freeResult(); |
323 | 323 | sqlsrv_close($this->database); |
@@ -335,10 +335,10 @@ discard block |
||
335 | 335 | } |
336 | 336 | |
337 | 337 | |
338 | - /** |
|
339 | - * Detect if no clustered index has been created for a table; if none created then just pick the first index and make it that |
|
340 | - * |
|
341 | - * @see MssqlHelper::indexSQL() |
|
338 | + /** |
|
339 | + * Detect if no clustered index has been created for a table; if none created then just pick the first index and make it that |
|
340 | + * |
|
341 | + * @see MssqlHelper::indexSQL() |
|
342 | 342 | */ |
343 | 343 | public function getConstraintSql($indices, $table) |
344 | 344 | { |
@@ -378,12 +378,12 @@ discard block |
||
378 | 378 | $columns[$column_name]['len']=strtolower($row['PRECISION']); |
379 | 379 | $columns[$column_name]['len'].=','.strtolower($row['SCALE']); |
380 | 380 | } |
381 | - elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) { |
|
382 | - $columns[$column_name]['len']=strtolower($row['PRECISION']); |
|
383 | - if ( $row['TYPE_NAME'] == 'nvarchar' && $row['PRECISION'] == '0' ) { |
|
384 | - $columns[$column_name]['len']='max'; |
|
385 | - } |
|
386 | - } |
|
381 | + elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) { |
|
382 | + $columns[$column_name]['len']=strtolower($row['PRECISION']); |
|
383 | + if ( $row['TYPE_NAME'] == 'nvarchar' && $row['PRECISION'] == '0' ) { |
|
384 | + $columns[$column_name]['len']='max'; |
|
385 | + } |
|
386 | + } |
|
387 | 387 | elseif ( !in_array($row['TYPE_NAME'],array('datetime','text')) ) { |
388 | 388 | $columns[$column_name]['len']=strtolower($row['LENGTH']); |
389 | 389 | } |
@@ -488,21 +488,21 @@ discard block |
||
488 | 488 | return "TRUNCATE TABLE $name"; |
489 | 489 | } |
490 | 490 | |
491 | - /** |
|
492 | - * (non-PHPdoc) |
|
493 | - * @see DBManager::lastDbError() |
|
494 | - */ |
|
491 | + /** |
|
492 | + * (non-PHPdoc) |
|
493 | + * @see DBManager::lastDbError() |
|
494 | + */ |
|
495 | 495 | public function lastDbError() |
496 | 496 | { |
497 | 497 | $errors = sqlsrv_errors(SQLSRV_ERR_ERRORS); |
498 | 498 | if(empty($errors)) return false; |
499 | 499 | global $app_strings; |
500 | 500 | if (empty($app_strings) |
501 | - or !isset($app_strings['ERR_MSSQL_DB_CONTEXT']) |
|
502 | - or !isset($app_strings['ERR_MSSQL_WARNING']) ) { |
|
501 | + or !isset($app_strings['ERR_MSSQL_DB_CONTEXT']) |
|
502 | + or !isset($app_strings['ERR_MSSQL_WARNING']) ) { |
|
503 | 503 | //ignore the message from sql-server if $app_strings array is empty. This will happen |
504 | 504 | //only if connection if made before languge is set. |
505 | - return false; |
|
505 | + return false; |
|
506 | 506 | } |
507 | 507 | $messages = array(); |
508 | 508 | foreach($errors as $error) { |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | } |
516 | 516 | $sqlpos = strpos($sqlmsg, $app_strings['ERR_MSSQL_DB_CONTEXT']); |
517 | 517 | $sqlpos2 = strpos($sqlmsg, $app_strings['ERR_MSSQL_WARNING']); |
518 | - if ( $sqlpos !== false || $sqlpos2 !== false) { |
|
518 | + if ( $sqlpos !== false || $sqlpos2 !== false) { |
|
519 | 519 | continue; |
520 | 520 | } |
521 | 521 | $messages[] = $sqlmsg; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | break; |
82 | 82 | case "mssql": |
83 | - if ( function_exists('sqlsrv_connect') |
|
83 | + if ( function_exists('sqlsrv_connect') |
|
84 | 84 | && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'sqlsrv' )) { |
85 | 85 | $my_db_manager = 'SqlsrvManager'; |
86 | 86 | } elseif (self::isFreeTDS() |
@@ -122,20 +122,20 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
125 | - * Returns a reference to the DB object for instance $instanceName, or the default |
|
125 | + * Returns a reference to the DB object for instance $instanceName, or the default |
|
126 | 126 | * instance if one is not specified |
127 | 127 | * |
128 | 128 | * @param string $instanceName optional, name of the instance |
129 | 129 | * @return object DBManager instance |
130 | 130 | */ |
131 | - public static function getInstance($instanceName = '') |
|
131 | + public static function getInstance($instanceName = '') |
|
132 | 132 | { |
133 | 133 | global $sugar_config; |
134 | 134 | static $count = 0, $old_count = 0; |
135 | 135 | |
136 | 136 | //fall back to the default instance name |
137 | 137 | if(empty($sugar_config['db'][$instanceName])){ |
138 | - $instanceName = ''; |
|
138 | + $instanceName = ''; |
|
139 | 139 | } |
140 | 140 | if(!isset(self::$instances[$instanceName])){ |
141 | 141 | $config = $sugar_config['dbconfig']; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | /** |
249 | 249 | * Check if we have freeTDS driver installed |
250 | 250 | * Invoked when connected to mssql. checks if we have freetds version of mssql library. |
251 | - * the response is put into a global variable. |
|
251 | + * the response is put into a global variable. |
|
252 | 252 | * @return bool |
253 | 253 | */ |
254 | 254 | public static function isFreeTDS() |
@@ -256,14 +256,14 @@ discard block |
||
256 | 256 | static $is_freetds = null; |
257 | 257 | |
258 | 258 | if($is_freetds === null) { |
259 | - ob_start(); |
|
260 | - phpinfo(INFO_MODULES); |
|
261 | - $info=ob_get_contents(); |
|
262 | - ob_end_clean(); |
|
259 | + ob_start(); |
|
260 | + phpinfo(INFO_MODULES); |
|
261 | + $info=ob_get_contents(); |
|
262 | + ob_end_clean(); |
|
263 | 263 | |
264 | - $is_freetds = (strpos($info,'FreeTDS') !== false); |
|
264 | + $is_freetds = (strpos($info,'FreeTDS') !== false); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | return $is_freetds; |
268 | - } |
|
268 | + } |
|
269 | 269 | } |
270 | 270 | \ No newline at end of file |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | var $templateDir = 'modules/'; |
51 | 51 | var $ss; |
52 | 52 | function TemplateHandler() { |
53 | - $this->cacheDir = sugar_cached(''); |
|
53 | + $this->cacheDir = sugar_cached(''); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | function loadSmarty(){ |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | * |
67 | 67 | */ |
68 | 68 | static function clearAll() { |
69 | - global $beanList; |
|
70 | - foreach($beanList as $module_dir =>$object_name){ |
|
69 | + global $beanList; |
|
70 | + foreach($beanList as $module_dir =>$object_name){ |
|
71 | 71 | TemplateHandler::clearCache($module_dir); |
72 | - } |
|
72 | + } |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | foreach($panel as $row) { |
133 | 133 | foreach($row as $entry) { |
134 | 134 | if(empty($entry)) { |
135 | - continue; |
|
135 | + continue; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | if(is_array($entry) && |
@@ -140,35 +140,35 @@ discard block |
||
140 | 140 | isset($entry['displayParams']) && |
141 | 141 | isset($entry['displayParams']['required']) && |
142 | 142 | $entry['displayParams']['required']) { |
143 | - $panelFields[$entry['name']] = $entry; |
|
143 | + $panelFields[$entry['name']] = $entry; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | if(is_array($entry)) { |
147 | - $defs2[$entry['name']] = $entry; |
|
147 | + $defs2[$entry['name']] = $entry; |
|
148 | 148 | } else { |
149 | - $defs2[$entry] = array('name' => $entry); |
|
149 | + $defs2[$entry] = array('name' => $entry); |
|
150 | 150 | } |
151 | 151 | } //foreach |
152 | 152 | } //foreach |
153 | 153 | } //foreach |
154 | 154 | |
155 | 155 | foreach($panelFields as $field=>$value) { |
156 | - $nameList = array(); |
|
157 | - if(!is_array($value['displayParams']['required'])) { |
|
158 | - $nameList[] = $field; |
|
159 | - } else { |
|
160 | - foreach($value['displayParams']['required'] as $groupedField) { |
|
161 | - $nameList[] = $groupedField; |
|
162 | - } |
|
163 | - } |
|
164 | - |
|
165 | - foreach($nameList as $x) { |
|
166 | - if(isset($defs[$x]) && |
|
156 | + $nameList = array(); |
|
157 | + if(!is_array($value['displayParams']['required'])) { |
|
158 | + $nameList[] = $field; |
|
159 | + } else { |
|
160 | + foreach($value['displayParams']['required'] as $groupedField) { |
|
161 | + $nameList[] = $groupedField; |
|
162 | + } |
|
163 | + } |
|
164 | + |
|
165 | + foreach($nameList as $x) { |
|
166 | + if(isset($defs[$x]) && |
|
167 | 167 | isset($defs[$x]['type']) && |
168 | 168 | !isset($defs[$x]['required'])) { |
169 | 169 | $defs[$x]['required'] = true; |
170 | - } |
|
171 | - } |
|
170 | + } |
|
171 | + } |
|
172 | 172 | } //foreach |
173 | 173 | |
174 | 174 | //Create a base class with field_name_map property |
@@ -195,23 +195,23 @@ discard block |
||
195 | 195 | //5) not already been added to Array |
196 | 196 | foreach($sugarbean->field_name_map as $name=>$def) { |
197 | 197 | |
198 | - if($def['type']=='relate' && |
|
198 | + if($def['type']=='relate' && |
|
199 | 199 | isset($defs2[$name]) && |
200 | 200 | (!isset($defs2[$name]['validateDependency']) || $defs2[$name]['validateDependency'] === true) && |
201 | 201 | isset($def['id_name']) && |
202 | 202 | !in_array($name, $validatedFields)) { |
203 | 203 | |
204 | - if(isset($mod_strings[$def['vname']]) |
|
204 | + if(isset($mod_strings[$def['vname']]) |
|
205 | 205 | || isset($app_strings[$def['vname']]) |
206 | 206 | || translate($def['vname'],$sugarbean->module_dir) != $def['vname']) { |
207 | - $vname = $def['vname']; |
|
208 | - } |
|
209 | - else{ |
|
210 | - $vname = "undefined"; |
|
211 | - } |
|
212 | - $javascript->addToValidateBinaryDependency($name, 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty($vname), (!empty($def['required']) ? 'true' : 'false'), '', $def['id_name']); |
|
213 | - $validatedFields[] = $name; |
|
214 | - } |
|
207 | + $vname = $def['vname']; |
|
208 | + } |
|
209 | + else{ |
|
210 | + $vname = "undefined"; |
|
211 | + } |
|
212 | + $javascript->addToValidateBinaryDependency($name, 'alpha', $javascript->buildStringToTranslateInSmarty('ERR_SQS_NO_MATCH_FIELD').': '.$javascript->buildStringToTranslateInSmarty($vname), (!empty($def['required']) ? 'true' : 'false'), '', $def['id_name']); |
|
213 | + $validatedFields[] = $name; |
|
214 | + } |
|
215 | 215 | } //foreach |
216 | 216 | |
217 | 217 | $contents .= "{literal}\n"; |
@@ -275,11 +275,11 @@ discard block |
||
275 | 275 | } |
276 | 276 | $file = $this->cacheDir . $this->templateDir . $module . '/' . $view . '.tpl'; |
277 | 277 | if(file_exists($file)) { |
278 | - return $this->ss->fetch($file); |
|
278 | + return $this->ss->fetch($file); |
|
279 | 279 | } else { |
280 | - global $app_strings; |
|
281 | - $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'] .": $file"); |
|
282 | - return $app_strings['ERR_NO_SUCH_FILE'] .": $file"; |
|
280 | + global $app_strings; |
|
281 | + $GLOBALS['log']->fatal($app_strings['ERR_NO_SUCH_FILE'] .": $file"); |
|
282 | + return $app_strings['ERR_NO_SUCH_FILE'] .": $file"; |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
@@ -329,13 +329,13 @@ discard block |
||
329 | 329 | } |
330 | 330 | $qsd->setFormName($view); |
331 | 331 | if(preg_match('/^SearchForm_.+/', $view)){ |
332 | - if(strpos($view, 'popup_query_form')){ |
|
333 | - $qsd->setFormName('popup_query_form'); |
|
334 | - $parsedView = 'advanced'; |
|
335 | - }else{ |
|
336 | - $qsd->setFormName('search_form'); |
|
337 | - $parsedView = preg_replace("/^SearchForm_/", "", $view); |
|
338 | - } |
|
332 | + if(strpos($view, 'popup_query_form')){ |
|
333 | + $qsd->setFormName('popup_query_form'); |
|
334 | + $parsedView = 'advanced'; |
|
335 | + }else{ |
|
336 | + $qsd->setFormName('search_form'); |
|
337 | + $parsedView = preg_replace("/^SearchForm_/", "", $view); |
|
338 | + } |
|
339 | 339 | //Loop through the Meta-Data fields to see which ones need quick search support |
340 | 340 | foreach($defs as $f) { |
341 | 341 | $field = $f; |
@@ -373,14 +373,14 @@ discard block |
||
373 | 373 | $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSContact($field['name'], $field['id_name']); |
374 | 374 | } |
375 | 375 | } else { |
376 | - $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent($field['module']); |
|
377 | - if(!isset($field['field_list']) && !isset($field['populate_list'])) { |
|
378 | - $sqs_objects[$name.'_'.$parsedView]['populate_list'] = array($field['name'], $field['id_name']); |
|
379 | - $sqs_objects[$name.'_'.$parsedView]['field_list'] = array('name', 'id'); |
|
380 | - } else { |
|
381 | - $sqs_objects[$name.'_'.$parsedView]['populate_list'] = $field['field_list']; |
|
382 | - $sqs_objects[$name.'_'.$parsedView]['field_list'] = $field['populate_list']; |
|
383 | - } |
|
376 | + $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent($field['module']); |
|
377 | + if(!isset($field['field_list']) && !isset($field['populate_list'])) { |
|
378 | + $sqs_objects[$name.'_'.$parsedView]['populate_list'] = array($field['name'], $field['id_name']); |
|
379 | + $sqs_objects[$name.'_'.$parsedView]['field_list'] = array('name', 'id'); |
|
380 | + } else { |
|
381 | + $sqs_objects[$name.'_'.$parsedView]['populate_list'] = $field['field_list']; |
|
382 | + $sqs_objects[$name.'_'.$parsedView]['field_list'] = $field['populate_list']; |
|
383 | + } |
|
384 | 384 | } |
385 | 385 | } else if($field['type'] == 'parent') { |
386 | 386 | $sqs_objects[$name.'_'.$parsedView] = $qsd->getQSParent(); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | } //foreach |
389 | 389 | |
390 | 390 | foreach ( $sqs_objects as $name => $field ) |
391 | - foreach ( $field['populate_list'] as $key => $fieldname ) |
|
391 | + foreach ( $field['populate_list'] as $key => $fieldname ) |
|
392 | 392 | $sqs_objects[$name]['populate_list'][$key] = $sqs_objects[$name]['populate_list'][$key] . '_'.$parsedView; |
393 | 393 | }else{ |
394 | 394 | //Loop through the Meta-Data fields to see which ones need quick search support |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | $field['id_name'] = $module.$field['id_name']; |
414 | 414 | } |
415 | 415 | } |
416 | - $name = $qsd->form_name . '_' . $field['name']; |
|
416 | + $name = $qsd->form_name . '_' . $field['name']; |
|
417 | 417 | |
418 | 418 | |
419 | 419 | if($field['type'] == 'relate' && isset($field['module']) && (preg_match('/_name$|_c$/si',$name) || !empty($field['quicksearch']))) { |
@@ -427,15 +427,15 @@ discard block |
||
427 | 427 | } else if($matches[0] == 'Users'){ |
428 | 428 | if($field['name'] == 'reports_to_name'){ |
429 | 429 | $sqs_objects[$name] = $qsd->getQSUser('reports_to_name','reports_to_id'); |
430 | - // Bug #52994 : QuickSearch for a 1-M User relationship changes assigned to user |
|
430 | + // Bug #52994 : QuickSearch for a 1-M User relationship changes assigned to user |
|
431 | 431 | }elseif($field['name'] == 'assigned_user_name'){ |
432 | - $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name','assigned_user_id'); |
|
433 | - } |
|
434 | - else |
|
435 | - { |
|
436 | - $sqs_objects[$name] = $qsd->getQSUser($field['name'], $field['id_name']); |
|
432 | + $sqs_objects[$name] = $qsd->getQSUser('assigned_user_name','assigned_user_id'); |
|
433 | + } |
|
434 | + else |
|
435 | + { |
|
436 | + $sqs_objects[$name] = $qsd->getQSUser($field['name'], $field['id_name']); |
|
437 | 437 | |
438 | - } |
|
438 | + } |
|
439 | 439 | } else if($matches[0] == 'Campaigns') { |
440 | 440 | $sqs_objects[$name] = $qsd->loadQSObject('Campaigns', 'Campaign', $field['name'], $field['id_name'], $field['id_name']); |
441 | 441 | } else if($matches[0] == 'Accounts') { |
@@ -486,39 +486,39 @@ discard block |
||
486 | 486 | //merge populate_list && field_list with vardef |
487 | 487 | if (!empty($field['field_list']) && !empty($field['populate_list'])) { |
488 | 488 | for ($j=0; $j<count($field['field_list']); $j++) { |
489 | - //search for the same couple (field_list_item,populate_field_item) |
|
490 | - $field_list_item = $field['field_list'][$j]; |
|
491 | - $field_list_item_alternate = $qsd->form_name . '_' . $field['field_list'][$j]; |
|
492 | - $populate_list_item = $field['populate_list'][$j]; |
|
493 | - $found = false; |
|
494 | - for ($k=0; $k<count($sqs_objects[$name]['field_list']); $k++) { |
|
495 | - if (($field_list_item == $sqs_objects[$name]['populate_list'][$k] || $field_list_item_alternate == $sqs_objects[$name]['populate_list'][$k]) && //il faut inverser field_list et populate_list (cf lignes 465,466 ci-dessus) |
|
496 | - $populate_list_item == $sqs_objects[$name]['field_list'][$k]) { |
|
497 | - $found = true; |
|
498 | - break; |
|
499 | - } |
|
500 | - } |
|
501 | - if (!$found) { |
|
502 | - $sqs_objects[$name]['field_list'][] = $field['populate_list'][$j]; // as in lines 462 and 463 |
|
503 | - $sqs_objects[$name]['populate_list'][] = $field['field_list'][$j]; |
|
504 | - } |
|
505 | - } |
|
489 | + //search for the same couple (field_list_item,populate_field_item) |
|
490 | + $field_list_item = $field['field_list'][$j]; |
|
491 | + $field_list_item_alternate = $qsd->form_name . '_' . $field['field_list'][$j]; |
|
492 | + $populate_list_item = $field['populate_list'][$j]; |
|
493 | + $found = false; |
|
494 | + for ($k=0; $k<count($sqs_objects[$name]['field_list']); $k++) { |
|
495 | + if (($field_list_item == $sqs_objects[$name]['populate_list'][$k] || $field_list_item_alternate == $sqs_objects[$name]['populate_list'][$k]) && //il faut inverser field_list et populate_list (cf lignes 465,466 ci-dessus) |
|
496 | + $populate_list_item == $sqs_objects[$name]['field_list'][$k]) { |
|
497 | + $found = true; |
|
498 | + break; |
|
499 | + } |
|
500 | + } |
|
501 | + if (!$found) { |
|
502 | + $sqs_objects[$name]['field_list'][] = $field['populate_list'][$j]; // as in lines 462 and 463 |
|
503 | + $sqs_objects[$name]['populate_list'][] = $field['field_list'][$j]; |
|
504 | + } |
|
505 | + } |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | } //foreach |
509 | 509 | } |
510 | 510 | |
511 | - //Implement QuickSearch for the field |
|
512 | - if(!empty($sqs_objects) && count($sqs_objects) > 0) { |
|
513 | - $quicksearch_js = '<script language="javascript">'; |
|
514 | - $quicksearch_js.= 'if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}'; |
|
515 | - $json = getJSONobj(); |
|
516 | - foreach($sqs_objects as $sqsfield=>$sqsfieldArray){ |
|
517 | - $quicksearch_js .= "sqs_objects['$sqsfield']={$json->encode($sqsfieldArray)};"; |
|
518 | - } |
|
519 | - return $quicksearch_js . '</script>'; |
|
520 | - } |
|
521 | - return ''; |
|
511 | + //Implement QuickSearch for the field |
|
512 | + if(!empty($sqs_objects) && count($sqs_objects) > 0) { |
|
513 | + $quicksearch_js = '<script language="javascript">'; |
|
514 | + $quicksearch_js.= 'if(typeof sqs_objects == \'undefined\'){var sqs_objects = new Array;}'; |
|
515 | + $json = getJSONobj(); |
|
516 | + foreach($sqs_objects as $sqsfield=>$sqsfieldArray){ |
|
517 | + $quicksearch_js .= "sqs_objects['$sqsfield']={$json->encode($sqsfieldArray)};"; |
|
518 | + } |
|
519 | + return $quicksearch_js . '</script>'; |
|
520 | + } |
|
521 | + return ''; |
|
522 | 522 | } |
523 | 523 | |
524 | 524 |
@@ -44,45 +44,45 @@ |
||
44 | 44 | */ |
45 | 45 | class ConnectorFactory{ |
46 | 46 | |
47 | - static $source_map = array(); |
|
47 | + static $source_map = array(); |
|
48 | 48 | |
49 | - public static function getInstance($source_name){ |
|
50 | - if(empty(self::$source_map[$source_name])) { |
|
51 | - require_once('include/connectors/sources/SourceFactory.php'); |
|
52 | - require_once('include/connectors/component.php'); |
|
53 | - $source = SourceFactory::getSource($source_name); |
|
54 | - $component = new component(); |
|
55 | - $component->setSource($source); |
|
56 | - $component->init(); |
|
57 | - self::$source_map[$source_name] = $component; |
|
58 | - } |
|
59 | - return self::$source_map[$source_name]; |
|
60 | - } |
|
49 | + public static function getInstance($source_name){ |
|
50 | + if(empty(self::$source_map[$source_name])) { |
|
51 | + require_once('include/connectors/sources/SourceFactory.php'); |
|
52 | + require_once('include/connectors/component.php'); |
|
53 | + $source = SourceFactory::getSource($source_name); |
|
54 | + $component = new component(); |
|
55 | + $component->setSource($source); |
|
56 | + $component->init(); |
|
57 | + self::$source_map[$source_name] = $component; |
|
58 | + } |
|
59 | + return self::$source_map[$source_name]; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Split the class name by _ and go through the class name |
|
64 | - * which represents the inheritance structure to load up all required parents. |
|
65 | - * @param string $class the root class we want to load. |
|
66 | - */ |
|
67 | - public static function load($class, $type){ |
|
68 | - self::loadClass($class, $type); |
|
69 | - } |
|
62 | + /** |
|
63 | + * Split the class name by _ and go through the class name |
|
64 | + * which represents the inheritance structure to load up all required parents. |
|
65 | + * @param string $class the root class we want to load. |
|
66 | + */ |
|
67 | + public static function load($class, $type){ |
|
68 | + self::loadClass($class, $type); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * include a source class file. |
|
73 | - * @param string $class a class file to include. |
|
74 | - */ |
|
75 | - public static function loadClass($class, $type){ |
|
76 | - $dir = str_replace('_','/',$class); |
|
77 | - $parts = explode("/", $dir); |
|
78 | - $file = $parts[count($parts)-1] . '.php'; |
|
79 | - if(file_exists("custom/modules/Connectors/connectors/{$type}/{$dir}/$file")){ |
|
80 | - require_once("custom/modules/Connectors/connectors/{$type}/{$dir}/$file"); |
|
81 | - } else if(file_exists("modules/Connectors/connectors/{$type}/{$dir}/$file")) { |
|
82 | - require_once("modules/Connectors/connectors/{$type}/{$dir}/$file"); |
|
83 | - } else if(file_exists("connectors/{$type}/{$dir}/$file")) { |
|
84 | - require_once("connectors/{$type}/{$dir}/$file"); |
|
85 | - } |
|
86 | - } |
|
71 | + /** |
|
72 | + * include a source class file. |
|
73 | + * @param string $class a class file to include. |
|
74 | + */ |
|
75 | + public static function loadClass($class, $type){ |
|
76 | + $dir = str_replace('_','/',$class); |
|
77 | + $parts = explode("/", $dir); |
|
78 | + $file = $parts[count($parts)-1] . '.php'; |
|
79 | + if(file_exists("custom/modules/Connectors/connectors/{$type}/{$dir}/$file")){ |
|
80 | + require_once("custom/modules/Connectors/connectors/{$type}/{$dir}/$file"); |
|
81 | + } else if(file_exists("modules/Connectors/connectors/{$type}/{$dir}/$file")) { |
|
82 | + require_once("modules/Connectors/connectors/{$type}/{$dir}/$file"); |
|
83 | + } else if(file_exists("connectors/{$type}/{$dir}/$file")) { |
|
84 | + require_once("connectors/{$type}/{$dir}/$file"); |
|
85 | + } |
|
86 | + } |
|
87 | 87 | } |
88 | 88 | ?> |
89 | 89 | \ No newline at end of file |