', false);
}
if ($escaped !== array()) {
diff --git a/data_custom/set_raw_page.php b/data_custom/set_raw_page.php
new file mode 100644
index 0000000..894cfbb
--- /dev/null
+++ b/data_custom/set_raw_page.php
@@ -0,0 +1,44 @@
+' . "\n" . 'Critical startup errorComposr startup error
The second most basic Composr startup file, sources/global.php, could not be located. This is almost always due to an incomplete upload of the Composr system, so please check all files are uploaded correctly.
Once all Composr files are in place, Composr must actually be installed by running the installer. You must be seeing this message either because your system has become corrupt since installation, or because you have uploaded some but not all files from our manual installer package: the quick installer is easier, so you might consider using that instead.
ocProducts maintains full documentation for all procedures and tools, especially those for installation. These may be found on the Composr website. If you are unable to easily solve this problem, we may be contacted from our website and can help resolve it for you.
Composr is a website engine created by ocProducts.
');
+}
+require($FILE_BASE . '/sources/global.php');
+
+require_code('sets');
+set_raw_page_script();
diff --git a/themes/default/templates_custom/NEWS_ENTRY_SCREEN.tpl b/themes/default/templates_custom/NEWS_ENTRY_SCREEN.tpl
new file mode 100644
index 0000000..cc8b3a7
--- /dev/null
+++ b/themes/default/templates_custom/NEWS_ENTRY_SCREEN.tpl
@@ -0,0 +1,107 @@
+{+START,INCLUDE,SET_NAV}
+ SET=site:news
+ VALID_NODE_TYPES=news
+ SKIP=
+ PAGE_LINK=site:news:view:{ID}
+{+END}
diff --git a/themes/default/templates_custom/GALLERY_ENTRY_SCREEN.tpl b/themes/default/templates_custom/GALLERY_ENTRY_SCREEN.tpl
new file mode 100644
index 0000000..3c73caa
--- /dev/null
+++ b/themes/default/templates_custom/GALLERY_ENTRY_SCREEN.tpl
@@ -0,0 +1,190 @@
+ {+START,INCLUDE,SET_NAV}
+ SET=site:galleries
+ VALID_NODE_TYPES=image,video
+ SKIP=
+ PAGE_LINK=site:galleries:{MEDIA_TYPE}:{ID}
+ {+END}
diff --git a/themes/default/templates_custom/DOWNLOAD_SCREEN.tpl b/themes/default/templates_custom/DOWNLOAD_SCREEN.tpl
new file mode 100644
index 0000000..dc6a167
--- /dev/null
+++ b/themes/default/templates_custom/DOWNLOAD_SCREEN.tpl
@@ -0,0 +1,227 @@
+{+START,INCLUDE,SET_NAV}
+ SET=site:downloads
+ VALID_NODE_TYPES=download
+ SKIP=
+ PAGE_LINK=site:downloads:entry:{ID}
+{+END}
diff --git a/themes/default/templates_custom/COMCODE_PAGE_SCREEN.tpl b/themes/default/templates_custom/COMCODE_PAGE_SCREEN.tpl
new file mode 100644
index 0000000..5eb9255
--- /dev/null
+++ b/themes/default/templates_custom/COMCODE_PAGE_SCREEN.tpl
@@ -0,0 +1,71 @@
+{+START,IF,{$NOR,{IS_PANEL},{BEING_INCLUDED}}}
+ {+START,INCLUDE,SET_NAV}
+ SET=:
+ VALID_NODE_TYPES=comcode_page,root
+ SKIP=site:,adminzone:
+ PAGE_LINK={$ZONE}:{+START,IF,{$NEQ,{NAME},start}}{NAME}{+END}
+ {+END}
+{+END}
diff --git a/themes/default/templates_custom/CNS_TOPIC_SCREEN.tpl b/themes/default/templates_custom/CNS_TOPIC_SCREEN.tpl
new file mode 100644
index 0000000..b9371f8
--- /dev/null
+++ b/themes/default/templates_custom/CNS_TOPIC_SCREEN.tpl
@@ -0,0 +1,10 @@
+{+START,INCLUDE,SET_NAV}
+ SET=forum:forumview
+ VALID_NODE_TYPES=topic
+ SKIP=
+ PAGE_LINK=forum:topicview:id={ID}
+{+END}
diff --git a/themes/default/templates_custom/CALENDAR_EVENT_SCREEN.tpl b/themes/default/templates_custom/CALENDAR_EVENT_SCREEN.tpl
new file mode 100644
index 0000000..3b01911
--- /dev/null
+++ b/themes/default/templates_custom/CALENDAR_EVENT_SCREEN.tpl
@@ -0,0 +1,10 @@
+{+START,INCLUDE,SET_NAV}
+ SET=site:calendar
+ VALID_NODE_TYPES=event
+ SKIP=
+ PAGE_LINK=site:calendar:view:{ID}
+{+END}
diff --git a/themes/default/javascript_custom/sets.js b/themes/default/javascript_custom/sets.js
new file mode 100644
index 0000000..61a83e6
--- /dev/null
+++ b/themes/default/javascript_custom/sets.js
@@ -0,0 +1,181 @@
+if (typeof window.set_cached_pages == 'undefined') {
+ window.set_cached_pages = {};
+ window.set_nav_locked = false;
+
+ window.addEventListener('popstate', _goto_set_page_history);
+
+ window.addEventListener('DOMContentLoaded', function() {
+ save_set_state(window.location.href);
+
+ // Code for swiping...
+
+ // https://gist.github.com/SleepWalker/da5636b1abcbaff48c4d
+ var pageWidth = window.innerWidth || document.body.clientWidth;
+ var horizontalThreshold = Math.floor(0.3 * pageWidth);
+ var verticalThreshold = 20; // Low, as we want to give up/down precedence to make it not swipe when scrolling
+ var touchstartX = 0;
+ var touchstartY = 0;
+ var touchendX = 0;
+ var touchendY = 0;
+
+ var limit = Math.tan(45 * 1.5 / 180 * Math.PI);
+ var gestureZone = document.getElementById('page_content');
+
+ gestureZone.addEventListener('touchstart', function(event) {
+ touchstartX = event.changedTouches[0].screenX;
+ touchstartY = event.changedTouches[0].screenY;
+ }, false);
+
+ gestureZone.addEventListener('touchend', function(event) {
+ touchendX = event.changedTouches[0].screenX;
+ touchendY = event.changedTouches[0].screenY;
+ handleGesture(event);
+ }, false);
+
+ function handleGesture(e) {
+ var navigate_to = null;
+
+ var x = touchendX - touchstartX;
+ var y = touchendY - touchstartY;
+ var xy = Math.abs(x / y);
+ var yx = Math.abs(y / x);
+ if (Math.abs(y) > verticalThreshold) {
+ // Up/down has precedence, as that's just scrolling the page
+ if (xy <= limit) {
+ if (y < 0) {
+ console.log("swipe up");
+ } else {
+ console.log("swipe down");
+ }
+ }
+ } else if (Math.abs(x) > horizontalThreshold) {
+ if (yx <= limit) {
+ if (x < 0) {
+ navigate_to = document.getElementById('set_nav_next');
+ console.log("swipe left");
+ } else {
+ navigate_to = document.getElementById('set_nav_prev');
+ console.log("swipe right");
+ }
+ }
+ } else {
+ console.log("tap");
+ }
+ if ((navigate_to !== null) && (navigate_to.href)) {
+ try {
+ goto_set_page(navigate_to.href, true);
+ }
+ catch (e) {}
+ }
+ }
+ });
+}
+
+function goto_set_page(url, swipe)
+{
+ if (window.set_nav_locked) {
+ return;
+ }
+
+ if ((typeof window.set_cached_pages[url] == 'undefined') || (window.set_cached_pages[url] === false)) {
+ window.set_nav_locked = true;
+
+ _load_set_page(url, function(html, title, body_classname) {
+ window.set_nav_locked = false;
+
+ var page_content = document.getElementById('page_content');
+ if (page_content) {
+ set_inner_html(page_content,'
{!LOADING;^}<\/span><\/div><\/div><\/div>');
+ }
+
+ _goto_set_page(url, html, title, body_classname, swipe);
+ save_set_state(url);
+ });
+ return false;
+ }
+
+ _goto_set_page(url, window.set_cached_pages[url].html, window.set_cached_pages[url].title, window.set_cached_pages[url].body_classname, swipe);
+ save_set_state(url);
+ return false;
+}
+
+function _goto_set_page(url, html, title, body_classname, swipe)
+{
+ if (!swipe) {
+ window.scrollTo(0, 0);
+ }
+
+ var page_content = document.getElementById('page_content');
+
+ set_inner_html(page_content, html);
+ document.title = title;
+ document.body.className = body_classname;
+
+ window.setTimeout(function() {
+ var prev=document.getElementById('set_nav_prev');
+ if (prev) cache_set_page(prev.href);
+
+ var next=document.getElementById('set_nav_next');
+ if (next) cache_set_page(next.href);
+ },0);
+
+ change_menu_highlighting(url);
+}
+
+function change_menu_highlighting()
+{
+ var elements = document.getElementsByClassName('menu');
+ for (var i = 0; i < elements.length; i++) {
+ menu_active_selection(elements[i].id,true);
+ }
+}
+
+function save_set_state(url)
+{
+ var page_content = document.getElementById('page_content');
+
+ var html = get_inner_html(page_content);
+ var title = document.title;
+ var body_classname = document.body.className;
+
+ window.history.pushState({url: url, html: html, title: title, body_classname: body_classname}, title, url);
+}
+
+function _goto_set_page_history(event)
+{
+ if (!event.state) {
+ window.history.back();
+ return;
+ }
+ var url = event.state.url;
+ var html = event.state.html;
+ var title = event.state.title;
+ var body_classname = event.state.body_classname;
+ _goto_set_page(url, html, title, body_classname);
+}
+
+function cache_set_page(url)
+{
+ if (typeof window.set_cached_pages[url] != 'undefined') {
+ // Already cached
+ return;
+ }
+
+ _load_set_page(url);
+}
+
+function _load_set_page(url, then)
+{
+ var _url = '{$FIND_SCRIPT;,set_raw_page}?url=' + window.encodeURIComponent(url);
+
+ do_ajax_request(_url, function(ajax_result) {
+ var html = ajax_result.responseText;
+ var title = ajax_result.getResponseHeader('x-title');
+ var body_classname = ajax_result.getResponseHeader('x-body-classname');
+
+ window.set_cached_pages[url] = {html: html, title: title, body_classname: body_classname};
+ if (then) {
+ then(html, title, body_classname);
+ }
+ });
+}
diff --git a/sources_custom/sets.php b/sources_custom/sets.php
new file mode 100644
index 0000000..6d88cf3
--- /dev/null
+++ b/sources_custom/sets.php
@@ -0,0 +1,98 @@
+query_select('zones', array('*'), array('zone_name' => $zone), '', 1);
+ if (!array_key_exists(0, $zones)) {
+ warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
+ }
+ if (($zones[0]['zone_name'] != '') && (get_value('windows_auth_is_enabled') !== '1') && ((get_session_id() == '') || (!$GLOBALS['SESSION_CONFIRMED_CACHE'])) && (!is_guest()) && ($zones[0]['zone_require_session'] == 1) && (!is_guest())) {
+ access_denied('ZONE_ACCESS_SESSION');
+ }
+ if (!has_actual_page_access(get_member(), $page, $zone)) {
+ access_denied('ZONE_ACCESS');
+ }
+
+ // Closed site
+ $site_closed = get_option('site_closed');
+ if (($site_closed == '1') && (!has_privilege(get_member(), 'access_closed_site')) && (!$GLOBALS['IS_ACTUALLY_ADMIN'])) {
+ @exit(get_option('closed'));
+ }
+
+ header('x-title: ' . get_header_text() . ' - ' . get_site_name()); // Can't use ndash because the unicode contains an ASCII new line and complains
+ header('x-zone: ' . $zone);
+ header('x-page: ' . $page);
+ header('x-body-classname: website_body zone_running_' . $zone . ' page_running_' . $page);
+
+ safe_ini_set('ocproducts.xss_detect', '0');
+
+ // Load page
+ $output = request_page($page, true, $zone);
+ $output->handle_symbol_preprocessing();
+
+ $out = new Tempcode();
+ $out->attach(symbol_tempcode('CSS_TEMPCODE'));
+ $out->attach(symbol_tempcode('JS_TEMPCODE'));
+ $out->attach($output);
+ $out->attach(symbol_tempcode('JS_TEMPCODE', array('footer')));
+
+ echo $out->evaluate();
+}
+
+function set_navigation($page_link_current, $offset_diff, $type)
+{
+ global $SITEMAP_SET;
+ if (!isset($SITEMAP_SET)) {
+ return 'No set loaded';
+ }
+
+ static $cache = array();
+
+ if ($page_link_current === null) {
+ $page_link_current = url_to_page_link(get_self_url_easy());
+ }
+
+ if (isset($cache[$page_link_current][$offset_diff][$type])) {
+ return $cache[$page_link_current][$offset_diff][$type];
+ }
+
+ if (!isset($SITEMAP_SET['index'][$page_link_current])) {
+ return '';
+ }
+ $current_pos = $SITEMAP_SET['index'][$page_link_current];
+
+ $set = $SITEMAP_SET[$type];
+
+ if (!isset($set[$current_pos + $offset_diff])) {
+ return '';
+ }
+ $_sequential = $set[$current_pos + $offset_diff];
+
+ if ($type == 'page_links') {
+ $sequential = page_link_to_url($_sequential);
+ } else {
+ $sequential = $_sequential;
+ if (($type == 'titles') && (trim($sequential) == '')) {
+ $sequential = '(Unnamed)';
+ }
+ }
+
+ $cache[$page_link_current][$offset_diff][$type] = $sequential;
+
+ return $sequential;
+}
diff --git a/sources_custom/hooks/systems/symbols/SET_LOAD.php b/sources_custom/hooks/systems/symbols/SET_LOAD.php
new file mode 100644
index 0000000..f3df10d
--- /dev/null
+++ b/sources_custom/hooks/systems/symbols/SET_LOAD.php
@@ -0,0 +1,54 @@
+get_page_links($node, $skip, $valid_node_types, $page_links, $titles);
+ $SITEMAP_SET = array('index' => array_flip($page_links), 'page_links' => $page_links, 'titles' => $titles);
+
+ // Cache
+ require_code('caches2');
+ put_into_cache('set_' . $page_link, 60 * 24, serialize($param), null, null, permissive_groups_cache_signature(), null, '', $SITEMAP_SET);
+ } else {
+ $SITEMAP_SET = $set;
+ }
+
+ return '';
+ }
+
+ protected function get_page_links($node, $skip, $valid_node_types, &$page_links, &$titles)
+ {
+ if ((!in_array($node['page_link'], $skip)) && (($valid_node_types === null) || (in_array($node['content_type'], $valid_node_types)))) {
+ $page_links[] = $node['page_link'];
+ $titles[] = $node['title'];
+ }
+ if (isset($node['children'])) {
+ foreach ($node['children'] as $subnode) {
+ $this->get_page_links($subnode, $skip, $valid_node_types, $page_links, $titles);
+ }
+ }
+ }
+}
diff --git a/sources_custom/hooks/systems/symbols/SET_NEXT_PAGE_LINK.php b/sources_custom/hooks/systems/symbols/SET_NEXT_PAGE_LINK.php
new file mode 100644
index 0000000..e836c83
--- /dev/null
+++ b/sources_custom/hooks/systems/symbols/SET_NEXT_PAGE_LINK.php
@@ -0,0 +1,12 @@
+