本文整理汇总了PHP中PKPRequest::url方法的典型用法代码示例。如果您正苦于以下问题:PHP PKPRequest::url方法的具体用法?PHP PKPRequest::url怎么用?PHP PKPRequest::url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PKPRequest
的用法示例。
在下文中一共展示了PKPRequest::url方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view
/**
* View announcement details.
* @param $args array optional, first parameter is the ID of the announcement to display
*/
function view($args = array())
{
$this->validate();
$this->setupTemplate();
$announcementId = !isset($args) || empty($args) ? null : (int) $args[0];
$announcementDao =& DAORegistry::getDAO('AnnouncementDAO');
if ($this->_getAnnouncementsEnabled() && $this->_announcementIsValid($announcementId)) {
$announcement =& $announcementDao->getAnnouncement($announcementId);
if ($announcement->getDateExpire() == null || strtotime($announcement->getDateExpire()) > time()) {
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign('announcement', $announcement);
if ($announcement->getTypeId() == null) {
$templateMgr->assign('announcementTitle', $announcement->getLocalizedTitle());
} else {
$templateMgr->assign('announcementTitle', $announcement->getAnnouncementTypeName() . ": " . $announcement->getLocalizedTitle());
}
$templateMgr->append('pageHierarchy', array(PKPRequest::url(null, 'announcement'), 'announcement.announcements'));
$templateMgr->display('announcement/view.tpl');
} else {
Request::redirect(null, null, 'announcement');
}
} else {
Request::redirect(null, null, 'announcement');
}
}
示例2: index
/**
* Display help table of contents.
*/
function index()
{
$this->validate();
$this->setupTemplate();
$templateMgr =& TemplateManager::getManager();
$user = Request::getUser();
if (isset($user)) {
$userId = $user->getId();
$templateMgr->assign('isUserLoggedIn', true);
} else {
$userId = 0;
$templateMgr->assign('emailUrl', PKPRequest::url(NotificationHandler::getContextDepthArray(), 'notification', 'subscribeMailList'));
$templateMgr->assign('isUserLoggedIn', false);
}
$rangeInfo =& Handler::getRangeInfo('notifications');
$notificationDao =& DAORegistry::getDAO('NotificationDAO');
$notifications = $notificationDao->getByUserId($userId, NOTIFICATION_LEVEL_NORMAL, $rangeInfo);
$templateMgr->assign('notifications', $notifications);
$templateMgr->assign('unread', $notificationDao->getUnreadNotificationCount($userId));
$templateMgr->assign('read', $notificationDao->getReadNotificationCount($userId));
$templateMgr->assign('url', PKPRequest::url(NotificationHandler::getContextDepthArray(), 'notification', 'settings'));
$templateMgr->display('notification/index.tpl');
}
示例3: smartySortHeading
/**
* Smarty usage: {sort_heading key="localization.key.name" sort="foo"}
*
* Custom Smarty function for creating heading links to sort tables by
* @params $params array associative array
* @params $smarty Smarty
* @return string heading link to sort table by
*/
function smartySortHeading($params, &$smarty)
{
if (isset($params) && !empty($params)) {
$sortParams = Request::getQueryArray();
isset($params['sort']) ? $sortParams['sort'] = $params['sort'] : null;
$sortDirection = $smarty->get_template_vars('sortDirection');
$sort = $smarty->get_template_vars('sort');
// Invert sort direction
if ($params['sort'] == $sort) {
if ($sortDirection == SORT_DIRECTION_ASC) {
$sortParams['sortDirection'] = SORT_DIRECTION_DESC;
} else {
$sortParams['sortDirection'] = SORT_DIRECTION_ASC;
}
} else {
$sortParams['sortDirection'] = SORT_DIRECTION_ASC;
}
$link = PKPRequest::url(null, null, null, Request::getRequestedArgs(), $sortParams, null, true);
$text = isset($params['key']) ? Locale::translate($params['key']) : '';
$style = isset($sort) && isset($params['sort']) && $sort == $params['sort'] ? ' style="font-weight:bold"' : '';
return "<a href=\"{$link}\"{$style}>{$text}</a>";
}
}
示例4: smartyPageLinks
/**
* Display page links for a listing of items that has been
* divided onto multiple pages.
* Usage:
* {page_links
* name="nameMustMatchGetRangeInfoCall"
* iterator=$myIterator
* additional_param=myAdditionalParameterValue
* }
*/
function smartyPageLinks($params, $smarty)
{
$iterator = $params['iterator'];
$name = $params['name'];
if (isset($params['params']) && is_array($params['params'])) {
$extraParams = $params['params'];
unset($params['params']);
$params = array_merge($params, $extraParams);
}
if (isset($params['anchor'])) {
$anchor = $params['anchor'];
unset($params['anchor']);
} else {
$anchor = null;
}
if (isset($params['all_extra'])) {
$allExtra = ' ' . $params['all_extra'];
unset($params['all_extra']);
} else {
$allExtra = '';
}
unset($params['iterator']);
unset($params['name']);
$numPageLinks = $smarty->get_template_vars('numPageLinks');
if (!is_numeric($numPageLinks)) {
$numPageLinks = 10;
}
$page = $iterator->getPage();
$pageCount = $iterator->getPageCount();
$pageBase = max($page - floor($numPageLinks / 2), 1);
$paramName = $name . 'Page';
if ($pageCount <= 1) {
return '';
}
$value = '';
$router = $this->_request->getRouter();
$requestedArgs = null;
if (is_a($router, 'PageRouter')) {
$requestedArgs = $router->getRequestedArgs($this->_request);
}
if ($page > 1) {
$params[$paramName] = 1;
$value .= '<a href="' . $this->_request->url(null, null, null, $requestedArgs, $params, $anchor) . '"' . $allExtra . '><<</a> ';
$params[$paramName] = $page - 1;
$value .= '<a href="' . $this->_request->url(null, null, null, $requestedArgs, $params, $anchor) . '"' . $allExtra . '><</a> ';
}
for ($i = $pageBase; $i < min($pageBase + $numPageLinks, $pageCount + 1); $i++) {
if ($i == $page) {
$value .= "<strong>{$i}</strong> ";
} else {
$params[$paramName] = $i;
$value .= '<a href="' . $this->_request->url(null, null, null, $requestedArgs, $params, $anchor) . '"' . $allExtra . '>' . $i . '</a> ';
}
}
if ($page < $pageCount) {
$params[$paramName] = $page + 1;
$value .= '<a href="' . $this->_request->url(null, null, null, $requestedArgs, $params, $anchor) . '"' . $allExtra . '>></a> ';
$params[$paramName] = $pageCount;
$value .= '<a href="' . $this->_request->url(null, null, null, $requestedArgs, $params, $anchor) . '"' . $allExtra . '>>></a> ';
}
return $value;
}
示例5: resetPassword
/**
* Reset a user's password
* @param $args array first param contains the username of the user whose password is to be reset
*/
function resetPassword($args)
{
$this->validate();
$this->setupTemplate();
$username = isset($args[0]) ? $args[0] : null;
$userDao =& DAORegistry::getDAO('UserDAO');
$confirmHash = Request::getUserVar('confirm');
if ($username == null || ($user =& $userDao->getUserByUsername($username)) == null) {
PKPRequest::redirect(null, null, 'lostPassword');
return;
}
$templateMgr =& TemplateManager::getManager();
$hash = Validation::generatePasswordResetHash($user->getId());
if ($hash == false || $confirmHash != $hash) {
$templateMgr->assign('errorMsg', 'user.login.lostPassword.invalidHash');
$templateMgr->assign('backLink', PKPRequest::url(null, null, 'lostPassword'));
$templateMgr->assign('backLinkLabel', 'user.login.resetPassword');
$templateMgr->display('common/error.tpl');
} else {
// Reset password
$newPassword = Validation::generatePassword();
if ($user->getAuthId()) {
$authDao =& DAORegistry::getDAO('AuthSourceDAO');
$auth =& $authDao->getPlugin($user->getAuthId());
}
if (isset($auth)) {
$auth->doSetUserPassword($user->getUsername(), $newPassword);
$user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword()));
// Used for PW reset hash only
} else {
$user->setPassword(Validation::encryptCredentials($user->getUsername(), $newPassword));
}
$user->setMustChangePassword(1);
$userDao->updateObject($user);
// Send email with new password
$site =& Request::getSite();
import('classes.mail.MailTemplate');
$mail = new MailTemplate('PASSWORD_RESET');
$this->_setMailFrom($mail);
$mail->assignParams(array('username' => $user->getUsername(), 'password' => $newPassword, 'siteTitle' => $site->getLocalizedTitle()));
$mail->addRecipient($user->getEmail(), $user->getFullName());
$mail->send();
$templateMgr->assign('pageTitle', 'user.login.resetPassword');
$templateMgr->assign('message', 'user.login.lostPassword.passwordSent');
$templateMgr->assign('backLink', PKPRequest::url(null, Request::getRequestedPage()));
$templateMgr->assign('backLinkLabel', 'user.login');
$templateMgr->display('common/message.tpl');
}
}
示例6: setupTemplate
function setupTemplate($subclass = false)
{
parent::setupTemplate(true);
if ($subclass) {
$templateMgr =& TemplateManager::getManager();
$templateMgr->append('pageHierarchy', array(PKPRequest::url(null, 'manager', 'announcements'), 'manager.announcements'));
}
}