예제 #1
0
    }
    foreach ($files as $n) {
        $fh = fopen($full . '/' . $n . '.php', 'w');
        if ($fh) {
            writeHeader($fh, $name, $author, $type);
            fclose($fh);
        }
    }
}
// if it's a template...
if ($type == 'template') {
    $contents = file_get_contents($full . '/index.php');
    $contents .= "\n\$dwoodata\t= array(); // if you need to set some additional template vars, add them here\nglobal \$page_id;\n\$variant = CAT_Helper_Page::getPageSettings(\$page_id,'internal','template_variant');\nif ( \$variant == '' ) \$variant = DEFAULT_TEMPLATE_VARIANT;\nif ( \$variant == '' || !file_exists(CAT_PATH.'/templates/bootstrap/templates/'.\$variant.'/index.tpl' ) )\n    \$variant = 'default';\n\$parser->setPath(CAT_TEMPLATE_DIR.'/templates/'.\$variant);\n\$parser->setFallbackPath(CAT_TEMPLATE_DIR.'/templates/default');\n\$parser->output('index.tpl',\$dwoodata);\n";
    file_put_contents($full . '/index.php', $contents);
    CAT_Helper_Directory::createDirectory($full . '/templates/default');
    CAT_Helper_Directory::recursiveCreateIndex($full . '/templates');
}
// insert module into DB
foreach ($info as $key => $value) {
    $key = str_replace($pre, 'module_', $key);
    $info[$key] = $value;
}
$info['addon_function'] = $type;
CAT_Helper_Addons::loadModuleIntoDB($dir, 'install', $info);
$success = true;
$message = $backend->lang()->translate('Module created successfully!');
printResult();
function printResult()
{
    global $message, $success;
    $ajax = array('message' => $message, 'success' => $success);