From ed28dc0808df65c2d39378849d4de3334aea526e Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Sun, 27 May 2012 10:42:16 +0000 Subject: [PATCH] Rating system re-work and cleanup. --- e107_admin/cpage.php | 8 +- e107_admin/header.php | 33 +- .../core/{admin.css => admin.jquery.css} | 0 e107_files/jslib/core/admin.jquery.js | 2 +- e107_files/jslib/rate/img/cancel-off.png | Bin 0 -> 699 bytes e107_files/jslib/rate/img/cancel-on.png | Bin 0 -> 715 bytes e107_files/jslib/rate/img/star-half.png | Bin 0 -> 667 bytes e107_files/jslib/rate/img/star-off.png | Bin 0 -> 685 bytes e107_files/jslib/rate/img/star-on.png | Bin 0 -> 631 bytes e107_files/jslib/rate/index.html | 916 ++++++++++++++++++ e107_files/jslib/rate/js/jquery.raty.js | 462 +++++++++ e107_handlers/e107_class.php | 15 +- e107_handlers/form_handler.php | 20 +- e107_handlers/rate_class.php | 173 +++- e107_languages/English/lan_rate.php | 20 +- e107_plugins/download/download_shortcodes.php | 14 +- e107_themes/jayya/admin_theme.php | 22 +- e107_themes/jayya/style.css | 8 +- e107_themes/templates/header_default.php | 14 +- page.php | 79 +- rate.php | 65 +- 21 files changed, 1744 insertions(+), 107 deletions(-) rename e107_files/jslib/core/{admin.css => admin.jquery.css} (100%) create mode 100644 e107_files/jslib/rate/img/cancel-off.png create mode 100644 e107_files/jslib/rate/img/cancel-on.png create mode 100644 e107_files/jslib/rate/img/star-half.png create mode 100644 e107_files/jslib/rate/img/star-off.png create mode 100644 e107_files/jslib/rate/img/star-on.png create mode 100644 e107_files/jslib/rate/index.html create mode 100644 e107_files/jslib/rate/js/jquery.raty.js diff --git a/e107_admin/cpage.php b/e107_admin/cpage.php index b1ea70701..93527d6d4 100644 --- a/e107_admin/cpage.php +++ b/e107_admin/cpage.php @@ -731,8 +731,8 @@ class page_admin_ui extends e_admin_ui } }*/ - - admin_update($update, 'update', LAN_UPDATED, false, false); // Display result of update + $mes = e107::getMessage(); + $mes->autoMessage($update, 'update', LAN_UPDATED, false, false); // Display result of update } else { // New page/menu @@ -755,7 +755,7 @@ class page_admin_ui extends e_admin_ui 'page_theme' => $menuname, 'page_template' => varset($_POST['page_template'],'') ); - $pid = admin_update($sql->db_Insert('page', $info), 'insert', $addMsg, LAN_CREATED_FAILED, false); + $pid = e107::getMessage()->autoMessage($sql->db_Insert('page', $info), 'insert', $addMsg, LAN_CREATED_FAILED, false); $admin_log->log_event('CPAGE_01',$menuname.'[!br!]'.$page_title.'[!br!]'.$pauthor,E_LOG_INFORMATIVE,''); if($type) @@ -768,7 +768,7 @@ class page_admin_ui extends e_admin_ui 'menu_pages' => '', 'menu_path' => $pid, ); - admin_update($sql->db_Insert('menus', $info), 'insert', CUSLAN_52, LAN_CREATED_FAILED, false); + e107::getMessage()->autoMessage($sql->db_Insert('menus', $info), 'insert', CUSLAN_52, LAN_CREATED_FAILED, false); } /*if(vartrue($_POST['page_link'])) diff --git a/e107_admin/header.php b/e107_admin/header.php index 3d8b6b19c..0768e3d82 100644 --- a/e107_admin/header.php +++ b/e107_admin/header.php @@ -25,6 +25,33 @@ define("USER_AREA", FALSE); e107::getDb()->db_Mark_Time('(Header Top)'); + +e107::js('core', 'colorbox/jquery.colorbox-min.js', 'jquery', 2); +e107::css('core', 'colorbox/colorbox.css', 'jquery'); + +e107::js('core', 'jquery.elastic.js', 'jquery', 2); +e107::js('core', 'jquery-ui-timepicker-addon.js', 'jquery', 2); + +e107::js('core', 'plupload/plupload.full.js', 'jquery', 2); +e107::css('core', 'plupload/jquery.plupload.queue/css/jquery.plupload.queue.css', 'jquery'); +e107::js('core', 'plupload/jquery.plupload.queue/jquery.plupload.queue.js', 'jquery', 2); + +e107::css('core', 'chosen/chosen.css', 'jquery'); +e107::js('core', 'chosen/chosen.jquery.min.js', 'jquery', 2); + +e107::css('core', 'password/style.css', 'jquery'); +e107::js('core', 'password/jquery.pwdMeter.js', 'jquery', 2); +// +e107::js("core", "plupload/customUpload.js","jquery",3); + +e107::js("core", "core/mediaManager.js","jquery",3); + + +e107::css('core', 'core/admin.jquery.css', 'jquery'); +e107::css('core', 'core/all.jquery.css', 'jquery'); +e107::js("core", "core/admin.jquery.js","jquery",4); // Load all default functions. +e107::js("core", "core/all.jquery.js","jquery",4); // Load all default functions. + // // *** Code sequence for headers *** // IMPORTANT: These items are in a carefully constructed order. DO NOT REARRANGE @@ -755,7 +782,7 @@ if ($e107_popup != 1) } /** - * Automate DB system messages + * Automate DB system messages DEPRECATED * NOTE: default value of $output parameter will be changed to false (no output by default) in the future * * @param integer|bool $update return result of db::db_Query @@ -766,6 +793,8 @@ if ($e107_popup != 1) * @return integer|bool db::db_Query result */ // TODO - This function often needs to be available BEFORE header.php is loaded. + + // It has been copied to message_handler.php as autoMessage(); function admin_update($update, $type = 'update', $success = false, $failed = false, $output = true) @@ -810,6 +839,8 @@ if ($e107_popup != 1) $text = ($failed ? $failed : $msg." - ".LAN_TRY_AGAIN)."
".LAN_ERROR." ".mysql_errno().": ".mysql_error(); $emessage->add($text, E_MESSAGE_ERROR); } + + $emessage->addInfo("Using deprecated admin_update() which has been replaced by \$mes->autoMessage();"); if ($output) echo $emessage->render(); return $update; diff --git a/e107_files/jslib/core/admin.css b/e107_files/jslib/core/admin.jquery.css similarity index 100% rename from e107_files/jslib/core/admin.css rename to e107_files/jslib/core/admin.jquery.css diff --git a/e107_files/jslib/core/admin.jquery.js b/e107_files/jslib/core/admin.jquery.js index 3087df73b..d7ddeda4c 100644 --- a/e107_files/jslib/core/admin.jquery.js +++ b/e107_files/jslib/core/admin.jquery.js @@ -1,5 +1,5 @@ $(document).ready(function() - { +{ $(".e-hideme").hide(); $(".e-expandit").show(); diff --git a/e107_files/jslib/rate/img/cancel-off.png b/e107_files/jslib/rate/img/cancel-off.png new file mode 100644 index 0000000000000000000000000000000000000000..a3031f055375716b848c29191cabf6253b936379 GIT binary patch literal 699 zcmV;s0!00ZP)LlQBzMVHAd+8!Cx7n4ko2BpKR*l8~R!U*RTd z-KC3@i{RwscE?Or>7D!)-4qlQMGUEfL=(Km2!<>7e((2nscB0J9em*|hwptkhx2@% zbB?#@9f0R~!$uf}AB-`J&bbvyGuB!pb*#0!lD@62t+ig?I_L15bHjiz3>S+9fx3`mlMX0u7HR>SkWlB6Yo%&%RRecz|k z>G1UQM7!Ol*X!~4`1n@=JUl#5tyYn=JiLOW*=#mTx7)=S!|LklKTpX-R`T3bfqw!C(=Xn$g1v;G$#+deS0%Ocx zv)QCjD3GQpV`F0@W@{|~#bS};<71q2dw;I5Z>_z(xVT_`ejb2KCc`T%)><-|4E1`Q z!^1=3IKGv%5BvscXJ=4|#1P83Dl-```crC2O7H8sW2(GjgyYar=!5CjJ! zC~t3XFGvaizgDY}&*uS%qKK1|6XH0&lk_DBf>D%TwY9bNLDHfzX2m%-BMD01y4qo3(5`U!bUg@nP|I3oZ6002ovPDHLkV1f)gL$Ck< literal 0 HcmV?d00001 diff --git a/e107_files/jslib/rate/img/cancel-on.png b/e107_files/jslib/rate/img/cancel-on.png new file mode 100644 index 0000000000000000000000000000000000000000..08f249365afd29594b51210c6e21ba253897505d GIT binary patch literal 715 zcmV;+0yO=JP)C4}Mrzlg<+1Y8PEBfUp0jJpx4B>@E+cy3`^(Gw`Mf+2&yxZm<$to~Vpgvg&QKNR z_f#1(r6svZt%iF?s+n<8X?B&!h3g9Dbb8_=MX}!;HiQSAh`bp^WMl~Z-44teO7W_Y zV4thSL{h;rJY7!l3%5J4H1!tIzB`Dv+YxO(haWeausGZYkI8^hWj6mzo=L0{%;yxzh{5!Htr?51 zvG|W62MzC8BZ76hRpCyO2zOn<%e)K>NHge!-~)Ap33OdWw6hsLYbCxGNt0%wk_2z7 zfyYvXheSG)5HRK1VB~%mq7Dmurw#bi@hEcOr3&G1ZiF*$M=&9nB#VNf&Q^r$4G5kp zTURh&s)E0%5&hyVD}sp<72~zmAY`Y(9aqO6CXF%=zFHGzO-A&I(pE}v70YQxCPJ{Y z4L+?5-crdLn3ZRPEs!A4ehEY3ZRpL~w9>@aMN+{F4dI@v&>(QDHQum!mG~E^$OS8l z!7?%Uwib*ROP67Hw`ika)gX-(8Ia`-u_IEhxG7U<13kSsMW+$lbb2dUMm5p6pa}cjgA+U$^mJ^AjD?&bdi)8~y+Q002ovPDHLkV1g8IMc@Dc literal 0 HcmV?d00001 diff --git a/e107_files/jslib/rate/img/star-half.png b/e107_files/jslib/rate/img/star-half.png new file mode 100644 index 0000000000000000000000000000000000000000..3c19e90a8a755e004424db205c8433f0f63048b4 GIT binary patch literal 667 zcmV;M0%ZM(P)5kxfVxVHn4M^Ulocu4}uCxq(JO)+Y9GD5Jat zbqNy5lR|3Ugd)g`R}H!Z-82#+xHAej^Uvb`)a1J$lTNk&_XNAE zBfTQ9v_v8Sa5IxmRs3@SYh=d-l+~gM@B>A4P0dc=P9~jd$fQ$sTUl-3B9(2Y;#Z9F ziv79~Bz4_Q3b9eCYwPF+d^xg&l#+bj;nT_rzOS%t8z2j`7`B7!=X2+jXB|TV=B8-| z5I_(F*tU&nN^1AkB4vn~=}AV%Mjv-|U3#ej40jVdS&P?6I*kPtxhy74l2*jJNmZ458vW9PWLT-hGu|=LysO@uBuA(2q79M zrYCoMu8-X7>n;ia!^1;Yo0`tX3%(WvK`H*P`T^?|->M&U?OXr=002ovPDHLkV1gTF BCtCmj literal 0 HcmV?d00001 diff --git a/e107_files/jslib/rate/img/star-off.png b/e107_files/jslib/rate/img/star-off.png new file mode 100644 index 0000000000000000000000000000000000000000..956fa7c637cddb4db6a091556cc63a0f6a186264 GIT binary patch literal 685 zcmV;e0#f~nP)R5*>Dl0QrnVHn1Ly)Enp;##exZh7()Uk zR1!C3adKe*!lVgta&se2n3x!5BLe|s!Nt*~X-#y7B3eoUik5~%+lD(Tz0ZL^0YjVU zv%Pu#yl=keg9gZ?Q_Q(|Z0g_5!WIoz~V%6X6SCq;x5j%6#A6o&%l(m4W2o+DSkrok{@j zfS9fu_%t7u6-EyR*{?cCDbX|y$Ei}>*}-*d*tQMu1GuLQBnNZ({Kj-B6r%H5Cv9zQ z1OftQ-v&TRiEZ1cs+abw?R0hbV45b`)$HqmfpE80>NxE=6Ci}>F?0hV0tABwPH{}X=zm$k-d TM0>cp00000NkvXXu0mjfLk}+u0K@`S+@BV*_sWrqlwFo8}(kQkaqzD;A z=u{lE-2?}_II1YR)S)U)E*26HCl}q?MW=Ld6)l=U=ui@ZMFoe7jcsaT?tgaXnG9{0ZQ-FLi$F8Gk$pICVsN_6A+-I}LP#xf!zP`KEQ*A|86(eYX?Vrxqg`*m?> zyc17#YQ&Emm{YDS9%UIE2;KXq0p(YRuVBj4qCoke?8ek~ZfK?*SF$toUz&(q^LzVF zc)m+{o=z$CtKX9fo)4nH88Gx=Z0LtIJw+2pF{o}Aa&I@D_|-bv)_zWzpnQfNU|%D| z2ONlib6`yct1JCRlQx>P4J2Q!lkr}!P)`rD5RWn;!ch^BrauSPHXPUh?BDz@Ut;od zmQ4>}ahc!a2^JEAoD+yQ#m?=B%^vZad=f}S8X&Tqm1m)@;e`m!IcA(C>>M0F#2E0tt%Gn#jhcX3%^aLBZN-xDTU?LbBKJ1?Kz|Loh!06cE>#5u?R;17H*+`wdH ROO^lt002ovPDHLkV1mP{6ITEL literal 0 HcmV?d00001 diff --git a/e107_files/jslib/rate/index.html b/e107_files/jslib/rate/index.html new file mode 100644 index 000000000..22e56b22a --- /dev/null +++ b/e107_files/jslib/rate/index.html @@ -0,0 +1,916 @@ + + + + + + + + + + + jQuery Raty - A Star Rating Plugin + + + + + + + + + + + + +
+
Default options:
+ +
+ +
+ $('#star').raty();

