예제 #1
0
    $form .= '</div>';
    $from .= '</form>';
    echo $form;
    ?>
    </div>
    </div>
<?php 
    if ($showSessions) {
        ?>
            <div class="col-md-4">
                <h5><?php 
        echo get_lang('Sessions');
        ?>
</h5>
                <a class="btn btn-default btn-block" href="<?php 
        echo getCourseCategoryUrl(1, $pageLength, null, 0, 'display_sessions');
        ?>
"><?php 
        echo get_lang('SessionList');
        ?>
</a>
            </div>
        <?php 
    }
    ?>
</div>
 <?php 
}
?>
<div class="row"> 
 <?php 
 /**
  * Show the Session Catalogue with filtered session by a query term
  * @param array $limit
  */
 public function sessionListBySearch(array $limit)
 {
     $q = isset($_REQUEST['q']) ? Security::remove_XSS($_REQUEST['q']) : null;
     $hiddenLinks = isset($_GET['hidden_links']) ? intval($_GET['hidden_links']) == 1 : false;
     $courseUrl = getCourseCategoryUrl(1, $limit['length'], null, 0, 'subscribe');
     $searchDate = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d');
     $sessions = $this->model->browseSessionsBySearch($q, $limit);
     $sessionsBlocks = $this->getFormatedSessionsBlock($sessions);
     $tpl = new Template();
     $tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses());
     $tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions());
     $tpl->assign('show_tutor', api_get_setting('show_session_coach') === 'true' ? true : false);
     $tpl->assign('course_url', $courseUrl);
     $tpl->assign('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel());
     $tpl->assign('hidden_links', $hiddenLinks);
     $tpl->assign('search_token', Security::get_token());
     $tpl->assign('search_date', Security::remove_XSS($searchDate));
     $tpl->assign('search_tag', Security::remove_XSS($q));
     $tpl->assign('sessions', $sessionsBlocks);
     $contentTemplate = $tpl->get_template('auth/session_catalog.tpl');
     $tpl->display($contentTemplate);
 }
            }
            }
            ?>
            <?php if ($showSessions) { ?>
                <div class="well">
                    <ul class="nav nav-list">
                        <li class="nav-header"><?php echo get_lang('Sessions'); ?></li>
                        <li>
                            <?php if ($action == 'display_sessions' && $_SERVER['REQUEST_METHOD'] != 'POST') { ?>
                                <strong><?php echo get_lang('Sessions'); ?></strong>
                            <?php } else { ?>
                                <a href="<?php echo getCourseCategoryUrl(1, $pageLength, null, 0, 'display_sessions'); ?>"><?php echo get_lang('SessionList'); ?></a>
                            <?php } ?>
                        </li>
                        <li class="nav-header"><?php echo get_lang('SearchActiveSessions') ?></li>
                        <form class="form-search" method="post" action="<?php echo getCourseCategoryUrl(1, $pageLength, null, 0, 'display_sessions'); ?>">
                            <div class="input-append">
                                <?php echo Display::input('date', 'date', $date, array(
                                    'class' => 'span2',
                                    'id' => 'date',
                                    'readonly' => ''
                                )); ?>
                                <button class="btn" type="submit"><?php echo get_lang('Search'); ?></button>
                            </div>
                        </form>
                    </ul>
                </div>
            <?php } ?>
        </div>

        <div class="span9">
/**
 * Get li HTML of page number
 * @param $pageNumber
 * @param $pageLength
 * @param array $liAttributes
 * @param string $content
 * @return string
 */
function getPageNumberItem($pageNumber, $pageLength, $liAttributes = array(), $content = '')
{
    // Get page URL
    $url = getCourseCategoryUrl($pageNumber, $pageLength);
    // If is current page ('active' class) clear URL
    if (isset($liAttributes) && is_array($liAttributes)) {
        if (strpos('active', $liAttributes['class']) !== false) {
            $url = '';
        }
    }
    $content = !empty($content) ? $content : $pageNumber;
    return Display::tag('li', Display::url($content, $url), $liAttributes);
}
 /**
  * Return Session Catalogue rendered view
  * @param string $action
  * @param string $nameTools
  * @param array $limit
  */
 public function sessionsList($action, $nameTools, $limit = array())
 {
     $date = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d');
     $hiddenLinks = isset($_GET['hidden_links']) ? intval($_GET['hidden_links']) == 1 : false;
     $limit = isset($limit) ? $limit : getLimitArray();
     $countSessions = $this->model->countSessions($date);
     $sessions = $this->model->browseSessions($date, $limit);
     $pageTotal = intval(ceil(intval($countSessions) / $limit['length']));
     // Do NOT show pagination if only one page or less
     $cataloguePagination = $pageTotal > 1 ? getCataloguePagination($limit['current'], $limit['length'], $pageTotal) : '';
     $sessionsBlocks = array();
     // Get session list catalogue URL
     $sessionUrl = getCourseCategoryUrl(1, $limit['length'], null, 0, 'display_sessions');
     // Get session search catalogue URL
     $courseUrl = getCourseCategoryUrl(1, $limit['length'], null, 0, 'subscribe');
     foreach ($sessions as $session) {
         $sessionsBlocks[] = array('id' => $session['id'], 'name' => $session['name'], 'nbr_courses' => $session['nbr_courses'], 'nbr_users' => $session['nbr_users'], 'coach_name' => $session['coach_name'], 'is_subscribed' => $session['is_subscribed'], 'icon' => $this->getSessionIcon($session['name']), 'date' => SessionManager::getSessionFormattedDate($session), 'subscribe_button' => $this->getRegisterInSessionButton($session['name']));
     }
     $tpl = new Template();
     $tpl->assign('action', $action);
     $tpl->assign('showCourses', CoursesAndSessionsCatalog::showCourses());
     $tpl->assign('showSessions', CoursesAndSessionsCatalog::showSessions());
     $tpl->assign('api_get_self', api_get_self());
     $tpl->assign('sessionUrl', $sessionUrl);
     $tpl->assign('courseUrl', $courseUrl);
     $tpl->assign('nameTools', $nameTools);
     $tpl->assign('coursesCategoriesList', $this->getCoursesCategoriesBlock(null, false, $limit));
     $tpl->assign('cataloguePagination', $cataloguePagination);
     $tpl->assign('hiddenLinks', $hiddenLinks);
     $tpl->assign('searchToken', Security::get_token());
     $tpl->assign('searchDate', $date);
     $tpl->assign('web_session_courses_ajax_url', api_get_path(WEB_AJAX_PATH) . 'course.ajax.php');
     $tpl->assign('sessions_blocks', $sessionsBlocks);
     $tpl->assign('already_subscribed_label', $this->getAlreadyRegisterInSessionLabel());
     $contentTemplate = $tpl->get_template('auth/sessions_catalog.tpl');
     $tpl->display($contentTemplate);
 }