|
From: <vo...@us...> - 2013-02-18 11:39:52
|
Revision: 11058
http://sourceforge.net/p/xoops/svn/11058
Author: voltan1
Date: 2013-02-18 11:39:46 +0000 (Mon, 18 Feb 2013)
Log Message:
-----------
Add ajax rate
Modified Paths:
--------------
XoopsModules/oledrion/branches/voltan/oledrion/admin/actions/attributes.php
XoopsModules/oledrion/branches/voltan/oledrion/ajax.php
XoopsModules/oledrion/branches/voltan/oledrion/all-products.php
XoopsModules/oledrion/branches/voltan/oledrion/class/oledrion_products.php
XoopsModules/oledrion/branches/voltan/oledrion/docs/changelog.txt
XoopsModules/oledrion/branches/voltan/oledrion/language/english/modinfo.php
XoopsModules/oledrion/branches/voltan/oledrion/product.php
XoopsModules/oledrion/branches/voltan/oledrion/rate-product.php
XoopsModules/oledrion/branches/voltan/oledrion/templates/oledrion_product.html
Added Paths:
-----------
XoopsModules/oledrion/branches/voltan/oledrion/images/rate/
XoopsModules/oledrion/branches/voltan/oledrion/images/rate/delete.gif
XoopsModules/oledrion/branches/voltan/oledrion/images/rate/index.html
XoopsModules/oledrion/branches/voltan/oledrion/images/rate/star.gif
Modified: XoopsModules/oledrion/branches/voltan/oledrion/admin/actions/attributes.php
===================================================================
--- XoopsModules/oledrion/branches/voltan/oledrion/admin/actions/attributes.php 2013-02-18 09:15:51 UTC (rev 11057)
+++ XoopsModules/oledrion/branches/voltan/oledrion/admin/actions/attributes.php 2013-02-18 11:39:46 UTC (rev 11058)
@@ -277,7 +277,7 @@
$edit = false;
}
// Appel à jQuery
- oledrion_utils::callJavascriptFile('jquery/jquery.js', false, true);
+ $xoTheme->addScript("browse.php?Frameworks/jquery/jquery.js");
oledrion_utils::callJavascriptFile('noconflict.js', false, true);
// Appel du fichier langue
oledrion_utils::callJavascriptFile('messages.js', true, true);
Modified: XoopsModules/oledrion/branches/voltan/oledrion/ajax.php
===================================================================
--- XoopsModules/oledrion/branches/voltan/oledrion/ajax.php 2013-02-18 09:15:51 UTC (rev 11057)
+++ XoopsModules/oledrion/branches/voltan/oledrion/ajax.php 2013-02-18 11:39:46 UTC (rev 11058)
@@ -237,7 +237,52 @@
}
$return = json_encode($ret);
}
- break;
+ break;
+
+ // Ajax rate
+ case 'rate':
+ if(isset($_POST['product_id'])) {
+ $product_id = intval($_POST['product_id']);
+ $product = null;
+ $product = $h_oledrion_products->get($product_id);
+ if(is_object($product) && $product->getVar('product_online') && !oledrion_utils::getModuleOption('show_unpublished') && $product->getVar('product_submitted') < time() && oledrion_utils::getModuleOption('nostock_display') && $product->getVar('product_stock')) {
+ $GLOBALS['current_category'] = -1;
+ $ratinguser = oledrion_utils::getCurrentUserID();
+ $canRate = true;
+ if ($ratinguser != 0) {
+ if($h_oledrion_votedata->hasUserAlreadyVoted($ratinguser, $product->getVar('product_id'))) {
+ $canRate = false;
+ }
+ } else {
+ if($h_oledrion_votedata->hasAnonymousAlreadyVoted('', $product->getVar('product_id'))) {
+ $canRate = false;
+ }
+ }
+ if($canRate) {
+ if($_POST['rating'] == '--' ) {
+ oledrion_utils::redirect(_OLEDRION_NORATING, OLEDRION_URL.'product.php?product_id='.$product->getVar('product_id'),4);
+ }
+ $rating = intval($_POST['rating']);
+ if($rating <1 || $rating > 10) {
+ exit(_ERRORS);
+ }
+ $result = $h_oledrion_votedata->createRating($product->getVar('product_id'), $ratinguser, $rating);
+
+ // Calcul du nombre de votes et du total des votes pour mettre à jour les informations du produit
+ $totalVotes = 0;
+ $sumRating = 0;
+ $ret = 0;
+ $ret = $h_oledrion_votedata->getCountRecordSumRating($product->getVar('product_id'), $totalVotes, $sumRating);
+
+ $finalrating = $sumRating / $totalVotes;
+ $finalrating = number_format($finalrating, 4);
+ $h_oledrion_products->updateRating($product_id, $finalrating, $totalVotes);
+ $ratemessage = _OLEDRION_VOTEAPPRE.'<br />'.sprintf(_OLEDRION_THANKYOU,$xoopsConfig['sitename']);
+ oledrion_utils::redirect($ratemessage, OLEDRION_URL.'product.php?product_id='.$product->getVar('product_id'), 2);
+ }
+ }
+ }
+ break;
}
echo $return;
?>
\ No newline at end of file
Modified: XoopsModules/oledrion/branches/voltan/oledrion/all-products.php
===================================================================
--- XoopsModules/oledrion/branches/voltan/oledrion/all-products.php 2013-02-18 09:15:51 UTC (rev 11057)
+++ XoopsModules/oledrion/branches/voltan/oledrion/all-products.php 2013-02-18 11:39:46 UTC (rev 11058)
@@ -60,7 +60,7 @@
oledrion_utils::setCSS();
oledrion_utils::setLocalCSS($xoopsConfig['language']);
if(!OLEDRION_MY_THEME_USES_JQUERY) {
- oledrion_utils::callJavascriptFile('jquery/jquery.js');
+ $xoTheme->addScript("browse.php?Frameworks/jquery/jquery.js");
}
oledrion_utils::callJavascriptFile('noconflict.js');
oledrion_utils::callJavascriptFile('tablesorter/jquery.tablesorter.min.js');
Modified: XoopsModules/oledrion/branches/voltan/oledrion/class/oledrion_products.php
===================================================================
--- XoopsModules/oledrion/branches/voltan/oledrion/class/oledrion_products.php 2013-02-18 09:15:51 UTC (rev 11057)
+++ XoopsModules/oledrion/branches/voltan/oledrion/class/oledrion_products.php 2013-02-18 11:39:46 UTC (rev 11058)
@@ -1245,8 +1245,9 @@
if($itemsCount > oledrion_utils::getModuleOption('max_products')) { // Il faut créer notre propre sélecteur
if($parameters['multiple']) {
if($jqueryIncluded == null) {
- $jqueryIncluded = true;
- oledrion_utils::callJavascriptFile('jquery/jquery.js');
+ $jqueryIncluded = true;
+ global $xoTheme;
+ $xoTheme->addScript("browse.php?Frameworks/jquery/jquery.js");
}
oledrion_utils::callJavascriptFile('select/select.js', false, true);
$productTray = new XoopsFormElementTray($parameters['caption'], '');
Modified: XoopsModules/oledrion/branches/voltan/oledrion/docs/changelog.txt
===================================================================
--- XoopsModules/oledrion/branches/voltan/oledrion/docs/changelog.txt 2013-02-18 09:15:51 UTC (rev 11057)
+++ XoopsModules/oledrion/branches/voltan/oledrion/docs/changelog.txt 2013-02-18 11:39:46 UTC (rev 11058)
@@ -2,15 +2,17 @@
2.34
---------------------------------------
- Add Ajax search system and block (voltan)
+- Add Ajax rate (voltan)
+- Add json output for products and categoresy (voltan)
- Improve search (voltan)
- Improve gateway ( checkout.php admin/gateways/gateway.php ) (voltan)
+- improve admin order page (voltan)
+- improve product properties (voltan)
+- improve load jquery (voltan)
- Fix errors in admin and user side (voltan)
- Remove Cache Lite (voltan)
-- Support php 5.4.11 and mysql 5.5.28 (voltan)
+- Support php 5.4.11 and mysql 5.5.29 (voltan)
- convert all files to utf-8 (voltan)
-- json output for products and categoresy (voltan)
-- improve admin order page (voltan)
-- improve product properties (voltan)
---------------------------------------
2.33 Beta 1 2012-07-23
Added: XoopsModules/oledrion/branches/voltan/oledrion/images/rate/delete.gif
===================================================================
(Binary files differ)
Index: XoopsModules/oledrion/branches/voltan/oledrion/images/rate/delete.gif
===================================================================
--- XoopsModules/oledrion/branches/voltan/oledrion/images/rate/delete.gif 2013-02-18 09:15:51 UTC (rev 11057)
+++ XoopsModules/oledrion/branches/voltan/oledrion/images/rate/delete.gif 2013-02-18 11:39:46 UTC (rev 11058)
Property changes on: XoopsModules/oledrion/branches/voltan/oledrion/images/rate/delete.gif
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+image/gif
\ No newline at end of property
Added: XoopsModules/oledrion/branches/voltan/oledrion/images/rate/index.html
===================================================================
--- XoopsModules/oledrion/branches/voltan/oledrion/images/rate/index.html (rev 0)
+++ XoopsModules/oledrion/branches/voltan/oledrion/images/rate/index.html 2013-02-18 11:39:46 UTC (rev 11058)
@@ -0,0 +1 @@
+<script>history.go(-1);</script>
\ No newline at end of file
Property changes on: XoopsModules/oledrion/branches/voltan/oledrion/images/rate/index.html
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: XoopsModules/oledrion/branches/voltan/oledrion/images/rate/star.gif
===================================================================
(Binary files differ)
Index: XoopsModules/oledrion/branches/voltan/oledrion/images/rate/star.gif
===================================================================
--- XoopsModules/oledrion/branches/voltan/oledrion/images/rate/star.gif 2013-02-18 09:15:51 UTC (rev 11057)
+++ XoopsModules/oledrion/branches/voltan/oledrion/images/rate/star.gif 2013-02-18 11:39:46 UTC (rev 11058)
Property changes on: XoopsModules/oledrion/branches/voltan/oledrion/images/rate/star.gif
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+image/gif
\ No newline at end of property
Modified: XoopsModules/oledrion/branches/voltan/oledrion/language/english/modinfo.php
===================================================================
--- XoopsModules/oledrion/branches/voltan/oledrion/language/english/modinfo.php 2013-02-18 09:15:51 UTC (rev 11057)
+++ XoopsModules/oledrion/branches/voltan/oledrion/language/english/modinfo.php 2013-02-18 11:39:46 UTC (rev 11058)
@@ -212,7 +212,8 @@
define('_MI_OLEDRION_PRODUCT_PROPERTY2',"Product Property 2");
define('_MI_OLEDRION_PRODUCT_PROPERTY3',"Product Property 3");
define('_MI_OLEDRION_PRODUCT_PROPERTY4',"Product Property 4");
-define('_MI_OLEDRION_PRODUCT_PROPERTY5',"Product Property 5");
+define('_MI_OLEDRION_PRODUCT_PROPERTY5',"Product Property 5");
+define('_MI_OLEDRION_PRODUCT_PROPERTY_TITLE',"Title");
define('_MI_OLEDRION_GATEWAY',"Gateway used by the module");
Modified: XoopsModules/oledrion/branches/voltan/oledrion/product.php
===================================================================
--- XoopsModules/oledrion/branches/voltan/oledrion/product.php 2013-02-18 09:15:51 UTC (rev 11057)
+++ XoopsModules/oledrion/branches/voltan/oledrion/product.php 2013-02-18 11:39:46 UTC (rev 11058)
@@ -83,7 +83,7 @@
}
}
if(!OLEDRION_MY_THEME_USES_JQUERY) {
- oledrion_utils::callJavascriptFile('jquery/jquery.js');
+ $xoTheme->addScript("browse.php?Frameworks/jquery/jquery.js");
}
oledrion_utils::callJavascriptFile('noconflict.js');
$xoTheme->addStylesheet(OLEDRION_JS_URL.'css/prettyPhoto.css');
@@ -428,7 +428,11 @@
$canRate = !$h_oledrion_votedata->hasUserAlreadyVoted($currentUser, $product->getVar('product_id'));
} else {
$canRate = !$h_oledrion_votedata->hasAnonymousAlreadyVoted('', $product->getVar('product_id'));
- }
+ }
+ $xoTheme->addScript("browse.php?Frameworks/jquery/jquery.js");
+ oledrion_utils::callJavascriptFile('rateit.js');
+ oledrion_utils::setCSS(OLEDRION_URL.'css/rateit.css');
+
$xoopsTpl->assign('userCanRate', $canRate);
}
Modified: XoopsModules/oledrion/branches/voltan/oledrion/rate-product.php
===================================================================
--- XoopsModules/oledrion/branches/voltan/oledrion/rate-product.php 2013-02-18 09:15:51 UTC (rev 11057)
+++ XoopsModules/oledrion/branches/voltan/oledrion/rate-product.php 2013-02-18 11:39:46 UTC (rev 11058)
@@ -24,7 +24,8 @@
* Notation d'un produit
*/
require 'header.php';
-
+oledrion_utils::redirect(_OLEDRION_NORATE, 'index.php', 5);
+/*
$product_id = 0;
// Les tests **************************************************************************************
// Peut on voter ?
@@ -119,7 +120,7 @@
oledrion_utils::setCSS();
oledrion_utils::setLocalCSS($xoopsConfig['language']);
}
+*/
-
require_once XOOPS_ROOT_PATH.'/footer.php';
?>
\ No newline at end of file
Modified: XoopsModules/oledrion/branches/voltan/oledrion/templates/oledrion_product.html
===================================================================
--- XoopsModules/oledrion/branches/voltan/oledrion/templates/oledrion_product.html 2013-02-18 09:15:51 UTC (rev 11057)
+++ XoopsModules/oledrion/branches/voltan/oledrion/templates/oledrion_product.html 2013-02-18 11:39:46 UTC (rev 11058)
@@ -399,7 +399,30 @@
<div class="oledrion_rating">
<{$smarty.const._OLEDRION_RATINGC}> <{$product.product_rating_formated}> (<{$product.product_votes_count}>)
<{if $userCanRate}>
- - <a href="<{$smarty.const.OLEDRION_URL}>rate-product.php?product_id=<{$product.product_id}>" title="<{$smarty.const._OLEDRION_RATETHISPRODUCT}>"><{$smarty.const._OLEDRION_RATETHISPRODUCT}></a>
+ <div class="vote">
+ <input value="<{$product.product_rating_formated}>" step="1" id="backing<{$product.product_id}>" type="range">
+ <div class="rateit" data-url="<{$smarty.const.OLEDRION_URL}>ajax.php?op=rate" data-product="<{$product.product_id}>" data-rateit-backingfld="#backing<{$product.product_id}>" data-rateit-resetable="false" data-rateit-ispreset="true" data-rateit-min="0" data-rateit-max="10"></div>
+ </div>
+ <script type="text/javascript">
+ $('.vote .rateit').bind('rated reset', function (e) {
+ var ri = $(this);
+ var rating = ri.rateit('vote');
+ var product_id = ri.data('product');
+ var url = ri.data('url');
+ ri.rateit('readonly', true);
+ $.ajax({
+ url: url,
+ data: { product_id: product_id, rating: rating},
+ type: 'POST',
+ dataType: "json",
+ success:function (result) {
+ if (!result.status == 1) {
+ alert(result.message);
+ }
+ }
+ });
+ });
+ </script>
<{/if}>
</div>
<{/if}>
|