1<?php
2	class switchpanel_case_close{
3		public static function getSvg( $oCase, $iX, $iY, $opt ){
4			$sSvg = '';
5			if( isset( $oCase[ 'options' ][ 'link' ] ) ){
6				$sSvg .= '<a xlink:href="'.$oCase[ 'options' ][ 'link' ].'" target="'.( isset( $oCase[ 'options' ][ 'target' ] ) ? $oCase[ 'options' ][ 'target' ] : $opt[ 'target' ] ).'" style="text-decoration:none">';
7			}
8			if( isset( $oCase[ 'options' ][ 'text' ] ) ){
9				$sLabel = str_replace( "\\", "\\'", isset( $oCase[ 'label' ] ) ? $oCase[ 'label' ] : '' );
10				$sTitle = str_replace( "\\", "\\'", isset( $oCase[ 'title' ] ) ? $oCase[ 'title' ] : '' );
11				$sText = str_replace( "\\", "\\'", $oCase[ 'options' ][ 'text' ] );
12				$sLink = str_replace( "\\", "\\'", isset( $oCase[ 'options' ][ 'link' ] ) ? $oCase[ 'options' ][ 'link' ] : '' );
13				if( isset( $oCase[ 'options' ][ 'textlink' ] ) ){
14					$sLink = str_replace( "\\", "\\'", $oCase[ 'options' ][ 'textlink' ] );
15				}
16				$sSvg .= '<g onmousemove="window.oSwitchPanel.showToolTip(evt, \''.$sLabel.'\', \''.$sTitle.'\', \''.$sText.'\', \''.$sLink.'\')" onmouseout="window.oSwitchPanel.hideToolTip()">';
17			}
18
19			// Case color
20			$sColor = $opt[ 'color' ];
21			if( isset( $oCase[ 'options' ][ 'color' ] ) ){
22				$sColor = $oCase[ 'options' ][ 'color' ];
23			}
24
25			// Label background color
26			$sLabelBgColor = $opt[ 'labelBgColor' ];
27			if( isset( $oCase[ 'options' ][ 'labelBgColor' ] ) ){
28				$sLabelBgColor = $oCase[ 'options' ][ 'labelBgColor' ];
29			}
30
31			// Label text color
32			$sLabelTxtColor = $opt[ 'labelTxtColor' ];
33			if( isset( $oCase[ 'options' ][ 'labelTxtColor' ] ) ){
34				$sLabelTxtColor = $oCase[ 'options' ][ 'labelTxtColor' ];
35			}
36
37
38			$sSvg .= '<rect x="'.$iX.'" y="'.$iY.'" width="'.$opt[ 'elementWidth' ].'" height="'.$opt[ 'elementHeight' ].'" fill="'.$sColor.'"/>
39
40				<rect x="'.$iX.'" y="'.$iY.'" width="'.$opt[ 'elementWidth' ].'" height="'.( $opt[ 'elementHeight' ] / 2.65 ).'" stroke-width="'.( $opt[ 'elementWidth' ] / 30 ).'" stroke="#000000" fill="'.$sLabelBgColor.'" ry="1.5" rx="1.5"/>
41				<text x="'.( $iX + ( $opt[ 'elementWidth' ] / 2 ) ).'" y="'.( $iY + ( $opt[ 'elementHeight' ] / 3.6 ) ).'" style="font-weight:bold;" text-anchor="middle" font-family="sans-serif" font-size="'.( $opt[ 'elementWidth' ] * 0.27 ).'" fill="'.$sLabelTxtColor.'">'.$oCase[ 'label' ].'</text>
42				<line x1="'.( $iX + ( $opt[ 'elementWidth' ] / 8 ) ).'" y1="'.( $iY + ( $opt[ 'elementHeight' ] / 2 ) ).'" x2="'.( ( $iX + ( $opt[ 'elementWidth' ] / 8 ) ) + ( $opt[ 'elementWidth' ] / 1.35 ) ).'" y2="'.( ( $iY + ( $opt[ 'elementHeight' ] / 2 ) ) + ( $opt[ 'elementHeight' ] / 2.4 ) ).'" style="stroke:rgb(255,0,0);stroke-width:1" />
43				<line x1="'.( ( $iX + ( $opt[ 'elementWidth' ] / 8 ) ) + ( $opt[ 'elementWidth' ] / 1.35 ) ).'" y1="'.( $iY + ( $opt[ 'elementHeight' ] / 2 ) ).'" x2="'.( $iX + ( $opt[ 'elementWidth' ] / 8 ) ).'" y2="'.( ( $iY + ( $opt[ 'elementHeight' ] / 2 ) ) + ( $opt[ 'elementHeight' ] / 2.4 ) ).'" style="stroke:rgb(255,0,0);stroke-width:1" />
44				<rect x="'.( $iX + ( $opt[ 'elementWidth' ] / 8 ) ).'" y="'.( $iY + ( $opt[ 'elementHeight' ] / 2 ) ).'" width="'.( $opt[ 'elementWidth' ] / 1.35 ).'" height="'.( $opt[ 'elementHeight' ] / 2.4 ).'" fill="none" stroke="#000000"/>';
45
46			if( isset( $oCase[ 'title' ] ) ){
47				$sSvg .= '<text x="'.( $iX + ( $opt[ 'elementWidth' ] / 2 ) ).'" y="'.( $iY + ( $opt[ 'elementHeight' ] / 1.25 ) ).'" text-anchor="middle" font-family="sans-serif" font-size="'.( $opt[ 'elementWidth' ] * 0.3 ).'" fill="#ffffff">'.$oCase[ 'title' ].'</text>';
48			}
49			if( isset( $oCase[ 'options' ][ 'text' ] ) ){
50				$sSvg .= '</g>';
51			}
52			if( isset( $oCase[ 'options' ][ 'link' ] ) ){
53				$sSvg .= '</a>';
54			}
55
56			return $sSvg;
57		}
58	}
59