Explorar o código

New grid view catalog session, under structure in the search refs BT#11017

Alex Aragon %!s(int64=8) %!d(string=hai) anos
pai
achega
ab2eb59757

+ 24 - 7
app/Resources/public/css/base.css

@@ -91,7 +91,9 @@ a.thumbnail:hover{
     -ms-flex-negative:1 ;
     display: block;
     position: relative;
-    
+}
+.popover.bottom{
+    width: 320px;
 }
 .page-course{
     padding: 2% 3%;
@@ -4886,6 +4888,11 @@ div#chat-remote-video video {
 .grid-courses .items .toolbar{
     text-align: right;
 }
+.grid-courses .session-date{
+    color: #fff;
+    font-size: 12px;
+    padding: 10px;
+}
 .grid-courses .items .image{
     position: relative;
 }
@@ -4934,6 +4941,10 @@ div#chat-remote-video video {
     border-radius: 0;
     border: none;
 }
+.grid-courses .items .admin-actions .registered{
+    background-color: #17AA1C;
+    color: #FFF;
+}
 .grid-courses .items .category{
     position: absolute;
     bottom: 0px;
@@ -4957,6 +4968,9 @@ div#chat-remote-video video {
 .grid-courses .items .description{
     padding: 5px 10px;
 }
+.grid-courses .items .description .text{
+    font-size: 12px;
+}
 .grid-courses .items .author-card{
     display: flex;
     margin-top: 5px;
@@ -4981,15 +4995,18 @@ div#chat-remote-video video {
     color: #fff;
 }
 /* Catalog session */
+.search-session{
+    margin-bottom: 30px;
+    margin-top: 25px;
+}
+.search-session .form-inline label{
+    font-weight: normal;
+    padding-right: 10px;
+    margin-right: 5px;
+}
 #session-list .col-md-4:nth-child(3n+1) {
   clear: left;
 }
-.section-title-catalog{
-  padding-bottom: 10px;
-  border-bottom: 1px solid #ddd;
-  margin-bottom: 10px;
-  text-transform: uppercase;
-}
 #session-list .title-session{
   font-size: 14px;
   line-height: 1.2;

+ 15 - 12
main/auth/courses_controller.php

@@ -514,14 +514,15 @@ class CoursesController
             ]);
 
             return Display::toolbarButton(
-                get_lang('CheckRequirements'),
+                null,
                 $url,
-                'check-circle',
-                'primary',
+                'shield',
+                'default',
                 [
-                    'class' => 'btn-lg btn-block ajax',
+                    'class' => 'btn-sm ajax',
                     'data-title' => get_lang('CheckRequirements'),
-                    'data-size' => 'md'
+                    'data-size' => 'md',
+                    'title' => get_lang('CheckRequirements')
                 ]
             );
         }
@@ -544,14 +545,15 @@ class CoursesController
             ]);
 
             $result = Display::toolbarButton(
-                get_lang('Subscribe'),
+                null,
                 $url,
-                'check-circle',
-                'primary',
+                'sign-in',
+                'success',
                 [
-                    'class' => 'btn-lg btn-block ajax',
+                    'class' => 'btn-sm ajax',
                     'data-title' => get_lang('AreYouSureToSubscribe'),
-                    'data-size' => 'md'
+                    'data-size' => 'md',
+                    'title' => get_lang('Subscribe')
                 ]
             );
         } else {
@@ -595,7 +597,7 @@ class CoursesController
 
         return Display::div(
             $icon,
-            array('class' => 'btn btn-default btn-sm', 'title' => get_lang("AlreadyRegisteredToSession"))
+            array('class' => 'btn btn-default btn-sm registered', 'title' => get_lang("AlreadyRegisteredToSession"))
         );
     }
 
@@ -747,7 +749,7 @@ class CoursesController
                 '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 = [];
@@ -814,6 +816,7 @@ class CoursesController
                     $hasRequirements
                 ),
                 'show_description' => $session->getShowDescription(),
+                'description' => $session->getDescription(),
                 'category' => $session->getCategory()->getName(),
                 'tags' => $sessionCourseTags,
                 'edit_actions' => $actions

+ 60 - 0
main/inc/lib/internationalization.lib.php

@@ -470,6 +470,66 @@ function api_get_local_time(
     }
 }
 
