Changeset 374822
- Timestamp:
- 04/19/2011 04:30:11 PM (14 years ago)
- Location:
- formstack/trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
formstack/trunk/API.php
r294067 r374822 48 48 $res = wp_remote_fopen("{$url}?".http_build_query($args)); 49 49 50 return json_decode($res)->status == "ok" ? json_decode($res)->response : null; 50 if($res === false) 51 return false; 52 53 return json_decode($res); 54 //return json_decode($res)->status == "ok" ? json_decode($res)->response : null; 51 55 52 56 } -
formstack/trunk/Plugin.php
r332150 r374822 77 77 public function admin_menu() { 78 78 79 add_options_page('Formstack Options', 'Formstack', 'manage_options', 'Formstack', array($this, 'plugin_options')); 79 add_menu_page('Formstack Forms', 'Formstack', 'manage_options', 'Formstack', array($this, 'main_page'), '../wp-content/plugins/formstack/stack.gif', 26); 80 add_submenu_page('Formstack', 'Formstack Forms', 'View Forms', 'manage_options', 'Formstack', array($this, 'main_page')); 81 add_submenu_page('Formstack', 'Create Formstack Form', 'Create Form', 'manage_options', 'FormstackNewForm', array($this, 'main_page')); 82 add_submenu_page('Formstack', 'Formstack Submissions', 'Submissions', 'manage_options', 'FormstackSubmissions', array($this, 'main_page')); 83 add_submenu_page('Formstack', 'Formstack API Info', 'API Key', 'manage_options', 'FormstackAPI', array($this, 'main_page')); 84 85 add_options_page('Formstack Options', 'Formstack', 'manage_options', 'FormstackOptions', array($this, 'plugin_options')); 80 86 } 81 87 … … 144 150 145 151 152 153 /** 154 * Render the Formstack page 155 */ 156 public function main_page() { 157 include 'tmpl/main.php'; 158 } 159 146 160 private function addActions($actions) { 147 161 -
formstack/trunk/Widget.php
r332153 r374822 75 75 76 76 $res = Formstack_API::request($api_key, 'forms'); 77 78 if(empty($res->forms)) { 79 77 if($res->status == "error"){ 78 include 'tmpl/empty_api_key.php'; 79 return; 80 }elseif($res->status != "ok"){ 80 81 include 'tmpl/api_error.php'; 81 82 return; 82 83 } 84 85 $res = $res->response; 83 86 84 87 $fields = array(); … … 92 95 print "<label for='{$fields['formkey']['id']}'>Choose a form to embed:"; 93 96 print "<select class='widefat' name='{$fields['formkey']['name']}' id='{$fields['formkey']['id']}'>"; 97 98 if($fields['formkey']['value'] == '') 99 print "<option value=''></option>"; 100 94 101 foreach($res->forms as $form) { 95 102 $sel = esc_attr($fields['formkey']['value']) == "{$form->id}-{$form->viewkey}" ? -
formstack/trunk/tinymce/dialog.php
r287303 r374822 20 20 require_once dirname(__FILE__). '/../config.php'; 21 21 22 if(!empty($_POST['formstack_api_key'])){ 23 update_option('formstack_api_key', $_POST['formstack_api_key']); 24 } 25 22 26 $api_key = get_option('formstack_api_key'); 23 if(!empty($api_key)) 27 $res = null; 28 if(!empty($api_key)){ 24 29 $res = Formstack_API::request($api_key, 'forms'); 30 if($res->status == "ok"){ 31 $res = $res->response; 32 } 33 } 34 25 35 ?> 26 36 … … 76 86 <?php 77 87 78 if(empty($api_key) )88 if(empty($api_key) || !empty($res->error)) 79 89 include dirname(__FILE__). '/../tmpl/empty_api_key.php'; 80 90 81 else if( empty($res->forms))91 else if($res == null) 82 92 include dirname(__FILE__). '/../tmpl/api_error.php'; 83 93 84 94 else { 85 95 -
formstack/trunk/tinymce/plugin.js
r287303 r374822 9 9 ed.windowManager.open({ 10 10 file : url + '/dialog.php', 11 width : 300, //+ ed.getLang('cetsHelloWorld.delta_width', 0),12 height : 1 40, //+ ed.getLang('cetsHelloWorld.delta_height', 0),11 width : 400, //+ ed.getLang('cetsHelloWorld.delta_width', 0), 12 height : 160, //+ ed.getLang('cetsHelloWorld.delta_height', 0), 13 13 inline : 1 14 14 }, { plugin_url : url }); -
formstack/trunk/tmpl/api_error.php
r287303 r374822 1 1 <div style="background-color:#FFFFE0;border: 1px solid #E6DB55;padding:4px;-moz-border-radius: 3px;-webkit-border-radius: 3px;"> 2 <p><strong>An error has occured: Your Formstack API key is invalid.</strong></p>2 <p><strong>An error has occured: It seems Formstack is unreachable.</strong></p> 3 3 </div> -
formstack/trunk/tmpl/empty_api_key.php
r287303 r374822 1 1 <div style="background-color:#FFFFE0;border: 1px solid #E6DB55;padding:4px;-moz-border-radius: 3px;-webkit-border-radius: 3px;"> 2 <p><strong>This widget requires a Formstack API key. Set one in the Formstack settings.</strong></p> 2 <p><strong> 3 <?php 4 if(!empty($res->error)){ 5 print $res->error; 6 }else{?> 7 <div style="padding-bottom:5px;"> 8 This widget requires a valid Formstack API key. 9 </div> 10 <div style="padding-bottom:5px;"> 11 Don't have an API Key? <a href="../../../../wp-admin/admin.php?page=FormstackAPI&new=1" target="parent">Click here</a> to create one. 12 </div> 13 <?php 14 } 15 ?></strong></p> 16 17 <form method="post" action="dialog.php"> 18 19 <table cellpadding="3" cellspacing="0" border="0"> 20 <tr> 21 <td style="width:50px;" nowrap="nowrap" align="right"><strong>API Key:</strong></td> 22 <td><input type="text" name="formstack_api_key" style="width:300px;" value="<?php echo get_option('formstack_api_key'); ?>" /></td> 23 </tr> 24 </table> 25 26 <p class="submit"> 27 <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /> 28 </p> 29 30 </form> 3 31 </div>
Note: See TracChangeset
for help on using the changeset viewer.