+ + <div id="star"></div> +
+ +
Started with a score and read only value:
+
+ +
+ $('#star').raty({
+   readOnly : true,
+   score    : 2
+ });

+ + <div id="star"></div> +
+ +
Starting with a callback:
+
+ +
+ $('#score').raty({
+   score: function() {
+     return $(this).attr('data-rating');
+   }
+ });

+ + <div id="star" data-rating="3"></div> +
+ +
A hint for no rated elements when it's read-only:
+
+ +
+ $('#star').raty({
+   readOnly   : true,
+   noRatedMsg : 'anyone rated this product yet!'
+ });

+ + <div id="star"></div> +
+ +
Custom score name and a number of stars:
+
+ +
+ $('#star').raty({
+   scoreName : 'entity.score',
+   number    : 10
+ });

+ + <div id="star"></div> +
+ +
Using click function:
+
+ +
+ $('#star').raty({
+   click: function(score, evt) {
+     alert('ID: ' + $(this).attr('id') + '\nscore: ' + score + '\nevent: ' + evt);
+   }
+ });

+ + <div id="star"></div> +

+ + + - The argument score is the selected value;
+ - The argument evt is the click event;
+ - You can mension the star element (DOM) itself using 'this'.
+
+ +
Default cancel button:
+
+ +
+ $('#star').raty({
+   cancel: true
+ });

