Ejemplo n.º 1
0
/**
 * Walks through the boxes or forms folders and recursively builds a $list of found actions.
 *
 * @param string
 * @param string
 * @param string
 * @param array
 * @return boolean
 *
 */
function help_walker($appname, $type = 'boxes', $directory, &$list)
{
    $dir = new Dir($directory);
    if (!$dir->handle) {
        return false;
    }
    foreach ($dir->read_all() as $file) {
        if (strpos($file, '.') === 0 || $file == 'CVS') {
            continue;
        } elseif (@is_dir($directory . '/' . $file)) {
            $name = str_replace(getcwd() . '/inc/app/' . $appname . '/' . $type . '/', '', $directory . '/' . $file);
            $box = array('name' => $name, 'alt' => ucfirst(basename($name)), $type => array(), 'is_dir' => false);
            if (!@file_exists($directory . '/' . $file . '/index.php')) {
                $box['is_dir'] = true;
            } else {
                if ($type == 'boxes' && @file_exists($directory . '/' . $file . '/settings.php')) {
                    $settings = ini_parse($directory . '/' . $file . '/settings.php');
                    $box['alt'] = $settings['Meta']['name'];
                }
            }
            $list[$name] = $box;
            help_walker($appname, $type, $directory . '/' . $file, $list[$name][$type]);
        }
    }
    return true;
}
Ejemplo n.º 2
0
if ($parameters['appname'] == 'GLOBAL') {
    header('Location: ' . site_prefix() . '/index/appdoc-app');
    exit;
} elseif (empty($parameters['appname']) || strstr($parameters['appname'], '..') || !@is_dir(getcwd() . '/inc/app/' . $parameters['appname'])) {
    header('Location: ' . $_SERVER['HTTP_REFERER']);
    exit;
}
$path = getcwd() . '/inc/app/' . $parameters['appname'];
$info = ini_parse(getcwd() . '/inc/app/' . $parameters['appname'] . '/conf/config.ini.php', false);
$fullname = $info['app_name'];
if (!$fullname) {
    $fullname = ucfirst($parameters['appname']);
}
$data = array('boxes' => array(), 'forms' => array());
help_walker($parameters['appname'], 'boxes', $path . '/boxes', $data['boxes']);
help_walker($parameters['appname'], 'forms', $path . '/forms', $data['forms']);
foreach ($info as $k => $v) {
    $data[$k] = $v;
}
if (isset($data['author'])) {
    $data['author'] = preg_replace('/<([^>]+)>/', '&lt;<a href="mailto:\\1?subject=' . $fullname . '">\\1</a>&gt;', $data['author']);
}
if (@is_dir($path . '/docs/en')) {
    $data['helpdocs'] = site_prefix() . '/index/help-app?appname=' . $parameters['appname'];
} else {
    $data['helpdocs'] = false;
}
if (@file_exists($path . '/docs/api/index.html')) {
    $data['apidocs'] = site_prefix() . '/inc/app/' . $parameters['appname'] . '/docs/api';
} else {
    $data['apidocs'] = false;