aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-28 22:03:18 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-28 22:03:18 +0000
commit71dc8cbf9eecb4de149bc96bb5758b866116b1c8 (patch)
treeee3d99eb82fe42d0dfaee6d63003ca753001d03b
parenta1b7808dea79b3a547aa805b86d829fa1f5f19db (diff)
downloadelgg-71dc8cbf9eecb4de149bc96bb5758b866116b1c8.tar.gz
elgg-71dc8cbf9eecb4de149bc96bb5758b866116b1c8.tar.bz2
Fixes #2173 #2507 integrated the ie and admin stylesheets into the new simplecache code
git-svn-id: http://code.elgg.org/elgg/trunk@7465 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/admin.php2
-rw-r--r--engine/lib/elgglib.php6
-rw-r--r--engine/lib/views.php52
-rw-r--r--views/default/friends/picker.php3
-rw-r--r--views/default/page_elements/html_begin.php7
5 files changed, 53 insertions, 17 deletions
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index 3c070203e..aab4b3aea 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -161,7 +161,7 @@ function admin_init() {
*/
function admin_pagesetup() {
if (elgg_in_context('admin')) {
- $url = elgg_get_site_url() . 'pg/css/admin.css';
+ $url = elgg_view_get_simplecache_url('css', 'admin');
elgg_register_css($url, 'admin');
elgg_unregister_css('elgg');
}
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 7bf23df5e..ec67f97cf 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -2123,7 +2123,7 @@ function _elgg_shutdown_hook() {
*/
function js_page_handler($page) {
if (is_array($page) && sizeof($page)) {
- $js = str_replace('.js', '', $page[0]);
+ $js = substr($page[0], 0, strpos($page[0], '.'));
$return = elgg_view('js/' . $js);
header('Content-type: text/javascript');
@@ -2133,7 +2133,6 @@ function js_page_handler($page) {
header("Content-Length: " . strlen($return));
echo $return;
- exit;
}
}
@@ -2150,9 +2149,10 @@ function js_page_handler($page) {
function css_page_handler($page) {
if (!isset($page[0])) {
// default css
+ $page[0] = 'elgg';
}
- $css = str_replace('.css', '', $page[0]);
+ $css = substr($page[0], 0, strpos($page[0], '.'));
$return = elgg_view("css/$css");
header("Content-type: text/css", true);
diff --git a/engine/lib/views.php b/engine/lib/views.php
index 6c4cec0f2..e0e10bcb7 100644
--- a/engine/lib/views.php
+++ b/engine/lib/views.php
@@ -399,7 +399,7 @@ function elgg_view_exists($view, $viewtype = '', $recurse = true) {
* @warning Simple cached views must take no parameters and return
* the same content no matter who is logged in.
*
- * @note CSS and the basic JS views are automatically cached.
+ * @note CSS and the basic JS views are cached by the engine.
*
* @param string $viewname View name
*
@@ -422,6 +422,27 @@ function elgg_view_register_simplecache($viewname) {
}
/**
+ * Get the URL for the cached file
+ *
+ * @param string $type The file type: css or js
+ * @param string $view The view name
+ * @return string
+ * @since 1.8.0
+ */
+function elgg_view_get_simplecache_url($type, $view) {
+ global $CONFIG;
+ $lastcache = $CONFIG->lastcache;
+
+ if (elgg_view_is_simplecache_enabled()) {
+ $viewtype = elgg_get_viewtype();
+ $url = elgg_get_site_url() . "cache/$type/$view/$viewtype/$view.$lastcache.$type";
+ } else {
+ $url = elgg_get_site_url() . "pg/$type/$view.$lastcache.$type";
+ }
+ return $url;
+}
+
+/**
* Regenerates the simple cache.
*
* @warning This does not invalidate the cache, but actively resets it.
@@ -484,6 +505,22 @@ function elgg_view_regenerate_simplecache($viewtype = NULL) {
}
/**
+ * Is simple cache enabled
+ *
+ * @return bool
+ * @since 1.8.0
+ */
+function elgg_view_is_simplecache_enabled() {
+ global $CONFIG;
+
+ if ($CONFIG->simplecache_enabled) {
+ return true;
+ }
+
+ return false;
+}
+
+/**
* Enables the simple cache.
*
* @access private
@@ -1329,17 +1366,10 @@ function elgg_is_valid_view_type($view_type) {
* Add the core Elgg head elements that could be cached
*/
function elgg_views_register_core_head_elements() {
- global $CONFIG;
-
- $base = elgg_get_site_url();
- $lastcache = $CONFIG->lastcache;
- $viewtype = elgg_get_viewtype();
-
- //$url = "{$base}_css/js.php?lastcache=$lastcache&js=initialise_elgg&viewtype=$viewtype";
- $url = "{$base}cache/js/initialise_elgg/$viewtype/initialise_elgg.$lastcache.js";
+ $url = elgg_view_get_simplecache_url('js', 'initialise_elgg');
elgg_register_js($url, 'initialise_elgg');
- $url = "{$base}cache/css/elgg/$viewtype/elgg.$lastcache.css";
+ $url = elgg_view_get_simplecache_url('css', 'elgg');
elgg_register_css($url, 'elgg');
}
@@ -1355,6 +1385,8 @@ function elgg_views_boot() {
global $CONFIG;
elgg_view_register_simplecache('css/elgg');
+ elgg_view_register_simplecache('ie/elgg');
+ elgg_view_register_simplecache('ie6/elgg');
elgg_view_register_simplecache('js/friendsPickerv1');
elgg_view_register_simplecache('js/initialise_elgg');
diff --git a/views/default/friends/picker.php b/views/default/friends/picker.php
index b8cc1560c..6a9551732 100644
--- a/views/default/friends/picker.php
+++ b/views/default/friends/picker.php
@@ -12,7 +12,8 @@
$base = elgg_get_site_url();
$viewtype = elgg_get_viewtype();
elgg_register_js("{$base}vendors/jquery/jquery.easing.1.3.packed.js", 'jquery.easing');
-elgg_register_js("{$base}cache/js/friendsPickerv1/default/friendsPickerv1.{$vars['config']->lastcache}.js", 'friendsPicker');
+$url = elgg_view_get_simplecache_url('js', 'friendsPickerv1');
+elgg_register_js($url, 'friendsPicker');
$chararray = elgg_echo('friendspicker:chararray');
diff --git a/views/default/page_elements/html_begin.php b/views/default/page_elements/html_begin.php
index a673d8ff6..23879dde8 100644
--- a/views/default/page_elements/html_begin.php
+++ b/views/default/page_elements/html_begin.php
@@ -65,13 +65,16 @@ foreach ($css as $link) {
<link rel="stylesheet" href="<?php echo $link; ?>" type="text/css" />
<?php
}
+
+$ie_url = elgg_view_get_simplecache_url('css', 'ie');
+$ie6_url = elgg_view_get_simplecache_url('css', 'ie6');
?>
<!--[if IE 6]>
- <link rel="stylesheet" type="text/css" href="<?php echo elgg_get_site_url(); ?>pg/css/ie6.css" />
+ <link rel="stylesheet" type="text/css" href="<?php echo $ie_url; ?>" />
<![endif]-->
<!--[if gt IE 6]>
- <link rel="stylesheet" type="text/css" href="<?php echo elgg_get_site_url(); ?>pg/css/ie.css" />
+ <link rel="stylesheet" type="text/css" href="<?php echo $ie6_url; ?>" />
<![endif]-->
<?php