This commit is contained in:
Phyks 2014-02-09 15:36:39 +01:00
parent bd947487a2
commit 8bccb3134b
2 changed files with 114 additions and 104 deletions

View File

@ -143,11 +143,16 @@ function adblock_plugin_treat_events(&$events) {
} }
function adblock_plugin_setting_link(&$myUser) { function adblock_plugin_setting_link(&$myUser) {
$myUser = (isset($_SESSION['currentUser'])?unserialize($_SESSION['currentUser']):false);
if($myUser!=false) {
echo ' echo '
<li class="pointer" onclick="$(\'#main section\').hide();$(\'#main #adblockSettingsBloc\').fadeToggle(200);">Adblock</li>'; <li onclick="toggleBlocks(\'#adblockSettingsBloc\');"><a href="#adblockSettingsBloc">Adblock</a></li>';
}
} }
function adblock_plugin_setting_bloc(&$myUser) { function adblock_plugin_setting_bloc(&$myUser) {
$myUser = (isset($_SESSION['currentUser'])?unserialize($_SESSION['currentUser']):false);
if($myUser!=false) {
$adblock_constants = file_get_contents('adblock_constants.php'); $adblock_constants = file_get_contents('adblock_constants.php');
$adblock_constants = explode("\n", $adblock_constants); $adblock_constants = explode("\n", $adblock_constants);
@ -179,11 +184,11 @@ function adblock_plugin_setting_bloc(&$myUser) {
$getimagesize_available = function_exists("getimagesize") && ((ini_get("allow_url_fopen") == "1") ? true : false); $getimagesize_available = function_exists("getimagesize") && ((ini_get("allow_url_fopen") == "1") ? true : false);
echo ' echo '
<section id="adblockSettingsBloc"> <section id="adblockSettingsBloc" class="settingsPage">
<form action="action.php?action=adblock_update" method="POST"> <article>
<h2>Plugin Adblock</h2> <h2>Plugin Adblock</h2>
<p><em>Note : </em><br/> <p><em>Note : </em> You must enter a list of id of feeds in the blacklist / whitelist fields. This list must be one id per line. You can find the id of the feed you want in the address bar on the page of the feed in Leed (http://LEED_URL/index.php?action=selectedFeed&feed=ID).</p>
You must enter a list of id of feeds in the blacklist / whitelist fields. This list must be one id per line. You can find the id of the feed you want in the address bar on the page of the feed in Leed (http://LEED_URL/index.php?action=selectedFeed&feed=ID).</p> <form action="action.php?action=adblock_update" method="POST">
<fieldset> <fieldset>
<div class="flash_adblockSettingsBlock"> <div class="flash_adblockSettingsBlock">
<h3>Flash embedded contents :</h3> <h3>Flash embedded contents :</h3>
@ -198,7 +203,7 @@ function adblock_plugin_setting_bloc(&$myUser) {
<input type="radio" name="flash_adblock_default_behavior" value="0" id="flash_adblock_allowall" onchange="adblock_whitelist_blacklist(\'adblock_flash_whitelist_blacklist\', 0);" '.((!$flash_block) ? 'checked="checked"' : '').'/><label for="flash_adblock_allowall">Allow all contents (and use a blacklist)</label> <input type="radio" name="flash_adblock_default_behavior" value="0" id="flash_adblock_allowall" onchange="adblock_whitelist_blacklist(\'adblock_flash_whitelist_blacklist\', 0);" '.((!$flash_block) ? 'checked="checked"' : '').'/><label for="flash_adblock_allowall">Allow all contents (and use a blacklist)</label>
</p> </p>
<p><span id="adblock_flash_whitelist_blacklist">'.(($flash_block) ? 'Whitelist :' : 'Blacklist :').'</span></br> <p><span id="adblock_flash_whitelist_blacklist">'.(($flash_block) ? 'Blacklist :' : 'Whitelist :').'</span></br>
<textarea name="flash_adblock_list" rows="7">'.$flash_list.'</textarea> <textarea name="flash_adblock_list" rows="7">'.$flash_list.'</textarea>
</div> </div>
</fieldset> </fieldset>
@ -222,7 +227,7 @@ function adblock_plugin_setting_bloc(&$myUser) {
<input type="radio" name="img_adblock_only_mobiles" value="0" id="img_adblock_only_mobiles_no" '.((!$img_only_mobiles) ? 'checked="checked"' : '').'/><label for="img_adblock_only_mobiles_no">Block images on all devices</label> <input type="radio" name="img_adblock_only_mobiles" value="0" id="img_adblock_only_mobiles_no" '.((!$img_only_mobiles) ? 'checked="checked"' : '').'/><label for="img_adblock_only_mobiles_no">Block images on all devices</label>
</p> </p>
<p><span id="adblock_img_whitelist_blacklist">'.(($img_block) ? 'Whitelist :' : 'Blacklist :').'</span></br> <p><span id="adblock_img_whitelist_blacklist">'.(($img_block) ? 'Blacklist :' : 'Whitelist :').'</span></br>
<textarea name="img_adblock_list" rows="7">'.$img_list.'</textarea> <textarea name="img_adblock_list" rows="7">'.$img_list.'</textarea>
</div> </div>
</fieldset> </fieldset>
@ -232,13 +237,17 @@ function adblock_plugin_setting_bloc(&$myUser) {
<input type="radio" name="adblock_elegant_degradation" value="0" id="adblock_elegant_degradation_no" '.((!$elegant_degradation) ? 'checked="checked"' : '').'/><label for="adblock_elegant_degradation_no">No</label> <input type="radio" name="adblock_elegant_degradation" value="0" id="adblock_elegant_degradation_no" '.((!$elegant_degradation) ? 'checked="checked"' : '').'/><label for="adblock_elegant_degradation_no">No</label>
</p> </p>
<p id="adblock_settings_submit"> <p id="adblock_settings_submit">
<input type="submit" class="button" value="Save"/> <button type="submit" class="red">Save</button>
</p> </p>
</form> </form>
</article>
</section>'; </section>';
}
} }
function adblock_plugin_setting_update($_) { function adblock_plugin_setting_update($_) {
$myUser = (isset($_SESSION['currentUser'])?unserialize($_SESSION['currentUser']):false);
if($myUser!=false) {
if($_['action'] == 'adblock_update') { if($_['action'] == 'adblock_update') {
$flash_enabled = (int) $_['flash_adblock_enable']; $flash_enabled = (int) $_['flash_adblock_enable'];
$flash_block = (int) $_['flash_adblock_default_behavior']; $flash_block = (int) $_['flash_adblock_default_behavior'];
@ -258,6 +267,7 @@ function adblock_plugin_setting_update($_) {
else else
exit("Unable to write parameters to adblock_constants.php. Check permissions on the folders."); exit("Unable to write parameters to adblock_constants.php. Check permissions on the folders.");
} }
}
} }
Plugin::addCSS("/css/adblock_plugin_css.css"); Plugin::addCSS("/css/adblock_plugin_css.css");

View File

@ -1,8 +1,8 @@
function adblock_whitelist_blacklist(id, whitelist_blacklist) { function adblock_whitelist_blacklist(id, whitelist_blacklist) {
if(whitelist_blacklist == 0) if(whitelist_blacklist == 0)
document.getElementById(id).innerHTML = "Blacklist :";
else
document.getElementById(id).innerHTML = "Whitelist :"; document.getElementById(id).innerHTML = "Whitelist :";
else
document.getElementById(id).innerHTML = "Blacklist :";
} }
function adblock_unblock_img(span, url) { function adblock_unblock_img(span, url) {