public function read()
 {
     try {
         // 验证参数的合法性
         $aid = I('get.id');
         $options = array();
         $options['download'] = I('get.download');
         if (!$aid || !is_numeric($aid)) {
             throw new \Exception(L('_ERR_ATID_'));
         }
         $attService = D('Attachment', 'Service');
         if (!$attService->read($aid, $options)) {
             return false;
         }
         $resp = \Component\Common\Response::get_instance();
         return $resp->stop();
     } catch (\Exception $e) {
         $errInfo = $e->getMessage();
         return save_app_log($errInfo, 'component');
         // return get_api_result ('component', array (), $errInfo);
     }
 }
 public function edit()
 {
     $id = I('get.id');
     $this->contentTitle = '编辑文章';
     try {
         // 获取要编辑的数据
         $data = $this->objServ->getEditRow($id);
         $data['id'] = $id;
         $this->assign('data', $data);
         // 传递附件id
         if ($data['face_atid']) {
             $this->assign('attids', $data['face_atid']);
         }
         $actUrl = U('Home/Admin/Index/dosubmit');
         $this->assign('act_url', $actUrl);
         $this->_assignUeditor(htmlspecialchars_decode($data['content']));
         $this->__assignCate();
     } catch (\Exception $e) {
         $this->error($e->getMessage());
         return save_app_log($e->getMessage(), $this->identifier);
     }
     $this->loadSystemView();
 }
 protected function _assignUeditor($defaultContent = '', $contentKey = 'content', $options = array(), $toolBars = '_mobile', $innerHight = 300)
 {
     $ueditor = \Component\Common\Ueditor::get_instance($options);
     // $contentKey = 'content';
     $ueditor->ueditor_config = array('toolbars' => $toolBars, 'textarea' => $contentKey, 'initialFrameHeight' => $innerHight, 'initialContent' => $defaultContent, 'elementPathEnabled' => false);
     if (!$ueditor->create_editor('content')) {
         save_app_log($ueditor->ueditor_error, $this->identifier);
     }
     $ueditor_html = $ueditor->ueditor_html;
     $this->assign('ueditor', $ueditor_html);
     return true;
 }
Beispiel #4
0
/**
 * 设置错误信息
 * 
 * @param $app_name string
 * @param $str string
 * 
 * @return bool|array
 * */
function set_error_info($app_name = '', $str)
{
    if (!$str) {
        return false;
    }
    $errArr = explode(':', $str);
    if (!$errArr) {
        return false;
    }
    $rs['errcode'] = -9;
    $rs['errmsg'] = $errArr[0];
    if (is_numeric($errArr[0])) {
        $rs['errcode'] = $errArr[0];
    }
    if (isset($errArr[1])) {
        $rs['errmsg'] = $errArr[1];
    }
    save_app_log($str, $app_name, 'NOTICE');
    return $rs;
}