本文整理汇总了PHP中SessionManager::parseSessionDates方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionManager::parseSessionDates方法的具体用法?PHP SessionManager::parseSessionDates怎么用?PHP SessionManager::parseSessionDates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionManager
的用法示例。
在下文中一共展示了SessionManager::parseSessionDates方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFormatedSessionsBlock
/**
* Get the formated data for sessions block to be displayed on Session Catalog page
* @param array $sessions The session list
* @return array
*/
private function getFormatedSessionsBlock(array $sessions)
{
$extraFieldValue = new ExtraFieldValue('session');
$userId = api_get_user_id();
$sessionsBlocks = [];
$entityManager = Database::getManager();
$sessionRelCourseRepo = $entityManager->getRepository('ChamiloCoreBundle:SessionRelCourse');
$extraFieldRepo = $entityManager->getRepository('ChamiloCoreBundle:ExtraField');
$extraFieldRelTagRepo = $entityManager->getRepository('ChamiloCoreBundle:ExtraFieldRelTag');
$tagsField = $extraFieldRepo->findOneBy(['extraFieldType' => Chamilo\CoreBundle\Entity\ExtraField::COURSE_FIELD_TYPE, 'variable' => 'tags']);
/** @var \Chamilo\CoreBundle\Entity\Session $session */
foreach ($sessions as $session) {
$sessionDates = SessionManager::parseSessionDates(['display_start_date' => $session->getDisplayStartDate(), 'display_end_date' => $session->getDisplayEndDate(), 'access_start_date' => $session->getAccessStartDate(), 'access_end_date' => $session->getAccessEndDate(), 'coach_access_start_date' => $session->getCoachAccessStartDate(), 'coach_access_end_date' => $session->getCoachAccessEndDate()]);
$imageField = $extraFieldValue->get_values_by_handler_and_field_variable($session->getId(), 'image');
$sessionCourseTags = [];
if (!is_null($tagsField)) {
$sessionRelCourses = $sessionRelCourseRepo->findBy(['session' => $session]);
foreach ($sessionRelCourses as $sessionRelCourse) {
$courseTags = $extraFieldRelTagRepo->getTags($tagsField, $sessionRelCourse->getCourse()->getId());
foreach ($courseTags as $tag) {
$sessionCourseTags[] = $tag->getTag();
}
}
}
if (!empty($sessionCourseTags)) {
$sessionCourseTags = array_unique($sessionCourseTags);
}
$repo = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource');
$sequences = $repo->getRequirementsAndDependenciesWithinSequences($session->getId(), SequenceResource::SESSION_TYPE);
$hasRequirements = false;
foreach ($sequences['sequences'] as $sequence) {
if (count($sequence['requirements']) === 0) {
continue;
}
$hasRequirements = true;
break;
}
$sessionsBlock = array('id' => $session->getId(), 'name' => $session->getName(), 'image' => isset($imageField['value']) ? $imageField['value'] : null, 'nbr_courses' => $session->getNbrCourses(), 'nbr_users' => $session->getNbrUsers(), 'coach_name' => $session->getGeneralCoach()->getCompleteName(), 'is_subscribed' => SessionManager::isUserSubscribedAsStudent($session->getId(), $userId), 'icon' => $this->getSessionIcon($session->getName()), 'date' => $sessionDates['display'], 'subscribe_button' => $this->getRegisteredInSessionButton($session->getId(), $session->getName(), $hasRequirements), 'show_description' => $session->getShowDescription(), 'tags' => $sessionCourseTags);
$sessionsBlock = array_merge($sessionsBlock, $sequences);
$sessionsBlocks[] = $sessionsBlock;
}
return $sessionsBlocks;
}
示例2: foreach
foreach ($courseDescriptionTools as $descriptionTool) {
switch ($descriptionTool->getDescriptionType()) {
case CCourseDescription::TYPE_DESCRIPTION:
$courseDescription = $descriptionTool;
break;
case CCourseDescription::TYPE_OBJECTIVES:
$courseObjectives = $descriptionTool;
break;
case CCourseDescription::TYPE_TOPICS:
$courseTopics = $descriptionTool;
break;
}
}
$courses[] = ['course' => $sessionCourse, 'description' => $courseDescription, 'tags' => $courseTags, 'objectives' => $courseObjectives, 'topics' => $courseTopics, 'coaches' => $coachesData, 'extra_fields' => $courseValues->getAllValuesForAnItem($sessionCourse->getId())];
}
$sessionDates = SessionManager::parseSessionDates(['display_start_date' => $session->getDisplayStartDate(), 'display_end_date' => $session->getDisplayEndDate(), 'access_start_date' => $session->getAccessStartDate(), 'access_end_date' => $session->getAccessEndDate(), 'coach_access_start_date' => $session->getCoachAccessStartDate(), 'coach_access_end_date' => $session->getCoachAccessEndDate()]);
$sessionRequirements = $sequenceResourceRepo->getRequirements($session->getId(), SequenceResource::SESSION_TYPE);
$hasRequirements = false;
foreach ($sessionRequirements as $sequence) {
if (!empty($sequence['requirements'])) {
$hasRequirements = true;
break;
}
}
$courseController = new CoursesController();
/* View */
//$template = new Template($session->getName(), true, true, false, true, false);
$template = \Chamilo\CoreBundle\Framework\Container::getTwig();
$template->addGlobal('show_tutor', api_get_setting('session.show_session_coach') === 'true' ? true : false);
$template->addGlobal('pageUrl', api_get_path(WEB_PATH) . "session/{$session->getId()}/about/");
$template->addGlobal('session', $session);
示例3: implode
}
/** @var SequenceRepository $repo */
$repo = Database::getManager()->getRepository('ChamiloCoreBundle:SequenceResource');
$requirementAndDependencies = $repo->getRequirementAndDependencies($sessionId, SequenceResource::SESSION_TYPE);
$requirements = '';
if (!empty($requirementAndDependencies['requirements'])) {
$requirements = Display::page_subheader(get_lang('Requirements'));
$requirements .= implode(' + ', array_column($requirementAndDependencies['requirements'], 'admin_link'));
}
$dependencies = '';
if (!empty($requirementAndDependencies['dependencies'])) {
$dependencies = Display::page_subheader(get_lang('Dependencies'));
$dependencies .= implode(', ', array_column($requirementAndDependencies['dependencies'], 'admin_link'));
}
//$tpl = new Template(get_lang('Session'));
$tpl = Container::getTwig();
$tpl->addGlobal('session_header', $sessionHeader);
$tpl->addGlobal('title', $sessionTitle);
$tpl->addGlobal('general_coach', $generalCoach);
$tpl->addGlobal('session_admin', api_get_user_info($session->getSessionAdminId()));
$tpl->addGlobal('session', $sessionInfo);
$tpl->addGlobal('session_category', is_null($sessionCategory) ? null : $sessionCategory->getName());
$tpl->addGlobal('session_dates', SessionManager::parseSessionDates($sessionInfo));
$tpl->addGlobal('session_visibility', SessionManager::getSessionVisibility($sessionInfo));
$tpl->addGlobal('url_list', $urlList);
$tpl->addGlobal('extra_fields', $extraFieldData);
$tpl->addGlobal('course_list', $courseListToShow);
$tpl->addGlobal('user_list', $userListToShow);
$tpl->addGlobal('dependencies', $dependencies);
$tpl->addGlobal('requirements', $requirements);
echo $tpl->render('@template_style/session/resume_session.html.twig');
示例4: show_session_data
/**
* Shows the general data for a particular meeting
*
* @param id session id
* @return string session data
*/
public static function show_session_data($id_session)
{
$session_table = Database::get_main_table(TABLE_MAIN_SESSION);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$session_category_table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$sessionInfo = api_get_session_info($id_session);
if (empty($sessionInfo)) {
return '';
}
$sql = 'SELECT name FROM ' . $session_category_table . '
WHERE id = "' . intval($sessionInfo['session_category_id']) . '"';
$rs_category = Database::query($sql);
$session_category = '';
if (Database::num_rows($rs_category) > 0) {
$rows_session_category = Database::store_result($rs_category);
$rows_session_category = $rows_session_category[0];
$session_category = $rows_session_category['name'];
}
$coachInfo = api_get_user_info($sessionInfo['id_coach']);
$output = '';
if (!empty($session_category)) {
$output .= '<tr><td>' . get_lang('SessionCategory') . ': ' . '<b>' . $session_category . '</b></td></tr>';
}
$dateInfo = SessionManager::parseSessionDates($sessionInfo);
$msgDate = $dateInfo['access'];
$output .= '<tr>
<td style="width:50%">' . get_lang('SessionName') . ': ' . '<b>' . $sessionInfo['name'] . '</b></td>
<td>' . get_lang('GeneralCoach') . ': ' . '<b>' . $coachInfo['complete_name'] . '</b></td></tr>';
$output .= '<tr>
<td>' . get_lang('SessionIdentifier') . ': ' . Display::return_icon('star.png', ' ', array('align' => 'absmiddle')) . '
</td>
<td>' . get_lang('Date') . ': ' . '<b>' . $msgDate . '</b>
</td>
</tr>';
return $output;
}
示例5: getSessionInfo
/**
* Get session info
* @param array $sessionId The session ID
* @return array
*/
public function getSessionInfo($sessionId)
{
$entityManager = Database::getManager();
$session = $entityManager->find('ChamiloCoreBundle:Session', $sessionId);
if (empty($session)) {
return [];
}
$item = $this->getItemByProduct($session->getId(), self::PRODUCT_TYPE_SESSION);
if (empty($item)) {
return [];
}
$sessionDates = SessionManager::parseSessionDates(['display_start_date' => $session->getDisplayStartDate(), 'display_end_date' => $session->getDisplayEndDate(), 'access_start_date' => $session->getAccessStartDate(), 'access_end_date' => $session->getAccessEndDate(), 'coach_access_start_date' => $session->getCoachAccessStartDate(), 'coach_access_end_date' => $session->getCoachAccessEndDate()]);
$sessionInfo = ['id' => $session->getId(), 'name' => $session->getName(), 'dates' => $sessionDates, 'courses' => [], 'price' => $item['price'], 'currency' => $item['iso_code'], 'image' => null];
$fieldValue = new ExtraFieldValue('session');
$sessionImage = $fieldValue->get_values_by_handler_and_field_variable($session->getId(), 'image');
if (!empty($sessionImage)) {
$sessionInfo['image'] = api_get_path(WEB_UPLOAD_PATH) . $sessionImage['value'];
}
$sessionCourses = $session->getCourses();
foreach ($sessionCourses as $sessionCourse) {
$course = $sessionCourse->getCourse();
$sessionCourseData = ['title' => $course->getTitle(), 'coaches' => []];
$userCourseSubscriptions = $session->getUserCourseSubscriptionsByStatus($course, Chamilo\CoreBundle\Entity\Session::COACH);
foreach ($userCourseSubscriptions as $userCourseSubscription) {
$user = $userCourseSubscription->getUser();
$sessionCourseData['coaches'][] = $user->getCompleteName();
}
$sessionInfo['courses'][] = $sessionCourseData;
}
return $sessionInfo;
}
示例6: get_sessions_by_category
//.........这里部分代码省略.........
// First take $row2, as it contains less data and this data is enough
while ($row2 = Database::fetch_array($result2)) {
$join[] = $row2;
$ordered_join[] = $row2;
$ids[] = $row2['id'];
}
}
if (Database::num_rows($result1) > 0) {
// Now add the diff with $row1, ordering elements as planned by query
$i = 0;
while ($row1 = Database::fetch_array($result1)) {
if (!in_array($row1['id'], $ids)) {
if ($reverse_order) {
while (isset($join[$i]) && strcmp($row1['session_category_name'], $join[$i]['session_category_name']) <= 0) {
$ordered_join[] = $join[$i];
$i++;
}
} else {
while (isset($join[$i]) && strcmp($row1['session_category_name'], $join[$i]['session_category_name']) > 0) {
$ordered_join[] = $join[$i];
$i++;
}
if (isset($join[$i]) && strcmp($row1['session_category_name'], $join[$i]['session_category_name']) === 0) {
while (isset($join[$i]) && isset($row1['short_name']) && strcmp($row1['short_name'], $join[$i]['short_name']) > 0) {
$ordered_join[] = $join[$i];
$i++;
}
}
}
$ordered_join[] = $row1;
$join[] = $row1;
}
}
}
if (count($ordered_join) == 0) {
$ordered_join = $join;
}
if (count($ordered_join) > 0) {
foreach ($ordered_join as $row) {
if ($get_count) {
return $row['total_rows'];
}
$categories[$row['session_category_id']]['session_category']['id'] = $row['session_category_id'];
$categories[$row['session_category_id']]['session_category']['name'] = $row['session_category_name'];
$categories[$row['session_category_id']]['session_category']['date_start'] = $row['session_category_date_start'];
$categories[$row['session_category_id']]['session_category']['date_end'] = $row['session_category_date_end'];
$session_id = $row['id'];
// The only usage of $session_info is to call
// api_get_session_date_validation, which only needs id and
// dates from the session itself, so really no need to query
// the session table again
$session_info = $row;
// Checking session visibility
$visibility = api_get_session_visibility($session_id, null, $ignore_visibility_for_admins);
switch ($visibility) {
case SESSION_VISIBLE_READ_ONLY:
case SESSION_VISIBLE:
case SESSION_AVAILABLE:
break;
case SESSION_INVISIBLE:
continue 2;
}
if ($is_time_over == false) {
$date_validation = api_get_session_date_validation($session_info, null, false, false);
if (!$date_validation) {
continue;
}
}
$categories[$row['session_category_id']]['sessions'][$row['id']]['session_name'] = $row['name'];
$categories[$row['session_category_id']]['sessions'][$row['id']]['session_id'] = $row['id'];
$categories[$row['session_category_id']]['sessions'][$row['id']]['id_coach'] = $row['id_coach'];
if (isset($row['id_coach']) && !empty($row['id_coach'])) {
$user_info = api_get_user_info($row['id_coach']);
$categories[$row['session_category_id']]['sessions'][$row['id']]['coach_info'] = $user_info;
}
$categories[$row['session_category_id']]['sessions'][$row['id']]['access_start_date'] = $row['access_start_date'];
$categories[$row['session_category_id']]['sessions'][$row['id']]['access_end_date'] = $row['access_end_date'];
$categories[$row['session_category_id']]['sessions'][$row['id']]['coach_access_start_date'] = $row['coach_access_start_date'];
$categories[$row['session_category_id']]['sessions'][$row['id']]['coach_access_end_date'] = $row['coach_access_end_date'];
$date_message = SessionManager::parseSessionDates($row);
$categories[$row['session_category_id']]['sessions'][$row['id']]['date_message'] = $date_message;
$courses = UserManager::get_courses_list_by_session($user_id, $row['id']);
$course_list = array();
foreach ($courses as $course) {
// Checking course session visibility
$visibility = api_get_session_visibility($session_id, $course['real_id']);
if ($visibility == SESSION_INVISIBLE) {
continue;
}
$user_status_in_course = CourseManager::get_user_in_course_status($user_id, $course['code']);
$course['user_status_in_course'] = $user_status_in_course;
$course_list[] = $course;
}
$categories[$row['session_category_id']]['sessions'][$row['id']]['courses'] = $course_list;
$categories[$row['session_category_id']]['sessions'][$row['id']]['moved_to'] = isset($row['moved_to']) ? $row['moved_to'] : null;
$categories[$row['session_category_id']]['sessions'][$row['id']]['moved_status'] = isset($row['moved_status']) ? $row['moved_status'] : null;
}
}
return $categories;
}
示例7: implode
$userListToShow .= $table->toHtml();
}
/** @var SequenceRepository $repo */
$repo = Database::getManager()->getRepository('ChamiloCoreBundle:SequenceResource');
$requirementAndDependencies = $repo->getRequirementAndDependencies($sessionId, SequenceResource::SESSION_TYPE);
$requirements = '';
if (!empty($requirementAndDependencies['requirements'])) {
$requirements = Display::page_subheader(get_lang('Requirements'));
$requirements .= implode(' + ', array_column($requirementAndDependencies['requirements'], 'admin_link'));
}
$dependencies = '';
if (!empty($requirementAndDependencies['dependencies'])) {
$dependencies = Display::page_subheader(get_lang('Dependencies'));
$dependencies .= implode(', ', array_column($requirementAndDependencies['dependencies'], 'admin_link'));
}
$tpl = new Template(get_lang('Session'));
$tpl->assign('session_header', $sessionHeader);
$tpl->assign('title', $sessionTitle);
$tpl->assign('general_coach', $generalCoach);
$tpl->assign('session', $sessionInfo);
$tpl->assign('session_category', is_null($sessionCategory) ? null : $sessionCategory->getName());
$tpl->assign('session_dates', SessionManager::parseSessionDates($sessionInfo));
$tpl->assign('session_visibility', SessionManager::getSessionVisibility($sessionInfo));
$tpl->assign('url_list', $urlList);
$tpl->assign('extra_fields', $extraFieldData);
$tpl->assign('course_list', $courseListToShow);
$tpl->assign('user_list', $userListToShow);
$tpl->assign('dependencies', $dependencies);
$tpl->assign('requirements', $requirements);
$layout = $tpl->get_template('session/resume_session.tpl');
$tpl->display($layout);