Overview

Namespaces

  • App
    • Components
    • Interfaces
    • Lib
      • Files
      • Forms
        • Controls
      • Html
      • Repair
      • Statics
    • Model
    • Modules
      • BaseModule
        • Presenters
      • PartnersModule
        • Presenters
      • ProductModule
        • Presenters
      • SaleModule
        • Model
        • Presenters
      • SettingsModule
        • Model
        • Presenters
      • StoreModule
        • Model
        • Presenters
    • Presenters
    • Router
  • PHP

Classes

  • DateTime
  • SplFileInfo

Interfaces

  • ArrayAccess
  • Countable
  • Exception
  • Iterator
  • Traversable
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Download
  1: <?php
  2: 
  3: /**
  4:  * Project sberp
  5:  *
  6:  * @file Variables
  7:  * @author Jaromír Polášek
  8:  * @version 0.9.1.AFTERMATH
  9:  * Encoding UTF-8
 10:  */
 11: 
 12: namespace App\Lib\Statics;
 13: 
 14: use Nette\Object,
 15:     Nette\Utils\Strings;
 16: 
 17: /**
 18:  * Knihovna statických metod 
 19:  */
 20: class Vars extends Object {
 21: 
 22:     /** Jméno databáze 
 23:      * @var string */
 24:     public static $database;
 25: 
 26:     /**
 27:      * získá cestu do složky App
 28:      * @return string
 29:      */
 30:     public static function appPath() {
 31:     return self::path() . '/app';
 32:     }
 33: 
 34:     /**
 35:      * Získá cestu do kořenové složky
 36:      * @return string
 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:      * Vrací hodnotu Ano / ne
 46:      * @param bolean $var
 47:      * @return String
 48:      */
 49:     public static function aN($var) {
 50:     return($var === '1') ? 'Ano' : 'Ne';
 51:     }
 52: 
 53:     /**
 54:      * Vrací hodnotu Aktivní/Neaktivní
 55:      * @param bolean $var
 56:      * @return string
 57:      */
 58:     public static function active($var) {
 59:     return ($var === 'Active') ? 'Aktivní' : (($var === 'Inactive') ? 'Neaktivní' : (($var === 'Blocked') ? 'Zablokován': $var));
 60:     }
 61: 
 62:     /**
 63:      * V případě 1 nebo TRUE vrací TRUE. 
 64:      * Ve všech ostatních případech vrací FALSE
 65:      * @param mixed $var
 66:      * @return bollean
 67:      */
 68:     public static function trueFalse($var) {
 69:     return ($var === TRUE || $var === '1') ? TRUE : FALSE;
 70:     }
 71: 
 72:     /**
 73:      * Vrátí setříděné pole v pořadí sudá, lichá
 74:      * př. 123456 = 135246
 75:      * @param array $array pole k setřídění
 76:      * @param array $left předefinované pole lichých položek
 77:      * @param array $right předefinované pole sudých položek
 78:      * @return array
 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:      * Vytvoří tabulku pro selector
 96:      * Formát aloupec1, sloupec2, sloupc...../NULL (prázdná hodnota)
 97:      * @param \Nette\Database\Table\Selection $rows
 98:      * @param string $column
 99:      * @return string
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:      * Nastaví NULL místo ''
123:      * @param type $values
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: 
sberp API API documentation generated by ApiGen