本文整理汇总了PHP中Display::div方法的典型用法代码示例。如果您正苦于以下问题:PHP Display::div方法的具体用法?PHP Display::div怎么用?PHP Display::div使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Display
的用法示例。
在下文中一共展示了Display::div方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAlreadyRegisteredInSessionLabel
/**
* Generate a label if the user has been registered in session
* @return string The label
*/
public function getAlreadyRegisteredInSessionLabel()
{
$icon = '<em class="fa fa-smile-o"></em>';
return Display::div($icon . ' ' . get_lang("AlreadyRegisteredToSession"), array('class' => 'info-catalog'));
}
示例2: api_get_path
$minutes = 60;
$url = api_get_path(WEB_AJAX_PATH) . 'exercise.ajax.php?a=get_live_stats&exercise_id=' . $objExercise->id . '&minutes=' . $minutes;
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('Time'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score'));
//Column config
$column_model = array(array('name' => 'firstname', 'index' => 'firstname', 'width' => '100', 'align' => 'left'), array('name' => 'lastname', 'index' => 'lastname', 'width' => '100', 'align' => 'left'), array('name' => 'start_date', 'index' => 'start_date', 'width' => '100', 'align' => 'left'), array('name' => 'question', 'index' => 'count_questions', 'width' => '60', 'align' => 'left', 'sortable' => 'false'), array('name' => 'score', 'index' => 'score', 'width' => '50', 'align' => 'left', 'sortable' => 'false'));
//Autowidth
$extra_params['autowidth'] = 'true';
//height auto
$extra_params['height'] = 'auto';
?>
<script>
function refreshGrid() {
var grid = $("#live_stats");
grid.trigger("reloadGrid");
t = setTimeout("refreshGrid()", 10000);
}
$(function() {
<?php
echo Display::grid_js('live_stats', $url, $columns, $column_model, $extra_params, array(), null, true);
?>
refreshGrid();
});
</script>
<?php
$actions = '<a href="exercise_report.php?exerciseId=' . intval($_GET['exerciseId']) . '&' . api_get_cidreq() . '">' . Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM) . '</a>';
echo $actions = Display::div($actions, array('class' => 'actions'));
echo Display::grid_html('live_stats');
Display::display_footer();
示例3: returnCategoryForm
/**
* Returns the category form.
* @param Exercise $exercise_obj
* @return string
*/
public function returnCategoryForm(Exercise $exercise_obj)
{
$categories = $this->getListOfCategoriesForTest($exercise_obj);
$saved_categories = $exercise_obj->get_categories_in_exercise();
$return = null;
if (!empty($categories)) {
$nbQuestionsTotal = $exercise_obj->getNumberQuestionExerciseCategory();
$exercise_obj->setCategoriesGrouping(true);
$real_question_count = count($exercise_obj->getQuestionList());
$warning = null;
if ($nbQuestionsTotal != $real_question_count) {
$warning = Display::return_message(get_lang('CheckThatYouHaveEnoughQuestionsInYourCategories'), 'warning');
}
$return .= $warning;
$return .= '<table class="data_table">';
$return .= '<tr>';
$return .= '<th height="24">' . get_lang('Categories') . '</th>';
$return .= '<th width="70" height="24">' . get_lang('Number') . '</th></tr>';
foreach ($categories as $category) {
$cat_id = $category['iid'];
$return .= '<tr>';
$return .= '<td>';
$return .= Display::div($category['parent_path']);
$return .= '</td>';
$return .= '<td>';
$value = isset($saved_categories) && isset($saved_categories[$cat_id]) ? $saved_categories[$cat_id]['count_questions'] : -1;
$return .= '<input name="category[' . $cat_id . ']" value="' . $value . '" />';
$return .= '</td>';
$return .= '</tr>';
}
$return .= '</table>';
$return .= get_lang('ZeroMeansNoQuestionWillBeSelectedMinusOneMeansThatAllQuestionsWillBeSelected');
return $return;
}
}
示例4: display_message_for_group
/**
* Displays messages of a group with nested view
* @param $group_id
* @param $topic_id
* @param $is_member
* @param $message_id
* @return string
*/
public static function display_message_for_group($group_id, $topic_id, $is_member, $message_id)
{
global $my_group_role;
$main_message = self::get_message_by_id($topic_id);
if (empty($main_message)) {
return false;
}
$rows = self::get_messages_by_group_by_message($group_id, $topic_id);
$rows = self::calculate_children($rows, $topic_id);
$current_user_id = api_get_user_id();
$items_per_page = 50;
$query_vars = array('id' => $group_id, 'topic_id' => $topic_id, 'topics_page_nr' => 0);
// Main message
$links = '';
$main_content = '';
$items_page_nr = null;
$html = '';
$delete_button = '';
if (api_is_platform_admin()) {
$delete_button = Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), 'group_topics.php?action=delete&id=' . $group_id . '&topic_id=' . $topic_id);
}
$html .= Display::page_subheader(Security::remove_XSS($main_message['title'] . $delete_button, STUDENT, true));
$user_sender_info = api_get_user_info($main_message['user_sender_id']);
$files_attachments = self::get_links_message_attachment_files($main_message['id']);
$name = $user_sender_info['complete_name'];
$topic_page_nr = isset($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : null;
$links .= '<div id="message-reply-link">';
if ($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR || $main_message['user_sender_id'] == $current_user_id) {
$urlEdit = api_get_path(WEB_CODE_PATH);
$urlEdit .= 'social/message_for_group_form.inc.php?';
$urlEdit .= http_build_query(['user_friend' => $current_user_id, 'group_id' => $group_id, 'message_id' => $main_message['id'], 'action' => 'edit_message_group', 'anchor_topic' => 'topic_' . $main_message['id'], 'topics_page_nr' => $topic_page_nr, 'items_page_nr' => $items_page_nr, 'topic_id' => $main_message['id']]);
$links .= Display::url(Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL), $urlEdit, ['class' => 'ajax btn btn-default', 'title' => get_lang('Edit'), 'data-title' => get_lang('Edit'), 'data-size' => 'lg']);
}
$urlReply = api_get_path(WEB_CODE_PATH);
$urlReply .= 'social/message_for_group_form.inc.php?';
$urlReply .= http_build_query(['user_friend' => api_get_user_id(), 'group_id' => $group_id, 'message_id' => $main_message['id'], 'action' => 'reply_message_group', 'anchor_topic' => 'topic_' . $main_message['id'], 'topics_page_nr' => $topic_page_nr, 'topic_id' => $main_message['id']]);
$links .= Display::url(Display::return_icon('talk.png', get_lang('Reply')), $urlReply, ['class' => 'ajax btn btn-default', 'title' => get_lang('Reply'), 'data-title' => get_lang('Reply'), 'data-size' => 'lg']);
$links .= '</div>';
$userPicture = $user_sender_info['avatar'];
$main_content .= '<div class="message-group-author">
<img src="' . $userPicture . '" alt="' . $name . '" width="32" height="32" title="' . $name . '" /></div>';
$user_link = '<a href="' . api_get_path(WEB_PATH) . 'main/social/profile.php?u=' . $main_message['user_sender_id'] . '">' . $name . ' </a>';
$date = '';
if ($main_message['send_date'] != $main_message['update_date']) {
if (!empty($main_message['update_date']) && $main_message['update_date'] != '0000-00-00 00:00:00') {
$date = '<div class="message-group-date"> ' . get_lang('LastUpdate') . ' ' . date_to_str_ago($main_message['update_date']) . '</div>';
}
} else {
$date = '<div class="message-group-date"> ' . get_lang('Created') . ' ' . date_to_str_ago($main_message['send_date']) . '</div>';
}
$attachment = '<div class="message-attach">' . (!empty($files_attachments) ? implode('<br />', $files_attachments) : '') . '</div>';
$main_content .= '<div class="message-group-content">' . $links . $user_link . ' ' . $date . $main_message['content'] . $attachment . '</div>';
$main_content = Security::remove_XSS($main_content, STUDENT, true);
$html .= Display::div(Display::div(Display::div($main_content, array('class' => 'group_social_sub_item', 'style' => 'background-color:#fff;')), array('class' => 'group_social_item')), array('class' => 'group_social_grid'));
$topic_id = $main_message['id'];
if (is_array($rows) && count($rows) > 0) {
$topics = $rows;
$array_html_items = array();
foreach ($topics as $index => $topic) {
if (empty($topic['id'])) {
continue;
}
$items_page_nr = isset($_GET['items_' . $topic['id'] . '_page_nr']) ? intval($_GET['items_' . $topic['id'] . '_page_nr']) : null;
$links = '';
$html_items = '';
$user_sender_info = api_get_user_info($topic['user_sender_id']);
$files_attachments = self::get_links_message_attachment_files($topic['id']);
$name = $user_sender_info['complete_name'];
$links .= '<div id="message-reply-link">';
if ($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR || $topic['user_sender_id'] == $current_user_id) {
$links .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'social/message_for_group_form.inc.php?height=400&width=800&&user_friend=' . $current_user_id . '&group_id=' . $group_id . '&message_id=' . $topic['id'] . '&action=edit_message_group&anchor_topic=topic_' . $topic_id . '&topics_page_nr=' . $topic_page_nr . '&items_page_nr=' . $items_page_nr . '&topic_id=' . $topic_id . '" class="ajax btn" data-size="lg" data-title="' . get_lang('Edit') . '" title="' . get_lang('Edit') . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
}
$links .= ' <a href="' . api_get_path(WEB_CODE_PATH) . 'social/message_for_group_form.inc.php?height=400&width=800&&user_friend=' . api_get_user_id() . '&group_id=' . $group_id . '&message_id=' . $topic['id'] . '&action=reply_message_group&anchor_topic=topic_' . $topic_id . '&topics_page_nr=' . $topic_page_nr . '&items_page_nr=' . $items_page_nr . '&topic_id=' . $topic_id . '" class="ajax btn" data-size="lg" data-title="' . get_lang('Reply') . '" title="' . get_lang('Reply') . '">';
$links .= Display::return_icon('talk.png', get_lang('Reply')) . '</a>';
$links .= '</div>';
$userPicture = $user_sender_info['avatar'];
$html_items .= '<div class="message-group-author"><img src="' . $userPicture . '" alt="' . $name . '" width="32" height="32" title="' . $name . '" /></div>';
$user_link = '<a href="' . api_get_path(WEB_PATH) . 'main/social/profile.php?u=' . $topic['user_sender_id'] . '">' . $name . ' </a>';
$date = '';
if ($topic['send_date'] != $topic['update_date']) {
if (!empty($topic['update_date']) && $topic['update_date'] != '0000-00-00 00:00:00') {
$date = '<div class="message-group-date"> ' . get_lang('LastUpdate') . ' ' . date_to_str_ago($topic['update_date']) . '</div>';
}
} else {
$date = '<div class="message-group-date"> ' . get_lang('Created') . ' ' . date_to_str_ago($topic['send_date']) . '</div>';
}
$attachment = '<div class="message-attach">' . (!empty($files_attachments) ? implode('<br />', $files_attachments) : '') . '</div>';
$html_items .= '<div class="message-group-content">' . $links . $user_link . ' ' . $date . Security::remove_XSS($topic['content'], STUDENT, true) . $attachment . '</div>';
$base_padding = 20;
if ($topic['indent_cnt'] == 0) {
$indent = $base_padding;
} else {
//.........这里部分代码省略.........
示例5: api_get_course_info
// if course is public, go to course without auth
$tab_course_info = api_get_course_info($firstpage);
api_set_firstpage_parameter($firstpage);
$tpl = new Template(null, 1, 1);
$action = api_get_self() . '?' . Security::remove_XSS($_SERVER['QUERY_STRING']);
$action = str_replace('&', '&', $action);
$form = new FormValidator('formLogin', 'post', $action, null, array('class' => 'form-stacked'));
$form->addElement('text', 'login', null, array('placeholder' => get_lang('UserName'), 'class' => 'span3 autocapitalize_off'));
//new
$form->addElement('password', 'password', null, array('placeholder' => get_lang('Password'), 'class' => 'span3'));
//new
$form->addElement('style_submit_button', 'submitAuth', get_lang('LoginEnter'), array('class' => 'btn span3'));
// see same text in main_api.lib.php function api_not_allowed
if (api_is_cas_activated()) {
$msg .= Display::return_message(sprintf(get_lang('YouHaveAnInstitutionalAccount'), api_get_setting("Institution")), '', false);
$msg .= Display::div("<br/><a href='" . get_cas_direct_URL(api_get_course_id()) . "'>" . getCASLogoHTML() . " " . sprintf(get_lang('LoginWithYourAccount'), api_get_setting("Institution")) . "</a><br/><br/>", array('align' => 'center'));
$msg .= Display::return_message(get_lang('YouDontHaveAnInstitutionAccount'));
$msg .= "<p style='text-align:center'><a href='#' onclick='\$(this).parent().next().toggle()'>" . get_lang('LoginWithExternalAccount') . "</a></p>";
$msg .= "<div style='display:none;'>";
}
$msg .= '<div class="well_login">';
$msg .= $form->return_form();
$msg .= '</div>';
if (api_is_cas_activated()) {
$msg .= "</div>";
}
$msg .= '<hr/><p style="text-align:center"><a href="' . api_get_path(WEB_PATH) . '">' . get_lang('ReturnToCourseHomepage') . '</a></p>';
$tpl->assign('content', '<h4>' . get_lang('LoginToGoToThisCourse') . '</h4>' . $msg);
$tpl->display_one_col_template();
} else {
api_delete_firstpage_parameter();
示例6: count
$result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
$id = $result['id'];
$url_open = '<a href="group_view.php?id=' . $id . '">';
$url_close = '</a>';
$count_users_group = count($usergroup->get_users_by_group($id, false, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR), 0, 1000));
if ($count_users_group == 1) {
$count_users_group = $count_users_group . ' ' . get_lang('Member');
} else {
$count_users_group = $count_users_group . ' ' . get_lang('Members');
}
$name = cut($result['name'], GROUP_TITLE_LENGTH, true);
$picture = $usergroup->get_picture_group($result['id'], $result['picture'], 80);
$result['picture'] = '<img class="social-groups-image" src="' . $picture['file'] . '" />';
$item_0 = Display::div($result['picture'], array('class' => 'box_description_group_image'));
$members = Display::span($count_users_group, array('class' => 'box_description_group_member'));
$item_1 = Display::div(Display::tag('h4', $url_open . $name . $url_close) . $members, array('class' => 'box_description_group_title'));
if ($result['description'] != '') {
$item_3 = '<div class="box_description_group_content" >' . cut($result['description'], 100, true) . '</div>';
} else {
$item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
$item_3 = '<div class="box_description_group_content" ></div>';
}
$join_url = '';
if (!in_array($id, $my_group_list)) {
$join_url = '<a class="btn" href="group_view.php?id=' . $id . '&action=join&u=' . api_get_user_id() . '">' . get_lang('JoinGroup') . '</a> ';
}
$item_4 = '<div class="box_description_group_actions" >' . $join_url . '</div>';
$grid_item_2 = $item_0 . $item_1 . $item_2 . $item_3 . $item_4;
$grid_pop_groups[] = array($grid_item_2);
}
}
示例7: print_recursive
function print_recursive($elements, $default_data, $default_content)
{
$return = '';
foreach ($elements as $key => $item) {
if (isset($item['load_data']) || empty($item['data'])) {
$item['data'] = $default_data[$item['load_data']];
$item['type'] = $default_content[$item['load_data']]['item_type'];
}
$sub_list = '';
if (isset($item['type']) && $item['type'] == 'dokeos_chapter') {
$sub_list = Display::tag('li', '', array('class' => 'sub_item empty'));
// empty value
}
if (empty($item['children'])) {
$sub_list = Display::tag('ul', $sub_list, array('id' => 'UL_' . $key, 'class' => 'record li_container'));
$active = null;
if (isset($_REQUEST['id']) && $key == $_REQUEST['id']) {
$active = 'active';
}
$return .= Display::tag('li', Display::div($item['data'], array('class' => "item_data {$active}")) . $sub_list, array('id' => $key, 'class' => 'record li_container'));
} else {
//sections
if (isset($item['children'])) {
$data = self::print_recursive($item['children'], $default_data, $default_content);
}
$sub_list = Display::tag('ul', $sub_list . $data, array('id' => 'UL_' . $key, 'class' => 'record li_container'));
$return .= Display::tag('li', Display::div($item['data'], array('class' => 'item_data')) . $sub_list, array('id' => $key, 'class' => 'record li_container'));
}
}
return $return;
}
示例8: displayCourses
/**
* @param int $user_id
* @param $filter
* @param bool $load_dirs
* @param int $getCount
* @param int $start
* @param null $maxPerPage
* @return null|string
*/
public static function displayCourses($user_id, $filter, $load_dirs, $getCount, $start = null, $maxPerPage = null)
{
// Table definitions
$TABLECOURS = Database::get_main_table(TABLE_MAIN_COURSE);
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TABLE_ACCESS_URL_REL_COURSE = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$current_url_id = api_get_current_access_url_id();
// Get course list auto-register
$special_course_list = self::get_special_course_list();
$without_special_courses = '';
if (!empty($special_course_list)) {
//$without_special_courses = ' AND course.code NOT IN ("'.implode('","',$special_course_list).'")';
}
$select = " SELECT DISTINCT\n course.id,\n course.title,\n course.code,\n course.subscribe subscr,\n course.unsubscribe unsubscr,\n course_rel_user.status status,\n course_rel_user.sort sort,\n course_rel_user.user_course_cat user_course_cat,\n course.id as real_id\n ";
$from = "{$TABLECOURS} course, {$TABLECOURSUSER} course_rel_user, {$TABLE_ACCESS_URL_REL_COURSE} url ";
$where = " course.id = course_rel_user.c_id AND\n url.c_id = course.id AND\n course_rel_user.user_id = '" . $user_id . "' AND\n course_rel_user.user_course_cat = 0\n ";
$order = " ORDER BY course_rel_user.user_course_cat, course_rel_user.sort ASC";
if ($getCount) {
$select = "SELECT count(course.id) as total";
}
$sql = "{$select} FROM {$from} WHERE {$where} {$without_special_courses} ";
// corresponding to the current URL.
if (api_get_multiple_access_url() && $current_url_id != -1) {
$sql .= " AND url.c_id = course.id AND access_url_id='" . $current_url_id . "'";
}
$sql .= $order;
if (isset($start) && isset($maxPerPage)) {
$start = intval($start);
$maxPerPage = intval($maxPerPage);
$limitCondition = " LIMIT {$start}, {$maxPerPage}";
$sql .= $limitCondition;
}
if ($getCount) {
$result = Database::query($sql);
$row = Database::fetch_array($result);
return $row['total'];
}
$result = Database::query($sql);
$html = null;
$course_list = array();
// Browse through all courses.
while ($course = Database::fetch_array($result)) {
$course_info = api_get_course_info($course['code']);
$course_info['id_session'] = null;
$course_info['status'] = $course['status'];
//In order to avoid doubles
if (in_array($course_info['real_id'], $course_list)) {
continue;
} else {
$course_list[] = $course_info['real_id'];
}
// For each course, get if there is any notification icon to show
// (something that would have changed since the user's last visit).
$show_notification = Display::show_notification($course_info);
// New code displaying the user's status in respect to this course.
$status_icon = Display::return_icon('blackboard.png', $course_info['title'], array(), ICON_SIZE_LARGE);
$params = array();
$params['right_actions'] = '';
if (api_is_platform_admin()) {
if ($load_dirs) {
$params['right_actions'] .= '<a id="document_preview_' . $course_info['real_id'] . '_0" class="document_preview" href="javascript:void(0);">' . Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>';
$params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>';
$params['right_actions'] .= Display::div('', array('id' => 'document_result_' . $course_info['real_id'] . '_0', 'class' => 'document_preview_container'));
} else {
$params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>';
}
if ($course_info['status'] == COURSEMANAGER) {
//echo Display::return_icon('teachers.gif', get_lang('Status').': '.get_lang('Teacher'), array('style'=>'width: 11px; height: 11px;'));
}
} else {
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) {
if ($load_dirs) {
$params['right_actions'] .= '<a id="document_preview_' . $course_info['real_id'] . '_0" class="document_preview" href="javascript:void(0);">' . Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>';
$params['right_actions'] .= Display::div('', array('id' => 'document_result_' . $course_info['real_id'] . '_0', 'class' => 'document_preview_container'));
} else {
if ($course_info['status'] == COURSEMANAGER) {
$params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>';
}
}
}
}
$course_title_url = '';
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED || $course['status'] == COURSEMANAGER) {
//$course_title_url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?id_session=0';
$course_title_url = api_get_path(WEB_COURSE_PATH) . $course_info['code'] . '/index.php?id_session=0';
$course_title = Display::url($course_info['title'], $course_title_url);
} else {
$course_title = $course_info['title'] . " " . Display::tag('span', get_lang('CourseClosed'), array('class' => 'item_closed'));
}
// Start displaying the course block itself
if (api_get_setting('course.display_coursecode_in_courselist') == 'true') {
//.........这里部分代码省略.........
示例9: array
if (count($grid_pop_groups) > 0) {
$popular_content = Display::return_sortable_grid(
'mygroups',
array(),
$grid_pop_groups,
array('hide_navigation' => true, 'per_page' => 100),
$query_vars,
false,
array(true, true, true, true, true)
);
}
}
if (!empty($create_group_item)) {
$social_right_content .= Display::div(
$create_group_item,
array('class' => 'span9')
);
}
$headers = array(
get_lang('Newest'),
get_lang('Popular'),
get_lang('MyGroups')
);
$social_right_content .= '<div class="span9">' . Display::tabs(
$headers,
array($newest_content, $popular_content, $my_group_content),
'tab_browse'
) . '</div>';
}
$show_message = null;
示例10: api_not_allowed
/**
* Displays message "You are not allowed here..." and exits the entire script.
* @param bool $print_headers Whether or not to print headers (default = false -> does not print them)
* @param string $message
*/
function api_not_allowed($print_headers = false, $message = null)
{
$message = get_lang('NotAllowed');
throw new Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException($message);
if (api_get_setting('sso_authentication') === 'true') {
global $osso;
if ($osso) {
$osso->logout();
}
}
$home_url = api_get_path(WEB_PATH);
$user_id = api_get_user_id();
$course = api_get_course_id();
global $this_section;
if (CustomPages::enabled() && !isset($user_id)) {
if (empty($user_id)) {
// Why the CustomPages::enabled() need to be to set the request_uri
$_SESSION['request_uri'] = $_SERVER['REQUEST_URI'];
}
CustomPages::display(CustomPages::INDEX_UNLOGGED);
}
$origin = isset($_GET['origin']) ? $_GET['origin'] : '';
$msg = null;
if (isset($message)) {
$msg = $message;
} else {
$msg = Display::return_message(get_lang('NotAllowedClickBack') . '<br/><br/><a href="' . $home_url . '">' . get_lang('ReturnToCourseHomepage') . '</a>', 'error', false);
}
$msg = Display::div($msg, array('align' => 'center'));
$show_headers = 0;
if ($print_headers && $origin != 'learnpath') {
$show_headers = 1;
}
$tpl = new Template(null, $show_headers, $show_headers);
$tpl->assign('hide_login_link', 1);
$tpl->assign('content', $msg);
if ($user_id != 0 && !api_is_anonymous() && (!isset($course) || $course == -1) && empty($_GET['cidReq'])) {
// if the access is not authorized and there is some login information
// but the cidReq is not found, assume we are missing course data and send the user
// to the user_portal
$tpl->display_one_col_template();
exit;
}
if (!empty($_SERVER['REQUEST_URI']) && (!empty($_GET['cidReq']) || $this_section == SECTION_MYPROFILE || $this_section == SECTION_PLATFORM_ADMIN)) {
$courseCode = api_get_course_id();
// Only display form and return to the previous URL if there was a course ID included
if ($user_id != 0 && !api_is_anonymous()) {
//if there is a user ID, then the user is not allowed but the session is still there. Say so and exit
$tpl->assign('content', $msg);
$tpl->display_one_col_template();
exit;
}
if (!is_null($courseCode)) {
api_set_firstpage_parameter($courseCode);
}
// If the user has no user ID, then his session has expired
$action = api_get_self() . '?' . Security::remove_XSS($_SERVER['QUERY_STRING']);
$action = str_replace('&', '&', $action);
$form = new FormValidator('formLogin', 'post', $action, null, array(), FormValidator::LAYOUT_BOX_NO_LABEL);
$form->addElement('text', 'login', null, array('placeholder' => get_lang('UserName'), 'class' => 'autocapitalize_off'));
$form->addElement('password', 'password', null, array('placeholder' => get_lang('Password')));
$form->addButton('submitAuth', get_lang('LoginEnter'), '', 'primary');
// see same text in auth/gotocourse.php and main_api.lib.php function api_not_allowed (above)
$content = Display::return_message(get_lang('NotAllowed'), 'error', false);
if (!empty($courseCode)) {
$content .= '<h4>' . get_lang('LoginToGoToThisCourse') . '</h4>';
}
if (api_is_cas_activated()) {
$content .= Display::return_message(sprintf(get_lang('YouHaveAnInstitutionalAccount'), api_get_setting("Institution")), '', false);
$content .= Display::div("<br/><a href='" . get_cas_direct_URL(api_get_course_id()) . "'>" . sprintf(get_lang('LoginWithYourAccount'), api_get_setting("Institution")) . "</a><br/><br/>", array('align' => 'center'));
$content .= Display::return_message(get_lang('YouDontHaveAnInstitutionAccount'));
$content .= "<p style='text-align:center'><a href='#' onclick='\$(this).parent().next().toggle()'>" . get_lang('LoginWithExternalAccount') . "</a></p>";
$content .= "<div style='display:none;'>";
}
$content .= '<div class="well_login">';
$content .= $form->return_form();
$content .= '</div>';
if (api_is_cas_activated()) {
$content .= "</div>";
}
if (!empty($courseCode)) {
$content .= '<hr/><p style="text-align:center"><a href="' . $home_url . '">' . get_lang('ReturnToCourseHomepage') . '</a></p>';
} else {
$content .= '<hr/><p style="text-align:center"><a href="' . $home_url . '">' . get_lang('CampusHomepage') . '</a></p>';
}
$tpl->setLoginBodyClass();
$tpl->assign('content', $content);
$tpl->display_one_col_template();
exit;
}
if ($user_id != 0 && !api_is_anonymous()) {
$tpl->display_one_col_template();
exit;
}
$msg = null;
//.........这里部分代码省略.........
示例11: get_document_preview
static function get_document_preview($course_info, $lp_id = false, $target = '', $session_id = 0, $add_move_button = false, $filter_by_folder = null, $overwrite_url = null)
{
if (empty($course_info['real_id']) || empty($course_info['code']) || !is_array($course_info)) {
return '';
}
$user_id = api_get_user_id();
$user_in_course = false;
if (api_is_platform_admin()) {
$user_in_course = true;
}
if (!$user_in_course) {
if (CourseManager::is_course_teacher($user_id, $course_info['real_id'])) {
$user_in_course = true;
}
}
//condition for the session
$session_id = intval($session_id);
if (!$user_in_course) {
if (empty($session_id)) {
if (CourseManager::is_user_subscribed_in_course($user_id, $course_info['real_id'])) {
$user_in_course = true;
}
//Check if course is open then we can consider that the student is regitered to the course
if (isset($course_info) && in_array($course_info['visibility'], array(2, 3))) {
$user_in_course = true;
}
} else {
$user_status = SessionManager::get_user_status_in_course_session($user_id, $course_info['real_id'], $session_id);
//is true if is an student, course session teacher or coach
if (in_array($user_status, array('0', '2', '6'))) {
$user_in_course = true;
}
}
}
$tbl_doc = Database::get_course_table(TABLE_DOCUMENT);
$tbl_item_prop = Database::get_course_table(TABLE_ITEM_PROPERTY);
$path = '/';
$path = Database::escape_string(str_replace('_', '\\_', $path));
$added_slash = $path == '/' ? '' : '/';
//$condition_session = " AND (id_session = '$session_id' OR (id_session = '0' AND insert_date <= (SELECT creation_date FROM $tbl_course WHERE code = '".$course_info['code']."' )))";
$condition_session = " AND (id_session = '{$session_id}' OR id_session = '0' )";
$add_folder_filter = null;
if (!empty($filter_by_folder)) {
$add_folder_filter = " AND docs.path LIKE '" . Database::escape_string($filter_by_folder) . "%'";
}
$sql_doc = "SELECT last.visibility, docs.*\n\t\t\t\t\tFROM {$tbl_item_prop} AS last, {$tbl_doc} AS docs\n \t WHERE docs.id = last.ref AND\n docs.path LIKE '" . $path . $added_slash . "%' AND\n docs.path NOT LIKE '%_DELETED_%' AND\n last.tool = '" . TOOL_DOCUMENT . "' {$condition_session} AND\n last.visibility = '1' AND\n docs.c_id = {$course_info['real_id']} AND\n last.c_id = {$course_info['real_id']}\n {$add_folder_filter}\n ORDER BY docs.title ASC";
$res_doc = Database::query($sql_doc);
$resources = Database::store_result($res_doc, 'ASSOC');
$resources_sorted = array();
$return = '';
if ($lp_id) {
$return .= '<div class="lp_resource_element">';
$return .= Display::return_icon('new_doc.gif', '', array(), ICON_SIZE_SMALL);
$return .= Display::url(get_lang('NewDocument'), api_get_self() . '?' . api_get_cidreq() . '&action=add_item&type=' . TOOL_DOCUMENT . '&lp_id=' . $_SESSION['oLP']->lp_id);
$return .= '</div>';
} else {
$return .= Display::div(Display::url(Display::return_icon('close.png', get_lang('Close'), array(), ICON_SIZE_SMALL), ' javascript:void(0);', array('id' => 'close_div_' . $course_info['real_id'] . '_' . $session_id, 'class' => 'close_div')), array('style' => 'position:absolute;right:10px'));
}
// If you want to debug it, I advise you to do "echo" on the eval statements.
if (!empty($resources) && $user_in_course) {
foreach ($resources as $resource) {
$is_visible = self::is_visible_by_id($resource['id'], $course_info, $session_id, api_get_user_id());
if (!$is_visible) {
continue;
}
$resource_paths = explode('/', $resource['path']);
array_shift($resource_paths);
$path_to_eval = $last_path = '';
$is_file = false;
if ($resource['filetype'] == 'file') {
foreach ($resource_paths as $key => $resource_path) {
if ($key != count($resource_paths) - 1) {
// It's a folder.
$path_to_eval .= "['{$resource_path}']['files']";
}
$is_file = true;
}
} else {
foreach ($resource_paths as $key => $resource_path) {
if ($key != count($resource_paths) - 1) {
// It's a folder.
$path_to_eval .= "['{$resource_path}']['files']";
}
}
}
$last_path = $resource_path;
//$data = json_encode(array('title'=>$resource['title'], 'path'=>$last_path));
//@todo not sure if it's a good thing using base64_encode. I tried with json_encode but i received the same error
//Some testing is needed in order to prove the performance
//Also change the explode to value from "/" to "|@j@|" it fixes #3780
$data = base64_encode($resource['title'] . '|@j@|' . $last_path);
if ($is_file) {
//for backward compatibility
if (empty($resource['title'])) {
$resource['title'] = basename($resource['path']);
}
eval('$resources_sorted' . $path_to_eval . '[' . $resource['id'] . '] = "' . $data . '" ; ');
} else {
eval('$resources_sorted' . $path_to_eval . '["' . $last_path . '"]["id"]=' . $resource['id'] . ';');
eval('$resources_sorted' . $path_to_eval . '["' . $last_path . '"]["title"]= "' . api_htmlentities($resource['title']) . '";');
//.........这里部分代码省略.........
示例12: showQuestion
/**
* Shows a question
*
* @param int $questionId question id
* @param bool $only_questions if true only show the questions, no exercise title
* @param bool $origin i.e = learnpath
* @param string $current_item current item from the list of questions
* @param bool $show_title
* @param bool $freeze
* @param array $user_choice
* @param bool $show_comment
* @param bool $exercise_feedback
* @param bool $show_answers
* */
function showQuestion($questionId, $only_questions = false, $origin = false, $current_item = '', $show_title = true, $freeze = false, $user_choice = array(), $show_comment = false, $exercise_feedback = null, $show_answers = false)
{
// Text direction for the current language
$is_ltr_text_direction = api_get_text_direction() != 'rtl';
// Change false to true in the following line to enable answer hinting
$debug_mark_answer = $show_answers;
//api_is_allowed_to_edit() && false;
// Reads question information
if (!($objQuestionTmp = Question::read($questionId))) {
// Question not found
return false;
}
if ($exercise_feedback != EXERCISE_FEEDBACK_TYPE_END) {
$show_comment = false;
}
$answerType = $objQuestionTmp->selectType();
$pictureName = $objQuestionTmp->selectPicture();
$s = '';
if ($answerType != HOT_SPOT && $answerType != HOT_SPOT_DELINEATION) {
// Question is not a hotspot
if (!$only_questions) {
$questionDescription = $objQuestionTmp->selectDescription();
if ($show_title) {
Testcategory::displayCategoryAndTitle($objQuestionTmp->id);
echo Display::div($current_item . '. ' . $objQuestionTmp->selectTitle(), array('class' => 'question_title'));
}
if (!empty($questionDescription)) {
echo Display::div($questionDescription, array('class' => 'question_description'));
}
}
if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION)) && $freeze) {
return '';
}
echo '<div class="question_options">';
// construction of the Answer object (also gets all answers details)
$objAnswerTmp = new Answer($questionId);
$nbrAnswers = $objAnswerTmp->selectNbrAnswers();
$course_id = api_get_course_int_id();
$quiz_question_options = Question::readQuestionOption($questionId, $course_id);
// For "matching" type here, we need something a little bit special
// because the match between the suggestions and the answers cannot be
// done easily (suggestions and answers are in the same table), so we
// have to go through answers first (elems with "correct" value to 0).
$select_items = array();
//This will contain the number of answers on the left side. We call them
// suggestions here, for the sake of comprehensions, while the ones
// on the right side are called answers
$num_suggestions = 0;
if ($answerType == MATCHING) {
$s .= '<table class="data_table">';
// Iterate through answers
$x = 1;
//mark letters for each answer
$letter = 'A';
$answer_matching = array();
$cpt1 = array();
for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
$answerCorrect = $objAnswerTmp->isCorrect($answerId);
$numAnswer = $objAnswerTmp->selectAutoId($answerId);
$answer = $objAnswerTmp->selectAnswer($answerId);
if ($answerCorrect == 0) {
// options (A, B, C, ...) that will be put into the list-box
// have the "correct" field set to 0 because they are answer
$cpt1[$x] = $letter;
$answer_matching[$x] = $objAnswerTmp->selectAnswerByAutoId($numAnswer);
$x++;
$letter++;
}
}
$i = 1;
$select_items[0]['id'] = 0;
$select_items[0]['letter'] = '--';
$select_items[0]['answer'] = '';
foreach ($answer_matching as $id => $value) {
$select_items[$i]['id'] = $value['id'];
$select_items[$i]['letter'] = $cpt1[$id];
$select_items[$i]['answer'] = $value['answer'];
$i++;
}
$user_choice_array_position = array();
if (!empty($user_choice)) {
foreach ($user_choice as $item) {
$user_choice_array_position[$item['position']] = $item['answer'];
}
}
$num_suggestions = $nbrAnswers - $x + 1;
//.........这里部分代码省略.........
示例13: get_lang
<div class="span3">
<a class="profile_link" href="' . $userInfo['profile_url'] . '">' . $userInfo['complete_name'] . '</a>
<div>' . $title . ' : ' . $content . '</div>
<div>' . get_lang('DateSend') . ' : ' . $date . '</div>
</div>
</div>';
}
}
if (count($pending_invitations) > 0) {
$social_right_content .= Display::page_subheader(get_lang('GroupsWaitingApproval'));
$new_invitation = array();
foreach ($pending_invitations as $invitation) {
$picture = $usergroup->get_picture_group($invitation['id'], $invitation['picture'], 80);
$img = '<img class="social-groups-image" src="' . $picture['file'] . '" hspace="4" height="50" border="2" align="left" width="50" />';
$invitation['picture'] = '<a href="groups.php?id=' . $invitation['id'] . '">' . $img . '</a>';
$invitation['name'] = '<a href="groups.php?id=' . $invitation['id'] . '">' . Text::cut($invitation['name'], 120, true) . '</a>';
$invitation['join'] = '<a class="btn btn-primary" href="invitations.php?accept=' . $invitation['id'] . '">' . get_lang('AcceptInvitation') . '</a>';
$invitation['deny'] = '<a class="btn btn-danger" href="invitations.php?deny=' . $invitation['id'] . '">' . get_lang('DenyInvitation') . '</a>';
$invitation['description'] = Text::cut($invitation['description'], 220, true);
$new_invitation[] = $invitation;
}
$social_right_content .= Display::return_sortable_grid('waiting_user', array(), $new_invitation, array('hide_navigation' => true, 'per_page' => 100), array(), false, array(true, true, true, false, false, true, true, true, true));
}
$social_right_content = Display::div($social_right_content, array('class' => 'span9'));
$tpl = $app['template'];
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_right_content', $social_right_content);
$tpl->assign('message', $show_message);
$tpl->assign('content', $content);
$social_layout = $tpl->get_template('layout/social_layout.tpl');
$tpl->display($social_layout);
示例14: show_right_block
/**
* @todo use the template system
*/
function show_right_block($title, $content, $id = null, $params = null) {
if (!empty($id)) {
$params['id'] = $id;
}
$params['class'] = 'well sidebar-nav';
$html = null;
if (!empty($title)) {
$html.= '<h4>'.$title.'</h4>';
}
$html.= $content;
$html = Display::div($html, $params);
return $html;
}
示例15: display_simple_grid
/**
* This function returns the content of a table in a grid
* Should not be use to edit information (edit/delete rows) only.
* @param array options of visibility
* @param bool hide navigation optionally
* @param int content per page when show navigation (optional)
* @param bool sort data optionally
* @return string grid html
*/
public function display_simple_grid($visibility_options, $hide_navigation = true, $per_page = 20, $sort_data = true, $grid_class = array())
{
$empty_table = false;
$total = $this->get_total_number_of_items();
if ($this->get_total_number_of_items() == 0) {
$cols = $this->getColCount();
//$this->setCellAttributes(1, 0, 'style="font-style: italic;text-align:center;" colspan='.$cols);
$message_empty = api_xml_http_response_encode(get_lang('TheListIsEmpty'));
$this->setCellContents(1, 0, $message_empty);
$empty_table = true;
}
$html = '';
if (!$empty_table) {
// If we show the pagination
if (!$hide_navigation) {
$form = ' ';
if ($this->get_total_number_of_items() > $per_page) {
if ($per_page > 10) {
$form = $this->get_page_select_form();
}
$nav = $this->get_navigation_html();
// This also must be moved
$html = '<div class="sub-header">';
$html .= '<div class="grid_selectbox">' . $form . '</div>';
$html .= '<div class="grid_title">' . $this->get_table_title() . '</div>';
$html .= '<div class="grid_nav">' . $nav . '</div>';
$html .= '</div>';
}
}
$html .= '<div class="clear"></div>';
if (count($this->form_actions) > 0) {
$script = '<script>
/*<![CDATA[*/
function setCheckbox(value) {
d = document.form_' . $this->table_name . ';
for (i = 0; i < d.elements.length; i++) {
if (d.elements[i].type == "checkbox") {
d.elements[i].checked = value;
}
if (value) {
$(d.elements[i]).parentsUntil("tr").parent().addClass("row_selected");
} else {
$(d.elements[i]).parentsUntil("tr").parent().removeClass("row_selected");
}
}
}
/*]]>*/
</script>';
$params = $this->get_sortable_table_param_string() . '&' . $this->get_additional_url_paramstring();
$html .= '<form method="post" action="' . api_get_self() . '?' . $params . '" name="form_' . $this->table_name . '">';
}
}
if ($hide_navigation) {
$items = $this->table_data;
// This is a faster way to get what we want
} else {
// The normal way
$items = $this->get_clean_html($sort_data);
// Getting the items of the table
}
// Generation of style classes must be improved. Maybe we need a a table name to create style on the fly:
// i.e: .whoisonline_table_grid_container instead of .grid_container
// where whoisonline is the table's name like drupal's template engine
if (is_array($visibility_options)) {
$filter = false;
// The 2nd condition of the if will be loaded
} else {
$filter = $visibility_options !== false;
}
$item_css_class = $item_css_style = $grid_css_class = $grid_css_style = '';
if (!empty($grid_class)) {
$grid_css_class = $grid_class['main']['class'];
$item_css_class = $grid_class['item']['class'];
$grid_css_style = isset($grid_class['main']['style']) ? $grid_class['main']['style'] : null;
$item_css_style = isset($grid_class['item']['style']) ? $grid_class['item']['style'] : null;
}
$div = '';
if (is_array($items) && count($items) > 0) {
foreach ($items as &$row) {
$i = 0;
$rows = '';
foreach ($row as &$element) {
if ($filter || $visibility_options[$i]) {
$rows .= '<div class="' . $this->table_name . '_grid_element_' . $i . '">' . $element . '</div>';
}
$i++;
}
$div .= Display::div($rows, array('class' => $item_css_class . ' ' . $this->table_name . '_grid_item', 'style' => $item_css_style));
}
}
$html .= Display::div($div, array('class' => $grid_css_class . ' ' . $this->table_name . '_grid_container', 'style' => $grid_css_style));
//.........这里部分代码省略.........