Commit e6bd509e authored by Alexandr Sitchenko's avatar Alexandr Sitchenko

First version for presentation

parent a0c1bb30
div {
}
table {
table-layout: fixed;
width: 300px;
......@@ -10,7 +8,4 @@ table {
}
td {
border: 1px solid grey;
/*color: red;
background-color: white;
text-align: center;*/
}
\ No newline at end of file
......@@ -19,7 +19,7 @@ require_once './data/sample.php';
if (empty($data->err) == 0) {echo $data->err;}
else
{
echo "<br>";
echo "<p>This is the input array:</p>";
foreach ($tbl->data as $key => $value)
{
echo "[$key] = $value<br>";
......@@ -28,11 +28,27 @@ require_once './data/sample.php';
echo "{$a} => $b<br>";
}
}
$tbl->html_matrix()
?>
</table>
</div>
echo "<br>";
$tbl->html_table();
echo "<p>This is the output array:</p>";
foreach ($tbl->data as $key => $value)
{
echo "[$key] = $value<br>";
foreach ($value as $a => $b)
{
echo "{$a} => $b<br>";
}
}
echo "<p>This is the matrix:</p>";
foreach ($tbl->matrix as $key => $value)
{
echo "[$key] = $value<br>";
foreach ($value as $a => $b)
{
echo "{$a} => $b<br>";
}
} ?>
</div>
</body>
</html>
<?php } ?>
<?php } ?>
<?php
class Check
{
public $data;
public $sim;
public $matrix;
public $alibaba;
public $err;
public $cnt;
public $max;
public $temp;
public $stoplist;
public $k;
public $data; // input array
public $sim;
public $matrix; // array of data keys for output
public $err; // data validation errors
public $cnt; // number of rectangles
public $max; // the size of square
//public $temp; // temp data
public function __construct($data) // output $cnt - значений квадратов в таблице, $max - сторона квадрат, $sim['keys'] $err -проверка на ошибки
public function __construct($data)
{
// assign var $data value $input
$this->data = $data;
......@@ -47,30 +44,30 @@ public function __construct($data) // output $cnt - значений квадр
$this->err = "Variable names in the array are not valid.";
break;
}
// убираем лишние пробелы
str_replace(" ", "", $this->data{$k}['cells']);
// извлекаем цифры в массив
$this->temp['temp_keys'] = explode(",", $this->data{$k}['cells']);
$this->sim['keys'][$k] = $this->temp['temp_keys']; //html table`s key
$this->temp['cnt'] = array_merge($this->temp['cnt'], $this->temp['temp_keys']); // складываем массивы, получаем все значение целлс входные
$this->sim['keys'][$k] = $this->temp['temp_keys'];
$this->temp['cnt'] = array_merge($this->temp['cnt'], $this->temp['temp_keys']);
}
ksort ($this->sim['keys']); //сортирует массив по ключам
unset($k);
$this->temp['count']['1'] = count($this->temp['cnt']); //считаем
ksort ($this->sim['keys']);
$this->temp['count']['1'] = count($this->temp['cnt']);
$this->temp['cnt'] = array_flip($this->temp['cnt']);
$this->temp['count']['2'] = count(array_flip($this->temp['cnt']));
if ($this->temp['count']['1'] !== $this->temp['count']['2']) {$this->err = "The numbers of the squares coincide in 'cells'. Please enter correct data";}
if ($this->temp['count']['1'] !== $this->temp['count']['2'])
{
$this->err = "The numbers of the squares coincide in 'cells'. Please enter correct data";
}
else
{
sort($this->temp['cnt']);
$this->max = end($this->temp['cnt']);
$this->max = ceil(sqrt($this->max));
}
unset($temp);
unset($temp, $k);
}
}
public function html_matrix()
public function html_table()
{
$this->street = 1;
$this->sim['k'] = [];
......@@ -79,14 +76,13 @@ public function __construct($data) // output $cnt - значений квадр
for ($mm = 0; $mm < $this->cnt; ++$mm)
{
$sch = count($this->sim['keys'][$mm]);
//print_r ($this->sim['keys'][$mm]);
for ($p = 0; $p < $sch; ++$p)
{
$this->sim['k'] = array($this->sim['keys'][$mm][$p] => $mm);
$this->sim['street'] = $this->sim['street'] + $this->sim['k']; // складываем массивы, получаем все значение целлс входные
$this->sim['street'] = $this->sim['street'] + $this->sim['k'];
}
}
// создаём матрицу
// create a matrix
for ($str = 1; $str <= $max; ++$str)
{
for ($col=1; $col <= $max; ++$col)
......@@ -110,7 +106,8 @@ public function __construct($data) // output $cnt - значений квадр
foreach ($this->data as $key => $value)
{
$this->data[$key] = $this->data[$key] + ['colspan' => 0,
$this->data[$key] = $this->data[$key] + [
'colspan' => 0,
'rowspan' => 0,
'colspan_flag' => 0,
'rowspan_flag' => 0,
......@@ -150,7 +147,7 @@ public function __construct($data) // output $cnt - значений квадр
}
}
}
// displaying the table on the screen
$this->t = "#";
echo "<table>";
for ($str = 1; $str <= $max; ++$str)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment