Plugin Directory

Changeset 739201


Ignore:
Timestamp:
07/11/2013 01:55:36 PM (12 years ago)
Author:
shauno
Message:

Version 2.6 commit.
Mostly hooks and filters for next premium release. Also added screenshots to repo

Location:
nextgen-gallery-voting
Files:
41 added
5 edited

Legend:

Unmodified
Added
Removed
  • nextgen-gallery-voting/trunk/js/ajaxify-likes.js

    r618913 r739201  
    1 jQuery(document).ready(function() {
    2         jQuery('a.nggv-link-like, a.nggv-link-dislike').click(function(e) {
    3                 var container = jQuery(this).parents('.nggv_container');
    4                
    5                 container.find('img.nggv-star-loader').show();
    6                
    7                 var url = jQuery(this).attr('href');
    8                 url += '&ajaxify=1';
    9                
    10                 jQuery.ajax({
    11                         url: url,
    12                         data: '',
    13                         success: function(data, textStatus, XMLHttpRequest) {
    14                             var start = data.indexOf("<!-- NGGV START AJAX RESPONSE -->") + 41; //find the start of the outputting by the ajax url (stupid wordpress and poor buffering options blah blah)
    15                             var end = data.indexOf("<script><!-- NGGV END AJAX RESPONSE -->");
    16                            
    17                             var js = data.substr(start, (end-start));
    18                             js = js.replace(/(\r\n|\n|\r)/gm,'');
    19                            
    20                             eval(js); //the array of voters gets echoed out at the ajax url
    21                            
    22                             if(typeof(nggv_js) == 'object') {
    23                                 var msg = '';
    24                                 if(nggv_js.saved) {
    25                                     jQuery(document).focus();
    26                                     container.find('.nggv-vote-form').html(nggv_js.voting_form);
    27                                 }else{
    28                                     if(nggv_js.msg) {
    29                                         msg = nggv_js.msg
    30                                     }else{ //there should always be a msg, but just in case lets default one
    31                                         msg = jQuery('#ngg-genric-err-msg').val();
    32                                     }
    33                                    
    34                                     //if we got markup back, replace the voting form with it
    35                                     if(nggv_js.voting_form) {
    36                                         jQuery(document).focus();
    37                                         container.find('.nggv-vote-form').html(nggv_js.voting_form);
    38                                     }
    39                                 }
    40                             }else{
     1function nggv_dis_like_click(e) {
     2        var container = jQuery(this).parents('.nggv_container');
     3       
     4        container.find('img.nggv-star-loader').show();
     5       
     6        var url = jQuery(this).attr('href');
     7        url += '&ajaxify=1';
     8       
     9        jQuery.ajax({
     10                url: url,
     11                data: '',
     12                success: function(data, textStatus, XMLHttpRequest) {
     13                    var start = data.indexOf("<!-- NGGV START AJAX RESPONSE -->") + 41; //find the start of the outputting by the ajax url (stupid wordpress and poor buffering options blah blah)
     14                    var end = data.indexOf("<script><!-- NGGV END AJAX RESPONSE -->");
     15                   
     16                    var js = data.substr(start, (end-start));
     17                    js = js.replace(/(\r\n|\n|\r)/gm,'');
     18                   
     19                    eval(js); //the array of voters gets echoed out at the ajax url
     20                   
     21                    if(typeof(nggv_js) == 'object') {
     22                        var msg = '';
     23                        if(nggv_js.saved) {
     24                            jQuery(document).focus();
     25                            container.find('.nggv-vote-form').html(nggv_js.voting_form);
     26                        }else{
     27                            if(nggv_js.msg) {
     28                                msg = nggv_js.msg
     29                            }else{ //there should always be a msg, but just in case lets default one
    4130                                msg = jQuery('#ngg-genric-err-msg').val();
    4231                            }
    4332                           
    44                             if(msg) {
    45                                 //the 'continer' div and 'nggv-error' div are on the same dom level, making them siblings
    46                                 container.find('div.nggv-error').show();
    47                                 container.find('div.nggv-error').html(msg);
     33                            //if we got markup back, replace the voting form with it
     34                            if(nggv_js.voting_form) {
     35                                jQuery(document).focus();
     36                                container.find('.nggv-vote-form').html(nggv_js.voting_form);
    4837                            }
    49                         },
    50                         error: function(XMLHttpRequest, textStatus, errorThrown) {
    51                             container.find('div.nggv-error').show();
    52                             container.find('div.nggv-error').html(jQuery('#ngg-genric-err-msg').val());
    53                         },
    54                         complete: function() {
    55                             container.find('img.nggv-star-loader').hide();
    5638                        }
    57                 });
    58                
    59                 e.preventDefault();
    60                 return false;
     39                    }else{
     40                        msg = jQuery('#ngg-genric-err-msg').val();
     41                    }
     42                   
     43                    if(msg) {
     44                        //the 'continer' div and 'nggv-error' div are on the same dom level, making them siblings
     45                        container.find('div.nggv-error').show();
     46                        container.find('div.nggv-error').html(msg);
     47                    }
     48                },
     49                error: function(XMLHttpRequest, textStatus, errorThrown) {
     50                    container.find('div.nggv-error').show();
     51                    container.find('div.nggv-error').html(jQuery('#ngg-genric-err-msg').val());
     52                },
     53                complete: function() {
     54                    container.find('img.nggv-star-loader').hide();
     55                }
    6156        });
     57       
     58        e.preventDefault();
     59        return false;
     60}
     61
     62jQuery(document).ready(function() {
     63        jQuery('a.nggv-link-like, a.nggv-link-dislike').click(nggv_dis_like_click);
    6264});
  • nextgen-gallery-voting/trunk/js/ajaxify-stars.js

    r618913 r739201  
     1function nggv_stars_click(e) {
     2    var container = jQuery(this).parents('.nggv_container');
     3   
     4    container.find('img.nggv-star-loader').show();
     5   
     6    var url = jQuery(this).attr('href');
     7    url += '&ajaxify=1';
     8   
     9    jQuery.ajax({
     10            url: url,
     11            data: '',
     12            success: function(data, textStatus, XMLHttpRequest) {
     13                var start = data.indexOf("<!-- NGGV START AJAX RESPONSE -->") + 41; //find the start of the outputting by the ajax url (stupid wordpress and poor buffering options blah blah)
     14                var end = data.indexOf("<script><!-- NGGV END AJAX RESPONSE -->");
     15               
     16                var js = data.substr(start, (end-start));
     17                js = js.replace(/(\r\n|\n|\r)/gm,'');
     18               
     19                eval(js); //the array of voters gets echoed out at the ajax url
     20               
     21                if(typeof(nggv_js) == 'object') {
     22                    var msg = '';
     23                    if(nggv_js.saved) {
     24                        jQuery(document).focus();
     25                        container.find('.nggv-vote-form').html(nggv_js.voting_form);
     26                    }else{
     27                        if(nggv_js.msg) {
     28                            msg = nggv_js.msg
     29                        }else{ //there should always be a msg, but just in case lets default one
     30                            msg = jQuery('#ngg-genric-err-msg').val();
     31                        }
     32                       
     33                        //if we got markup back, replace the voting form with it
     34                        if(nggv_js.voting_form) {
     35                            jQuery(document).focus();
     36                            container.find('.nggv-vote-form').html(nggv_js.voting_form);
     37                        }
     38                    }
     39                }else{
     40                    msg = jQuery('#ngg-genric-err-msg').val();
     41                }
     42               
     43                if(msg) {
     44                    //the 'continer' div and 'nggv-error' div are on the same dom level, making them siblings
     45                    container.find('div.nggv-error').show();
     46                    container.find('div.nggv-error').html(msg);
     47                }
     48            },
     49            error: function(XMLHttpRequest, textStatus, errorThrown) {
     50                container.find('div.nggv-error').show();
     51                container.find('div.nggv-error').html(jQuery('#ngg-genric-err-msg').val());
     52            },
     53            complete: function() {
     54                container.find('img.nggv-star-loader').hide();
     55            }
     56    });
     57   
     58    e.preventDefault();
     59    return false;
     60}
     61
    162jQuery(document).ready(function() {
    2         jQuery('ul.star-rating li a').click(function(e) {
    3                 var container = jQuery(this).parents('.nggv_container');
    4                
    5                 container.find('img.nggv-star-loader').show();
    6                
    7                 var url = jQuery(this).attr('href');
    8                 url += '&ajaxify=1';
    9                
    10                 jQuery.ajax({
    11                         url: url,
    12                         data: '',
    13                         success: function(data, textStatus, XMLHttpRequest) {
    14                             var start = data.indexOf("<!-- NGGV START AJAX RESPONSE -->") + 41; //find the start of the outputting by the ajax url (stupid wordpress and poor buffering options blah blah)
    15                             var end = data.indexOf("<script><!-- NGGV END AJAX RESPONSE -->");
    16                            
    17                             var js = data.substr(start, (end-start));
    18                             js = js.replace(/(\r\n|\n|\r)/gm,'');
    19                            
    20                             eval(js); //the array of voters gets echoed out at the ajax url
    21                            
    22                             if(typeof(nggv_js) == 'object') {
    23                                 var msg = '';
    24                                 if(nggv_js.saved) {
    25                                     jQuery(document).focus();
    26                                     container.find('.nggv-vote-form').html(nggv_js.voting_form);
    27                                 }else{
    28                                     if(nggv_js.msg) {
    29                                         msg = nggv_js.msg
    30                                     }else{ //there should always be a msg, but just in case lets default one
    31                                         msg = jQuery('#ngg-genric-err-msg').val();
    32                                     }
    33                                    
    34                                     //if we got markup back, replace the voting form with it
    35                                     if(nggv_js.voting_form) {
    36                                         jQuery(document).focus();
    37                                         container.find('.nggv-vote-form').html(nggv_js.voting_form);
    38                                     }
    39                                 }
    40                             }else{
    41                                 msg = jQuery('#ngg-genric-err-msg').val();
    42                             }
    43                            
    44                             if(msg) {
    45                                 //the 'continer' div and 'nggv-error' div are on the same dom level, making them siblings
    46                                 container.find('div.nggv-error').show();
    47                                 container.find('div.nggv-error').html(msg);
    48                             }
    49                         },
    50                         error: function(XMLHttpRequest, textStatus, errorThrown) {
    51                             container.find('div.nggv-error').show();
    52                             container.find('div.nggv-error').html(jQuery('#ngg-genric-err-msg').val());
    53                         },
    54                         complete: function() {
    55                             container.find('img.nggv-star-loader').hide();
    56                         }
    57                 });
    58                
    59                 e.preventDefault();
    60                 return false;
    61         });
     63        jQuery('ul.star-rating li a').click(nggv_stars_click);
    6264});
  • nextgen-gallery-voting/trunk/js/top-voted.js

    r723381 r739201  
    88                e.preventDefault();
    99        });
     10       
     11        /*
     12        jQuery('a.nggv-delete-vote').click(function(e) {
     13                if(!confirm('Are you sure you want to delete this vote? This cannot be undone!')) {
     14                    e.preventDefault();
     15                }
     16        });
     17        */
    1018});
    1119
  • nextgen-gallery-voting/trunk/ngg-voting.php

    r724636 r739201  
    44Plugin URI: http://shauno.co.za/wordpress/nextgen-gallery-voting/
    55Description: This plugin allows you to add user voting and rating to NextGEN Galleries and Images
    6 Version: 2.5.2
     6Version: 2.6
    77Author: Shaun Alberts
    88Author URI: http://shauno.co.za
     
    3535
    3636class nggVoting {
    37     private $dbVersion = 2.5;
    38     private $slug;
     37    private $dbVersion = 2.6;
     38    public $slug;
    3939    public $types = array(
    4040        '2'=>array('name'=>'Star Rating', 'gallery'=>true, 'image'=>true,
     
    9191        $this->slug = basename(dirname(__FILE__));
    9292       
    93         $dir = array_pop(explode('/', str_replace('\\', '/', dirname(__FILE__))));
     93        $tmp = explode('/', str_replace('\\', '/', dirname(__FILE__)));
     94        $dir = array_pop($tmp);
    9495        $this->pluginUrl = trailingslashit(WP_PLUGIN_URL.'/'.$dir);
    9596        $this->pluginPath = trailingslashit(str_replace('\\', '/', dirname(__FILE__)));
     
    142143                voting_type INT NOT NULL DEFAULT 1,
    143144                criteria_id BIGINT NOT NULL DEFAULT 0,
     145                show_in_popup TINYINT NOT NULL DEFAULT 0,
    144146                UNIQUE KEY id (id)
    145147            );';
     
    906908                echo '<td><strong>User Name</strong><br ><em>(if logged in)</em></td>';
    907909                echo '<td><strong>IP</strong></td>';
     910                echo '<td></td>';
    908911                echo '</tr>';
    909912                echo '</thead>';
     
    927930                    echo '<td>'.(isset($user_info->data->display_name) && $user_info->data->display_name ? $user_info->data->display_name : $val->user_id).'</td>';
    928931                    echo '<td>'.$val->ip.'</td>';
     932                    echo '<td>';
     933                    echo apply_filters('nggv_top_voted_row_actions', '', $this, $val);
     934                    echo '</td>';
    929935                    echo '</tr>';
    930936                   
     
    932938                }
    933939               
     940                echo do_action('nggv_popup_votes_list_bottom', $this, $options);
     941               
    934942                echo '</tbody>';
    935943                echo '</table>';
     944               
    936945                exit;
    937946                /*
     
    10261035                    <p>
    10271036                        Here you can set the default voting options for Galleries and Images.
    1028                         Changing these options will not affect any existing Galleries or Images.
     1037                        Changing these options will not affect any existing Galleries or Images. You can change the settings per image or gallery from the 'Manage Gallery' screen in NextGEN Gallery.
    10291038                    </p>
    10301039                   
     
    10541063       
    10551064                                <tr valign="top">
    1056                                     <th>Limit user to 1 vote:<br ><em>(IP or userid is used to stop multiple)</em></th>
     1065                                    <th>Limit user to 1 vote:<br ><em><small>IP or userid is used to stop multiple</small></em></th>
    10571066                                    <td style="text-align:center;"><input type="checkbox" name="nggv[gallery][force_once]" <?php echo (get_option('nggv_gallery_force_once') ? 'checked="checked"' : ''); ?> /></td>
    10581067                                    <td style="text-align:center;">
     
    11941203                                <tr>
    11951204                                    <th>From Date</th>
    1196                                     <td><input type="text" id="nggv_date_from" name="nggv[date_from]" value="<?php echo $_GET['nggv']['date_from'] ?>" /></td>
     1205                                    <td><input type="text" id="nggv_date_from" name="nggv[date_from]" value="<?php echo (isset($_GET['nggv']['date_from']) ? $_GET['nggv']['date_from'] : '') ?>" /></td>
    11971206                                    <th>To Date</th>
    1198                                     <td><input type="text" id="nggv_date_to" name="nggv[date_to]" value="<?php echo $_GET['nggv']['date_to'] ?>" /></td>
     1207                                    <td><input type="text" id="nggv_date_to" name="nggv[date_to]" value="<?php echo (isset($_GET['nggv']['date_to']) ? $_GET['nggv']['date_to'] : '') ?>" /></td>
    11991208                                </tr>
    12001209                               
     
    12651274                                            if($val->criteria_id) {
    12661275                                                if(class_exists('nggVotingPremium')) {
    1267                                                     $c = nggVotingPremium::getCriteria(array('id'=>$val->criteria_id));
    1268                                                     echo $c->name;
     1276                                                    if($c = nggVotingPremium::getCriteria(array('id'=>$val->criteria_id))) {
     1277                                                        echo $c->name;
     1278                                                    }else{
     1279                                                        echo 'Critera has been deleted';
     1280                                                    }
    12691281                                                }
    12701282                                            }else{
     
    15021514                        //TODO 2.0 Consider APIing these queries, using new wpdb insert/update methods
    15031515                        if($this->getImageVotingOptions($pid, $criteriaId)) {
    1504                             $wpdb->query('UPDATE '.$wpdb->prefix.'nggv_settings SET criteria_id = "'.$criteriaId.'", force_login = "'.$login.'", force_once = "'.$once.'", user_results = "'.$user_results.'", enable = "'.$enable.'", voting_type = "'.$voting_type.'" WHERE pid = "'.$wpdb->escape($pid).'"');
     1516                            $wpdb->query('UPDATE '.$wpdb->prefix.'nggv_settings SET criteria_id = "'.$criteriaId.'", force_login = "'.$login.'", force_once = "'.$once.'", user_results = "'.$user_results.'", enable = "'.$enable.'", voting_type = "'.$voting_type.'" WHERE pid = "'.$wpdb->escape($pid).'" AND criteria_id = "'.$wpdb->escape($criteriaId).'"');
    15051517                        }else{
    15061518                            $wpdb->query('INSERT INTO '.$wpdb->prefix.'nggv_settings (id, pid, criteria_id, enable, force_login, force_once, user_results, voting_type) VALUES (null, "'.$wpdb->escape($pid).'", "'.$criteriaId.'", "'.$enable.'", "'.$login.'", "'.$once.'", "'.$user_results.'", "'.$voting_type.'")');
     
    17081720                }
    17091721            }
     1722           
     1723            do_action('nggv_wp_init_bottom', $this);
    17101724        }
    17111725       
     
    18221836                    $out .= '<div class="nggv_container">';
    18231837                        $out .= (isset($form['scripts']) ?  $form['scripts'] : '');
    1824                         $out .= '<input type="hidden" id="ngg-genric-err-msg" value="'.esc_attr(nggVoting::msg('There was a problem saving your vote, please try again in a few moments.')).'" />';
     1838                       
     1839                        //make sure the generic err is only every output once. hackity, but needs to be in for backwards compat with premium releases blah blah etc
     1840                        global $_nggv_generic_err;
     1841                        if(!$_nggv_generic_err) {
     1842                            $out .= '<input type="hidden" id="ngg-genric-err-msg" value="'.esc_attr(nggVoting::msg('There was a problem saving your vote, please try again in a few moments.')).'" />';
     1843                            $_nggv_generic_err = true;
     1844                        }
     1845                       
     1846                        $votedOrErr = isset($this->initCatchVote[$pid][$criteriaId]['result']) ? $this->initCatchVote[$pid][$criteriaId]['result'] : '';
    18251847
    18261848                        $out .= '<div class="nggv-error" style="'.(!$votedOrErr || $votedOrErr === true ? 'display:none;' : '').' border: 1px solid red;">';
     
    18321854                        $out .= '</div>';
    18331855                    $out .= '</div>';
     1856                   
     1857                    do_action('nggv_image_vote_bottom', $options);
    18341858                /*
    18351859                }
  • nextgen-gallery-voting/trunk/readme.txt

    r724636 r739201  
    44Tags: nextgen-gallery, nextgen, gallery, voting, rating, ratings, nextgen-gallery-voting
    55Requires at least: 2.9.1
    6 Tested up to: 3.5.1
    7 Stable tag: 2.5.2
    8 
    9 Adds the ability for users to vote and rate your NextGEN Galleries and Images. Simple to understand options give you the ability to
    10 limit who can vote on what.
     6Tested up to: 3.5.2
     7Stable tag: 2.6
     8
     9Adds the ability for users to vote and rate your NextGEN Galleries and Images. Simple to understand options give you the ability to limit who can vote on what.
    1110
    1211== Description ==
     
    3534Do not put inside the `<a>` tag that wraps the image in some of the templates, or the link will conflict with the voting process.
    3635
    37 = Ew, that looks hideous =
    38 This plugin intentionally adds very little styling to the voting forms. It does provded plenty of ids and classes allowing you to style it to fit in with your site.
     36= Can I style it? =
     37Absolutely. This plugin intentionally adds very little styling to the voting forms, but it does provide plenty of ids and classes allowing you to style it to fit in with your site.
    3938
    4039= Where are the results =
    41 Under the Gallery or Image options, the current average vote show along with how many votes have been cast.  Click on the number of votes cast to show more info on those votes.
     40Under the Gallery or Image options, the current average vote show along with how many votes have been cast.  Click on the number of votes cast to view more info on those votes.
     41You can also see more information on the voting results under the 'Top Voted' menu option.
    4242
    4343== Installation ==
     
    46461. Activate the plugin through the 'Plugins' menu in WordPress
    47471. Go to 'Manage Gallery' in NextGEN, and select a gallery to see the new options
    48 1. Remember to add the tag to the gallery template for image voting to work!
     481. Remember to add the tag to the gallery template for image voting to work (see the FAQ)!
     49
     50== Screenshots ==
     51
     521. Main settings screen to control settings for any new Images or Galleries created
     532. The image settings for an actual image in the NextGEN Gallery 'Manage Gallery' screen
     543. Voting types available (more available in the Premium add-on!)
     554. Voting results for an image
     565. Top Voted screen showing you images and their votes
     576. Images with voting enabled
    4958
    5059== Changelog ==
     60
     61= 2.6 =
     62* Added hooks and filters for the premium add-on to use.
    5163
    5264= 2.5.2 =
     
    176188== Upgrade Notice ==
    177189
     190= 2.6 =
     191Minor update adding hooks and filters for next Premium add-on version to use.
     192
    178193= 2.5.2 =
    179194This update fixes an issue stopping the vote form showing for certain setups.
Note: See TracChangeset for help on using the changeset viewer.