当前位置: 首页>>代码示例>>PHP>>正文


PHP LogUtil::getErrorType方法代码示例

本文整理汇总了PHP中LogUtil::getErrorType方法的典型用法代码示例。如果您正苦于以下问题:PHP LogUtil::getErrorType方法的具体用法?PHP LogUtil::getErrorType怎么用?PHP LogUtil::getErrorType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LogUtil的用法示例。


在下文中一共展示了LogUtil::getErrorType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: main

 /**
  * Display an error
  * This function displays a generic error form
  * The template used is based on the error type passed
  *
  * @param string $args['type'] error type '404' or 'module'
  * @param string $args['message'] custom error message
  *
  * @return string HTML string
  */
 public function main($args)
 {
     $type = FormUtil::getPassedValue('errtype', isset($args['type']) ? $args['type'] : LogUtil::getErrorType(), 'GET');
     $exception = isset($args['exception']) ? $args['exception'] : null;
     $message = isset($args['message']) ? $args['message'] : '';
     // perform any error specific tasks
     $protocol = System::serverGetVar('SERVER_PROTOCOL');
     switch ($type) {
         case 301:
             header("{$protocol} 301 Moved Permanently");
             break;
         case 403:
             header("{$protocol} 403 Access Denied");
             break;
         case 404:
             header("{$protocol} 404 Not Found");
             break;
         case 500:
             header("{$protocol} 500 Internal Server Error");
         default:
     }
     // load the stylesheet
     PageUtil::addVar('stylesheet', 'system/Errors/style/style.css');
     $this->view->setCaching(Zikula_View::CACHE_DISABLED);
     // assign the document info
     $this->view->assign('reportlevel', System::getVar('reportlevel'))->assign('currenturi', System::getCurrentUri())->assign('localreferer', System::localReferer())->assign('sitename', System::getVar('sitename'))->assign('reportlevel', System::getVar('reportlevel'))->assign('funtext', System::getVar('funtext'));
     $messages = LogUtil::getErrorMessages();
     // show the detailed error message for admins only
     if (System::isDevelopmentMode() || SecurityUtil::checkPermission('::', '::', ACCESS_ADMIN)) {
         $message ? $messages[] = $message : null;
     }
     $trace = array();
     if (System::isDevelopmentMode() && $exception instanceof Exception) {
         $line = $exception->getLine();
         $file = $exception->getFile();
         $trace = array(0 => '#0 ' . $this->__f('Exception thrown in %1$s, line %2$s.', array($file, $line)));
         $trace += explode("\n", $exception->getTraceAsString());
     }
     // assign the list of registered errors
     // and the trace (if development mode is enabled)
     $this->view->assign('messages', $messages)->assign('trace', $trace);
     // return the template output
     if ($this->view->template_exists($template = "errors_user_{$type}.tpl")) {
         return $this->view->fetch($template);
     } else {
         return $this->view->fetch('errors_user_main.tpl');
     }
 }
开发者ID:,项目名称:,代码行数:58,代码来源:

示例2: error

    /**
     * Immediately stops execution and returns an error message.
     *
     * @param string  $message      Error text.
     * @param array   $other        Optional data to attach to the response.
     * @param boolean $createauthid Flag to create or not a new authkey.
     * @param boolean $displayalert Flag to display the error as an alert or not.
     * @param string  $code         Optional error code, default '400 Bad data'.
     *
     * @throws Zikula_Exception_Forbidden If there are errors in when legacymode is disabled.
     *
     * @deprecated since 1.3.0
     *
     * @return void
     */
    public static function error($message = '', $other = array(), $createauthid = false, $displayalert = true, $code = '400 Bad data')
    {
        if (!System::isLegacyMode()) {
            if (LogUtil::hasErrors()) {
                if (!$message) {
                    throw new Zikula_Exception_Forbidden();
                }
            }

            throw new Zikula_Exception_Forbidden($message);
        }
        // Below for reference - to be deleted.


        if (empty($message)) {
            $type = LogUtil::getErrorType();
            $code = $type ? $type : $code;
            $message = LogUtil::getErrorMessagesText("\n");
        }

        if (!empty($message)) {
            $data = array('errormessage' => $message);
            if (is_array($other)) {
                $data = array_merge($data, $other);
            }
        }

        $data['displayalert'] = ($displayalert === true ? '1' : '0');

        self::output($data, $createauthid, false, true, $code);
    }
开发者ID:,项目名称:,代码行数:46,代码来源:


注:本文中的LogUtil::getErrorType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。