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


PHP ArrayToolkit::filter方法代码示例

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


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

示例1: saveNote

 /**
  *类似这样的,提交数据保存到数据的流程是:
  *
  *  1. 检查参数是否正确,不正确就抛出异常
  *  2. 过滤数据
  *  3. 插入到数据库
  *  4. 更新其他相关的缓存字段
  */
 public function saveNote(array $note)
 {
     if (!ArrayToolkit::requireds($note, array('lessonId', 'courseId', 'content'))) {
         throw $this->createServiceException('缺少必要的字段,保存笔记失败');
     }
     list($course, $member) = $this->getCourseService()->tryTakeCourse($note['courseId']);
     $user = $this->getCurrentUser();
     if (!$this->getCourseService()->getCourseLesson($note['courseId'], $note['lessonId'])) {
         throw $this->createServiceException('课时不存在,保存笔记失败');
     }
     $note = ArrayToolkit::filter($note, array('courseId' => 0, 'lessonId' => 0, 'content' => '', 'status' => 0));
     $note['content'] = $this->purifyHtml($note['content']) ?: '';
     $note['length'] = $this->calculateContnentLength($note['content']);
     $existNote = $this->getUserLessonNote($user['id'], $note['lessonId']);
     if (!$existNote) {
         $note['userId'] = $user['id'];
         $note['createdTime'] = time();
         $note['updatedTime'] = time();
         $note = $this->getNoteDao()->addNote($note);
         $this->getDispatcher()->dispatch('course.note.create', new ServiceEvent($note));
     } else {
         $note['updatedTime'] = time();
         $note = $this->getNoteDao()->updateNote($existNote['id'], $note);
         $this->getDispatcher()->dispatch('course.note.update', new ServiceEvent($note, array('preStatus' => $existNote['status'])));
     }
     $this->getCourseService()->setMemberNoteNumber($note['courseId'], $note['userId'], $this->getNoteDao()->getNoteCountByUserIdAndCourseId($note['userId'], $note['courseId']));
     return $note;
 }
开发者ID:liugang19890719,项目名称:www.zesow.com,代码行数:36,代码来源:NoteServiceImpl.php

示例2: indexAction

 public function indexAction(Request $request)
 {
     $fields = $request->query->all();
     $fields = ArrayToolkit::filter($fields, array('nextExcutedStartTime' => '', 'nextExcutedEndTime' => '', 'name' => '', 'cycle' => ''));
     $paginator = new Paginator($this->get('request'), $this->getJobService()->searchJobsCount($fields), 30);
     $jobs = $this->getJobService()->searchJobs($fields, 'nextExcutedTime', $paginator->getOffsetCount(), $paginator->getPerPageCount());
     return $this->render('TopxiaAdminBundle:System:jobs.html.twig', array('jobs' => $jobs, 'paginator' => $paginator));
 }
开发者ID:CaiZhongda,项目名称:EduSoho,代码行数:8,代码来源:JobController.php

示例3: _filterAttributeFields

 private function _filterAttributeFields($fields)
 {
     $fields = ArrayToolkit::filter($fields, array('name' => '', 'attrType' => 0, 'attrValues' => '', 'parentId' => 0));
     if (empty($fields['name'])) {
         throw $this->createServiceException("名称不能为空,保存属性失败");
     }
     return $fields;
 }
开发者ID:liugang19890719,项目名称:www.zesow.com,代码行数:8,代码来源:AttributeServiceImpl.php

示例4: _filterGiftFields

 private function _filterGiftFields($fields)
 {
     $fields = ArrayToolkit::filter($fields, array('giftName' => '', 'detail' => '', 'points' => 0));
     if (!empty($fields['detail'])) {
         $fields['detail'] = $this->purifyHtml($fields['detail'], true);
     }
     return $fields;
 }
开发者ID:liugang19890719,项目名称:www.zesow.com,代码行数:8,代码来源:GiftServiceImpl.php

示例5: updateField

 public function updateField($id, $fields)
 {
     $fields = ArrayToolkit::filter($fields, array("title" => "", "seq" => "", "enabled" => 0));
     if (isset($fields['title']) && empty($fields['title'])) {
         throw $this->createServiceException('字段名称不能为空!');
     }
     if (isset($fields['seq']) && empty($fields['seq'])) {
         throw $this->createServiceException('字段排序不能为空!');
     }
     if (isset($fields['seq']) && !intval($fields['seq'])) {
         throw $this->createServiceException('字段排序只能为数字!');
     }
     return $this->getUserFieldDao()->updateField($id, $fields);
 }
开发者ID:jonesgithub,项目名称:EduSoho,代码行数:14,代码来源:UserFieldServiceImpl.php

