From 9a0b61e4afed94727679eee966afb76e1add2beb Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 13 Apr 2016 16:31:06 -0700 Subject: refactor the js detection into a checkjs class which is only enabled on demand (currently only the channel and display pages). Will probably require a bit more work to hide/disable the cover photo when js is disabled. Have not actually tested without js to discover any other potential page issues. Have only confirmed that the detection class works and redirects to set a jsdisabled cookie and reload the page with that cookie+variable set if called from the channel page. --- mod/channel.php | 7 ++++--- mod/display.php | 10 +++++++--- mod/nojs.php | 3 ++- 3 files changed, 13 insertions(+), 7 deletions(-) (limited to 'mod') diff --git a/mod/channel.php b/mod/channel.php index 9119f91a6..9bc7332dc 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -54,6 +54,7 @@ function channel_content(&$a, $update = 0, $load = false) { if($load) $_SESSION['loadtime'] = datetime_convert(); + $checkjs = new Zotlabs\Web\CheckJS(); $category = $datequery = $datequery2 = ''; @@ -209,7 +210,7 @@ function channel_content(&$a, $update = 0, $load = false) { App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start'])); - if($load || ($_COOKIE['jsdisabled'] == 1)) { + if($load || ($checkjs->disabled())) { if ($mid) { $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d $item_normal AND item_wall = 1 $sql_extra limit 1", @@ -338,13 +339,13 @@ function channel_content(&$a, $update = 0, $load = false) { } - if($_COOKIE['jsdisabled'] == 1) { + if($checkjs->disabled()) { $o .= conversation($a,$items,'channel',$update,'traditional'); } else { $o .= conversation($a,$items,'channel',$update,$page_mode); } - if((! $update) || ($_COOKIE['jsdisabled'] == 1)) { + if((! $update) || ($checkjs->disabled())) { $o .= alt_pager($a,count($items)); if ($mid && $items[0]['title']) App::$page['title'] = $items[0]['title'] . " - " . App::$page['title']; diff --git a/mod/display.php b/mod/display.php index 9c50eb9c0..2844a1205 100644 --- a/mod/display.php +++ b/mod/display.php @@ -5,6 +5,10 @@ function display_content(&$a, $update = 0, $load = false) { // logger("mod-display: update = $update load = $load"); + + $checkjs = new Zotlabs\Web\CheckJS(); + + if($load) $_SESSION['loadtime'] = datetime_convert(); @@ -168,13 +172,13 @@ function display_content(&$a, $update = 0, $load = false) { $sql_extra = public_permissions_sql($observer_hash); - if(($update && $load) || ($_COOKIE['jsdisabled'] == 1)) { + if(($update && $load) || ($checkjs->disabled())) { $updateable = false; $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']),intval(App::$pager['start'])); - if($load || ($_COOKIE['jsdisabled'] == 1)) { + if($load || ($checkjs->disabled())) { $r = null; require_once('include/identity.php'); @@ -290,7 +294,7 @@ function display_content(&$a, $update = 0, $load = false) { } - if ($_COOKIE['jsdisabled'] == 1) { + if ($checkjs->disabled()) { $o .= conversation($a, $items, 'display', $update, 'traditional'); if ($items[0]['title']) App::$page['title'] = $items[0]['title'] . " - " . App::$page['title']; diff --git a/mod/nojs.php b/mod/nojs.php index 3d894d13e..c6e04a72b 100644 --- a/mod/nojs.php +++ b/mod/nojs.php @@ -4,6 +4,7 @@ function nojs_init(&$a) { setcookie('jsdisabled', 1, 0); $p = $_GET['query']; - goaway(z_root() . (($p) ? '/' . $p : '')); + $hasq = strpos($p,'?'); + goaway(z_root() . (($p) ? '/' . $p : '') . (($hasq) ? '' : '?f=' ) . '&jsdisabled=1'); } \ No newline at end of file -- cgit v1.2.3