SZGoogleActionPanoramio

The SZ - Google SZGoogleActionPanoramio class.

Defined (1)

The class is defined in the following location(s).

/classes/action/SZGoogleActionPanoramio.php  
  1. class SZGoogleActionPanoramio extends SZGoogleAction 
  2. /** 
  3. * Function to create the HTML code of the 
  4. * module connected to the shortcode required 
  5. */ 
  6.  
  7. function getShortcode($atts, $content=null)  
  8. return $this->getHTMLCode(shortcode_atts(array( 
  9. 'template' => '', // default value 
  10. 'user' => '', // default value 
  11. 'group' => '', // default value 
  12. 'tag' => '', // default value 
  13. 'set' => '', // default value 
  14. 'width' => '', // default value 
  15. 'height' => '', // default value 
  16. 'bgcolor' => '', // default value 
  17. 'delay' => '', // default value 
  18. 'columns' => '', // default value 
  19. 'rows' => '', // default value 
  20. 'orientation' => '', // default value 
  21. 'listsize' => '', // default value 
  22. 'position' => '', // default value 
  23. 'paragraph' => '', // default value 
  24. 'action' => 'shortcode',  
  25. ), $atts), $content); 
  26.  
  27. /** 
  28. * Creating HTML code for the component called to 
  29. * be used in common for both widgets and shortcode 
  30. */ 
  31.  
  32. function getHTMLCode($atts=array(), $content=null) 
  33. if (!is_array($atts)) $atts = array(); 
  34.  
  35. // Extraction of the values **specified in shortcode, returned values 
  36. // **are contained in the variable names corresponding to the key 
  37.  
  38. extract(shortcode_atts(array( 
  39. 'template' => '', // default value 
  40. 'user' => '', // default value 
  41. 'group' => '', // default value 
  42. 'tag' => '', // default value 
  43. 'set' => '', // default value 
  44. 'width' => '', // default value 
  45. 'height' => '', // default value 
  46. 'bgcolor' => '', // default value 
  47. 'delay' => '', // default value 
  48. 'columns' => '', // default value 
  49. 'rows' => '', // default value 
  50. 'orientation' => '', // default value 
  51. 'listsize' => '', // default value 
  52. 'position' => '', // default value 
  53. 'paragraph' => '', // default value 
  54. 'action' => '', // default value 
  55. ), $atts)); 
  56.  
  57. // I delete spaces added and execute the transformation in string 
  58. // lowercase for the control of special values **such as "auto" 
  59.  
  60. $user = trim($user); 
  61. $group = trim($group); 
  62. $tag = trim($tag); 
  63. $set = strtolower(trim($set)); 
  64. $template = strtolower(trim($template)); 
  65. $width = strtolower(trim($width)); 
  66. $height = strtolower(trim($height)); 
  67. $bgcolor = strtolower(trim($bgcolor)); 
  68. $delay = strtolower(trim($delay)); 
  69. $columns = strtolower(trim($columns)); 
  70. $rows = strtolower(trim($rows)); 
  71. $listsize = strtolower(trim($listsize)); 
  72. $position = strtolower(trim($position)); 
  73. $paragraph = strtolower(trim($paragraph)); 
  74. $action = strtolower(trim($action)); 
  75.  
  76. // Loading options for the configuration variables  
  77. // containing the default values **for shortcodes and widgets 
  78.  
  79. $options = $this->getModuleOptions('SZGoogleModulePanoramio'); 
  80.  
  81. // Lettura delle opzioni per la definzione di parametri che non hanno 
  82. // specificato nessun valore e che saranno sostituiti con quelli di default 
  83.  
  84. if ($action == 'widget')  
  85. $DEFAULT_TEMPLATE = $options['panoramio_w_template']; 
  86. $DEFAULT_WIDTH = $options['panoramio_w_width']; 
  87. $DEFAULT_HEIGHT = $options['panoramio_w_height']; 
  88. $DEFAULT_LIST_SIZE = $options['panoramio_w_list_size']; 
  89. $DEFAULT_POSITION = $options['panoramio_w_position']; 
  90. $DEFAULT_ORIENTATION = $options['panoramio_w_orientation']; 
  91. $DEFAULT_PARAGRAPH = $options['panoramio_w_paragraph']; 
  92. $DEFAULT_DELAY = $options['panoramio_w_delay']; 
  93. $DEFAULT_SET = $options['panoramio_w_set']; 
  94. $DEFAULT_COLUMNS = $options['panoramio_w_columns']; 
  95. $DEFAULT_ROWS = $options['panoramio_w_rows']; 
  96.  
  97. } else { 
  98.  
  99. $DEFAULT_TEMPLATE = $options['panoramio_s_template']; 
  100. $DEFAULT_WIDTH = $options['panoramio_s_width']; 
  101. $DEFAULT_HEIGHT = $options['panoramio_s_height']; 
  102. $DEFAULT_LIST_SIZE = $options['panoramio_s_list_size']; 
  103. $DEFAULT_POSITION = $options['panoramio_s_position']; 
  104. $DEFAULT_ORIENTATION = $options['panoramio_s_orientation']; 
  105. $DEFAULT_PARAGRAPH = $options['panoramio_s_paragraph']; 
  106. $DEFAULT_DELAY = $options['panoramio_s_delay']; 
  107. $DEFAULT_SET = $options['panoramio_s_set']; 
  108. $DEFAULT_COLUMNS = $options['panoramio_s_columns']; 
  109. $DEFAULT_ROWS = $options['panoramio_s_rows']; 
  110.  
  111. // Controllo la variabile che controlla il paragrafo vuoto da aggiungere 
  112. // dopo il blocco di codice (shortocde) per compatibilit al post di wordpress 
  113.  
  114. if ($paragraph == 'true') $paragraph = '1'; 
  115. if ($paragraph == 'false') $paragraph = '0'; 
  116.  
  117. if (!in_array($paragraph, array('1', '0'))) $paragraph = $DEFAULT_PARAGRAPH; 
  118.  
  119. // Controllo la coerenza delle opzioni di elaborazione modulo e  
  120. // sostituzione con valori di default quando presentano dei problemi 
  121.  
  122. if (!in_array($template , array('photo', 'slideshow', 'list', 'photo_list'))) $template = $DEFAULT_TEMPLATE; 
  123. if (!in_array($set , array('all', 'public', 'recent'))) $set = $DEFAULT_SET; 
  124. if (!in_array($orientation, array('horizontal', 'vertical'))) $orientation = $DEFAULT_ORIENTATION; 
  125. if (!in_array($position , array('left', 'top', 'right', 'bottom'))) $position = $DEFAULT_POSITION; 
  126.  
  127. if (!ctype_xdigit(str_replace("#", "", $bgcolor))) $bgcolor = ''; 
  128. if (!is_numeric($delay) or $delay < 0) $delay = $DEFAULT_DELAY;  
  129.  
  130. if (!ctype_digit($columns)) $columns = $DEFAULT_COLUMNS;  
  131. if (!ctype_digit($rows)) $rows = $DEFAULT_ROWS; 
  132. if (!ctype_digit($listsize)) $listsize = $DEFAULT_LIST_SIZE;  
  133.  
  134. // Controllo i valori passati in array che specificano la dimensione del widget 
  135. // in caso contrario imposto il valore su quello specificato nelle opzioni 
  136.  
  137. if (!is_numeric($width) and $width != 'auto') $width = $DEFAULT_WIDTH; 
  138. if (!is_numeric($height) and $height != 'auto') $height = $DEFAULT_HEIGHT; 
  139.  
  140. // Controllo la dimensione del widget e controllo formale dei valori numerici 
  141. // se trovo qualche incongruenza applico i valori di default prestabiliti 
  142.  
  143. if ($width == '') $width = "'+w+'"; 
  144. if ($width == 'auto') $width = "'+w+'"; 
  145.  
  146. if ($height == '') $height = '300'; 
  147. if ($height == 'auto') $height = '300'; 
  148.  
  149. // Creazione identificativo univoco per riconoscere il codice embed  
  150. // nel caso la funzioine venga richiamata pi volte nella stessa pagina 
  151.  
  152. $unique = md5(uniqid(), false); 
  153. $keyIDs = 'sz-google-panoramio-'.$unique; 
  154.  
  155. // Creazione codice HTML per inserimento javascript di google  
  156.  
  157. $HTML = '<div class="sz-google-panoramio">'; 
  158. $HTML .= '<div class="sz-google-panoramio-wrap">'; 
  159. $HTML .= '<div class="sz-google-panoramio-iframe" id="'.$keyIDs.'">'; 
  160.  
  161. $HTML .= '<script type="text/javascript">'; 
  162. $HTML .= "var w=document.getElementById('".$keyIDs."').offsetWidth;"; 
  163. $HTML .= "var h='<'+'"; 
  164.  
  165. $HTML .= 'iframe src="https://ssl.panoramio.com/wapi/template/'.$template.'.html?'; 
  166. $HTML .= 'width=' .$width; 
  167. $HTML .= '&height=' .$height; 
  168. $HTML .= '&bgcolor=' .rawurlencode($bgcolor); 
  169. $HTML .= '&delay=' .rawurlencode($delay); 
  170. $HTML .= '&columns=' .rawurlencode($columns); 
  171. $HTML .= '&rows=' .rawurlencode($rows); 
  172. $HTML .= '&orientation='.rawurlencode($orientation); 
  173. $HTML .= '&list_size=' .rawurlencode($listsize); 
  174. $HTML .= '&position=' .rawurlencode($position); 
  175.  
  176. if ($user != '') $HTML .= '&user=' .rawurlencode($user); 
  177. if ($group != '') $HTML .= '&group='.rawurlencode($group); 
  178. if ($tag != '') $HTML .= '&tag=' .rawurlencode($tag); 
  179.  
  180. if ($user == '' and $group == '' and $tag == '') { 
  181. if ($set != '') $HTML .= '&set='.rawurlencode($set); 
  182.  
  183. $HTML .= '" '; 
  184. $HTML .= 'scrolling="no" frameborder="0" marginwidth="0" marginheight="0" '; 
  185. $HTML .= 'width="'.$width.'" '; 
  186. $HTML .= 'height="'.$height.'"'; 
  187. $HTML .= "></'+'iframe'+'>';"; 
  188. $HTML .= "document.write(h);"; 
  189. $HTML .= '</script>'; 
  190.  
  191. $HTML .= '</div>'; 
  192. $HTML .= '</div>'; 
  193. $HTML .= '</div>'; 
  194.  
  195. if ($action != 'widget' and $paragraph == '1') { 
  196. $HTML .= '<p></p>'; 
  197.  
  198. // Return from the function with the whole string containing  
  199. // the HTML code for inserting the code in the page 
  200.  
  201. return $HTML;