示例6: updateLesson

 public function updateLesson($courseId, $lessonId, $fields)
 {
     $argument = $fields;
     $course = $this->getCourse($courseId);
     if (empty($course)) {
         throw $this->createServiceException("课程(#{$courseId})不存在!");
     }
     $lesson = $this->getCourseLesson($courseId, $lessonId);
     if (empty($lesson)) {
         throw $this->createServiceException("课时(#{$lessonId})不存在!");
     }
     $fields = ArrayToolkit::filter($fields, array('title' => '', 'summary' => '', 'content' => '', 'media' => array(), 'mediaId' => 0, 'number' => 0, 'seq' => 0, 'chapterId' => 0, 'free' => 0, 'length' => 0, 'startTime' => 0, 'giveCredit' => 0, 'requireCredit' => 0, 'homeworkId' => 0, 'exerciseId' => 0, 'testMode' => 'normal', 'testStartTime' => 0, 'suggestHours' => '1.0', 'replayStatus' => 'ungenerated'));
     if (isset($fields['title'])) {
         $fields['title'] = $this->purifyHtml($fields['title']);
     }
     $fields['type'] = $lesson['type'];
     if ($fields['type'] == 'live' && isset($fields['startTime'])) {
         $fields['endTime'] = $fields['startTime'] + $fields['length'] * 60;
         $fields['suggestHours'] = $fields['length'] / 60;
     }
     if (array_key_exists('media', $fields)) {
         $this->fillLessonMediaFields($fields);
     }
     $updatedLesson = LessonSerialize::unserialize($this->getLessonDao()->updateLesson($lessonId, LessonSerialize::serialize($fields)));
     $this->updateCourseCounter($course['id'], array('giveCredit' => $this->getLessonDao()->sumLessonGiveCreditByCourseId($course['id'])));
     // Update link count of the course lesson file, if the lesson file is changed
     if (array_key_exists('mediaId', $fields)) {
         if ($fields['mediaId'] != $lesson['mediaId']) {
             // Incease the link count of the new selected lesson file
             if (!empty($fields['mediaId'])) {
                 $this->getUploadFileService()->waveUploadFile($fields['mediaId'], 'usedCount', 1);
             }
             // Decrease the link count of the original lesson file
             if (!empty($lesson['mediaId'])) {
                 $this->getUploadFileService()->waveUploadFile($lesson['mediaId'], 'usedCount', -1);
             }
         }
     }
     $this->getLogService()->info('course', 'update_lesson', "更新课时《{$updatedLesson['title']}》({$updatedLesson['id']})", $updatedLesson);
     $updatedLesson['fields'] = $lesson;
     $this->dispatchEvent("course.lesson.update", array('argument' => $argument, 'lesson' => $updatedLesson));
     return $updatedLesson;
 }
开发者ID:CaiZhongda,项目名称:EduSoho,代码行数:43,代码来源:CourseServiceImpl.php

示例7: _filterCategoryFields

 protected function _filterCategoryFields($fields)
 {
     $fields = ArrayToolkit::filter($fields, array('name' => '', 'code' => '', 'weight' => 0, 'publishArticle' => '', 'seoTitle' => '', 'seoDesc' => '', 'published' => 1, 'parentId' => 0));
     if (empty($fields['name'])) {
         throw $this->createServiceException("名称不能为空,保存栏目失败");
     }
     if (empty($fields['code'])) {
         throw $this->createServiceException("编码不能为空,保存栏目失败");
     } else {
         if (!preg_match("/^[a-zA-Z0-9_]+\$/i", $fields['code'])) {
             throw $this->createServiceException("编码({$fields['code']})含有非法字符,保存栏目失败");
         }
         if (ctype_digit($fields['code'])) {
             throw $this->createServiceException("编码({$fields['code']})不能全为数字,保存栏目失败");
         }
     }
     return $fields;
 }
开发者ID:robert-li-2015,项目名称:EduSoho,代码行数:18,代码来源:CategoryServiceImpl.php

