From: Erin S. <si...@ha...> - 2002-10-25 15:14:09
|
Marc Groot Koerkamp said: > Erin Schnabel zei: >> I think we >> need to continue to define SM_PATH exactly as we do today. >> >> In any displayed file, src or plugin, I think we should use: >> >> define('SM_PATH', '<../ or ../../>'); >> require_once(SM_PATH . 'sm_init.php'); >> >> Where sm_init.php is located at the base of the tree, and defines >> other path variables as appropriate. >> sm_init.php could then do something like this: >> >> // Install config path required to stay in the tree >> // and have this location.. >> require_once(SM_PATH . 'config/config.php'); >> >> define('SM_LIB_PATH', $config_lib_path); >> ... >> >> Where config.php contains something like this in the >> default case: >> >> $config_lib_path = SM_PATH . 'lib'; >> >> Which is how it currently handles the paths for themes, the >> org_logos, and relative data and attachment directories. >> >> Is that clearer? ;) >> OI! It certainly isn't any more concise. :-P >> > In mine opinion it should be: > require_once('../include/sm_init.php'); > require_once(SM_SRC_PATH. 'some_file.php'); > require_once(SM_FUNC_PATH.'some_file2.php'); > > and in sm_init.php we do: > $script = $_SERVER['SCRIPT_FILENAME']; > <locate the directory where the script is located> > pseudo code: > switch ($dir) { > case 'src': > $sm_root = substr($script,0,$offset) > case 'plugins': > .... > } > required static SM locations > define ('SM_PATH',$sm_root); > define ('SM_SRC_PATH' SM_PATH . 'src/'); > ..... > > configurable locations: > include path definitions from some config file > if ($xxx_path && $xxx != 'xxx') { > define ('SM_XXX_PATH', $xxx_path); > } else { > define ('SM_XXX_PATH',SM_PATH .'xxx/'); > } > > This also implies that we should get rid of all the '../xxx' > configured paths. > instead configure it as 'xxx' which means that it's a subdir of the > SM root > dir. > > After this the SM_PATHS are defined absolute instead of relative and > you still > can move your SM dir to other places without the need for changing > your > config. Like I said, I don't think this: require_once('../include/sm_init.php'); is appropriate. We started all this to get rid of those kinds of includes, and I think allowing even one will cause them to propagate AGAIN (if only because the example is there). Also, note that the $_SERVER['SCRIPT_FILENAME'] variable returns where the original script started from, rather than where the sm_init script would be located. Which means, you'd need to figure out from within sm_init.php who included him, so you know how much to lop off the path. If sm_init is included from .../src/folders.php, then you have to lop off everything after the second to last slash (src to end). If sm_init is included from a plugin, you have to lop off anything from plugins to the end (.../plugins/<plugname>/<file>.php). Coding this in sm_init would be a kludge at best. I think you're better off sticking with SM_PATH, and working off of it, as I mentioned in the email you quoted above. |