From 71c9d686df603518e69deefbd34b2d5071b4df26 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 21 Mar 2010 14:50:08 +0000 Subject: [PATCH] enabled front page editing --- codepot/etc/codepot.ini.in | 8 +- codepot/src/codepot/controllers/issue.php | 4 +- codepot/src/codepot/controllers/site.php | 81 +++++++++++++++++-- .../codepot/language/english/common_lang.php | 8 +- .../language/indonesian/common_lang.php | 8 +- .../codepot/language/korean/common_lang.php | 8 +- codepot/src/codepot/models/sitemodel.php | 13 ++- codepot/src/codepot/views/Makefile.am | 2 + codepot/src/codepot/views/Makefile.in | 2 + codepot/src/codepot/views/projectbar.php | 2 +- codepot/src/codepot/views/site_adminhome.php | 79 ++++++++++++++++++ codepot/src/codepot/views/site_delete.php | 6 +- codepot/src/codepot/views/site_edit.php | 24 ++++-- codepot/src/codepot/views/site_home.php | 14 +--- codepot/src/codepot/views/site_show.php | 76 +++++++++++++++++ codepot/src/codepot/views/taskbar.php | 4 +- codepot/src/config.php.in | 4 +- codepot/src/css/Makefile.am | 1 + codepot/src/css/Makefile.in | 1 + codepot/src/css/project.css | 49 +---------- codepot/src/css/site.css | 59 ++++++++++++++ 21 files changed, 352 insertions(+), 101 deletions(-) create mode 100644 codepot/src/codepot/views/site_adminhome.php create mode 100644 codepot/src/codepot/views/site_show.php create mode 100644 codepot/src/css/site.css diff --git a/codepot/etc/codepot.ini.in b/codepot/etc/codepot.ini.in index b10ed431..5cc2d70e 100644 --- a/codepot/etc/codepot.ini.in +++ b/codepot/etc/codepot.ini.in @@ -1,12 +1,12 @@ ;------------------------------------------------------------------------------ -; default site ID +; default site language ;------------------------------------------------------------------------------ -default_siteid = "default"; +default_site_language = "english"; ;------------------------------------------------------------------------------ -; banner to display when no project id is available +; default site name ;------------------------------------------------------------------------------ -default_banner = "@PACKAGE@" +default_site_name = "@PACKAGE@" ;------------------------------------------------------------------------------ ; database settings diff --git a/codepot/src/codepot/controllers/issue.php b/codepot/src/codepot/controllers/issue.php index 6a4d3dd9..f3c82d21 100644 --- a/codepot/src/codepot/controllers/issue.php +++ b/codepot/src/codepot/controllers/issue.php @@ -298,7 +298,7 @@ class Issue extends Controller " - {$projectid}"; $this->load->view ($this->VIEW_ERROR, $data); } - else if (!$login['sysadmin?'] && + else if (!$login['sysadmin?'] && $mode != 'create' && $this->projects->projectHasMember($project->id, $login['id']) === FALSE) { $data['project'] = $project; @@ -307,6 +307,8 @@ class Issue extends Controller } else { + { + } $this->form_validation->set_rules ( 'issue_projectid', 'project ID', 'required|alpha_dash|max_length[32]'); $this->form_validation->set_rules ( diff --git a/codepot/src/codepot/controllers/site.php b/codepot/src/codepot/controllers/site.php index 7b4e50e4..0b791223 100644 --- a/codepot/src/codepot/controllers/site.php +++ b/codepot/src/codepot/controllers/site.php @@ -3,11 +3,13 @@ class Site extends Controller { var $VIEW_ERROR = 'error'; + var $VIEW_SHOW = 'site_show'; var $VIEW_HOME = 'site_home'; var $VIEW_EDIT = 'site_edit'; var $VIEW_DELETE = 'site_delete'; var $VIEW_LOG = 'log'; var $VIEW_PROJECT_LIST = 'project_list'; + var $VIEW_SITE_ADMINHOME = 'site_adminhome'; function Site () { @@ -37,7 +39,7 @@ class Site extends Controller $this->load->model ('ProjectModel', 'projects'); $this->load->model ('LogModel', 'logs'); - $site = $this->sites->get (CODEPOT_DEFAULT_SITEID); + $site = $this->sites->get ($this->config->config['language']); if ($site === FALSE) { $data['login'] = $login; @@ -45,6 +47,17 @@ class Site extends Controller $this->load->view ($this->VIEW_ERROR, $data); return; } + if ($site === NULL && CODEPOT_DEFAULT_SITE_LANGUAGE != '') + { + $site = $this->sites->get (CODEPOT_DEFAULT_SITE_LANGUAGE); + if ($site === FALSE) + { + $data['login'] = $login; + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + return; + } + } if ($site === NULL) $site = $this->sites->getDefault (); $latest_projects = $this->projects->getLatestProjects ($login['id'], CODEPOT_MAX_LATEST_PROJECTS); @@ -74,6 +87,60 @@ class Site extends Controller $this->load->view ($this->VIEW_HOME, $data); } + function adminhome () + { + $login = $this->login->getUser (); + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') + redirect ('main/signin'); + + $this->load->model ('SiteModel', 'sites'); + + $sites = $this->sites->getAll ($login['id']); + + if ($sites === FALSE) + { + $data['login'] = $login; + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else + { + $data['login'] = $login; + $data['sites'] = $sites; + $this->load->view ($this->VIEW_SITE_ADMINHOME, $data); + } + } + + function show ($siteid) + { + $login = $this->login->getUser (); + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') + redirect ('main/signin'); + + $this->load->model ('SiteModel', 'sites'); + + $data['login'] = $login; + + $site = $this->sites->get ($siteid); + if ($site === FALSE) + { + $data['login'] = $login; + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + return; + } + + if ($site === NULL) + { + $data['message'] = "NO SUCH SITE - {$siteid}"; + $this->load->view ($this->VIEW_ERROR, $data); + return; + } + + $data['site'] = $site; + $this->load->view ($this->VIEW_SHOW, $data); + } + function _edit_site ($site, $mode, $login) { $this->load->helper ('form'); @@ -120,8 +187,7 @@ class Site extends Controller } else { - //redirect ('site/home/' . $site->id); - redirect ('site/home'); + redirect ("site/show/{$site->id}"); } } else @@ -232,16 +298,15 @@ class Site extends Controller else { // the site has been deleted successfully. - // go back to the site home. - redirect ('site/home'); + // go back to the site admin home. + redirect ('site/adminhome'); } } else { // the confirm checkbox is not checked. - // go back to the site home page. - //redirect ('site/home/' . $site->id); - redirect ('site/home'); + // go back to the site adminhome page. + redirect ('site/adminhome'); } } else diff --git a/codepot/src/codepot/language/english/common_lang.php b/codepot/src/codepot/language/english/common_lang.php index 6a3c8e1f..62aa8743 100644 --- a/codepot/src/codepot/language/english/common_lang.php +++ b/codepot/src/codepot/language/english/common_lang.php @@ -1,4 +1,5 @@ id = CODEPOT_DEFAULT_SITEID; - $site->name = CODEPOT_DEFAULT_BANNER; + $site->id = CODEPOT_DEFAULT_SITE_LANGUAGE; + $site->name = CODEPOT_DEFAULT_SITE_NAME; $site->text = ''; $site->updatedby = ''; $site->createdby = ''; @@ -48,6 +48,15 @@ class SiteModel extends Model return $result[0]; } + function getAll ($userid) + { + $this->db->trans_start (); + $query = $this->db->get ('site'); + $this->db->trans_complete (); + if ($this->db->trans_status() === FALSE) return FALSE; + return $query->result (); + } + function create ($userid, $site) { $this->db->trans_begin (); diff --git a/codepot/src/codepot/views/Makefile.am b/codepot/src/codepot/views/Makefile.am index a18b003f..0925e720 100644 --- a/codepot/src/codepot/views/Makefile.am +++ b/codepot/src/codepot/views/Makefile.am @@ -24,9 +24,11 @@ www_DATA = \ project_home.php \ project_list.php \ projectbar.php \ + site_adminhome.php \ site_edit.php \ site_delete.php \ site_home.php \ + site_show.php \ taskbar.php \ wiki_delete.php \ wiki_edit.php \ diff --git a/codepot/src/codepot/views/Makefile.in b/codepot/src/codepot/views/Makefile.in index ed66e5da..02a09de3 100644 --- a/codepot/src/codepot/views/Makefile.in +++ b/codepot/src/codepot/views/Makefile.in @@ -187,9 +187,11 @@ www_DATA = \ project_home.php \ project_list.php \ projectbar.php \ + site_adminhome.php \ site_edit.php \ site_delete.php \ site_home.php \ + site_show.php \ taskbar.php \ wiki_delete.php \ wiki_edit.php \ diff --git a/codepot/src/codepot/views/projectbar.php b/codepot/src/codepot/views/projectbar.php index ddb04f5d..d386ad26 100644 --- a/codepot/src/codepot/views/projectbar.php +++ b/codepot/src/codepot/views/projectbar.php @@ -16,7 +16,7 @@ function show_projectbar ($con, $site, $project, $pageid, $ctxmenuitems) } else if (isset($site) && $site->name != '') print htmlspecialchars($site->name); - else print htmlspecialchars(CODEPOT_DEFAULT_BANNER); + else print htmlspecialchars(CODEPOT_DEFAULT_SITE_NAME); print ""; diff --git a/codepot/src/codepot/views/site_adminhome.php b/codepot/src/codepot/views/site_adminhome.php new file mode 100644 index 00000000..1b3073fb --- /dev/null +++ b/codepot/src/codepot/views/site_adminhome.php @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + +<?=htmlspecialchars($this->lang->line('Administration'))?> + + + + +
+ + + +load->view ('taskbar'); ?> + + + +load->view ( + 'projectbar', + array ( + 'site' => NULL, + 'project' => NULL, + 'pageid' => '', + 'ctxmenuitems' => NULL + ) +); +?> + + + +
+ +
lang->line('Administration')?>
+ +
+Front Pages +lang->line('New'), 'id="site_new_button"'); ?> +
+ +
    +name} ({$site->id})"; + $anc = anchor ("site/show/{$site->id}", htmlspecialchars($cap)); + print "
  • {$anc}
  • "; +} +?> +
+ +
+ + + +load->view ('footer'); ?> + + + + +
+ + + + diff --git a/codepot/src/codepot/views/site_delete.php b/codepot/src/codepot/views/site_delete.php index b5f74d0e..9571fcc9 100644 --- a/codepot/src/codepot/views/site_delete.php +++ b/codepot/src/codepot/views/site_delete.php @@ -3,7 +3,7 @@ - + <?=htmlspecialchars($site->name)?> @@ -33,12 +33,12 @@ $this->load->view ( $message"; ?> -id)?> +id}")?>
- lang->line('MSG_SURE_TO_DELETE_THIS')?> - name)?> + lang->line('MSG_SURE_TO_DELETE_THIS')?> - name)?> (id?>)
diff --git a/codepot/src/codepot/views/site_edit.php b/codepot/src/codepot/views/site_edit.php index fcc8525a..e44cd316 100644 --- a/codepot/src/codepot/views/site_edit.php +++ b/codepot/src/codepot/views/site_edit.php @@ -3,7 +3,7 @@ - + <?=htmlspecialchars($site->name)?> @@ -39,20 +39,23 @@ $this->load->view ( if ($mode == 'update') $formurl .= '/'.$site->id; ?> - +
- lang->line('ID').': ', 'site_id')?> + lang->line('Language').': ', 'site_id')?>
- id), $extra)?> + id), + $extra) + ?>
@@ -62,8 +65,10 @@ $this->load->view (
- - name), $extra)?> + name), + 'maxlength="80" size="40" class="name"'); + ?>
@@ -73,7 +78,10 @@ $this->load->view (
- text))?> + text), + 'class="text"') + ?>
diff --git a/codepot/src/codepot/views/site_home.php b/codepot/src/codepot/views/site_home.php index 415dc35f..5f42c684 100644 --- a/codepot/src/codepot/views/site_home.php +++ b/codepot/src/codepot/views/site_home.php @@ -3,7 +3,7 @@ - + + + + +<?=htmlspecialchars($site->name)?> (<?=$site->id?>) + + + + +
+ + + +load->view ('taskbar'); ?> + + + +lang->line('Create')), + array ("site/update/{$site->id}", $this->lang->line('Edit')), + array ("site/delete/{$site->id}", $this->lang->line('Delete')) + ); +} +else $ctxmenuitems = array (); + +$this->load->view ( + 'projectbar', + array ( + 'project' => NULL, + 'site' => $site, + 'pageid' => 'site', + 'ctxmenuitems' => $ctxmenuitems + ) +); +?> + + + +
+ +
+ +
+ + + +
+ +load->view ('footer'); ?> + +
+ + + diff --git a/codepot/src/codepot/views/taskbar.php b/codepot/src/codepot/views/taskbar.php index a26091ee..da720361 100644 --- a/codepot/src/codepot/views/taskbar.php +++ b/codepot/src/codepot/views/taskbar.php @@ -39,10 +39,8 @@ function show_taskbar ($con, $loginid, $issysadmin) print '
'; print anchor ('site/home', $con->lang->line('Home')); print anchor ('site/projectlist', $con->lang->line('Projects')); - /* if ($issysadmin) - print anchor ('site/admin', $con->lang->line('System')); - */ + print anchor ('site/adminhome', $con->lang->line('Administration')); print '
'; print ''; diff --git a/codepot/src/config.php.in b/codepot/src/config.php.in index 1518eb27..ace10a66 100644 --- a/codepot/src/config.php.in +++ b/codepot/src/config.php.in @@ -13,8 +13,8 @@ function load_ini ($file) if (/*$cfg === FALSE*/ $cfg == FALSE) die ("ERROR: cannot parse $file"); $xcfgs = array ( - array ('default_siteid', 'string', 'default'), - array ('default_banner', 'string', '@PACKAGE@'), + array ('default_site_language', 'string', 'english'), + array ('default_site_name', 'string', '@PACKAGE@'), array ('language', 'string', 'auto'), array ('enable_websvn', 'boolean', FALSE), diff --git a/codepot/src/css/Makefile.am b/codepot/src/css/Makefile.am index 195d381e..bb3e3c9a 100644 --- a/codepot/src/css/Makefile.am +++ b/codepot/src/css/Makefile.am @@ -6,6 +6,7 @@ www_DATA = \ issue.css \ jquery-ui.css \ project.css \ + site.css \ websvn.css EXTRA_DIST = $(www_DATA) diff --git a/codepot/src/css/Makefile.in b/codepot/src/css/Makefile.in index af205dcd..48080e32 100644 --- a/codepot/src/css/Makefile.in +++ b/codepot/src/css/Makefile.in @@ -208,6 +208,7 @@ www_DATA = \ issue.css \ jquery-ui.css \ project.css \ + site.css \ websvn.css EXTRA_DIST = $(www_DATA) diff --git a/codepot/src/css/project.css b/codepot/src/css/project.css index 24d15027..32f7207f 100644 --- a/codepot/src/css/project.css +++ b/codepot/src/css/project.css @@ -68,53 +68,6 @@ font-weight: bold; } - -/*----------------------------------------------- - * user home view - *-----------------------------------------------*/ -#site_home_mainarea_sidebar { - width: 24em; -} - -#site_home_mainarea_sidebar_log_table { - border-collapse: collapse; -} - -#site_home_mainarea_sidebar_log_table tr.odd { - background-color: #bbccef; -} - -#site_home_mainarea_sidebar_log_table tr.odd td { - white-space: nowrap; -} - -#site_home_mainarea_sidebar_log_table tr.odd td.date { - width: 1px; -} - -#site_home_mainarea_sidebar_log_table tr.even { - background-color: inherit; -} - -#site_home_mainarea_sidebar_log_table tr.even .description { - font-style: italic; -} - -#site_home_mainarea_sidebar_log_table tr.even pre.message { - border: 0; - margin: 1px; - background-color: inherit; - white-space: pre-wrap; -} - -#site_home_mainarea_sidebar_log_table td.date { - width: 1px; -} - -#site_home_mainarea_sidebar_log_table td.project { - width: 1px; -} - /*----------------------------------------------- * project home view *-----------------------------------------------*/ @@ -149,7 +102,7 @@ white-space: pre-wrap; } -#site_home_mainarea_sidebar_log_table td.date { +#project_home_mainarea_sidebar_log_table td.date { width: 1px; } diff --git a/codepot/src/css/site.css b/codepot/src/css/site.css new file mode 100644 index 00000000..b93baeaa --- /dev/null +++ b/codepot/src/css/site.css @@ -0,0 +1,59 @@ +/*----------------------------------------------- + * site home view + *-----------------------------------------------*/ +#site_home_mainarea_sidebar { + width: 24em; +} + +#site_home_mainarea_sidebar_log_table { + border-collapse: collapse; +} + +#site_home_mainarea_sidebar_log_table tr.odd { + background-color: #bbccef; +} + +#site_home_mainarea_sidebar_log_table tr.odd td { + white-space: nowrap; +} + +#site_home_mainarea_sidebar_log_table tr.odd td.date { + width: 1px; +} + +#site_home_mainarea_sidebar_log_table tr.even { + background-color: inherit; +} + +#site_home_mainarea_sidebar_log_table tr.even .description { + font-style: italic; +} + +#site_home_mainarea_sidebar_log_table tr.even pre.message { + border: 0; + margin: 1px; + background-color: inherit; + white-space: pre-wrap; +} + +#site_home_mainarea_sidebar_log_table td.date { + width: 1px; +} + +#site_home_mainarea_sidebar_log_table td.project { + width: 1px; +} + +/*----------------------------------------------- + * site adminhome view + *-----------------------------------------------*/ +#site_adminhome_mainarea .infostrip span.title { + float: left; +} + +/*----------------------------------------------- + * site edit view + *-----------------------------------------------*/ +#site_edit_form .text { + width: 100%; +}