/** * Add a new flash message to the list for $key */ public function setFlash($key = "", $class = "", $message = "") { if (!empty($key) && is_string($key)) { $class = Sanitize::toText($class); $message = Sanitize::toText($message); $key = $this->fkey . "." . $key; $list = $this->session->get($key, array()); $list[] = array("class" => $class, "message" => $message, "addtime" => time()); $this->session->set($key, $list); } }
/** * Write data to a file */ public function write($data = "") { $path = $this->getPath(); $parent = $this->getParent(); $ext = $this->getExtension(); $data = Sanitize::toText($data); $output = false; if (!empty($path) && !empty($parent) && !empty($ext)) { if (is_dir($parent) || mkdir($parent, 0777, true)) { $stream = fopen($path, "wb"); $output = fwrite($stream, $data); fclose($stream); } } return $output; }
/** * Fills a space to the right of a string with a number of characters */ public static function fill($value = "", $limit = 30, $char = ".", $last = ":") { $value = Sanitize::toText($value); $strlen = strlen($value) + strlen($last); $count = $strlen > $limit ? $strlen - $limit : $limit - $strlen; return $value . str_repeat($char, $count) . $last; }
/** * Set the response charset */ public function setCharset($charset) { $charset = Sanitize::toText($charset); $this->_charset = Utils::value($charset, $this->_charset, "UTF-8"); return $this; }