示例8: updateLesson

 public function updateLesson($courseId, $lessonId, $fields)
 {
     $course = $this->getCourse($courseId);
     if (empty($course)) {
         throw $this->createServiceException("课程(#{$courseId})不存在!");
     }
     $lesson = $this->getCourseLesson($courseId, $lessonId);
     if (empty($lesson)) {
         throw $this->createServiceException("课时(#{$lessonId})不存在!");
     }
     $fields = ArrayToolkit::filter($fields, array('title' => '', 'summary' => '', 'content' => '', 'media' => array(), 'mediaId' => 0, 'free' => 0, 'length' => 0, 'startTime' => 0, 'giveCredit' => 0, 'requireCredit' => 0, 'homeworkId' => 0, 'exerciseId' => 0));
     if (isset($fields['title'])) {
         $fields['title'] = $this->purifyHtml($fields['title']);
     }
     $fields['type'] = $lesson['type'];
     if ($fields['type'] == 'live') {
         $fields['endTime'] = $fields['startTime'] + $fields['length'] * 60;
     }
     $this->fillLessonMediaFields($fields);
     $updatedLesson = LessonSerialize::unserialize($this->getLessonDao()->updateLesson($lessonId, LessonSerialize::serialize($fields)));
     $this->updateCourseCounter($course['id'], array('giveCredit' => $this->getLessonDao()->sumLessonGiveCreditByCourseId($course['id'])));
     // Update link count of the course lesson file, if the lesson file is changed
     if ($fields['mediaId'] != $lesson['mediaId']) {
         // Incease the link count of the new selected lesson file
         if (!empty($fields['mediaId'])) {
             $this->getUploadFileService()->increaseFileUsedCount(array($fields['mediaId']));
         }
         // Decrease the link count of the original lesson file
         if (!empty($lesson['mediaId'])) {
             $this->getUploadFileService()->decreaseFileUsedCount(array($lesson['mediaId']));
         }
     }
     $this->getLogService()->info('course', 'update_lesson', "更新课时《{$updatedLesson['title']}》({$updatedLesson['id']})", $updatedLesson);
     $this->dispatchEvent("course.lesson.update", $updatedLesson);
     return $updatedLesson;
 }
开发者ID:nanyi,项目名称:EduSoho,代码行数:36,代码来源:CourseServiceImpl.php

示例9: updateUserProfile

 public function updateUserProfile($id, $fields)
 {
     $user = $this->getUser($id);
     if (empty($user)) {
         throw $this->createServiceException('用户不存在,更新用户失败。');
     }
     $fields = ArrayToolkit::filter($fields, array('truename' => '', 'gender' => 'secret', 'iam' => '', 'idcard' => '', 'birthday' => null, 'city' => '', 'mobile' => '', 'qq' => '', 'school' => '', 'class' => '', 'company' => '', 'job' => '', 'signature' => '', 'title' => '', 'about' => '', 'weibo' => '', 'weixin' => '', 'site' => '', 'intField1' => null, 'intField2' => null, 'intField3' => null, 'intField4' => null, 'intField5' => null, 'dateField1' => null, 'dateField2' => null, 'dateField3' => null, 'dateField4' => null, 'dateField5' => null, 'floatField1' => null, 'floatField2' => null, 'floatField3' => null, 'floatField4' => null, 'floatField5' => null, 'textField1' => "", 'textField2' => "", 'textField3' => "", 'textField4' => "", 'textField5' => "", 'textField6' => "", 'textField7' => "", 'textField8' => "", 'textField9' => "", 'textField10' => "", 'varcharField1' => "", 'varcharField2' => "", 'varcharField3' => "", 'varcharField4' => "", 'varcharField5' => "", 'varcharField6' => "", 'varcharField7' => "", 'varcharField8' => "", 'varcharField9' => "", 'varcharField10' => ""));
     if (empty($fields)) {
         return $this->getProfileDao()->getProfile($id);
     }
     if (isset($fields['title'])) {
         $this->getUserDao()->updateUser($id, array('title' => $fields['title']));
         $this->dispatchEvent('user.update', new ServiceEvent(array('user' => $user, 'fields' => $fields)));
     }
     unset($fields['title']);
     if (!empty($fields['gender']) && !in_array($fields['gender'], array('male', 'female', 'secret'))) {
         throw $this->createServiceException('性别不正确,更新用户失败。');
     }
     if (!empty($fields['birthday']) && !SimpleValidator::date($fields['birthday'])) {
         throw $this->createServiceException('生日不正确,更新用户失败。');
     }
     if (!empty($fields['mobile']) && !SimpleValidator::mobile($fields['mobile'])) {
         throw $this->createServiceException('手机不正确,更新用户失败。');
     }
     if (!empty($fields['qq']) && !SimpleValidator::qq($fields['qq'])) {
         throw $this->createServiceException('QQ不正确,更新用户失败。');
     }
     if (!empty($fields['about'])) {
         $fields['about'] = $this->purifyHtml($fields['about']);
     }
     $userProfile = $this->getProfileDao()->updateProfile($id, $fields);
     $this->dispatchEvent('profile.update', new ServiceEvent(array('user' => $user, 'fields' => $fields)));
     return $userProfile;
 }
