Plugin Directory

Changeset 374822


Ignore:
Timestamp:
04/19/2011 04:30:11 PM (14 years ago)
Author:
jeremyformstack
Message:
 
Location:
formstack/trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • formstack/trunk/API.php

    r294067 r374822  
    4848        $res = wp_remote_fopen("{$url}?".http_build_query($args));
    4949       
    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;
    5155       
    5256    }
  • formstack/trunk/Plugin.php

    r332150 r374822  
    7777    public function admin_menu() {
    7878
    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'));
    8086    }
    8187
     
    144150
    145151
     152
     153    /**
     154     * Render the Formstack page
     155     */
     156    public function main_page() {
     157        include 'tmpl/main.php';
     158    }
     159
    146160    private function addActions($actions) {
    147161
  • formstack/trunk/Widget.php

    r332153 r374822  
    7575
    7676        $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"){
    8081            include 'tmpl/api_error.php';
    8182            return;
    8283        }
     84
     85        $res = $res->response;
    8386       
    8487        $fields = array();
     
    9295        print "<label for='{$fields['formkey']['id']}'>Choose a form to embed:";
    9396        print "<select class='widefat' name='{$fields['formkey']['name']}' id='{$fields['formkey']['id']}'>";
     97
     98        if($fields['formkey']['value'] == '')
     99            print "<option value=''></option>";
     100
    94101        foreach($res->forms as $form) {
    95102            $sel = esc_attr($fields['formkey']['value']) == "{$form->id}-{$form->viewkey}" ?
  • formstack/trunk/tinymce/dialog.php

    r287303 r374822  
    2020require_once dirname(__FILE__). '/../config.php';
    2121
     22if(!empty($_POST['formstack_api_key'])){
     23    update_option('formstack_api_key', $_POST['formstack_api_key']);
     24}
     25
    2226$api_key = get_option('formstack_api_key');
    23 if(!empty($api_key))
     27$res = null;
     28if(!empty($api_key)){
    2429    $res = Formstack_API::request($api_key, 'forms');
     30    if($res->status == "ok"){
     31        $res = $res->response;
     32    }
     33}
     34
    2535?>
    2636
     
    7686        <?php
    7787
    78             if(empty($api_key))
     88            if(empty($api_key) || !empty($res->error))
    7989                include dirname(__FILE__). '/../tmpl/empty_api_key.php';
    8090
    81             else if(empty($res->forms))
     91            else if($res == null)
    8292                include dirname(__FILE__). '/../tmpl/api_error.php';
    83            
     93
    8494            else {
    8595
  • formstack/trunk/tinymce/plugin.js

    r287303 r374822  
    99                ed.windowManager.open({
    1010                    file   : url + '/dialog.php',
    11                     width  : 300, //+ ed.getLang('cetsHelloWorld.delta_width', 0),
    12                     height : 140, //+ ed.getLang('cetsHelloWorld.delta_height', 0),
     11                    width  : 400, //+ ed.getLang('cetsHelloWorld.delta_width', 0),
     12                    height : 160, //+ ed.getLang('cetsHelloWorld.delta_height', 0),
    1313                    inline : 1
    1414                }, { plugin_url : url });
  • formstack/trunk/tmpl/api_error.php

    r287303 r374822  
    11<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>
    33</div>
  • formstack/trunk/tmpl/empty_api_key.php

    r287303 r374822  
    11<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>
    331</div>
Note: See TracChangeset for help on using the changeset viewer.