SZGoogleWidgetPlusPage

The SZ - Google SZGoogleWidgetPlusPage class.

Defined (1)

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

/classes/widget/SZGoogleWidgetPlusPage.php  
  1. class SZGoogleWidgetPlusPage 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-Page', __('SZ-Google - G+ Page', 'szgoogleadmin'), array( 
  9. 'classname' => 'sz-widget-google sz-widget-google-plus sz-widget-google-plus-page',  
  10. 'description' => ucfirst(__('google+ page.', '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. 'id' => '', // default value 
  24. 'type' => '', // default value 
  25. 'width' => '', // default value 
  26. 'align' => '', // default value 
  27. 'layout' => '', // default value 
  28. 'theme' => '', // default value 
  29. 'cover' => '', // default value 
  30. 'tagline' => '', // default value 
  31. 'publisher' => '', // default value 
  32. 'text' => '', // default value 
  33. 'image' => '', // 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. 'method' => '', // default value 
  41. 'specific' => '', // default value 
  42. 'width_auto' => '', // default value 
  43. ), $instance); 
  44.  
  45. // Correction of the value of size is specified in 
  46. // the case the automatically and then use javascript 
  47.  
  48. if ($controls['method'] != '1') $options['id'] = $controls['specific'];  
  49. if ($controls['method'] == '1') $options['id'] = '';  
  50. if ($controls['width_auto'] == '1') $options['width'] = 'auto'; 
  51.  
  52. // Create the HTML code for the current widget recalling the basic 
  53. // function which is also invoked by the corresponding shortcode 
  54.  
  55. if ($object = SZGoogleModule::getObject('SZGoogleModulePlus')) { 
  56. $HTML = $object->getPlusPageShortcode($options); 
  57.  
  58. // Output HTML code linked to the widget to 
  59. // display call to the general standard for wrap 
  60.  
  61. echo $this->common_widget($args, $instance, $HTML); 
  62.  
  63. /** 
  64. * Changing parameters related to the widget FORM  
  65. * with storing the values **directly in the database 
  66. */ 
  67.  
  68. function update($new_instance, $old_instance)  
  69. // Performing additional operations on fields of the 
  70. // form widget before it is stored in the database 
  71.  
  72. return $this->common_update(array( 
  73. 'title' => '0', // strip_tags 
  74. 'type' => '1', // strip_tags 
  75. 'method' => '1', // strip_tags 
  76. 'specific' => '1', // strip_tags 
  77. 'width' => '1', // strip_tags 
  78. 'width_auto' => '1', // strip_tags 
  79. 'align' => '1', // strip_tags 
  80. 'layout' => '1', // strip_tags 
  81. 'theme' => '1', // strip_tags 
  82. 'cover' => '1', // strip_tags 
  83. 'tagline' => '1', // strip_tags 
  84. 'publisher' => '1', // strip_tags 
  85. 'text' => '1', // strip_tags 
  86. 'image' => '1', // strip_tags 
  87. ), $new_instance, $old_instance); 
  88.  
  89. /** 
  90. * FORM display the widget in the management of  
  91. * sidebar in the administration panel of wordpress 
  92. */ 
  93.  
  94. function form($instance)  
  95. // Creating arrays for list fields that must be 
  96. // present in the form before calling wp_parse_args() 
  97.  
  98. $array = array( 
  99. 'title' => '', // default value 
  100. 'type' => '', // default value 
  101. 'method' => '', // default value 
  102. 'specific' => '', // default value 
  103. 'width' => '', // default value 
  104. 'width_auto' => '', // default value 
  105. 'align' => '', // default value 
  106. 'layout' => '', // default value 
  107. 'theme' => '', // default value 
  108. 'cover' => '', // default value 
  109. 'tagline' => '', // default value 
  110. 'publisher' => '', // default value 
  111. 'text' => '', // default value 
  112. 'image' => '', // default value 
  113. ); 
  114.  
  115. // Creating arrays for list of fields to be retrieved FORM 
  116. // and loading the file with the HTML template to display 
  117.  
  118. extract(wp_parse_args($instance, $array), EXTR_OVERWRITE); 
  119.  
  120. // Reading of the options for the control of default values 
  121. // be assigned to the widget when it is placed in the sidebar 
  122.  
  123. if ($object = SZGoogleModule::getObject('SZGoogleModulePlus'))  
  124. $options = (object) $object->getOptions(); 
  125.  
  126. if (!ctype_digit($width) and $width != 'auto') { 
  127. if($layout == 'landscape') $width = $options->plus_widget_size_landscape; 
  128. else $width = $options->plus_widget_size_portrait; 
  129.  
  130. // Setting any of the default parameters for the 
  131. // fields that contain invalid values **or inconsistent 
  132.  
  133. $DEFAULT = include(dirname(SZ_PLUGIN_GOOGLE_MAIN)."/options/sz_google_options_plus.php"); 
  134.  
  135. if (!in_array($cover , array('true', 'false'))) $cover = 'true'; 
  136. if (!in_array($tagline , array('true', 'false'))) $tagline = 'true'; 
  137. if (!in_array($publisher, array('true', 'false'))) $publisher = 'false'; 
  138. if (!in_array($theme , array('light', 'dark'))) $theme = 'light'; 
  139. if (!in_array($layout , array('portrait', 'landscape'))) $layout = 'portrait'; 
  140. if (!in_array($type , array('standard', 'popup'))) $type = 'standard'; 
  141.  
  142. if (!ctype_digit($method) or $method == 0) { $method = '1'; } 
  143.  
  144. if (!ctype_digit($width) or $width == 0) {  
  145. if($layout == 'landscape') $width = $DEFAULT['plus_widget_size_landscape']['value'];  
  146. else $width = $DEFAULT['plus_widget_size_portrait']['value']; 
  147. $width_auto = '1'; 
  148.  
  149. // Calling the template for displaying the part  
  150. // that concerns the administration panel (admin) 
  151.  
  152. @include(dirname(SZ_PLUGIN_GOOGLE_MAIN).'/admin/widgets/SZGoogleWidget.php'); 
  153. @include(dirname(SZ_PLUGIN_GOOGLE_MAIN).'/admin/widgets/' .__CLASS__.'.php');