Blame view

plugins/content/embed_google_map/embedGoogleMapParser.php 4.67 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
<?php
/**
* @version		$Id: Embed Google Map v2.0.1 2015-03-28 16:06 $
* @package		Joomla 1.6
* @copyright	Copyright (C) 2014-2015 Petteri Kivimki. All rights reserved.
* @author		Petteri Kivimki
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/

  class EmbedGoogleMapParser {
	
	public function parse($string, &$params) {
      $arr = explode('|',$string);
      $params->setAddress($arr[0]);

      foreach ( $arr as $phrase ) { 
        if ( strstr(strtolower($phrase), 'version:') )	
        {         
          $tpm1 = explode(':',$phrase);
		  $tmp1 = trim($tpm1[1], '"');
		  if(strcmp(strtolower($tmp1),'new') == 0) {
		    $params->setVersion("new");
		  } else if(strcmp(strtolower($tmp1),'classic') == 0) {
		    $params->setVersion("classic");
		  } else if(strcmp(strtolower($tmp1),'embed') == 0) {
		    $params->setVersion("embed");
		  }        
        }
		
        if ( strstr(strtolower($phrase), 'zoom:') )	
        {         
          $tpm1 = explode(':',$phrase);
          $params->setZoomLevel(trim($tpm1[1], '"'));
        }
        
        if ( strstr(strtolower($phrase), 'height:') )	
        {         
          $tpm1 = explode(':',$phrase);
          $params->setHeight(trim($tpm1[1], '"'));
        }
            
        if ( strstr(strtolower($phrase), 'width:') )
        {
          $tpm1 = explode(':',$phrase);
          $params->setWidth(trim($tpm1[1], '"'));
        }
        
        if ( strstr(strtolower($phrase), 'border:') )	
        {         
          $tpm1 = explode(':',$phrase);
          $params->setBorder(trim($tpm1[1], '"'));
        }	
        
        if ( strstr(strtolower($phrase), 'border_style:') )	
        {         
          $tpm1 = explode(':',$phrase);        	
          $border_style = trim($tpm1[1], '"');
          $border_style = ( preg_match('/^(none|hidden|dotted|dashed|solid|double)$/i', $border_style) ? $border_style : 'solid' );
          $params->setBorderStyle($border_style);
        }	
        
        if ( strstr(strtolower($phrase), 'border_color:') )	
        {         
          $tpm1 = explode(':',$phrase);
          $params->setBorderColor(trim($tpm1[1], '"'));        	
        }	
        
        if ( strstr(strtolower($phrase), 'lang:') )	
        {         
          $tpm1 = explode(':',$phrase);
          $params->setLanguage(trim($tpm1[1], '"'));
        }        	
        
        if ( strstr(strtolower($phrase), 'link:') )
        {
          $tpm1 = explode(':',$phrase);
          $tmp1 = trim($tpm1[1], '"');
          if(strcmp(strtolower($tmp1),'yes') == 0) {
            $params->setAddLink(0);
          } else {
            $params->setAddLink(1);
          }
        }
        
        if ( strstr(strtolower($phrase), 'link_label:') )	
        {         
          $tpm1 = explode(':',$phrase);
          $params->setLinkLabel(trim($tpm1[1], '"'));
        }
		
        if ( strstr(strtolower($phrase), 'https:') )
        {
          $tpm1 = explode(':',$phrase);
          $tmp1 = trim($tpm1[1], '"');
          if(strcmp(strtolower($tmp1),'yes') == 0) {
            $params->setHttps(0);
          } else {
            $params->setHttps(1);
          }
        }		

		if ( strstr(strtolower($phrase), 'type:') )
		{
		  $tpm1 = explode(':',$phrase);
          $tmp1 = trim($tpm1[1], '"');
		  if(strcmp(strtolower($tmp1),'normal') == 0) {
		    $params->setMapType("m");
		  } else if(strcmp(strtolower($tmp1),'satellite') == 0) {
		    $params->setMapType("k");
		  } else if(strcmp(strtolower($tmp1),'hybrid') == 0) {
		    $params->setMapType("h");
		  } else if(strcmp(strtolower($tmp1),'terrain') == 0) {
		    $params->setMapType("p");
		  } 						
        }           
        
        if ( strstr(strtolower($phrase), 'link_full:') )
        {
          $tpm1 = explode(':',$phrase);
          $tmp1 = trim($tpm1[1], '"');
          if(strcmp(strtolower($tmp1),'yes') == 0) {
            $params->setLinkFull(0);
          } else {
            $params->setLinkFull(1);
          }
        }
      
        if ( strstr(strtolower($phrase), 'show_info:') )
        {
          $tpm1 = explode(':',$phrase);
          $tmp1 = trim($tpm1[1], '"');
          if(strcmp(strtolower($tmp1),'yes') == 0) {
            $params->setShowInfo(0);
          } else {
            $params->setShowInfo(1);
          }
        }
        
        if ( strstr(strtolower($phrase), 'info_label:') )	
        {         
          $tpm1 = explode(':',$phrase);
          $params->setInfoLabel(trim($tpm1[1], '"'));
        }		
      }
    }
  }

?>