1

Topic: Constants in config

So, i am in the config.php from the imagemanager folder, in that folder i've included the config from my custom MVC framework in which there are just a few defined constants, one of them is BASE_PATH.

I've done this:

$mcImageManagerConfig['filesystem.path'] = BASE_PATH;
$mcImageManagerConfig['filesystem.rootpath'] = BASE_PATH . "apps/";

and i get this in the LOG

2012-03-28 20:02:38 - Configured root: D:/Wamp/www/henk/apps/admin_test2/template/js/tiny_mce/plugins/imagemanager/BASE_PATHapps could not be found.


if add:
var_dump(BASE_PATH);
exit();

before:
$mcImageManagerConfig['filesystem.path'] = BASE_PATH;


when i click the imageupload button in tinymvc, it shows the dialog, and this:
string 'D:/Wamp/www/henk/' (length=17)

so the constant is defined, now, WHAT THE HELL IS HAPPENING?!

LE: if i define the constant in the same file it works fine
PS: no errors,warnings, notices, NOTHING

Last edited by geo.ariton (2012-03-29 11:57:05)

2

Re: Constants in config

You need to add the constant into config.php by including the file that has that constant or use the SessionAuthenticator and override the filesystem.root_path setting.

Best regards,
Spocke - Main developer of TinyMCE

3

Re: Constants in config

here are my steps:
1. the file is included (require, require once, include once, file_get_contents, fread, eval, all tested, all the constants echo correctly)
2. Uppon seting the values something like this $mcImageManagerConfig['filesystem.path'] = BASE_PATH , it does not work, it reads it literaly like a string (if i echo base_path, it echoes correctly)

Alternate solution:
1. leave the code above unchanged
2. instead of including the file, i define my constants in the same config.php where the $mcImageManagerConfig array exists
3. everything works like a charm

if the constants are defined in another file, they do not work, i have no idea why...

4

Re: Constants in config

Sounds very strange. Could be that it's not included properly when the path changes.
So when you load your external file into config.php use:
require_once(dirname(__FILE__) . '/../path/to/file.php');

So it's always relative from the config.php file.

Best regards,
Spocke - Main developer of TinyMCE

5

Re: Constants in config

You are so right! I'll try it as soon as i can, i forgot that the include or the require gets the file relative to where that file is included so sometimes it might be loaded correctly, but when included by another file it might have problems.
I have not tested it, after i will test it i will leave a reply with my fix, hopefully i'm the only one with these kind of problems.
Thanks for the assist.

6

Re: Constants in config

Seems like that could be the problem here.

Best regards,
Spocke - Main developer of TinyMCE