gde_profile_form

Outputs profile form (called from multiple places).

Description

gde_profile_form( (int) $id = 1 ); 

Parameters (1)

0. $id — Optional. (int) => 1
The id.

Usage

  1. if ( !function_exists( 'gde_profile_form' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-doc-embedder/libs/lib-profile.php'; 
  3.  
  4. // The id. 
  5. $id = 1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = gde_profile_form($id); 
  9.  

Defined (1)

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

/libs/lib-profile.php  
  1. function gde_profile_form( $id = 1 ) { 
  2. global $healthy; 
  3.  
  4. // get requested profile 
  5. if ( ! $healthy ) { 
  6. echo "<p>" . gde_show_error( __('Unable to load profile settings. Please re-activate GDE and if the problem persists, request help using the "Support" tab.', 'gde') ) . "</p>\n"; 
  7. } else { 
  8. $p = gde_get_profiles( $id ); 
  9.  
  10. // minimize FOUC 
  11. if ( $p['viewer'] == "standard" ) { 
  12. $hideenh = " hide"; 
  13. } else { 
  14. $hideenh = ''; 
  15.  
  16. // setup title & nonce 
  17. if ( $id == 1 ) { 
  18. $title = __('Default Settings', 'gde'); 
  19. $desc = __('These settings define the default viewer profile, which is used when no other profile is specified.', 'gde'); 
  20. $naction = "update-default-opts"; 
  21. $nname = "_general_default"; 
  22. } else { 
  23. $title = __('Edit Profile', 'gde'); 
  24. $naction = "update-profile-opts"; 
  25. $nname = "_profile_edit"; 
  26. ?> 
  27.  
  28. <!-- 
  29.  
  30. <?php 
  31.  
  32. echo "id: $id\n\n"; 
  33. echo gettype($p)."\n\n"; 
  34. print_r($p);  
  35.  
  36. ?> 
  37.  
  38. --> 
  39.  
  40. <div id="profile-form"> 
  41.  
  42. <form action="" method="post"> 
  43. <?php wp_nonce_field($naction, $nname); ?> 
  44. <input type="hidden" name="profile_id" value="<?php echo $id; ?>"> 
  45.  
  46. <?php gde_help_link( GDE_STDOPT_URL, 'right' ); ?> 
  47. <h3><?php echo $title; ?></h3> 
  48.  
  49. <?php if ( isset( $desc ) ) { echo $desc; } ?> 
  50.  
  51. <table class="form-table"> 
  52. <tbody> 
  53. <tr valign="top"> 
  54. <th scope="row"><?php _e('Viewer Mode', 'gde'); ?></th> 
  55. <td> 
  56. <select name="viewer" id="viewer"> 
  57. <?php 
  58. gde_profile_option( $p['viewer'], 'standard', __('Standard Viewer', 'gde'), __('Embed the basic viewer only', 'gde') ); 
  59. gde_profile_option( $p['viewer'], 'enhanced', __('Enhanced Viewer', 'gde'), __('Enable extended viewer options', 'gde') ); 
  60. ?> 
  61. </select><br/> 
  62. <span class="gde-fnote" id="viewer-h"></span> 
  63. </td> 
  64. </tr> 
  65. </tbody> 
  66. </table> 
  67.  
  68. <fieldset class="gde-inner<?php echo $hideenh; ?>" id="gde-enh-fs"> 
  69. <legend><?php _e('Enhanced Viewer Settings', 'gde'); ?></legend> 
  70. <table class="form-table"> 
  71. <tbody> 
  72. <tr valign="top"> 
  73. <th scope="row"><?php _e('Toolbar', 'gde'); ?></th> 
  74. <td> 
  75. <?php gde_help_link( GDE_ENHOPT_URL, 'right' ); ?> 
  76. <?php 
  77. gde_profile_checkbox( $p['tb_flags'], 'gdet_h', __('Remove Toolbar', 'gde') ); 
  78. ?> 
  79. </td> 
  80. </tr> 
  81. <tr valign="top" id="mobiletb"> 
  82. <th scope="row"><?php _e('Use Mobile Toolbar', 'gde'); ?></th> 
  83. <td> 
  84. <select name="tb_mobile" id="tb_mobile"> 
  85. <?php 
  86. gde_profile_option( $p['tb_mobile'], 'default', __('Mobile Devices Only (Default)', 'gde'), __('Use mobile toolbar when mobile device detected', 'gde') ); 
  87. gde_profile_option( $p['tb_mobile'], 'always', __('Always', 'gde'), __('Use mobile toolbar for all visitors', 'gde') ); 
  88. gde_profile_option( $p['tb_mobile'], 'never', __('Never', 'gde'), __('Never use mobile toolbar', 'gde') ); 
  89. ?> 
  90. </select><br/> 
  91. <span class="gde-fnote" id="mobile-h"></span> 
  92. </td> 
  93. </tr> 
  94. <tr valign="top" id="toolbuttons"> 
  95. <th scope="row"><?php _e('Toolbar Items', 'gde'); ?></th> 
  96. <td> 
  97. <?php 
  98. gde_profile_checkbox( $p['tb_flags'], 'gdet_p', __('Page Numbers', 'gde') ); 
  99. gde_profile_checkbox( $p['tb_flags'], 'gdet_r', __('Previous/Next Page', 'gde') ); 
  100. gde_profile_checkbox( $p['tb_flags'], 'gdet_z', __('Zoom In/Out', 'gde') ); 
  101. gde_profile_checkbox( $p['tb_flags'], 'gdet_n', __('Full Screen/New Window', 'gde'), 'allowNewWin' ); 
  102. ?> 
  103. <br/> 
  104. <span class="gde-fnote"><?php _e('Uncheck items to remove from toolbar. Buttons will vary based on file type and device used.', 'gde'); ?></span> 
  105. </td> 
  106. </tr> 
  107. <tr valign="top" id="fullscreen"> 
  108. <th scope="row"><?php _e('Full Screen Behavior', 'gde'); ?></th> 
  109. <td> 
  110. <select name="tb_fullscr" id="tb_fullscr"> 
  111. <?php 
  112. gde_profile_option( $p['tb_fullscr'], 'default', __('Google-Hosted Page (Default)', 'gde') ); 
  113. //gde_profile_option( $p['tb_fullscr'], 'branded', __('Custom-Branded Page', 'gde') ); 
  114. gde_profile_option( $p['tb_fullscr'], 'viewer', __('Full Screen Viewer', 'gde') ); 
  115. ?> 
  116. </select><br/> 
  117.  
  118. <?php 
  119. gde_profile_checkbox( $p['tb_fullwin'], 'fs_win', __('Open in New Window', 'gde') ); 
  120. gde_profile_checkbox( $p['tb_fulluser'], 'fs_user', __('Allow Logged-in Users Only', 'gde'), 'blockAnon' ); 
  121. gde_profile_checkbox( $p['tb_print'], 'fs_print', __('Allow Printing', 'gde'), 'allowPrint' ); 
  122. ?> 
  123. </td> 
  124. </tr> 
  125. <tr valign="top" id="bgcolor"> 
  126. <th scope="row"><?php _e('Page Area Background Color', 'gde'); ?></th> 
  127. <td> 
  128. <?php 
  129. gde_profile_text( $p['vw_bgcolor'], 'vw_bgcolor', 'color {hash:true, required:false}', 10 ); 
  130. gde_profile_text( $p['vw_bgcolor'], 'vw_bgcolor_holder', 'holder', 10, false ); 
  131. gde_profile_checkbox( $p['vw_flags'], 'gdev_t', __('None (Transparent)', 'gde') ); 
  132. ?> 
  133. </td> 
  134. </tr> 
  135. <tr valign="top" id="pbcolor"> 
  136. <th scope="row"><?php _e('Page Border Color', 'gde'); ?></th> 
  137. <td> 
  138. <?php 
  139. gde_profile_text( $p['vw_pbcolor'], 'vw_pbcolor', 'color {hash:true, required:false}', 10 ); 
  140. gde_profile_text( $p['vw_pbcolor'], 'vw_pbcolor_holder', 'holder', 10, false ); 
  141. gde_profile_checkbox( $p['vw_flags'], 'gdev_b', __('No Border', 'gde') ); 
  142. ?> 
  143. </td> 
  144. </tr> 
  145. <tr valign="top" id="cssfile"> 
  146. <th scope="row"><?php _e('Custom CSS File', 'gde'); ?></th> 
  147. <td> 
  148. <?php 
  149. @gde_profile_text( $p['vw_css'], 'vw_css', '', '65' ); 
  150. ?> 
  151. <br/> 
  152. <span class="gde-fnote"><?php _e('URL of custom CSS file (may override some of the above options)', 'gde'); ?></span> 
  153. </td> 
  154. </tr> 
  155. <tr valign="top" id="docsec"> 
  156. <th scope="row"><?php _e('Security', 'gde'); ?></th> 
  157. <td> 
  158. <?php 
  159. gde_profile_checkbox( $p['vw_flags'], 'gdev_x', __('Hide ability to select/copy/paste text', 'gde'), 'hideselect', 1 ); 
  160. gde_profile_checkbox( $p['link_block'], 'block', __('Block all downloadrequestsfor file', 'gde'), 'linkblock', 1 ); 
  161. ?> 
  162. </td> 
  163. </tr> 
  164. </tbody> 
  165. </table> 
  166. </fieldset> 
  167.  
  168. <table class="form-table"> 
  169. <tbody> 
  170. <tr valign="top"> 
  171. <th scope="row"><?php _e('Default Language', 'gde'); ?></th> 
  172. <td> 
  173. <select name="language" id="language"> 
  174. <?php 
  175. require_once( GDE_PLUGIN_DIR . 'libs/lib-langs.php' ); 
  176. $langs = gde_supported_langs(); 
  177.  
  178. foreach ( $langs as $code => $desc ) { 
  179. gde_profile_option( $p['language'], $code, $desc ); 
  180. ?> 
  181. </select><br/> 
  182. <span class="gde-fnote"><?php _e('Language of toolbar button tips', 'gde'); ?></span> 
  183. </td> 
  184. </tr> 
  185. <tr valign="top"> 
  186. <th scope="row"><?php _e('Default Size', 'gde'); ?></th> 
  187. <td> 
  188.  <?php _e('Width', 'gde'); ?>  
  189. <?php 
  190. gde_profile_text( $p['default_width'], 'default_width', '', '5' ); 
  191. ?> 
  192.     <?php _e('Height', 'gde'); ?>  
  193. <?php 
  194. gde_profile_text( $p['default_height'], 'default_height', '', '5' ); 
  195. ?> 
  196. <br/> 
  197. <span class="gde-fnote"><?php _e('Enter as pixels or percentage (example: 500px or 100%)', 'gde'); ?></span> 
  198. </td> 
  199. </tr> 
  200. <tr valign="top"> 
  201. <th scope="row"><?php _e('File Base URL', 'gde'); ?></th> 
  202. <td> 
  203. <?php 
  204. gde_profile_text( $p['base_url'], 'base_url', '', '65' ); 
  205. ?> 
  206. <br/> 
  207. <span class="gde-fnote"><?php _e('Any file not starting with <code>http</code> will be prefixed by this value', 'gde'); ?></span> 
  208. </td> 
  209. </tr> 
  210. <tr valign="top"> 
  211. <th scope="row"><?php _e('Download Link', 'gde'); ?></th> 
  212. <td> 
  213. <select name="link_show" id="link_show"> 
  214. <?php 
  215. gde_profile_option( $p['link_show'], 'all', __('All Users', 'gde'), __('Download link visible to everyone by default', 'gde') ); 
  216. gde_profile_option( $p['link_show'], 'users', __('Logged-in Users', 'gde'), __('Download link visible to logged-in users', 'gde') ); 
  217. gde_profile_option( $p['link_show'], 'none', __('None', 'gde'), __('Download link is not visible by default', 'gde') ); 
  218. ?> 
  219. </select><br/> 
  220. <span class="gde-fnote" id="linkshow-h"></span> 
  221. </td> 
  222. </tr> 
  223. <tr valign="top" id="linktext"> 
  224. <th scope="row"><?php _e('Link Text', 'gde'); ?></th> 
  225. <td> 
  226. <input size="50" name="link_text" value="<?php echo $p['link_text']; ?>" type="text"><br/> 
  227. <span class="gde-fnote"><?php _e('You can further customize text using these dynamic replacements:', 'gde'); ?></span><br> 
  228. <code>%FILE</code> : <?php _e('filename', 'gde'); ?>     
  229. <code>%TYPE</code> : <?php _e('file type', 'gde'); ?>     
  230. <code>%SIZE</code> : <?php _e('file size', 'gde'); ?> 
  231. </td> 
  232. </tr> 
  233. <tr valign="top" id="linkpos"> 
  234. <th scope="row"><?php _e('Link Position', 'gde'); ?></th> 
  235. <td> 
  236. <select name="link_pos"> 
  237. <?php 
  238. gde_profile_option( $p['link_pos'], 'above', __('Above Viewer', 'gde') ); 
  239. gde_profile_option( $p['link_pos'], 'below', __('Below Viewer', 'gde') ); 
  240. ?> 
  241. </select> 
  242. </td> 
  243. </tr> 
  244. <tr valign="top" id="linkbehavior"> 
  245. <th scope="row"><?php _e('Link Behavior', 'gde'); ?></th> 
  246. <td> 
  247. <?php 
  248. gde_profile_checkbox( $p['link_force'], 'force', __('Force download (bypass browser plugins)', 'gde'), 'linkforce', 1 ); 
  249. gde_profile_checkbox( $p['link_mask'], 'mask', __('Shorten URL', 'gde'), 'linkmask', 1 ); 
  250. ?> 
  251. </td> 
  252. </tr> 
  253. </tbody> 
  254. </table> 
  255.  
  256. <p class="gde-submit"> 
  257. <input id="pro-submit" class="button-primary" type="submit" value="<?php _e('Save Changes', 'gde'); ?>" name="submit"> 
  258. </p> 
  259.  
  260. </form> 
  261.  
  262. </div> 
  263.  
  264. <?php