本文整理汇总了PHP中Topxia\Common\ArrayToolkit::column方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayToolkit::column方法的具体用法?PHP ArrayToolkit::column怎么用?PHP ArrayToolkit::column使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topxia\Common\ArrayToolkit
的用法示例。
在下文中一共展示了ArrayToolkit::column方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filterItem
private function filterItem($items)
{
$questionIds = ArrayToolkit::column($items, "questionId");
$questions = $this->getQuestionService()->findQuestionsByIds($questionIds);
$materialMap = array();
$itemIndexMap = array();
$newItems = array();
foreach ($items as &$item) {
unset($item['answer']);
unset($item['userId']);
$question = $questions[$item['questionId']];
$item['questionType'] = $question['type'];
$item['questionParentId'] = $question['parentId'];
if ('material' == $item['questionType']) {
$itemIndexMap[$item['questionId']] = $item['id'];
$materialMap[$item['questionId']] = array();
}
if ($item['questionParentId'] != 0 && isset($materialMap[$item['questionParentId']])) {
$materialMap[$item['questionParentId']][] = $item;
continue;
}
$newItems[$item['id']] = $item;
}
foreach ($materialMap as $id => $material) {
$newItems[$itemIndexMap[$id]]['items'] = $material;
}
return array_values($newItems);
}
示例2: listAction
public function listAction(Request $request, $classroomId)
{
$classroom = $this->getClassroomService()->getClassroom($classroomId);
$headTeacher = $this->getClassroomService()->findClassroomMembersByRole($classroomId, 'headTeacher', 0, 1);
$assistants = $this->getClassroomService()->findClassroomMembersByRole($classroomId, 'assistant', 0, PHP_INT_MAX);
$studentAssistants = $this->getClassroomService()->findClassroomMembersByRole($classroomId, 'studentAssistant', 0, PHP_INT_MAX);
$members = $this->getClassroomService()->findClassroomMembersByRole($classroomId, 'teacher', 0, PHP_INT_MAX);
$members = array_merge($headTeacher, $members, $assistants, $studentAssistants);
$members = ArrayToolkit::index($members, 'userId');
$teacherIds = ArrayToolkit::column($members, 'userId');
$teachers = $this->getUserService()->findUsersByIds($teacherIds);
$teachers = $this->sort($teachers, $members);
$profiles = $this->getUserService()->findUserProfilesByIds($teacherIds);
$user = $this->getCurrentUser();
$myfollowings = $this->getUserService()->filterFollowingIds($user['id'], $teacherIds);
$member = $user ? $this->getClassroomService()->getClassroomMember($classroom['id'], $user['id']) : null;
$layout = 'ClassroomBundle:Classroom:layout.html.twig';
if ($member && !$member['locked']) {
$layout = 'ClassroomBundle:Classroom:join-layout.html.twig';
}
if (!$classroom) {
$classroomDescription = array();
} else {
$classroomDescription = $classroom['about'];
$classroomDescription = strip_tags($classroomDescription, '');
$classroomDescription = preg_replace("/ /", "", $classroomDescription);
}
return $this->render('ClassroomBundle:Classroom\\Teacher:list.html.twig', array('layout' => $layout, 'canLook' => $this->getClassroomService()->canLookClassroom($classroom['id']), 'classroom' => $classroom, 'teachers' => $teachers, 'profiles' => $profiles, 'member' => $member, 'members' => $members, 'Myfollowings' => $myfollowings, 'classroomDescription' => $classroomDescription));
}
示例3: indexAction
public function indexAction(Request $request, $courseId)
{
$course = $this->getCourseService()->tryManageCourse($courseId);
$conditions = $request->query->all();
if (empty($conditions['target'])) {
$conditions['targetPrefix'] = "course-{$course['id']}";
}
if (!empty($conditions['keyword'])) {
$conditions['stem'] = $conditions['keyword'];
}
//现实所有的题目包括设置为中间题的题目
$conditions['isMiddle'] = 'all';
if (!empty($conditions['parentId'])) {
$parentQuestion = $this->getQuestionService()->getQuestion($conditions['parentId']);
if (empty($parentQuestion)) {
return $this->redirect($this->generateUrl('course_manage_question', array('courseId' => $courseId)));
}
$orderBy = array('createdTime', 'ASC');
} else {
$conditions['parentId'] = 0;
$parentQuestion = null;
$orderBy = array('createdTime', 'DESC');
}
$paginator = new Paginator($this->get('request'), $this->getQuestionService()->searchQuestionsCount($conditions), 10);
$questions = $this->getQuestionService()->searchQuestions($conditions, $orderBy, $paginator->getOffsetCount(), $paginator->getPerPageCount());
$users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($questions, 'userId'));
$targets = $this->get('topxia.target_helper')->getTargets(ArrayToolkit::column($questions, 'target'));
return $this->render('TopxiaWebBundle:CourseQuestionManage:index.html.twig', array('course' => $course, 'questions' => $questions, 'users' => $users, 'targets' => $targets, 'paginator' => $paginator, 'parentQuestion' => $parentQuestion, 'conditions' => $conditions, 'targetChoices' => $this->getQuestionTargetChoices($course)));
}
示例4: getData
/**
* 获取最热话题
*
* 可传入的参数:
*
* count 必需 话题数量,取值不能超过100
*
* @param array $arguments 参数
* @return array 最热话题
*/
public function getData(array $arguments)
{
$groupSetting = $this->getSettingService()->get('group', array());
$time = 7 * 24 * 60 * 60;
if (isset($groupSetting['threadTime_range'])) {
$time = $groupSetting['threadTime_range'] * 24 * 60 * 60;
}
$hotThreads = $this->getThreadService()->searchThreads(array('createdTime' => time() - $time, 'status' => 'open'), array(array('isStick', 'DESC'), array('postNum', 'DESC'), array('createdTime', 'DESC')), 0, $arguments['count']);
$ownerIds = ArrayToolkit::column($hotThreads, 'userId');
$groupIds = ArrayToolkit::column($hotThreads, 'groupId');
$userIds = ArrayToolkit::column($hotThreads, 'lastPostMemberId');
$lastPostMembers = $this->getUserService()->findUsersByIds($userIds);
$owners = $this->getUserService()->findUsersByIds($ownerIds);
$groups = $this->getGroupService()->getGroupsByids($groupIds);
foreach ($hotThreads as $key => $thread) {
if ($thread['userId'] == $owners[$thread['userId']]['id']) {
$hotThreads[$key]['user'] = $owners[$thread['userId']];
}
if ($thread['lastPostMemberId'] > 0 && $thread['lastPostMemberId'] == $lastPostMembers[$thread['lastPostMemberId']]['id']) {
$hotThreads[$key]['lastPostMember'] = $lastPostMembers[$thread['lastPostMemberId']];
}
if ($thread['groupId'] == $groups[$thread['groupId']]['id']) {
$hotThreads[$key]['group'] = $groups[$thread['groupId']];
}
}
return $hotThreads;
}
示例5: showAction
public function showAction(Request $request, $id)
{
$buyer = $this->getCurrentUser();
$ex = $request->query->all();
$myexchangeid = $ex['ex'];
$applyid = $ex[applyid];
$exchange = $this->getExchangeService()->getExchange($id);
$condition = array('exchangeId' => $exchange['id'], 'userId' => $buyer['id']);
$buyerapplys = $this->getApplyService()->searchApplys($condition, 'latest', 0, 10);
$buyerapplyIds = ArrayToolkit::column($buyerapplys, 'id');
$sellerId = $exchange['userId'];
$seller = $this->getUserService()->getUser($sellerId);
if (empty($exchange)) {
throw $this->createNotFoundException("宝贝不存在");
}
$conditions = array('exchangeId' => $exchange['id']);
$paginator = new Paginator($this->get('request'), $this->getApplyService()->searchApplyCount($conditions), 5);
$applys = $this->getApplyService()->searchApplys($conditions, 'latest', $paginator->getOffsetCount(), $paginator->getPerPageCount());
$applysIds = ArrayToolkit::column($applys, 'id');
// dump($applysIds);
// die;
$flag = 0;
if (!empty($applysIds)) {
foreach ($buyerapplyIds as $val) {
if (in_array($val, $applysIds)) {
$flag = 1;
break;
}
}
}
$userIds = ArrayToolkit::column($applys, 'userId');
$users = $this->getUserService()->findUsersByIds($userIds);
return $this->render("TopxiaWebBundle:Exchange:show.html.twig", array('flag' => $flag, 'seller' => $seller, 'applyid' => $applyid, 'myexchangeid' => $myexchangeid, 'exchange' => $exchange, 'applys' => $applys, 'users' => $users, 'paginator' => $paginator));
}
示例6: getData
/**
* 获取所有用户的最新动态
*
* 可传入的参数:
* mode 必需 动态的模式(simple, full)
* count 必需 获取动态数量
* objectType 可选 动态所属对象类型
* objectId 可选 动态所属对象编号
*
* @param array $arguments 参数
* @return array 用户列表
*/
public function getData(array $arguments)
{
$conditions = array();
if (isset($arguments['private'])) {
if ($arguments['private'] == 0) {
$conditions['private'] = 0;
}
}
if (isset($arguments['objectType']) && isset($arguments['objectId'])) {
if ($arguments['objectType'] == 'course') {
$conditions['courseIds'] = array($arguments['objectId']);
} else {
$courses = $this->getClassroomService()->findActiveCoursesByClassroomId($classroom['id']);
if ($courses) {
$courseIds = ArrayToolkit::column($courses, 'id');
$conditions['classroomCourseIds'] = $courseIds;
$conditions['classroomId'] = $arguments['objectId'];
} else {
$conditions['onlyClassroomId'] = $arguments['objectId'];
}
}
}
$statuses = $this->getStatusService()->searchStatuses($conditions, array('createdTime', 'DESC'), 0, $arguments['count']);
if ($statuses) {
$userIds = ArrayToolkit::column($statuses, 'userId');
$users = $this->getUserService()->findUsersByIds($userIds);
$manager = ExtensionManager::instance();
foreach ($statuses as &$status) {
$status['user'] = $users[$status['userId']];
$status['message'] = $manager->renderStatus($status, $arguments['mode']);
unset($status);
}
}
return $statuses;
}
示例7: exploreAction
public function exploreAction(Request $request)
{
if (!$this->setting('course.live_course_enabled')) {
return $this->createMessageResponse('info', '直播频道已关闭');
}
$recenntLessonsCondition = array('status' => 'published', 'endTimeGreaterThan' => time());
$paginator = new Paginator($this->get('request'), $this->getCourseService()->searchLessonCount($recenntLessonsCondition), 30);
$recentlessons = $this->getCourseService()->searchLessons($recenntLessonsCondition, array('startTime', 'ASC'), $paginator->getOffsetCount(), $paginator->getPerPageCount());
$courses = $this->getCourseService()->findCoursesByIds(ArrayToolkit::column($recentlessons, 'courseId'));
$recentCourses = array();
foreach ($recentlessons as $lesson) {
$course = $courses[$lesson['courseId']];
if ($course['status'] != 'published') {
continue;
}
$course['lesson'] = $lesson;
$recentCourses[] = $course;
}
$liveCourses = $this->getCourseService()->searchCourses(array('status' => 'published', 'type' => 'live'), 'lastest', 0, 10);
$userIds = array();
foreach ($liveCourses as $course) {
$userIds = array_merge($userIds, $course['teacherIds']);
}
$users = $this->getUserService()->findUsersByIds($userIds);
$default = $this->getSettingService()->get('default', array());
return $this->render('TopxiaWebBundle:LiveCourse:index.html.twig', array('recentCourses' => $recentCourses, 'liveCourses' => $liveCourses, 'users' => $users, 'paginator' => $paginator, 'default' => $default));
}
示例8: getData
/**
* 获取一个分类下的课程成员列表
*
* 可传入的参数:
* categoryId 选填 分类ID
* count 必需 学员数量,取值不能超过100
*
* @param array $arguments 参数
* @return array 课程成员列表
*/
public function getData(array $arguments)
{
$this->checkCount($arguments);
$conditions = array('status' => 'paid');
$orders = $this->getGiftOrdersService()->searchOrders($conditions, 'latest', 0, 1000);
return $users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($orders, 'userId'));
}
示例9: indexAction
public function indexAction(Request $request, $postStatus)
{
$conditions = $request->query->all();
if (isset($conditions['keywordType']) && $conditions['keywordType'] == 'courseTitle') {
$courses = $this->getCourseService()->findCoursesByLikeTitle(trim($conditions['keyword']));
$conditions['courseIds'] = ArrayToolkit::column($courses, 'id');
if (count($conditions['courseIds']) == 0) {
return $this->render('TopxiaAdminBundle:CourseQuestion:index.html.twig', array('paginator' => new Paginator($request, 0, 20), 'questions' => array(), 'users' => array(), 'courses' => array(), 'lessons' => array(), 'type' => $postStatus));
}
}
$conditions['type'] = 'question';
$paginator = new Paginator($request, $this->getThreadService()->searchThreadCount($conditions), 20);
$questions = $this->getThreadService()->searchThreads($conditions, 'createdNotStick', $paginator->getOffsetCount(), $paginator->getPerPageCount());
$unPostedQuestion = array();
foreach ($questions as $key => $value) {
if ($value['postNum'] == 0) {
$unPostedQuestion[] = $value;
} else {
$threadPostsNum = $this->getThreadService()->getThreadPostCountByThreadId($value['id']);
$userPostsNum = $this->getThreadService()->getPostCountByuserIdAndThreadId($value['userId'], $value['id']);
if ($userPostsNum == $threadPostsNum) {
$unPostedQuestion[] = $value;
}
}
}
if ($postStatus == 'unPosted') {
$questions = $unPostedQuestion;
}
$users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($questions, 'userId'));
$courses = $this->getCourseService()->findCoursesByIds(ArrayToolkit::column($questions, 'courseId'));
$lessons = $this->getCourseService()->findLessonsByIds(ArrayToolkit::column($questions, 'lessonId'));
return $this->render('TopxiaAdminBundle:CourseQuestion:index.html.twig', array('paginator' => $paginator, 'questions' => $questions, 'users' => $users, 'courses' => $courses, 'lessons' => $lessons, 'type' => $postStatus));
}
示例10: defaultCoursePictureCropAction
public function defaultCoursePictureCropAction(Request $request)
{
if ($request->getMethod() == 'POST') {
$options = $request->request->all();
$data = $options["images"];
$fileIds = ArrayToolkit::column($data, "id");
$files = $this->getFileService()->getFilesByIds($fileIds);
$files = ArrayToolkit::index($files, "id");
$fileIds = ArrayToolkit::index($data, "type");
$setting = $this->getSettingService()->get("default", array());
$oldAvatars = array('course.png' => !empty($setting['course.png']) ? $setting['course.png'] : null);
$setting['defaultCoursePicture'] = 1;
unset($setting['defaultCoursePictureFileName']);
$setting['course.png'] = $files[$fileIds["course.png"]["id"]]["uri"];
$this->getSettingService()->set("default", $setting);
$fileService = $this->getFileService();
array_map(function ($oldAvatar) use($fileService) {
if (!empty($oldAvatar)) {
$fileService->deleteFileByUri($oldAvatar);
}
}, $oldAvatars);
return $this->redirect($this->generateUrl('admin_setting_course_avatar'));
}
$fileId = $request->getSession()->get("fileId");
list($pictureUrl, $naturalSize, $scaledSize) = $this->getFileService()->getImgFileMetaInfo($fileId, 480, 270);
return $this->render('TopxiaAdminBundle:System:default-course-picture-crop.html.twig', array('pictureUrl' => $pictureUrl, 'naturalSize' => $naturalSize, 'scaledSize' => $scaledSize));
}
示例11: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->initServiceKernel();
$connection = $this->getContainer()->get('database_connection');
$tomorrow = date("Y-m-d", strtotime("+1 day"));
$startDate = $tomorrow . " 0:00:00";
$endDate = $tomorrow . " 24:00:00";
$conditions['startTimeLessThan'] = strtotime($endDate);
$conditions['startTimeGreaterThan'] = strtotime($startDate);
$total = $this->getCourseService()->searchLessonCount($conditions);
$liveLessons = $this->getCourseService()->searchLessons($conditions, array('startTime', 'ASC'), 0, $total);
$courseIds = ArrayToolkit::column($liveLessons, 'courseId');
$courseIds = array_unique($courseIds);
$courseIds = array_values($courseIds);
if ($courseIds) {
$courseMembers = $this->getCourseService()->findCourseStudentsByCourseIds($courseIds);
foreach ($courseMembers as $key => $value) {
$minStartTime = $this->getCourseService()->findMinStartTimeByCourseId($value['courseId']);
if (time() >= strtotime($startDate)) {
$noticeDay = "今天";
} else {
$noticeDay = "明天";
}
$minStartTime = date("Y-m-d H:i:s", $minStartTime[0]['startTime']);
$message = array('noticeDay' => $noticeDay, 'minStartTime' => $minStartTime);
$this->getNotificationService()->notify($value['userId'], "live-course", $message);
}
$output->writeln('<info>消息发布完成</info>');
} else {
$output->writeln('<info>没有消息可以发布</info>');
}
}
示例12: editAction
public function editAction(Request $request, $id)
{
$article = $this->getArticleService()->getArticle($id);
if (empty($article)) {
throw $this->createNotFoundException('文章已删除或者未发布!');
}
if (empty($article['tagIds'])) {
$article['tagIds'] = array();
}
$tags = $this->getTagService()->findTagsByIds($article['tagIds']);
$tagNames = ArrayToolkit::column($tags, 'name');
$categoryId = $article['categoryId'];
$category = $this->getCategoryService()->getCategory($categoryId);
$categoryTree = $this->getCategoryService()->getCategoryTree();
if ($request->getMethod() == 'POST') {
$formData = $request->request->all();
$article = $this->getArticleService()->updateArticle($id, $formData);
return $this->redirect($this->generateUrl('admin_article'));
}
//添加报名人数
$ArticleService = $this->getServiceKernel()->createService('Article.ArticleService');
$temp_count = $ArticleService->getArticleLikesCountByArticleId($article['id']);
$article['enroll'] = $temp_count;
return $this->render('TopxiaAdminBundle:Article:article-modal.html.twig', array('article' => $article, 'categoryTree' => $categoryTree, 'category' => $category, 'tagNames' => $tagNames));
}
示例13: assemblyArticles
protected function assemblyArticles(&$articles)
{
$tagIds = array();
foreach ($articles as $article) {
$tagIds = array_merge($tagIds, $article['tagIds']);
}
$tags = $this->getTagService()->findTagsByIds($tagIds);
$categoryIds = ArrayToolkit::column($articles, 'categoryId');
$categories = $this->getCategoryService()->findCategoriesByIds($categoryIds);
foreach ($articles as &$article) {
$article['tags'] = array();
if (empty($article['tagIds'])) {
continue;
}
foreach ($article['tagIds'] as $tagId) {
if (empty($tags[$tagId])) {
continue;
}
$article['tags'][] = array('id' => $tagId, 'name' => $tags[$tagId]['name']);
}
}
foreach ($articles as &$article) {
if (isset($categories[$article['categoryId']])) {
$article['category'] = array('id' => $categories[$article['categoryId']]['id'], 'name' => $categories[$article['categoryId']]['name']);
} else {
$article['category'] = array();
}
}
return $articles;
}
示例14: indexAction
public function indexAction(Request $request, $id)
{
$course = $this->getCourseService()->tryManageCourse($id);
$type = $request->query->get('type');
$type = in_array($type, array('courselesson', 'coursematerial')) ? $type : 'courselesson';
$conditions = array('targetType' => $type, 'targetId' => $course['id']);
if (array_key_exists('targetId', $conditions) && !empty($conditions['targetId'])) {
$course = $this->getCourseService()->getCourse($conditions['targetId']);
if ($course['parentId'] > 0 && $course['locked'] == 1) {
$conditions['targetId'] = $course['parentId'];
}
}
$paginator = new Paginator($request, $this->getUploadFileService()->searchFileCount($conditions), 20);
$files = $this->getUploadFileService()->searchFiles($conditions, 'latestCreated', $paginator->getOffsetCount(), $paginator->getPerPageCount());
foreach ($files as $key => $file) {
$files[$key]['metas2'] = json_decode($file['metas2'], true) ?: array();
$files[$key]['convertParams'] = json_decode($file['convertParams']) ?: array();
$useNum = $this->getCourseService()->searchLessonCount(array('mediaId' => $file['id']));
$manageFilesUseNum = $this->getMaterialService()->getMaterialCountByFileId($file['id']);
if ($files[$key]['targetType'] == 'coursematerial') {
$files[$key]['useNum'] = $manageFilesUseNum;
} else {
$files[$key]['useNum'] = $useNum;
}
}
$users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($files, 'updatedUserId'));
$storageSetting = $this->getSettingService()->get("storage");
return $this->render('TopxiaWebBundle:CourseFileManage:index.html.twig', array('type' => $type, 'course' => $course, 'courseLessons' => $files, 'users' => ArrayToolkit::index($users, 'id'), 'paginator' => $paginator, 'now' => time(), 'storageSetting' => $storageSetting));
}
示例15: latestReviewsBlockAction
public function latestReviewsBlockAction($number)
{
$reviews = $this->getReviewService()->searchReviews(array(), 'latest', 0, $number);
$users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($reviews, 'userId'));
$courses = $this->getCourseService()->findCoursesByIds(ArrayToolkit::column($reviews, 'courseId'));
return $this->render('TopxiaWebBundle:Default:latest-reviews-block.html.twig', array('reviews' => $reviews, 'users' => $users, 'courses' => $courses));
}