SZGoogleWidgetDriveEmbed

The SZ - Google SZGoogleWidgetDriveEmbed class.

Defined (1)

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

/classes/widget/SZGoogleWidgetDriveEmbed.php  
  1. class SZGoogleWidgetDriveEmbed 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-Drive-Embed', __('SZ-Google - Drive Embed', 'szgoogleadmin'), array( 
  9. 'classname' => 'sz-widget-google sz-widget-google-drive sz-widget-google-drive-embed',  
  10. 'description' => ucfirst(__('google drive embed.', '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. 'title' => '', // default value 
  24. 'type' => '', // default value 
  25. 'id' => '', // default value 
  26. 'width' => '', // default value 
  27. 'height' => '', // default value 
  28. 'folderview' => '', // default value 
  29. 'single' => '', // default value 
  30. 'gid' => '', // default value 
  31. 'range' => '', // default value 
  32. 'start' => '', // default value 
  33. 'loop' => '', // default value 
  34. 'delay' => '', // default value 
  35. 'margintop' => '', // default value 
  36. 'marginright' => '', // default value 
  37. 'marginbottom' => '', // default value 
  38. 'marginleft' => '', // default value 
  39. 'marginunit' => '', // default value 
  40. ), $instance); 
  41.  
  42. // Definition of the control variables of the widget, these values* 
  43. // do not affect the items of basic but affect some aspects 
  44.  
  45. $controls = $this->common_empty(array( 
  46. 'width_auto' => '', // default value 
  47. 'height_auto' => '', // default value 
  48. ), $instance); 
  49.  
  50. // Correction of the value of size is specified in 
  51. // the case the automatically and then use javascript 
  52.  
  53. if ($controls['width_auto'] == '1') $options['width'] = 'auto'; 
  54. if ($controls['height_auto'] == '1') $options['height'] = 'auto'; 
  55.  
  56. // Create the HTML code for the current widget recalling the basic 
  57. // function which is also invoked by the corresponding shortcode 
  58.  
  59. $OBJC = new SZGoogleActionDriveEmbed(); 
  60. $HTML = $OBJC->getHTMLCode($options); 
  61.  
  62. // Output HTML code linked to the widget to 
  63. // display call to the general standard for wrap 
  64.  
  65. echo $this->common_widget($args, $instance, $HTML); 
  66.  
  67. /** 
  68. * Changing parameters related to the widget FORM  
  69. * with storing the values **directly in the database 
  70. */ 
  71.  
  72. function update($new_instance, $old_instance)  
  73. // Performing additional operations on fields of the 
  74. // form widget before it is stored in the database 
  75.  
  76. return $this->common_update(array( 
  77. 'title' => '0', // strip_tags 
  78. 'type' => '1', // strip_tags 
  79. 'id' => '1', // strip_tags 
  80. 'folderview' => '1', // strip_tags 
  81. 'single' => '1', // strip_tags 
  82. 'gid' => '1', // strip_tags 
  83. 'range' => '1', // strip_tags 
  84. 'start' => '1', // strip_tags 
  85. 'loop' => '1', // strip_tags 
  86. 'delay' => '1', // strip_tags 
  87. 'width' => '1', // strip_tags 
  88. 'width_auto' => '1', // strip_tags 
  89. 'height' => '1', // strip_tags 
  90. 'height_auto' => '1', // strip_tags 
  91. ), $new_instance, $old_instance); 
  92.  
  93. /** 
  94. * FORM display the widget in the management of  
  95. * sidebar in the administration panel of wordpress 
  96. */ 
  97.  
  98. function form($instance)  
  99. // Creating arrays for list fields that must be 
  100. // present in the form before calling wp_parse_args() 
  101.  
  102. $array = array( 
  103. 'title' => '', // default value 
  104. 'type' => '', // default value 
  105. 'id' => '', // default value 
  106. 'folderview' => '', // default value 
  107. 'single' => '', // default value 
  108. 'gid' => '', // default value 
  109. 'range' => '', // default value 
  110. 'start' => '', // default value 
  111. 'loop' => '', // default value 
  112. 'delay' => '', // default value 
  113. 'width' => '', // default value 
  114. 'width_auto' => '', // default value 
  115. 'height' => '', // default value 
  116. 'height_auto' => '', // default value 
  117. ); 
  118.  
  119. // Creating arrays for list of fields to be retrieved FORM 
  120. // and loading the file with the HTML template to display 
  121.  
  122. extract(wp_parse_args($instance, $array), EXTR_OVERWRITE); 
  123.  
  124. // Reading of the options for the control of default values 
  125. // be assigned to the widget when it is placed in the sidebar 
  126.  
  127. if ($object = SZGoogleModule::getObject('SZGoogleModuleDrive'))  
  128. $options = (object) $object->getOptions(); 
  129.  
  130. if (!ctype_digit($width) and $width != 'auto') $width = $options->drive_embed_w_width; 
  131. if (!ctype_digit($height) and $height != 'auto') $height = $options->drive_embed_w_height; 
  132.  
  133. // Setting any of the default parameters for the 
  134. // fields that contain invalid values **or inconsistent 
  135.  
  136. $DEFAULT = include(dirname(SZ_PLUGIN_GOOGLE_MAIN)."/options/sz_google_options_drive.php"); 
  137.  
  138. if (!ctype_digit($width) or $width == 0) { $width = $DEFAULT['drive_embed_w_width']['value']; $width_auto = '1'; } 
  139. if (!ctype_digit($height) or $height == 0) { $height = $DEFAULT['drive_embed_w_height']['value']; $height_auto = '1'; } 
  140.  
  141. // Calling the template for displaying the part  
  142. // that concerns the administration panel (admin) 
  143.  
  144. @include(dirname(SZ_PLUGIN_GOOGLE_MAIN).'/admin/widgets/SZGoogleWidget.php'); 
  145. @include(dirname(SZ_PLUGIN_GOOGLE_MAIN).'/admin/widgets/' .__CLASS__.'.php');