Skip to content

Commit

Permalink
"Upgrading" the form for handling project colors to the HTML5 form ty…
Browse files Browse the repository at this point in the history
…pe "color". In addition to making the code HTML5-friendly, we also get rid of some Javascript code and a solid amount of concats in the entire codebase that add the "#" symbol to all background styles. Instead the html color is saved in the database directly with the "#" in front of it.
  • Loading branch information
teodorg committed Mar 19, 2018
1 parent 305544f commit 288f252
Showing 28 changed files with 48 additions and 57 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -5,7 +5,8 @@
includes/config.php
!files/index.html
!files/temp/index.html
files/
lib/ezpdf/fonts/php_*
/nbproject/private/
/nbproject
/nbproject
/dotProject/
!/modules/files/
2 changes: 1 addition & 1 deletion db/dotproject.sql
Original file line number Diff line number Diff line change
@@ -256,7 +256,7 @@ CREATE TABLE `%dbprefix%projects` (
`project_end_date` datetime default NULL,
`project_status` int(11) default '0',
`project_percent_complete` tinyint(4) default '0',
`project_color_identifier` varchar(6) default 'eeeeee',
`project_color_identifier` varchar(7) default '#eeeeee',
`project_description` text,
`project_target_budget` decimal(10,2) default '0.00',
`project_actual_budget` decimal(10,2) default '0.00',
3 changes: 3 additions & 0 deletions db/upgrade_project_color_identifier.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# DO NOT USE THIS SCRIPT DIRECTLY - USE THE INSTALLER INSTEAD.

ALTER TABLE projects MODIFY project_color_identifier VARCHAR(7);
4 changes: 2 additions & 2 deletions modules/files/folders_table.php
Original file line number Diff line number Diff line change
@@ -443,10 +443,10 @@ function displayFiles($folder_id) {
if ($fp != $row['file_project']) {
if (!$row['file_project']) {
$row['project_name'] = $AppUI->_('Not associated to projects');
$row['project_color_identifier'] = 'f4efe3';
$row['project_color_identifier'] = '#f4efe3';
}
if ($showProject) {
$style = ('background-color:#' . $row['project_color_identifier']
$style = ('background-color:' . $row['project_color_identifier']
. ';color:' . bestColor($row['project_color_identifier']));
?>
<tr>
4 changes: 2 additions & 2 deletions modules/files/index_table.php
Original file line number Diff line number Diff line change
@@ -264,10 +264,10 @@ function expand(id) {
if ($fp != $latest_file["file_project"]) {
if (!$latest_file["file_project"]) {
$latest_file["project_name"] = $AppUI->_('Not associated to projects');
$latest_file["project_color_identifier"] = 'f4efe3';
$latest_file["project_color_identifier"] = '#f4efe3';
}
if ($showProject) {
$style = ("background-color:#$latest_file[project_color_identifier];color:"
$style = ("background-color:$latest_file[project_color_identifier];color:"
. bestColor($latest_file["project_color_identifier"]));
?>
<tr>
2 changes: 1 addition & 1 deletion modules/forums/index.php
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@
$create_date = intval($row['forum_create_date']) ? new CDate($row['forum_create_date']) : null;
?>
<tr>
<td colspan="6" style="background-color:#<?php echo $row["project_color_identifier"];?>">
<td colspan="6" style="background-color:<?php echo $row["project_color_identifier"];?>">
<a href="?m=projects&amp;a=view&amp;project_id=<?php echo $row["forum_project"];?>">
<font color=<?php echo bestColor($row["project_color_identifier"]);?>>
<strong><?php echo $AppUI->___($row["project_name"]);?></strong>
2 changes: 1 addition & 1 deletion modules/forums/viewer.php
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@
?>
<table width="100%" cellspacing="0" cellpadding="2" border="0" class="std">
<tr>
<td height="20" colspan="3" style="border: outset #D1D1CD 1px;background-color:#<?php echo $forum["project_color_identifier"];?>">
<td height="20" colspan="3" style="border: outset #D1D1CD 1px;background-color:<?php echo $forum["project_color_identifier"];?>">
<font size="2" color=<?php echo bestColor($forum["project_color_identifier"]);?>><strong><?php echo $AppUI->___(@$forum["forum_name"]);?></strong></font>
</td>
</tr>
4 changes: 2 additions & 2 deletions modules/links/index_table.php
Original file line number Diff line number Diff line change
@@ -193,12 +193,12 @@ function shownavbar_links($xpg_totalrecs, $xpg_pagesize, $xpg_total_pages, $page
if ($fp != $row['link_project']) {
if (!$row['project_name']) {
$row['project_name'] = $AppUI->_('All Projects');
$row['project_color_identifier'] = 'f4efe3';
$row['project_color_identifier'] = '#f4efe3';
}
if ($showProject) {
?>
<tr>
<td colspan="10" style="background-color:#<?php
<td colspan="10" style="background-color:<?php
echo ($row['project_color_identifier']); ?>" style="border: outset 2px #eeeeee">
<font color="<?php
echo (bestColor($row['project_color_identifier'])); ?>">
6 changes: 3 additions & 3 deletions modules/projectdesigner/gantt.php
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@
$user_id = defVal( @$_REQUEST['user_id'], 0 );

$projects[$project_id]['project_name'] = $AppUI->_('Todo for').' '.dPgetUsername($user_id);
$projects[$project_id]['project_color_identifier'] = 'ff6000';
$projects[$project_id]['project_color_identifier'] = '#ff6000';

$showLabels = (bool)dPgetParam($_REQUEST, 'showLabels', false);
$showPinned = (bool)dPgetParam( $_REQUEST, 'showPinned', false );
@@ -211,8 +211,8 @@
// Use TTF font if it exists
// try commenting out the following two lines if gantt charts do not display
$graph->scale->tableTitle->SetFont(FF_CUSTOM, FS_BOLD, 12);
$graph->scale->SetTableTitleBackground('#'.$projects[$project_id]['project_color_identifier']);
$font_color = bestColor('#'.$projects[$project_id]['project_color_identifier']);
$graph->scale->SetTableTitleBackground($projects[$project_id]['project_color_identifier']);
$font_color = bestColor($projects[$project_id]['project_color_identifier']);
$graph->scale->tableTitle->SetColor($font_color);
$graph->scale->tableTitle->Show(true);

4 changes: 2 additions & 2 deletions modules/projectdesigner/index.php
Original file line number Diff line number Diff line change
@@ -611,7 +611,7 @@ function removeComponent(tr_id) {
<td style="border: outset #d1d1cd 1px;" colspan="2">
<table border="0" cellpadding="4" cellspacing="0" width="100%">
<tr>
<td style="background-color:#<?php echo $obj->project_color_identifier;?>" colspan="1">
<td style="background-color:<?php echo $obj->project_color_identifier;?>" colspan="1">
<?php
echo '<a href="#fp" name="fp" style="display:block" onClick="expand_colapse(\'project\', \'tblProjects\')">'
?>
@@ -623,7 +623,7 @@ function removeComponent(tr_id) {
echo '</a>'
?>
</td>
<td width="12" style="background-color:#<?php echo $obj->project_color_identifier;?>" align="right" colspan="1">
<td width="12" style="background-color:<?php echo $obj->project_color_identifier;?>" align="right" colspan="1">
<?php
echo '<a href="#fp" name="fp" style="display:block" onClick="expand_colapse(\'project\', \'tblProjects\')">'
?>
4 changes: 2 additions & 2 deletions modules/projectdesigner/projectdesigner.class.php
Original file line number Diff line number Diff line change
@@ -265,7 +265,7 @@ function showtask_pd( &$a, $level=0, $is_opened = true, $today_view = false) {
if ($today_view) { // Show the project name
$s .= '<td>';
$s .= '<a href="./index.php?m=projects&a=view&project_id=' . $a['task_project'] . '">';
$s .= '<span style="padding:2px;background-color:#' . $a['project_color_identifier'] . ';color:' . bestColor($a['project_color_identifier']) . '">' . $a['project_name'] . '</span>';
$s .= '<span style="padding:2px;background-color:' . $a['project_color_identifier'] . ';color:' . bestColor($a['project_color_identifier']) . '">' . $a['project_name'] . '</span>';
$s .= '</a></td>';
}
// task description
@@ -435,7 +435,7 @@ function showtask_pr( &$a, $level=0, $is_opened = true, $today_view = false) {
if ($today_view) { // Show the project name
$s .= '<td>';
$s .= '<a href="./index.php?m=projects&a=view&project_id=' . $a['task_project'] . '">';
$s .= '<span style="padding:2px;background-color:#' . $a['project_color_identifier'] . ';color:' . bestColor($a['project_color_identifier']) . '">' . $a['project_name'] . '</span>';
$s .= '<span style="padding:2px;background-color:' . $a['project_color_identifier'] . ';color:' . bestColor($a['project_color_identifier']) . '">' . $a['project_name'] . '</span>';
$s .= '</a></td>';
}
if (! $today_view) {
17 changes: 2 additions & 15 deletions modules/projects/addedit.php
Original file line number Diff line number Diff line change
@@ -133,14 +133,6 @@
<script src="<?php echo DP_BASE_URL;?>/lib/calendar/lang/calendar-<?php echo $AppUI->user_locale; ?>.js"></script>

<script language="javascript" >
function setColor(color) {
var f = document.editFrm;
if (color) {
f.project_color_identifier.value = color;
}
//test.style.background = f.project_color_identifier.value;
document.getElementById('test').style.background = '#' + f.project_color_identifier.value; //fix for mozilla: does this work with ie? opera ok.
}

function setShort() {
var f = document.editFrm;
@@ -402,14 +394,9 @@ function setDepartment(department_id_string) {
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Color Identifier');?></td>
<td nowrap="nowrap">
<input type="text" name="project_color_identifier" value="<?php echo (@$row->project_color_identifier) ? @$row->project_color_identifier : 'FFFFFF';?>" size="10" maxlength="6" onblur="javascript:setColor();" class="text" /> *
</td>
<td nowrap="nowrap" align="right">
<a href="#" onclick="javascript:newwin=window.open('?m=public&a=color_selector&dialog=1&callback=setColor', 'calwin', 'width=320, height=300, scrollbars=no');"><?php echo $AppUI->_('change color');?></a>
</td>
<td nowrap="nowrap">
<span id="test" title="test" style="background:#<?php echo (@$row->project_color_identifier) ? @$row->project_color_identifier : 'FFFFFF';?>;"><a href="#" onclick="javascript:newwin=window.open('?m=public&a=color_selector&dialog=1&callback=setColor', 'calwin', 'width=320, height=300, scrollbars=no');"><img src="./images/shim.gif" border="1" width="40" height="20" alt="" /></a></span>
<input type="color" name="project_color_identifier" value="<?php echo (@$row->project_color_identifier) ? @$row->project_color_identifier : '#FFFFFF';?>" size="10" maxlength="7"/> *
</td>

</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Project Type');?></td>
2 changes: 1 addition & 1 deletion modules/projects/admin_tab.viewuser.projects.php
Original file line number Diff line number Diff line change
@@ -178,7 +178,7 @@
? 'style="color:red; font-weight:bold"' : '');
?>
<tr>
<td width="65" align="center" style="border: outset #eeeeee 2px;background-color:#<?php
<td width="65" align="center" style="border: outset #eeeeee 2px;background-color:<?php
echo ($row['project_color_identifier']); ?>">
<span style="color:<?php echo bestColor($row['project_color_identifier']); ?>">
<?php echo sprintf("%.1f%%", $row['project_percent_complete']); ?>
2 changes: 1 addition & 1 deletion modules/projects/calendar_tab.projects.php
Original file line number Diff line number Diff line change
@@ -104,7 +104,7 @@
$end_date = (intval(@$row['project_end_date']) ? new CDate($row['project_end_date']) : null);
?>
<tr>
<td width="65" align="center" style="border: outset #eeeeee 2px;background-color:#<?php
<td width="65" align="center" style="border: outset #eeeeee 2px;background-color:<?php
echo $row['project_color_identifier']; ?>">
<span style="font-color: <?php echo bestColor($row['project_color_identifier']); ?>">
<?php echo sprintf("%.1f%%", $row['project_percent_complete']); ?>
2 changes: 1 addition & 1 deletion modules/projects/departments_tab.view.projects.php
Original file line number Diff line number Diff line change
@@ -186,7 +186,7 @@
? 'style="color:red; font-weight:bold"' : '');
?>
<tr>
<td width="65" align="center" style="border: outset #eeeeee 2px;background-color:#<?php
<td width="65" align="center" style="border: outset #eeeeee 2px;background-color:<?php
echo ($row['project_color_identifier']); ?>">
<span style="color:<?php echo bestColor($row['project_color_identifier']); ?>">
<?php echo sprintf("%.1f%%", $row['project_percent_complete']); ?>
10 changes: 5 additions & 5 deletions modules/projects/gantt.php
Original file line number Diff line number Diff line change
@@ -269,7 +269,7 @@
$bar->title->SetFont(FF_CUSTOM, FS_NORMAL, 9);
}
$bar->SetFillColor('#' . $p['project_color_identifier']);
$bar->SetPattern(BAND_SOLID, ('#' . $p['project_color_identifier']));
$bar->SetPattern(BAND_SOLID, ($p['project_color_identifier']));

//adding captions
$bar->caption = new TextProperty($caption);
@@ -321,10 +321,10 @@
? 0.1 : 0.6));

$bar2->title->SetColor(bestColor('#ffffff',
('#' . $p['project_color_identifier']),
($p['project_color_identifier']),
'#000000'));
$bar2->title->SetFont(FF_CUSTOM, FS_NORMAL, 9);
$bar2->SetFillColor(('#' . $p['project_color_identifier']));
$bar2->SetFillColor(($p['project_color_identifier']));
$graph->Add($bar2);
} else {
$bar2 = new MileStone ($row++, ('-- ' . $t['task_name']),
@@ -352,9 +352,9 @@
$tEndObj->format(FMT_DATETIME_MYSQL), 0.6);
$bar3->title->SetFont(FF_CUSTOM, FS_NORMAL, 9);
$bar3->title->SetColor(bestColor('#ffffff',
('#' . $p['project_color_identifier']),
($p['project_color_identifier']),
'#000000'));
$bar3->SetFillColor('#' . $p['project_color_identifier']);
$bar3->SetFillColor($p['project_color_identifier']);
$graph->Add($bar3);
}
//End of insert workers for each task into Gantt Chart
8 changes: 4 additions & 4 deletions modules/projects/gantt2.php
Original file line number Diff line number Diff line change
@@ -164,8 +164,8 @@
$row++;
$barTmp = new GanttBar($row++, array($t['user_name'], '', '',' '), '0', '0;' , 0.6);
$barTmp->title->SetFont(FF_CUSTOM, FS_NORMAL, 8);
$barTmp->title->SetColor('#' . $t['project_color_identifier']);
$barTmp->SetFillColor('#' . $t['project_color_identifier']);
$barTmp->title->SetColor($t['project_color_identifier']);
$barTmp->SetFillColor($t['project_color_identifier']);
if (is_file(TTF_DIR . 'FreeSansBold.ttf')) {
$barTmp->title ->SetFont(FF_CUSTOM, FF_BOLD);
}
@@ -230,8 +230,8 @@
if (is_file(TTF_DIR . 'FreeSans.ttf')) {
$bar->title->SetFont(FF_CUSTOM, FS_NORMAL, 10);
}
$bar->SetFillColor(('#' . $t['project_color_identifier']));
$bar->SetPattern(BAND_SOLID, ('#' . $t['project_color_identifier']));
$bar->SetFillColor(($t['project_color_identifier']));
$bar->SetPattern(BAND_SOLID, ($t['project_color_identifier']));

//adding captions
$bar->caption = new TextProperty($caption);
2 changes: 1 addition & 1 deletion modules/projects/view.php
Original file line number Diff line number Diff line change
@@ -226,7 +226,7 @@ function delIt() {
</form>
<table border="0" cellpadding="4" cellspacing="0" width="100%" class="std">
<tr>
<td style="border: outset #d1d1cd 1px;background-color:#<?php
<td style="border: outset #d1d1cd 1px;background-color:<?php
echo $obj->project_color_identifier; ?>" colspan="2">
<?php
echo ('<span style="color:' . bestColor($obj->project_color_identifier) . '; font-weight:bold">'
2 changes: 1 addition & 1 deletion modules/projects/vw_idx_active.php
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@
? ' style="color:red; font-weight:bold"' : '');
?>
<tr>
<td width="65" align="center" style="border: outset #eeeeee 2px;background-color:#<?php
<td width="65" align="center" style="border: outset #eeeeee 2px;background-color:<?php
echo ($row['project_color_identifier']); ?>">
<span style="color:<?php echo (bestColor($row['project_color_identifier'])); ?>">
<?php echo(sprintf('%.1f%%', $row['project_percent_complete'])); ?>
2 changes: 1 addition & 1 deletion modules/projects/vw_idx_archived.php
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@
? new CDate($row['project_actual_end_date']) : null);
?>
<tr>
<td width="65" align="center" style="border: outset #eeeeee 2px;background-color:#<?php
<td width="65" align="center" style="border: outset #eeeeee 2px;background-color:<?php
echo ($row['project_color_identifier']); ?>">
<span style="color:<?php echo (bestColor($row['project_color_identifier'])); ?>">
<?php echo(sprintf('%.1f%%', $row['project_percent_complete'])); ?>
2 changes: 1 addition & 1 deletion modules/projects/vw_idx_complete.php
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@
? new CDate($row['project_end_date']) : null);
?>
<tr>
<td width="65" align="center" style="border: outset #eeeeee 2px;background-color:#<?php
<td width="65" align="center" style="border: outset #eeeeee 2px;background-color:<?php
echo ($row['project_color_identifier']); ?>">
<span style="color:<?php echo (bestColor($row['project_color_identifier'])); ?>">
<?php echo(sprintf('%.1f%%', $row['project_percent_complete'])); ?>
2 changes: 1 addition & 1 deletion modules/projects/vw_idx_proposed.php
Original file line number Diff line number Diff line change
@@ -129,7 +129,7 @@
? 'style="color:red; font-weight:bold"' : '');
?>
<tr>
<td width="65" align="center" style="border: outset #eeeeee 2px;background-color:#<?php
<td width="65" align="center" style="border: outset #eeeeee 2px;background-color:<?php
echo ($row['project_color_identifier']); ?>">
<span style="color:<?php echo (bestColor($row['project_color_identifier'])); ?>">
<?php echo(sprintf('%.1f%%', $row['project_percent_complete'])); ?>
2 changes: 1 addition & 1 deletion modules/tasks/addedit.php
Original file line number Diff line number Diff line change
@@ -253,7 +253,7 @@ function getDepartmentSelectionList($company_id, $checked_array = array(),
echo $obj->task_contacts; ?>" />
<table border="1" cellpadding="4" cellspacing="0" width="100%" class="std">
<tr>
<td colspan="2" style="border: outset #eeeeee 1px;background-color:#<?php
<td colspan="2" style="border: outset #eeeeee 1px;background-color:<?php
echo $project->project_color_identifier; ?>" >
<font color="<?php echo bestColor($project->project_color_identifier); ?>">
<strong><?php echo $AppUI->_('Project'); ?>: <?php
4 changes: 2 additions & 2 deletions modules/tasks/gantt.php
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@

$projects[$project_id]['project_name'] = ($AppUI->_('Todo for') . ' '
. dPgetUsernameFromID($user_id));
$projects[$project_id]['project_color_identifier'] = 'ff6000';
$projects[$project_id]['project_color_identifier'] = '#ff6000';


$q->addTable('tasks', 't');
@@ -246,7 +246,7 @@
// Use TTF font if it exists
// try commenting out the following two lines if gantt charts do not display
$graph->scale->tableTitle->SetFont(FF_CUSTOM, FS_BOLD, 12);
$graph->scale->SetTableTitleBackground('#'.$projects[$project_id]['project_color_identifier']);
$graph->scale->SetTableTitleBackground($projects[$project_id]['project_color_identifier']);
$graph->scale->tableTitle->Show(true);

//-----------------------------------------
2 changes: 1 addition & 1 deletion modules/tasks/tasks.class.php
Original file line number Diff line number Diff line change
@@ -2812,7 +2812,7 @@ function showtask(&$a, $level=0, $is_opened = true, $today_view = false, $hideOp

if ($today_view) { // Show the project name
$s .= ('<td width="50%"><a href="?m=projects&amp;a=view&amp;project_id='
. $a['task_project'] . '">' . '<span style="padding:2px;background-color:#'
. $a['task_project'] . '">' . '<span style="padding:2px;background-color:'
. $a['project_color_identifier'] . ';color:'
. bestColor($a['project_color_identifier']) . '">' . $a['project_name'] . '</span>'
. '</a></td>');
2 changes: 1 addition & 1 deletion modules/tasks/tasks.php
Original file line number Diff line number Diff line change
@@ -533,7 +533,7 @@ function chAssignment(project_id, rmUser, del) {
<table width="100%" border="0">
<tr>
<!-- patch 2.12.04 display company name next to project name -->
<td nowrap style="border: outset #eeeeee 2px;background-color:#<?php
<td nowrap style="border: outset #eeeeee 2px;background-color:<?php
echo @$p['project_color_identifier']; ?>">
<a href="?m=projects&amp;a=view&amp;project_id=<?php echo $k;?>">
<span style="color:<?php
2 changes: 1 addition & 1 deletion modules/tasks/tasksperuser_sub.php
Original file line number Diff line number Diff line change
@@ -605,7 +605,7 @@ function displayTask($list,$task,$level,$display_week_hours,$fromPeriod,$toPerio

$tmp .= '<td align="center">';
$tmp .= ('<a href="?m=projects&amp;a=view&amp;project_id=' . $task->task_project
. '" style="background-color:#' . @$projects['project_color_identifier'] . '; color:'
. '" style="background-color:' . @$projects['project_color_identifier'] . '; color:'
. bestColor(@$projects['project_color_identifier']) . '">'
. $projects['project_short_name'] . '</a>');
$tmp .= '</td>';
2 changes: 1 addition & 1 deletion modules/tasks/view.php
Original file line number Diff line number Diff line change
@@ -186,7 +186,7 @@ function delIt() {
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Project');?>:</td>
<td style="background-color:#<?php echo $obj->project_color_identifier;?>">
<td style="background-color:<?php echo $obj->project_color_identifier;?>">
<font color="<?php echo bestColor($obj->project_color_identifier); ?>">
<?php echo $AppUI->___(@$obj->project_name);?>
</font>

0 comments on commit 288f252

Please sign in to comment.