+/**
+ * Returns a DATETIME string converted to the right timezone
+ * @param mixed The time to be converted
+ * @param string The timezone to be converted to.
+ * If null, the timezone will be determined based on user preference,
+ * or timezone chosen by the admin for the platform.
+ * @param string The timezone to be converted from. If null, UTC will be assumed.
+ * @param boolen view time in formatted
+ * @return string The converted time formatted as Y-m-d H:i:s
+ *
+ * @author Guillaume Viguier <guillaume.viguier@beeznest.com>
+ */
+function apiGetTimeForHumans(
+    $time = null,
+    $to_timezone = null,
+    $from_timezone = null,
+    $return_null_if_invalid_date = false,
+    $showTime = true
+) {
+    // Determining the timezone to be converted from
+    if (is_null($from_timezone)) {
+        $from_timezone = 'UTC';
+    }
+
+    // Determining the timezone to be converted to
+    if (is_null($to_timezone)) {
+        $to_timezone = _api_get_timezone();
+    }
+
+    // If time is a timestamp, convert it to a string
+    if (is_null($time) || empty($time) || $time == '0000-00-00 00:00:00') {
+        if ($return_null_if_invalid_date) {
+            return null;
+        }
+        $from_timezone = 'UTC';
+        $time = gmdate('Y-m-d H:i:s');
+    }
+    if (is_numeric($time)) {
+        $time = intval($time);
+        $from_timezone = 'UTC';
+        $time = gmdate('Y-m-d H:i:s', $time);
+    }
+    if ($time instanceof DateTime) {
+        $time = $time->format('Y-m-d H:i:s');
+        $from_timezone = 'UTC';
+    }
+    try {
+        $date = new DateTime($time, new DateTimezone($from_timezone));
+        $date->setTimezone(new DateTimeZone($to_timezone));
+        if($showTime){
+            return $date->format('j M Y, g:i a'); 
+        }else{
+            return $date->format('j M Y'); 
+        }
+    } catch (Exception $e) {
+
+        return null;
+    }
+}
+
 /**
  * Converts a string into a timestamp safely (handling timezones), using strtotime
  *

+ 2 - 4
main/inc/lib/sessionmanager.lib.php

@@ -6591,10 +6591,10 @@ class SessionManager
         $endDateToLocal = '';
         // This will clean the variables if 0000-00-00 00:00:00 the variable will be empty
         if (isset($startDateToLocal)) {
-            $startDateToLocal = api_get_local_time($startDate, null, null, true);
+            $startDateToLocal = apiGetTimeForHumans($startDate, null, null, true, false);
         }
         if (isset($endDateToLocal)) {
-            $endDateToLocal = api_get_local_time($endDate, null, null, true);
+            $endDateToLocal = apiGetTimeForHumans($endDate, null, null, true, false);
         }
 
         $result = '';
@@ -6615,7 +6615,6 @@ class SessionManager
 
         return $result;
     }
-
     /**
      * Returns a human readable string
      * @params array $sessionInfo An array with all the session dates
@@ -6627,7 +6626,6 @@ class SessionManager
             $sessionInfo['display_start_date'],
             $sessionInfo['display_end_date']
         );
-
         $accessDates = self::convertSessionDateToString(
             $sessionInfo['access_start_date'],
             $sessionInfo['access_end_date']

+ 34 - 37
main/template/default/auth/session_catalog.tpl

@@ -13,7 +13,7 @@
         <div class="row">
             {% if show_courses %}
                 <div class="col-md-4">
-                    <div class="section-title-catalog">{{ 'Courses'|get_lang }}</div>
+                    <div class="section-title-catalog>{{ 'Courses'|get_lang }}</div>
                     {% if not hidden_links %}
                         <form class="form-horizontal" method="post" action="{{ course_url }}">
                             <div class="form-group">
@@ -33,49 +33,43 @@
                 </div>
             {% endif %}
 
-            <div class="col-md-8">
+            <div class="col-md-{{ show_sessions ? '12' : '8' }}">
                 {% if show_sessions %}
-                    <div class="section-title-catalog">{{ 'Sessions'|get_lang }}</div>
-
+                    <h3>{{ 'Sessions'|get_lang }}</h3>
+                    <div class="search-session">
                     <div class="row">
                         <div class="col-md-6">
-                            <form class="form-horizontal" method="post" action="{{ _p.web_self }}?action=display_sessions">
-                                <div class="form-group">
-                                    <label class="col-sm-3">{{ "ByDate"|get_lang }}</label>
-                                    <div class="col-sm-9">
-                                        <div class="input-group">
-                                            <input type="date" name="date" id="date" class="form-control" value="{{ search_date }}" readonly>
-                                            <span class="input-group-btn">
-                                                <button class="btn btn-default" type="submit"><em class="fa fa-search"></em> {{ 'Search'|get_lang }}</button>
-                                            </span>
-                                        </div>
-                                    </div>
+                            <form class="form-inline" method="post" action="{{ _p.web_self }}?action=display_sessions">
+                            <div class="form-group">
+                                <label>{{ "ByDate"|get_lang }}</label>
+                                <div class="input-group">
+                                    <input type="date" name="date" id="date" class="form-control" value="{{ search_date }}" readonly>
+                                    <span class="input-group-btn">
+                                        <button class="btn btn-default" type="submit"><em class="fa fa-search"></em> {{ 'Search'|get_lang }}</button>
+                                    </span>
                                 </div>
+                            </div>
                             </form>
                         </div>
                         <div class="col-md-6">
-                            <form class="form-horizontal" method="post" action="{{ _p.web_self }}?action=search_tag">
-                                <div class="form-group">
-                                    <label class="col-sm-4">{{ "ByTag"|get_lang }}</label>
-                                    <div class="col-sm-8">
-                                        <div class="input-group">
-                                            <input type="text" name="search_tag" class="form-control" value="{{ search_tag }}" />
-                                            <span class="input-group-btn">
-                                                <button class="btn btn-default" type="submit"><em class="fa fa-search"></em> {{ 'Search'|get_lang }}</button>
-                                            </span>
-                                        </div>
-                                    </div>
-                                </div>
-                            </form>
+                            <form class="form-inline" method="post" action="{{ _p.web_self }}?action=search_tag">
+                            <label>{{ "ByTag"|get_lang }}</label>
+                             <div class="input-group">
+                                <input type="text" name="search_tag" class="form-control" value="{{ search_tag }}" />
+                                <span class="input-group-btn">
+                                    <button class="btn btn-default" type="submit"><em class="fa fa-search"></em> {{ 'Search'|get_lang }}</button>
+                                </span>
+                            </div>     
+                            </form>    
                         </div>
                     </div>
+                    </div>
                 {% endif %}
             </div>
         </div>
     </div>
-
 <!-- new view session grib -->
-<div class="grid-courses">
+<div class="grid-courses col-md-12">
     <div class="row">
         {% for item in sessions %}
         <div class="col-md-3 col-sm-6 col-xs-6">
@@ -102,18 +96,23 @@
                         </div>
                         {% endif %}
                         <div class="session-date">
-                            {{ item.date }}
+                            <i class="fa fa-calendar-o" aria-hidden="true"></i> {{ item.date }}
                         </div>
                     </div>
-                    {% if item.edit_actions != '' %}
+                    
                     <div class="admin-actions">
                         <div class="btn-group" role="group">
+                            {% if item.edit_actions != '' %}
                             <a class="btn btn-default btn-sm" href="{{ item.edit_actions }}">
                                 <i class="fa fa-pencil" aria-hidden="true"></i>
                             </a>
+                            {% endif %}
+                            {% if item.is_subscribed %}
+                                {{ already_subscribed_label }}
+                            {% endif %}
                         </div> 
                     </div>
-                    {% endif %}
+                    
                 </div>
                 <div class="description">
                     <h4 class="title">
@@ -121,7 +120,7 @@
                             {{ item.name }}
                         </a>
                     </h4>
-                    <div class="options">
+                    <div class="toolbar">
                         {% if not _u.logged %}
                             &nbsp;
                         {% else %}
@@ -131,9 +130,7 @@
                             {% else %}
                                 <a class="btn btn-default btn-sm" role="button" title="{{ 'SeeSequences'|get_lang }}" data-toggle="popover" id="session-{{ item.id }}-sequences"><i class="fa fa-sitemap" aria-hidden="true"></i></a>
                             {% endif %}
-                            {% if item.is_subscribed %}
-                                {{ already_subscribed_label }}
-                            {% else %}
+                            {% if item.is_subscribed == false %}
                                 {{ item.subscribe_button }}
                             {% endif %}
                         </div>