Code_Manager.php
4 years ago
Code_Manager_Dashboard.php
4 years ago
Code_Manager_Export.php
4 years ago
Code_Manager_Form.php
4 years ago
Code_Manager_Import.php
4 years ago
Code_Manager_Import_File.php
4 years ago
Code_Manager_List.php
4 years ago
Code_Manager_List_View.php
4 years ago
Code_Manager_Model.php
4 years ago
Code_Manager_Preview.php
4 years ago
Code_Manager_Settings.php
4 years ago
Code_Manager_Tabs.php
4 years ago
Message_Box.php
4 years ago
WP_List_Table.php
4 years ago
Code_Manager_Tabs.php
143 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Code_Manager { |
| 4 | |
| 5 | /** |
| 6 | * Class Code_Manager_Tabs |
| 7 | * |
| 8 | * Builds the Code Manager tab mode IDE |
| 9 | * |
| 10 | * @author Peter Schulz |
| 11 | * @since 1.0.0 |
| 12 | */ |
| 13 | class Code_Manager_Tabs { |
| 14 | |
| 15 | protected $wpnonce; |
| 16 | protected $wpnonce_get_code; |
| 17 | |
| 18 | /** |
| 19 | * Code_Manager_Tabs constructor |
| 20 | * |
| 21 | * Creates a number of wpnonces needed to authorize ajax calls |
| 22 | * |
| 23 | * @since 1.0.0 |
| 24 | */ |
| 25 | public function __construct() { |
| 26 | $this->wpnonce = wp_create_nonce( 'code-manager-' . Code_manager::get_current_user_login() ); |
| 27 | $this->wpnonce_get_code = wp_create_nonce( 'code-manager-get-code' . Code_manager::get_current_user_login() ); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Shows the tab mode IDE |
| 32 | * |
| 33 | * JavaScript depending on server variables not available in the browser are added here. Generic JavaScript |
| 34 | * code is added as a script file. |
| 35 | * |
| 36 | * @since 1.0.0 |
| 37 | */ |
| 38 | public function show() { |
| 39 | ?> |
| 40 | <script type="text/javascript"> |
| 41 | var wpnonce = '<?php echo $this->wpnonce; ?>'; |
| 42 | var wpnonce_get_code = '<?php echo $this->wpnonce_get_code; ?>'; |
| 43 | var code_manager_code_groups = []; |
| 44 | <?php |
| 45 | $code_manager_tab_class = CODE_MANAGER_TAB_CLASS; |
| 46 | $code_manager_tab = new $code_manager_tab_class(); |
| 47 | $code_types = $code_manager_tab->get_code_types(); |
| 48 | foreach ( $code_types as $code_type_group => $value ) { |
| 49 | echo 'code_manager_code_group = [];'; |
| 50 | foreach ( $value as $code_type => $code_type_label ) { |
| 51 | echo "code_manager_code_group['{$code_type}'] = '{$code_type_label}';"; |
| 52 | } |
| 53 | echo "code_manager_code_groups['{$code_type_group}'] = code_manager_code_group;"; |
| 54 | } |
| 55 | ?> |
| 56 | </script> |
| 57 | <div class="wrap"> |
| 58 | <table cellspacing="0" cellpadding="0" border="0" width="100%"> |
| 59 | <tr> |
| 60 | <td> |
| 61 | <h1 class="wp-heading-inline"> |
| 62 | <span> |
| 63 | <span class="cm_page_title"> |
| 64 | <?php echo CODE_MANAGER_H1_TITLE . ' - tab mode'; ?> |
| 65 | </span> |
| 66 | <?php |
| 67 | if ( ! Code_Manager_Dashboard::dashboard_enabled() ) { |
| 68 | ?> |
| 69 | <a href="?page=<?php echo CODE_MANAGER_MENU_SLUG; ?>" |
| 70 | title="Switch to list mode (standard WordPress list view)"> |
| 71 | <span class="material-icons cm_menu_title">menu</span></a> |
| 72 | <a id="code_manager_new" href="javascript:void(0)"> |
| 73 | <span class="material-icons cm_menu_title" |
| 74 | title="Add new code">add_circle_outline</span></a> |
| 75 | <a id="code_manager_open" href="javascript:void(0)"> |
| 76 | <span class="material-icons cm_menu_title" |
| 77 | title="Open existing code">arrow_circle_down</span></a> |
| 78 | <a href="<?php echo CODE_MANAGER_HELP_URL; ?>" target="_blank" |
| 79 | title="Plugin help - opens in a new tab or window"> |
| 80 | <span class="material-icons cm_menu_title">help_outline</span></a> |
| 81 | <?php |
| 82 | } |
| 83 | ?> |
| 84 | </span> |
| 85 | </h1> |
| 86 | </td> |
| 87 | <td style="text-align:right;padding-right:10px;padding-top:4px"> |
| 88 | <a id="disable_preview" |
| 89 | href="javascript:void(0)" |
| 90 | class="material-icons cm_menu_title" |
| 91 | style="text-decoration:none" |
| 92 | title="Turn of preview mode for all code IDs" |
| 93 | >visibility_off</a> |
| 94 | </td> |
| 95 | </tr> |
| 96 | </table> |
| 97 | <style> |
| 98 | #code_manager_code_list { |
| 99 | background-image: none; |
| 100 | max-width: initial; |
| 101 | min-width: 300px; |
| 102 | } |
| 103 | #code_manager_code_list option { |
| 104 | width: 100%; |
| 105 | } |
| 106 | </style> |
| 107 | <div id="code_manager_open_frame" style="display: none; background-color: transparent;"> |
| 108 | <p style="margin-top:0">Hold ctrl key to select multiple</p> |
| 109 | <form> |
| 110 | <select id="code_manager_code_list" size="14" multiple="multiple"> |
| 111 | <option>Loading data...</option> |
| 112 | </select> |
| 113 | </form> |
| 114 | </div> |
| 115 | <div id="code_manager_taskbar_tabmode" class="nav-tab-wrapper"></div> |
| 116 | <div id="code_manager_workspace_tabmode"></div> |
| 117 | </div> |
| 118 | <?php |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Get code types |
| 123 | * |
| 124 | * Code types are organized in group to allow grouping in list boxes. |
| 125 | * |
| 126 | * @since 1.0.0 |
| 127 | * |
| 128 | * @return string[][] |
| 129 | */ |
| 130 | public function get_code_types() { |
| 131 | return [ |
| 132 | 'Shortcodes' => [ |
| 133 | 'php shortcode' => 'PHP Shortcode', |
| 134 | 'javascript shortcode' => 'JavaScript Shortcode', |
| 135 | 'css shortcode' => 'CSS Shortcode', |
| 136 | 'html shortcode' => 'HTML Shortcode' |
| 137 | ], |
| 138 | ]; |
| 139 | } |
| 140 | |
| 141 | } |
| 142 | |
| 143 | } |