plugin_name = $plugin_name; $this->plugin_path = $plugin_path; // handler $this->initialize_event_handler(); } function initialize_event_handler() { if (script_basename() != $this->plugin_name.'_controller') { add_event_handler('loc_end_page_header', array(&$this, 'loc_end_page_header')); add_event_handler('loc_end_index', array(&$this, 'loc_end_index')); add_event_handler('picture_pictures_data', array(&$this, 'picture_pictures_data')); } if (isset($_GET[$this->plugin_name])) { add_event_handler('loc_begin_page_header', array(&$this, 'loc_begin_page_header')); pwg_set_session_var($this->plugin_name, ($_GET[$this->plugin_name] === 'open')); } $this->opened = pwg_get_session_var($this->plugin_name, false); $this->to_close = (isset($_GET[$this->plugin_name]) and ($_GET[$this->plugin_name] === 'close')); } function get_thumb_post_on_a_website() { global $page, $lang_info; $list = array(); $S = ''; switch (script_basename()) { case 'index': { global $pictures; if (isset($pictures)) { $list = $pictures; } break; } case 'picture': { global $picture; if (isset($picture['current'])) { $list[] = $picture['current']; } break; } } if (empty($list) and !empty($page['items'])) { $query = ' SELECT * FROM '.IMAGES_TABLE.' WHERE id IN ('.implode(',', $page['items']).') ;'; $result = pwg_query($query); while ($row = mysql_fetch_assoc($result)) { $row['rank'] = $page['rank_of'][ $row['id'] ]; array_push($list, $row); } usort($list, 'rank_compare'); } if (!empty($list)) { set_make_full_url(); foreach ($list as $row) { /* Affichage de la miniature sur des sites. Cliquable. EXEMPLE */ $S .= ' $row['id'], 'image_file' => $row['file'], )).'\">'; $S .= '\n\n'; } unset_make_full_url(); } return $S; } function get_thumb_post_on_a_forum() { global $page, $lang_info; $list = array(); $S = ''; switch (script_basename()) { case 'index': { global $pictures; if (isset($pictures)) { $list = $pictures; } break; } case 'picture': { global $picture; if (isset($picture['current'])) { $list[] = $picture['current']; } break; } } if (empty($list) and !empty($page['items'])) { $query = ' SELECT * FROM '.IMAGES_TABLE.' WHERE id IN ('.implode(',', $page['items']).') ;'; $result = pwg_query($query); while ($row = mysql_fetch_assoc($result)) { $row['rank'] = $page['rank_of'][ $row['id'] ]; array_push($list, $row); } usort($list, 'rank_compare'); } if (!empty($list)) { set_make_full_url(); foreach ($list as $row) { /* Affichage de la miniature sur des forums. Cliquable. EXEMPLE [url={$ROOT_WAY}{$current.U_IMG}][img]{$ROOT_WAY}{$current.THUMB_SRC|@replace:'./':''}[/img][/url] */ $S .= '[url='. duplicate_picture_url( array( 'image_id' => $row['id'], 'image_file' => $row['file'], )).'][img]'. str_replace('/./', '/', get_thumbnail_url($row)).'[/img][/url]'; $S .= '\n\n'; } unset_make_full_url(); } return $S; } function get_view_post_on_a_website() { global $page, $lang_info; $list = array(); $S = ''; switch (script_basename()) { case 'index': { global $pictures; if (isset($pictures)) { $list = $pictures; } break; } case 'picture': { global $picture; if (isset($picture['current'])) { $list[] = $picture['current']; } break; } } if (empty($list) and !empty($page['items'])) { $query = ' SELECT * FROM '.IMAGES_TABLE.' WHERE id IN ('.implode(',', $page['items']).') ;'; $result = pwg_query($query); while ($row = mysql_fetch_assoc($result)) { $row['rank'] = $page['rank_of'][ $row['id'] ]; array_push($list, $row); } usort($list, 'rank_compare'); } if (!empty($list)) { include_once(PHPWG_ROOT_PATH.'/include/functions_picture.inc.php'); set_make_full_url(); foreach ($list as $row) { /* Affichage de la vue normale sur des sites. Non cliquable. EXEMPLE */ $S .= ' $row['id'], 'image_file' => $row['file'], )).'\">'; $S .= '\n\n'; } unset_make_full_url(); } return $S; } function get_view_direct_link() { global $page, $lang_info; $list = array(); $S = ''; switch (script_basename()) { case 'index': { global $pictures; if (isset($pictures)) { $list = $pictures; } break; } case 'picture': { global $picture; if (isset($picture['current'])) { $list[] = $picture['current']; } break; } } if (empty($list) and !empty($page['items'])) { $query = ' SELECT * FROM '.IMAGES_TABLE.' WHERE id IN ('.implode(',', $page['items']).') ;'; $result = pwg_query($query); while ($row = mysql_fetch_assoc($result)) { $row['rank'] = $page['rank_of'][ $row['id'] ]; array_push($list, $row); } usort($list, 'rank_compare'); } if (!empty($list)) { include_once(PHPWG_ROOT_PATH.'/include/functions_picture.inc.php'); set_make_full_url(); foreach ($list as $row) { /* Affichage du chemin en clair du lien vers la vue normale. EXEMPLE {$ROOT_WAY}{$SRC_IMG|@replace:'./':''} */ $S .= get_absolute_root_url(). str_replace('./', '', get_image_url($row)); $S .= '\n\n'; } unset_make_full_url(); } return $S; } function get_p_perso_writer_01() { global $page, $lang_info; $list = array(); $S = ''; switch (script_basename()) { case 'index': { global $pictures; if (isset($pictures)) { $list = $pictures; } break; } case 'picture': { global $picture; if (isset($picture['current'])) { $list[] = $picture['current']; } break; } } if (empty($list) and !empty($page['items'])) { $query = ' SELECT * FROM '.IMAGES_TABLE.' WHERE id IN ('.implode(',', $page['items']).') ;'; $result = pwg_query($query); while ($row = mysql_fetch_assoc($result)) { $row['rank'] = $page['rank_of'][ $row['id'] ]; array_push($list, $row); } usort($list, 'rank_compare'); } if (!empty($list)) { include_once(PHPWG_ROOT_PATH.'/include/functions_picture.inc.php'); $image_url = PHPWG_ROOT_PATH.'admin.php?page=picture_modify'; set_make_full_url(); foreach ($list as $row) { /* Affichage Personnalisé, 01. EXEMPLE
{$ALT_IMG}Galerie complète à visiter
*/ $S .= '
$row['id'], 'image_file' => $row['file'], )). '\">\"'. $image_url,). '\"; target=\"_blank\">Galerie complète à visiter
'; // Arguments à transmettre $S .= '\n\n'; } unset_make_full_url(); } return $S; } function get_p_perso_writer_02() { global $page, $lang_info; $list = array(); $S = ''; switch (script_basename()) { case 'index': { global $pictures; if (isset($pictures)) { $list = $pictures; } break; } case 'picture': { global $picture; if (isset($picture['current'])) { $list[] = $picture['current']; } break; } } if (empty($list) and !empty($page['items'])) { $query = ' SELECT * FROM '.IMAGES_TABLE.' WHERE id IN ('.implode(',', $page['items']).') ;'; $result = pwg_query($query); while ($row = mysql_fetch_assoc($result)) { $row['rank'] = $page['rank_of'][ $row['id'] ]; array_push($list, $row); } usort($list, 'rank_compare'); } if (!empty($list)) { include_once(PHPWG_ROOT_PATH.'/include/functions_url.inc.php'); set_make_full_url(); foreach ($list as $row) { //'[(('.$picture['current']['thumbnail'].'))|'.$picture['current']['url'].'|'.$lang_info['code'].']'; $S .= '*** '.(!empty($row['name']) ? $row['name'] : $row['file']).' ***\n'; $S .= '[(('. str_replace('/./', '/', get_thumbnail_url($row)).'))|'. duplicate_picture_url( array( 'image_id' => $row['id'], 'image_file' => $row['file'], )).'|'. $lang_info['code'].']\n\n'; } unset_make_full_url(); } return $S; } // Fin de la définition des champs function loc_begin_page_header() { global $template; $redirect_url = ( script_basename()=='picture' ? duplicate_picture_url(array(), array($this->plugin_name)) : duplicate_index_url(array(), array($this->plugin_name)) ); $template->assign( array( 'page_refresh' => array( 'TIME' => 1, 'U_REFRESH' => $redirect_url ) )); } function loc_end_page_header() { global $template; if ($this->opened or $this->to_close) { $plugin_root_url = get_root_url().'plugins/'.$this->plugin_name.'/'; $js = ' '; $template->append('head_elements', $js); } } function get_link_icon($main_link) { global $page; if (empty($page['items'])) { return; } $this->loading_lang(); if ($this->opened) { $suffix_url = 'close'; $link_title = l10n('close_window_piwishack'); } else { $suffix_url = 'open'; $link_title = l10n('open_window_piwishack'); } $link_url = add_url_params($main_link, array($this->plugin_name => $suffix_url)); if (!empty($link_url)) { $link_url = 'PiwiShack controller'; } return $link_url; } function loc_end_index() { global $template; $link_url = $this->get_link_icon(duplicate_index_url()); if (!empty($link_url)) { $template->concat( 'PLUGIN_INDEX_ACTIONS', '
  • '.$link_url.'
  • '); } } function picture_pictures_data($pictures) { global $template; $link_url = $this->get_link_icon(duplicate_picture_url()); if (!empty($link_url)) { $template->concat( 'PLUGIN_PICTURE_ACTIONS', $link_url); } return $pictures; } function loading_lang() { load_language('plugin.lang', $this->plugin_path); } } ?>