Exemple #1
0
 /**
  * CURL方式提交数据
  * @param string $pathinfo
  * @param array $params
  * @param string $method
  * @return mixed
  */
 public function talk($pathinfo, array $params = array(), $method = 'GET')
 {
     $ral = $this->getRal();
     $ral->setLogId(Log::getId());
     $maxRetry = $this->getRetry();
     for ($retry = 0; $retry < $maxRetry; $retry++) {
         try {
             $result = $ral->talk($pathinfo);
             $message = 'Ral Exec Curl Successfully!';
             $code = 0;
         } catch (ErrorException $e) {
             $message = 'Ral Exec Curl Failed! ' . $e->getMessage();
             $code = $e->getCode();
             $result = false;
         }
         $event = array('msg' => $message, 'retry' => $retry, 'pathinfo' => $pathinfo, 'params' => serialize($params), 'method' => $method, 'config' => serialize($this->getConfig()));
         if ($result !== false) {
             Log::notice($event, __METHOD__);
             return $result;
         }
         Log::warning($event, $code, __METHOD__);
     }
     return $result;
 }
Exemple #2
0
 /**
  * 将常用数据设置到模板变量中
  * @return void
  */
 public function assignSystem()
 {
     $viw = Mvc::getView();
     $viw->assign('app', APP_NAME);
     $viw->assign('module', Mvc::$module);
     $viw->assign('controller', Mvc::$controller);
     $viw->assign('action', Mvc::$action);
     $viw->assign('sidebar', Mvc::$module . '/' . Mvc::$controller . '_sidebar');
     $viw->assign('log_id', Log::getId());
     $viw->assign('language', Ap::getLanguageType());
     if (($wfBackTrace = Registry::get('warning_backtrace')) !== null) {
         $viw->assign('warning_backtrace', $wfBackTrace);
     }
 }
Exemple #3
0
 /**
  * 规范化输出数据的格式
  * 默认添加的输出内容:log_id (integer)
  *
  * 一.参数是字符串:
  * <pre>
  * $data = 'trotri';
  * 返回值:
  * $ret = array (
  *     'err_no' => 0,
  *     'err_msg' => '',
  *     'data' => 'trotri',
  *     'log_id' => 2000010
  * );
  * </pre>
  *
  * 二.参数是数组,但是没有指定err_no和err_msg:
  * <pre>
  * $data = array (
  *     'user_id' => 1,
  *     'user_name' => 'trotri'
  * );
  * 或
  * $data = array (
  *     'extra' => '', // 这个值将被丢弃
  *     'data' => array (
  *         'user_id' => 1,
  *         'user_name' => 'trotri'
  *     )
  * );
  * 返回值:
  * $ret = array (
  *     'err_no' => 0,
  *     'err_msg' => '',
  *     'data' => array (
  *         'user_id' => 1,
  *         'user_name' => 'trotri',
  *     ),
  *     'log_id' => 2000010
  * );
  * </pre>
  *
  * 三.参数是数组,并且已经指定err_no和err_msg:
  * <pre>
  * $data = array (
  *     'err_no' => 1001,
  *     'err_msg' => 'Login Failed',
  *     'user_id' => 1,
  *     'user_name' => 'trotri'
  * );
  * 或
  * $data = array (
  *     'err_no' => 1001,
  *     'err_msg' => 'Login Failed',
  *     'extra' => '', // 这个值将被丢弃
  *     'data' => array (
  *         'user_id' => 1,
  *         'user_name' => 'trotri'
  *     )
  * );
  * 返回值:
  * $ret = array (
  *     'err_no' => 1001,
  *     'err_msg' => 'Login Failed',
  *     'data' => array (
  *         'user_id' => 1,
  *         'user_name' => 'trotri'
  *     ),
  *     'log_id' => 2000010
  * );
  * </pre>
  * @param mixed $data
  * @return array
  */
 public function getViewData($data)
 {
     $errNo = ErrorNo::SUCCESS_NUM;
     $errMsg = '';
     if (is_array($data)) {
         if (isset($data['err_no'])) {
             $errNo = (int) $data['err_no'];
             unset($data['err_no']);
         }
         if (isset($data['err_msg'])) {
             $errMsg = $data['err_msg'];
             unset($data['err_msg']);
         }
         if (isset($data['data'])) {
             $data = $data['data'];
         }
     }
     $ret = array('err_no' => $errNo, 'err_msg' => $errMsg, 'data' => $data, 'log_id' => Log::getId());
     return $ret;
 }
Exemple #4
0
 /**
  * 将常用数据设置到模板变量中
  * @return void
  */
 public function assignSystem()
 {
     $viw = Mvc::getView();
     $viw->assign('app', APP_NAME);
     $viw->assign('module', Mvc::$module);
     $viw->assign('controller', Mvc::$controller);
     $viw->assign('action', Mvc::$action);
     $viw->assign('sidebar', Mvc::$module . '/' . Mvc::$action . '_sidebar');
     $viw->assign('log_id', Log::getId());
     $viw->assign('language', Ap::getLanguageType());
     $viw->assign('urlHelper', UrlHelper::getInstance());
     $viw->assign('site_name', Options::getSiteName());
     if (!isset($viw->meta_title)) {
         $viw->assign('meta_title', Options::getMetaTitle());
     }
     if (!isset($viw->meta_keywords)) {
         $viw->assign('meta_keywords', Options::getMetaKeywords());
     }
     if (!isset($viw->meta_description)) {
         $viw->assign('meta_description', Options::getMetaDescription());
     }
     $viw->assign('powerby', Options::getPowerby());
     $viw->assign('stat_code', Options::getStatCode());
     if (($wfBackTrace = Registry::get('warning_backtrace')) !== null) {
         $viw->assign('warning_backtrace', $wfBackTrace);
     }
 }