From 9eaf891242af6fa44a7cba5dc2aff15fc5292fb4 Mon Sep 17 00:00:00 2001 From: Phyks Date: Sun, 4 Aug 2013 15:11:29 +0200 Subject: [PATCH] Added settings page for the plugin (but plugin still not functional) --- .gitignore | 0 adblock.plugin.enabled.php | 95 +++++++++++++++++++++++++++++++++++--- adblock_constants.php | 6 +++ css/adblock_plugin_css.css | 11 +++++ js/adblock_plugin_js.js | 6 +++ 5 files changed, 112 insertions(+), 6 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 adblock.plugin.enabled.php create mode 100644 adblock_constants.php create mode 100644 css/adblock_plugin_css.css create mode 100644 js/adblock_plugin_js.js diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/adblock.plugin.enabled.php b/adblock.plugin.enabled.php old mode 100644 new mode 100755 index 12916ac..6002879 --- a/adblock.plugin.enabled.php +++ b/adblock.plugin.enabled.php @@ -6,14 +6,97 @@ @licence BEERWARE @version 2.0.0 @description Le plugin adblock permet d'empêcher le lancement automatique de contenus embed de type "flash" et notamment des pubs dans les flux RSS. Par défaut, tous les contenus sont bloqués. Il est possible de modifier ce comportement et de régler finement par flux. -*/ + */ -function clean_events(&$events){ - foreach($events as $event) { - $old_content = $event->getContent(); - } +function adblock_plugin_treatment(&$events) { + foreach($events as $event) { + $old_content = $event->getContent(); + } } -Plugin::addHook("index_post_treatment", "clean_events"); +function adblock_plugin_setting_link(&$myUser) { + echo ' +
  • Adblock
  • '; +} + +function adblock_plugin_setting_bloc(&$myUser) { + $adblock_constants = file_get_contents('plugins/adblock/adblock_constants.php'); + + $adblock_constants = explode("\n", $adblock_constants); + + foreach($adblock_constants as $adblock_constant) { + if(trim($adblock_constant) != "") { + $adblock_constant = explode("=", $adblock_constant); + $adblock_params[trim($adblock_constant[0])] = trim($adblock_constant[1]); + } + } + + $flash_enabled = ($adblock_params["flash_enabled"] == "1") ? true : false; + $flash_block = ($adblock_params["flash_block"] == "1") ? true : false; + $flash_list = ""; + $img_enabled = ($adblock_params["img_enabled"] == "1") ? true : false; + $img_block = ($adblock_params["img_block"] == "1") ? true : false; + $img_list = ""; + + echo ' +
    +
    +

    Plugin Adblock

    +
    +
    +

    Flash embedded contents :

    +

    + Enable / Disable blocking of flash contents in events :
    +
    + +

    + +

    Default behavior :
    +
    + +

    + +

    '.(($flash_block) ? 'Blacklist :' : 'Whitelist :').'
    + +

    +
    + +
    +
    +

    Images :

    +

    + Enable / Disable blocking of images in events :
    +
    + +

    + +

    Default behavior :
    +
    + +

    + +

    '.(($img_block) ? 'Blacklist :' : 'Whitelist :').'
    + +

    +
    +

    + +

    +
    +
    '; +} + +function adblock_plugin_setting_update($_) { + +} + +Plugin::addCSS("/css/adblock_plugin_css.css"); +Plugin::addJS("/js/adblock_plugin_js.js"); + +Plugin::addHook("index_post_treatment", "adblock_plugin_treatment"); + +Plugin::addHook("setting_post_link", "adblock_plugin_setting_link"); +Plugin::addHook("setting_post_section", "adblock_plugin_setting_bloc"); +Plugin::addHook("action_post_case", "adblock_plugin_setting_update"); ?> diff --git a/adblock_constants.php b/adblock_constants.php new file mode 100644 index 0000000..c3b1910 --- /dev/null +++ b/adblock_constants.php @@ -0,0 +1,6 @@ +flash_enabled = 1 +flash_block = 1 +flash_list = +img_enabled = 1 +img_block = 1 +img_list = diff --git a/css/adblock_plugin_css.css b/css/adblock_plugin_css.css new file mode 100644 index 0000000..6ecca10 --- /dev/null +++ b/css/adblock_plugin_css.css @@ -0,0 +1,11 @@ +#adblockSettingsBloc { + display: none; +} + +#adblockSettingsBloc textarea { + width: 75%; +} + +#adblock_settings_submit { + text-align: center; +} diff --git a/js/adblock_plugin_js.js b/js/adblock_plugin_js.js new file mode 100644 index 0000000..ff5e6ab --- /dev/null +++ b/js/adblock_plugin_js.js @@ -0,0 +1,6 @@ +function adblock_whitelist_blacklist(id, whitelist_blacklist) { + if(whitelist_blacklist == 0) + document.getElementById(id).innerHTML = "Whitelist :"; + else + document.getElementById(id).innerHTML = "Blacklist :"; +}