Example #1
0
 public function __construct(Router $_router, $_ = array())
 {
     $this->lang = $_router->getLang();
     if (!in_array($this->lang, \Ker\Config::getOne("allowedLanguages"))) {
         $this->lang = \Ker\Config::getOne("defaultLanguage");
         $this->setError(404);
         return;
     }
     $this->module = $_router->getModule();
     $this->action = $_router->getAction();
     $this->data = $_router->getData();
     $this->extra = $_router->getExtra();
     $view = $this->getView();
     if (!$this->module) {
         $this->module = "Index";
         $this->action = "index";
     } elseif (isset($_["requireViewFile"]) and $_["requireViewFile"] and !file_exists($view::getViewFile($this->lang, $this->module, $this->action))) {
         $this->setError(404);
     }
 }
Example #2
0
 /**
  * Metoda wyświetlajaca lub zwracająca (zależnie od przekazanych parametrów) rozbudowanego dumpa z przekazanych parametrów.
  * Dump jest przygotowywany tylko, gdy w \Ker\Config klucz "debug" jest ustawiony na wartość true.
  *
  * @static
  * @public
  * @param array $_opts [opt = null] tablica opcji sterujacych dumpem:\n
  *  trace => (bool) [opt = true] czy uwzględnić stos wywołań
  *  memory => (bool) [opt = true] czy uwzględnić zużycie pamięci
  *  print => (bool) [opt = true] czy wyświetlić dumpa
  * @param list $... elementy do zdumpowania
  * @return string|null tekstowa reprezentacja dumpa, zwracana tylko gdy $_opts["print"] === false
  */
 public static function dmp()
 {
     if (!\Ker\Config::getOne("debug")) {
         return;
     }
     $args = func_get_args();
     $_opts = array_shift($args);
     ob_start();
     $callPlace = debug_backtrace();
     // zapewniamy, by w przypadku wywołania metody z wrappera dump - poprawie wyświetlić informacje o miejscu wywołania dmp/dump
     if ($callPlace[1]["class"] === "Ker\\Utils\\Debug" && $callPlace[1]["function"] === "dump") {
         $callPlace = "{$callPlace[1]["file"]} :: {$callPlace[1]["line"]}";
     } else {
         $callPlace = "{$callPlace[0]["file"]} :: {$callPlace[0]["line"]}";
     }
     echo "<div style='text-align: left; border: red solid; margin: 5px; padding: 5px;'>";
     echo "<span style='color: red; font-weight: bold;'>DEBUG: {$callPlace} :</span>";
     call_user_func_array(array("static", "preDump"), $args);
     if (!isset($_opts["trace"]) || $_opts["trace"]) {
         echo "<hr />";
         static::preTrace();
     }
     if (!isset($_opts["memory"]) || $_opts["memory"]) {
         echo "<hr />";
         echo "Memory: " . static::memory() . " / " . static::memory(true);
         echo "<hr />";
         echo "MemoryMax: " . static::memoryMax() . " / " . static::memoryMax(true);
     }
     echo "</div>";
     if (!isset($_opts["print"]) || $_opts["print"]) {
         ob_end_flush();
         return;
     }
     $content = ob_get_clean();
     $content = preg_replace("/\n/", "<br />", $content);
     return preg_replace("/(?<=\\s)\\s/", "&nbsp;", $content);
 }
Example #3
0
File: CRUD.php Project: keradus/ker
 /**
  * Metoda zwracająca handler do bazy danych.
  *
  * @static
  * @public
  * @return DB handler
  * @see Ker\Config::getOne("SQL")
  */
 public static function getDbHandler()
 {
     static $handler = null;
     if (!$handler) {
         $handler = \Ker\Config::getOne("SQL");
     }
     return $handler;
 }
Example #4
0
File: View.php Project: keradus/ker
 public static function getViewFile($_lang, $_module, $_action)
 {
     // jesli istnieje plik przewidziany dla danego jezyka
     $file = \Ker\Config::getOne("view", "./view") . "/{$_module}/{$_action}.{$_lang}.php";
     if (file_exists($file)) {
         return $file;
     }
     // w przeciwnym wypadku zwroc plik ogolny (bez uszczegolowionego jezyka)
     // funckja zaklada, ze jesli nie ma pliku dla jezyka to _musi_ byc plik ogolny
     return \Ker\Config::getOne("view", "./view") . "/{$_module}/{$_action}.php";
 }