當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Dispatcher::setAction方法代碼示例

本文整理匯總了PHP中Dispatcher::setAction方法的典型用法代碼示例。如果您正苦於以下問題:PHP Dispatcher::setAction方法的具體用法?PHP Dispatcher::setAction怎麽用?PHP Dispatcher::setAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Dispatcher的用法示例。


在下文中一共展示了Dispatcher::setAction方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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
開發者ID:ngardner,項目名稱:BentoCMS,代碼行數:31,代碼來源:index.php

示例2: ucfirst

        $action = ucfirst(!empty($params['_action']) ? $params['_action'] : 'Index');
    }
}
// permission check
$objPermissions = Permissions::getInstance();
$hasPermission = $objPermissions->actionAllowed($controller, $action, $objAuthentication->user_id);
if (!$hasPermission) {
    $controller = 'Error';
    $action = 'Permission';
}
// start up
try {
    $objSettings->loadSettings();
    $objDispatcher->setDirectory('backend');
    $objDispatcher->setController($controller);
    $objDispatcher->setAction($action);
    $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());
    $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
開發者ID:ngardner,項目名稱:BentoCMS,代碼行數:31,代碼來源:bento.php

示例3: 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();
     }
 }
開發者ID:ngardner,項目名稱:BentoCMS,代碼行數:40,代碼來源:Community.php

示例4: 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 . '/');
             }
         }
     }
 }
開發者ID:ngardner,項目名稱:BentoCMS,代碼行數:61,代碼來源:Form.php


注:本文中的Dispatcher::setAction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。