本文整理汇总了PHP中application::current方法的典型用法代码示例。如果您正苦于以下问题:PHP application::current方法的具体用法?PHP application::current怎么用?PHP application::current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类application
的用法示例。
在下文中一共展示了application::current方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getScopeParameter
public static final function getScopeParameter(&$domain, &$path)
{
// process focus selection
$focus = config::get('session.focus', 'application');
switch ($focus) {
case 'domain':
// valid for whole current domain
$domain = $_SERVER['HTTP_HOST'];
$path = '/';
break;
case 'txf':
// valid for all applications in current installation, only
$domain = $_SERVER['HTTP_HOST'];
$path = '/' . txf::getContext()->prefixPathname;
break;
case 'application':
// valid for current application, only
$domain = $_SERVER['HTTP_HOST'];
$path = '/' . application::current()->prefixPathname;
break;
default:
// option is explicitly providing domain and path to focus
if (strpos($focus, '%') !== false) {
$focus = strtr($focus, array('%H' => $_SERVER['HTTP_HOST'], '%T' => '/' . txf::getContext()->prefixPathname, '%A' => '/' . application::current()->prefixPathname));
}
$temp = explode('/', $focus);
$domain = array_shift($temp);
$path = '/' . implode('/', $temp);
}
}
示例3: redirectTo
public static function redirectTo($url)
{
if (func_num_args() > 1) {
$url = call_user_func_array(array(__NAMESPACE__ . '\\context', 'scriptURL'), func_get_args());
}
if (url::isRelative($url)) {
$url = application::current()->relativePrefix($url);
}
header('Location: ' . $url);
view::callDisableOutput();
exit;
}
示例4: qualifyThread
/**
* Converts current set of items into multi-dimensional array containing
* subordinated navigators' items as ordinary arrays as well.
*
* Additionally this method tries to detect active/selected items and
* threads of navigator.
*
* @return array set items with subordinated items resolved to arrays
*/
protected function qualifyThread($depth = 1, &$selected)
{
$out = array('level' => intval($depth), 'items' => array());
foreach ($this->items as $name => $item) {
if (@$item['label'] || $item['asset']) {
// process attached sub navigator
if (@$item['sub'] instanceof navigator) {
// resolve that one's items
$subselected = false;
$item['sub'] = $item['sub']->qualifyThread($depth + 1, $subselected);
// if resolving detected selected sub-item ...
if ($subselected && !$selected) {
// ... transfer related mark to caller
$selected = true;
// ... mark containing navigator as active one
$out['active'] = 'active';
}
} else {
$item['sub'] = array('items' => array());
}
// apply auto-detection of selected item if enabled and on haven't selected item before
if (!$selected) {
$detected = $this->detectSelected($item);
if ($detected) {
// current item is selected, thus mark
if ($detected === true) {
$item['selected'] = 'selected';
} else {
$item['active'] = 'active';
}
// and tell any containing navigator about having found selected item
$selected = $detected;
}
}
$item['action'] = application::current()->normalizeUrl($item['action']);
$out['items'][$name] = $item;
}
}
return $out;
}
示例5: scriptURL
/**
* Simplifies retrieval of compiled URLs to a selected script of current
* application.
*
* In opposition to selfURL() $parameters must be array of parameters to
* integrate into generated link for never being merged with existing input.
*
* @param string $scriptName name of script to refer to
* @param array $parameters set of parameters to include in reference
* @param string $selector one of several selectors to include in reference
* @return string URL referring to selected script
*/
public static function scriptURL($scriptName, $parameters = array(), $selector = null)
{
$args = func_get_args();
return call_user_func_array(array(application::current(), 'scriptURL'), $args);
}
示例6: getCode
/**
* Renders HTML code of form.
*
* @return string generated HTML code
*/
public function getCode()
{
$method = $this->usePost ? 'post' : 'get';
$action = is_null($this->processorUrl) ? application::current()->selfUrl($this->usePost ? array() : false) : $this->processorUrl;
$mime = $this->maxFileSize > 0 ? ' enctype="multipart/form-data"' : '';
$size = $this->maxFileSize > 0 ? '<input type="hidden" name="MAX_FILE_SIZE" value="' . $this->maxFileSize . "\"/>\n\t" : '';
$name = html::idname($this->name);
$idName = $this->idName();
$idValue = $this->idValue();
$labelClass = 'without-labels';
// compile code of form's rows
$template = self::getRowTemplate();
$rows = array_filter($this->rows, function ($row) {
return !!count($row);
});
if ($this->sortingOrder) {
data::rearrangeArray($rows, $this->sortingOrder, true);
}
$rows = array_map(function ($row) use($template, &$labelClass) {
if (@$row['label']) {
$labelClass = 'with-labels';
}
$label = view::wrapNotEmpty(@$row['label'], '', '');
$code = view::wrapNotEmpty(@$row['htmlCode'], '', '');
$hint = view::wrapNotEmpty(@$row['hint'], '<span class="hint">', "</span>\n");
$error = view::wrapNotEmpty(@$row['error'], '<span class="error">', "</span>\n");
$mandatory = @$row['mandatory'] ? config::get('html.form.mandatory', '<span class="mandatory">*</span>') : '';
if (trim($label) !== '') {
$label = sprintf(config::get('html.form.label', '%s%s:'), $label, $mandatory);
}
return sprintf($template, trim('form-row-name-' . @$row['name'] . ' ' . @$row['class']), $label, $code, $error, $hint);
}, $rows);
// embed compiled rows in form's custom content
$code = str_replace('%%%%ROWS_STACK%%%%', implode('', $rows), $this->code);
$hidden = $this->enableXsrfMode ? "<input type=\"hidden\" name=\"{$idName}\" value=\"{$idValue}\"/>" : '';
foreach ($this->hidden as $key => $value) {
if (is_array($value)) {
foreach ($value as $subName => $subValue) {
$hidden .= '<input type="hidden" name="' . html::inAttribute($key) . '[' . html::inAttribute($subName) . ']" value="' . html::inAttribute($subValue) . '"/>';
}
} else {
if ($value !== null) {
$hidden .= '<input type="hidden" name="' . html::inAttribute($key) . '" value="' . html::inAttribute($value) . '"/>';
}
}
}
$class = ' class="' . html::inAttribute(trim($this->class . ' ' . $labelClass)) . '"';
return <<<EOT
<form action="{$action}" method="{$method}"{$mime} id="{$name}"{$class}>
\t{$size}{$hidden}
{$code}
</form>
EOT;
}
示例7: qualifyString
public static function qualifyString($in, $values = null)
{
if (is_array($values)) {
$cb = function ($matches) use($values) {
$chunks = explode('::', $matches[1]);
return array_key_exists($chunks[0], $values) ? $values[trim($chunks[0])] : $matches[1];
};
} else {
$cb = function ($matches) use($values) {
$chunks = explode('::', $matches[1]);
switch (strtolower(trim($chunks[0]))) {
case 'appdir':
return application::current()->pathname;
case 'appurl':
return application::current()->scriptURL($chunks[1]);
case 'date':
return date($chunks[1], count($chunks) > 2 ? intval($chunks[2]) : time());
default:
return '';
}
};
}
return preg_replace_callback('/\\{\\{([^}]+)\\}\\}/', $cb, $in);
}