plugin_name = $plugin_name;
$this->plugin_path = $plugin_path;
$this->load_config();
// handler
$this->initialize_event_handler();
}
/**************************************************************************
* function: initialize_event_handler
**************************************************************************
* Rôle:
* Ajout des handlers nécessaires aux pages index et picture
* si les droits l'autorisent.
*************************************************************************/
function initialize_event_handler()
{
if ((($this->config['URLShackRight'] == "admin") && (is_admin()))
|| (($this->config['URLShackRight'] == "member") && (!is_a_guest()))
|| ($this->config['URLShackRight'] == "all"))
{
if (script_basename() != $this->plugin_name.'_controller')
{
add_event_handler('loc_end_index', array(&$this, 'handler_index'));
add_event_handler('picture_pictures_data', array(&$this, 'handler_picture'));
}
}
}
/**************************************************************************
* function: loading_lang
**************************************************************************
* Rôle:
* Chargement des données de langue
*************************************************************************/
function loading_lang()
{
load_language('plugin.lang', $this->plugin_path);
}
/**************************************************************************
* function: get_link_icon
**************************************************************************
* in:
* out:
* code de l'action
**************************************************************************
* Rôle:
* Retourne le code de l'action d'ouverture piwishack
*************************************************************************/
function get_link_icon($main_link)
{
global $page;
if (empty($page['items']))
{
return;
}
$this->loading_lang();
$link_title = l10n('open_window_piwishack');
$link_url = '';
return $link_url;
}
/**************************************************************************
* function: handler_index
**************************************************************************
* in:
* out:
* Code source
**************************************************************************
* Rôle:
* Handler dans le cas des pages d'index : ajoute le code javascript,
* le code html du popup et l'icone d'ouverture piwishack.
*************************************************************************/
function handler_index()
{
global $template;
$link_url = $this->get_link_icon(duplicate_index_url());
if (!empty($link_url))
{
$mystyle = '';
$template->block_html_head(null, $mystyle);
// get button javascript code and add to page
$code = $this->get_js_button_code();
$template->concat('PLUGIN_INDEX_CONTENT_AFTER', $code);
// Add piwishack button in the list of action icons
$template->concat('PLUGIN_INDEX_ACTIONS', '
'.$link_url.'
');
// get popup html code and add to page
$popup = $this->get_html_popup_code("index");
$template->concat('PLUGIN_INDEX_CONTENT_AFTER', $popup);
}
}
/**************************************************************************
* function: handler_picture
**************************************************************************
* in:
* out:
* Code source
**************************************************************************
* Rôle:
* Handler dans le cas des pages images : ajoute le code javascript,
* le code html du popup et l'icone d'ouverture piwishack.
*************************************************************************/
function handler_picture($pictures)
{
global $template;
$link_url = $this->get_link_icon(duplicate_index_url());
if (!empty($link_url))
{
$mystyle = '';
$template->block_html_head(null, $mystyle);
// get button javascript code and add to page
$code = $this->get_js_button_code();
$template->concat('PLUGIN_PICTURE_AFTER', $code);
// Add piwishack button in the list of action icons
$template->concat('PLUGIN_PICTURE_ACTIONS', $link_url);
// get popup html code and add to page
$popup = $this->get_html_popup_code("picture");
$template->concat('PLUGIN_PICTURE_AFTER', $popup);
}
return $pictures;
}
/**************************************************************************
* function: get_js_button_code
**************************************************************************
* in:
* out:
* Code source
**************************************************************************
* Rôle:
* Genere le code javascript de la page
*************************************************************************/
function get_js_button_code()
{
$this->loading_lang();
$link_open = l10n('open_window_piwishack');
$link_close = l10n('close_window_piwishack');
$icon_open = get_root_url() . 'plugins/piwishack/icon/controller_open.png';
$icon_close = get_root_url() . 'plugins/piwishack/icon/controller_close.png';
$code = '
';
return $code;
}
/**************************************************************************
* function: get_html_popup_code
**************************************************************************
* in:
* $pagetype (index ou picture)
* out:
* Code source
**************************************************************************
* Rôle:
* Genere le code html complet du popup piwishack
*************************************************************************/
function get_html_popup_code($pagetype)
{
$prefix = 0;
$icon_close = get_root_url() . 'plugins/piwishack/icon/controller_close.png';
$icon_open = get_root_url() . 'plugins/piwishack/icon/controller_open.png';
$this->get_data();
$listdisp = $this->config['Display'];
asort($listdisp);
$namedisp = array_keys($listdisp);
$this->loading_lang();
$popup = "
\n";
$popup .= "
Piwishack
\n";
$popup .= "
\n";
$popup .= "
" . l10n('Partage_me') . "
\n";
$popup .= "\n";
// A block is inserted for each format, bbcode and html
// but displayed only for the selected (radio) format
foreach (array("html", "bbcode") as $format)
{
$popup.= "