aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/elgglib.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-05-14 20:01:59 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-05-14 20:01:59 +0000
commitb6aaba915151dd07800761a01b67ffffaee1302b (patch)
tree53c30035411460270278943f2427405233b34fac /engine/lib/elgglib.php
parentffbd7cd4179a0186dc674c2d24f578660cc75df0 (diff)
downloadelgg-b6aaba915151dd07800761a01b67ffffaee1302b.tar.gz
elgg-b6aaba915151dd07800761a01b67ffffaee1302b.tar.bz2
merge -r5898:5928 (not excluding riverdashboard, notifications, and messageboard) from 1.7 to trunk.
git-svn-id: http://code.elgg.org/elgg/trunk@6058 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/elgglib.php')
-rw-r--r--engine/lib/elgglib.php54
1 files changed, 53 insertions, 1 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index f6aae2b97..fd99cee0b 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -24,6 +24,10 @@ function forward($location = "") {
global $CONFIG;
if (!headers_sent()) {
+ if ($location === REFERER) {
+ $location = $_SERVER['HTTP_REFERER'];
+ }
+
$current_page = current_page_url();
if ((substr_count($location, 'http://') == 0) && (substr_count($location, 'https://') == 0)) {
$location = $CONFIG->url . $location;
@@ -139,6 +143,45 @@ function elgg_get_viewtype() {
}
/**
+ * Register a viewtype to fall back to a default view if view does not exist in
+ * that viewtype.
+ *
+ * This is useful for alternate html viewtypes (such as for mobile devices)
+ *
+ * @param string $viewtype The viewtype to register
+ */
+function elgg_register_viewtype_fallback($viewtype) {
+ global $CONFIG;
+
+ if (!isset($CONFIG->viewtype)) {
+ $CONFIG->viewtype = new stdClass;
+ }
+
+ if (!isset($CONFIG->viewtype->fallback)) {
+ $CONFIG->viewtype->fallback = array();
+ }
+
+ $CONFIG->viewtype->fallback[] = $viewtype;
+}
+
+/**
+ * Checks if this viewtype falls back to default
+ *
+ * @param string $viewtype
+ * @return boolean
+ */
+function elgg_does_viewtype_fallback($viewtype) {
+ global $CONFIG;
+
+ if (isset($CONFIG->viewtype) && isset($CONFIG->viewtype->fallback)) {
+ return in_array($viewtype, $CONFIG->viewtype->fallback);
+ }
+
+ return FALSE;
+}
+
+
+/**
* Return the location of a given view.
*
* @param string $view The view.
@@ -282,7 +325,7 @@ function elgg_view($view, $vars = array(), $bypass = false, $debug = false, $vie
$error = "$viewtype/$view view does not exist.";
// attempt to load default view
- if ($viewtype != 'default') {
+ if ($viewtype != 'default' && elgg_does_viewtype_fallback($viewtype)) {
if (file_exists($default_view_file) && include($default_view_file)) {
// default view found
$error .= " Using default/$view instead.";
@@ -3326,9 +3369,18 @@ define('ACCESS_LOGGED_IN', 1);
define('ACCESS_PUBLIC', 2);
define('ACCESS_FRIENDS', -2);
+/**
+ * @since 1.7
+ */
define('ELGG_ENTITIES_ANY_VALUE', NULL);
define('ELGG_ENTITIES_NO_VALUE', 0);
+/**
+ * @since 1.7.2
+ */
+define('REFERRER', -1);
+define('REFERER', -1);
+
register_elgg_event_handler('init', 'system', 'elgg_init');
register_elgg_event_handler('boot', 'system', 'elgg_boot', 1000);
register_plugin_hook('unit_test', 'system', 'elgg_api_test');