aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-10-16 13:50:07 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-10-16 13:50:07 +0000
commit8f9fb62906572904aa0f1e4b2a97423dc2b2a938 (patch)
tree3530b9f6ce84f346a0863d2f35fd1fa9e16397f6
parentea2caadad819bac25d8c374a70cc05aec103c08f (diff)
downloadelgg-8f9fb62906572904aa0f1e4b2a97423dc2b2a938.tar.gz
elgg-8f9fb62906572904aa0f1e4b2a97423dc2b2a938.tar.bz2
Moving internal function out of elgg_view_tree() since this caused problems
git-svn-id: https://code.elgg.org/elgg/trunk@2270 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/elgglib.php70
1 files changed, 39 insertions, 31 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index e7bdbe665..1bc05fca2 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -295,7 +295,36 @@
return false;
}
-
+
+ /**
+ * Internal function for retrieving views used by elgg_view_tree
+ *
+ * @param unknown_type $dir
+ * @param unknown_type $base
+ * @return unknown
+ */
+ function get_views($dir, $base) {
+
+ $return = array();
+ if (file_exists($dir) && is_dir($dir)) {
+ if ($handle = opendir($dir)) {
+ while ($view = readdir($handle)) {
+ if (!in_array($view, array('.','..','.svn','CVS'))) {
+ if (is_dir($dir . '/' . $view)) {
+ if ($val = get_views($dir . '/' . $view, $base . '/' . $view)) {
+ $return = array_merge($return, $val);
+ }
+ } else {
+ $view = str_replace('.php','',$view);
+ $return[] = $base . '/' . $view;
+ }
+ }
+ }
+ }
+ }
+ return $return;
+ }
+
/**
* When given a partial view root (eg 'js' or 'page_elements'), returns an array of views underneath it
*
@@ -306,33 +335,12 @@
global $CONFIG;
static $treecache;
-
- function get_views($dir, $base) {
- $return = array();
- if (file_exists($dir) && is_dir($dir)) {
- if ($handle = opendir($dir)) {
- while ($view = readdir($handle)) {
- if (!in_array($view, array('.','..','.svn','CVS'))) {
- if (is_dir($dir . '/' . $view)) {
- if ($val = get_views($dir . '/' . $view, $base . '/' . $view)) {
- $return = array_merge($return, $val);
- }
- } else {
- $view = str_replace('.php','',$view);
- $return[] = $base . '/' . $view;
- }
- }
- }
- }
- }
- return $return;
- }
-
+
// Has the treecache been initialised?
- if (!isset($treecache)) $treecache = array();
+ if (!isset($treecache)) $treecache = array();
// A little light internal caching
if (!empty($treecache[$view_root])) return $treecache[$view_root];
-
+
// Examine $CONFIG->views->locations
if (isset($CONFIG->views->locations)) {
foreach($CONFIG->views->locations as $view => $path) {
@@ -342,18 +350,18 @@
}
}
}
-
+
// Now examine core
$location = $CONFIG->viewpath;
$viewtype = elgg_get_viewtype();
$root = $location . $viewtype . '/' . $view_root;
-
- if (file_exists($root) && is_dir($root)) {
- $val = get_views($root, $view_root);
- if (!is_array($treecache[$view_root])) $treecache[$view_root] = array();
+
+ if (file_exists($root) && is_dir($root)) {
+ $val = get_views($root, $view_root);
+ if (!is_array($treecache[$view_root])) $treecache[$view_root] = array();
$treecache[$view_root] = array_merge($treecache[$view_root], $val);
}
-
+
return $treecache[$view_root];
}