/** * read * get the value of the cookie with the given name in format $type, * else return $default * * @param string $name * @param int|string $type \Flywheel\Filter\Input::TYPE_* @see \Flywheel\Filter\Input * @param mixed $default * * @return mixed */ public function read($name, $type = 'STRING', $default = null) { $name = $this->getName($name); if (!isset($_COOKIE[$name])) { return $default; } return Input::clean($_COOKIE[$name], $type); }
/** * Returns the named DELETE parameter value. * If the DELETE parameter does not exist or if the current request is not a DELETE request, * the second parameter to this method will be returned. * If the DELETE request was tunneled through POST via _method parameter, the POST parameter * will be returned instead * @param string $name the DELETE parameter name * @param string $type filter type (INT, UINT, FLOAT, BOOLEAN, WORD, ALNUM, CMD, BASE64, STRING, ARRAY, PATH, NONE) * @param mixed $default the default parameter value if the DELETE parameter does not exist. * @return mixed the DELETE parameter value */ public function delete($name, $type = 'STRING', $default = null) { if (!isset($this->_cleaned['DELETE'][$name])) { if ($this->_getIsDeleteViaPostRequest()) { return $this->post($name, $type, $default); } if ($this->_deleteParams === null) { $this->_deleteParams = $this->isDeleteRequest() ? $this->getRestParams() : array(); } if (!isset($this->_deleteParams[$name])) { return $default; } $this->_cleaned['DELETE'][$name] = Input::clean($this->_deleteParams[$name], $type); } return $this->_cleaned['DELETE'][$name]; }
/** * resize and make an square image with new dimension * if no newWidth given, the smallest side will be used as newWidth * * @param int $newWidth * * @return boolen * @throws InvalidArgumentException */ public function square($newWidth = null) { if (null == $newWidth) { $newWidth = $this->_currentDimensions['width'] < $this->_currentDimensions['height'] ? $this->_currentDimensions['width'] : $this->_currentDimensions['height']; } else { $newWidth = Input::clean($newWidth, 'INT', 0); if (0 === $newWidth) { $this->_triggerError('kích thước hình phải lớn hơn 0.', new \InvalidArgumentException('newWidth must be numeric and greater than zero.')); return false; } if ($this->_currentDimensions['width'] < $this->_currentDimensions['height']) { //resize by width $newWidth = $this->_currentDimensions['width'] < $newWidth ? $this->_currentDimensions['width'] : $newWidth; $result = $this->resize($newWidth); } else { //resize by height $newWidth = $this->_currentDimensions['height'] < $newWidth ? $this->_currentDimensions['height'] : $newWidth; $result = $this->resize(0, $newWidth); } if (false === $result) { return false; } } return $this->cropFromCenter($newWidth); }