aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_css/css.php13
-rw-r--r--_css/js.php40
-rw-r--r--engine/lib/elgglib.php64
-rw-r--r--engine/start.php3
-rw-r--r--mod/profile/start.php1
-rw-r--r--mod/profile/views/default/profile/metatags.php7
-rw-r--r--simplecache/view.php44
-rw-r--r--upgrade.php1
-rw-r--r--views/default/page_elements/header.php4
9 files changed, 169 insertions, 8 deletions
diff --git a/_css/css.php b/_css/css.php
index e36b35d16..df681bcb2 100644
--- a/_css/css.php
+++ b/_css/css.php
@@ -11,6 +11,8 @@
* @link http://elgg.org/
*/
+ /*
+
require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
$default_css = elgg_view("css");
@@ -22,5 +24,16 @@
header("Content-Length: " . strlen($default_css));
echo $default_css;
+ */
+
+ global $viewinput;
+ $viewinput['view'] = 'css';
+
+ header("Content-type: text/css", true);
+ header('Expires: ' . date('r',time() + 864000), true);
+ header("Pragma: public", true);
+ header("Cache-Control: public", true);
+ // header("Content-Length: " . strlen($default_css));
+ require_once(dirname(dirname(__FILE__)) . '/simplecache/view.php');
?> \ No newline at end of file
diff --git a/_css/js.php b/_css/js.php
new file mode 100644
index 000000000..99c786e01
--- /dev/null
+++ b/_css/js.php
@@ -0,0 +1,40 @@
+<?php
+
+ /**
+ * Elgg CSS file
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008-2009
+ * @link http://elgg.org/
+ */
+
+ /*
+
+ require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+
+ $default_css = elgg_view("css");
+
+ header("Content-type: text/css", true);
+ header('Expires: ' . date('r',time() + 864000), true);
+ header("Pragma: public", true);
+ header("Cache-Control: public", true);
+ header("Content-Length: " . strlen($default_css));
+
+ echo $default_css;
+ */
+
+ global $viewinput;
+ $viewinput['view'] = 'js/' . $_GET['js'];
+
+ header('Content-type: text/javascript');
+ header('Expires: ' . date('r',time() + 864000));
+ header("Pragma: public");
+ header("Cache-Control: public");
+ // header("Content-Length: " . strlen($return));
+
+ require_once(dirname(dirname(__FILE__)) . '/simplecache/view.php');
+
+?> \ No newline at end of file
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index e21e30e25..40a248d8f 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -397,6 +397,59 @@
return false;
+ }
+
+ /**
+ * Registers a view to be simply cached
+ *
+ * Views cached in this manner must take no parameters and be login agnostic -
+ * that is to say, they look the same no matter who is logged in (or logged out).
+ *
+ * CSS and the basic jS views are automatically cached like this.
+ *
+ * @param string $viewname View name
+ */
+ function elgg_view_register_simplecache($viewname) {
+
+ global $CONFIG;
+
+ if (!isset($CONFIG->views->simplecache))
+ $CONFIG->views->simplecache = array();
+
+ //if (elgg_view_exists($viewname))
+ $CONFIG->views->simplecache[] = $viewname;
+
+ }
+
+ /**
+ * Regenerates the simple cache.
+ *
+ * @see elgg_view_register_simplecache
+ *
+ */
+ function elgg_view_regenerate_simplecache() {
+
+ global $CONFIG;
+
+ if (isset($CONFIG->views->simplecache)) {
+
+ if (!file_exists($CONFIG->dataroot . 'views_simplecache')) {
+ @mkdir($CONFIG->dataroot . 'views_simplecache');
+ }
+
+ if (!empty($CONFIG->views->simplecache) && is_array($CONFIG->views->simplecache)) {
+ foreach($CONFIG->views->simplecache as $view) {
+ $viewcontents = elgg_view($view);
+ $viewname = md5($view);
+ if ($handle = fopen($CONFIG->dataroot . 'views_simplecache/' . $viewname, 'w')) {
+ fwrite($handle, $viewcontents);
+ fclose($handle);
+ }
+ }
+ }
+
+ }
+
}
/**
@@ -2106,14 +2159,19 @@
register_page_handler('js','js_page_handler');
extend_view('js/initialise_elgg','embed/js');
// Register an event triggered at system shutdown
- register_shutdown_function('__elgg_shutdown_hook');
+ register_shutdown_function('__elgg_shutdown_hook');
+
}
function elgg_boot() {
// Actions
register_action('comments/add');
- register_action('comments/delete');
+ register_action('comments/delete');
+
+ elgg_view_register_simplecache('css');
+ elgg_view_register_simplecache('js/friendsPickerv1');
+ elgg_view_register_simplecache('js/initialise_elgg');
}
/**
@@ -2124,6 +2182,6 @@
define('ACCESS_PUBLIC',2);
register_elgg_event_handler('init','system','elgg_init');
- register_elgg_event_handler('boot','system','elgg_boot');
+ register_elgg_event_handler('boot','system','elgg_boot',1000);
?> \ No newline at end of file
diff --git a/engine/start.php b/engine/start.php
index 568cea905..d1484cafd 100644
--- a/engine/start.php
+++ b/engine/start.php
@@ -185,8 +185,9 @@
//forward("setup.php");
//}
}
-
// System booted, return to normal view
set_input('view', $oldview);
+
+ run_function_once('elgg_view_regenerate_simplecache',time() - (86400 * 7));
?> \ No newline at end of file
diff --git a/mod/profile/start.php b/mod/profile/start.php
index 671000f80..111f3ea8c 100644
--- a/mod/profile/start.php
+++ b/mod/profile/start.php
@@ -56,6 +56,7 @@
// Add Javascript reference to the page header
extend_view('metatags','profile/metatags');
extend_view('css','profile/css');
+ extend_view('js/initialise_elgg','profile/javascript');
if (get_context() == "profile")
extend_view('canvas_header/submenu','profile/submenu');
diff --git a/mod/profile/views/default/profile/metatags.php b/mod/profile/views/default/profile/metatags.php
index 9bc455cfb..2ca9718d9 100644
--- a/mod/profile/views/default/profile/metatags.php
+++ b/mod/profile/views/default/profile/metatags.php
@@ -11,8 +11,11 @@
*
*/
-?>
+ /*
+ * <script type="text/javascript" src="<?php echo $vars['url']; ?>pg/iconjs/profile.js" ></script>
+ */
- <script type="text/javascript" src="<?php echo $vars['url']; ?>pg/iconjs/profile.js" ></script>
+?>
+
<?php if ($owner = page_owner_entity()) { ?><link rel="meta" type="application/rdf+xml" title="FOAF" href="<?php echo full_url(); ?>?view=foaf" /><?php } ?>
diff --git a/simplecache/view.php b/simplecache/view.php
new file mode 100644
index 000000000..b7e4e7fe5
--- /dev/null
+++ b/simplecache/view.php
@@ -0,0 +1,44 @@
+<?php
+
+ /**
+ * Simple cache viewer
+ * Bypasses the engine to view simple cached CSS views.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008-2009
+ * @link http://elgg.org/
+ */
+
+ // Get DB settings, connect
+ require_once(dirname(dirname(__FILE__)). '/engine/settings.php');
+
+ global $CONFIG, $viewinput;
+
+ $contents = '';
+ if (!isset($viewinput)) $viewinput = $_GET;
+
+ if ($dblink = @mysql_connect($CONFIG->dbhost,$CONFIG->dbuser,$CONFIG->dbpass)) {
+
+ $view = $viewinput['view'];
+
+ // Get the dataroot
+ if (@mysql_select_db($CONFIG->dbname,$dblink)) {
+ if ($result = mysql_query("select value from {$CONFIG->dbprefix}datalists where name = 'dataroot'",$dblink)) {
+ $row = mysql_fetch_object($result);
+ $dataroot = $row->value;
+ }
+ $filename = $dataroot . 'views_simplecache/' . md5($view);
+ if (file_exists($filename))
+ $contents = @file_get_contents($filename);
+ else {
+ echo ''; exit;
+ }
+ }
+ }
+
+ echo $contents;
+
+?> \ No newline at end of file
diff --git a/upgrade.php b/upgrade.php
index 53f372e3f..d4aa1bbea 100644
--- a/upgrade.php
+++ b/upgrade.php
@@ -21,6 +21,7 @@
if (version_upgrade_check()) {
version_upgrade();
}
+ datalist_set('elgg_view_regenerate_simplecache',0);
} else {
global $CONFIG;
echo elgg_view('settings/upgrading');
diff --git a/views/default/page_elements/header.php b/views/default/page_elements/header.php
index 307eb1828..627e4b87a 100644
--- a/views/default/page_elements/header.php
+++ b/views/default/page_elements/header.php
@@ -62,14 +62,14 @@ END;
<script type="text/javascript" src="<?php echo $vars['url']; ?>vendors/jquery/jquery-1.2.6.pack.js"></script>
<script type="text/javascript" src="<?php echo $vars['url']; ?>vendors/jquery/jquery-ui-personalized-1.5.3.packed.js"></script>
- <script type="text/javascript" src="<?php echo $vars['url']; ?>pg/js/initialise_elgg.js"></script>
+ <script type="text/javascript" src="<?php echo $vars['url']; ?>_css/js.php?js=initialise_elgg"></script>
<?php
global $pickerinuse;
if (isset($pickerinuse) && $pickerinuse == true) {
?>
<!-- only needed on pages where we have friends collections and/or the friends picker -->
<script type="text/javascript" src="<?php echo $vars['url']; ?>vendors/jquery/jquery.easing.1.3.packed.js"></script>
- <script type="text/javascript" src="<?php echo $vars['url']; ?>pg/js/friendsPickerv1.js"></script>
+ <script type="text/javascript" src="<?php echo $vars['url']; ?>_css/js.php?js=friendsPickerv1"></script>
<?php
}
?>