开发者ID:robert-li-2015,项目名称:EduSoho,代码行数:34,代码来源:UserServiceImpl.php

示例10: updateLesson

 public function updateLesson($courseId, $lessonId, $fields)
 {
     $course = $this->getCourse($courseId);
     if (empty($course)) {
         throw $this->createServiceException("课程(#{$courseId})不存在!");
     }
     $lesson = $this->getCourseLesson($courseId, $lessonId);
     if (empty($lesson)) {
         throw $this->createServiceException("课时(#{$lessonId})不存在!");
     }
     $fields = ArrayToolkit::filter($fields, array('title' => '', 'summary' => '', 'content' => '', 'media' => array(), 'mediaId' => 0, 'free' => 0, 'length' => 0, 'startTime' => 0, 'giveCredit' => 0, 'requireCredit' => 0));
     if (isset($fields['title'])) {
         $fields['title'] = $this->purifyHtml($fields['title']);
     }
     $fields['type'] = $lesson['type'];
     if ($fields['type'] == 'live') {
         $fields['endTime'] = $fields['startTime'] + $fields['length'] * 60;
     }
     $this->fillLessonMediaFields($fields);
     $lesson = LessonSerialize::unserialize($this->getLessonDao()->updateLesson($lessonId, LessonSerialize::serialize($fields)));
     $this->updateCourseCounter($course['id'], array('giveCredit' => $this->getLessonDao()->sumLessonGiveCreditByCourseId($course['id'])));
     $this->getLogService()->info('course', 'update_lesson', "更新课时《{$lesson['title']}》({$lesson['id']})", $lesson);
     return $lesson;
 }
开发者ID:styling,项目名称:LeesPharm,代码行数:24,代码来源:CourseServiceImpl.php

示例11: _filterProductFields

 private function _filterProductFields($fields)
 {
     $fields = ArrayToolkit::filter($fields, array('name' => '', 'price' => 0, 'productBrief' => '', 'categoryId' => 0, 'relatedIds' => array()));
     if (!empty($fields['detail'])) {
         $fields['detail'] = $this->purifyHtml($fields['detail'], true);
     }
     return $fields;
 }
开发者ID:liugang19890719,项目名称:www.zesow.com,代码行数:8,代码来源:ProductServiceImpl.php

示例12: _filterAttributeFields

 private function _filterAttributeFields($fields)
 {
     $fields = ArrayToolkit::filter($fields, array('productId' => 0, 'attrId' => 0, 'attrValue' => ''));
     return $fields;
 }
开发者ID:liugang19890719,项目名称:www.zesow.com,代码行数:5,代码来源:ProductDetailsServiceImpl.php

示例13: _filterExchangeFields

 private function _filterExchangeFields($fields)
 {
     $fields = ArrayToolkit::filter($fields, array('title' => '', 'about' => '', 'points' => 0));
     if (!empty($fields['about'])) {
         $fields['about'] = $this->purifyHtml($fields['about'], true);
     }
     return $fields;
 }
开发者ID:liugang19890719,项目名称:www.zesow.com,代码行数:8,代码来源:ExchangeServiceImpl.php

示例14: updateLesson

 public function updateLesson($courseId, $lessonId, $fields)
 {
     $course = $this->getCourse($courseId);
     if (empty($course)) {
         throw $this->createServiceException("课程(#{$courseId})不存在!");
     }
     $lesson = $this->getCourseLesson($courseId, $lessonId);
     if (empty($lesson)) {
         throw $this->createServiceException("课时(#{$lessonId})不存在!");
     }
     $fields = ArrayToolkit::filter($fields, array('title' => '', 'content' => '', 'summary' => '', 'media' => array(), 'mediaId' => 0, 'free' => 0, 'length' => 0, 'startTime' => 0, 'giveCredit' => 0, 'requireCredit' => 0, 'homeworkId' => 0, 'exerciseId' => 0, 'first_image' => ''));
     if (isset($fields['content'])) {
         $fields['content'] = $this->purifyHtml($fields['content']);
     }
     $updatedLesson = LessonSerialize::unserialize($this->getLessonDao()->updateLesson($lessonId, LessonSerialize::serialize($fields)));
     $this->updateCourseCounter($course['id'], array('giveCredit' => $this->getLessonDao()->sumLessonGiveCreditByCourseId($course['id'])));
     // Update link count of the course lesson file, if the lesson file is changed
     $this->getLogService()->info('course', 'update_lesson', "更新课时《{$updatedLesson['title']}》({$updatedLesson['id']})", $updatedLesson);
     return $updatedLesson;
 }
开发者ID:liugang19890719,项目名称:www.zesow.com,代码行数:20,代码来源:CourseServiceImpl.php


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