function view($id) { if ($this->article->read($id)) { $data = array('article' => $this->article->read($id), 'title' => 'All articles'); Load::view('article_read.php', $data); } else { parent::error(); } }
public static function justRender($viewName, $data = []) { extract($data, EXTR_PREFIX_SAME, "same"); // dump(CORE_REPOSITORY_REAL_PATH."views/".$viewName.".php"); if (is_file(CORE_REPOSITORY_REAL_PATH . "views/" . $viewName . ".php")) { include_once CORE_REPOSITORY_REAL_PATH . "views/" . $viewName . ".php"; } else { $sc = new Controller(); $sc->error('template-not-found', $viewName); } }
/** * Set a 'flash' message that will persist through a redirect. * * Usage example: * {flash error="Uh oh, something went wrong" redirect="/somewhere"} * {flash notice="Account saved!" refresh=true} * {flash warning="There have been {$x} login attempts"} */ function flash($params, $options = null) { if (is_array($params)) { $redirect = $params['redirect'] ?: ($params['refresh'] ? $_SERVER['REQUEST_URI'] : null); if ($params['error']) { Controller::error($params['error'], $redirect); } if ($params['warn']) { Controller::warn($params['warn'], $redirect); } if ($params['notice']) { Controller::notice($params['notice'], $redirect); } } else { if (is_string($params)) { Controller::notice($params); } } return; }
public static function codesToString($connection_codes) { $result = ''; $cc = new Controller(); if (count($connection_codes)) { foreach ($connection_codes as $code) { if ($code instanceof ConnectionCode) { if (isset($code->value_raw)) { $result .= "| Код: " . $code->value_raw; } else { $result .= "| Код: " . $code->value; } if (isset($code->tip) && strlen($code->tip)) { $result .= " (" . $code->tip . ") "; } } else { $cc->error('500'); } } } else { $result = '| Код не выдан или не требуется'; } return $result; }