Beispiel #1
0
    private static function list_page()
    {
        if (!self::is_gravityforms_supported()) {
            die(__(sprintf("PayPal Add-On requires Gravity Forms %s. Upgrade automatically on the %sPlugin page%s.", self::$min_gravityforms_version, "<a href='plugins.php'>", "</a>"), "gravityformspaypal"));
        }
        if (rgpost('action') == "delete") {
            check_admin_referer("list_action", "gf_paypal_list");
            $id = absint($_POST["action_argument"]);
            GFPayPalData::delete_feed($id);
            ?>
            <div class="updated fade" style="padding:6px"><?php 
            _e("Feed deleted.", "gravityformspaypal");
            ?>
</div>
            <?php 
        } else {
            if (!empty($_POST["bulk_action"])) {
                check_admin_referer("list_action", "gf_paypal_list");
                $selected_feeds = $_POST["feed"];
                if (is_array($selected_feeds)) {
                    foreach ($selected_feeds as $feed_id) {
                        GFPayPalData::delete_feed($feed_id);
                    }
                }
                ?>
            <div class="updated fade" style="padding:6px"><?php 
                _e("Feeds deleted.", "gravityformspaypal");
                ?>
</div>
            <?php 
            }
        }
        ?>
        <div class="wrap">
            <img alt="<?php 
        _e("PayPal Transactions", "gravityformspaypal");
        ?>
" src="<?php 
        echo self::get_base_url();
        ?>
/images/paypal_wordpress_icon_32.png" style="float:left; margin:15px 7px 0 0;"/>
            <h2><?php 
        _e("PayPal Forms", "gravityformspaypal");
        if (get_option("gf_paypal_configured")) {
            ?>
                <a class="button add-new-h2" href="admin.php?page=gf_paypal&view=edit&id=0"><?php 
            _e("Add New", "gravityformspaypal");
            ?>
</a>
                <?php 
        }
        ?>
            </h2>

            <form id="feed_form" method="post">
                <?php 
        wp_nonce_field('list_action', 'gf_paypal_list');
        ?>
                <input type="hidden" id="action" name="action"/>
                <input type="hidden" id="action_argument" name="action_argument"/>

                <div class="tablenav">
                    <div class="alignleft actions" style="padding:8px 0 7px 0;">
                        <label class="hidden" for="bulk_action"><?php 
        _e("Bulk action", "gravityformspaypal");
        ?>
</label>
                        <select name="bulk_action" id="bulk_action">
                            <option value=''> <?php 
        _e("Bulk action", "gravityformspaypal");
        ?>
 </option>
                            <option value='delete'><?php 
        _e("Delete", "gravityformspaypal");
        ?>
</option>
                        </select>
                        <?php 
        echo '<input type="submit" class="button" value="' . __("Apply", "gravityformspaypal") . '" onclick="if( jQuery(\'#bulk_action\').val() == \'delete\' && !confirm(\'' . __("Delete selected feeds? ", "gravityformspaypal") . __("\\'Cancel\\' to stop, \\'OK\\' to delete.", "gravityformspaypal") . '\')) { return false; } return true;"/>';
        ?>
                    </div>
                </div>
                <table class="widefat fixed" cellspacing="0">
                    <thead>
                        <tr>
                            <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
                            <th scope="col" id="active" class="manage-column check-column"></th>
                            <th scope="col" class="manage-column"><?php 
        _e("Form", "gravityformspaypal");
        ?>
</th>
                            <th scope="col" class="manage-column"><?php 
        _e("Transaction Type", "gravityformspaypal");
        ?>
</th>
                        </tr>
                    </thead>

                    <tfoot>
                        <tr>
                            <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
                            <th scope="col" id="active" class="manage-column check-column"></th>
                            <th scope="col" class="manage-column"><?php 
        _e("Form", "gravityformspaypal");
        ?>
</th>
                            <th scope="col" class="manage-column"><?php 
        _e("Transaction Type", "gravityformspaypal");
        ?>
</th>
                        </tr>
                    </tfoot>

                    <tbody class="list:user user-list">
                        <?php 
        $settings = GFPayPalData::get_feeds();
        if (!get_option("gf_paypal_configured")) {
            ?>
                            <tr>
                                <td colspan="3" style="padding:20px;">
                                    <?php 
            echo sprintf(__("To get started, please configure your %sPayPal Settings%s.", "gravityformspaypal"), '<a href="admin.php?page=gf_settings&addon=PayPal">', "</a>");
            ?>
                                </td>
                            </tr>
                            <?php 
        } else {
            if (is_array($settings) && sizeof($settings) > 0) {
                foreach ($settings as $setting) {
                    ?>
                                <tr class='author-self status-inherit' valign="top">
                                    <th scope="row" class="check-column"><input type="checkbox" name="feed[]" value="<?php 
                    echo $setting["id"];
                    ?>
"/></th>
                                    <td><img src="<?php 
                    echo self::get_base_url();
                    ?>
/images/active<?php 
                    echo intval($setting["is_active"]);
                    ?>
.png" alt="<?php 
                    echo $setting["is_active"] ? __("Active", "gravityformspaypal") : __("Inactive", "gravityformspaypal");
                    ?>
" title="<?php 
                    echo $setting["is_active"] ? __("Active", "gravityformspaypal") : __("Inactive", "gravityformspaypal");
                    ?>
" onclick="ToggleActive(this, <?php 
                    echo $setting['id'];
                    ?>
); " /></td>
                                    <td class="column-title">
                                        <a href="admin.php?page=gf_paypal&view=edit&id=<?php 
                    echo $setting["id"];
                    ?>
" title="<?php 
                    _e("Edit", "gravityformspaypal");
                    ?>
"><?php 
                    echo $setting["form_title"];
                    ?>
</a>
                                        <div class="row-actions">
                                            <span class="edit">
                                            <a title="<?php 
                    _e("Edit", "gravityformspaypal");
                    ?>
" href="admin.php?page=gf_paypal&view=edit&id=<?php 
                    echo $setting["id"];
                    ?>
" ><?php 
                    _e("Edit", "gravityformspaypal");
                    ?>
</a>
                                            |
                                            </span>
                                            <span class="view">
                                            <a title="<?php 
                    _e("View Stats", "gravityformspaypal");
                    ?>
" href="admin.php?page=gf_paypal&view=stats&id=<?php 
                    echo $setting["id"];
                    ?>
"><?php 
                    _e("Stats", "gravityformspaypal");
                    ?>
</a>
                                            |
                                            </span>
                                            <span class="view">
                                            <a title="<?php 
                    _e("View Entries", "gravityformspaypal");
                    ?>
" href="admin.php?page=gf_entries&view=entries&id=<?php 
                    echo $setting["form_id"];
                    ?>
"><?php 
                    _e("Entries", "gravityformspaypal");
                    ?>
</a>
                                            |
                                            </span>
                                            <span class="trash">
                                            <a title="<?php 
                    _e("Delete", "gravityformspaypal");
                    ?>
" href="javascript: if(confirm('<?php 
                    _e("Delete this feed? ", "gravityformspaypal");
                    ?>
 <?php 
                    _e("\\'Cancel\\' to stop, \\'OK\\' to delete.", "gravityformspaypal");
                    ?>
')){ DeleteSetting(<?php 
                    echo $setting["id"];
                    ?>
);}"><?php 
                    _e("Delete", "gravityformspaypal");
                    ?>
</a>
                                            </span>
                                        </div>
                                    </td>
                                    <td class="column-date">
                                        <?php 
                    switch ($setting["meta"]["type"]) {
                        case "product":
                            _e("Product and Services", "gravityformspaypal");
                            break;
                        case "donation":
                            _e("Donation", "gravityformspaypal");
                            break;
                        case "subscription":
                            _e("Subscription", "gravityformspaypal");
                            break;
                    }
                    ?>
                                    </td>
                                </tr>
                                <?php 
                }
            } else {
                ?>
                            <tr>
                                <td colspan="4" style="padding:20px;">
                                    <?php 
                echo sprintf(__("You don't have any PayPal feeds configured. Let's go %screate one%s!", "gravityformspaypal"), '<a href="admin.php?page=gf_paypal&view=edit&id=0">', "</a>");
                ?>
                                </td>
                            </tr>
                            <?php 
            }
        }
        ?>
                    </tbody>
                </table>
            </form>
        </div>
        <script type="text/javascript">
            function DeleteSetting(id){
                jQuery("#action_argument").val(id);
                jQuery("#action").val("delete");
                jQuery("#feed_form")[0].submit();
            }
            function ToggleActive(img, feed_id){
                var is_active = img.src.indexOf("active1.png") >=0
                if(is_active){
                    img.src = img.src.replace("active1.png", "active0.png");
                    jQuery(img).attr('title','<?php 
        _e("Inactive", "gravityformspaypal");
        ?>
').attr('alt', '<?php 
        _e("Inactive", "gravityformspaypal");
        ?>
');
                }
                else{
                    img.src = img.src.replace("active0.png", "active1.png");
                    jQuery(img).attr('title','<?php 
        _e("Active", "gravityformspaypal");
        ?>
').attr('alt', '<?php 
        _e("Active", "gravityformspaypal");
        ?>
');
                }

                var mysack = new sack(ajaxurl);
                mysack.execute = 1;
                mysack.method = 'POST';
                mysack.setVar( "action", "gf_paypal_update_feed_active" );
                mysack.setVar( "gf_paypal_update_feed_active", "<?php 
        echo wp_create_nonce("gf_paypal_update_feed_active");
        ?>
" );
                mysack.setVar( "feed_id", feed_id );
                mysack.setVar( "is_active", is_active ? 0 : 1 );
                mysack.onError = function() { alert('<?php 
        _e("Ajax error while updating feed", "gravityformspaypal");
        ?>
' )};
                mysack.runAJAX();

                return true;
            }


        </script>
        <?php 
    }