enabled front page editing

This commit is contained in:
hyung-hwan 2010-03-21 14:50:08 +00:00
parent 2941be5ebe
commit 71c9d686df
21 changed files with 352 additions and 101 deletions

View File

@ -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

View File

@ -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 (

View File

@ -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

View File

@ -1,4 +1,5 @@
<?php
$lang['Administration'] = 'Administration';
$lang['All'] = 'All';
$lang['Author'] = 'Author';
$lang['Blame'] = 'Blame';
@ -30,7 +31,11 @@ $lang['Home'] = 'Home';
$lang['ID'] = 'ID';
$lang['Issue'] = 'Issue';
$lang['Issues'] = 'Issues';
$lang['Language'] = 'Language';
$lang['Last'] = 'Last';
$lang['Last updated by'] = 'Last updated by';
$lang['Last updated on'] = 'Last updated on';
$lang['Latest projects'] = 'Latest projects';
$lang['MD5'] = 'MD5';
$lang['Member'] = 'Member';
$lang['Members'] = 'Members';
@ -38,9 +43,6 @@ $lang['Message'] = 'Message';
$lang['My projects'] = 'My projects';
$lang['Name'] = 'Name';
$lang['New'] = 'New';
$lang['Last updated by'] = 'Last updated by';
$lang['Last updated on'] = 'Last updated on';
$lang['Latest projects'] = 'Latest projects';
$lang['OK'] = 'OK';
$lang['Other projects'] = 'Other projects';
$lang['Overview'] = 'Overview';

View File

@ -1,4 +1,5 @@
<?php
$lang['Administration'] = 'Administration';
$lang['All'] = 'Semua';
$lang['Author'] = 'Pengarang';
$lang['Blame'] = 'Menyalahkan';
@ -30,7 +31,11 @@ $lang['Home'] = 'Beranda';
$lang['ID'] = 'ID';
$lang['Issue'] = 'Issue';
$lang['Issues'] = 'Issue';
$lang['Language'] = 'Bahasa';
$lang['Last'] = 'Terakhir';
$lang['Last updated by'] = 'Terakhir memperbaharui oleh';
$lang['Last updated on'] = 'Waktu memperbaharui terakhir';
$lang['Latest projects'] = 'Proyek terakhir';
$lang['MD5'] = 'MD5';
$lang['Member'] = 'Anggota';
$lang['Members'] = 'Anggota';
@ -38,9 +43,6 @@ $lang['Message'] = 'Pesan';
$lang['My projects'] = 'Proyek saya';
$lang['Name'] = 'Nama';
$lang['New'] = 'Baru';
$lang['Last updated by'] = 'Terakhir memperbaharui oleh';
$lang['Last updated on'] = 'Waktu memperbaharui terakhir';
$lang['Latest projects'] = 'Proyek terakhir';
$lang['OK projects'] = 'OK';
$lang['Other projects'] = 'Proyek lain';
$lang['Overview'] = 'Ringkasan';

View File

@ -1,4 +1,5 @@
<?php
$lang['Administration'] = '관리';
$lang['All'] = '모두';
$lang['Author'] = '저자';
$lang['Blame'] = '책임전가';
@ -30,7 +31,11 @@ $lang['Home'] = '홈';
$lang['ID'] = '아이디';
$lang['Issue'] = '이슈';
$lang['Issues'] = '이슈';
$lang['Language'] = '언어';
$lang['Last'] = '마지막';
$lang['Last updated by'] = '최종수정인';
$lang['Last updated on'] = '최종수정시간';
$lang['Latest projects'] = '최근 프로젝트';
$lang['MD5'] = 'MD5';
$lang['Member'] = '구성원';
$lang['Members'] = '구성원';
@ -38,9 +43,6 @@ $lang['Message'] = '메시지';
$lang['My projects'] = '내 프로젝트';
$lang['Name'] = '이름';
$lang['New'] = '신규';
$lang['Last updated by'] = '최종수정인';
$lang['Last updated on'] = '최종수정시간';
$lang['Latest projects'] = '최근 프로젝트';
$lang['OK'] = '확인';
$lang['Other projects'] = '다른 프로젝트';
$lang['Overview'] = '개요';

View File

@ -10,8 +10,8 @@ class SiteModel extends Model
function getDefault ()
{
$site->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 ();

View File

@ -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 \

View File

@ -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 \

View File

@ -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 "</div>";

View File

@ -0,0 +1,79 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/common.css" />
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/site.css" />
<script type="text/javascript" src="<?=base_url()?>/js/jquery.min.js"></script>
<script type="text/javascript" src="<?=base_url()?>/js/jquery-ui.min.js"></script>
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/jquery-ui.css" />
<script type="text/javascript">
$(function () {
$('#site_new_button').button();
});
</script>
<title><?=htmlspecialchars($this->lang->line('Administration'))?></title>
</head>
<body>
<div class="content" id="site_adminhome_content">
<!---------------------------------------------------------------------------->
<?php $this->load->view ('taskbar'); ?>
<!---------------------------------------------------------------------------->
<?php
$this->load->view (
'projectbar',
array (
'site' => NULL,
'project' => NULL,
'pageid' => '',
'ctxmenuitems' => NULL
)
);
?>
<!---------------------------------------------------------------------------->
<div class="mainarea" id="site_adminhome_mainarea">
<div class="title"><?=$this->lang->line('Administration')?></div>
<div class="infostrip">
<span class="title">Front Pages</span>
<?php print anchor ('site/create', $this->lang->line('New'), 'id="site_new_button"'); ?>
</div>
<ul>
<?php
foreach ($sites as $site)
{
$cap = "{$site->name} ({$site->id})";
$anc = anchor ("site/show/{$site->id}", htmlspecialchars($cap));
print "<li>{$anc}</li>";
}
?>
</ul>
</div> <!-- site_adminhome_mainarea -->
<!---------------------------------------------------------------------------->
<?php $this->load->view ('footer'); ?>
<!---------------------------------------------------------------------------->
</div> <!-- site_adminhome_content -->
</body>
</html>

View File

@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/common.css" />
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/project.css" />
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/site.css" />
<title><?=htmlspecialchars($site->name)?></title>
</head>
@ -33,12 +33,12 @@ $this->load->view (
<?php if ($message != "") print "<div id='site_create_message' class='form_message'>$message</div>"; ?>
<?=form_open('site/delete/'.$site->id)?>
<?=form_open("site/delete/{$site->id}")?>
<?=form_fieldset()?>
<div>
<div>
<?=form_checkbox('site_confirm', 'yes', set_checkbox('site_confirm', $site_confirm))?>
<?=$this->lang->line('MSG_SURE_TO_DELETE_THIS')?> - <?=htmlspecialchars($site->name)?>
<?=$this->lang->line('MSG_SURE_TO_DELETE_THIS')?> - <?=htmlspecialchars($site->name)?> (<?=$site->id?>)
<?=form_error('site_confirm')?>
</div>
</div>

View File

@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/common.css" />
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/project.css" />
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/site.css" />
<title><?=htmlspecialchars($site->name)?></title>
</head>
@ -39,20 +39,23 @@ $this->load->view (
if ($mode == 'update') $formurl .= '/'.$site->id;
?>
<?=form_open($formurl)?>
<?=form_open($formurl, 'id="site_edit_form"')?>
<?=form_fieldset()?>
<div>
<div>
<?=form_label($this->lang->line('ID').': ', 'site_id')?>
<?=form_label($this->lang->line('Language').': ', 'site_id')?>
<?=form_error('site_id')?>
</div>
<div>
<?php
$extra = ($mode == 'update')? 'readonly="readonly"': '';
$extra .= 'maxlength="32" size="16"';
$extra .= 'maxlength="32" size="16" class="id"';
?>
<?=form_input('site_id', set_value('site_id', $site->id), $extra)?>
<?=form_input('site_id',
set_value('site_id', $site->id),
$extra)
?>
</div>
</div>
@ -62,8 +65,10 @@ $this->load->view (
<?=form_error('site_name')?>
</div>
<div>
<?php $extra = 'maxlength="80" size="40"'; ?>
<?=form_input('site_name', set_value('site_name', $site->name), $extra)?>
<?=form_input('site_name',
set_value('site_name', $site->name),
'maxlength="80" size="40" class="name"');
?>
</div>
</div>
@ -73,7 +78,10 @@ $this->load->view (
<?=form_error('site_text')?>
</div>
<div>
<?=form_textarea('site_text', set_value('site_text', $site->text))?>
<?=form_textarea('site_text',
set_value('site_text', $site->text),
'class="text"')
?>
</div>
</div>

View File

@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/common.css" />
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/project.css" />
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/site.css" />
<script type="text/javascript" src="<?=base_url()?>/js/creole.js"></script>
<script type="text/javascript">
function render_wiki()
@ -35,23 +35,13 @@ function render_wiki()
<?php
if ($login['sysadmin?'])
{
$ctxmenuitems = array (
array ("site/create", $this->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
'ctxmenuitems' => NULL
)
);
?>

View File

@ -0,0 +1,76 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/common.css" />
<link type="text/css" rel="stylesheet" href="<?=base_url()?>/css/site.css" />
<script type="text/javascript" src="<?=base_url()?>/js/creole.js"></script>
<script type="text/javascript">
function render_wiki()
{
creole_render_wiki (
"site_show_mainarea_textpre",
"site_show_mainarea_text",
"<?=site_url()?>/site/wiki/"
);
}
</script>
<?php
?>
<title><?=htmlspecialchars($site->name)?> (<?=$site->id?>)</title>
</head>
<body onLoad="render_wiki()">
<div class="content" id="site_show_content">
<!---------------------------------------------------------------------------->
<?php $this->load->view ('taskbar'); ?>
<!---------------------------------------------------------------------------->
<?php
if ($login['sysadmin?'])
{
$ctxmenuitems = array (
array ("site/create", $this->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
)
);
?>
<!---------------------------------------------------------------------------->
<div class="mainarea" id="site_show_mainarea">
<div id="site_show_mainarea_text">
<pre id="site_show_mainarea_textpre" style="visibility: hidden">
<?php print htmlspecialchars($site->text); ?>
</pre>
</div> <!-- site_show_mainarea_text -->
<!----------------------------------------------------------->
</div> <!-- site_show_mainarea -->
<?php $this->load->view ('footer'); ?>
</div> <!-- site_show_content -->
</body>
</html>

View File

@ -39,10 +39,8 @@ function show_taskbar ($con, $loginid, $issysadmin)
print '<div class="boxa">';
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 '</div>';
print '</div>';

View File

@ -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),

View File

@ -6,6 +6,7 @@ www_DATA = \
issue.css \
jquery-ui.css \
project.css \
site.css \
websvn.css
EXTRA_DIST = $(www_DATA)

View File

@ -208,6 +208,7 @@ www_DATA = \
issue.css \
jquery-ui.css \
project.css \
site.css \
websvn.css
EXTRA_DIST = $(www_DATA)

View File

@ -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;
}

59
codepot/src/css/site.css Normal file
View File

@ -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%;
}