+ + <div id="star"></div> +

+ + + - The score value for the click on cancel button is null.
+
+ +
Custom cancel button:
+
+ +
+ $('#star').raty({
+   cancel      : true,
+   cancelHint  : 'remove my rating!',
+   cancelPlace : 'right',
+   click       : function(score, evt) {
+     alert('score: ' + score);
+   }
+ });

+ + <div id="star"></div> +
+ +
Half star voting:
+
+ +
+ $('#star').raty({
+   half  : true,
+   score : 3.3
+ });

+ + <div id="star"></div> +

+ + + - You can disable the 'halfShow' option to just vote with half star but not show it.
+ - If 'halfShow' is disabled, then score >= x.6 will be rounded up visually.
+ - The interval can be:
+ -- Rounded down: [x.00 .. x.25]
+ -- Half star:    [x.26 .. x.75]
+ -- Rounded up:   [x.76 .. x.99] +
+ +
Custom round option:
+
+ +
+ $('#star').raty({
+   score : 1.26,
+   round : { down: .25, full: .6, up: .76 }
+ });

+ + <div id="star"></div> +

+ + + - This example use the default round values;
+ - down: with halfShow enabled, score <= x.25 will be rounded down; (inclusive)
+ - up: with halfShow enabled, score >= x.76 will be rounded up; (inclusive)
+ - down-up: with halfShow enabled, score > x.25 and score < .76 will be half star; (inclusive)
+ - full: with halfShow disabled, score >= x.6 will be rounded up; (inclusive)
+
+ +
Custom hint and icons:
+
+ +
+ $('#star').raty({
+   hints   : ['a', '', null, 'd', '5'],
+   starOn  : 'medal-on.png',
+   starOff : 'medal-off.png'
+ });

+ + <div id="star"></div> +

+ + + - To display the number of the star, set null. + + +
Range of custom icons:
+
+ +
+ $('#star').raty({
+   iconRange: [
+     { range: 2, on: 'face-a.png', off: 'face-a-off.png' },
+     { range: 3, on: 'face-b.png', off: 'face-b-off.png' },
+     { range: 4, on: 'face-c.png', off: 'face-c-off.png' },
+     { range: 5, on: 'face-d.png', off: 'face-d-off.png' }
+   ]
+ });

+ + <div id="star"></div> +

+ + + - It's a array of objects where each one represents a custom icon;
+ - The value range is until wich position the icon will be displayed;
+ - The value on is the active icon;
+ - The value off is the inactive icon;
+ - The sequence of the range interval should be in a ascending order;
+ - If the value on or off is omitted then the attribute starOn or starOff will be used. +
+ +
Bigger icon:
+
+ +
+ $('#star').raty({
+   cancel    : true,
+   cancelOff : 'cancel-off-big.png',
+   cancelOn  : 'cancel-on-big.png',
+   half      : true,
+   size      : 24,
+   starHalf  : 'star-half-big.png',
+   starOff   : 'star-off-big.png',
+   starOn    : 'star-on-big.png'
+ });

+ + <div id="star"></div> +

+ + + - You can specify your own width as following: width: 120. + + +
Group of elements:
+
+
+
+ +
+ $('.star').raty();

+ + <div class="star"></div>
+ <div class="star"></div>
+ <div class="star"></div> +

+ + + - The ID is optional and must be unique;
+ - If you don't pass a ID for the element, then it will be created. +
+ +
Displaying hint in a target element:
+ +
+

+ +
+ $('#star').raty({
+   cancel     : true,
+   cancelHint : 'none',
+   target     : '#hint'
+ });

+ + <div id="star"></div>
+ <div id="target"></div> +
+ +
Displaying and keeping the score in a target element:
+ +
+ + + +
+ $('#star').raty({
+   cancel     : true,
+   target     : '#score',
+   targetKeep : true,
+   targetType : 'number'
+ });

+ + <select id="target">
+   <option value="">0</option>
+   <option value="1">1</option>
+   <option value="2">2</option>
+   <option value="3">3</option>
+   <option value="4">4</option>
+   <option value="5">5</option>
+ </select>
+

+ + + - You can to choose the target types 'hint' or 'number'. + + +
Setting default value to the target on mouseout:
+ +
+

+ +
+ $('#star').raty({
+   target     : '#hint',
+   targetText : '--'
+ });

+ + <div id="star"></div>
+ <div id="target"></div> +
+ +
Displaying hint with format template:
+ +
+

+ +
+ $('#star').raty({
+   cancel       : true,
+   cancelHint   : 'Sure?',
+   target       : '#hint',
+   targetFormat : 'your score: {score}',
+   targetText   : 'none',
+   targetKeep   : true
+ });

+ + <div id="star"></div>
+ <div id="target"></div> +
+ +
Using mouseover callback:
+ +
+

+ +
+ $('#star').raty({
+   cancel    : true,
+   mouseover : function(score, evt) {
+     var target = $('#mouseover-target');

+ +     if (score === null) {
+       target.html('Boring!');
+     } else if (score === undefined) {
+       target.empty();
+     } else {
+       target.html('score: ' + score);
+     }
+   }
+ });

+ + <div id="star"></div>
+ <div id="target"></div> +
+ + + - The options target, targetFormat, targetKeep, targetText and targetType are abstractions of this callback. + + +
Half star voting precision:
+ +
+

+ +
+ $('#star').raty({
+   half       : true,
+   precision  : true,
+   size       : 24,
+   starHalf   : 'star-half-big.png',
+   starOff    : 'star-off-big.png',
+   starOn     : 'star-on-big.png'
+   target     : '#precision-target'
+   targetType : 'number'
+ });

+ + <div id="star"></div>
+ <div id="target"></div> +
+ +
Without space between stars:
+ +
+ +
+ $('#star').raty({
+   space: false
+ });

+ + <div id="star"></div>
+
+ +
Single icon:
+ +
+ +
+ $('#star').raty({
+   single: true
+ });

+ + <div id="star"></div>
+
+ +
Directed actions with public functions:
+ + love: +
+ + happy: +

