本文整理汇总了PHP中Router::createUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::createUrl方法的具体用法?PHP Router::createUrl怎么用?PHP Router::createUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Router
的用法示例。
在下文中一共展示了Router::createUrl方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Bese controller constructor: restores user object by using session data and
* checks a permission to a requested action
*
* @param LiveCart $application Application instance
* @throws AccessDeniedExeption
*/
public function __construct(LiveCart $application)
{
parent::__construct($application);
$this->router = $this->application->getRouter();
if (!$application->isInstalled() && !$this instanceof InstallController) {
header('Location: ' . $this->router->createUrl(array('controller' => 'install', 'action' => 'index')));
exit;
}
unset($this->locale);
unset($this->config);
unset($this->user);
unset($this->session);
$this->checkAccess();
$this->application->setRequestLanguage($this->request->get('requestLanguage'));
$this->configFiles = $this->getConfigFiles();
$this->application->setConfigFiles($this->configFiles);
$localeCode = $this->application->getLocaleCode();
// add language code to URL for non-default languages
if ($localeCode != $this->application->getDefaultLanguageCode()) {
$this->router->setAutoAppendVariables(array('requestLanguage' => $localeCode));
}
// verify that the action is accessed via HTTPS if it is required
if ($this->router->isSSL($this->request->getControllerName(), $this->request->getActionName()) && !$this->router->isHttps()) {
header('Location: ' . $this->router->createFullUrl($_SERVER['REQUEST_URI'], true));
exit;
}
}
示例2: links
public static function links($current, $all, $perPage = 50)
{
$view = new View('pagination');
$view->total_pages = ceil($all / $perPage);
$view->current_page = $current;
$view->per_page = $perPage;
$view->previous_page = $current > 0 ? $current - 1 : false;
$view->next_page = $current + 1 < $all ? $current + 1 : false;
$view->url = Router::createUrl(array('page' => '{page}'));
return $view->render();
}
示例3: smarty_function_createUrl
function smarty_function_createUrl($param, &$smarty)
{
$project = isset($param['project']) ? $param['project'] : '';
$controller = isset($param['controller']) ? $param['controller'] : '';
$action = isset($param['action']) ? $param['action'] : '';
$baseUrl = isset($param['baseUrl']) ? $param['baseUrl'] : '';
$params = isset($param['params']) ? $param['params'] : '';
$delParams = isset($param['delParams']) ? $param['delParams'] : '';
$addParams = isset($param['addParams']) ? $param['addParams'] : '';
$baseUrl = isset($param['baseUrl']) ? $param['baseUrl'] : '';
if (!empty($delParams)) {
return Router::delUrlParams($controller, $action, $delParams, $project, $baseUrl);
}
if (!empty($addParams)) {
return Router::addUrlParams($controller, $action, $addParams, $project, $baseUrl);
}
return Router::createUrl($controller, $action, $params, $project, $baseUrl);
}
示例4: __construct
/**
* 翻页页码初始化
* @param int $totalNum 总条数
* @param int $pageSize 每页显示条数
* @param int $params 链接参数,默认为空时使用$_GET
* @param int $pName 翻页页码数参数名称,默认为page
* @return void
*/
public function __construct($totalNum, $pageSize, $params = array(), $pName = 'page')
{
$pageSize = intval($pageSize);
if (empty($pageSize)) {
return false;
}
empty($params) && ($params = BaseModelRouter::$get);
//基本数据计算
$this->totalNum = max(intval($totalNum), 0);
//自然数
$this->pageSize = max($pageSize, -1 * $pageSize);
//自然数,当$pageSize=0时不分页
$this->params = $params;
empty($pName) || ($this->pName = $pName);
$this->page = isset($this->params[$this->pName]) ? max($this->params[$this->pName], 1) : 1;
$this->totalPage = ceil($this->totalNum / $this->pageSize);
// $this->page = min($this->page, $this->totalPage);
$this->prePage = max($this->page - 1, 1);
//上一页
$this->nextPage = min($this->page + 1, $this->totalPage);
//下一页
$this->lastPage = $this->totalPage;
//最后一页
//limit计算
$this->page || ($this->page = 1);
$this->limit = " LIMIT " . ($this->page - 1) * $this->pageSize . ', ' . $this->pageSize;
//用于 MySQL 分页生成语句
//url参数计算
unset($this->params[$this->pName]);
if (defined('QUEUE') || defined('EXTERN')) {
$this->paramStr = "?" . http_build_query($this->params);
} else {
$this->paramStr = Router::createUrl('', '', $this->params);
}
if (strpos($this->paramStr, '?') !== false) {
$this->paramStr .= '&';
} else {
$this->paramStr .= '?';
}
return;
}
示例5: foreach
<tr class="crud-search-tr">
<td> </td>
<?php
foreach ($columns as $column => $name) {
echo '<td>';
echo '<input type="text" class="crud-search-field" name="search[' . $column . ']" value="' . (isset($_GET['search']['column']) ? htmlspecialchars($_GET['search']['column']) : '') . '">';
echo '</td>';
}
?>
</tr>
<?php
foreach ($iterations as $row) {
echo '<tr>';
echo '<td><input type="checkbox" name="ids[' . $row->id . ']"' . ((isset($_GET['ids'][$row->id]) and $_GET['ids'][$row->id] == 'on') ? ' checked="checked"' : '') . '/></td>';
foreach ($columns as $column => $name) {
echo '<td onclick="document.location = \'' . Router::createUrl(array('id' => $row->id)) . '\'">' . $row->{$column} . '</td>';
}
echo '</tr>';
}
?>
</table>
<?php
if ($countAll > 0) {
?>
<a href="javascript:document.getElementById('crud-form').submit()"><?php
echo Dict::word('delete marked');
?>
</a>
|
<?php
}
示例6: htmlspecialchars
<form method="post" action="<?php
echo Router::createUrl(array(), false, false);
?>
" class="crud-form">
<fieldset>
<table>
<?php
foreach ($model->fields() as $column => $name) {
echo '<tr>';
echo '<td>' . $name . '</td>';
echo '<td><input type="text" name="data[' . $column . ']" value="' . htmlspecialchars($model->{$column}) . '"/>';
}
?>
</table>
<input type="hidden" name="id" value="<?php
echo $model->id;
?>
"/>
<input type="submit" class="submit" value="<?php
echo Dict::word('Save');
?>
"/>
</fieldset>
</form>
示例7: createUrl
/**
* 网址(URL)组装操作
*
* 注:组装绝对路径的URL
*
* @access public
*
* @param string $route controller与action。例:controllerName/actionName
* @param array $params URL路由其它字段。注:url的参数信息
*
* @return string
*/
public static function createUrl($route, $params = array())
{
//参数分析
if (!$route) {
return false;
}
return Router::createUrl($route, $params);
}
示例8: testRouteNotFound
public function testRouteNotFound()
{
$this->setExpectedException('Http\\RouterException');
$router = new Router();
$router->createUrl('404');
}
示例9: createUrl
/**
* 网址(URL)组装操作
*
* 注:组装绝对路径的URL
*
* @access public
*
* @param string $route controller与action。例:controllerName/actionName
* @param array $params URL路由其它字段。注:url的参数信息
*
* @return string
*/
public static function createUrl($route, $params = array())
{
return Router::createUrl($route, $params);
}