示例#1
0
/**
 * Regenerates the simple cache.
 *
 * @param string $viewtype Optional viewtype to regenerate
 * @see elgg_view_register_simplecache()
 *
 * @deprecated 1.8 Use {@link elgg_regenerate_simplecache()}
 */
function elgg_view_regenerate_simplecache($viewtype = NULL)
{
    elgg_deprecated_notice("elgg_view_regenerate_simplecache() was deprecated by elgg_regenerate_simplecache()", 1.8);
    return elgg_regenerate_simplecache($viewtype);
}
示例#2
0
$type = $matches[1];
$viewtype = $matches[2];
$view = $matches[3];
switch ($type) {
    case 'css':
        header("Content-type: text/css", true);
        header('Expires: ' . date('r', strtotime("+6 months")), true);
        header("Pragma: public", true);
        header("Cache-Control: public", true);
        $view = "css/{$view}";
        break;
    case 'js':
        header('Content-type: text/javascript', true);
        header('Expires: ' . date('r', strtotime("+6 months")), true);
        header("Pragma: public", true);
        header("Cache-Control: public", true);
        $view = "js/{$view}";
        break;
}
$filename = $dataroot . 'views_simplecache/' . md5($viewtype . $view);
if (file_exists($filename)) {
    $contents = file_get_contents($filename);
} else {
    // someone trying to access a non-cached file or a race condition with cache flushing
    mysql_close($mysql_dblink);
    require_once dirname(dirname(__FILE__)) . "/start.php";
    elgg_regenerate_simplecache();
    elgg_set_viewtype($viewtype);
    $contents = elgg_view($view);
}
echo $contents;
示例#3
0
/**
 * Enables the simple cache.
 *
 * @access private
 * @see elgg_register_simplecache_view()
 * @return void
 * @since 1.8.0
 */
function elgg_enable_simplecache()
{
    global $CONFIG;
    datalist_set('simplecache_enabled', 1);
    $CONFIG->simplecache_enabled = 1;
    elgg_regenerate_simplecache();
}
示例#4
0
文件: start.php 项目: risho/Elgg
}
// confirm that the installation completed successfully
verify_installation();
// Autodetect some default configuration settings
set_default_config();
// needs to be set for links in html head
$viewtype = get_input('view', 'default');
$lastcached = datalist_get("simplecache_lastcached_{$viewtype}");
$CONFIG->lastcache = $lastcached;
// Trigger boot events for core. Plugins can't hook
// into this because they haven't been loaded yet.
elgg_trigger_event('boot', 'system');
// Load the plugins that are active
elgg_load_plugins();
elgg_trigger_event('plugins_boot', 'system');
// Trigger system init event for plugins
elgg_trigger_event('init', 'system');
// Regenerate the simple cache if expired.
// Don't do it on upgrade because upgrade does it itself.
// @todo - move into function and perhaps run off init system event
if (!defined('UPGRADING')) {
    $lastupdate = datalist_get("simplecache_lastupdate_{$viewtype}");
    $lastcached = datalist_get("simplecache_lastcached_{$viewtype}");
    if ($lastupdate == 0 || $lastcached < $lastupdate) {
        elgg_regenerate_simplecache($viewtype);
        $lastcached = datalist_get("simplecache_lastcached_{$viewtype}");
    }
    $CONFIG->lastcache = $lastcached;
}
// System loaded and ready
elgg_trigger_event('ready', 'system');
示例#5
0
文件: cache.php 项目: nogsus/Elgg
/**
 * @access private
 */
function _elgg_cache_init()
{
    global $CONFIG;
    $viewtype = elgg_get_viewtype();
    // Regenerate the simple cache if expired.
    // Don't do it on upgrade because upgrade does it itself.
    // @todo - move into function and perhaps run off init system event
    if (!defined('UPGRADING')) {
        $lastupdate = datalist_get("simplecache_lastupdate_{$viewtype}");
        $lastcached = datalist_get("simplecache_lastcached_{$viewtype}");
        if ($lastupdate == 0 || $lastcached < $lastupdate) {
            elgg_regenerate_simplecache($viewtype);
            $lastcached = datalist_get("simplecache_lastcached_{$viewtype}");
        }
        $CONFIG->lastcache = $lastcached;
    }
    // cache system data if enabled and not loaded
    if ($CONFIG->system_cache_enabled && !$CONFIG->system_cache_loaded) {
        elgg_save_system_cache('view_locations', serialize($CONFIG->views->locations));
        elgg_save_system_cache('view_types', serialize($CONFIG->view_types));
    }
    if ($CONFIG->system_cache_enabled && !$CONFIG->i18n_loaded_from_cache) {
        reload_all_translations();
        foreach ($CONFIG->translations as $lang => $map) {
            elgg_save_system_cache("{$lang}.php", serialize($map));
        }
    }
}
示例#6
0
 /**
  * Initialize the site including site entity, plugins, and configuration
  *
  * @param array $submissionVars Submitted vars
  *
  * @return bool
  */
 protected function saveSiteSettings($submissionVars)
 {
     global $CONFIG;
     // ensure that file path, data path, and www root end in /
     $submissionVars['path'] = sanitise_filepath($submissionVars['path']);
     $submissionVars['dataroot'] = sanitise_filepath($submissionVars['dataroot']);
     $submissionVars['wwwroot'] = sanitise_filepath($submissionVars['wwwroot']);
     $site = new ElggSite();
     $site->name = $submissionVars['sitename'];
     $site->url = $submissionVars['wwwroot'];
     $site->access_id = ACCESS_PUBLIC;
     $site->email = $submissionVars['siteemail'];
     $guid = $site->save();
     if (!$guid) {
         register_error(elgg_echo('install:error:createsite'));
         return FALSE;
     }
     // bootstrap site info
     $CONFIG->site_guid = $guid;
     $CONFIG->site = $site;
     datalist_set('installed', time());
     datalist_set('path', $submissionVars['path']);
     datalist_set('dataroot', $submissionVars['dataroot']);
     datalist_set('default_site', $site->getGUID());
     datalist_set('version', get_version());
     datalist_set('simplecache_enabled', 1);
     datalist_set('viewpath_cache_enabled', 1);
     // new installations have run all the upgrades
     $upgrades = elgg_get_upgrade_files($submissionVars['path'] . 'engine/lib/upgrades/');
     datalist_set('processed_upgrades', serialize($upgrades));
     set_config('view', 'default', $site->getGUID());
     set_config('language', 'en', $site->getGUID());
     set_config('default_access', $submissionVars['siteaccess'], $site->getGUID());
     set_config('allow_registration', TRUE, $site->getGUID());
     set_config('walled_garden', FALSE, $site->getGUID());
     $this->enablePlugins();
     // reset the views path in case of installing over an old data dir.
     $dataroot = $submissionVars['dataroot'];
     $CONFIG->dataroot = $dataroot;
     $cache = new ElggFileCache($dataroot);
     $cache->delete('view_paths');
     elgg_invalidate_simplecache();
     elgg_regenerate_simplecache();
     return TRUE;
 }