+ + your last rate: +
+ +
+ $('.star').raty({
+   half  : true,
+   click : function(score, evt) {
+     $(this).raty('cancel');
+     $('#result').raty('score', score);
+   }
+ });

+ + <div class="star"></div>
+ <div class="star"></div>

+ <div id="result"></div> +

+ + + - All functions have a optional second parameter to specify which container will be executed;
+ - You can pass a ID or a class to be the target of the action;
+ - If the ID or class are not specified, then the last element Raty will be takes. +
+ +
Functions Demo:
+ +
+

+ +
+ Score 1 | + Score 2 | + Score 3 | + Score 4 | + Score 5 +
+ +
+ Click 1 | + Click 2 | + Click 3 | + Click 4 | + Click 5 +
+ + + + + +
+ Reload | + Score +
+ +
+ settings: + set +
+ +
Changing the settings globally:
+ +
+ $.fn.raty.defaults.starOn = 'star-on.gif';
+ $.fn.raty.defaults.starOff = 'star-off.gif'; +
+ + + - You can change any option mention the scope $.fn.raty.defaults. + option_name;
+ - This setup must be called before you bind the Raty, of course. +
+ +
Default options:
+ +
cancel: false
+
If will be showed a button to cancel the rating.
+ +
+ +
cancelHint: 'cancel this rating!'
+
The hint information.
+ +
+ +
cancelHint: 'cancel this rating!'
+
The hint information.
+ +
+ +
cancelOff: 'cancel-off.png'
+
Name of the cancel image off.
+ +
+ +
cancelOn: 'cancel-on.png'
+
Name of the cancel image on.
+ +
+ +
cancelPlace: 'left'
+
Position of the cancel button.
+ +
+ +
click: undefined
+
Function that returns the selected value.
+ +
+ +
half: false
+
Enables half star selection.
+ +
+ +
halfShow: true
+
Enables half star display.
+ +
+ +
hints: ['bad', 'poor', 'regular', 'good', 'gorgeous']
+
List of names that will be used as a hint on each star.
+ +
+ +
iconRange: undefined
+
List of object that represent each icon with position and names.
+ +
+ +
noRatedMsg: 'not rated yet'
+
A hint for no rated elements when it's read-only.
+ +
+ +
number: 5
+
Number of stars that will be presented.
+ +
+ +
path: 'img/'
+
A range of custom icons that you can set.
+ +
+ +
precision: false
+
Enables the selection of a precision score.
+ +
+ +
readOnly: false
+
If the stars will be read-only.
+ +
+ +
round: { down: .25, full: .6, up: .76 }
+
Configuration to set the round rules.
+ +
+ +
score: undefined
+
Number of stars to be selected.
+ +
+ +
scoreName: 'score'
+
Name of the hidden field that holds the score value.
+ +
+ +
single: false
+
Enables the single star selection.
+ +
+ +
space: true
+
Puts space between the stars.
+ +
+ +
size: 16
+
The icons size.
+ +
+ +
starHalf: 'star-half.png'
+
The name of the half star image.
+ +
+ +
starOff: 'star-off.png'
+
Name of the star image off.
+ +
+ +
starOn: 'star-on.png'
+
Name of the star image on.
+ +
+ +
target: undefined
+
Element selector where the rating will be displayed.
+ +
+ +
targetFormat: '{score}'
+
Template to interpolate the score with some thing.
+ +
+ +
targetKeep: false
+
If the last choose value will be keeped on mouseout.
+ +
+ +
targetText: ''
+
Default value when there is no score or targetKeep is off.
+ +
+ +
targetType: 'hint'
+
What display on target element hint or number.
+ +
+ +
width : undefined
+
The container width of the stars.
+ +
Functions:
+ +
$('#star').raty('score');
+
Recovers the current score or undefined for no rated. Class returns an array of score
+ +
$('#star').raty('score', 3);
+
Set the score with 3 stars.
+ +
$('#star').raty('click', 2);
+
Click on the second star of the Raty with ID called 'raty'.
+ +
$('.star').raty('readOnly', true);
+
Adjusts all Raty with class called 'raty' for read-only.
+ +
$('#star').raty('cancel', true);
+
Cancel the rating. The second optional parameter enable thes click callback.
+ +
$('#star').raty('reload');
+
Reload the rating with the current configuration.
+ +
$('#star').raty('set', { number: 10 });
+
Reload the rating applying new configurations.
+
+ + + + + + diff --git a/e107_files/jslib/rate/js/jquery.raty.js b/e107_files/jslib/rate/js/jquery.raty.js new file mode 100644 index 000000000..65e1dffde --- /dev/null +++ b/e107_files/jslib/rate/js/jquery.raty.js @@ -0,0 +1,462 @@ +/*! + * jQuery Raty - A Star Rating Plugin - http://wbotelhos.com/raty + * ------------------------------------------------------------------- + * + * jQuery Raty is a plugin that generates a customizable star rating. + * + * Licensed under The MIT License + * + * @version 2.4.5 + * @since 2010.06.11 + * @author Washington Botelho + * @documentation wbotelhos.com/raty + * @twitter twitter.com/wbotelhos + * + * Usage: + * ------------------------------------------------------------------- + * $('#star').raty(); + * + *
+ * + */ + +;(function($) { + + var methods = { + init: function(settings) { + return this.each(function() { + var self = this, + $this = $(self).empty(); + + self.opt = $.extend(true, {}, $.fn.raty.defaults, settings); + + $this.data('settings', self.opt); + + self.opt.number = methods.between(self.opt.number, 0, 20); + + if (self.opt.path.substring(self.opt.path.length - 1, self.opt.path.length) != '/') { + self.opt.path += '/'; + } + + if (typeof self.opt.score == 'function') { + self.opt.score = self.opt.score.call(self); + } + + if (self.opt.score) { + self.opt.score = methods.between(self.opt.score, 0, self.opt.number); + } + + for (var i = 1; i <= self.opt.number; i++) { + $('', { + src : self.opt.path + ((!self.opt.score || self.opt.score < i) ? self.opt.starOff : self.opt.starOn), + alt : i, + class : self.opt.css, + title : (i <= self.opt.hints.length && self.opt.hints[i - 1] !== null) ? self.opt.hints[i - 1] : i + }).appendTo(self); + + if (self.opt.space) { + $this.append((i < self.opt.number) ? ' ' : ''); + } + } + + self.stars = $this.children('img:not(".raty-cancel")'); + self.score = $('', { type: 'hidden', name: self.opt.scoreName }).appendTo(self); + + if (self.opt.score && self.opt.score > 0) { + self.score.val(self.opt.score); + methods.roundStar.call(self, self.opt.score); + } + + if (self.opt.iconRange) { + methods.fill.call(self, self.opt.score); + } + + methods.setTarget.call(self, self.opt.score, self.opt.targetKeep); + + var space = self.opt.space ? 4 : 0, + width = self.opt.width || (self.opt.number * self.opt.size + self.opt.number * space); + + if (self.opt.cancel) { + self.cancel = $('', { src: self.opt.path + self.opt.cancelOff, alt: 'x', title: self.opt.cancelHint, 'class': 'raty-cancel' }); + + if (self.opt.cancelPlace == 'left') { + $this.prepend(' ').prepend(self.cancel); + } else { + $this.append(' ').append(self.cancel); + } + + width += (self.opt.size + space); + } + + if (self.opt.readOnly) { + methods.fixHint.call(self); + + if (self.cancel) { + self.cancel.hide(); + } + } else { + $this.css('cursor', 'pointer'); + + methods.bindAction.call(self); + } + + // $this.css('width', width); + }); + }, between: function(value, min, max) { + return Math.min(Math.max(parseFloat(value), min), max); + }, bindAction: function() { + var self = this, + $this = $(self); + + $this.mouseleave(function() { + var score = self.score.val() || undefined; + + methods.initialize.call(self, score); + methods.setTarget.call(self, score, self.opt.targetKeep); + + if (self.opt.mouseover) { + self.opt.mouseover.call(self, score); + } + }); + + var action = self.opt.half ? 'mousemove' : 'mouseover'; + + if (self.opt.cancel) { + self.cancel.mouseenter(function() { + $(this).attr('src', self.opt.path + self.opt.cancelOn); + + self.stars.attr('src', self.opt.path + self.opt.starOff); + + methods.setTarget.call(self, null, true); + + if (self.opt.mouseover) { + self.opt.mouseover.call(self, null); + } + }).mouseleave(function() { + $(this).attr('src', self.opt.path + self.opt.cancelOff); + + if (self.opt.mouseover) { + self.opt.mouseover.call(self, self.score.val() || null); + } + }).click(function(evt) { + self.score.removeAttr('value'); + + if (self.opt.click) { + self.opt.click.call(self, null, evt); + } + }); + } + + self.stars.bind(action, function(evt) { + var value = parseInt(this.alt, 10); + + if (self.opt.half) { + var position = parseFloat((evt.pageX - $(this).offset().left) / self.opt.size), + diff = (position > .5) ? 1 : .5; + + value = parseFloat(this.alt) - 1 + diff; + + methods.fill.call(self, value); + + if (self.opt.precision) { + value = value - diff + position; + } + + methods.showHalf.call(self, value); + } else { + methods.fill.call(self, value); + } + + $this.data('score', value); + + methods.setTarget.call(self, value, true); + + if (self.opt.mouseover) { + self.opt.mouseover.call(self, value, evt); + } + }).click(function(evt) { + self.score.val((self.opt.half || self.opt.precision) ? $this.data('score') : this.alt); + + if (self.opt.click) { + self.opt.click.call(self, self.score.val(), evt); + } + }); + }, cancel: function(isClick) { + return $(this).each(function() { + var self = this, + $this = $(self); + + if ($this.data('readonly') === true) { + return this; + } + + if (isClick) { + methods.click.call(self, null); + } else { + methods.score.call(self, null); + } + + self.score.removeAttr('value'); + }); + }, click: function(score) { + return $(this).each(function() { + if ($(this).data('readonly') === true) { + return this; + } + + methods.initialize.call(this, score); + + if (this.opt.click) { + this.opt.click.call(this, score); + } else { + methods.error.call(this, 'you must add the "click: function(score, evt) { }" callback.'); + } + + methods.setTarget.call(this, score, true); + }); + }, error: function(message) { + $(this).html(message); + + $.error(message); + }, fill: function(score) { + var self = this, + number = self.stars.length, + count = 0, + $star , + star , + icon ; + + for (var i = 1; i <= number; i++) { + $star = self.stars.eq(i - 1); + + if (self.opt.iconRange && self.opt.iconRange.length > count) { + star = self.opt.iconRange[count]; + + if (self.opt.single) { + icon = (i == score) ? (star.on || self.opt.starOn) : (star.off || self.opt.starOff); + } else { + icon = (i <= score) ? (star.on || self.opt.starOn) : (star.off || self.opt.starOff); + } + + if (i <= star.range) { + $star.attr('src', self.opt.path + icon); + } + + if (i == star.range) { + count++; + } + } else { + if (self.opt.single) { + icon = (i == score) ? self.opt.starOn : self.opt.starOff; + } else { + icon = (i <= score) ? self.opt.starOn : self.opt.starOff; + } + + $star.attr('src', self.opt.path + icon); + } + } + }, fixHint: function() { + var $this = $(this), + score = parseInt(this.score.val(), 10), + hint = this.opt.noRatedMsg; + + if (!isNaN(score) && score > 0) { + hint = (score <= this.opt.hints.length && this.opt.hints[score - 1] !== null) ? this.opt.hints[score - 1] : score; + } + + $this.data('readonly', true).css('cursor', 'default').attr('title', hint); + + this.score.attr('readonly', 'readonly'); + this.stars.attr('title', hint); + }, getScore: function() { + var score = [], + value ; + + $(this).each(function() { + value = this.score.val(); + + score.push(value ? parseFloat(value) : undefined); + }); + + return (score.length > 1) ? score : score[0]; + }, readOnly: function(isReadOnly) { + return this.each(function() { + var $this = $(this); + + if ($this.data('readonly') === isReadOnly) { + return this; + } + + if (this.cancel) { + if (isReadOnly) { + this.cancel.hide(); + } else { + this.cancel.show(); + } + } + + if (isReadOnly) { + $this.unbind(); + + $this.children('img').unbind(); + + methods.fixHint.call(this); + } else { + methods.bindAction.call(this); + methods.unfixHint.call(this); + } + + $this.data('readonly', isReadOnly); + }); + }, reload: function() { + return methods.set.call(this, {}); + }, roundStar: function(score) { + var diff = (score - Math.floor(score)).toFixed(2); + + if (diff > this.opt.round.down) { + var icon = this.opt.starOn; // Full up: [x.76 .. x.99] + + if (diff < this.opt.round.up && this.opt.halfShow) { // Half: [x.26 .. x.75] + icon = this.opt.starHalf; + } else if (diff < this.opt.round.full) { // Full down: [x.00 .. x.5] + icon = this.opt.starOff; + } + + this.stars.eq(Math.ceil(score) - 1).attr('src', this.opt.path + icon); + } // Full down: [x.00 .. x.25] + }, score: function() { + return arguments.length ? methods.setScore.apply(this, arguments) : methods.getScore.call(this); + }, set: function(settings) { + this.each(function() { + var $this = $(this), + actual = $this.data('settings'), + clone = $this.clone().removeAttr('style').insertBefore($this); + + $this.remove(); + + clone.raty($.extend(actual, settings)); + }); + + return $(this.selector); + }, setScore: function(score) { + return $(this).each(function() { + if ($(this).data('readonly') === true) { + return this; + } + + methods.initialize.call(this, score); + methods.setTarget.call(this, score, true); + }); + }, setTarget: function(value, isKeep) { + if (this.opt.target) { + var $target = $(this.opt.target); + + if ($target.length == 0) { + methods.error.call(this, 'target selector invalid or missing!'); + } + + var score = value; + + if (!isKeep || score === undefined) { + score = this.opt.targetText; + } else { + if (this.opt.targetType == 'hint') { + score = (score === null && this.opt.cancel) + ? this.opt.cancelHint + : this.opt.hints[Math.ceil(score - 1)]; + } else { + score = this.opt.precision + ? parseFloat(score).toFixed(1) + : parseInt(score, 10); + } + } + + if (this.opt.targetFormat.indexOf('{score}') < 0) { + methods.error.call(this, 'template "{score}" missing!'); + } + + if (value !== null) { + score = this.opt.targetFormat.toString().replace('{score}', score); + } + + if ($target.is(':input')) { + $target.val(score); + } else { + $target.html(score); + } + } + }, showHalf: function(score) { + var diff = (score - Math.floor(score)).toFixed(1); + + if (diff > 0 && diff < .6) { + this.stars.eq(Math.ceil(score) - 1).attr('src', this.opt.path + this.opt.starHalf); + } + }, initialize: function(score) { + score = !score ? 0 : methods.between(score, 0, this.opt.number); + + methods.fill.call(this, score); + + if (score > 0) { + if (this.opt.halfShow) { + methods.roundStar.call(this, score); + } + + this.score.val(score); + } + }, unfixHint: function() { + for (var i = 0; i < this.opt.number; i++) { + this.stars.eq(i).attr('title', (i < this.opt.hints.length && this.opt.hints[i] !== null) ? this.opt.hints[i] : i); + } + + $(this).data('readonly', false).css('cursor', 'pointer').removeAttr('title'); + + this.score.attr('readonly', 'readonly'); + } + }; + + $.fn.raty = function(method) { + if (methods[method]) { + return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); + } else if (typeof method === 'object' || !method) { + return methods.init.apply(this, arguments); + } else { + $.error('Method ' + method + ' does not exist!'); + } + }; + + $.fn.raty.defaults = { + cancel : false, + cancelHint : 'cancel this rating!', + cancelOff : 'cancel-off.png', + cancelOn : 'cancel-on.png', + cancelPlace : 'left', + click : undefined, + half : false, + halfShow : true, + hints : ['bad', 'poor', 'regular', 'good', 'gorgeous'], + iconRange : undefined, + mouseover : undefined, + noRatedMsg : 'not rated yet', + number : 5, + path : 'img/', + precision : false, + round : { down: .25, full: .6, up: .76 }, + readOnly : false, + score : undefined, + scoreName : 'score', + single : false, + size : 16, + space : true, + starHalf : 'star-half.png', + starOff : 'star-off.png', + starOn : 'star-on.png', + target : undefined, + targetFormat : '{score}', + targetKeep : false, + targetText : '', + targetType : 'hint', + width : undefined, + css : 'raty' + }; + +})(jQuery); diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 772514105..a95f78b72 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -195,13 +195,15 @@ class e107 'news' => '{e_HANDLER}news_class.php', 'notify' => '{e_HANDLER}notify_class.php', 'override' => '{e_HANDLER}override_class.php', + 'rater' => '{e_HANDLER}rate_class.php', 'redirection' => '{e_HANDLER}redirection_class.php', 'sitelinks' => '{e_HANDLER}sitelinks_class.php', 'themeHandler' => '{e_HANDLER}theme_handler.php', 'user_class' => '{e_HANDLER}userclass_class.php', 'userlogin' => '{e_HANDLER}login.php', 'xmlClass' => '{e_HANDLER}xml_class.php', - 'eIPHandler' => '{e_HANDLER}iphandler_class.php', + 'eIPHandler' => '{e_HANDLER}iphandler_class.php' + ); @@ -1023,6 +1025,17 @@ class e107 { return self::getSingleton('redirection', true); } + + + /** + * Retrieve rater singleton object + * + * @return rate + */ + public static function getRate() + { + return self::getSingleton('rater', true); + } /** * Retrieve sitelinks singleton object diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 36852800d..80007739c 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -549,6 +549,24 @@ class e_form return $ret; } + + + /** + * A 'Rating' element + * @var $text + */ + function rate($table,$id,$options=null) + { + $table = preg_replace('/\W/', '', $table); + $id = intval($id); + + return e107::getRate()->render($table, $id, $options); + } + + + + + function file($name, $options = array()) { @@ -566,7 +584,7 @@ class e_form { $options = $this->format_options('text', $name, $options); //never allow id in format name-value for text fields - return "get_attributes($options, $name)." />"; + return "get_attributes($options, $name)." />"; } // autoexpand done diff --git a/e107_handlers/rate_class.php b/e107_handlers/rate_class.php index 20fc3680b..efd468008 100644 --- a/e107_handlers/rate_class.php +++ b/e107_handlers/rate_class.php @@ -15,11 +15,91 @@ if (!defined('e107_INIT')) { exit; } include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_rate.php"); class rater { - function rateselect($text, $table, $id, $mode=FALSE) { + + + function render($table,$id,$options=array()) + { + list($votes,$score,$uvoted) = $this->getrating($table, $id); + parse_str($options,$options); + // + $label = varset($options['label'],RATELAN_5); + + $readonly = $this->checkrated($table, $id) ? '1' : '0'; + + $hintArray = array(RATELAN_POOR,RATELAN_FAIR,RATELAN_GOOD,RATELAN_VERYGOOD,RATELAN_EXCELLENT); + + $datahint = implode(",",$hintArray); + $path = e_FILE_ABS."jslib/rate/img/"; + + $score = ($score / 2); + // var_dump($readonly); + + if(!$votes) + { + $voteDiz = RATELAN_4; + } + else + { + $voteDiz = ($votes == 1) ? RATELAN_0 : RATELAN_1; + } + + if($readonly == '1') + { + $label = RATELAN_3; + } + + if(!USERID) + { + $label = RATELAN_6; // Please login to vote. + $readonly = '1'; + } + + $template = vartrue($options['template'], "STATUS|RATE|VOTES"); + + $TEMPLATE['STATUS'] = "
".$label."
"; + $TEMPLATE['RATE'] = "
"; + $TEMPLATE['VOTES'] = "
".$this->renderVotes($votes,$score)."
"; + + $tmp = explode("|",$template); + + $text = ""; + foreach($tmp as $k) + { + $text .= $TEMPLATE[$k]; + } + + return $text; + } + + + + + function renderVotes($votes,$score) // TODO use template? + { + if(!$votes) + { + $voteDiz = RATELAN_4; + } + else + { + $voteDiz = ($votes == 1) ? RATELAN_0 : RATELAN_1; + } + + return "{$score}/5 : {$votes} ".$voteDiz; + } + + + + // Legacy Rate Selector. + function rateselect($text, $table, $id, $mode=FALSE) + { //$mode : if mode is set, no urljump will be used (used in combined comments+rating system) $table = preg_replace('/\W/', '', $table); $id = intval($id); + + // return $this->render($text,$table,$id,$mode); + // $self = $_SERVER['PHP_SELF']; // if ($_SERVER['QUERY_STRING']) { @@ -71,7 +151,7 @@ class rater { } function checkrated($table, $id) { - + $table = preg_replace('/\W/', '', $table); $id = intval($id); @@ -97,6 +177,12 @@ class rater { $table = preg_replace('/\W/', '', $table); $id = intval($id); + + if($id == 0) + { + return "There is no item ID in the rating"; + } + $sep = chr(1); $sql = new db; if (!$sql->db_Select("rate", "*", "rate_table = '{$table}' AND rate_itemid = '{$id}' ")) { @@ -107,8 +193,8 @@ class rater { $rating = ""; $rateusers = explode(".", $rowgr['rate_voters']); for($i=0;$ienterrating($array,true); + + } + + + function enterrating($rateindex,$ajax = false) + { + + $sql = e107::getDb(); + $tp = e107::getParser(); $qs = explode("^", $rateindex); - if (!$qs[0] || USER == FALSE || $qs[3] > 10 || $qs[3] < 1) { - header("location:".e_BASE."index.php"); - exit; + if (!$qs[0] || USER == FALSE || $qs[3] > 10 || $qs[3] < 1) + { + + if($ajax == false) + { + header("location:".e_BASE."index.php"); + exit; + } + else + { + return "Error: ".print_a($qs,true); + } + } $table = $tp -> toDB($qs[0], true); @@ -153,18 +263,51 @@ class rater { //rating is now stored as userid-rating (to retain individual users rating) //$sep = "^"; - $sep = chr(1); + $sep = chr(1); // problematic - invisible in phpmyadmin. $voter = USERID.$sep.intval($qs[3]); - if ($sql->db_Select("rate", "*", "rate_table='{$table}' AND rate_itemid='{$itemid}' ")) { - $row = $sql->db_Fetch(); + if ($sql->db_Select("rate", "*", "rate_table='{$table}' AND rate_itemid='{$itemid}' ")) + { + + $row = $sql -> db_Fetch(); $rate_voters = $row['rate_voters'].".".$voter."."; - $sql->db_Update("rate", "rate_votes=rate_votes+1, rate_rating=rate_rating+'{$rate}', rate_voters='{$rate_voters}' WHERE rate_id='{$row['rate_id']}' "); - } else { - $sql->db_Insert("rate", " 0, '$table', '$itemid', '$rate', '1', '.".$voter.".' "); + $new_votes = $row['rate_votes'] + 1; + $new_rating = $row['rate_rating'] + $rate; + + $stat = ($new_rating /$new_votes)/2; + $statR = round($stat,1); + + if(strpos($row['rate_voters'], ".".$voter.".") == true || strpos($row['rate_voters'], ".".USERID.".") == true) + { + + return "You already voted|".$this->renderVotes($new_votes,$statR); // " newvotes = ".($statR). " =".$new_votes; + } + + + if($sql->db_Update("rate", "rate_votes= ".$new_votes.", rate_rating='{$new_rating}', rate_voters='{$rate_voters}' WHERE rate_id='{$row['rate_id']}' ")) + { + return RATELAN_3."|".$this->renderVotes($new_votes,$statR); // Thank you for your vote. + } + else + { + return "Error"; + } + } + elseif($sql->db_Insert("rate", " 0, '$table', '$itemid', '$rate', '1', '.".$voter.".' ")) + { + $stat = ($rate /1)/2; + $statR = round($stat,1); + return RATELAN_3."|".$this->renderVotes(1,$statR); ; // Thank you for your vote. + } + } + + + + + function composerating($table, $id, $enter=TRUE, $userid=FALSE, $nojump=FALSE){ //enter : boolean to show (rateselect box + textual info) or not //userid : used to calculate a users given rating diff --git a/e107_languages/English/lan_rate.php b/e107_languages/English/lan_rate.php index 95ce0b55e..de2bd63ac 100644 --- a/e107_languages/English/lan_rate.php +++ b/e107_languages/English/lan_rate.php @@ -10,11 +10,19 @@ +----------------------------------------------------------------------------+ */ -define("RATELAN_0", "vote"); -define("RATELAN_1", "votes"); -define("RATELAN_2", "how do you rate this item?"); -define("RATELAN_3", "thank you for your vote"); -define("RATELAN_4", "not rated"); -define("RATELAN_5", "Rate"); +define("RATELAN_0", "Vote"); +define("RATELAN_1", "Votes"); +define("RATELAN_2", "How do you rate this item?"); +define("RATELAN_3", "Thanks for voting!"); +define("RATELAN_4", "Not rated"); +define("RATELAN_5", "Rate this:"); +define("RATELAN_6", "Please login to rate this."); + +define("RATELAN_POOR","Poor"); +define("RATELAN_FAIR","Fair"); +define("RATELAN_GOOD","Good"); +define("RATELAN_VERYGOOD","Very Good"); +define("RATELAN_EXCELLENT","Excellent"); + ?> \ No newline at end of file diff --git a/e107_plugins/download/download_shortcodes.php b/e107_plugins/download/download_shortcodes.php index 348b2a4a1..426fb7ec9 100644 --- a/e107_plugins/download/download_shortcodes.php +++ b/e107_plugins/download/download_shortcodes.php @@ -189,7 +189,8 @@ class download_shortcodes } function sc_download_list_rating() { - global $dlrow; + global $dlrow,$tp; + return $tp->rate("download", $dlrow['download_id']); $rater = new rater(); $ratearray = $rater->getrating("download", $dlrow['download_id']); if (!$ratearray[0]) { @@ -307,7 +308,7 @@ class download_shortcodes { global $pref,$dl,$tp; if ($pref['agree_flag'] == 1) { - return "xxxtoJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION'))."');\" title='".LAN_dl_46."'>".$dl['download_name'].""; + return "toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION'))."');\" title='".LAN_dl_46."'>".$dl['download_name'].""; } else { return "".$dl['download_name'].""; } @@ -399,7 +400,7 @@ class download_shortcodes } else { - return $dnld_link." xxx*"; + return $dnld_link."*"; } } function sc_download_view_filesize() @@ -409,9 +410,14 @@ class download_shortcodes } function sc_download_view_rating() { + global $dlrow; + $frm = e107::getForm(); + $options = array('label'=>' ','template'=>'RATE|VOTES|STATUS'); + return $frm->rate("download", $dlrow['download_id'],$options); + require_once(e_HANDLER."rate_class.php"); $rater = new rater; - global $dlrow; + $text = " diff --git a/e107_themes/jayya/admin_theme.php b/e107_themes/jayya/admin_theme.php index ed1baeae9..54fcaa82b 100644 --- a/e107_themes/jayya/admin_theme.php +++ b/e107_themes/jayya/admin_theme.php @@ -103,28 +103,10 @@ e107::css('inline',"/******** Tabs JS */ // jQUERY scripts -e107::js('core', 'colorbox/jquery.colorbox-min.js', 'jquery', 2); -e107::css('core', 'colorbox/colorbox.css', 'jquery'); -e107::js('core', 'jquery.elastic.js', 'jquery', 2); -e107::js('core', 'jquery-ui-timepicker-addon.js', 'jquery', 2); -e107::js('core', 'plupload/plupload.full.js', 'jquery', 2); -e107::css('core', 'plupload/jquery.plupload.queue/css/jquery.plupload.queue.css', 'jquery'); -e107::js('core', 'plupload/jquery.plupload.queue/jquery.plupload.queue.js', 'jquery', 2); - -e107::css('core', 'chosen/chosen.css', 'jquery'); -e107::js('core', 'chosen/chosen.jquery.min.js', 'jquery', 2); - -e107::css('core', 'password/style.css', 'jquery'); -e107::js('core', 'password/jquery.pwdMeter.js', 'jquery', 2); -// -e107::js("core", "plupload/customUpload.js","jquery",3); - -e107::js("core", "core/mediaManager.js","jquery",3); - -e107::css('core', 'core/admin.css', 'jquery'); -e107::js('core', 'core/admin.jquery.js', 'jquery', 4); +//e107::css('core', 'core/admin.css', 'jquery'); +//e107::js('core', 'core/admin.jquery.js', 'jquery', 4); diff --git a/e107_themes/jayya/style.css b/e107_themes/jayya/style.css index 681ee7b10..ea9968ad3 100644 --- a/e107_themes/jayya/style.css +++ b/e107_themes/jayya/style.css @@ -827,10 +827,4 @@ h1.bbcode, h2.bbcode, h3.bbcode, h4.bbcode, h5.bbcode, h6.bbcode { }/* override div.bbcode { margin: 15px 0px; clear: both; } /* layout control via bbcodes */ -a.media-select-image { margin:5px; border:1px solid silver; width:120px; height:100px; } -a.media-select-image:hover { border:1px solid red; } -a.media-select-icon { text-align:center; vertical-align:middle; margin:1px; border:1px solid white; width:48px; height:48px;} -a.media-select-icon:hover { border:1px solid red; } -.media-select-container { padding:10px; } -.media-select-none { text-decoration:none; } -.media-select-active { border: 2px solid silver; } + diff --git a/e107_themes/templates/header_default.php b/e107_themes/templates/header_default.php index 6c0122f17..bc25d8048 100644 --- a/e107_themes/templates/header_default.php +++ b/e107_themes/templates/header_default.php @@ -23,6 +23,15 @@ define('ADMIN_AREA',FALSE); $e107 = e107::getInstance(); $e107->sql->db_Mark_Time('(Header Top)'); +e107::css('core', 'password/style.css', 'jquery'); +e107::js('core', 'password/jquery.pwdMeter.js', 'jquery', 2); +e107::js('core', 'colorbox/jquery.colorbox-min.js', 'jquery', 2); +e107::css('core', 'colorbox/colorbox.css', 'jquery'); + +e107::js('core', 'rate/js/jquery.raty.js', 'jquery', 2); +e107::css('core', 'core/all.jquery.css', 'jquery'); +e107::js("core", "core/all.jquery.js","jquery",5); // Load all default functions. + // // *** Code sequence for headers *** // IMPORTANT: These items are in a carefully constructed order. DO NOT REARRANGE @@ -125,6 +134,8 @@ else define("e_WYSIWYG",FALSE); } + + // // D: Register CSS // @@ -508,6 +519,7 @@ if (count($js_body_onload)) $body_onload = " onload=\"".implode(" ",$js_body_onl * Fire Event e107:loaded * FIXME - disable core JS */ +/* echo "\n"; - +*/ echo "\n"; diff --git a/page.php b/page.php index f404f33ba..e80cf519f 100644 --- a/page.php +++ b/page.php @@ -428,44 +428,53 @@ class pageClass // FIXME most probably will fail when cache enabled function pageRating($page_rating_flag) { - $rate_text = ''; // Notice removal + if($page_rating_flag) { - require_once(e_HANDLER."rate_class.php"); - $rater = new rater; - $rate_text = "
"; - - if ($ratearray = $rater->getrating("page", $this->pageID)) - { - if ($ratearray[2] == "") - { - $ratearray[2] = 0; - } - $rate_text .= "\n"; - $rate_text .= " ".$ratearray[1].".".$ratearray[2]." - ".$ratearray[0]." "; - $rate_text .= ($ratearray[0] == 1 ? "vote" : "votes"); - } - else - { - $rating .= LAN_PAGE_dl_13; - } - $rate_text .= ""; - - if (!$rater->checkrated("page", $this->pageID) && USER) - { - $rate_text .= $rater->rateselect("     ".LAN_PAGE_4."", "page", $this->pageID); - } - else if(!USER) - { - $rate_text .= " "; - } - else - { - $rate_text .= LAN_PAGE_5; - } - $rate_text .= "
"; + return "
".e107::getRate()->render("page", $this->pageID,array('label'=>LAN_PAGE_4))."
"; + /* + + $rate_text = ''; // Notice removal + + require_once(e_HANDLER."rate_class.php"); + $rater = new rater; + $rate_text = "
"; + + if ($ratearray = $rater->getrating("page", $this->pageID)) + { + if ($ratearray[2] == "") + { + $ratearray[2] = 0; + } + $rate_text .= "\n"; + $rate_text .= " ".$ratearray[1].".".$ratearray[2]." - ".$ratearray[0]." "; + $rate_text .= ($ratearray[0] == 1 ? "vote" : "votes"); + } + else + { + $rating .= LAN_PAGE_dl_13; + } + $rate_text .= ""; + + if (!$rater->checkrated("page", $this->pageID) && USER) + { + $rate_text .= $rater->rateselect("     ".LAN_PAGE_4."", "page", $this->pageID); + } + else if(!USER) + { + $rate_text .= " "; + } + else + { + $rate_text .= LAN_PAGE_5; + } + $rate_text .= "
"; + */ + } - return $rate_text; + + + // return $rate_text; } function pageComment($page_comment_flag) diff --git a/rate.php b/rate.php index 88b3f7a3c..2d3c9d4e2 100644 --- a/rate.php +++ b/rate.php @@ -22,19 +22,40 @@ require_once("class2.php"); include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE); -$qs = explode("^", e_QUERY); -if (!$qs[0] || USER == FALSE || $qs[3] > 10 || $qs[3] < 1 || strpos($qs[2], '://') !== false) -{ - header("location:".e_BASE."index.php"); +if(!e_AJAX_REQUEST) // Legacy method. +{ + $qs = explode("^", e_QUERY); + + if (!$qs[0] || USER == FALSE || $qs[3] > 10 || $qs[3] < 1 || strpos($qs[2], '://') !== false) + { + header("location:".e_BASE."index.php"); + exit; + } + + $table = $tp -> toDB($qs[0]); + $itemid = intval($qs[1]); + $returnurl = $tp -> toDB($qs[2]); + $rate = intval($qs[3]); + e107::getRate()->submitVote($table,$itemid,$rate); + header("location:".$returnurl); exit; } +else // Ajax Used. +{ + $table = $tp->toDB($_POST['table']); + $itemid = intval($_POST['id']); + $rate = intval($_POST['score']) * 2; + echo e107::getRate()->submitVote($table,$itemid,$rate); + exit; +} -$table = $tp -> toDB($qs[0]); -$itemid = intval($qs[1]); -$returnurl = $tp -> toDB($qs[2]); -$rate = intval($qs[3]); + + + + +/* if ($sql -> db_Select("rate", "*", "rate_table='{$table}' AND rate_itemid='{$itemid}'")) { $row = $sql -> db_Fetch(); @@ -43,19 +64,41 @@ if ($sql -> db_Select("rate", "*", "rate_table='{$table}' AND rate_itemid='{$ite $rate_voters = $row['rate_voters'].".".USERID."."; $new_rating = $row['rate_rating']+$rate; $sql -> db_Update("rate", "rate_votes=rate_votes+1, rate_rating='{$new_rating}', rate_voters='{$rate_voters}' WHERE rate_id='{$row['rate_id']}' "); + if(!$returnurl) + { + $voteStatus = e107::getRate()->renderVotes($rate_voters,($row['rate_votes'] +1)); + echo $voteStatus."|".RATELAN_3; // Thank you for your vote. + } } else { - header("location:".e_BASE."index.php"); + if($returnurl) + { + header("location:".e_BASE."index.php"); + } + else + { + echo "You already voted!"; + } exit; } } else { - $sql->db_Insert("rate", " 0, '{$table}', '{$itemid}', '{$rate}', '1', '.".USERID.".' "); + if($sql->db_Insert("rate", " 0, '{$table}', '{$itemid}', '{$rate}', '1', '.".USERID.".' ")) + { + if(!$returnurl) + { + echo RATELAN_3; // Thank you for your vote. + } + } + } + + */ + + -header("location:".$returnurl); exit; ?> \ No newline at end of file