Ejemplo n.º 1
0
    }
    if (!empty($page['errors'])) {
        $newfile_page = true;
    } else {
        $template->assign('template', $filename);
        $edited_file = $_POST['tpl_parent'] . '/' . $filename;
        $content_file = $_POST['tpl_model'] == '0' ? '' : file_get_contents($_POST['tpl_model']);
    }
}
if ($newfile_page) {
    $filename = isset($_POST['tpl_name']) ? $_POST['tpl_name'] : '';
    $selected['model'] = isset($_POST['tpl_model']) ? $_POST['tpl_model'] : '0';
    $selected['parent'] = isset($_POST['tpl_parent']) ? $_POST['tpl_parent'] : PHPWG_ROOT_PATH . 'template-extension';
    // Parent directories list
    $options['parent'] = array(PHPWG_ROOT_PATH . 'template-extension' => 'template-extension');
    $options['parent'] = array_merge($options['parent'], get_rec_dirs(PHPWG_ROOT_PATH . 'template-extension'));
    $options['model'][] = l10n('locfiledit_empty_page');
    $options['model'][] = '----------------------';
    $i = 0;
    foreach (get_extents() as $pwg_template) {
        $value = PHPWG_ROOT_PATH . 'template-extension/' . $pwg_template;
        $options['model'][$value] = 'template-extension / ' . str_replace('/', ' / ', $pwg_template);
        $i++;
    }
    foreach (get_dirs($conf['themes_dir']) as $theme_id) {
        if ($i) {
            $options['model'][] = '----------------------';
            $i = 0;
        }
        $dir = $conf['themes_dir'] . '/' . $theme_id . '/template/';
        if (is_dir($dir) and $content = opendir($dir)) {
/**
 * returns dirs and subdirs
 * retun array
 * @param string
 */
function get_rec_dirs($path = '')
{
    $options = array();
    if (is_dir($path)) {
        $fh = opendir($path);
        while ($file = readdir($fh)) {
            $pathfile = $path . '/' . $file;
            if ($file != '.' and $file != '..' and $file != '.svn' and is_dir($pathfile)) {
                $options[$pathfile] = str_replace(array('./', '/'), array('', ' / '), $pathfile);
                $options = array_merge($options, get_rec_dirs($pathfile));
            }
        }
        closedir($fh);
    }
    return $options;
}