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


PHP MVCUtils::initializeModel方法代碼示例

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


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

示例1: __construct


//.........這裏部分代碼省略.........
         }
         //Load the module names
         $this->viewerModuleName = $db->getOne("SELECT modulename FROM templates WHERE templateid = ?", array($this->templateID));
         if (isset($this->fieldData['moduleName']) && $this->fieldData['moduleName'] != '') {
             $this->modelModuleName = $this->fieldData['moduleName'];
         } else {
             $this->modelModuleName = 'MVC';
         }
         ### Check that the user has permission to use the submitted form
         // get the realmid of the submitted form
         $sql = 'SELECT realmid FROM forms WHERE formname = ? AND modulename = ?';
         $realmid = $db->getOne($sql, array($this->formName, $this->modelModuleName));
         $auth = Auth::getInstance();
         // If the realm id could not found then allow access
         // (this will cause 'Model' to be used - so no processing occurs)
         if (!$realmid) {
             //Access is allowed
             $modelAccess = true;
         } else {
             //Check if the user has access to the realm associated with the form
             if (!$auth->isLoggedIn()) {
                 $auth->attemptLogin($cfg['Auth']['anonuser']);
             } else {
                 $auth->attemptLogin();
             }
             $path = AuthUtil::getRealmPath($realmid);
             if (!AuthUtil::getDetailedUserrealmAccess($path, $auth->getUserID())) {
                 //If the user does not have permission, show an error
                 $modelAccess = false;
                 $errors = array('permission' => 'You do not have permission to use the submited form');
             } else {
                 //Set access flag to false
                 $modelAccess = true;
             }
         }
         //If access to the requested form is allowed
         if ($modelAccess) {
             //If a form was submitted
             if (isset($this->formName) && !is_null($this->formName)) {
                 //Then validate the form data
                 //Store any errors in $errors
                 $errors = $this->validate();
             }
         }
         //If the user has access to the requested template
         if ($this->checkAuth()) {
             if ($modelAccess) {
                 $newModel = MVCUtils::initializeModel(array($this->templateID), $this->formName, $this->modelModuleName, $this->viewerModuleName, $this->fieldData, $errors);
             } else {
                 $this->templateID = MVCUtils::getPermErrorTemplateID();
                 $newModel = MVCUtils::initializeModel(array($this->templateID), null, 'MVC', 'Auth', $this->fieldData, $errors);
             }
             //If there are errors then these will be passed in the $errors array,
             //if there are no errors then $errors will simple be an empty array
             //If no form name was passed, $this->formName will be null
         } else {
             //The user is not authorised to access this area
             $auth = Auth::getInstance();
             //Set the template ID to that of the permission error template
             $this->templateID = MVCUtils::getPermErrorTemplateID();
             //Get the reason for failure and specify an error message
             $reason = $auth->getFailureReason();
             if (count($errors) == 0) {
                 if ($reason == 2) {
                     $errors = array('permission' => 'Your session has been inactive for too long');
                 } elseif ($reason != 0) {
                     $errors = array('permission' => 'Unfortunately, an error has occurred. Please attempt logging in again.');
                 } else {
                     $errors = array('permission' => 'You do not have permission to view this page');
                 }
             }
             //Initialise the viewer for the permission error template
             if ($auth->getUserID() == $cfg['Auth']['anonuserID'] && $cfg['Auth']['anonuserredirect'] == 'y') {
                 $permErrorTID = $cfg['Auth']['anonuserRedirectTemplateID'];
                 $newModel = MVCUtils::initializeViewer(array($permErrorTID), null, 'tkfecommon', null, $errors);
             } else {
                 $permErrorTID = MVCUtils::getTemplateID($cfg['Auth']['permissionErrorTemplate']);
                 $newModel = MVCUtils::initializeViewer(array($permErrorTID), null, 'tkfecommon', null, $errors);
             }
         }
         //Print out the page
         echo $newModel->getCode();
     } catch (Exception $e) {
         //If a problem occured then create an error page
         $ev = new ExceptionViewer($e);
         $ev->printTemplate();
         exit;
     }
     //Show the execution time if set in config file
     if ($cfg['smarty']['showExecTime']) {
         list($usec, $sec) = explode(" ", microtime());
         $endTime = (double) $usec + (double) $sec;
         $totalTime = round($endTime - $startTime, 3);
         $log = Database::getQueryLog();
         echo "Total time to parse page: {$totalTime} seconds<br />\n";
         echo "Total number of queries: " . Database::getTotalQueries();
         echo "<br />Log: ";
         print_r($log);
     }
 }
開發者ID:radiowarwick,項目名稱:digiplay_legacy,代碼行數:101,代碼來源:Page.class.php


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