/** * Checks if /cache directory has been symlinked to views simplecache directory * * @return bool * @access private */ function _elgg_is_cache_symlinked() { $link = elgg_get_root_path() . 'cache/'; $target = elgg_get_cache_path() . 'views_simplecache/'; return is_dir($link) && realpath($target) == realpath($link); }
$params['class'] = 'elgg-state-disabled'; $params['label_class'] = 'elgg-state-disabled'; $simple_cache_warning .= "<span class=\"elgg-text-help\">" . elgg_echo('admin:settings:in_settings_file') . "</span>"; } $simple_cache_input = elgg_view("input/checkbox", $params); $cache_symlinked = _elgg_is_cache_symlinked(); $params = array('label' => elgg_echo('installation:cache_symlink:label'), 'name' => 'cache_symlink_enabled', 'checked' => $cache_symlinked, 'class' => $simple_cache_disabled_class, 'label_class' => $simple_cache_disabled_class, 'switch' => true); $symlink_warning = '<p class="elgg-text-help">' . elgg_echo('installation:cache_symlink:description') . '</p>'; if ($cache_symlinked) { $params['class'] = 'elgg-state-disabled'; $params['label_class'] = 'elgg-state-disabled'; $symlink_warning .= elgg_format_element('span', ['class' => 'elgg-text-help'], elgg_echo('installation:cache_symlink:warning')); } $symlink_input = elgg_view('input/checkbox', $params); $symlink_source = elgg_get_root_path() . 'cache/'; $symlink_target = elgg_get_cache_path() . 'views_simplecache/'; $symlink_paths_help = elgg_echo('installation:cache_symlink:paths', [$symlink_source, $symlink_target]); $symlink_warning .= elgg_format_element('span', ['class' => 'elgg-text-help'], $symlink_paths_help); // minify $minify_description = elgg_echo('installation:minify:description'); $minify_js_input = elgg_view("input/checkbox", array('label' => elgg_echo('installation:minify_js:label'), 'name' => 'simplecache_minify_js', 'checked' => (bool) elgg_get_config('simplecache_minify_js'), 'label_class' => $simple_cache_disabled_class, 'switch' => true)); $minify_css_input = elgg_view("input/checkbox", array('label' => elgg_echo('installation:minify_css:label'), 'name' => 'simplecache_minify_css', 'checked' => (bool) elgg_get_config('simplecache_minify_css'), 'label_class' => $simple_cache_disabled_class, 'switch' => true)); $system_cache_input = elgg_view_field(['#type' => 'checkbox', 'label' => elgg_echo('installation:systemcache:label'), 'help' => elgg_echo('installation:systemcache:description'), 'name' => 'system_cache_enabled', 'switch' => true, 'checked' => elgg_is_system_cache_enabled(), '#class' => 'mtm']); $body = <<<BODY \t<div> \t\t{$simple_cache_input} \t\t{$simple_cache_warning} \t</div> \t<div> \t\t{$symlink_input} \t\t{$symlink_warning}
if (strpos($dataroot, '/') !== 0) { $msg = elgg_echo('admin:configuration:dataroot:relative_path', array($dataroot)); register_error($msg); forward(REFERER); } } elgg_save_config('dataroot', $dataroot); if ('on' === get_input('simplecache_enabled')) { elgg_enable_simplecache(); } else { elgg_disable_simplecache(); } $cache_symlinked = _elgg_is_cache_symlinked(); if ('on' === get_input('cache_symlink_enabled') && !$cache_symlinked) { if (!is_dir(elgg_get_root_path() . 'cache/')) { $cache_symlinked = symlink(elgg_get_cache_path() . 'views_simplecache/', elgg_get_root_path() . 'cache/'); } if (!_elgg_is_cache_symlinked()) { unlink(elgg_get_root_path() . 'cache/'); $cache_symlinked = false; } if (!$cache_symlinked) { register_error(elgg_echo('installation:cache_symlink:error')); } } elgg_save_config('simplecache_minify_js', 'on' === get_input('simplecache_minify_js')); elgg_save_config('simplecache_minify_css', 'on' === get_input('simplecache_minify_css')); if ('on' === get_input('system_cache_enabled')) { elgg_enable_system_cache(); } else { elgg_disable_system_cache();