本文整理汇总了PHP中XString::cntrim方法的典型用法代码示例。如果您正苦于以下问题:PHP XString::cntrim方法的具体用法?PHP XString::cntrim怎么用?PHP XString::cntrim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XString
的用法示例。
在下文中一共展示了XString::cntrim方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postTopic
public function postTopic($request, $response)
{
$groupIds = $request->groupIds;
if(!$groupIds)
{
$response->message = '没有选择话题所在的组!';
MsgHtml::msg($response->message, 'http://'.URL_PREFIX.'passport.haodf.com/mypatient/post', array('delay' => 6, 'button' => 'back'));
return false;
}
$title = $request->title;
$content = preg_replace("/<\/?a[^>]*>/i", "", $request->content);
if(XString::cntrim($title) == '' || XString::cntrim($content) == '')
{
$response->message = '话题标题和内容都不能为空!';
MsgHtml::msg($response->message, 'http://'.URL_PREFIX.'passport.haodf.com/mypatient/post', array('delay' => 6, 'button' => 'back'));
return false;
}
$groups = DAL::get()->find('regroup', $groupIds);
foreach($groups as $group)
{
if($group->reboard->isNull() == false)
{
$member = ForumClient::getInstance()->getMemberByUserIdAndGroupId($this->user->id, $group->id);
if($member->isNull() == false && $member->isForbiddened())
{
$response->message = '您的发言没有成功,可能是已被禁止发言!服务电话:'.HdfPhoneNumber::PHONE_FENZHEN;
MsgHtml::msg($response->message, 'http://'.URL_PREFIX.'passport.haodf.com/mypatient/index', array('delay' => 6, 'button' => 'back'));
return false;
}
ResidentEvilClient::getInstance()->createTopic($group->space, $group->reboard, $this->user, $title, $content);
}
}
$response->message = '话题发表成功!';
MsgHtml::msg($response->message, 'http://'.URL_PREFIX.'passport.haodf.com/mypatient/index', array('delay' => 6, 'button' => 'back'));
}
示例2: buildData
private function buildData($datas)
{/*{{{*/
$res = array();
if (false == $datas)
{
return $res;
}
foreach($datas as $hospital)
{
$intro = (empty($hospital->conclusion))?$hospital->intro:$hospital->conclusion;
$intro = XString::truncate(strip_tags($intro),500);
$hospitalFacultyInfo = $this->getHospitalFacultyForm($hospital->id);
$res[$hospital->id]['item'] = array(
'key' => $hospital->name,
'title' => $hospital->name,
'synonym' => $hospital->synonyms,
'url' => $hospital->getUrl(),
'grade' => $hospital->getGradeStr(),
'address' => $hospital->address,
'phone' => $hospital->phone,
'way' => XString::cntrim(strip_tags($hospital->addressInfo)),
'intro' => XString::cntrim(strip_tags($intro)),
'zixunInfo' => ($hospital->spaceCount)?"咨询".$hospital->spaceCount."位大夫":"",
'zixunInfoUrl' => ($hospital->spaceCount)?$hospital->getDoctorUrl():"",
'hospitalInfo' => "科室".$hospital->facultyCount."个, 大夫".$hospital->doctorCount."人",
'hospitalFacultyCnt' => $hospital->facultyCount,
'hospitalInfoUrl' => $hospital->getScheduleUrl(),
'hospitalFacultyInfo' => $hospitalFacultyInfo,
);
unset($hospital);
}
return $res;
}/*}}}*/
示例3: newCaseWithMultiPatients
//.........这里部分代码省略.........
{
$this->setErrorCode(316);
return 0;
}
}
$askSpace = new NullEntity();
//兼容android客户端,doctorId传null字符串的bug
if ($doctorId == 'null')
{
$doctorId = 0;
$appVer = $request->v;
}
if($doctorId)
{
$doctor = DAL::get()->find('doctor', $doctorId);
if($doctor->isNull())
{
$this->setErrorCode(132);
return 0;
}
$askSpace = $doctor->space;
if($askSpace->isNull())
{
$this->setErrorCode(144);
return 0;
}
try
{
SpaceClient::getInstance()->ensureAllowAskRule($user, $askSpace);
}
catch(Exception $ex)
{
$this->setErrorCode(320);
return 0;
}
}
$options = array();
$options['title'] = $title;
$options['disease'] = $tag;
$options['content'] = $content1;
if ($content2)
{
$options['content'] .= "\n\n曾经治疗情况和效果:\n\n".$content2;
}
$options['attachmentIds'] = $attachmentIds;
$options['facultyId'] = 0;
//就诊过的医院
$options['prehospital'] = '';
if($askSpace->isNull() == false)
{
$options['facultyId'] = $askSpace->host->hospitalfaculty->faculty->id;
}
$options['deviceType'] = $deviceType;
$options['title'] = htmlspecialchars_decode($options['title'], ENT_QUOTES);
$options['disease'] = htmlspecialchars_decode($options['disease'], ENT_QUOTES);
if(mb_strlen(XString::cntrim($options['title'])) < 5 || mb_strlen(XString::cntrim($options['title'])) > 10)
{
$this->setErrorCode(167);
return 0;
}
if(mb_strlen(XString::cntrim($options['disease'])) < 1 || mb_strlen(XString::cntrim($options['disease'])) > 20)
{
$this->setErrorCode(304);
return 0;
}
if ($user->isNull() || $patient->isNull())
{
error_log(print_r(debug_backtrace(), true), 3, '/tmp/ask_user_null.log');
$this->setErrorCode(206);
return 0;
}
$noticeAfterCase = "您的咨询将由网站医学助理按病情转交合适的医生回复。70%的咨询可在3天内得到医生回复,未回复的咨询将在7天后过期。如病情紧急建议直接去医院就诊。";
/*加点患者提问成功扣分*/
$res = ScoreClient::getInstance()->ask($user->id);
$src = $deviceType;
$hospital = $options['prehospital'];
$disease = $options['disease'];
$title = $options['title'];
$content = $options['content'];
$hopeHelp = $content3;
if($options['attachmentIds'])
{
$attachmentIds = explode("," , $options['attachmentIds']);
}
else
{
$attachmentIds = array();
}
$thread = IntentionClient::getInstance()->add4ThreadFromWap($patient, $askSpace, $src, $hospital, $content, $attachmentIds, $disease, $title, '', $hopeHelp);
//todo::伪装展示
$this->content = array('threadId' => $thread->id, 'caseType' => 'thread', 'sign' => 0, 'noticeAfterCase' => $noticeAfterCase);
if ($thread->isNull())
{
$this->setErrorCode(169);
return 0;
}
}/*}}}*/
示例4: postTopic
/** 发表话题**/
public function postTopic($request, $response)
{
/*{{{*/
$groupIds = array($request->defaultid);
if ($request->groupIds) {
$groupIds = array_diff(array_merge($request->groupIds, $groupIds), array(null));
}
DBC::requireFalse(empty($groupIds), '小组不能为空');
$title = $request->title;
$content = preg_replace("/<\\/?a[^>]*>/i", "", $request->getUnSafeData('content'));
DBC::requireFalse(XString::cntrim($title) == '' || XString::cntrim($content) == '', '话题标题和内容都不能为空');
$res = ResidentEvilClient::getInstance()->createTopics2Groups($this->space->id, $groupIds, $this->user->id, $title, $content);
if (false == $res && $this->user->id != $this->space->id) {
$this->message('您的发言没有成功,可能是已被禁止发言!服务电话:' . HdfPhoneNumber::PHONE_FENZHEN, $response, array('url' => $this->space->getPatientIndexUrl()));
return;
}
$this->message('话题发表成功!', $response, array('url' => $this->space->getPatientIndexUrl()));
}
示例5: updatePost
/** 编辑文章提交 */
public function updatePost($request, $response)
{
/*{{{*/
DBC::requireFalse(XString::cntrim($request->article_title) == '' || XString::cntrim($request->getUnSafeData('article_content')) == '', '文章标题和内容都不能为空');
$categoryId = intval($request->getRequest('category_id', 0));
DBC::requireFalse($categoryId == 0, '请选择文章分类');
$category = DAL::get()->find('ArticleCategory', $categoryId);
$article = DAL::get()->find('article', $request->article_id);
DBC::requireFalse($article->isNull(), '编辑文章出错,请重试');
$articleContent = htmlspecialchars($request->getUnSafeData('article_content'), ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
$articleContent = preg_replace("'&lt;script&gt;.*?&lt;/script&gt;'", "", $articleContent);
$data = array('topLevel' => $request->top_level, 'docAttachmentId' => $request->getRequest('docAttachmentId', 0), 'title' => $request->article_title, 'content' => $articleContent, 'tags' => $request->article_tags, 'source' => $request->article_source, 'articleCategory' => $category, 'status' => Article::STATUS_INIT);
$data['tags'] = str_replace("选择合适的关键词使文章更容易被搜索到(请用空格或逗号分隔)", '', $data['tags']);
ArticleClient::getInstance()->modifyArticle($article->id, $data);
$listUrl = $article->isClassicsCase() ? $response->router->urlfor('article/classicsCaseList') : $response->router->urlfor('article/index');
$this->message('文章修改成功', $response, array('text' => '查看修改的文章', 'url' => $response->router->urlfor('article/detail', array('article_id' => $article->id)), 'reserveText' => '返回文章列表', 'reserveUrl' => $listUrl, 'articleId' => $article->id));
}
示例6: getLengthOfGBKString
public static function getLengthOfGBKString($str)
{/*{{{*/
$str = mb_convert_encoding($str, 'gbk', 'auto');
return mb_strlen(XString::cntrim($str));
}/*}}}*/
示例7: newComment
public function newComment($os, $deviceId, $userId, $doctorId, $tag, $effect, $attitude, $comment, $type, $name, $phone, $treatment, $deviceType = 'Android')
{/*{{{*/
$doctor = DAL::get()->find('doctor', $doctorId);
//加上判断(如果传了电话信息,并且电话信息不为空,增加电话信息判断)
if(isset($phone) && trim($phone) != '')
{
if(false == XString::isMobile($phone))
{
$this->setErrorCode(110);
return 0;
}
}
if($doctor->isNull())
{
$this->setErrorCode(132);
return 0;
}
if($doctor->inPunishTime())
{
$this->setErrorCode(187);
return 0;
}
if(false == $deviceId)
{
$deviceId = XIpLocation::getIp();
}
if(false == $os)
{
$this->setErrorCode(191);
return 0;
}
if(mb_strlen(XString::cntrim($tag)) <= 0 || mb_strlen(XString::cntrim($tag)) > 50)
{
$this->setErrorCode(183);
return 0;
}
if(DoctorComment::COMMENT_TYPE_UNKNOWN != $type && (mb_strlen(XString::cntrim($name)) <= 0 || mb_strlen(XString::cntrim($name)) > 10))
{
$this->setErrorCode(190);
return 0;
}
if(false == in_array($type, self::$typeList))
{
$this->setErrorCode(188);
return 0;
}
if(DoctorComment::COMMENT_TYPE_PROCESS == $type)
{
if(false == in_array($effect, self::$skillList))
{
$this->setErrorCode(184);
return 0;
}
if(false == in_array($attitude, self::$attitudeList))
{
$this->setErrorCode(185);
return 0;
}
if(mb_strlen(XString::cntrim($comment)) < 50 || mb_strlen(XString::cntrim($comment)) > 5000)
{
$this->setErrorCode(186);
return 0;
}
$comment = "<span class=gray>看病过程:</span>".$comment;
}
else if(DoctorComment::COMMENT_TYPE_UNKNOWN == $type)
{
if($doctor->trustIndex == 100 && ($effect == DoctorComment::VOTE_BUMANYI || $attitude == DoctorComment::VOTE_BUMANYI))
{
$this->setErrorCode('193');
return 0;
}
if(false == in_array($effect, self::$skillList))
{
$this->setErrorCode(184);
return 0;
}
if(false == in_array($attitude, self::$attitudeList))
{
$this->setErrorCode(185);
return 0;
}
}
else if(DoctorComment::COMMENT_TYPE_THANK_LETTER == $type)
{
if(false == in_array($effect, self::$thankSkillList))
{
$this->setErrorCode(184);
return 0;
}
if(false == in_array($attitude, self::$thankAttitudeList))
{
$this->setErrorCode(185);
return 0;
}
if(mb_strlen(XString::cntrim($comment)) < 50 || mb_strlen(XString::cntrim($comment)) > 5000)
{
$this->setErrorCode(186);
return 0;
}
//.........这里部分代码省略.........
示例8: updatePost
/** 编辑文章提交(D,HF) */
public function updatePost($request, $response)
{/*{{{*/
if (XString::cntrim($request->article_title) == '' ||
XString::cntrim($request->getUnSafeData('article_content')) == '') {
$this->message('文章标题和内容都不能为空', $response);
return false;
}
$categoryId = intval($request->getRequest('category_id', 0));
$article = DAL::get()->find('article', $request->article_id);
if($article->isNull()){
$this->message('编辑文章出错,请重试', $response);
return false;
}
if ($categoryId == 0) {
$this->message('请选择文章分类', $response);
return false;
}
$category = DAL::get()->find('ArticleCategory', $categoryId);
$data = array(
'topLevel' => $request->top_level,
'docAttachmentId' => $request->getRequest('docAttachmentId', 0),
'title' => $request->article_title,
'content' => $request->getUnSafeData('article_content'),
'tags' => $request->article_tags,
'source' => $request->article_source,
'articleCategory'=>$category,
'status' => Article::STATUS_INIT
);
ArticleClient::getInstance()->modifyArticle($article->id, $data);
$listUrl = ($article->isClassicsCase() ? $response->router->urlfor('article/classicsCaseList') : $response->router->urlfor('article/index'));
$this->message('文章修改成功', $response, array(
'buttons' => array(
array('text' => '查看修改的文章', 'url' => $response->router->urlfor('article/detail', array('article_id' => $article->id))),
array('text' => '返回文章列表', 'url' => $listUrl),
),
));
}/*}}}*/
示例9: newCaseWithPatient
/**
* @brief 提交咨询意向
* @author cs
* @exampleUrl dev.mobile-api.haodf.com/patientapi/intention_newCaseWithPatient?userId=581662815&doctorId=238324&title=xxx&tag=xxx&content1=xxx&content2=xxx&content3=xxx&attachmentIds=&deviceType=android&patientId=1163360744
*
* @Param $userId 用户id
* @Param $doctorId 咨询医生id
* @Param $title 标题
* @Param $tag 疾病
* @Param $content1 内容1
* @Param $content2 内容2
* @Param $content3 内容3
* @Param $attachmentIds 附件ids(逗号分割)
* @Param $deviceType 设备类型
* @Param $patientId 患者id
*
* @Returns
*/
public function newCaseWithPatient($userId, $doctorId, $title, $tag, $content1, $content2, $content3, $attachmentIds, $deviceType, $patientId)
{/*{{{*/
if($this->isThreadServiceSuspendTime())
{
$this->setErrorCode(901);
return 0;
}
$user = DAL::get()->find('user', $userId);
if ($userId <=0 || $user->isNull())
{
$this->setErrorCode(107);
return 0;
}
$patient = DAL::get()->find('patient', $patientId);
if ($patient->isNull())
{
$this->setErrorCode(316);
return 0;
}
if(false == isset($user->patients[$patient->id]))
{
$this->setErrorCode(316);
return 0;
}
$askSpace = new NullEntity();
if ($doctorId == 'null')
{
$doctorId = 0;
}
if($doctorId)
{
$doctor = DAL::get()->find('doctor', $doctorId);
if($doctor->isNull())
{
$this->setErrorCode(132);
return 0;
}
$askSpace = $doctor->space;
if($askSpace->isNull())
{
$this->setErrorCode(144);
return 0;
}
try
{
SpaceClient::getInstance()->ensureAllowAskRule($user, $askSpace);
}
catch(Exception $ex)
{
$this->setErrorCode(320);
return 0;
}
}
$title = htmlspecialchars_decode($title, ENT_QUOTES);
$tag = htmlspecialchars_decode($tag, ENT_QUOTES);
if(mb_strlen(XString::cntrim($title)) < 5 || mb_strlen(XString::cntrim($title)) > 10)
{
$this->setErrorCode(167);
return 0;
}
if(mb_strlen(XString::cntrim($tag)) < 1 || mb_strlen(XString::cntrim($tag)) > 20)
{
$this->setErrorCode(304);
return 0;
}
$content = $content1;
if ($content2)
{
$content .= "\n\n曾经治疗情况和效果:\n\n".$content2;
}
$attachmentArrs = $attachmentIds ? explode("," , $attachmentIds) : array();
$deviceType = ($deviceType == 'Android') ? Intention::SRC_ANDROID : Intention::SRC_IOS;
$intention = IntentionClient::getInstance()->add4ThreadFromWap($patient, $askSpace, $deviceType, '', $content, $attachmentArrs, $tag, $title, '', $content3);
if ($intention->isNull())
{
$this->setErrorCode(169);
return 0;
}
//.........这里部分代码省略.........