1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace App\Lib\Statics;
13:
14: use Nette\Object,
15: Nette\Utils\Strings;
16:
17: 18: 19:
20: class Vars extends Object {
21:
22: 23:
24: public static $database;
25:
26: 27: 28: 29:
30: public static function appPath() {
31: return self::path() . '/app';
32: }
33:
34: 35: 36: 37:
38: public static function path() {
39: $pathToWWWdir = \WWW_DIR;
40: $pathLength = Strings::length($pathToWWWdir) - 4;
41: return Strings::substring($pathToWWWdir, 0, $pathLength);
42: }
43:
44: 45: 46: 47: 48:
49: public static function aN($var) {
50: return($var === '1') ? 'Ano' : 'Ne';
51: }
52:
53: 54: 55: 56: 57:
58: public static function active($var) {
59: return ($var === 'Active') ? 'Aktivní' : (($var === 'Inactive') ? 'Neaktivní' : (($var === 'Blocked') ? 'Zablokován': $var));
60: }
61:
62: 63: 64: 65: 66: 67:
68: public static function trueFalse($var) {
69: return ($var === TRUE || $var === '1') ? TRUE : FALSE;
70: }
71:
72: 73: 74: 75: 76: 77: 78: 79:
80: public static function leftRightSort($array, $left = array(), $right = array()) {
81: $leftRight = TRUE;
82: foreach ($array as $key => $val) {
83: if ($leftRight === TRUE) {
84: $left[$key] = $val;
85: $leftRight = FALSE;
86: } else {
87: $right[$key] = $val;
88: $leftRight = TRUE;
89: }
90: }
91: return array_merge($left, $right);
92: }
93:
94: 95: 96: 97: 98: 99: 100:
101: public static function fetch($rows, $column) {
102: $params = explode('/', strtolower($column));
103: if (isset($params[1]) && $params[1] === 'null'){
104: $result = array('0' => 'Prázdné');
105: }
106: foreach ($rows as $row) {
107: $data = explode(',', $params[0]);
108: $all = '';
109: foreach ($data as $item) {
110: if ($item === reset($data)) {
111: $all .= $row[$item];
112: } else {
113: $all .= ' ,' . $row[$item];
114: }
115: }
116: $result[$row[Cons::COLUMN_ID]] = $all;
117: }
118: return $result;
119: }
120:
121: 122: 123: 124:
125: public static function setNULL($values){
126: foreach ($values as & $value){
127: if ($value === 0){
128: $value = NULL;
129: }
130: }
131: return $values;
132: }
133: }
134: