diff options
Diffstat (limited to 'code')
-rw-r--r-- | code/admin/add.php | 51 | ||||
-rw-r--r-- | code/admin/admin.css | 19 | ||||
-rw-r--r-- | code/admin/index.php | 26 | ||||
-rw-r--r-- | code/admin/utils.php | 4 |
4 files changed, 80 insertions, 20 deletions
diff --git a/code/admin/add.php b/code/admin/add.php index cb2ff16..02622fc 100644 --- a/code/admin/add.php +++ b/code/admin/add.php @@ -2,6 +2,31 @@ require_once('utils.php'); need_auth(); + function add_fold($kind,$path,$name) { + $fullpath=(($kind=='media')?'media/':'content/').$path.'/'.$name; +echo $fullpath . "\n"; + return mkdir($fullpath); + } + + function add_media($path,$name) { + //TODO + } + + function add_page($path,$name) { + if ( $res=add_fold('page',$path,$name) ) { + $props = array( + 'page_template' => 'default', + '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; + } + // 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); @@ -11,9 +36,26 @@ // URL parameter parsing $kind = sanitize($_GET, 'kind', RE_IDENTIFIER_CLEANER, 'page'); /* Could be : page, media */ + $action=sanitize($_GET, 'action', RE_IDENTIFIER_CLEANER, 'preview'); /* Could be : none, add_fold, add_item */ + $path = sanitize($_GET, 'path', RE_RELPATH_CLEANER, ''); + $name = sanitize($_GET, 'name', RE_IDENTIFIER_CLEANER, ''); // Pre-computed because used twice - $page_title = _('Admin') . ' - ' . ( ($kind=='media')?_('Add a media'):_('Add a page') ); + $page_title = _('Admin') . ' - ' . ( ($kind=='media')?_('Add or remove a media'):_('Add or remove a page') ); + + $res=null; + switch ($action) { + case 'add_fold': + $res=add_fold($kind,$path,$name); + break; + case 'add_item': + if ( $kind=='media' ) { + $res=add_media($path,$name); + } else { + $res=add_page($path,$name); + } + break; + } ?> <!DOCTYPE html> <html> @@ -28,6 +70,7 @@ <h1><?=$page_title?></h1> <form> +<span class="inline_half"> <fieldset> <legend><?=($kind=='media')?_('Media tree'):_('Page tree')?></legend> <div class="css-treeview"> @@ -41,20 +84,20 @@ ?> </div> </fieldset> - +</span><!-- No blanks here, important for CSS --><span class="inline_half"> <fieldset> <legend><?=_('Selected folder')?></legend> <label for="fold_path"><?=_('Folder path')?></label> <input id="fold_path" name="fold_path" readonly="readonly" value="<?=_('(choose a folder in the tree)')?>"><br> <label for="fold_add_name"><?=_('New item name')?></label> -<input id="fold_add_name" type="text" value=""> +<input id="fold_add_name" type="text" value=""><br> <label for="fold_add_fold"><?=_('Actions')?></label> <input id="fold_add_fold" type="button" value="<?=_('Add folder')?>" onclick="go_add('<?=$kind?>','fold');"> <input id="fold_add_item" type="button" value="<?=_('Add page')?>" onclick="go_add('<?=$kind?>','item');"> </fieldset> - +</span><!-- No blanks here, important for CSS --><span class="inline_half"> <input id="fold_back_admin" type="button" value="<?=_('Back to admin')?>" onclick="go_admin_page();"> </form> diff --git a/code/admin/admin.css b/code/admin/admin.css index f394ef9..6561044 100644 --- a/code/admin/admin.css +++ b/code/admin/admin.css @@ -3,17 +3,30 @@ h1 { font-size:160% } -fieldset { +form { + text-align:center; /* For inner inline blocks */ +} + +span.inline_half { + margin: 0; + padding: 0; display:inline-block; vertical-align: top; - margin: 0.5em; - width:45%; + width:50%; + min-width:28em; + text-align:left; /* Clear parent trick */ +} + +fieldset { + margin: 0 0.5em 0.5em 0.5em; } + fieldset>label { display:inline-block; text-align:right; width: 12em; } + .tree_add { display:block; float:right; diff --git a/code/admin/index.php b/code/admin/index.php index dc10206..8cf1b39 100644 --- a/code/admin/index.php +++ b/code/admin/index.php @@ -26,9 +26,10 @@ <h1><?=$page_title?></h1> <form> +<span class="inline_half"> <fieldset> <legend><?=_('Page tree')?></legend> -<input id="page_add" class="tree_add" type="button" value="<?=_('Add page')?>" onclick="go_add_form('page');"> +<input id="page_add" class="tree_add" type="button" value="<?=_('Add/Delete page')?>" onclick="go_add_form('page');"> <div class="css-treeview"> <?php $page_tree=find_all('./content', 'page'); @@ -37,7 +38,7 @@ ?> </div> </fieldset> - +</span><!-- No blanks here, important for CSS --><span class="inline_half"> <fieldset> <legend><?=_('Selected page')?></legend> <label for="page_path"><?=_('Page path')?></label> @@ -45,7 +46,8 @@ <label for="page_edit"><?=_('Actions')?></label> <input id="page_edit" type="button" value="<?=_('Edit page')?>" onclick="go_edit_page();"> -<input id="page_delete" type="button" value="<?=_('Delete page')?>" onclick="go_delete_page();"> +<!--<input id="page_delete" type="button" value="<?=_('Delete page')?>" onclick="go_delete_page();">--> +<input id="page_rename" type="button" value="<?=_('Rename page')?>" onclick="rename_page();"> <br><br> @@ -61,10 +63,10 @@ <label for="page_submit"></label> <input id="page_submit" type="button" value="<?=_('Save properties')?>" onclick="save_page_props();"><br> </fieldset> - +</span><!-- No blanks here, important for CSS --><span class="inline_half"> <fieldset> <legend><?=_('Media tree')?></legend> -<input id="media_add" class="tree_add" type="button" value="<?=_('Add media')?>" onclick="go_add_form('media');"> +<input id="media_add" class="tree_add" type="button" value="<?=_('Add/Delete media')?>" onclick="go_add_form('media');"> <div class="css-treeview"> <?php $media_tree=find_all('../media', 'media'); @@ -73,17 +75,17 @@ ?> </div> </fieldset> - +</span><!-- No blanks here, important for CSS --><span class="inline_half"> <fieldset> <legend><?=_('Selected Media')?></legend> <label for="media_path"><?=_('Media path')?></label> <input id="media_path" name="media_path" readonly="readonly" value="<?=_('(choose a media in the tree)')?>"><br> -<label for="media_edit"><?=_('Actions')?></label> -<!--<input id="media_edit" type="button" value="Edit media">--> +<!--<label for="media_edit"><?=_('Actions')?></label> +<input id="media_edit" type="button" value="Edit media"> <input id="media_delete" type="button" value="<?=_('Delete media')?>" onclick="go_delete_media();"> - <br><br> +--> <label for="media_title"><?=_('Media title')?></label> <input id="media_title" name="media_title" value=""><br> @@ -97,7 +99,7 @@ <label for="media_submit"></label> <input id="media_submit" type="button" value="<?=_('Save properties')?>" onclick="save_media_props();"><br> </fieldset> - +</span><!-- No blanks here, important for CSS --><span class="inline_half"> <fieldset> <legend><?=_('Site properties')?></legend> <label for="site_admin_lang"><?=_('Admin lang')?></label> @@ -109,7 +111,9 @@ <label for="site_submit"></label> <input id="site_submit" type="button" value="<?=_('Save properties')?>" onclick="save_site_props();"><br> </fieldset> - +</span><!-- No blanks here, important for CSS --><span class="inline_half"> +<!-- Place holder --> +</span> </form> </body> </html> diff --git a/code/admin/utils.php b/code/admin/utils.php index 9612535..4db2d2d 100644 --- a/code/admin/utils.php +++ b/code/admin/utils.php @@ -77,8 +77,8 @@ function is_ress($kind, $path) { switch ($kind) { - case 'page': return is_file($path.'/props.ini'); - case 'media': return substr($path, -4)=='.jpg' && is_file($path); + case 'page': return ( is_dir($path) && is_file($path.'/props.ini') ); + case 'media': return ( substr($path, -4)=='.jpg' && is_file($path) ); default : return FALSE; } } |