Define more (uniquely prefixed) constants for Roundcube directories in order to enhance the interoperability of the Roundcube framework

pull/66/head
Thomas Bruederli 12 years ago
parent 5352b55779
commit 9be2f43d02

@ -43,6 +43,14 @@ if (!defined('RCMAIL_CONFIG_DIR')) {
define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config'); define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config');
} }
if (!defined('RCUBE_LOCALIZATION_DIR')) {
define('RCUBE_LOCALIZATION_DIR', INSTALL_PATH . 'program/localization/');
}
define('RCUBE_INSTALL_PATH', INSTALL_PATH);
define('RCUBE_CONFIG_DIR', RCMAIL_CONFIG_DIR);
// RC include folders MUST be included FIRST to avoid other // RC include folders MUST be included FIRST to avoid other
// possible not compatible libraries (i.e PEAR) to be included // possible not compatible libraries (i.e PEAR) to be included
// instead the ones provided by RC // instead the ones provided by RC

@ -52,12 +52,24 @@ define('RCMAIL_VERSION', '0.9-git');
define('RCMAIL_CHARSET', 'UTF-8'); define('RCMAIL_CHARSET', 'UTF-8');
define('RCMAIL_START', microtime(true)); define('RCMAIL_START', microtime(true));
if (!defined('INSTALL_PATH')) { if (!defined('RCUBE_LIB_DIR')) {
define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/'); define('RCUBE_LIB_DIR', dirname(__FILE__).'/');
} }
if (!defined('RCMAIL_CONFIG_DIR')) { if (!defined('RCUBE_INSTALL_PATH')) {
define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config'); define('RCUBE_INSTALL_PATH', RCUBE_LIB_DIR);
}
if (!defined('RCUBE_CONFIG_DIR')) {
define('RCUBE_CONFIG_DIR', RCUBE_INSTALL_PATH . 'config');
}
if (!defined('RCUBE_PLUGINS_DIR')) {
define('RCUBE_PLUGINS_DIR', RCUBE_INSTALL_PATH . 'plugins/');
}
if (!defined('RCUBE_LOCALIZATION_DIR')) {
define('RCUBE_LOCALIZATION_DIR', RCUBE_INSTALL_PATH . 'localization/');
} }
// set internal encoding for mbstring extension // set internal encoding for mbstring extension

