/** * Sets the cookie name */ public function setName($value = '') { $value = Sanitize::toKey($value); if (!empty($value)) { $this->_name = $value; } }
/** * Look for timezone offset value saved in cookie by JS (in seconds) */ public function lookupJsCookie($name = '') { $name = Sanitize::toKey($name); $value = Utils::getValue(@$_COOKIE[$name], null); if (is_numeric($value)) { $this->setTimezoneOffset(intval($value)); } }
/** * Get the hostname */ public static function getHost() { $value = Utils::getValue(@$_SERVER['SERVER_NAME'], '', true); $value = Sanitize::toKey($value); return $value; }
/** * Set fulltext column/s index */ public function addFulltextKey($name = '', $columns = array()) { $name = Sanitize::toKey($name); $columns = array_values($columns); if (!empty($name) && !empty($columns)) { $this->indexes[$name] = "FULLTEXT " . $name . " (`" . implode("`,`", $columns) . "`)"; } return $this; }
/** * Delete an entry for a dot-notated key string */ public function delete($key = '') { $key = Sanitize::toKey($key); if (!empty($key) && $this->started === true) { $path = trim($this->container . '.' . $key, '.'); $list = explode('.', $path); $last = array_pop($list); $data =& $_SESSION; foreach ($list as $step) { if (!isset($data[$step])) { return; // gone } $data =& $data[$step]; } if (isset($data[$last])) { // need to reference the last key for unset() to work $data[$last] = null; unset($data[$last]); } } }
/** * Get a value for a key in _ENV, if set, or default */ public function getEnv($key = '', $default = null) { $key = Sanitize::toKey($key); if (!empty($key) && array_key_exists($key, $_ENV)) { return $_ENV[$key]; } return $default; }
/** * Gets an existing key, or return a default value. */ public function delete($key = '') { $key = Sanitize::toKey($key); if (!empty($key)) { $list = explode('.', $key); $last = array_pop($list); $data =& $this->_data; foreach ($list as $step) { if (!isset($data[$step])) { return; } $data =& $data[$step]; } if (isset($data[$last])) { $data[$last] = null; unset($data[$last]); } } }
/** * Adds an entry to the list of breadcrumb links data */ public function addCrumb($name = '', $link = '', $title = '', $params = array()) { $key = Sanitize::toKey($name); $name = Sanitize::toName($name); $link = Sanitize::toPath($link); $title = Sanitize::toTitle($title); if (!empty($key) && !empty($link)) { $crumbs = $this->get('crumbs', array()); $crumbs[$key] = array_merge(array('name' => $name, 'link' => $link, 'title' => $title), $params); $this->set('crumbs', $crumbs); } }
/** * Sets table primary column name */ public function setPrimary($column = '') { if (is_string($column)) { $this->_primary = Sanitize::toKey($column); } }