| // | Mod description : | // | Ce module est base sur le module existant pour le telechargement, | // | cette version permet le telechargement sur plusieurs pages. | // +-----------------------------------------------------------------------+ // | This program is free software; you can redistribute it and/or modify | // | it under the terms of the GNU General Public License as published by | // | the Free Software Foundation | // | | // | This program is distributed in the hope that it will be useful, but | // | WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | // | General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program; if not, write to the Free Software | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | // | USA. ' | // +-----------------------------------------------------------------------+ class DownloadMulti { var $plugin_name, $plugin_path, $plugin_url; var $my_config; function DownloadMulti($plugin_name, $plugin_path, $plugin_url) { // Args $this->plugin_name = $plugin_name; $this->plugin_path = $plugin_path; $this->plugin_url = $plugin_url; // handler $this->initialize_event_handler($plugin_name, $plugin_path, $plugin_url); } function initialize_event_handler() { global $user; $this->load_config(); // Chargement de la configuration $this->load_lang(); // Chargement des langues if ($user['status'] != 'guest' AND !empty($this->my_config['group_id'])) { // Récupération du groupe utilisateur autorisé à télécharger les images $query = ' SELECT group_id FROM '.USER_GROUP_TABLE.' WHERE user_id = '.$user['id'].' ;'; $result = pwg_query($query); // Parcours la requête SQL while($row = mysql_fetch_array($result)) { if(in_array($row['group_id'], $this->my_config['group_id'])) { // Mise à jour du panier add_event_handler('loc_begin_index', array(&$this, 'DmCart')); // Ajout d'élements dans le header // Ne pas inclure dans les pages d'administration add_event_handler('loc_end_page_header', array(&$this, 'DmHeader')); // Ajout une entrée dans le menubar add_event_handler('blockmanager_apply', array(&$this, 'DmMenubar')); add_event_handler('blockmanager_register_blocks', array(&$this, 'register_dm_menubar_blocks')); // ---- Thumbnail // Entrée HTML du formulaire pour la sélection des images add_event_handler('loc_begin_index_thumbnails', array(&$this, 'DmFormThumbnail')); // Affichage des cases à cocher sous les vignettes add_event_handler('loc_end_index_thumbnails', array($this, 'DmCategoryThumbnail'), 50, 2); // Affichage du cadre en bas de thumbnail.tpl add_event_handler('loc_begin_index_thumbnails', array(&$this, 'DmCategoryDefault')); if (script_basename() == 'popuphelp') { // ---- Aide add_event_handler('get_popup_help_content', array(&$this, 'get_popup_help_content'), EVENT_HANDLER_PRIORITY_NEUTRAL, 2); } } } } if (is_admin()) { // ---- Administration add_event_handler('get_admin_plugin_menu_links', array(&$this, 'plugin_admin_menu')); // Menu d'administration } } /* this function initialize var $my_config with default values */ function init_config() { $this->my_config = array(); } //Chargement de la configuration function load_config() { $this->init_config(); $query = ' SELECT value FROM '.CONFIG_TABLE.' WHERE param = \'downloadmulti_config\' ;'; $result = pwg_query($query); if($result) { $row = mysql_fetch_row($result); if(is_string($row[0])) { $config = unserialize($row[0]); reset($config); while (list($key, $val) = each($config)) { $this->my_config[$key] = $val; } } } } // Sauvegarde de la configuration function save_config() { $query = ' REPLACE INTO '.CONFIG_TABLE.' VALUES( \'downloadmulti_config\', \''.serialize($this->my_config).'\', \'Configuration de Download Multi\') ;'; $result = pwg_query($query); if($result) { return true; } else { return false; } } // Affichage du lien dans la barre // menu administrateur function plugin_admin_menu($menu) { array_push($menu, array( 'NAME' => 'Download Multi', 'URL' => get_admin_plugin_menu_link($this->plugin_path.'admin/admin.php') ) ); return $menu; } // Chargement des fichiers langues function load_lang() { load_language('plugin.lang', $this->plugin_path); } // Gestion de l'aide pour le plugin function get_popup_help_content($popup_help_content, $page) { if (in_array($page, array($this->plugin_name, 'DownloadMulti'))) { $help_content = load_language('help/'.$page.'.html', $this->plugin_path, array('return'=>true)); } else { $help_content = false; } if ($help_content == false) { return $popup_help_content; } else { return $popup_help_content.$help_content; } } // Enregistrement du menu pour la gestion dans l'administration function register_dm_menubar_blocks($menu_ref_arr) { $menu = & $menu_ref_arr[0]; if ($menu->get_id() != 'menubar') return; $menu->register_block(new RegisteredBlock('mbDownloadMulti', 'Download Multi', 'DM')); } // Chargement de fichier dans l'entête du template function DmHeader() { global $template; $DmUrlJs = get_root_url().'plugins/'.$this->plugin_name.'/include/DownloadMulti.js'; $DmUrlCss = get_root_url().'plugins/'.$this->plugin_name.'/include/DownloadMulti.css'; $template->append( 'head_elements', ''."\n". ''."\n" ); } // Gestion de l'affichage dans le menubar function DmMenuBar($menu_ref_arr) { global $template; $menu = & $menu_ref_arr[0]; $template->assign('NBIMAGES', $this->DmCountCart()); if (($block = $menu->get_block( 'mbDownloadMulti' )) != null) { $block->set_title('Download Multi'); $block->template = $this->plugin_path.'template/DmMenu.tpl'; } } // Compte le nombre d'images selectionné // dans le panier du visiteur function DmCountCart() { global $prefixeTable, $user, $lang; $query = ' SELECT COUNT(*) AS nb_line FROM '.$prefixeTable.'download_multi WHERE id_user = '.$user['id'].' ;'; $row = mysql_fetch_array(pwg_query($query)); // Si le nombre de lignes est supérieur à 0 // alors on affiche le message d'avertissement // utilisateur if ($row['nb_line'] > 0) { $nbImages = sprintf($lang['dl_message_cart'], $row['nb_line']); } else { $nbImages = $lang['dl_empty_cart']; } return $nbImages; } // Mise à jour du panier function DmCart() { if (isset($_POST['action'])) { $this->DmControle(); } } // Affiche l'entrée HTML du formulaire function DmFormThumbnail() { global $template; $template->concat('PLUGIN_INDEX_CONTENT_BEGIN', '