本文整理汇总了PHP中Dispatcher::setParams方法的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher::setParams方法的具体用法?PHP Dispatcher::setParams怎么用?PHP Dispatcher::setParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::setParams方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionNewReply
function actionNewReply($params = '')
{
if ($this->objAuthentication->loggedIn()) {
if (!empty($params['newPost']) && $params['newPost'] == 1) {
$forumModel = new ForumModel();
if (!$forumModel->isThreadLocked($params['threadId'])) {
$post = array();
$post['postid'] = $params['threadId'];
$post['topic'] = $params['topic'];
$post['message'] = $params['message'];
$newPost = $forumModel->addReply($post);
if ($newPost) {
$objSettings = Settings::getInstance();
$perPage = $objSettings->getEntry('per_page_posts');
$thread = $forumModel->getThread($post['postid']);
$category = $forumModel->getCategory($thread['topic']['catid']);
$channel = $forumModel->getChannel($category['channelid']);
$totalPages = ceil($forumModel->numbReplies($thread['topic']['id']) / $perPage);
if ($totalPages == 0) {
$totalPages = 1;
}
header("Location: http://" . URL . "/community/" . preg_replace('/[^a-zA-Z]/', '_', $channel['name']) . "-" . $channel['id'] . "/" . preg_replace('/[^a-zA-Z]/', '_', $category['name']) . "-" . $category['id'] . "/" . preg_replace('/[^a-zA-Z]/', '_', $thread['topic']['topic']) . "-" . $thread['topic']['id'] . "-" . $totalPages . ".html#" . $newPost);
}
} else {
$this->view->assign('content', 'This thread is locked');
$this->finish();
}
} else {
$objDispatcher = new Dispatcher();
$objDispatcher->setController('Forum');
$objDispatcher->setAction('Index');
$objDispatcher->setParams($params);
$objDispatcher->dispatch();
}
} else {
$this->view->assign('errorMsg', 'You must login to make a post');
$this->view->assign('content', $this->view->fetch('tpl/community/login.tpl'));
$this->finish();
}
}
示例2: Dispatcher
$objAuthentication = Authentication::getInstance();
$objSettings = Settings::getInstance();
$objDispatcher = new Dispatcher();
// custom url rewriting
$objUrls = new FriendlyurlModel();
$objUrls->parseRequest($params['_urlrequest']);
if (!empty($objUrls->requestParams)) {
$params = array_merge($params, $objUrls->requestParams);
}
// start up
try {
$objSettings->loadSettings();
$objDispatcher->setDirectory('frontend');
$objDispatcher->setController($objUrls->requestController);
$objDispatcher->setAction($objUrls->requestAction);
$objDispatcher->setParams($params);
$objDispatcher->dispatch();
} catch (Exception $e) {
$objEmail = new Emailer();
$objEmail->addTO(ERROR_EMAIL);
$objEmail->setFrom(ERROR_EMAIL);
$objEmail->setSubject('FATAL ERROR | Exception thrown on ' . URL);
$objEmail->setBody('Fatal Exception! ' . $e->getMessage() . print_r($params, true));
//$objEmail->sendMail();
die('Error<br/>' . $e->getMessage() . '<br/><a href="http://' . URL . '">' . PRODUCT_NAME . '</a>');
}
// time to clean up
$dbQueries = $objDatabase->getNumbQueries();
$objDatabase->disconnect();
//end timer
$endTime = microtime(true);
示例3: actionSubmit
function actionSubmit($params2 = '')
{
// loading $params from global so that the View can load the proper _urlrequest
global $params;
$params = array_merge($params, $params2);
$hasError = false;
$formErrors = array();
if (!empty($params['formSubmit'])) {
$objEmail = new EmailSender();
$objForm = new FormModel();
if (!empty($params['formSubmit']['id'])) {
$formInfo = $objForm->loadForm($params['formSubmit']['id']);
// validate forms fields
if (!empty($formInfo['fields'])) {
foreach ($formInfo['fields'] as $formField) {
if ($formField['required'] == 1) {
if (empty($params['formSubmit']['fields'][$formField['id']])) {
$hasError = true;
$formError = array('field_id' => $formField['id'], 'errorMsg' => $formField['name'] . ' is required.');
$formErrors[] = $formError;
}
}
}
}
if ($hasError) {
// return to page with error message
if (!empty($params['returnUrlRequest']) && $params['returnUrlRequest'] != 'Form/submit') {
$objDispatcher = new Dispatcher();
$objFriendlyUrl = new FriendlyurlModel();
$objFriendlyUrl->parseRequest($params['returnUrlRequest']);
$controller = $objFriendlyUrl->requestController;
$action = $objFriendlyUrl->requestAction;
$params = array_merge($params, $objFriendlyUrl->requestParams);
$params['_urlrequest'] = $params['returnUrlRequest'];
$params['formErrors'] = $formErrors;
$objDispatcher->setDirectory('frontend');
$objDispatcher->setController($controller);
$objDispatcher->setAction($action);
$objDispatcher->setParams($params);
$objDispatcher->dispatch();
exit;
} else {
die('Please go back and retry submitting the form. Errors: ' . print_r($formErrors));
}
}
// save to database
$submission_id = $this->saveToDb($params);
if ($submission_id) {
$params['submission_id'] = $submission_id;
}
// email notification
$objEmail->sendForm($params);
// return to page with thanks message
if (!empty($params['returnUrlRequest'])) {
header("Location: http://" . URL . '/' . $params['returnUrlRequest'] . '?formSubmitted=true');
} else {
header("Location: http://" . URL . '/');
}
}
}
}