From 693b6d0fd4e2c1d30d0951f436566ecc54fd65c2 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 15 Oct 2013 00:43:11 +0200 Subject: [PATCH] Infinite scroll: At the end of the network page new content is loaded automatically --- index.php | 79 ++++++++++++++++++++++++++++- mod/settings.php | 23 +++++---- view/templates/settings_display.tpl | 1 + 3 files changed, 93 insertions(+), 10 deletions(-) diff --git a/index.php b/index.php index 8784b5d0eb..39b4337f3c 100644 --- a/index.php +++ b/index.php @@ -108,6 +108,7 @@ if((x($_GET,'zrl')) && (!$install && !$maintenance)) { * * What we really need to do is output the raw headers ourselves so we can keep them separate. * + */ // header('Link: <' . $a->get_baseurl() . '/amcd>; rel="acct-mgmt";'); @@ -118,7 +119,6 @@ if((x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module == if(! x($_SESSION,'authenticated')) header('X-Account-Management-Status: none'); - /* set up page['htmlhead'] and page['end'] for the modules to use */ $a->page['htmlhead'] = ''; $a->page['end'] = ''; @@ -428,6 +428,83 @@ else $a->page['htmlhead'] = str_replace('{{$stylesheet}}',$stylesheet,$a->page['htmlhead']); //$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array('$stylesheet' => $stylesheet)); +if ($_GET["mode"] == "raw") { + $doc = new DOMDocument(); + + $target = new DOMDocument(); + $target->loadXML(""); + + $content = mb_convert_encoding($a->page["content"], 'HTML-ENTITIES', "UTF-8"); + + @$doc->loadHTML($content); + + $xpath = new DomXPath($doc); + + $list = $xpath->query("//*[contains(@id,'tread-wrapper-')]"); /* */ + + foreach ($list as $item) { + + $item = $target->importNode($item, true); + + // And then append it to the target + $target->documentElement->appendChild($item); + } + + header("Content-type: text/html; charset=utf-8"); + + echo substr($target->saveHTML(), 6, -8); + + session_write_close(); + exit; + +} elseif (get_pconfig(local_user(),'system','infinite_scroll') AND ($_GET["q"] == "network")) { + if (is_string($_GET["page"])) + $pageno = $_GET["page"]; + else + $pageno = 1; + + $reload_uri = ""; + + foreach ($_GET AS $param => $value) + if (($param != "page") AND ($param != "q")) + $reload_uri .= "&".$param."=".$value; + +$a->page['htmlhead'] .= <<< EOT + + +EOT; + +} + $page = $a->page; $profile = $a->profile; diff --git a/mod/settings.php b/mod/settings.php index 12f7910cce..a75230f339 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -259,7 +259,8 @@ function settings_post(&$a) { $theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : $a->user['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); + $infinite_scroll = ((x($_POST,'infinite_scroll')) ? intval($_POST['infinite_scroll']) : 0); $browser_update = ((x($_POST,'browser_update')) ? intval($_POST['browser_update']) : 0); $browser_update = $browser_update * 1000; if($browser_update < 10000) @@ -281,6 +282,7 @@ function settings_post(&$a) { set_pconfig(local_user(),'system','itemspage_network', $itemspage_network); set_pconfig(local_user(),'system','itemspage_mobile_network', $itemspage_mobile_network); set_pconfig(local_user(),'system','no_smilies',$nosmile); + set_pconfig(local_user(),'system','infinite_scroll',$infinite_scroll); if ($theme == $a->user['theme']){ @@ -816,7 +818,7 @@ function settings_content(&$a) { } $theme_selected = (!x($_SESSION,'theme')? $default_theme : $_SESSION['theme']); $mobile_theme_selected = (!x($_SESSION,'mobile-theme')? $default_mobile_theme : $_SESSION['mobile-theme']); - + $browser_update = intval(get_pconfig(local_user(), 'system','update_interval')); $browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds @@ -824,17 +826,19 @@ function settings_content(&$a) { $itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : 40); // default if not set: 40 items $itemspage_mobile_network = intval(get_pconfig(local_user(), 'system','itemspage_mobile_network')); $itemspage_mobile_network = (($itemspage_mobile_network > 0 && $itemspage_mobile_network < 101) ? $itemspage_mobile_network : 20); // default if not set: 20 items - + $nosmile = get_pconfig(local_user(),'system','no_smilies'); $nosmile = (($nosmile===false)? '0': $nosmile); // default if not set: 0 + $infinite_scroll = get_pconfig(local_user(),'system','infinite_scroll'); + $infinite_scroll = (($infinite_scroll===false)? '0': $infinite_scroll); // default if not set: 0 $theme_config = ""; if( ($themeconfigfile = get_theme_config_file($theme_selected)) != null){ require_once($themeconfigfile); $theme_config = theme_content($a); } - + $tpl = get_markup_template("settings_display.tpl"); $o = replace_macros($tpl, array( '$ptitle' => t('Display Settings'), @@ -842,17 +846,18 @@ function settings_content(&$a) { '$submit' => t('Submit'), '$baseurl' => $a->get_baseurl(true), '$uid' => local_user(), - + '$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes, true), '$mobile_theme' => array('mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, false), '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')), '$itemspage_network' => array('itemspage_network', t("Number of items to display per page:"), $itemspage_network, t('Maximum of 100 items')), '$itemspage_mobile_network' => array('itemspage_mobile_network', t("Number of items to display per page when viewed from mobile device:"), $itemspage_mobile_network, t('Maximum of 100 items')), '$nosmile' => array('nosmile', t("Don't show emoticons"), $nosmile, ''), - + '$infinite_scroll' => array('infinite_scroll', t("Infinite scroll"), $infinite_scroll, ''), + '$theme_config' => $theme_config, )); - + $tpl = get_markup_template("settings_display_end.tpl"); $a->page['end'] .= replace_macros($tpl, array( '$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes) @@ -860,8 +865,8 @@ function settings_content(&$a) { return $o; } - - + + /* * ACCOUNT SETTINGS */ diff --git a/view/templates/settings_display.tpl b/view/templates/settings_display.tpl index 9107512965..5da575049f 100644 --- a/view/templates/settings_display.tpl +++ b/view/templates/settings_display.tpl @@ -14,6 +14,7 @@ {{include file="field_input.tpl" field=$itemspage_mobile_network}} {{include file="field_input.tpl" field=$ajaxint}} {{include file="field_checkbox.tpl" field=$nosmile}} +{{include file="field_checkbox.tpl" field=$infinite_scroll}}
-- 2.39.5