1
1
Fork 0
Issue #2822 - Fix [Embedded content - reload the page to view]
This commit is contained in:
Michael Vogel 2016-10-25 07:31:20 +02:00 committed by GitHub
commit 75a996c4e4
12 changed files with 146 additions and 147 deletions

View file

@ -291,30 +291,31 @@ function settings_post(&$a) {
} }
if (($a->argc > 1) && ($a->argv[1] === 'display')) { if (($a->argc > 1) && ($a->argv[1] === 'display')) {
check_form_security_token_redirectOnErr('/settings/display', 'settings_display'); check_form_security_token_redirectOnErr('/settings/display', 'settings_display');
$theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : $a->user['theme']); $theme = x($_POST, 'theme') ? notags(trim($_POST['theme'])) : $a->user['theme'];
$mobile_theme = ((x($_POST,'mobile_theme')) ? notags(trim($_POST['mobile_theme'])) : ''); $mobile_theme = x($_POST, 'mobile_theme') ? notags(trim($_POST['mobile_theme'])) : '';
$nosmile = ((x($_POST,'nosmile')) ? intval($_POST['nosmile']) : 0); $nosmile = x($_POST, 'nosmile') ? intval($_POST['nosmile']) : 0;
$first_day_of_week = ((x($_POST,'first_day_of_week')) ? intval($_POST['first_day_of_week']) : 0); $first_day_of_week = x($_POST, 'first_day_of_week') ? intval($_POST['first_day_of_week']) : 0;
$noinfo = ((x($_POST,'noinfo')) ? intval($_POST['noinfo']) : 0); $noinfo = x($_POST, 'noinfo') ? intval($_POST['noinfo']) : 0;
$infinite_scroll = ((x($_POST,'infinite_scroll')) ? intval($_POST['infinite_scroll']) : 0); $infinite_scroll = x($_POST, 'infinite_scroll') ? intval($_POST['infinite_scroll']) : 0;
$no_auto_update = ((x($_POST,'no_auto_update')) ? intval($_POST['no_auto_update']) : 0); $no_auto_update = x($_POST, 'no_auto_update') ? intval($_POST['no_auto_update']) : 0;
$browser_update = ((x($_POST,'browser_update')) ? intval($_POST['browser_update']) : 0); $bandwidth_saver = x($_POST, 'bandwidth_saver') ? intval($_POST['bandwidth_saver']) : 0;
$browser_update = x($_POST, 'browser_update') ? intval($_POST['browser_update']) : 0;
if ($browser_update != -1) { if ($browser_update != -1) {
$browser_update = $browser_update * 1000; $browser_update = $browser_update * 1000;
if ($browser_update < 10000) if ($browser_update < 10000)
$browser_update = 10000; $browser_update = 10000;
} }
$itemspage_network = ((x($_POST,'itemspage_network')) ? intval($_POST['itemspage_network']) : 40); $itemspage_network = x($_POST,'itemspage_network') ? intval($_POST['itemspage_network']) : 40;
if($itemspage_network > 100) if ($itemspage_network > 100) {
$itemspage_network = 100; $itemspage_network = 100;
$itemspage_mobile_network = ((x($_POST,'itemspage_mobile_network')) ? intval($_POST['itemspage_mobile_network']) : 20); }
if($itemspage_mobile_network > 100) $itemspage_mobile_network = x($_POST,'itemspage_mobile_network') ? intval($_POST['itemspage_mobile_network']) : 20;
if ($itemspage_mobile_network > 100) {
$itemspage_mobile_network = 100; $itemspage_mobile_network = 100;
}
if($mobile_theme !== '') { if($mobile_theme !== '') {
set_pconfig(local_user(),'system','mobile_theme',$mobile_theme); set_pconfig(local_user(),'system','mobile_theme',$mobile_theme);
@ -328,7 +329,7 @@ function settings_post(&$a) {
set_pconfig(local_user(), 'system', 'ignore_info' , $noinfo); set_pconfig(local_user(), 'system', 'ignore_info' , $noinfo);
set_pconfig(local_user(), 'system', 'infinite_scroll' , $infinite_scroll); set_pconfig(local_user(), 'system', 'infinite_scroll' , $infinite_scroll);
set_pconfig(local_user(), 'system', 'no_auto_update' , $no_auto_update); set_pconfig(local_user(), 'system', 'no_auto_update' , $no_auto_update);
set_pconfig(local_user(), 'system', 'bandwidth_saver' , $bandwidth_saver);
if ($theme == $a->user['theme']) { if ($theme == $a->user['theme']) {
// call theme_post only if theme has not been changed // call theme_post only if theme has not been changed
@ -975,6 +976,9 @@ function settings_content(&$a) {
$no_auto_update = get_pconfig(local_user(),'system','no_auto_update'); $no_auto_update = get_pconfig(local_user(),'system','no_auto_update');
$no_auto_update = (($no_auto_update===false)? '0': $no_auto_update); // default if not set: 0 $no_auto_update = (($no_auto_update===false)? '0': $no_auto_update); // default if not set: 0
$bandwidth_saver = get_pconfig(local_user(), 'system', 'bandwidth_saver');
$bandwidth_saver = (($bandwidth_saver === false) ? '0' : $bandwidth_saver); // default if not set: 0
$theme_config = ""; $theme_config = "";
if (($themeconfigfile = get_theme_config_file($theme_selected)) != null) { if (($themeconfigfile = get_theme_config_file($theme_selected)) != null) {
require_once($themeconfigfile); require_once($themeconfigfile);
@ -1000,6 +1004,7 @@ function settings_content(&$a) {
'$noinfo' => array('noinfo', t("Don't show notices"), $noinfo, ''), '$noinfo' => array('noinfo', t("Don't show notices"), $noinfo, ''),
'$infinite_scroll' => array('infinite_scroll', t("Infinite scroll"), $infinite_scroll, ''), '$infinite_scroll' => array('infinite_scroll', t("Infinite scroll"), $infinite_scroll, ''),
'$no_auto_update' => array('no_auto_update', t("Automatic updates only at the top of the network page"), $no_auto_update, 'When disabled, the network page is updated all the time, which could be confusing while reading.'), '$no_auto_update' => array('no_auto_update', t("Automatic updates only at the top of the network page"), $no_auto_update, 'When disabled, the network page is updated all the time, which could be confusing while reading.'),
'$bandwidth_saver' => array('bandwidth_saver', t('Bandwith Saver Mode'), $bandwidth_saver, 'When enabled, embedded content is not displayed on automatic updates, they only show on page reload.'),
'$d_tset' => t('General Theme Settings'), '$d_tset' => t('General Theme Settings'),
'$d_ctset' => t('Custom Theme Settings'), '$d_ctset' => t('Custom Theme Settings'),
@ -1347,4 +1352,3 @@ function settings_content(&$a) {
return $o; return $o;
} }

View file

@ -2,7 +2,7 @@
// See update_profile.php for documentation // See update_profile.php for documentation
require_once('mod/community.php'); require_once("mod/community.php");
function update_community_content(&$a) { function update_community_content(&$a) {
@ -15,7 +15,8 @@ function update_community_content(&$a) {
$replace = "<img\${1} dst=\"\${2}\""; $replace = "<img\${1} dst=\"\${2}\"";
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />'; if (get_pconfig(local_user(), "system", "bandwith_saver")) {
$replace = "<br />".t("[Embedded content - reload page to view]")."<br />";
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i"; $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i"; $pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
@ -24,10 +25,10 @@ function update_community_content(&$a) {
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i"; $pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
}
echo str_replace("\t",' ',$text); echo str_replace("\t", " ", $text);
echo "</section>"; echo "</section>";
echo "</body></html>\r\n"; echo "</body></html>\r\n";
killme(); killme();
} }

View file

@ -2,12 +2,12 @@
// See update_profile.php for documentation // See update_profile.php for documentation
require_once('mod/display.php'); require_once("mod/display.php");
require_once('include/group.php'); require_once("include/group.php");
function update_display_content(&$a) { function update_display_content(&$a) {
$profile_uid = intval($_GET['p']); $profile_uid = intval($_GET["p"]);
header("Content-type: text/html"); header("Content-type: text/html");
echo "<!DOCTYPE html><html><body>\r\n"; echo "<!DOCTYPE html><html><body>\r\n";
@ -19,7 +19,8 @@ function update_display_content(&$a) {
$replace = "<img\${1} dst=\"\${2}\""; $replace = "<img\${1} dst=\"\${2}\"";
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />'; if (get_pconfig(local_user(), "system", "bandwith_saver")) {
$replace = "<br />".t("[Embedded content - reload page to view]")."<br />";
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i"; $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i"; $pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
@ -28,11 +29,10 @@ function update_display_content(&$a) {
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i"; $pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
}
echo str_replace("\t", " ", $text);
echo str_replace("\t",' ',$text);
echo "</section>"; echo "</section>";
echo "</body></html>\r\n"; echo "</body></html>\r\n";
killme(); killme();
} }

View file

@ -2,27 +2,29 @@
// See update_profile.php for documentation // See update_profile.php for documentation
require_once('mod/network.php'); require_once("mod/network.php");
require_once('include/group.php'); require_once("include/group.php");
function update_network_content(&$a) { function update_network_content(&$a) {
$profile_uid = intval($_GET['p']); $profile_uid = intval($_GET["p"]);
header("Content-type: text/html"); header("Content-type: text/html");
echo "<!DOCTYPE html><html><body>\r\n"; echo "<!DOCTYPE html><html><body>\r\n";
echo "<section>"; echo "<section>";
if (!get_pconfig($profile_uid, "system", "no_auto_update") OR ($_GET['force'] == 1)) if (!get_pconfig($profile_uid, "system", "no_auto_update") OR ($_GET["force"] == 1)) {
$text = network_content($a, $profile_uid); $text = network_content($a, $profile_uid);
else } else {
$text = ""; $text = "";
}
$pattern = "/<img([^>]*) src=\"([^\"]*)\"/"; $pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
$replace = "<img\${1} dst=\"\${2}\""; $replace = "<img\${1} dst=\"\${2}\"";
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />'; if (get_pconfig(local_user(), "system", "bandwith_saver")) {
$replace = "<br />".t("[Embedded content - reload page to view]")."<br />";
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i"; $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i"; $pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
@ -31,11 +33,10 @@ function update_network_content(&$a) {
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i"; $pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
}
echo str_replace("\t", " ", $text);
echo str_replace("\t",' ',$text);
echo "</section>"; echo "</section>";
echo "</body></html>\r\n"; echo "</body></html>\r\n";
killme(); killme();
} }

View file

@ -1,17 +1,15 @@
<?php <?php
/** /**
* Module: update_profile * Module: update_notes
* Purpose: AJAX synchronisation of profile page * Purpose: AJAX synchronisation of notes page
*
*/ */
require_once("mod/notes.php");
require_once('mod/notes.php');
function update_notes_content(&$a) { function update_notes_content(&$a) {
$profile_uid = intval($_GET['p']); $profile_uid = intval($_GET["p"]);
header("Content-type: text/html"); header("Content-type: text/html");
echo "<!DOCTYPE html><html><body>\r\n"; echo "<!DOCTYPE html><html><body>\r\n";
@ -34,7 +32,8 @@ function update_notes_content(&$a) {
$replace = "<img\${1} dst=\"\${2}\""; $replace = "<img\${1} dst=\"\${2}\"";
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />'; if (get_pconfig(local_user(), "system", "bandwith_saver")) {
$replace = "<br />".t("[Embedded content - reload page to view]")."<br />";
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i"; $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i"; $pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
@ -43,14 +42,11 @@ function update_notes_content(&$a) {
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i"; $pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
}
/** // reportedly some versions of MSIE don't handle tabs in XMLHttpRequest documents very well
* reportedly some versions of MSIE don't handle tabs in XMLHttpRequest documents very well echo str_replace("\t", " ", $text);
*/
echo str_replace("\t",' ',$text);
echo "</section>"; echo "</section>";
echo "</body></html>\r\n"; echo "</body></html>\r\n";
killme(); killme();
} }

View file

@ -3,33 +3,26 @@
/** /**
* Module: update_profile * Module: update_profile
* Purpose: AJAX synchronisation of profile page * Purpose: AJAX synchronisation of profile page
*
*/ */
require_once("mod/profile.php");
require_once('mod/profile.php');
function update_profile_content(&$a) { function update_profile_content(&$a) {
$profile_uid = intval($_GET['p']); $profile_uid = intval($_GET["p"]);
header("Content-type: text/html"); header("Content-type: text/html");
echo "<!DOCTYPE html><html><body>\r\n"; echo "<!DOCTYPE html><html><body>\r\n";
/** // We can remove this hack once Internet Explorer recognises HTML5 natively
* We can remove this hack once Internet Explorer recognises HTML5 natively
*/
echo "<section>"; echo "<section>";
/** /**
*
* Grab the page inner contents by calling the content function from the profile module directly, * Grab the page inner contents by calling the content function from the profile module directly,
* but move any image src attributes to another attribute name. This is because * but move any image src attributes to another attribute name. This is because
* some browsers will prefetch all the images for the page even if we don't need them. * some browsers will prefetch all the images for the page even if we don't need them.
* The only ones we need to fetch are those for new page additions, which we'll discover * The only ones we need to fetch are those for new page additions, which we'll discover
* on the client side and then swap the image back. * on the client side and then swap the image back.
*
*/ */
$text = profile_content($a, $profile_uid); $text = profile_content($a, $profile_uid);
@ -38,7 +31,8 @@ function update_profile_content(&$a) {
$replace = "<img\${1} dst=\"\${2}\""; $replace = "<img\${1} dst=\"\${2}\"";
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />'; if (get_pconfig(local_user(), "system", "bandwith_saver")) {
$replace = "<br />".t("[Embedded content - reload page to view]")."<br />";
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i"; $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i"; $pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
@ -47,14 +41,11 @@ function update_profile_content(&$a) {
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i"; $pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
$text = preg_replace($pattern, $replace, $text); $text = preg_replace($pattern, $replace, $text);
}
/** // reportedly some versions of MSIE don't handle tabs in XMLHttpRequest documents very well
* reportedly some versions of MSIE don't handle tabs in XMLHttpRequest documents very well echo str_replace("\t", " ", $text);
*/
echo str_replace("\t",' ',$text);
echo "</section>"; echo "</section>";
echo "</body></html>\r\n"; echo "</body></html>\r\n";
killme(); killme();
} }

View file

@ -1,5 +1,6 @@
<div class='field checkbox' id='div_id_{{$field.0}}'> <div class="field checkbox" id="div_id_{{$field.0}}">
<label for='id_{{$field.0}}'>{{$field.1}}</label> <label for="id_{{$field.0}}">{{$field.1}}</label>
<input type="checkbox" name='{{$field.0}}' id='id_{{$field.0}}' aria-describedby='{{$field.0}}_tip' value="1" {{if $field.2}}checked="checked"{{/if}}> <input type="hidden" name="{{$field.0}}" value="0">
<span class='field_help' role='tooltip' id='{{$field.0}}_tip'>{{$field.3}}</span> <input type="checkbox" name="{{$field.0}}" id="id_{{$field.0}}" aria-describedby="{{$field.0}}_tip" value="1" {{if $field.2}}checked="checked"{{/if}}>
<span class="field_help" role="tooltip" id="{{$field.0}}_tip">{{$field.3}}</span>
</div> </div>

View file

@ -13,6 +13,7 @@
{{include file="field_checkbox.tpl" field=$nosmile}} {{include file="field_checkbox.tpl" field=$nosmile}}
{{include file="field_checkbox.tpl" field=$noinfo}} {{include file="field_checkbox.tpl" field=$noinfo}}
{{include file="field_checkbox.tpl" field=$infinite_scroll}} {{include file="field_checkbox.tpl" field=$infinite_scroll}}
{{include file="field_checkbox.tpl" field=$bandwidth_saver}}
<h2>{{$calendar_title}}</h2> <h2>{{$calendar_title}}</h2>
{{include file="field_select.tpl" field=$first_day_of_week}} {{include file="field_select.tpl" field=$first_day_of_week}}

View file

@ -1,7 +1,8 @@
<div class='field checkbox' id='div_id_{{$field.0}}'> <div class="field checkbox" id="div_id_{{$field.0}}">
<label id='label_id_{{$field.0}}' for='id_{{$field.0}}'>{{$field.1}}</label> <label id="label_id_{{$field.0}}" for="id_{{$field.0}}">{{$field.1}}</label>
<input type="checkbox" name='{{$field.0}}' id='id_{{$field.0}}' value="1" {{if $field.2}}checked="checked"{{/if}}><br /> <input type="hidden" name="{{$field.0}}" value="0">
<span class='field_help' id='help_id_{{$field.0}}'>{{$field.3}}</span> <input type="checkbox" name="{{$field.0}}" id="id_{{$field.0}}" value="1" {{if $field.2}}checked="checked"{{/if}}><br />
<span class="field_help" id="help_id_{{$field.0}}">{{$field.3}}</span>
</div> </div>

View file

@ -1,6 +1,7 @@
<div class="field checkbox" id='div_id_{{$field.0}}'> <div class="field checkbox" id="div_id_{{$field.0}}">
<input type="checkbox" name='{{$field.0}}' id='id_{{$field.0}}' value="1" {{if $field.2}}checked="checked"{{/if}}> <input type="hidden" name="{{$field.0}}" value="0">
<input type="checkbox" name="{{$field.0}}" id="id_{{$field.0}}" value="1" {{if $field.2}}checked="checked"{{/if}}>
<label for="id_{{$field.0}}"> <label for="id_{{$field.0}}">
{{$field.1}} {{$field.1}}
<p class="help-block">{{$field.3}}</p> <p class="help-block">{{$field.3}}</p>

View file

@ -70,6 +70,7 @@
{{include file="field_checkbox.tpl" field=$nosmile}} {{include file="field_checkbox.tpl" field=$nosmile}}
{{include file="field_checkbox.tpl" field=$noinfo}} {{include file="field_checkbox.tpl" field=$noinfo}}
{{include file="field_checkbox.tpl" field=$infinite_scroll}} {{include file="field_checkbox.tpl" field=$infinite_scroll}}
{{include file="field_checkbox.tpl" field=$bandwidth_saver}}
<div class="form-group pull-right settings-submit-wrapper" > <div class="form-group pull-right settings-submit-wrapper" >
<button type="submit" name="submit" class="btn btn-primary" value="{{$submit|escape:'html'}}">{{$submit}}</button> <button type="submit" name="submit" class="btn btn-primary" value="{{$submit|escape:'html'}}">{{$submit}}</button>

View file

@ -1,7 +1,8 @@
<div class='field checkbox' id='div_id_{{$field.0}}'> <div class="field checkbox" id="div_id_{{$field.0}}">
<label id='label_id_{{$field.0}}' for='id_{{$field.0}}'>{{$field.1}}</label> <label id="label_id_{{$field.0}}" for="id_{{$field.0}}">{{$field.1}}</label>
<input type="checkbox" name='{{$field.0}}' id='id_{{$field.0}}' value="1" {{if $field.2}}checked="checked"{{/if}}><br /> <input type="hidden" name="{{$field.0}}" value="0">
<span class='field_help' id='help_id_{{$field.0}}'>{{$field.3}}</span> <input type="checkbox" name="{{$field.0}}" id="id_{{$field.0}}" value="1" {{if $field.2}}checked="checked"{{/if}}><br />
<span class="field_help" id="help_id_{{$field.0}}">{{$field.3}}</span>
</div> </div>