'default', //TODO : not static 'page_layout' => 'article', 'page_title' => '(missing)', 'page_description' => '(missing)', 'page_keywords' => '(missing)' ); $ini_path="content/$path/$name/props.ini"; $res=write_ini_file($props, $ini_path, false); } return $res; } // TODO : choose between unix convention (0 is fine, else is error) and PHP one (FALSE is error, else is okay) function do_action($kind,$action,$path,$name) { if ($action==='none') return 0; if ($name==='') return E_INVALID_NAME; if ( ! is_valid_path($kind,$path) ) return E_INVALID_PATH; if ( is_valid_path($kind,$path . '/' . $name) ) return E_INVALID_NAME; switch ($action) { case 'add_fold': return add_fold($kind,$path,$name); break; case 'add_item': if ( $kind=='media' ) { return add_media($path,$name); } else { return add_page($path,$name); } break; default: return E_INVALID_ACTION; } } // Config loading $site_conf = load_ini_site_conf("content/site_conf.ini"); if ( ! is_array($site_conf) ) trigger_error("Error parsing site_conf.ini", E_USER_ERROR); // Localization Init l10n_init($site_conf['site_admin_lang']); $default_path = _('(choose a folder in the tree)'); // URL parameter parsing $kind = sanitize($_GET, 'kind', RE_IDENTIFIER_CLEANER, 'page'); /* Could be : page, media */ $action=sanitize($_GET, 'action', RE_IDENTIFIER_CLEANER, 'none'); /* Could be : none, add_fold, add_item */ $path = sanitize($_GET, 'path', RE_RELPATH_CLEANER, $default_path); $name = sanitize($_GET, 'name', RE_IDENTIFIER_CLEANER, ''); // Pre-computed because used twice $page_title = _('Admin') . ' - ' . ( ($kind=='media')?_('Add or remove a media'):_('Add or remove a page') ); $res=do_action($kind,$action,$path,$name); if ($res===E_INVALID_PATH) $path = $default_path; //echo "
\$res==$res\n"; //TODO : user feedback for success/failure ?>