diff options
author | kevinjardine <kevinjardine@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-02-24 10:36:23 +0000 |
---|---|---|
committer | kevinjardine <kevinjardine@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-02-24 10:36:23 +0000 |
commit | dea94d966389092be57ea517065c8822242711ae (patch) | |
tree | 45d5ec09d704c17099bbf54c5ca33e89c11efa3f | |
parent | adc58d2bc1807b6c41b012aae7eb74795ac17c67 (diff) | |
download | elgg-dea94d966389092be57ea517065c8822242711ae.tar.gz elgg-dea94d966389092be57ea517065c8822242711ae.tar.bz2 |
Made icon views work properly for non-default icons, and introduced elgg_view_enable_simplecache and elgg_view_disable_simplecache functions.
git-svn-id: https://code.elgg.org/elgg/trunk@2910 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | actions/admin/site/update_basic.php | 15 | ||||
-rw-r--r-- | engine/lib/elgglib.php | 43 | ||||
-rw-r--r-- | mod/profile/icondirect.php | 39 |
3 files changed, 62 insertions, 35 deletions
diff --git a/actions/admin/site/update_basic.php b/actions/admin/site/update_basic.php index 46ac133cc..564a3aa1c 100644 --- a/actions/admin/site/update_basic.php +++ b/actions/admin/site/update_basic.php @@ -35,20 +35,9 @@ datalist_set('path',sanitise_filepath(get_input('path')));
datalist_set('dataroot',sanitise_filepath(get_input('dataroot')));
if (get_input('simplecache_enabled')) {
- datalist_set('simplecache_enabled',1);
- elgg_view_regenerate_simplecache();
+ elgg_view_enable_simplecache();
} else {
- datalist_set('simplecache_enabled',0);
-
- // purge simple cache
- if ($handle = opendir($CONFIG->dataroot.'views_simplecache')) {
- while (false !== ($file = readdir($handle))) {
- if ($file != "." && $file != "..") {
- unlink($CONFIG->dataroot.'views_simplecache/'.$file);
- }
- }
- closedir($handle);
- }
+ elgg_view_disable_simplecache();
}
set_config('language', get_input('language'), $site->getGUID());
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index a14a5feb1..a081837fb 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -454,6 +454,47 @@ } + /** + * Enables the simple cache. + * + * @see elgg_view_register_simplecache + * + */ + + function elgg_view_enable_simplecache() { + global $CONFIG; + if(!$CONFIG->simplecache_enabled) { + datalist_set('simplecache_enabled',1); + $CONFIG->simplecache_enabled = 1; + elgg_view_regenerate_simplecache(); + } + } + + /** + * Disables the simple cache. + * + * @see elgg_view_register_simplecache + * + */ + + function elgg_view_disable_simplecache() { + global $CONFIG; + if ($CONFIG->simplecache_enabled) { + datalist_set('simplecache_enabled',0); + $CONFIG->simplecache_enabled = 0; + + // purge simple cache + if ($handle = opendir($CONFIG->dataroot.'views_simplecache')) { + while (false !== ($file = readdir($handle))) { + if ($file != "." && $file != "..") { + unlink($CONFIG->dataroot.'views_simplecache/'.$file); + } + } + closedir($handle); + } + } + } + /** * Internal function for retrieving views used by elgg_view_tree * @@ -2206,7 +2247,7 @@ /** * Some useful constant definitions - */
+ */ define('ACCESS_DEFAULT',-1); define('ACCESS_PRIVATE',0); define('ACCESS_LOGGED_IN',1); diff --git a/mod/profile/icondirect.php b/mod/profile/icondirect.php index 49d230efa..497420f55 100644 --- a/mod/profile/icondirect.php +++ b/mod/profile/icondirect.php @@ -71,33 +71,30 @@ $row = mysql_fetch_object($result);
}
}
- $filename = $dataroot . $matrix . "{$username}/profile/" . $username . $size . ".jpg";
- $contents = @file_get_contents($filename);
}
}
- if (empty($contents)) {
-
- global $CONFIG, $viewinput;
- $viewinput['view'] = 'icon/user/default/'.$size;
- if ($simplecache_enabled) {
+ if ($simplecache_enabled) {
+ $filename = $dataroot . $matrix . "{$username}/profile/" . $username . $size . ".jpg";
+ $contents = @file_get_contents($filename);
+ if (empty($contents)) {
+ global $viewinput;
+ $viewinput['view'] = 'icon/user/default/'.$size;
ob_start();
include(dirname(dirname(dirname(__FILE__))).'/simplecache/view.php');
$loc = ob_get_clean();
+ header('Location: ' . $loc);
+ exit;
//$contents = @file_get_contents(dirname(__FILE__) . "/graphics/default{$size}.jpg");
- } else {
- mysql_close($mysql_dblink);
- require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
- $loc = elgg_view($viewinput['view']);
+ } else {
+ header("Content-type: image/jpeg");
+ header('Expires: ' . date('r',time() + 864000));
+ header("Pragma: public");
+ header("Cache-Control: public");
+ header("Content-Length: " . strlen($contents));
+ echo $contents;
}
- header('Location: ' . $loc);
- exit;
+ } else {
+ mysql_close($mysql_dblink);
+ require_once(dirname(__FILE__).'/icon.php');
}
-
- header("Content-type: image/jpeg");
- header('Expires: ' . date('r',time() + 864000));
- header("Pragma: public");
- header("Cache-Control: public");
- header("Content-Length: " . strlen($contents));
- echo $contents;
-
?>
\ No newline at end of file |