Example #1
0
function get_file_substitution_values($handle, $type, $author, $override)
{
    $subs = array();
    $subs['dir'] = handle_to_path($handle, $type);
    if (0 == strcmp("controller", $type)) {
        $subs['class'] = handle_to_controller($handle);
    } else {
        $subs['class'] = handle_to_class($handle, $type);
    }
    list($plugin, $class) = explode("/", $handle);
    list($codepool, $company, $plugin_dir) = explode("/", module_path($plugin));
    $subs['filename'] = handle_to_file($handle, $type);
    $subs['output_file'] = "{$subs['dir']}/{$subs['filename']}";
    $subs['package'] = $company;
    $subs['description'] = cmd_switch("description");
    if (!$subs['description']) {
        $subs['description'] = user_text("Enter a description for the file");
    }
    $subs['plugin'] = $plugin_dir;
    $subs['author'] = cmd_switch("author");
    if (!$subs['author']) {
        $subs['author'] = user_text("Who is the author of the plugin", $author);
    }
    $subs['copyright'] = date("Y") . " " . $subs['author'];
    if (file_exists($subs['output_file'])) {
        throw new Exception("Class already exists, so I can't create it again, amirite?");
    }
    // FIXME
    $subs['extends'] = "";
    if ($override) {
        $subs['extends'] = " extends {$override}";
    }
    return $subs;
}
Example #2
0
function filter_rewrite_class(&$values, $default)
{
    if (cmd_switch('rewrite_handle')) {
        $values['rewrite_class'] = cmd_switch('rewrite_handle');
    } else {
        $class = user_text("Select class to override to", $default);
        $values['rewrite_class'] = $class;
    }
}