Changeset 827445
- Timestamp:
- 12/23/2013 01:20:15 PM (12 years ago)
- Location:
- nextgen-gallery-voting
- Files:
-
- 34 added
- 2 edited
-
tags/2.7 (added)
-
tags/2.7/css (added)
-
tags/2.7/css/jquery-ui (added)
-
tags/2.7/css/jquery-ui/images (added)
-
tags/2.7/css/jquery-ui/images/animated-overlay.gif (added)
-
tags/2.7/css/jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png (added)
-
tags/2.7/css/jquery-ui/images/ui-bg_flat_75_ffffff_40x100.png (added)
-
tags/2.7/css/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png (added)
-
tags/2.7/css/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png (added)
-
tags/2.7/css/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png (added)
-
tags/2.7/css/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png (added)
-
tags/2.7/css/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png (added)
-
tags/2.7/css/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png (added)
-
tags/2.7/css/jquery-ui/images/ui-icons_222222_256x240.png (added)
-
tags/2.7/css/jquery-ui/images/ui-icons_2e83ff_256x240.png (added)
-
tags/2.7/css/jquery-ui/images/ui-icons_454545_256x240.png (added)
-
tags/2.7/css/jquery-ui/images/ui-icons_888888_256x240.png (added)
-
tags/2.7/css/jquery-ui/images/ui-icons_cd0a0a_256x240.png (added)
-
tags/2.7/css/jquery-ui/jquery-ui-1.10.3.custom.css (added)
-
tags/2.7/css/jquery-ui/jquery-ui-1.10.3.custom.min.css (added)
-
tags/2.7/css/star_rating.css (added)
-
tags/2.7/images (added)
-
tags/2.7/images/loading.gif (added)
-
tags/2.7/images/star.gif (added)
-
tags/2.7/images/thumbs_down.png (added)
-
tags/2.7/images/thumbs_up.png (added)
-
tags/2.7/js (added)
-
tags/2.7/js/admin_gallery.js (added)
-
tags/2.7/js/ajaxify-likes.js (added)
-
tags/2.7/js/ajaxify-stars.js (added)
-
tags/2.7/js/top-voted.js (added)
-
tags/2.7/ngg-voting.php (added)
-
tags/2.7/readme.txt (added)
-
tags/2.7/voting-types.php (added)
-
trunk/ngg-voting.php (modified) (7 diffs)
-
trunk/readme.txt (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
nextgen-gallery-voting/trunk/ngg-voting.php
r769709 r827445 4 4 Plugin URI: http://shauno.co.za/wordpress/nextgen-gallery-voting/ 5 5 Description: This plugin allows you to add user voting and rating to NextGEN Galleries and Images 6 Version: 2. 6.1.16 Version: 2.7 7 7 Author: Shaun Alberts 8 8 Author URI: http://shauno.co.za … … 112 112 add_action('ngg_add_new_gallery_form', array(&$this, 'newGalleryForm')); //new in ngg 1.4.0a 113 113 add_action('ngg_created_new_gallery', array(&$this, 'onCreateGallery')); //new in ngg 1.4.0a 114 /* deprecated in NGG v2, manually call func in gallery template 115 114 116 //gallery voting hooks - user 115 add_filter('ngg_show_gallery_content', array(&$this, 'showGallery'), 10, 2); 117 //add_filter('ngg_show_gallery_content', array(&$this, 'showGallery'), 10, 2); 118 */ 116 119 117 120 add_action('init', array(&$this, 'wpInit')); … … 1740 1743 exit; 1741 1744 } 1745 }else if((isset($_GET['nggv_gid']) && $_GET['nggv_gid']) || isset($_POST['nggv']['vote_gid_id']) && $_POST['nggv']['vote_gid_id']) { 1746 if(isset($_GET['nggv_gid'])) { 1747 $options = $this->getVotingOptions($_GET['nggv_gid']); 1748 }else if(isset($_POST['nggv']['vote_gid_id'])) { 1749 $options = $this->getVotingOptions($_POST['nggv']['vote_gid_id']); 1750 } 1751 $voteFuncs = $this->types[$options->voting_type]['galleryCallback']; 1752 $votedOrErr = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['catch']), array($this, $options)); 1753 1754 //store in class var, so we have it for this page execution 1755 $this->initCatchVote[$options->gid] = array( 1756 'gid'=>$options->gid, 1757 'result'=>$votedOrErr, 1758 'dateadded'=>date('Y-m-d H:i:s', time()) 1759 ); 1760 1761 do_action('nggv_catch_gallery_vote', $options->gid, $this->initCatchVote); 1762 1763 if($_GET['ajaxify']) { //catch the ajax vote 1764 $form = $this->getGalleryVoteMarkup($options); 1765 1766 //echo '<!-- NGGV START AJAX RESPONSE -->'; 1767 //echo '<script>'; 1768 echo 'var nggv_ajax_ver = 2;'; //new in 2.6.1 to help js minification messing up ajac voting 1769 echo 'var nggv_js = {};'; 1770 echo 'nggv_js.options = {};'; 1771 echo 'nggv_js.saved = '.($votedOrErr === true ? '1' : '0').';'; 1772 echo 'nggv_js.msg = "'.addslashes($votedOrErr).'";'; 1773 echo 'nggv_js.voting_form = "'.addslashes($form['form']).'";'; 1774 //echo '<script><!-- NGGV END AJAX RESPONSE -->'; 1775 exit; 1776 } 1742 1777 } 1743 1778 … … 1892 1927 1893 1928 /** 1929 * DEPRECATED 1894 1930 * Hook: ngg_show_gallery_content 1895 1931 * The function adds the voting form/results to the gallery content … … 1901 1937 function showGallery($out, $gid) { 1902 1938 return $out.$this->galleryVoteForm($gid); 1939 } 1940 1941 function getGalleryVoteMarkup($options) { 1942 $gid = $options->gid; 1943 $voteFuncs = $this->types[$options->voting_type]['galleryCallback']; 1944 1945 //is there a vote happing for this gid right now? 1946 $votedOrErr = isset($this->initCatchVote[$gid]['result']) ? $this->initCatchVote[$gid]['result'] : ''; 1947 1948 $form = array(); 1949 if((($canVote = $this->canVote($gid)) === true) && !$votedOrErr) { //they can vote, show the form 1950 //$return = apply_filters('nggv_gallery_vote_form', $nggv, $options); 1951 $form = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['form']), array($this, $options)); 1952 }else{ //ok, they cant vote. what next? 1953 if($options->enable) { 1954 if($canVote === 'NOT LOGGED IN') { //the api wants them to login to vote 1955 $form['form'] = nggVoting::msg('Only registered users can vote. Please login to cast your vote.'); 1956 }else if($canVote === 'USER HAS VOTED' 1957 || $canVote === 'IP HAS VOTED' || $canVote == 'IP HAS VOTED TODAY' || $canVote == 'IP HAS VOTED THIS WEEK' || $canVote == 'IP HAS VOTED THIS MONTH' || $canVote == 'IP HAS VOTED THIS YEAR' 1958 || $canVote === 'USER HAS VOTED' || $canVote == 'USER HAS VOTED TODAY' || $canVote == 'USER HAS VOTED THIS WEEK' || $canVote == 'USER HAS VOTED THIS MONTH' || $canVote == 'USER HAS VOTED THIS YEAR' 1959 || $canVote === 'COOKIE HAS VOTED' || $canVote == 'COOKIE HAS VOTED TODAY' || $canVote == 'COOKIE HAS VOTED THIS WEEK' || $canVote == 'COOKIE HAS VOTED THIS MONTH' || $canVote == 'COOKIE HAS VOTED THIS YEAR' 1960 || $canVote === true) { //api tells us they have voted, can they see results? (canVote will be true if they have just voted successfully) 1961 if($options->user_results) { //yes! show it 1962 $form = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['results']), array($this, $options)); 1963 }else{ //nope, but thanks for trying 1964 $form['form'] = nggVoting::msg('Thank you for casting your vote.'); 1965 } 1966 } 1967 } 1968 } 1969 1970 return $form; 1903 1971 } 1904 1972 … … 1926 1994 } 1927 1995 1928 $url = $_SERVER['REQUEST_URI']; 1929 $url .= (strpos($url, '?') === false ? '?' : (substr($url, -1) == '&' ? '' : '&')); //make sure the url ends in '?' or '&' correctly 1930 1931 1932 //$votedOrErr = nggvGalleryVote::checkVoteData($this, $options); 1933 $voteFuncs = $this->types[$options->voting_type]['galleryCallback']; 1934 $votedOrErr = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['catch']), array($this, $options)); 1935 1936 if(isset($_GET['ajaxify']) && $_GET['ajaxify'] && isset($_GET['nggv_gid']) && $_GET['nggv_gid'] == $gid) { 1937 $out .= '<!-- NGGV START AJAX RESPONSE -->'; 1938 $out .= '<script>'; 1939 $out .= 'var nggv_js = {};'; 1940 $out .= 'nggv_js.options = {};'; 1941 $out .= 'nggv_js.saved = '.($votedOrErr === true ? '1' : '0').';'; 1942 $out .= 'nggv_js.msg = "'.addslashes($votedOrErr).'";'; 1943 } 1944 1945 //$form = nggvGalleryVote::showVoteForm($this, $options, $votedOrErr); 1946 1947 if((($canVote = $this->canVote($gid)) === true) && !$votedOrErr) { //they can vote, show the form 1948 //$return = apply_filters('nggv_gallery_vote_form', $nggv, $options); 1949 $form = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['form']), array($this, $options)); 1950 }else{ //ok, they cant vote. what next? 1951 if($options->enable) { 1952 if($canVote === 'NOT LOGGED IN') { //the api wants them to login to vote 1953 $form['form'] = nggVoting::msg('Only registered users can vote. Please login to cast your vote.'); 1954 }else if($canVote === 'USER HAS VOTED' || $canVote === 'IP HAS VOTED' || $canVote === true) { //api tells us they have voted, can they see results? (canVote will be true if they have just voted successfully) 1955 if($options->user_results) { //yes! show it 1956 $form = @call_user_func_array(array($voteFuncs['class'], $voteFuncs['results']), array($this, $options)); 1957 }else{ //nope, but thanks for trying 1958 $form['form'] = nggVoting::msg('Thank you for casting your vote.'); 1959 } 1960 } 1961 } 1962 } 1963 1964 if(isset($_GET['ajaxify']) && $_GET['ajaxify']) { 1965 $out .= 'nggv_js.voting_form = "'.addslashes($form['form']).'";'; 1966 }else{ 1967 $out .= '<div class="nggv_container">'; 1996 $form = $this->getGalleryVoteMarkup($options); 1997 1998 $out .= '<div class="nggv_container">'; 1999 $out .= (isset($form['scripts']) ? $form['scripts'] : ''); 2000 2001 //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 2002 global $_nggv_generic_err; 2003 if(!$_nggv_generic_err) { 1968 2004 $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.')).'" />'; 1969 $out .= isset($form['scripts']) ? $form['scripts'] : ''; 1970 $out .= '<div class="nggv-error" style="'.(!$votedOrErr || $votedOrErr === true ? 'display:none;' : '').' border: 1px solid red;">'; 1971 $out .= $votedOrErr; 1972 $out .= '</div>'; 1973 1974 $out .= '<div class="nggv-vote-form">'; 1975 $out .= $form['form']; 1976 $out .= '</div>'; 2005 $_nggv_generic_err = true; 2006 } 2007 2008 $votedOrErr = isset($this->initCatchVote[$gid]['result']) ? $this->initCatchVote[$gid]['result'] : ''; 2009 2010 $out .= '<div class="nggv-error" style="'.(!$votedOrErr || $votedOrErr === true ? 'display:none;' : '').' border: 1px solid red;">'; 2011 $out .= $votedOrErr; 1977 2012 $out .= '</div>'; 1978 } 1979 1980 if(isset($_GET['ajaxify']) && $_GET['ajaxify'] && isset($_GET['nggv_gid']) && $_GET['nggv_gid'] == $gid) { 1981 $out .= '<script><!-- NGGV END AJAX RESPONSE -->'; 1982 } 2013 2014 $out .= '<div class="nggv-vote-form">'; 2015 $out .= $form['form']; 2016 $out .= '</div>'; 2017 $out .= '</div>'; 2018 2019 do_action('nggv_gallery_vote_bottom', $options); 1983 2020 } 1984 2021 … … 1996 2033 return $officalNggVoting->imageVoteForm($pid, $criteriaId); 1997 2034 } 2035 2036 function nggv_galleryVoteForm($displayed_gallery, $gallery) { 2037 global $officalNggVoting; 2038 2039 $gid = 0; 2040 2041 //'new' templates 2042 if(is_object($displayed_gallery) && isset($displayed_gallery->container_ids)) { 2043 if(count($displayed_gallery->container_ids) == 1 && is_numeric($displayed_gallery->container_ids[0])) { 2044 $gid = $displayed_gallery->container_ids[0]; 2045 } 2046 } 2047 2048 //'legacy' templates 2049 if(!$gid && $gallery) { 2050 if(isset($gallery->displayed_gallery) && isset($gallery->displayed_gallery->container_ids)) { 2051 if(count($gallery->displayed_gallery->container_ids) == 1 && is_numeric($gallery->displayed_gallery->container_ids[0])) { 2052 $gid = $gallery->displayed_gallery->container_ids[0]; 2053 } 2054 } 2055 } 2056 2057 if($gid) { 2058 return $officalNggVoting->galleryVoteForm($gid); 2059 } 2060 } 1998 2061 //} 1999 2062 ?> -
nextgen-gallery-voting/trunk/readme.txt
r755230 r827445 4 4 Tags: nextgen-gallery, nextgen, gallery, voting, rating, ratings, nextgen-gallery-voting 5 5 Requires at least: 2.9.1 6 Tested up to: 3. 67 Stable tag: 2. 6.16 Tested up to: 3.8 7 Stable tag: 2.7 8 8 9 9 Adds the ability for users to vote and rate your NextGEN Images. Simple options give you the ability to limit who can vote on what. 10 10 11 11 == Description == 12 **PLEASE NOTE:** This plugin was written for NextGEN Gallery 1.x, but recently NGG have released version 2.x.13 I am working on bringing all the voting features up to date, but currently only the **Image** options work with NGG 2.x14 12 15 13 = Features = … … 29 27 == Frequently Asked Questions == 30 28 31 = Important note about NextGEN Gallery version 2.x =32 This plugin was written for NGG 1.x. The recent release of NGG 2.x has lead to the gallery voting functions not being applicable anymore.33 I am working on an update to fix this in the future, but please be aware that they currently DO NOT WORK. You can ignore any reference to34 the gallery options in the FAQ below35 36 29 = In a nutshell, what is this? = 37 30 This plugin adds options that can allow your users to vote on (more like rate) your Galleries and Images. There are options to limit which … … 39 32 current results. 40 33 41 = How do I make the voting form appear for images? = 42 You need to add a small tag, `<?php echo nggv_imageVoteForm($image->pid); ?>`, to the gallery output template to get the voting showing in 43 the galllery. 34 = How do I show the voting form? = 35 You need to add a small tag to the gallery display template. 36 37 **For image voting:** 38 For image voting, add the following tag: `<?php echo nggv_imageVoteForm($image->pid); ?>`, to the gallery display template. 39 40 **For gallery voting:** 41 For gallery voting, add the following tag: `<?php echo nggv_galleryVoteForm($displayed_gallery, $gallery); ?>`, to the gallery display template. 44 42 45 43 For NGG 1.x, you can find the gallery templates in the `/plugins/nextgen-gallery/view/` directory. For the default shortcode, `[nggallery id=x]`, you … … 49 47 For NGG version 2.x, you need to add the tag to the `/nextgen-gallery/products/photocrati_nextgen/modules/nextgen_basic_gallery/templates/thumbnails/index.php` 50 48 template. This will only work for galleries inserted WITHOUT selectiong a template from the gallery display options. 51 52 Please be aware, the voting form needs to be placed inside the `foreach()` loop in those templates, as that loop is outputting each image. 49 NGG v2.x templating system can be confusing for some users. Please see [this page](http://shauno.co.za/nextgen-gallery-v2-display-template-locations/) for more info on which templates are used. 50 51 Please be aware, for **image voting**, the form needs to be placed inside the `foreach()` loop in those templates, as that loop is outputting each image. 53 52 I find the best place to put the tag is AFTER the `<div class="ngg-gallery-thumbnail">` is CLOSED. 53 For **gallery voting**, be sure to place the tag outside of the foreach, or it will show more than once on the page. 54 54 55 55 = Can I style it? = … … 77 77 78 78 == Changelog == 79 80 = 2.7 = 81 * Added code to fix NGG Publuc Uploader bug, allowing it to be used with NGG Voting. 82 * Fixed gallery voting when using NGG v2.x. 79 83 80 84 = 2.6.1 = … … 211 215 == Upgrade Notice == 212 216 217 = 2.7 = 218 Fixed gallery voting on NGG v2.x. Also added code to make NGG Voting work with NGG Public Uploader 219 213 220 = 2.6.1 = 214 221 Minor updates to improve NextGEN Gallery version 2 compatibilty, and installs in a sub directory
Note: See TracChangeset
for help on using the changeset viewer.