Fred Hirsch <[EMAIL PROTECTED]> said:
The code below might work to import php into snippets, (no guarentees)
PHP-Nuke looks like overlaps alot of Midgard's features, and the rest could be
implemented quite easily..
>From a brief look at the code,
the code and HTML are heavily tied together - so creating a midgard-ized app
would be alot of work..
regards
alan
<? // convert php3 files and put them into midgard.
function get_snippetdir_byname($baseid, $dir) {
global $importdescription;
if ($snippetdirs = mgd_list_snippetdirs($baseid)) {
while ($snippetdirs->fetch()) {
if ($snippetdirs->name == $dir) return $snippetdirs->id;
}
}
return mgd_create_snippetdir($baseid, $dir, $importdescription, 0);
}
function convertsnippet($baseid, $dir, $file) {
global $rootdir, $importdescription;
// read the file
$contents = implode("", file($dir . "/" . $file));
// do the include & require replacements!
$contents = ereg_replace("include\(", "mgd_include_snippet('$rootdir' . ",
$contents);
$contents = ereg_replace("require\(", "mgd_include_snippet('$rootdir' . ",
$contents);
// does it exist!
if ($existsnippet = mgd_get_snippet_by_name($baseid, $file)) {
// then update it!
mgd_update_snippet($existsnippet->id, $file, $contents,
$importdescription,0);
} else {
mgd_create_snippet($baseid, $file, $contents, $importdescription, 0);
}
print "imported $file";
// create or update!
}
function convertsnippetdir($basedir, $dir, $baseid) {
//
// does this snippet dir exist!!!
// list all snippet dirs in the base!!!
$newbaseid = get_snippetdir_byname($baseid, $dir);
$handle = opendir($basedir . "/" . $dir);
while ($dirs = readdir($handle)) {
if (
(filetype($basedir . "/". $dir . "/" .$dirs) == "dir") &&
(!ereg("^[.]+$", $dirs ))
) {
// then it is a dir!
// check to see if it exists!
convertsnippetdir($basedir . "/" . $dir, $dirs , $newbaseid);
} elseif (
(filetype($basedir . "/" . $dir . "/" .$dirs) != "dir") &&
(ereg("\.php", $dirs ))
) {
// then it is a php file! - lets import it!
convertsnippet($newbaseid, $basedir . "/" . $dir , $dirs);
}
}
}
$importdescription = "SOME PROGRAM";
$rootdir = "/someprogram/";
convertsnippetdir("/somediretory/", "dirname", 0);
//mmh wonder if this works!!
?>
> Has anyone tried porting PHPNuke to Midgard using snippets or otherwise?
>
> Fred
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
Technical Director
Linux Center (HK) Ltd.
www.hklc.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]