SZGoogleWidgetDriveViewer

The SZ - Google SZGoogleWidgetDriveViewer class.

Defined (1)

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

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