@ -596,8 +596,8 @@ class rcube
ob_start(); ob_start();
// get english labels (these should be complete) // get english labels (these should be complete)
@include(INSTALL_PATH . 'program/localization/en_US/labels.inc'); @include(RCUBE_LOCALIZATION_DIR . 'en_US/labels.inc');
@include(INSTALL_PATH . 'program/localization/en_US/messages.inc'); @include(RCUBE_LOCALIZATION_DIR . 'en_US/messages.inc');
if (is_array($labels)) if (is_array($labels))
$this->texts = $labels; $this->texts = $labels;
@ -605,9 +605,9 @@ class rcube
$this->texts = array_merge($this->texts, $messages); $this->texts = array_merge($this->texts, $messages);
// include user language files // include user language files
if ($lang != 'en' && $lang != 'en_US' && is_dir(INSTALL_PATH . 'program/localization/' . $lang)) { if ($lang != 'en' && $lang != 'en_US' && is_dir(RCUBE_LOCALIZATION_DIR . $lang)) {
include_once(INSTALL_PATH . 'program/localization/' . $lang . '/labels.inc'); include_once(RCUBE_LOCALIZATION_DIR . $lang . '/labels.inc');
include_once(INSTALL_PATH . 'program/localization/' . $lang . '/messages.inc'); include_once(RCUBE_LOCALIZATION_DIR . $lang . '/messages.inc');
if (is_array($labels)) if (is_array($labels))
$this->texts = array_merge($this->texts, $labels); $this->texts = array_merge($this->texts, $labels);
@ -645,7 +645,7 @@ class rcube
} }
if (empty($rcube_languages)) { if (empty($rcube_languages)) {
@include(INSTALL_PATH . 'program/localization/index.inc'); @include(RCUBE_LOCALIZATION_DIR . 'index.inc');
} }
// check if we have an alias for that language // check if we have an alias for that language
@ -666,7 +666,7 @@ class rcube
} }
} }
if (!isset($rcube_languages[$lang]) || !is_dir(INSTALL_PATH . 'program/localization/' . $lang)) { if (!isset($rcube_languages[$lang]) || !is_dir(RCUBE_LOCALIZATION_DIR . $lang)) {
$lang = 'en_US'; $lang = 'en_US';
} }
@ -684,11 +684,11 @@ class rcube
static $sa_languages = array(); static $sa_languages = array();
if (!sizeof($sa_languages)) { if (!sizeof($sa_languages)) {
@include(INSTALL_PATH . 'program/localization/index.inc'); @include(RCUBE_LOCALIZATION_DIR . 'index.inc');
if ($dh = @opendir(INSTALL_PATH . 'program/localization')) { if ($dh = @opendir(RCUBE_LOCALIZATION_DIR)) {
while (($name = readdir($dh)) !== false) { while (($name = readdir($dh)) !== false) {
if ($name[0] == '.' || !is_dir(INSTALL_PATH . 'program/localization/' . $name)) { if ($name[0] == '.' || !is_dir(RCUBE_LOCALIZATION_DIR . $name)) {
continue; continue;
} }
@ -1017,7 +1017,7 @@ class rcube
$log_dir = self::$instance ? self::$instance->config->get('log_dir') : null; $log_dir = self::$instance ? self::$instance->config->get('log_dir') : null;
if (empty($log_dir)) { if (empty($log_dir)) {
$log_dir = INSTALL_PATH . 'logs'; $log_dir = RCUBE_INSTALL_PATH . 'logs';
} }
// try to open specific log file for writing // try to open specific log file for writing

@ -71,11 +71,11 @@ class rcube_config
private function load() private function load()
{ {
// load main config file // load main config file
if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/main.inc.php')) if (!$this->load_from_file(RCUBE_CONFIG_DIR . '/main.inc.php'))
$this->errors[] = 'main.inc.php was not found.'; $this->errors[] = 'main.inc.php was not found.';
// load database config // load database config
if (!$this->load_from_file(RCMAIL_CONFIG_DIR . '/db.inc.php')) if (!$this->load_from_file(RCUBE_CONFIG_DIR . '/db.inc.php'))
$this->errors[] = 'db.inc.php was not found.'; $this->errors[] = 'db.inc.php was not found.';
// load host-specific configuration // load host-specific configuration
@ -96,8 +96,8 @@ class rcube_config
$this->prop['skin'] = self::DEFAULT_SKIN; $this->prop['skin'] = self::DEFAULT_SKIN;
// fix paths // fix paths
$this->prop['log_dir'] = $this->prop['log_dir'] ? realpath(unslashify($this->prop['log_dir'])) : INSTALL_PATH . 'logs'; $this->prop['log_dir'] = $this->prop['log_dir'] ? realpath(unslashify($this->prop['log_dir'])) : RCUBE_INSTALL_PATH . 'logs';
$this->prop['temp_dir'] = $this->prop['temp_dir'] ? realpath(unslashify($this->prop['temp_dir'])) : INSTALL_PATH . 'temp'; $this->prop['temp_dir'] = $this->prop['temp_dir'] ? realpath(unslashify($this->prop['temp_dir'])) : RCUBE_INSTALL_PATH . 'temp';
// fix default imap folders encoding // fix default imap folders encoding
foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder) foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder)
@ -156,7 +156,7 @@ class rcube_config
} }
if ($fname) { if ($fname) {
$this->load_from_file(RCMAIL_CONFIG_DIR . '/' . $fname); $this->load_from_file(RCUBE_CONFIG_DIR . '/' . $fname);
} }
} }

@ -244,8 +244,8 @@ class rcube_csv2vcard
{ {
// Localize fields map // Localize fields map
if ($lang && $lang != 'en_US') { if ($lang && $lang != 'en_US') {
if (file_exists(INSTALL_PATH . "program/localization/$lang/csv2vcard.inc")) { if (file_exists(RCUBE_LOCALIZATION_DIR . "$lang/csv2vcard.inc")) {
include INSTALL_PATH . "program/localization/$lang/csv2vcard.inc"; include RCUBE_LOCALIZATION_DIR . "$lang/csv2vcard.inc";
} }
if (!empty($map)) { if (!empty($map)) {

@ -66,7 +66,7 @@ class rcube_db_sqlite extends rcube_db
// Initialize database structure in file is empty // Initialize database structure in file is empty
if (!empty($dsn['database']) && !filesize($dsn['database'])) { if (!empty($dsn['database']) && !filesize($dsn['database'])) {
$data = file_get_contents(INSTALL_PATH . 'SQL/sqlite.initial.sql'); $data = file_get_contents(RCUBE_INSTALL_PATH . 'SQL/sqlite.initial.sql');
if (strlen($data)) { if (strlen($data)) {
$this->debug('INITIALIZE DATABASE'); $this->debug('INITIALIZE DATABASE');

@ -653,7 +653,7 @@ class rcube_mime
{ {
$mime_type = null; $mime_type = null;
$mime_magic = rcube::get_instance()->config->get('mime_magic'); $mime_magic = rcube::get_instance()->config->get('mime_magic');
$mime_ext = @include RCMAIL_CONFIG_DIR . '/mimetypes.php'; $mime_ext = @include RCUBE_CONFIG_DIR . '/mimetypes.php';
// use file name suffix with hard-coded mime-type map // use file name suffix with hard-coded mime-type map
if (is_array($mime_ext) && $name) { if (is_array($mime_ext) && $name) {

@ -592,7 +592,7 @@ class rcube_output_html extends rcube_output
$ERROR_CODE = $code; $ERROR_CODE = $code;
$ERROR_MESSAGE = $message; $ERROR_MESSAGE = $message;
include INSTALL_PATH . 'program/steps/utils/error.inc'; include RCUBE_INSTALL_PATH . 'program/steps/utils/error.inc';
exit; exit;
} }
@ -921,11 +921,11 @@ class rcube_output_html extends rcube_output
} }
else if ($object == 'version') { else if ($object == 'version') {
$ver = (string)RCMAIL_VERSION; $ver = (string)RCMAIL_VERSION;
if (is_file(INSTALL_PATH . '.svn/entries')) { if (is_file(RCUBE_INSTALL_PATH . '.svn/entries')) {
if (preg_match('/Revision:\s(\d+)/', @shell_exec('svn info'), $regs)) if (preg_match('/Revision:\s(\d+)/', @shell_exec('svn info'), $regs))
$ver .= ' [SVN r'.$regs[1].']'; $ver .= ' [SVN r'.$regs[1].']';
} }
else if (is_file(INSTALL_PATH . '.git/index')) { else if (is_file(RCUBE_INSTALL_PATH . '.git/index')) {
if (preg_match('/Date:\s+([^\n]+)/', @shell_exec('git log -1'), $regs)) { if (preg_match('/Date:\s+([^\n]+)/', @shell_exec('git log -1'), $regs)) {
if ($date = date('Ymd.Hi', strtotime($regs[1]))) { if ($date = date('Ymd.Hi', strtotime($regs[1]))) {
$ver .= ' [GIT '.$date.']'; $ver .= ' [GIT '.$date.']';
@ -1760,7 +1760,7 @@ class rcube_output_html extends rcube_output
'about.html', 'about.html',
); );
foreach ($filenames as $file) { foreach ($filenames as $file) {
$fn = RCMAIL_CONFIG_DIR . '/' . $file; $fn = RCUBE_CONFIG_DIR . '/' . $file;
if (is_readable($fn)) { if (is_readable($fn)) {
$content = file_get_contents($fn); $content = file_get_contents($fn);
$content = $this->parse_conditions($content); $content = $this->parse_conditions($content);

@ -20,8 +20,8 @@
*/ */
// location where plugins are loade from // location where plugins are loade from
if (!defined('RCMAIL_PLUGINS_DIR')) if (!defined('RCUBE_PLUGINS_DIR'))
define('RCMAIL_PLUGINS_DIR', INSTALL_PATH . 'plugins/'); define('RCUBE_PLUGINS_DIR', RCUBE_INSTALL_PATH . 'plugins/');
/** /**
@ -101,7 +101,7 @@ class rcube_plugin_api
*/ */
protected function __construct() protected function __construct()
{ {
$this->dir = slashify(RCMAIL_PLUGINS_DIR); $this->dir = slashify(RCUBE_PLUGINS_DIR);
} }

Loading…
Cancel
Save