aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/elgglib.php
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-19 20:18:40 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-19 20:18:40 +0000
commitc25dcd4533ec98c7e58c647e4b2c08169c6b7dc4 (patch)
treea8569b30b979a78f0fa052023a2d1dffe03daadf /engine/lib/elgglib.php
parent5681f47424f7c4b17acb56656135efff420fa09a (diff)
downloadelgg-c25dcd4533ec98c7e58c647e4b2c08169c6b7dc4.tar.gz
elgg-c25dcd4533ec98c7e58c647e4b2c08169c6b7dc4.tar.bz2
Automatic RSS feeds!
git-svn-id: https://code.elgg.org/elgg/trunk@1011 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/elgglib.php')
-rw-r--r--engine/lib/elgglib.php81
1 files changed, 76 insertions, 5 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index d559e5131..261dc60cc 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -187,6 +187,50 @@
}
/**
+ * Returns whether the specified view exists
+ *
+ * @param string $view The view name
+ * @param string $viewtype The type of view
+ * @return true|false Depending on success
+ */
+ function elgg_view_exists($view, $viewtype = "") {
+
+ global $CONFIG;
+
+ // If we haven't been asked for a specific view, assume default
+ if (empty($_SESSION['view'])) {
+ $_SESSION['view'] = "default";
+
+ // If we have a config default view for this site then use that instead of 'default'
+ if (/*(is_installed()) && */(!empty($CONFIG->view)) && (trim($CONFIG->view)!=""))
+ $_SESSION['view'] = $CONFIG->view;
+ }
+ if (empty($viewtype) && is_callable('get_input'))
+ $viewtype = get_input('view');
+ if (empty($viewtype)) {
+ $viewtype = $_SESSION['view'];
+ }
+
+
+ if (!isset($CONFIG->views->locations[$view])) {
+ if (!isset($CONFIG->viewpath)) {
+ $location = dirname(dirname(dirname(__FILE__))) . "/views/";
+ } else {
+ $location = $CONFIG->viewpath;
+ }
+ } else {
+ $location = $CONFIG->views->locations[$view];
+ }
+
+ if (file_exists($location . "{$viewtype}/{$view}.php")) {
+ return true;
+ }
+
+ return false;
+
+ }
+
+ /**
* When given an entity, views it intelligently.
*
* Expects a view to exist called entity-type/subtype, or for the entity to have a parameter
@@ -203,6 +247,9 @@
*/
function elgg_view_entity(ElggEntity $entity, $viewtype = "", $full = false, $bypass = true, $debug = false) {
+ global $autofeed;
+ $autofeed = true;
+
$view = $entity->view;
if (is_string($view)) {
return elgg_view($view,array('entity' => $entity), $viewtype, $bypass, $debug);
@@ -231,11 +278,17 @@
$subtype = $entity->getSubtype();
if (empty($subtype)) { $subtype = $entity_type; }
- return elgg_view("{$entity_type}/{$subtype}",array(
+ if (elgg_view_exists("{$entity_type}/{$subtype}")) {
+ return elgg_view("{$entity_type}/{$subtype}",array(
+ 'entity' => $entity,
+ 'full' => $full
+ ), $viewtype, $bypass, $debug);
+ } else {
+ return elgg_view("{$entity_type}/default",array(
'entity' => $entity,
'full' => $full
), $viewtype, $bypass, $debug);
-
+ }
}
/**
@@ -303,9 +356,14 @@
$param_array['area' . $arg] = func_get_arg($arg);
$arg++;
}
- return elgg_view("canvas/layouts/{$layout}",$param_array);
+ if (elgg_view_exists("canvas/layouts/{$layout}")) {
+ return elgg_view("canvas/layouts/{$layout}",$param_array);
+ } else {
+ return elgg_view("canvas/default",$param_array);
+ }
}
+
/**
* Sets an alternative function to handle templates, which will be passed to by elgg_view.
@@ -1300,7 +1358,20 @@
return false;
}
-
-
+
+ /**
+ * Get the full URL of the current page.
+ *
+ * @return string The URL
+ */
+ function full_url()
+ {
+ $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
+ $protocol = substr(strtolower($_SERVER["SERVER_PROTOCOL"]), 0, strpos(strtolower($_SERVER["SERVER_PROTOCOL"]), "/")) . $s;
+ $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
+ return $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI'];
+ }
+
+
?> \ No newline at end of file