/libs/lib-profile.php

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