本文整理汇总了PHP中input::source方法的典型用法代码示例。如果您正苦于以下问题:PHP input::source方法的具体用法?PHP input::source怎么用?PHP input::source使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类input
的用法示例。
在下文中一共展示了input::source方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: selfURL
/**
* Compiles URL addressing current script of current application.
*
* @param array|false $parameters set of parameters to pass in query, false
* to drop all current parameters (e.g. on creating GET form),
* provide special parameter '*' in array to start fresh set of parameters
* @param mixed $selector first of multiple optional selectors to include
* @return string URL of addressed script including optional parameters
*/
public function selfURL($parameters = array(), $selector = null)
{
$selectors = func_get_args();
$selectors = array_slice($selectors, 1);
if (!count($selectors)) {
$selectors = application::current()->selectors;
}
/*
* merge current script's input parameters with provided one
*/
if ($parameters === false) {
$parameters = array();
} else {
// find all non-persistent input parameters of current script
$currentVolatileParameters = array();
if (!array_key_exists('*', $parameters)) {
$get = input::source(input::SOURCE_ACTUAL_GET);
foreach ($get->listNames() as $name) {
if (data::isKeyword($name) && !input::isPersistent($name)) {
$currentVolatileParameters[$name] = $get->getValue($name);
}
}
}
unset($parameters['*']);
// merge volatile input with given parameters, but drop all those
// finally set NULL (to support removal per $parameters)
$parameters = array_filter(array_merge($currentVolatileParameters, $parameters), function ($item) {
return $item !== null;
});
}
/*
* utilize scriptURL() for referring to current script
*/
array_unshift($selectors, $parameters);
array_unshift($selectors, $this->script);
return call_user_func_array(array(&$this, 'scriptURL'), $selectors);
}
示例2: hasInput
/**
* Detects if current input of script is considered containing input for
* current form.
*
* @param boolean $keepFormIdInInput set true to keep any valid ID of form in input of current script
* @return boolean true if form has actual input, false otherwise
*/
public function hasInput($keepFormIdInInput = false)
{
if ($this->_hasInput === null) {
$this->_hasInput = false;
try {
$idName = $this->idName();
$source = input::source($this->usePost ? input::SOURCE_ACTUAL_POST : input::SOURCE_ACTUAL_GET);
if ($source->hasValue($idName)) {
$value = $source->getValue($idName);
if ($value == $this->idValue()) {
if (!$keepFormIdInInput) {
$source->dropValue($idName);
}
$this->_hasInput = true;
}
}
} catch (\InvalidArgumentException $e) {
}
}
return $this->_hasInput;
}