/** * Returns a list of upgrade files relative to the $upgrade_path dir. * * @param string $upgrade_path The directory that has upgrade scripts * @return array|false * @access private * * @todo the wire and groups plugins and the installer are using this */ function elgg_get_upgrade_files($upgrade_path = null) { if (!$upgrade_path) { $upgrade_path = elgg_get_engine_path() . '/lib/upgrades/'; } $upgrade_path = sanitise_filepath($upgrade_path); $handle = opendir($upgrade_path); if (!$handle) { return false; } $upgrade_files = array(); while ($upgrade_file = readdir($handle)) { // make sure this is a well formed upgrade. if (is_dir($upgrade_path . '$upgrade_file')) { continue; } $upgrade_version = elgg_get_upgrade_file_version($upgrade_file); if (!$upgrade_version) { continue; } $upgrade_files[] = $upgrade_file; } sort($upgrade_files); return $upgrade_files; }
/** * @codeCoverageIgnore */ public static function boot() { if (version_compare(elgg_get_version(true), '1.9', '<')) { $autoloader = new \CodeReview\Autoloader(); $autoloader->register(); } $enginePath = elgg_get_config('path') . 'engine/'; if (function_exists('elgg_get_engine_path')) { $enginePath = elgg_get_engine_path() . '/'; } self::initConfig(array('engine_path' => $enginePath, 'path' => elgg_get_config('path'), 'pluginspath' => elgg_get_plugins_path(), 'plugins_getter' => 'elgg_get_plugins')); }
/** * Runs unit tests for the database * * @param string $hook unit_test * @param string $type system * @param array $value Array of tests * * @return array * @access private */ function _elgg_db_test($hook, $type, $value) { $value[] = elgg_get_engine_path() . '/tests/ElggDataFunctionsTest.php'; return $value; }
/** * Returns translation data for a specific plugin * * @param string $current_language which language to return * @param string $plugin for which plugin do you want the translations * * @return fasle|array */ function translation_editor_get_plugin($current_language, $plugin) { if (empty($current_language) || empty($plugin)) { return false; } global $_ELGG; if ($plugin == 'core') { // Core translation $plugin_language = dirname(elgg_get_engine_path()) . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR . 'en.php'; } elseif ($plugin == 'custom_keys') { $plugin_language = elgg_get_data_path() . 'translation_editor' . DIRECTORY_SEPARATOR . 'custom_keys' . DIRECTORY_SEPARATOR . 'en.php'; } else { // plugin translations $plugin_object = elgg_get_plugin_from_id($plugin); if (!$plugin_object instanceof ElggPlugin) { return false; } $plugin_language = $plugin_object->getPath() . 'languages' . DIRECTORY_SEPARATOR . 'en.php'; } translation_editor_reload_all_translations(); translation_editor_load_translations($current_language); $result = ['total' => 0]; $backup_full = $_ELGG->translations; $_ELGG->translations = []; // Fetch translations if (file_exists($plugin_language)) { $plugin_language_array = (include $plugin_language); if (is_array($plugin_language_array)) { add_translation('en', $plugin_language_array); } unset($_ELGG->translations['en']['']); $plugin_keys = $_ELGG->translations['en']; $key_count = count($plugin_keys); if (array_key_exists($current_language, $backup_full)) { $exists_count = $key_count - count(array_diff_key($plugin_keys, $backup_full[$current_language])); } else { $exists_count = 0; } $custom_content = translation_editor_read_translation($current_language, $plugin); if (!empty($custom_content)) { $custom = $custom_content; } else { $custom = []; } $result['total'] = $key_count; $result['exists'] = $exists_count; $result['en'] = $plugin_keys; $result['current_language'] = array_intersect_key($backup_full[$current_language], $plugin_keys); $result['custom'] = $custom; } $_ELGG->translations = $backup_full; return $result; }