diff options
author | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-02-15 11:49:32 +0000 |
---|---|---|
committer | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-02-15 11:49:32 +0000 |
commit | dd624054a469d9e8ceb91cc2ee3f63a393f016db (patch) | |
tree | 51ffd0bc6eef3558f0dfec10a1d975d1254aee8f | |
parent | 611c78a8bc7cb51c1c5b0d0ede91bc6d611d1331 (diff) | |
download | elgg-dd624054a469d9e8ceb91cc2ee3f63a393f016db.tar.gz elgg-dd624054a469d9e8ceb91cc2ee3f63a393f016db.tar.bz2 |
Plugins can now extend views.
git-svn-id: https://code.elgg.org/elgg/trunk@37 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/elgglib.php | 80 |
1 files changed, 70 insertions, 10 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index b68258470..218e2cb07 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -94,17 +94,32 @@ $viewtype = $_SESSION['view'];
}
+ if (isset($CONFIG->views->extensions[$view])) {
+ $viewlist = $CONFIG->views->extensions[$view];
+ } else {
+ $viewlist = array(500 => $view);
+ }
+
ob_start();
- if (!@include($CONFIG->viewpath . "views/{$viewtype}/{$view}.php")) {
- $success = false;
- if ($viewtype != "default") {
- if (@include($CONFIG->viewpath . "views/default/{$view}.php")) {
- $success = true;
- }
- }
- if (!$success && $debug == true) {
- echo " [This view ({$view}) does not exist] ";
- }
+ foreach($viewlist as $view) {
+
+ if (!isset($CONFIG->views->locations[$view])) {
+ $location = $CONFIG->viewpath . "views/";
+ } else {
+ $location = $CONFIG->views->locations[$view];
+ }
+ if (!@include($location . "{$viewtype}/{$view}.php")) {
+ $success = false;
+ if ($viewtype != "default") {
+ if (@include($location . "views/default/{$view}.php")) {
+ $success = true;
+ }
+ }
+ if (!$success && $CONFIG->debug == true) {
+ echo " [This view ({$view}) does not exist] ";
+ }
+ }
+
}
$content = ob_get_clean();
@@ -113,6 +128,51 @@ }
/**
+ * Extends a view by adding other views to be displayed at the same time.
+ *
+ * @param string $view The view to add to.
+ * @param string $view_name The name of the view to extend
+ * @param int $priority The priority, from 0 to 1000, to add at (lowest numbers will be displayed first)
+ */
+ function extend_view($view, $view_name, $priority = 501) {
+
+ global $CONFIG;
+ if (!isset($CONFIG->views)) {
+ $CONFIG->views = new stdClass;
+ }
+ if (!isset($CONFIG->views->extensions)) {
+ $CONFIG->views->extensions = array();
+ }
+ if (!isset($CONFIG->views->extensions[$view])) {
+ $CONFIG->views[$view][500] = "{$view}";
+ }
+ while(isset($CONFIG->views->extensions[$view][$priority])) {
+ $priority++;
+ }
+ $CONFIG->views->extensions[$view][$priority] = "{$view_name}";
+ ksort($CONFIG->views->extensions[$view]);
+
+ }
+
+ /**
+ * Set an alternative base location for a view (as opposed to the default of $CONFIG->viewpath)
+ *
+ * @param string $view The name of the view
+ * @param string $location The base location path
+ */
+ function set_view_location($view, $location) {
+
+ global $CONFIG;
+ if (!isset($CONFIG->views)) {
+ $CONFIG->views = new stdClass;
+ }
+ if (!isset($CONFIG->views->locations)) {
+ $CONFIG->views->locations = array($view => $location);
+ }
+
+ }
+
+ /**
* Returns a representation of a full 'page' (which might be an HTML page, RSS file, etc, depending on the current view)
*
* @param unknown_type $title
|