/** * Constructor * * @param string $dir Directory with data ($root_path) * @param int $unzip_type Unzip type, see constants * @param bool $remove_zip Remove zip after using it. * * @access public * @return void */ public function __construct($dir = null, $unzip_type = self::UNZIP_PREFERENCE, $remove_zip = true, $mpv_lang = false) { global $phpEx, $lang; if (is_null($dir)) { global $root_path; $dir = $root_path; } /** * Language is already included, iam not going to overwrite it * If a user wants to include a non english language, starting from * September 4, 2010 he should not include his own language file. * MPV will include the requested language, to set the language, * you need to set it as default parameter for the contructor, * or define it as MPV_LANG. * Note that the parameter given to this function is used * if favour of MPV_LANG. */ if (!is_array($lang)) { $lang = ''; if (!file_exists($dir . '/includes/languages/')) { // Language dir does not exists. if (file_exists($dir . 'lang.' . $phpEx)) { $lang = 'lang.' . $phpEx; } else { die('Language directory not found'); } } else { if ($mpv_lang && file_exists($dir . '/includes/languages/' . $mpv_lang . '/lang.' . $phpEx)) { $lang = $dir . '/includes/languages/' . $mpv_lang . '/lang.' . $phpEx; } else { if (MPV_LANG && file_exists($dir . '/includes/languages/' . MPV_LANG . '/lang.' . $phpEx)) { $lang = $dir . '/includes/languages/' . MPV_LANG . '/lang.' . $phpEx; } else { // no language defined, use en $lang = $dir . '/includes/languages/en/lang.' . $phpEx; } } } include $lang; } set_error_handler(array($this, 'error_handler')); if ($unzip_type == self::UNZIP_PREFERENCE) { $unzip_type = self::UNZIP_PHPBB; $exec_check = false; if (function_exists('exec') && stristr(php_uname(), 'Windows') === false) { $check = false; @exec("whereis unzip", $check); if ($check[0] != "unzip:") { $exec_check = true; } } if ($exec_check) { $unzip_type = self::UNZIP_EXEC; } else { if (extension_loaded('zip')) { $unzip_type = self::UNZIP_PHP; } } unset($exec_check); } if (defined('UNWANTED') && UNWANTED) { self::$unwanted_files = explode('|', UNWANTED); } $this->unzip_type = $unzip_type; $this->remove_zip = $remove_zip; $this->exec_php = self::DONT_EXEC_PHP; $this->dir = $dir; $this->errors = array(); $this->message = ''; $this->xsl_files = array(); $this->modx_files = array(); $this->package_files = array(); $this->package_directories = array(); $this->test_collections = array(); $this->output_type = self::OUTPUT_BBCODE; require $this->dir . 'includes/tests/test_base.php'; // Get the available test collections if ($opendir = opendir($this->dir . 'includes/tests/')) { while (false !== ($file = readdir($opendir))) { if (preg_match('#tests_([a-z]+)\\.' . preg_quote($phpEx, '#') . '$#i', $file)) { $php_file = $this->dir . 'includes/tests/' . $file; require $php_file; $class_name = 'mpv_tests_' . substr(basename($php_file), 6, -4); if (class_exists($class_name)) { $this->test_collections[$class_name] = new $class_name($this); } } } closedir($opendir); } }