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_text_dotclear() { 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) { //'[(('.$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; } 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_dotcleareasy'); } else { $suffix_url = 'open'; $link_title = l10n('open_window_dotcleareasy'); } $link_url = add_url_params($main_link, array($this->plugin_name => $suffix_url)); if (!empty($link_url)) { $link_url = 'DotClear Easy 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); } } ?>