Plugin Directory

Changeset 633231


Ignore:
Timestamp:
12/02/2012 11:15:28 PM (13 years ago)
Author:
AHWEBDEV
Message:

DEv ajax

Location:
facebook-awd-seo-comments/trunk/inc/classes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • facebook-awd-seo-comments/trunk/inc/classes/class.AWD_facebook_comments_base.php

    r633229 r633231  
    7777        if($this->comments_url == '')
    7878            return false;
     79           
     80
    7981        $fql = "SELECT comments_fbid,commentsbox_count,comment_count FROM link_stat WHERE url='".$this->comments_url."'";
    8082        try {
  • facebook-awd-seo-comments/trunk/inc/classes/class.AWD_facebook_seo_comments.php

    r633227 r633231  
    4949        add_action('AWD_facebook_save_custom_settings',array(&$this,'hook_post_from_custom_options'));
    5050        add_action('AWD_facebook_seo_comments_clear_cache',array(&$this,'clear_comments_cache'));
     51        add_action('wp_ajax_table_comments_list',array(&$this,'ajax_table_comments_list'));
    5152   
    5253        if($this->AWD_facebook->options['comments_merge'] == 1)
     
    295296            <input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />
    296297            <?php $AWD_facebook_table_comments->search_box(__('Search URL',$this->plugin_text_domain), $this->plugin_slug.'_search' ); ?>
    297             <?php $AWD_facebook_table_comments->display(); ?>
     298            <div class="<?php echo $this->plugin_slug; ?>comments-filter-table"><?php $AWD_facebook_table_comments->display(); ?></div>
    298299        </form>
    299300        <br />
     
    324325                $("#search_submit").click(function(e){
    325326                    e.preventDefault();
    326                     $("#'.$this->plugin_slug.'comments-filter").submit();
    327                     $("body").css("cursor", "progress");
     327                    //$("#'.$this->plugin_slug.'comments-filter").submit();
     328                    //$(".'.$this->plugin_slug.'comments-filter-table").slideUp().html("");
     329                    $.post(ajaxurl+"?action=table_comments_list",$("#'.$this->plugin_slug.'comments-filter").serialize().replace("action","action_modified_for_ajax")+"&"+$.param(list_args), function(data){
     330                        $(".'.$this->plugin_slug.'comments-filter-table").html(data.table).slideDown();
     331                        console.log(data);
     332                    },"json");
    328333                });
     334                jQuery(".next-page, .prev-page, th.sortable a").live("click",function(e){
     335                    e.preventDefault();
     336                    $this = $(this);
     337                    $("#'.$this->plugin_slug.'comments-filter input[name=\'paged\']").remove();
     338                    $.post($this.attr("href"),$("#'.$this->plugin_slug.'comments-filter").serialize().replace("action","action_modified_for_ajax")+"&"+$.param(list_args), function(data){
     339                        $(".'.$this->plugin_slug.'comments-filter-table").html(data.table).slideDown();
     340                    },"json");
     341                })
    329342                jQuery("#comment_submit").click(function(e){
    330343                    e.preventDefault();
    331344                    $("#'.$this->plugin_slug.'comments-post").submit();
    332                     $("body").css("cursor", "progress");
    333345                });
    334346            });
     
    337349        echo $style_js;
    338350    }
     351   
     352    public function ajax_table_comments_list(){
     353        $wp_list_table = new AWD_facebook_table_comments($this);
     354        $this->AWD_facebook_comments->comments_url = $_REQUEST['s'];
     355        $this->AWD_facebook_comments->get_comments_id_by_url();
     356        $wp_list_table->ajax_response();
     357        die('0');
     358    }
    339359}
  • facebook-awd-seo-comments/trunk/inc/classes/class.table_comments.php

    r633227 r633231  
    2323            'singular'  => 'comment',     
    2424            'plural'    => 'comments', 
    25             'ajax'      => false
     25            'ajax'      => true
    2626        ));
    2727    }
    28    
     28    function ajax_user_can()
     29    {
     30        return true;
     31    }
    2932    function no_items()
    3033    {
     
    4952        </p>
    5053        <?php
     54        wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
    5155    }
    5256    function column_default($item, $column_name)
     
    209213            return $good_comment_format;
    210214    }
     215   
     216   
     217    function ajax_response() {
     218        $this->prepare_items();
     219        extract( $this->_args );
     220        extract( $this->_pagination_args );
     221
     222        ob_start();
     223        $this->display();
     224        $table = ob_get_clean();
     225        $response = array( 'table' => $table);
     226       
     227        if ( isset( $total_items ) )
     228            $response['total_items_i18n'] = sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) );
     229
     230        if ( isset( $total_pages ) ) {
     231            $response['total_pages'] = $total_pages;
     232            $response['total_pages_i18n'] = number_format_i18n( $total_pages );
     233        }
     234
     235        die( json_encode( $response ) );
     236    }
     237
     238   
    211239}
    212240?>
Note: See TracChangeset for help on using the changeset viewer.