SZGoogleWidgetPanoramio

The SZ - Google SZGoogleWidgetPanoramio class.

Defined (1)

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

/classes/widget/SZGoogleWidgetPanoramio.php  
  1. class SZGoogleWidgetPanoramio extends SZGoogleWidget 
  2. /** 
  3. * Definition the constructor function, which is called 
  4. * at the time of the creation of an instance of this class 
  5. */ 
  6.  
  7. function __construct()  
  8. parent::__construct('sz-google-panoramio', __('SZ-Google - Panoramio', 'szgoogleadmin'), array( 
  9. 'classname' => 'sz-widget-google sz-widget-google-panoramio sz-widget-google-panoramio-iframe',  
  10. 'description' => ucfirst(__('panoramio photos.', 'szgoogleadmin')) 
  11. )); 
  12.  
  13. /** 
  14. * Generation of the HTML code of the widget 
  15. * for the full display in the sidebar associated 
  16. */ 
  17.  
  18. function widget($args, $instance)  
  19. // Checking whether there are the variables that are used during the processing 
  20. // the script and check the default values **in case they were not specified 
  21.  
  22. $options = $this->common_empty(array( 
  23. 'template' => '', // default value 
  24. 'width' => '', // default value 
  25. 'height' => '', // default value 
  26. 'user' => '', // default value 
  27. 'group' => '', // default value 
  28. 'tag' => '', // default value 
  29. 'set' => '', // default value 
  30. 'columns' => '', // default value 
  31. 'rows' => '', // default value 
  32. 'orientation' => '', // default value 
  33. 'position' => '', // default value 
  34. ), $instance); 
  35.  
  36. // Definition of the control variables of the widget, these values* 
  37. // do not affect the items of basic but affect some aspects 
  38.  
  39. $controls = $this->common_empty(array( 
  40. 'width_auto' => '', // default value 
  41. 'height_auto' => '', // default value 
  42. ), $instance); 
  43.  
  44. // Correction of the value of size is specified in 
  45. // the case the automatically and then use javascript 
  46.  
  47. if ($controls['width_auto'] == '1') $options['width'] = 'auto'; 
  48. if ($controls['height_auto'] == '1') $options['height'] = 'auto'; 
  49.  
  50. // Create the HTML code for the current widget recalling the basic 
  51. // function which is also invoked by the corresponding shortcode 
  52.  
  53. $OBJC = new SZGoogleActionPanoramio(); 
  54. $HTML = $OBJC->getHTMLCode($options); 
  55.  
  56. // Output HTML code linked to the widget to 
  57. // display call to the general standard for wrap 
  58.  
  59. echo $this->common_widget($args, $instance, $HTML); 
  60.  
  61. /** 
  62. * Changing parameters related to the widget FORM  
  63. * with storing the values **directly in the database 
  64. */ 
  65.  
  66. function update($new_instance, $old_instance)  
  67. // Performing additional operations on fields of the 
  68. // form widget before it is stored in the database 
  69.  
  70. return $this->common_update(array( 
  71. 'title' => '0', // strip_tags 
  72. 'template' => '1', // strip_tags 
  73. 'width' => '1', // strip_tags 
  74. 'width_auto' => '1', // strip_tags 
  75. 'height' => '1', // strip_tags 
  76. 'height_auto' => '1', // strip_tags 
  77. 'user' => '1', // strip_tags 
  78. 'group' => '1', // strip_tags 
  79. 'tag' => '1', // strip_tags 
  80. 'set' => '1', // strip_tags 
  81. 'columns' => '1', // strip_tags 
  82. 'rows' => '1', // strip_tags 
  83. 'orientation' => '1', // strip_tags 
  84. 'position' => '1', // strip_tags 
  85. ), $new_instance, $old_instance); 
  86.  
  87. /** 
  88. * FORM display the widget in the management of  
  89. * sidebar in the administration panel of wordpress 
  90. */ 
  91.  
  92. function form($instance)  
  93. // Creating arrays for list fields that must be 
  94. // present in the form before calling wp_parse_args() 
  95.  
  96. $array = array( 
  97. 'title' => '', // default value 
  98. 'template' => '', // default value 
  99. 'width' => '', // default value 
  100. 'width_auto' => '', // default value 
  101. 'height' => '', // default value 
  102. 'height_auto' => '', // default value 
  103. 'user' => '', // default value 
  104. 'group' => '', // default value 
  105. 'tag' => '', // default value 
  106. 'set' => '', // default value 
  107. 'columns' => '', // default value 
  108. 'rows' => '', // default value 
  109. 'orientation' => '', // default value 
  110. 'position' => '', // default value 
  111. ); 
  112.  
  113. // Creating arrays for list of fields to be retrieved FORM 
  114. // and loading the file with the HTML template to display 
  115.  
  116. extract(wp_parse_args($instance, $array), EXTR_OVERWRITE); 
  117.  
  118. // Reading of the options for the control of default values 
  119. // be assigned to the widget when it is placed in the sidebar 
  120.  
  121. if ($object = SZGoogleModule::getObject('SZGoogleModulePanoramio'))  
  122. $options = (object) $object->getOptions(); 
  123.  
  124. if (!ctype_digit($columns)) $columns = $options->panoramio_w_columns; 
  125. if (!ctype_digit($rows)) $rows = $options->panoramio_w_rows; 
  126.  
  127. if (!in_array($template , array('photo', 'slideshow', 'list', 'photo_list'))) $options->panoramio_w_template; 
  128. if (!in_array($set , array('all', 'public', 'recent'))) $options->panoramio_w_set; 
  129. if (!in_array($orientation , array('horizontal', 'vertical'))) $options->panoramio_w_orientation; 
  130. if (!in_array($position , array('left', 'top', 'right', 'bottom'))) $options->panoramio_w_position; 
  131.  
  132. if (!ctype_digit($width) and $width != 'auto') $width = $options->panoramio_w_width; 
  133. if (!ctype_digit($height) and $height != 'auto') $height = $options->panoramio_w_height; 
  134.  
  135. // Setting any of the default parameters for the 
  136. // fields that contain invalid values **or inconsistent 
  137.  
  138. $DEFAULT = include(dirname(SZ_PLUGIN_GOOGLE_MAIN)."/options/sz_google_options_panoramio.php"); 
  139.  
  140. if (!ctype_digit($columns)) $columns = $DEFAULT['panoramio_w_columns']['value']; 
  141. if (!ctype_digit($rows)) $rows = $DEFAULT['panoramio_w_rows']['value']; 
  142.  
  143. if (!in_array($template , array('photo', 'slideshow', 'list', 'photo_list'))) $template = $DEFAULT['panoramio_w_template']['value']; 
  144. if (!in_array($set , array('all', 'public', 'recent'))) $set = $DEFAULT['panoramio_w_set']['value']; 
  145. if (!in_array($orientation , array('horizontal', 'vertical'))) $orientation = $DEFAULT['panoramio_w_orientation']['value']; 
  146. if (!in_array($position , array('left', 'top', 'right', 'bottom'))) $position = $DEFAULT['panoramio_w_position']['value']; 
  147.  
  148. if (!ctype_digit($width) or $width == 0) { $width = $DEFAULT['panoramio_w_width']['value']; $width_auto = '1'; } 
  149. if (!ctype_digit($height) or $height == 0) { $height = $DEFAULT['panoramio_w_height']['value']; $height_auto = '1'; } 
  150.  
  151. // Calling the template for displaying the part  
  152. // that concerns the administration panel (admin) 
  153.  
  154. @include(dirname(SZ_PLUGIN_GOOGLE_MAIN).'/admin/widgets/SZGoogleWidget.php'); 
  155. @include(dirname(SZ_PLUGIN_GOOGLE_MAIN).'/admin/widgets/' .__CLASS__.'.php');