Changeset 19464 for extensions/PayPalShoppingCart
- Timestamp:
- Dec 17, 2012, 3:55:58 PM (11 years ago)
- Location:
- extensions/PayPalShoppingCart
- Files:
-
- 2 added
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/PayPalShoppingCart/admin.php
r9239 r19464 23 23 load_language('plugin.lang', PPPPP_PATH); 24 24 $my_base_url = get_admin_plugin_menu_link(__FILE__); 25 include_once (PPPPP_PATH.'/constants.php');26 25 27 26 // onglets … … 35 34 l10n('Currency'), 36 35 $my_base_url.'&tab=currency'); 36 $tabsheet->add('albums', l10n('Albums'), $my_base_url.'&tab=albums'); 37 37 $tabsheet->add('size', 38 38 l10n('Size'), … … 85 85 $template->assign('ppppp_array_currency',$array_currency); 86 86 break; 87 88 case 'albums' : 89 90 if (isset($_POST['apply_to_albums']) and in_array($_POST['apply_to_albums'], array('all', 'list'))) 91 { 92 $conf['PayPalShoppingCart']['apply_to_albums'] = $_POST['apply_to_albums']; 93 conf_update_param('PayPalShoppingCart', serialize($conf['PayPalShoppingCart'])); 94 95 if ($_POST['apply_to_albums'] == 'list') 96 { 97 check_input_parameter('albums', $_POST, true, PATTERN_ID); 98 99 if (empty($_POST['albums'])) 100 { 101 $_POST['albums'][] = -1; 102 } 103 104 $query = ' 105 UPDATE '.CATEGORIES_TABLE.' 106 SET paypal_active = \'false\' 107 WHERE id NOT IN ('.implode(',', $_POST['albums']).') 108 ;'; 109 pwg_query($query); 110 111 $query = ' 112 UPDATE '.CATEGORIES_TABLE.' 113 SET paypal_active = \'true\' 114 WHERE id IN ('.implode(',', $_POST['albums']).') 115 ;'; 116 pwg_query($query); 117 } 118 } 119 120 // associate to albums 121 $query = ' 122 SELECT id 123 FROM '.CATEGORIES_TABLE.' 124 WHERE paypal_active = \'true\' 125 ;'; 126 $paypal_albums = array_from_query($query, 'id'); 127 128 $query = ' 129 SELECT id,name,uppercats,global_rank 130 FROM '.CATEGORIES_TABLE.' 131 ;'; 132 display_select_cat_wrapper($query, $paypal_albums, 'album_options'); 133 134 $template->assign('apply_to_albums', $conf['PayPalShoppingCart']['apply_to_albums']); 135 136 break; 137 87 138 88 139 case 'size': -
extensions/PayPalShoppingCart/admin.tpl
r9239 r19464 1 {combine_script id='jquery.chosen' load='footer' path='themes/default/js/plugins/chosen.jquery.min.js'} 2 {combine_css path="themes/default/js/plugins/chosen.css"} 3 4 {footer_script}{literal} 5 jQuery(document).ready(function() { 6 jQuery(".chzn-select").chosen(); 7 8 function checkStatusOptions() { 9 if (jQuery("input[name=apply_to_albums]:checked").val() == "list") { 10 jQuery("#albumList").show(); 11 } 12 else { 13 jQuery("#albumList").hide(); 14 } 15 } 16 17 checkStatusOptions(); 18 19 jQuery("input[name=apply_to_albums]").change(function() { 20 checkStatusOptions(); 21 }); 22 }); 23 {/literal}{/footer_script} 24 1 25 <div class="titrePage"> 2 26 <h2>{'PayPal Shopping Cart'|@translate}</h2> … … 17 41 <br> 18 42 <!--input type=submit value="{'Update data'|@translate}"--> 43 </fieldset> 44 </form> 45 46 {elseif $tabsheet_selected=='albums'} 47 <h3>{'Albums'|@translate}</h3> 48 <form method=post> 49 <fieldset> 50 <legend>{'Apply to albums'|@translate}</legend> 51 <p> 52 <label><input type="radio" name="apply_to_albums" value="all"{if $apply_to_albums eq 'all'} checked="checked"{/if}> <strong>{'all albums'|@translate}</strong></label> 53 <label><input type="radio" name="apply_to_albums" value="list"{if $apply_to_albums eq 'list'} checked="checked"{/if}> <strong>{'a list of albums'|@translate}</strong></label> 54 </p> 55 <p id="albumList"> 56 <select data-placeholder="Select albums..." class="chzn-select" multiple style="width:700px;" name="albums[]"> 57 {html_options options=$album_options selected=$album_options_selected} 58 </select> 59 </p> 60 <p class="formButtons"> 61 <input type="submit" name="submit" value="{'Save Settings'|@translate}"> 62 </p> 19 63 </fieldset> 20 64 </form> -
extensions/PayPalShoppingCart/language/en_UK/plugin.lang.php
r9239 r19464 36 36 $lang['View Shopping Cart'] = 'View Shopping Cart'; 37 37 $lang['View my PayPal Shopping Cart'] = 'View my PayPal Shopping Cart'; 38 $lang['Apply to albums'] = 'Apply to albums'; 39 $lang['all albums'] = 'all albums'; 40 $lang['a list of albums'] = 'a list of albums'; 38 41 ?> -
extensions/PayPalShoppingCart/language/fr_FR/plugin.lang.php
r9239 r19464 36 36 $lang['View Shopping Cart'] = 'Voir mon panier'; 37 37 $lang['View my PayPal Shopping Cart'] = 'Voir mon panier PayPal'; 38 $lang['Apply to albums'] = 'Appliquer aux albums'; 39 $lang['all albums'] = 'tous les albums'; 40 $lang['a list of albums'] = 'une liste d\'albums'; 38 41 ?> -
extensions/PayPalShoppingCart/main.inc.php
r9876 r19464 2 2 /* 3 3 Plugin Name: PayPal Shopping Cart 4 Version: 1.0.74 Version: auto 5 5 Description: Append PayPal Shopping Cart on Piwigo to sell photos 6 6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=499 … … 56 56 */ 57 57 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 58 59 global $prefixeTable; 60 61 // +-----------------------------------------------------------------------+ 62 // | Define plugin constants | 63 // +-----------------------------------------------------------------------+ 64 65 defined('PPPPP_ID') or define('PPPPP_ID', basename(dirname(__FILE__))); 58 66 define('PPPPP_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); 59 include_once (PPPPP_PATH.'/constants.php'); 67 define('PPPPP_SIZE_TABLE', $prefixeTable.'ppppp_size'); 68 define('PPPPP_CONFIG_TABLE', $prefixeTable.'ppppp_config'); 69 define('PPPPP_VERSION', 'auto'); 70 60 71 61 72 function ppppp_append_form($tpl_source, &$smarty){ … … 112 123 113 124 function ppppp_picture_handler(){ 114 global $template; 125 global $template, $conf, $page; 126 127 if ($conf['PayPalShoppingCart']['apply_to_albums'] == 'list') 128 { 129 if (!isset($page['category'])) 130 { 131 return; 132 } 133 134 $query = ' 135 SELECT 136 paypal_active 137 FROM '.CATEGORIES_TABLE.' 138 WHERE id = '.$page['category']['id'].' 139 ;'; 140 list($paypal_active) = pwg_db_fetch_row(pwg_query($query)); 141 142 if ('false' == $paypal_active) 143 { 144 return; 145 } 146 } 147 115 148 $template->set_prefilter('picture', 'ppppp_append_form'); 116 149 load_language('plugin.lang', PPPPP_PATH); … … 130 163 131 164 $template->assign('ppppp_e_mail',get_webmaster_mail_address()); 132 $template->append('footer_elements',' - PayPal plugin by <a href=http://www.queguineur.fr>queguineur.fr</a>');133 165 } 134 166 … … 169 201 170 202 add_event_handler('get_admin_plugin_menu_links', 'ppppp_admin_menu'); 203 204 add_event_handler('init', 'ppppp_init'); 205 /** 206 * plugin initialization 207 * - check for upgrades 208 * - unserialize configuration 209 * - load language 210 */ 211 function ppppp_init() 212 { 213 global $conf, $pwg_loaded_plugins; 214 215 // apply upgrade if needed 216 if ( 217 PPPPP_VERSION == 'auto' or 218 $pwg_loaded_plugins[PPPPP_ID]['version'] == 'auto' or 219 version_compare($pwg_loaded_plugins[PPPPP_ID]['version'], PPPPP_VERSION, '<') 220 ) 221 { 222 // call install function 223 include_once(PPPPP_PATH.'include/install.inc.php'); 224 ppppp_install(); 225 226 // update plugin version in database 227 if ( $pwg_loaded_plugins[PPPPP_ID]['version'] != 'auto' and PPPPP_VERSION != 'auto' ) 228 { 229 $query = ' 230 UPDATE '. PLUGINS_TABLE .' 231 SET version = "'. PPPPP_VERSION .'" 232 WHERE id = "'. PPPPP_ID .'"'; 233 pwg_query($query); 234 235 $pwg_loaded_plugins[PPPPP_ID]['version'] = PPPPP_VERSION; 236 237 if (defined('IN_ADMIN')) 238 { 239 $_SESSION['page_infos'][] = 'PayPalShoppingCart plugin updated to version '. PPPPP_VERSION; 240 } 241 } 242 } 243 244 // load plugin language file 245 load_language('plugin.lang', PPPPP_PATH); 246 247 // prepare plugin configuration 248 $conf['PayPalShoppingCart'] = unserialize($conf['PayPalShoppingCart']); 249 } 171 250 ?> -
extensions/PayPalShoppingCart/maintain.inc.php
r9239 r19464 21 21 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 22 22 23 if (!defined("PPPPP_PATH")){ 24 define('PPPPP_PATH', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__))); 23 defined('PPPPP_ID') or define('PPPPP_ID', basename(dirname(__FILE__))); 24 include_once(PHPWG_PLUGINS_PATH.PPPPP_ID.'/include/install.inc.php'); 25 26 /** 27 * plugin installation 28 * 29 * perform here all needed step for the plugin installation 30 * such as create default config, add database tables, 31 * add fields to existing tables, create local folders... 32 */ 33 function plugin_install() 34 { 35 ppppp_install(); 36 define('ppppp_installed', true); 25 37 } 26 include_once (PPPPP_PATH.'/constants.php');27 38 28 function plugin_install(){ 29 global $prefixeTable; 30 $query = "CREATE TABLE IF NOT EXISTS ".PPPPP_SIZE_TABLE." ( 31 id tinyint(4) NOT NULL AUTO_INCREMENT, 32 size varchar(40) NOT NULL, 33 price float NOT NULL, 34 PRIMARY KEY (id), 35 UNIQUE KEY size (size) 36 );"; 37 pwg_query($query); 38 $query = "INSERT INTO ".PPPPP_SIZE_TABLE." (size,price) VALUES ('Classique', '40');"; 39 pwg_query($query); 39 /** 40 * plugin activation 41 * 42 * this function is triggered adter installation, by manual activation 43 * or after a plugin update 44 * for this last case you must manage updates tasks of your plugin in this function 45 */ 46 function plugin_activate() 47 { 48 if (!defined('ppppp_installed')) // a plugin is activated just after its installation 49 { 50 ppppp_install(); 51 } 52 } 53 54 /** 55 * plugin unactivation 56 * 57 * triggered before uninstallation or by manual unactivation 58 */ 59 function plugin_unactivate() 60 { 61 } 62 63 function plugin_uninstall() 64 { 65 global $prefixeTable; 40 66 41 $query = "CREATE TABLE IF NOT EXISTS ".PPPPP_CONFIG_TABLE." ( 42 param varchar(40) NOT NULL, 43 value text NOT NULL, 44 PRIMARY KEY (param) 45 );"; 46 pwg_query($query); 47 $query = "INSERT INTO ".PPPPP_CONFIG_TABLE." VALUES ('fixed_shipping', '0');"; 48 pwg_query($query); 49 $query = "INSERT INTO ".PPPPP_CONFIG_TABLE." VALUES ('currency', 'EUR');"; 50 pwg_query($query); 51 } 67 $query = "DROP TABLE ".$prefixeTable."ppppp_size;"; 68 pwg_query($query); 69 70 $query = "DROP TABLE ".$prefixeTable."ppppp_config;"; 71 pwg_query($query); 52 72 53 function plugin_uninstall(){ 54 global $prefixeTable; 55 $query = "DROP TABLE ".PPPPP_SIZE_TABLE.";"; 56 pwg_query($query); 57 $query = "DROP TABLE ".PPPPP_CONFIG_TABLE.";"; 58 pwg_query($query); 73 // delete configuration 74 pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "PayPalShoppingCart";'); 75 76 // delete field 77 pwg_query('ALTER TABLE `'. CATEGORIES_TABLE .'` DROP COLUMN paypal_active;'); 59 78 } 60 79 ?>
Note: See TracChangeset
for help on using the changeset viewer.