GFPDFViewView_Settings

View_Settings.

Defined (1)

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

/src/view/View_Settings.php  
  1. class View_Settings extends Helper_Abstract_View { 
  2.  
  3. /** 
  4. * Set the view's name 
  5. * @var string 
  6. * @since 4.0 
  7. */ 
  8. protected $view_type = 'Settings'; 
  9.  
  10. /** 
  11. * Holds the abstracted Gravity Forms API specific to Gravity PDF 
  12. * @var \GFPDF\Helper\Helper_Form 
  13. * @since 4.0 
  14. */ 
  15. protected $gform; 
  16.  
  17. /** 
  18. * Holds our log class 
  19. * @var \Monolog\Logger|LoggerInterface 
  20. * @since 4.0 
  21. */ 
  22. protected $log; 
  23.  
  24. /** 
  25. * Holds our Helper_Abstract_Options / Helper_Options_Fields object 
  26. * Makes it easy to access global PDF settings and individual form PDF settings 
  27. * @var \GFPDF\Helper\Helper_Options_Fields 
  28. * @since 4.0 
  29. */ 
  30. protected $options; 
  31.  
  32. /** 
  33. * Holds our Helper_Data object 
  34. * which we can autoload with any data needed 
  35. * @var \GFPDF\Helper\Helper_Data 
  36. * @since 4.0 
  37. */ 
  38. protected $data; 
  39.  
  40. /** 
  41. * Holds our Helper_Misc object 
  42. * Makes it easy to access common methods throughout the plugin 
  43. * @var \GFPDF\Helper\Helper_Misc 
  44. * @since 4.0 
  45. */ 
  46. protected $misc; 
  47.  
  48. /** 
  49. * Holds our Helper_Templates object 
  50. * used to ease access to our PDF templates 
  51. * @var \GFPDF\Helper\Helper_Templates 
  52. * @since 4.0 
  53. */ 
  54. protected $templates; 
  55.  
  56. /** 
  57. * Setup our class by injecting all our dependancies 
  58. * @param array $data_cache An array of data to pass to the view 
  59. * @param \GFPDF\Helper\Helper_Form|Helper_Abstract_Form $gform Our abstracted Gravity Forms helper functions 
  60. * @param \Monolog\Logger|LoggerInterface $log Our logger class 
  61. * @param \GFPDF\Helper\Helper_Abstract_Options $options Our options class which allows us to access any settings 
  62. * @param \GFPDF\Helper\Helper_Data $data Our plugin data store 
  63. * @param \GFPDF\Helper\Helper_Misc $misc Our miscellaneous class 
  64. * @param \GFPDF\Helper\Helper_Templates $templates 
  65. * @since 4.0 
  66. */ 
  67. public function __construct( $data_cache = [], Helper_Abstract_Form $gform, LoggerInterface $log, Helper_Abstract_Options $options, Helper_Data $data, Helper_Misc $misc, Helper_Templates $templates ) { 
  68.  
  69. /** Call our parent constructor */ 
  70. parent::__construct( $data_cache ); 
  71.  
  72. /** Assign our internal variables */ 
  73. $this->gform = $gform; 
  74. $this->log = $log; 
  75. $this->options = $options; 
  76. $this->data = $data; 
  77. $this->misc = $misc; 
  78. $this->templates = $templates; 
  79.  
  80. /** 
  81. * Load the Welcome Tab tabs 
  82. * @since 4.0 
  83. * @return void 
  84. */ 
  85. public function tabs() { 
  86.  
  87. /** Set up any variables we need for the view and display */ 
  88. $vars = [ 
  89. 'selected' => isset( $_GET['tab'] ) ? $_GET['tab'] : 'general',  
  90. 'tabs' => $this->get_avaliable_tabs(),  
  91. 'data' => $this->data,  
  92. ]; 
  93.  
  94. /** load the tabs view */ 
  95. $this->load( 'tabs', $vars ); 
  96.  
  97. /** 
  98. * Set up our settings navigation 
  99. * @return array The navigation array 
  100. * @since 4.0 
  101. */ 
  102. public function get_avaliable_tabs() { 
  103. /** 
  104. * Store the setting navigation 
  105. * The array key is the settings order 
  106. * @var array 
  107. */ 
  108. $navigation = [ 
  109. 5 => [ 
  110. 'name' => esc_html__( 'General', 'gravity-forms-pdf-extended' ),  
  111. 'id' => 'general',  
  112. ],  
  113.  
  114. 100 => [ 
  115. 'name' => esc_html__( 'Tools', 'gravity-forms-pdf-extended' ),  
  116. 'id' => 'tools',  
  117. ],  
  118.  
  119. 120 => [ 
  120. 'name' => esc_html__( 'Help', 'gravity-forms-pdf-extended' ),  
  121. 'id' => 'help',  
  122. ],  
  123. ]; 
  124.  
  125. /** 
  126. * Allow additional navigation to be added to the settings page 
  127. * @since 3.8 
  128. */ 
  129. return apply_filters( 'gfpdf_settings_navigation', $navigation ); 
  130.  
  131. /** 
  132. * Pull the system status details and show 
  133. * @return void 
  134. * @since 4.0 
  135. */ 
  136. public function system_status() { 
  137. global $wp_version; 
  138.  
  139. $status = new GFPDF_Major_Compatibility_Checks(); 
  140.  
  141. $vars = [ 
  142. 'memory' => $status->get_ram( $this->data->memory_limit ),  
  143. 'wp' => $wp_version,  
  144. 'php' => phpversion(),  
  145. 'gf' => $this->gform->get_version(),  
  146. ]; 
  147.  
  148. $this->log->addNotice( 'System Status', [ 
  149. 'status' => $vars,  
  150. ] ); 
  151.  
  152. /** load the system status view */ 
  153. $this->load( 'system_status', $vars ); 
  154.  
  155. /** 
  156. * Pull the general details and display 
  157. * @return void 
  158. * @since 4.0 
  159. */ 
  160. public function general() { 
  161.  
  162. $vars = [ 
  163. 'edit_cap' => $this->gform->has_capability( 'gravityforms_edit_settings' ),  
  164. ]; 
  165.  
  166. /** load the system status view */ 
  167. $this->load( 'general', $vars ); 
  168.  
  169. /** 
  170. * Pull the tools details and show 
  171. * @return void 
  172. * @since 4.0 
  173. */ 
  174. public function tools() { 
  175.  
  176. /** prevent unauthorized access */ 
  177. if ( ! $this->gform->has_capability( 'gravityforms_edit_settings' ) ) { 
  178. $this->log->addWarning( 'Lack of User Capabilities.' ); 
  179.  
  180. wp_die( esc_html__( 'You do not have permission to access this page', 'gravity-forms-pdf-extended' ) ); 
  181.  
  182. $template_directory = $this->templates->get_template_path(); 
  183.  
  184. $vars = [ 
  185. 'template_directory' => $this->misc->relative_path( $template_directory, '/' ),  
  186. 'template_files' => $this->templates->get_core_pdf_templates(),  
  187. 'custom_template_setup_warning' => $this->options->get_option( 'custom_pdf_template_files_installed' ),  
  188. ]; 
  189.  
  190. /** load the system status view */ 
  191. $this->load( 'tools', $vars ); 
  192.  
  193. /** 
  194. * Add Gravity Forms Tooltips 
  195. * @param array $tooltips The existing tooltips 
  196. * @since 4.0 
  197. * @return string 
  198. */ 
  199. public function add_tooltips( $tooltips ) { 
  200.  
  201. $tooltips['pdf_status_wp_memory'] = '<h6>' . esc_html__( 'WP Memory Available', 'gravity-forms-pdf-extended' ) . '</h6>' . sprintf( esc_html__( 'Producing PDF documents is hard work and Gravity PDF requires more resources than most plugins. We strongly recommend you have at least 128MB, but you may need more.', 'gravity-forms-pdf-extended' ) ); 
  202. $tooltips['pdf_protection'] = '<h6>' . esc_html__( 'Direct PDF Protection', 'gravity-forms-pdf-extended' ) . '</h6>' . sprintf( esc_html__( 'Apache and Litespeed servers automatically disable public access to the Gravity PDF temporary directory using a %s.htaccess%s file, but other web servers like Nginx do not support this feature. We will check if your PDFs are automatically protected, and let you know what you can do to protect your data if they are not.', 'gravity-forms-pdf-extended' ), '<code>', '</code>', '<code>', '</code>' ); 
  203.  
  204. return apply_filters( 'gravitypdf_registered_tooltips', $tooltips );