[9239] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: PayPal Shopping Cart |
---|
[9269] | 4 | Version: 1.0.4 |
---|
[9239] | 5 | Description: Append PayPal Shopping Cart on Piwigo to sell photos |
---|
| 6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=499 |
---|
| 7 | Author: queguineur.fr |
---|
| 8 | Author URI: http://www.queguineur.fr |
---|
| 9 | */ |
---|
| 10 | /* |
---|
| 11 | Plugin Panier PayPal Pour Piwigo |
---|
| 12 | Copyright (C) 2011 www.queguineur.fr Tous droits réservés. |
---|
| 13 | |
---|
| 14 | Ce programme est un logiciel libre ; vous pouvez le redistribuer ou le |
---|
| 15 | modifier suivant les termes de la GNU General Public License telle que |
---|
| 16 | publiée par la Free Software Foundation : soit la version 3 de cette |
---|
| 17 | licence, soit (à votre gré) toute version ultérieure. |
---|
| 18 | |
---|
| 19 | Ce programme est distribué dans lespoir quil vous sera utile, mais SANS |
---|
| 20 | AUCUNE GARANTIE : sans même la garantie implicite de COMMERCIALISABILITÉ |
---|
| 21 | ni dADÉQUATION À UN OBJECTIF PARTICULIER. Consultez la Licence Générale |
---|
| 22 | Publique GNU pour plus de détails. |
---|
| 23 | |
---|
| 24 | Vous devriez avoir reçu une copie de la Licence Générale Publique GNU avec |
---|
| 25 | ce programme ; si ce nest pas le cas, consultez : |
---|
| 26 | <http://www.gnu.org/licenses/>. |
---|
| 27 | */ |
---|
| 28 | /* |
---|
| 29 | Historique |
---|
| 30 | 1.0.0 10/02/2011 |
---|
| 31 | Version initiale |
---|
| 32 | |
---|
| 33 | 1.0.1 10/02/2011 |
---|
| 34 | Ajout du Plugin URI pour permettre les mises à jours |
---|
| 35 | Traduction en Anglais du Plugin Name et du nom du répertoire |
---|
| 36 | |
---|
| 37 | 1.0.2 10/02/2011 |
---|
| 38 | Correction du problème de compatibilité avec exif view (double affichage des boutons) |
---|
| 39 | |
---|
[9249] | 40 | 1.0.3 15/02/2011 |
---|
[9250] | 41 | Add lv_LV (Latvian) thanks to Aivars Baldone |
---|
[9249] | 42 | |
---|
[9269] | 43 | 1.0.4 17/02/2011 |
---|
| 44 | Add de_DE and it_IT (par Sugar888) |
---|
| 45 | |
---|
[9239] | 46 | */ |
---|
| 47 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 48 | define('PPPPP_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); |
---|
| 49 | include_once (PPPPP_PATH.'/constants.php'); |
---|
| 50 | |
---|
| 51 | function ppppp_append_form($tpl_source, &$smarty){ |
---|
| 52 | $pattern = '#</table>#'; |
---|
| 53 | $replacement = ' |
---|
| 54 | <tr> |
---|
| 55 | <td class="label">{\'Buy this picture\'|@translate}</td> |
---|
| 56 | <td> |
---|
| 57 | <form name="ppppp_form" target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" onSubmit="javascript:pppppValid()"> |
---|
| 58 | <input type="hidden" name="add" value="1"> |
---|
| 59 | <input type="hidden" name="cmd" value="_cart"> |
---|
| 60 | <input type="hidden" name="business" value="{$ppppp_e_mail}"> |
---|
| 61 | <input type="hidden" name="item_name"> |
---|
| 62 | <input type="hidden" name="no_shipping" value="2"><!-- shipping address mandatory --> |
---|
| 63 | <input type="hidden" name="handling_cart" value="{$ppppp_fixed_shipping}"> |
---|
| 64 | <input type="hidden" name="currency_code" value="{$ppppp_currency}"> |
---|
| 65 | <select name="amount"> |
---|
| 66 | {foreach from=$ppppp_array_size item=ppppp_row_size} |
---|
| 67 | <option value="{$ppppp_row_size.price}">{$ppppp_row_size.size} : {$ppppp_row_size.price} {$ppppp_currency}</option> |
---|
| 68 | {/foreach} |
---|
| 69 | <input type="submit" value="{\'Add to cart\'|@translate}"> |
---|
| 70 | </form> |
---|
| 71 | </td> |
---|
| 72 | <td> |
---|
| 73 | <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> |
---|
| 74 | <input type="hidden" name="cmd" value="_cart"> |
---|
| 75 | <input type="hidden" name="business" value="{$ppppp_e_mail}"> |
---|
| 76 | <input type="hidden" name="display" value="1"> |
---|
| 77 | <input type="hidden" name="no_shipping" value="2"> |
---|
| 78 | <input type=submit value="{\'View Shopping Cart\'|@translate}"> |
---|
| 79 | </form> |
---|
| 80 | </td> |
---|
| 81 | </tr> |
---|
| 82 | </table> |
---|
| 83 | |
---|
| 84 | {literal} |
---|
| 85 | <script type="text/javascript"> |
---|
| 86 | function pppppValid(){ |
---|
| 87 | var amount=document.ppppp_form.amount; |
---|
| 88 | var selectedAmount=amount[amount.selectedIndex]; |
---|
| 89 | document.ppppp_form.item_name.value="Photo \"{/literal}{$current.TITLE}\", Ref {$INFO_FILE}, {\'Size\'|@translate} : {literal} "+selectedAmount.text; |
---|
| 90 | } |
---|
| 91 | </script> |
---|
| 92 | {/literal} |
---|
| 93 | '; |
---|
| 94 | return preg_replace($pattern, $replacement, $tpl_source,1); |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | function ppppp_picture_handler(){ |
---|
| 98 | global $template; |
---|
| 99 | $template->set_prefilter('picture', 'ppppp_append_form'); |
---|
| 100 | load_language('plugin.lang', PPPPP_PATH); |
---|
| 101 | $query='SELECT * FROM '.PPPPP_SIZE_TABLE.';'; |
---|
| 102 | $result = pwg_query($query); |
---|
| 103 | while($row = mysql_fetch_array($result)){ |
---|
| 104 | $template->append('ppppp_array_size',$row); |
---|
| 105 | } |
---|
| 106 | $query='SELECT value FROM '.PPPPP_CONFIG_TABLE.' WHERE param = \'fixed_shipping\';'; |
---|
| 107 | $result = pwg_query($query); |
---|
| 108 | $row = mysql_fetch_array($result); |
---|
| 109 | $template->assign('ppppp_fixed_shipping',$row[0]); |
---|
| 110 | $query='SELECT value FROM '.PPPPP_CONFIG_TABLE.' WHERE param = \'currency\';'; |
---|
| 111 | $result = pwg_query($query); |
---|
| 112 | $row = mysql_fetch_array($result); |
---|
| 113 | $template->assign('ppppp_currency',$row[0]); |
---|
| 114 | |
---|
| 115 | $template->assign('ppppp_e_mail',get_webmaster_mail_address()); |
---|
| 116 | $template->append('footer_elements',' - PayPal plugin by <a href=http://www.queguineur.fr>queguineur.fr</a>'); |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | add_event_handler('loc_begin_picture', 'ppppp_picture_handler'); |
---|
| 120 | |
---|
| 121 | function ppppp_append_js($tpl_source, &$smarty){ |
---|
| 122 | load_language('plugin.lang', PPPPP_PATH); |
---|
| 123 | if(strstr($tpl_source,"{'Menu'|@translate}")==false) |
---|
| 124 | return $tpl_source; |
---|
| 125 | $pattern = '#{/foreach}#'; |
---|
| 126 | $replacement = '{/foreach} |
---|
| 127 | <li><a href="" title="'.l10n('View my PayPal Shopping Cart').'" onclick="document.forms[\'ppppp_form_view_cart\'].submit()">'.l10n('View Shopping Cart').'</a></li> |
---|
| 128 | <form name="ppppp_form_view_cart" target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> |
---|
| 129 | <input type="hidden" name="cmd" value="_cart"> |
---|
| 130 | <input type="hidden" name="business" value="{$ppppp_e_mail}"> |
---|
| 131 | <input type="hidden" name="display" value="1"> |
---|
| 132 | <input type="hidden" name="no_shipping" value="2"> |
---|
| 133 | </form> |
---|
| 134 | '; |
---|
| 135 | return preg_replace($pattern, $replacement, $tpl_source); |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | function ppppp_index_handler(){ |
---|
| 139 | global $template; |
---|
| 140 | $template->set_prefilter('menubar', 'ppppp_append_js'); |
---|
| 141 | $template->assign('ppppp_e_mail',get_webmaster_mail_address()); |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | add_event_handler('loc_begin_index', 'ppppp_index_handler'); |
---|
| 145 | |
---|
| 146 | function ppppp_admin_menu($menu){ |
---|
| 147 | load_language('plugin.lang', PPPPP_PATH); |
---|
| 148 | array_push($menu, array( |
---|
| 149 | 'NAME' => l10n('PayPal Shopping Cart'), |
---|
| 150 | 'URL' => get_admin_plugin_menu_link(PPPPP_PATH . 'admin.php'))); |
---|
| 151 | return $menu; |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | add_event_handler('get_admin_plugin_menu_links', 'ppppp_admin_menu'); |
---|
| 155 | ?> |
---|