{$Title} DATA_BIUNDARY; $SVG['C'][1]=<< {$Title} DATA_BIUNDARY; $SVG['C'][2]=<< {$Title} DATA_BIUNDARY; $SVG['C'][3]=<< {$Title} DATA_BIUNDARY; return str_ireplace( "\n",'',$SVG[$Layout][$CornerID] ); }; function createTrackBackground( $Layout, $Side, $LTitle, $RTitle ){ $SVG['C']['U']=<< {$LTitle} {$RTitle} DATA_BIUNDARY; $SVG['C']['B']=<< {$LTitle} {$RTitle} DATA_BIUNDARY; $SVG['E']['U']=<< {$Title} DATA_BIUNDARY; $SVG['E']['B']=<< {$Title} DATA_BIUNDARY; return str_ireplace( "\n",'',$SVG[$Layout][$Side] ); }; function createPlatformBackground( $Layout, $pid=0, $Modules=array() ){ $SVG['C']=<< %%%AREA%1%%% %%%AREA%2%%% %%%AREA%3%%% %%%AREA%4%%% DATA_BOUNDARY; $SVG['E']=<< %%%AREA%1%%% %%%AREA%2%%% %%%AREA%3%%% %%%AREA%4%%% DATA_BOUNDARY; if( isset( $Modules[0] ) ){ $as =($Modules[0]['status'])?'active_area':'passive_area'; $RPL = "{$Modules[0]['name']}"; $SVG[$Layout] = str_ireplace("%%%AREA%1%%%",$RPL,$SVG[$Layout]); } else { $SVG[$Layout] = str_ireplace("%%%AREA%1%%%",'',$SVG[$Layout]); }; if( isset( $Modules[1] ) ){ $as =($Modules[1]['status'])?'active_area':'passive_area'; $RPL = "{$Modules[1]['name']}"; $SVG[$Layout] = str_ireplace("%%%AREA%2%%%",$RPL,$SVG[$Layout]); } else { $SVG[$Layout] = str_ireplace("%%%AREA%2%%%",'',$SVG[$Layout]); }; if( isset( $Modules[2] ) ){ $as =($Modules[2]['status'])?'active_area':'passive_area'; $RPL = "{$Modules[2]['name']}"; $SVG[$Layout] = str_ireplace("%%%AREA%3%%%",$RPL,$SVG[$Layout]); } else { $SVG[$Layout] = str_ireplace("%%%AREA%3%%%",'',$SVG[$Layout]); }; if( isset( $Modules[3] ) ){ $as =($Modules[3]['status'])?'active_area':'passive_area'; $RPL = "{$Modules[3]['name']}"; $SVG[$Layout] = str_ireplace("%%%AREA%4%%%",$RPL,$SVG[$Layout]); } else { $SVG[$Layout] = str_ireplace("%%%AREA%4%%%",'',$SVG[$Layout]); }; return str_ireplace("\n",'',$SVG[$Layout]); }; function createPlatformAnimation( $PLayout, $PNames=array(), $Colors=array() ){ $SVG['C']=<< %%ANIMATION%% jjdgfjjdfh; $SVG['E']=<< %%ANIMATION%% khksdhfiwer; //Parameters - Start Point, Station Stop, End Point, Motion Duration, move to station, station stop, move from station $SVG_ANI_PARAMS['L']=array( 2210, 290,-700, 11, 2, 6, 3 ); // L -> to the left R -> To the right movement $SVG_ANI_PARAMS['R']=array( -1920, 930,1920, 12, 3, 6, 2 ); // Not Same duration makes animation Lifelike $SVG_ANI['C']=<< ksdhjfkhkie; $SVG_ANI['E']=<< ksjdhfksdhf; if( $LC = count( $Colors ) ){ switch( $PLayout ){ case 'A': $P_B = $P_A = $SVG_ANI_PARAMS['L'];break; case 'B': $P_B = $P_A = $SVG_ANI_PARAMS['R'];break; // UK-JAP case 'C': $P_A = $SVG_ANI_PARAMS['L']; $P_B = $SVG_ANI_PARAMS['R'];break; case 'D': $P_A = $SVG_ANI_PARAMS['R']; $P_B = $SVG_ANI_PARAMS['L'];break; // UK-JAP case 'E': $P_A = $SVG_ANI_PARAMS['L']; $P_B = $SVG_ANI_PARAMS['R'];break; case 'F': $P_A = $SVG_ANI_PARAMS['R']; $P_B = $SVG_ANI_PARAMS['L'];break; // UK-JAP }; $TOTAL_DURATION_A = $P_A[3]*$LC; $TOTAL_DURATION_B = $P_B[3]*$LC; $ATPL = $SVG_ANI[$PLayout]; $CT = 1/$LC; $TS_A = $P_A[4]/$P_A[3]; $SS_A = ($P_A[4]+$P_A[5])/$P_A[3]; $FS_A = ($P_A[4]+$P_A[5]+$P_A[6])/$P_A[3]; $TS_B = $P_B[4]/$P_B[3]; $SS_B = ($P_B[4]+$P_B[5])/$P_B[3]; $FS_B = ($P_B[4]+$P_B[5]+$P_B[6])/$P_B[3]; // Stop start stop-end $T_A = array($TS_A/$LC, $SS_A/$LC, $FS_A/$LC); $T_B = array($TS_B/$LC, $SS_B/$LC, $FS_B/$LC); $ANI = array(); $idx = 0; foreach( $Colors as $CC ){ $BT = $idx*$CT; $P_A_COORDS = $P_A[0].";".$P_A[0].";".$P_A[1].";".$P_A[1].";".$P_A[2].";".$P_A[2]; $P_B_COORDS = $P_B[0].";".$P_B[0].";".$P_B[1].";".$P_B[1].";".$P_B[2].";".$P_B[2]; $P_A_TIMING = "0;".$BT.";".($BT+$T_A[0]).";".($BT+$T_A[1]).";".($BT+$T_A[2]).";1"; $P_B_TIMING = "0;".$BT.";".($BT+$T_B[0]).";".($BT+$T_B[1]).";".($BT+$T_B[2]).";1"; $ANI[$idx] = str_ireplace('%%COLOR%%',$CC,$SVG_ANI[$PLayout] );//Load template $ANI[$idx] = str_ireplace('%%ACORDS%%',$P_A_COORDS,$ANI[$idx]); $ANI[$idx] = str_ireplace('%%ATIMES%%',$P_A_TIMING,$ANI[$idx]); $ANI[$idx] = str_ireplace('%%BCORDS%%',$P_B_COORDS,$ANI[$idx]); $ANI[$idx] = str_ireplace('%%BTIMES%%',$P_B_TIMING,$ANI[$idx]); $ANI[$idx] = str_ireplace('%%TOTA%%',$TOTAL_DURATION_A,$ANI[$idx]); $ANI[$idx] = str_ireplace('%%DTOTA%%',$TOTAL_DURATION_A*2,$ANI[$idx]); $ANI[$idx] = str_ireplace('%%TOTB%%',$TOTAL_DURATION_B,$ANI[$idx]); $ANI[$idx] = str_ireplace('%%DTOTB%%',$TOTAL_DURATION_B*2,$ANI[$idx]); $idx++; } $SVG[$PLayout]=str_ireplace('%%ANIMATION%%', implode( '', $ANI ),$SVG[$PLayout]); } else { $SVG[$PLayout]=str_ireplace('%%ANIMATION%%','',$SVG[$PLayout]); }; $Output = str_ireplace("\n",'',$SVG[$PLayout]); return $Output; }; function getPlatformLineInfo( $PID ){ global $DATABASE; $QS = "SELECT `ln`.`id`,`ln`.`short`,`ln`.`color` FROM `metro_lines` `ln` LEFT JOIN `metro_platforms_2_lines` `sl` ON ( `ln`.`id`=`sl`.`line_id` ) WHERE `sl`.`platform_id`={$PID} ORDER BY `ln`.`short`"; $R = $DATABASE->Query( $QS ); //get station index for each line $idx = 0; foreach( $R as $T ){ $QS = "SELECT `sl`.`station_id`, `sl`.`index` FROM `metro_stations_2_lines` `sl` LEFT JOIN `metro_platforms` `mp` ON ( `mp`.`station_id` = `sl`.`station_id` ) WHERE `mp`.`id`={$PID} AND `sl`.`line_id`={$T['id']}"; $Z = $DATABASE->Query( $QS ); if( count( $Z ) ) { $R[$idx]['index']=$Z[0]['index']; $R[$idx]['station_id']=$Z[0]['station_id']; } else { $R[$idx]['index']= 0; $R[$idx]['station_id']= 0; }; $idx++; }; return $R; }; function getPlatformInfo( $PID ){ global $DATABASE; $QS = "SELECT `ln`.`id`,`ln`.`short`,`ln`.`color` FROM `metro_lines` `ln` LEFT JOIN `metro_platforms_2_lines` `sl` ON ( `ln`.`id`=`sl`.`line_id` ) WHERE `sl`.`platform_id`={$PID} ORDER BY `ln`.`short`"; $R = $DATABASE->Query( $QS ); //get station index for each line $idx = 0; $P_PARTS = array(); $P_pidx = -1; $P_CSID = 0; $N_PARTS = array(); $N_pidx = -1; $N_CSID = 0; foreach( $R as $T ){ $QS = "SELECT `sl`.`station_id`, `sl`.`index` FROM `metro_stations_2_lines` `sl` LEFT JOIN `metro_platforms` `mp` ON ( `mp`.`station_id` = `sl`.`station_id` ) WHERE `mp`.`id`={$PID} AND `sl`.`line_id`={$T['id']}"; $Z = $DATABASE->Query( $QS ); if( count( $Z ) ) { $R[$idx]['index']=$Z[0]['index']; $R[$idx]['station_id']=$Z[0]['station_id']; } else { $R[$idx]['index']= 0; $R[$idx]['station_id']= 0; }; // Have Index if( $R[$idx]['index'] ){ $NSI = getLineStationInfo( $R[$idx]['id'], $R[$idx]['index']-1 ); if( count( $NSI ) ){ if( $N_CSID != $NSI['id'] ){ $N_CSID = $NSI['id']; $N_pidx++; }; $N_PARTS[$N_pidx]['name']=$NSI['name']; $N_PARTS[$N_pidx]['id']=$NSI['id']; $N_PARTS[$N_pidx]['colors'][]=$T['color']; }; $NSI = getLineStationInfo( $R[$idx]['id'], $R[$idx]['index']+1 ); if( count( $NSI ) ){ if( $P_CSID != $NSI['id'] ){ $P_CSID = $NSI['id']; $P_pidx++; }; $P_PARTS[$P_pidx]['name']=$NSI['name']; $P_PARTS[$N_pidx]['id']=$NSI['id']; $P_PARTS[$P_pidx]['colors'][]=$T['color']; }; }; $idx++; }; $R['INFO_COUNT'] = count( $R ); $R['NEXT_IS_MULTI']=( count( $N_PARTS ) > 1 ); $R['NEXT'] = array(); foreach( $N_PARTS as $P ){ $CZ['name']=$P['name']; $CZ['id'] = $P['id']; if( ( $CC = count( $P['colors'] ) ) > 1 ){ $CP = 100 / $CC; $COMAP = array(); for( $ix = 0; $ix < $CC; $ix++ ){ $SPO= intval( $ix * $CP ); $NPO= intval( ( $ix+1 ) * $CP ) - 1; if( $SPO < 2 ){ $COMAP[] = "#{$P['colors'][$ix]}, #{$P['colors'][$ix]} {$NPO}%"; } else if( $SPO > 90 ){ $COMAP[] = "#{$P['colors'][$ix]} {$SPO}%, #{$P['colors'][$ix]}"; } else { $COMAP[] = "#{$P['colors'][$ix]} {$SPO}%, #{$P['colors'][$ix]} {$NPO}%"; }; }; $GRADIENT = implode( ',', $COMAP );//writing-mode: vertical-lr;text-orientation: upright; $CZ['bg_style']="background-image: linear-gradient({$GRADIENT});"; } else { $CZ['bg_style']="background-color:#{$P['colors'][0]};"; }; $R['NEXT'][]=$CZ; }; $R['PREV_IS_MULTI']=( count( $P_PARTS ) > 1 ); $R['PREV'] = array(); foreach( $P_PARTS as $P ){ $CZ['name']=$P['name']; $CZ['id'] = $P['id']; if( ( $CC = count( $P['colors'] ) ) > 1 ){ $CP = 100 / $CC; $COMAP = array(); for( $ix = 0; $ix < $CC; $ix++ ){ $SPO= intval( $ix * $CP ); $NPO= intval( ( $ix+1 ) * $CP ) - 1; if( $SPO < 2 ){ $COMAP[] = "#{$P['colors'][$ix]}, #{$P['colors'][$ix]} {$NPO}%"; } else if( $SPO > 90 ){ $COMAP[] = "#{$P['colors'][$ix]} {$SPO}%, #{$P['colors'][$ix]}"; } else { $COMAP[] = "#{$P['colors'][$ix]} {$SPO}%, #{$P['colors'][$ix]} {$NPO}%"; }; }; $GRADIENT = implode( ',', $COMAP );//writing-mode: vertical-lr;text-orientation: upright; $CZ['bg_style']="background-image: linear-gradient({$GRADIENT});"; } else { $CZ['bg_style']="background-color:#{$P['colors'][0]};"; }; $R['PREV'][]=$CZ; }; return $R; }; function getLineStationInfo( $LID, $IDX ){ global $DATABASE; $QS = "SELECT `st`.`id`, `st`.`name` FROM `metro_stations` `st` LEFT JOIN `metro_stations_2_lines` `sl` ON ( `st`.`id`=`sl`.`station_id` ) WHERE `sl`.`line_id`={$LID} AND `sl`.`index`={$IDX}"; $RZ = $DATABASE->Query( $QS ); $INFO = array(); if( count( $RZ ) ) $INFO = $RZ[0]; return $INFO; } function createPlatformStationBlock( $PID, $D ){ $PINFO = getPlatformLineInfo( $PID ); $PARTS = array(); $pidx = -1; $CSID = 0; if( $D < 0 ){ $R_P = " "; $L_P = "
"; } else { $R_P = "
"; $L_P = ""; } else { $Output .= ""; }; }; return $Output; }; function getModleOnlineStatus( $MID ){ global $DATABASE; $QS = "SELECT `status`,`ts`,`SID` FROM `mem_online_cloud` WHERE `object_id`={$MID} AND `object_type`=2"; $RV = $DATABASE->Query( $QS, false ); if( count( $RV ) ) return $RV[0]; return array(); } function cmaera(){ }; function getStationName( $id ){ global $DATABASE; if( $id ){ $QS = "SELECT `name` FROM `metro_stations` WHERE `id`={$id}"; $RV = $DATABASE->Query( $QS, false ); if( count( $RV ) ) return $RV[0]['name']; }; return ''; }; function getTrackName( $id ){ global $DATABASE; if( $id ){ $QS = "SELECT `name` FROM `metro_tracks` WHERE `id`={$id}"; $RV = $DATABASE->Query( $QS, false ); if( count( $RV ) ) return $RV[0]['name']; }; return ''; }; function getModuleName( $id ){ global $DATABASE; if( $id ){ $QS = "SELECT `name` FROM `metro_modules` WHERE `id`={$id}"; $RV = $DATABASE->Query( $QS, false ); if( count( $RV ) ) return $RV[0]['name']; }; return ''; }; function getPlatformName( $id ){ global $DATABASE; if( $id ){ $QS = "SELECT `name` FROM `metro_platforms` WHERE `id`={$id}"; $RV = $DATABASE->Query( $QS, false ); if( count( $RV ) ) return $RV[0]['name']; }; return ''; }; function getOnlineStatus( $mid ){ global $DATABASE; if( $mid ){ $CTS = time() - 3; // 3 seconds lag $QS = "SELECT `status` FROM `mem_online_cloud` WHERE `object_id` = {$mid} AND `object_type`=10 AND `ts`>={$CTS}"; $RV = $DATABASE->Query( $QS, false ); if( count( $RV ) ) return intval( $RV[0]['status'] ); }; return false; }; function createTopLabel( $Station, $Platform, $Lines, $Track="", $color_class="" ){ if( $Track!=''){ $TR_INS=<<{$Track} DATA_BOUNDARY; } else { $TR_INS = ''; } $AA=<< {$TR_INS}
 "; }; foreach( $PINFO as $II ){ // If has more stations on the line //if( $II['index'] > 1 ) { $SI = getLineStationInfo( $II['id'], $II['index'] + $D ); if( count( $SI ) ){ if( $CSID != $SI['id'] ){ $CSID = $SI['id']; $pidx++; }; $PARTS[$pidx]['name']=$SI['name']; $PARTS[$pidx]['colors'][]=$II['color']; }; //}; }; $Output = ''; foreach( $PARTS as $P ){ if( ( $CC = count( $P['colors'] ) ) > 1 ){ $CP = 100 / $CC; $COMAP = array(); for( $ix = 0; $ix < $CC; $ix++ ){ $SPO= intval( $ix * $CP ); $NPO= intval( ( $ix+1 ) * $CP ) - 1; if( $SPO < 2 ){ $COMAP[] = "#{$P['colors'][$ix]}, #{$P['colors'][$ix]} {$NPO}%"; } else if( $SPO > 90 ){ $COMAP[] = "#{$P['colors'][$ix]} {$SPO}%, #{$P['colors'][$ix]}"; } else { $COMAP[] = "#{$P['colors'][$ix]} {$SPO}%, #{$P['colors'][$ix]} {$NPO}%"; }; }; $GRADIENT = implode( ',', $COMAP );//writing-mode: vertical-lr;text-orientation: upright; $Output .= "{$L_P}{$P['name']}{$R_P}{$L_P}{$P['name']}{$R_P}
{$Station}STATUS
{$Platform}
{$Lines}
DATA_BOUNDARY; return "{ xtype:'panel', border: false, frame: false, html: '". str_ireplace( "\n",'', $AA )."'}"; }; function createChopLabel( $line1, $line2, $Lines, $Track="", $color_class="", $oncli="", $atds="", $id ='' ){ if( $Track!=''){ $TR_INS=<<{$Track} DATA_BOUNDARY; } else { $TR_INS = ''; }; if( $atds!= "" ){ if( is_array( $atds ) ){ $ADDTD=' '; foreach( $atds as $A ) $ADDTD.=''.$A.''; } else { $ADDTD=' '.$atds.''; }; } else { $ADDTD=''; }; if( $oncli!=''){ $ACTION ='onclick="'.$oncli.';"'; } else { $ACTION =''; }; $AA=<< {$line1}{$TR_INS}{$ADDTD} {$line2} {$Lines} DATA_BOUNDARY; return "{ xtype:'panel', border: false, frame: false, html: '". str_ireplace( "\n",'', $AA )."'}"; }; ?>