Skip to content

Commit

Permalink
Merge pull request #1 from mlespiau/flexible-layout
Browse files Browse the repository at this point in the history
Flexible layout
  • Loading branch information
mlespiau authored Jun 28, 2016
2 parents dc6a9e8 + 70d28e7 commit e53ff18
Show file tree
Hide file tree
Showing 111 changed files with 330 additions and 506 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: php
php:
- 5.5
- 5.4
script: php modules/tests/runTests.php
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# OpenCATS
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/948d67033d624e9382a332af20339c00)](https://www.codacy.com/app/OpenCATS/OpenCATS?utm_source=github.com&utm_medium=referral&utm_content=opencats/OpenCATS&utm_campaign=Badge_Grade)
[![Build Status](https://travis-ci.org/mlespiau/OpenCATS.png)](https://travis-ci.org/mlespiau/OpenCATS)

OpenCATS is a Free and Open Source Candidate/Applicant Tracking System designed for Recruiters to manage recruiting process from job posting, candidate application, through to candidate selection and submission.

Expand Down
2 changes: 1 addition & 1 deletion ajax/getPipelineJobOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function printSortLink($field, $delimiter = "'", $changeDirection = true)

document.getElementById('ajaxPipelineNavigation').innerHTML = s;
</script>
<table class="notsortable" id="pipelineTable" width="925">
<table class="notsortable" id="pipelineTable" width="100%">
<tr>
<th></th>
<th></th>
Expand Down
Binary file removed images/bottom_shadow.jpg
Binary file not shown.
2 changes: 1 addition & 1 deletion js/dataGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ function updateMove()
function setTableWidth(tableID, tableWidth, objectOverrideCell,
objectOverrideDiv, minimumTableWidth, objectTableResizing)
{
document.getElementById(tableID).style.width = tableWidth + 'px';
document.getElementById(tableID).style.width = tableWidth;

_objectTableResizing = document.getElementById(tableID);
_minimumTableWidth = minimumTableWidth;
Expand Down
21 changes: 14 additions & 7 deletions lib/DataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
*/

include_once('./lib/StringUtility.php');
include_once('./lib/Width.php');


/**
* Data Grid Library
Expand All @@ -47,7 +49,7 @@ class DataGrid
* A datagrid must be configured in its child constructor. Specifically, each one of these
* class variables must be set:
*
* $this->_tableWidth = 915; - Table width in pixels.
* $this->_tableWidth; - Table width (Width object).
* $this->_defaultAlphabeticalSortBy = 'lastName'; - Default SQL column that the table is sorted by.
* This MUST match a sortableColumn property of a
* non optional class column.
Expand Down Expand Up @@ -1597,7 +1599,7 @@ public function draw($noOverflow = false)
echo '<script type="text/javascript">', $this->_getApplyFilterFunctionDefinition(), '</script>';

/* This makes the table able to be wider then the displayable area. */
echo '<div id="OverflowDiv'.$md5InstanceName.'" style="overflow: auto; width: ' , ($this->_tableWidth + 10) , 'px; padding-left: 1px; overflow-y: hidden; overflow-x: none; padding-bottom: expression(this.scrollWidth > this.offsetWidth ? 14 : 4); ' . $this->globalStyle . '">', "\n";
echo '<div id="OverflowDiv'.$md5InstanceName.'" style="overflow: auto; width: ' , ($this->getTableWidth(true)) , 'px; padding-left: 1px; overflow-y: hidden; overflow-x: none; padding-bottom: expression(this.scrollWidth > this.offsetWidth ? 14 : 4); ' . $this->globalStyle . '">', "\n";
}

/* IE fix for floating dialog boxes not floating over controls like dropdown lists. */
Expand All @@ -1609,12 +1611,12 @@ public function draw($noOverflow = false)
/* Actuall definition for the table. */
if (isset($this->listStyle) && $this->listStyle == true)
{
echo ('<table class="sortable" width="'. ($this->_tableWidth + 10) .'" onmouseover="javascript:trackTableHighlight(event)" id="table'.$md5InstanceName.'" style="border:none;">' . "\n");
echo ('<table class="sortable" width="'. $this->getTableWidth(true) .'" onmouseover="javascript:trackTableHighlight(event)" id="table'.$md5InstanceName.'" style="border:none;">' . "\n");
echo ('<thead style="-moz-user-select:none; -khtml-user-select:none; user-select:none; display:none; ' . $this->globalStyle . '">' . "\n");
}
else
{
echo ('<table class="sortable" width="'. ($this->_tableWidth + 10) .'" onmouseover="javascript:trackTableHighlight(event)" id="table'.$md5InstanceName.'">' . "\n");
echo ('<table class="sortable" width="'. $this->getTableWidth(true) .'" onmouseover="javascript:trackTableHighlight(event)" id="table'.$md5InstanceName.'">' . "\n");
echo ('<thead style="-moz-user-select:none; -khtml-user-select:none; user-select:none; ' . $this->globalStyle . '">' . "\n");
}
echo ('<tr>' . "\n");
Expand Down Expand Up @@ -1845,15 +1847,15 @@ public function draw($noOverflow = false)
$formatString .=
'user-select: none;" onmouseover="style.cursor = '
. '\'e-resize\'" onmousedown="startResize(\'cell%s%s\', '
. '\'table%s\', \'cell%s%s\', %s, \'%s\', \'%s\', '
. '\'table%s\', \'cell%s%s\', \'%s\', \'%s\', \'%s\', '
. '\'%s\', \'%s\', this.offsetWidth);">';

echo sprintf(
$formatString,
$md5InstanceName, $index,
$md5InstanceName,
$md5InstanceName, end($_keys_current_columns),
$this->_tableWidth,
$this->getTableWidth(),
urlencode($this->_instanceName),
$_SESSION['CATS']->getCookie(),
$data['name'],
Expand Down Expand Up @@ -1928,7 +1930,7 @@ public function draw($noOverflow = false)
echo ('</table>' . "\n");

/* If the table is smaller than the maximum width, JS will extend out the last cell so the table takes up all of its allocated space. */
echo ('<script type="text/javascript">setTableWidth("table'.$md5InstanceName.'", '.$this->_totalColumnWidths.', document.getElementById(\'cell'.$md5InstanceName.end($_keys_current_columns).'\'), document.getElementById(\'cell'.$md5InstanceName.end($_keys_current_columns).'div\'), ' . ($this->_tableWidth) . ');</script>' . "\n");
echo ('<script type="text/javascript">setTableWidth("table'.$md5InstanceName.'", '.$this->_totalColumnWidths.', document.getElementById(\'cell'.$md5InstanceName.end($_keys_current_columns).'\'), document.getElementById(\'cell'.$md5InstanceName.end($_keys_current_columns).'div\'), \'' . $this->getTableWidth() . '\');</script>' . "\n");

/* Close overflowdiv */
if (!$noOverflow)
Expand Down Expand Up @@ -2643,6 +2645,11 @@ public function _getCheckAllDefinition()

echo '}';
}

protected function getTableWidth($makeLargerThanDisplayableArea = false)
{
return $this->_tableWidth->asString($makeLargerThanDisplayableArea);
}
}


Expand Down
4 changes: 3 additions & 1 deletion lib/DatabaseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,9 @@ public function makeQueryDouble($value, $precision = false)

if ($precision !== false)
{
return (string) round($value, $precision);
$valueAsDouble = round($value, $precision);
$isAWholeNumber = fmod($valueAsDouble, 1) == 0;
return number_format($valueAsDouble, $isAWholeNumber ? 0 : 2);
}

return (string) $value;
Expand Down
6 changes: 3 additions & 3 deletions lib/DatabaseSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static function makeREGEXPString($string)
* @param string text to escape
* @return string marked up string
*/
public function markUpQuotes($string)
public static function markUpQuotes($string)
{
while (strpos($string, '"') !== false)
{
Expand Down Expand Up @@ -150,7 +150,7 @@ public function markUpQuotes($string)
* @param string text to unescape
* @return string marked up string
*/
public function unMarkUpQuotes($string)
public static function unMarkUpQuotes($string)
{
return str_replace(
array('_QSPACEQ_', '_QCOMMAQ_'), array(' ', ','), $string
Expand All @@ -163,7 +163,7 @@ public function unMarkUpQuotes($string)
* @param string string to evaluate
* @return boolean parenthesis are unmatched
*/
public function containsUnmatchedParenthesis($string)
public static function containsUnmatchedParenthesis($string)
{
/* Counters for open and close paranthesis. */
$open = 0;
Expand Down
4 changes: 2 additions & 2 deletions lib/FileUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public static function makeRandomTemporaryFilePath()
* @param string Extra data to include in the MD5 hash.
* @return string Ranom unique 32-character directory name.
*/
public function getUniqueDirectory($basePath, $extraData = '')
public static function getUniqueDirectory($basePath, $extraData = '')
{
if (!empty($basePath) && substr($basePath, -1, 1) != '/')
{
Expand Down Expand Up @@ -419,7 +419,7 @@ public static function getErrorMessage($errorCode)
* @param integer file size in bytes
* @return string human-readable file size
*/
public function sizeToHuman($size, $round = 2, $skipUnits = 0)
public static function sizeToHuman($size, $round = 2, $skipUnits = 0)
{
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
$unitIndex = 0;
Expand Down
144 changes: 0 additions & 144 deletions lib/HashUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,157 +37,13 @@
*/
class HashUtility
{
const HASH_OFFSET = 2590992;
const CRC32_CRCPOLY = 0xEDB88320;
const CRC32_CRCINV = 0x5B358FD3;
const CRC32_INITXOR = 0xFFFFFFFF;
const CRC32_FINALXOR = 0xFFFFFFFF;
const CRC32_READ_BLOCKSIZE = 1048576;
const INT_MAX = 0x7fffffff;

/**
* Encodes a 32-bit integer into a 14-byte base-35 case-insensitive string.
* This is a good method to use to mask an integer value to prevent data
* phishing.
*
* Note that this does not handle values over (2,147,483,647 - HASH_OFFSET)
* or under (-2,147,483,647 + HASH_OFFSET).
*
* @param integer 32-bit interger to hash.
* @return string 14-byte base-35 case-insensitive encoded string.
*/
public static function hashInt32($integer)
{
$bytes = pack('N1', ($integer + self::HASH_OFFSET));

$scramble = rand(0,6);
$hash = '';
for ($i = 0; $i < 4; $i++)
{
$ch = ord($bytes[$i]);

for ($bit=0; $bit<7; $bit++)
{
if ($ch & (1 << $bit)) $ch = $ch ^ (1 << $bit);
else $ch = $ch | (1 << $bit);
}

/* Scramble */
if ($ch & (1 << $scramble))
{
$ch = $ch ^ (1 << $scramble);
}
else
{
$ch = $ch | (1 << $scramble);
}
$tmp = base_convert($ch, 10, 34);
if (strlen($tmp) < 2)
{
$tmp = 'Z' . $tmp;
}
$hash .= $tmp;
}
$tmp = chr(ord($scramble) + 63);
$hash .= $tmp;

$md5 = substr(md5($bytes), 0, 5);
for ($i = 0; $i < 5; $i++)
{
$ch = ord($md5[$i]);

/* Scramble */
if ($ch & (1 << $scramble))
{
$ch = $ch ^ (1 << $scramble);
}
else
{
$ch = $ch | (1 << $scramble);
}
$tmp = base_convert($ch, 10, 34);
if (strlen($tmp) < 2)
{
$tmp = 'Z' . $tmp;
}
$hash .= $tmp;
}

return $hash;
}

/**
* Decodes a 14-byte case-insensative int32 hash string created by
* hashInt32. Basic md5 hashing prevents tampering.
*
* Note that this does not handle values over (2,147,483,647 - HASH_OFFSET)
* or under (-2,147,483,647 + HASH_OFFSET).
*
* @param string 14-byte base-35 case-insensitive encoded string.
* @return integer Decoded integer or false if tampering/data errors
* have occurred.
*/
public static function unhashInt32($hash)
{
$hash = strtolower($hash);

$scramble = intval(chr(ord(substr($hash, 8, 1)) - 63));
$md5hash = substr($hash, 9, 10);
$bytes = '';

$md5 = '';
for ($i = 0; $i < 10; $i += 2)
{
$pc = substr($md5hash, $i, 2);
if ($pc[0] == 'z') $pc = substr($pc, 1);
$ch = base_convert($pc, 34, 10);

/* Scramble */
if ($ch & (1 << $scramble))
{
$ch = $ch ^ (1 << $scramble);
}
else
{
$ch = $ch | (1 << $scramble);
}
$md5 .= chr($ch);
}

for ($i = 0; $i < 8; $i += 2)
{
$pc = substr($hash, $i, 2);
if ($pc[0] == 'z') $pc = substr($pc, 1);
$ch = base_convert($pc, 34, 10);

for ($bit = 0; $bit < 7; ++$bit)
{
if ($ch & (1 << $bit)) $ch = $ch ^ (1 << $bit);
else $ch = $ch | (1 << $bit);
}

/* Scramble */
if ($ch & (1 << $scramble))
{
$ch = $ch ^ (1 << $scramble);
}
else
{
$ch = $ch | (1 << $scramble);
}
$bytes .= chr($ch);
}

if (strcasecmp(substr(md5($bytes), 0, 5), $md5))
{
return false;
}

list(, $integer) = unpack('N1', $bytes);
return $integer - self::HASH_OFFSET;
}


/**
* A reasonably fast pure-PHP CRC algorithm that doesn't require the
* entire file to be read into memory first. This is based on the following
Expand Down
12 changes: 5 additions & 7 deletions lib/StringUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,15 +560,13 @@ public static function makeCityStateString($city, $state)
*/
public static function quotedPrintableEncode($string)
{
/* Use the callback (e modifier) feature of PHP PCRE to do the
* transformation.
*/
$string = preg_replace(
'/[^\x21-\x3C\x3E-\x7E\x09\x20]/e',
'sprintf("=%02X", ord("$0"));',
$string = preg_replace_callback(
'/[^\x21-\x3C\x3E-\x7E\x09\x20]/',
function($result) {
return sprintf("=%02X", ord($result[0]));
},
$string
);

/* Prevent the splitting of lines from interfering with escaped
* characters.
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/TemplateUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private function __clone() {}
public static function printHeader($pageTitle, $headIncludes = array())
{
self::_printCommonHeader($pageTitle, $headIncludes);
echo '<body style="background: #fff; width: 955px;">', "\n";
echo '<body style="background: #fff">', "\n";
self::_printQuickActionMenuHolder();
self::printPopupContainer();
}
Expand Down
29 changes: 29 additions & 0 deletions lib/Width.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

class Width
{
private $digit;
private $unit;

function __construct($digit, $unit = "px") {
$this->digit = $digit;
$this->unit = $unit;
}

function asString($makeLargerThanDisplayableArea = false) {
if ($this->unit == 'px') {
$out = $this->digit + ($makeLargerThanDisplayableArea ? 10 : 0);
} else if ($this->unit == '%') {
$out = $this->digit;
} else {
$out = $this->digit + ($makeLargerThanDisplayableArea ? 1 : 0);
}
return $out . $this->unit;
}

function getDigit() {
return $this->digit;
}

}
?>
Loading

0 comments on commit e53ff18

Please sign in to comment.