本文整理汇总了PHP中Url::generate方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::generate方法的具体用法?PHP Url::generate怎么用?PHP Url::generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Url
的用法示例。
在下文中一共展示了Url::generate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: leave
public function leave()
{
if ($this->_user->isPlaying()) {
$this->_user->exitBattlefield();
}
Url::redirect(Url::generate('Play'));
}
示例2: login
/**
* Login user
*/
public function login()
{
$redirectTo = Url::generate('Main', 'showLoginForm', '&');
if ($this->_user->isRegistered()) {
$redirectTo = Url::generate('');
}
$posted = $this->_form->getPosted();
if (empty($posted)) {
$this->_messenger->add('error', $this->_lang->get('invalidForm'));
} else {
if ($this->_user->loginByUserPass($posted['login'], $posted['password'])) {
$redirectTo = Url::generate('Play');
}
}
$this->_messenger->saveInSession();
Url::redirect($redirectTo);
}
示例3: saveAccount
public function saveAccount()
{
$urlToRedirect = Url::generate('Register');
$posted = $this->_form->getPosted();
if (empty($posted)) {
// Redirect to register page
$this->_messenger->add('error', $this->_lang->get('invalidForm'));
} else {
if ($posted['password'] != $posted['passwordVerif']) {
$this->_messenger->add('error', $this->_lang->get('passwordMismatch'));
} else {
if ($this->_user->register($posted['login'], $posted['password'], $posted['email'])) {
$urlToRedirect = Url::generate('');
}
}
}
$this->_messenger->saveInSession();
Url::redirect($urlToRedirect);
}
示例4:
<script src="<?php
echo Url::generate('/js/jquery-1.9.1.min.js');
?>
"></script>
</head>
<body>
<a href="<?php
echo Url::generate('/');
?>
">Форма поиска</a>
<a href="<?php
echo Url::generate('/result');
?>
">Результаты</a>
<h3>Данные по результату</h3>
<table class="table">
<thead>
<tr>
<td>Host</td>
</tr>
</thead>
<?php
foreach ($data as $item) {
?>
示例5: setNewPassword
/**
* Sets a new password for a user
*/
public function setNewPassword()
{
if ($this->_user->isRegistered()) {
Url::redirect(Url::generate('Account'));
}
$redirectTo = Url::generate('Account', 'showResetForm', '&');
$posted = $this->_form->getPosted();
if (empty($posted)) {
$this->_messenger->add('error', $this->_lang->get('invalidForm'));
} else {
if (!isset($posted['password'], $posted['password2'], $posted['passwordToken'])) {
$this->_messenger->add('error', $this->_lang->get('missingData'));
} else {
if ($posted['password'] != $posted['password2']) {
$this->_messenger->add('error', $this->_lang->get('passwordMismatch'));
} else {
if ($this->_user->setNewPassword($posted['passwordToken'], $posted['password'])) {
$this->_messenger->add('success', $this->_lang->get('newPasswordSet'));
$redirectTo = Url::generate('');
}
}
}
}
$this->_messenger->saveInSession();
Url::redirect($redirectTo);
}
示例6: captureHeadquarter
/**
* Capture a headquarter
*/
public function captureHeadquarter()
{
$urlToRedirect = Url::generate('Play');
$posted = $this->_form->getPosted();
if (empty($posted) || !isset($posted['headquarterId'])) {
// Logs an error message
$this->_messenger->add('error', $this->_lang->get('invalidForm'));
} else {
$this->_user->captureHeadquarter($posted['headquarterId']);
}
$this->_messenger->saveInSession();
Url::redirect($urlToRedirect);
}
示例7: foreach
</thead>
<?php
foreach ($results as $item) {
?>
<tr>
<td><?php
echo $item['host'];
?>
</td>
<td><?php
echo $types[$item['type']];
?>
</td>
<td><?php
echo $item['count'];
?>
</td>
<td><a href="<?php
echo Url::generate('/result/view/' . $item['id']);
?>
">View</a></td>
</tr>
<?php
}
?>
</table>
</body>
</html>
示例8: function
valid = false;
}
if (type == TEXT_SEARCH && text.length == 0) {
error = error + "\nYou should define text to search on page";
valid = false;
}
if (!valid) {
alert(error);
return false;
}
// SEND REQUEST
$.ajax({
type : "post",
url : "<?php
echo Url::generate('/index/search');
?>
",
data : {
'url' : url,
'type' : type,
'text' : text
},
success : function(data) {
console.log(data, data.error);
var statusDiv = $('#status-message');
if (data.error == '' || data.error == undefined) {
statusDiv.html('<span style="color: green;">Parsing successfully finished</span>').show('slow');
setTimeout(function() {
statusDiv.hide('slow').html('');
}, 3000)
示例9: createResetToken
/**
* Creates a reset password token for an account identified either by a login or an email.
*
* @param string $login User login
* @param string $meail User email
*
* @return boolean
* @todo replace the call to mail() by a proper mailer class
*/
public function createResetToken($login, $email)
{
$result = false;
$this->_db->beginTransaction();
try {
if (!empty($login)) {
$account = $this->_db->fetchFirstRequest('getUserByLogin', array(':login' => $login));
if (!empty($account['email'])) {
$email = $account['email'];
}
}
if (empty($email)) {
if (empty($account)) {
$this->_messenger->add('error', $this->_lang->get('loginNotFound'));
} else {
$this->_messenger->add('error', $this->_lang->get('accountWithoutEmail'));
}
return false;
} else {
if (empty($account)) {
$account = $this->_db->fetchFirstRequest('getUserByEmail', array(':email' => $email));
}
if (empty($account)) {
$this->_messenger->add('error', $this->_lang->get('emailNotFound'));
} else {
do {
$token = StringTools::generateToken();
$alreadyExists = $this->_db->fetchFirstRequest('getPasswordResetByToken', array(':token' => $token));
} while (!empty($alreadyExists));
$this->_db->executeRequest('createPasswordReset', array(':token' => $token, ':userId' => $account['ID']));
$to = str_replace(array("\r", "\n", "%0a", "%0d"), '', $email);
$subject = $this->_lang->get('resetMailTitle');
$body = sprintf($this->_lang->get('resetMailBody'), $account['login'], Url::generate('Account', 'showPasswordSetForm', '&', array('token' => $token)));
if (mail($to, $subject, $body, 'From: Atrexus <noreply@atrexus.com>' . "\n\r")) {
$result = true;
} else {
$this->_messenger->add('error', $body);
$this->_messenger->add('error', $this->_lang->get('emailNotSent'));
}
}
}
} catch (Exception $e) {
$this->_db->rollBack();
throw $e;
}
$this->_db->commit();
return $result;
}