. */ /* Historique 1.0.0 10/02/2011 Version initiale 1.0.1 10/02/2011 Ajout du Plugin URI pour permettre les mises à jours Traduction en Anglais du Plugin Name et du nom du répertoire 1.0.2 10/02/2011 Correction du problème de compatibilité avec exif view (double affichage des boutons) 1.0.3 15/02/2011 Add lv_LV (Latvian) thanks to Aivars Baldone 1.0.4 17/02/2011 Add de_DE and it_IT (par Sugar888) 1.0.5 27/02/2011 Correction pb compatibilité avec certains thèmes Déplacement des boutons PayPal en début de table info 1.0.6 05/03/2011 Add sk_SK (by dodo) 1.0.7 26/03/2011 Add hu_HU language (Hungarian) thanks to samli */ if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); global $prefixeTable; // +-----------------------------------------------------------------------+ // | Define plugin constants | // +-----------------------------------------------------------------------+ defined('PPPPP_ID') or define('PPPPP_ID', basename(dirname(__FILE__))); define('PPPPP_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); define('PPPPP_SIZE_TABLE', $prefixeTable.'ppppp_size'); define('PPPPP_CONFIG_TABLE', $prefixeTable.'ppppp_config'); define('PPPPP_VERSION', 'auto'); function ppppp_append_form($tpl_source, &$smarty){ $pattern = '#<.*\"infoTable\".*>#'; $replacement = ' {\'Buy this picture\'|@translate}
{literal} {/literal} '; if(!preg_match($pattern,$tpl_source)) { $pattern='#{if isset\(\$COMMENT_IMG\)}#'; $replacement=''.$replacement.'
'; $replacement=$replacement.'$0'; } else $replacement='$0'.$replacement; return preg_replace($pattern, $replacement, $tpl_source,1); } function ppppp_picture_handler(){ global $template, $conf, $page; if ($conf['PayPalShoppingCart']['apply_to_albums'] == 'list') { if (!isset($page['category'])) { return; } $query = ' SELECT paypal_active FROM '.CATEGORIES_TABLE.' WHERE id = '.$page['category']['id'].' ;'; list($paypal_active) = pwg_db_fetch_row(pwg_query($query)); if ('false' == $paypal_active) { return; } } $template->set_prefilter('picture', 'ppppp_append_form'); load_language('plugin.lang', PPPPP_PATH); $query='SELECT * FROM '.PPPPP_SIZE_TABLE.' '.@$conf['PayPalShoppingCart_sizes_order_by'].';'; $result = pwg_query($query); while($row = pwg_db_fetch_assoc($result)){ $template->append('ppppp_array_size',$row); } $query='SELECT value FROM '.PPPPP_CONFIG_TABLE.' WHERE param = \'fixed_shipping\';'; $result = pwg_query($query); $row = pwg_db_fetch_row($result); $template->assign('ppppp_fixed_shipping',$row[0]); $query='SELECT value FROM '.PPPPP_CONFIG_TABLE.' WHERE param = \'currency\';'; $result = pwg_query($query); $row = pwg_db_fetch_row($result); $template->assign('ppppp_currency',$row[0]); $template->assign('ppppp_e_mail',get_webmaster_mail_address()); } add_event_handler('loc_begin_picture', 'ppppp_picture_handler'); function ppppp_append_js($tpl_source, &$smarty){ load_language('plugin.lang', PPPPP_PATH); if(strstr($tpl_source,"{'Menu'|@translate}")==false) return $tpl_source; $pattern = '#{/foreach}#'; $replacement = '{/foreach}
  • '.l10n('View Shopping Cart').'
  • '; return preg_replace($pattern, $replacement, $tpl_source); } function ppppp_index_handler(){ global $template; $template->set_prefilter('menubar', 'ppppp_append_js'); $template->assign('ppppp_e_mail',get_webmaster_mail_address()); } add_event_handler('loc_begin_index', 'ppppp_index_handler'); function ppppp_admin_menu($menu){ load_language('plugin.lang', PPPPP_PATH); array_push($menu, array( 'NAME' => l10n('PayPal Shopping Cart'), 'URL' => get_admin_plugin_menu_link(PPPPP_PATH . 'admin.php'))); return $menu; } add_event_handler('get_admin_plugin_menu_links', 'ppppp_admin_menu'); add_event_handler('init', 'ppppp_init'); /** * plugin initialization * - check for upgrades * - unserialize configuration * - load language */ function ppppp_init() { global $conf, $pwg_loaded_plugins; // apply upgrade if needed if ( PPPPP_VERSION == 'auto' or $pwg_loaded_plugins[PPPPP_ID]['version'] == 'auto' or version_compare($pwg_loaded_plugins[PPPPP_ID]['version'], PPPPP_VERSION, '<') ) { // call install function include_once(PPPPP_PATH.'include/install.inc.php'); ppppp_install(); // update plugin version in database if ( $pwg_loaded_plugins[PPPPP_ID]['version'] != 'auto' and PPPPP_VERSION != 'auto' ) { $query = ' UPDATE '. PLUGINS_TABLE .' SET version = "'. PPPPP_VERSION .'" WHERE id = "'. PPPPP_ID .'"'; pwg_query($query); $pwg_loaded_plugins[PPPPP_ID]['version'] = PPPPP_VERSION; if (defined('IN_ADMIN')) { $_SESSION['page_infos'][] = 'PayPalShoppingCart plugin updated to version '. PPPPP_VERSION; } } } // load plugin language file load_language('plugin.lang', PPPPP_PATH); // prepare plugin configuration $conf['PayPalShoppingCart'] = unserialize($conf['PayPalShoppingCart']); } ?>