本文整理汇总了PHP中Text::cut方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::cut方法的具体用法?PHP Text::cut怎么用?PHP Text::cut使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Text
的用法示例。
在下文中一共展示了Text::cut方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
echo $post['title'];
?>
</title>
<link><?php
echo Option::get('siteurl') . '/blog/' . $post['slug'];
?>
</link>
<guid><?php
echo Option::get('siteurl') . '/blog/' . $post['slug'];
?>
</guid>
<pubDate><?php
echo Date::format($post['date'], 'd M Y');
?>
</pubDate>
<description><![CDATA[<?php
echo Text::toHtml(Text::cut(File::getContent(STORAGE . DS . 'pages' . DS . $post['id'] . '.page.txt'), 300));
?>
]]></description>
<author><?php
echo $post['author'];
?>
</author>
</item>
<?php
}
?>
</channel>
</rss>
<?php
Response::status(200);
示例2: getSlugAfterFilter
private function getSlugAfterFilter($filter)
{
if ($filter == '/') {
$filter = HTML_PATH_ROOT;
}
// Check if the filter is in the uri.
$position = Text::strpos($this->uri, $filter);
if ($position === false) {
return false;
}
$start = $position + Text::length($filter);
$end = $this->uriStrlen;
$slug = Text::cut($this->uri, $start, $end);
$this->slug = trim($slug, '/');
return $slug;
}
示例3: draw_category_label
/**
* @param array $category_list
* @param string $type
* @return null|string
*/
public static function draw_category_label($category_list, $type = 'label')
{
$new_category_list = array();
foreach ($category_list as $category) {
$category_name = $category['title'];
$category_name_cut = Text::cut($category['title'], 20);
switch ($type) {
case 'label':
// Global cat
/*
$parentId = isset($category['parent_id']) && !empty($category['parent_id']) ? $category['parent_id'] : null;
if (empty($parentId)) {
$new_category_list[] = Display::label($category_name, 'info');
} else {
// Local cat
$new_category_list[] = Display::label($category_name, 'success');
}*/
$courseId = isset($category['c_id']) && !empty($category['c_id']) ? $category['c_id'] : null;
if (empty($courseId)) {
$new_category_list[] = Display::label($category_name_cut, 'info', $category_name);
} else {
// Local cat
$new_category_list[] = Display::label($category_name_cut, 'success', $category_name);
}
break;
case 'header':
$new_category_list[] = $category_name;
break;
}
}
$html = null;
if (!empty($new_category_list)) {
switch ($type) {
case 'label':
$html = implode(' ', $new_category_list);
break;
case 'header':
$html = Display::page_subheader3(get_lang('Category') . ': ' . implode(', ', $new_category_list));
break;
}
}
return $html;
}
示例4: count
$count_users_group = count($usergroup->get_all_users_by_group($id));
if ($count_users_group == 1) {
$count_users_group = $count_users_group . ' ' . get_lang('Member');
} else {
$count_users_group = $count_users_group . ' ' . get_lang('Members');
}
$picture = $usergroup->get_picture_group($group['id'], $group['picture'], 80);
$tags = $usergroup->get_group_tags($group['id']);
$group['picture'] = '<img class="social-groups-image" src="' . $picture['file'] . '" hspace="4" height="50" border="2" align="left" width="50" />';
$item_0 = Display::div($group['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('h3', $url_open . $name . $url_close) . $members, array('class' => 'box_description_group_title'));
$item_2 = '';
$item_3 = '';
if ($group['description'] != '') {
$item_3 = '<div class="box_description_group_content" >' . Text::cut($group['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>';
}
$item_4 = '<div class="box_description_group_tags" >' . $tags . '</div>';
$item_5 = '<div class="box_description_group_actions" >' . $url_open . get_lang('SeeMore') . $url_close . '</div>';
$grid_item_2 = $item_0 . $item_1 . $item_2 . $item_3 . $item_4 . $item_5;
$grid_groups[] = array('', $grid_item_2);
}
}
$visibility = array(true, true, true, true, true);
$social_right_content .= Display::return_sortable_grid('mygroups', array(), $grid_groups, array('hide_navigation' => true, 'per_page' => 5), $query_vars, false, $visibility);
}
$app['title'] = $tool_name;
$tpl = $app['template'];
示例5: get_exercises
/**
* Creates a list with all the exercises (quiz) in it
* @return string
*/
public function get_exercises()
{
$course_id = api_get_course_int_id();
// New for hotpotatoes.
$uploadPath = DIR_HOTPOTATOES;
//defined in main_api
$tbl_doc = Database::get_course_table(TABLE_DOCUMENT);
$tbl_quiz = Database::get_course_table(TABLE_QUIZ_TEST);
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
$sql_quiz = "SELECT * FROM {$tbl_quiz} WHERE c_id = {$course_id} AND active<>'-1' {$condition_session} ORDER BY title ASC";
$sql_hot = "SELECT * FROM {$tbl_doc} WHERE c_id = {$course_id} AND path LIKE '" . $uploadPath . "/%/%htm%' {$condition_session} ORDER BY id ASC";
$res_quiz = Database::query($sql_quiz);
$res_hot = Database::query($sql_hot);
$return = '<ul class="lp_resource">';
$return .= '<li class="lp_resource_element">';
$return .= Display::return_icon('new_test_small.gif');
$return .= '<a href="' . api_get_path(REL_CODE_PATH) . 'exercice/exercise_admin.php?lp_id=' . $this->lp_id . '">' . get_lang('NewExercise') . '</a>';
$return .= '</li>';
// Display hotpotatoes
while ($row_hot = Database::fetch_array($res_hot)) {
$return .= '<li class="lp_resource_element" data_id="' . $row_hot['id'] . '" data_type="hotpotatoes" title="' . $row_hot['title'] . '" >';
$return .= '<a class="moved" href="#">';
$return .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY);
$return .= '</a> ';
$return .= Display::return_icon('hotpotatoes_s.png');
$return .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=add_item&type=' . TOOL_HOTPOTATOES . '&file=' . $row_hot['id'] . '&lp_id=' . $this->lp_id . '">' . (!empty($row_hot['comment']) ? $row_hot['comment'] : Security::remove_XSS($row_hot['title'])) . '</a>';
$return .= '</li>';
}
while ($row_quiz = Database::fetch_array($res_quiz)) {
$return .= '<li class="lp_resource_element" data_id="' . $row_quiz['iid'] . '" data_type="quiz" title="' . $row_quiz['title'] . '" >';
$return .= '<a class="moved" href="#">';
$return .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY);
$return .= '</a> ';
$return .= Display::return_icon('quizz_small.gif');
$return .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=add_item&type=' . TOOL_QUIZ . '&file=' . $row_quiz['iid'] . '&lp_id=' . $this->lp_id . '">' . Security::remove_XSS(Text::cut($row_quiz['title'], 80)) . '</a>';
$return .= '</li>';
}
$return .= '</ul>';
return $return;
}
示例6: 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);
示例7: getSlugAfterFilter
private function getSlugAfterFilter($filter)
{
// Remove both slash from the filter
$filter = trim($filter, '/');
// Add to the filter the root directory
$filter = HTML_PATH_ROOT . $filter;
// Check if the filter is in the uri.
$position = Text::stringPosition($this->uri, $filter);
// If the position is FALSE, the filter isn't in the URI.
if ($position === false) {
return false;
}
// Start position to cut
$start = $position + Text::length($filter);
// End position to cut
$end = $this->uriStrlen;
// Get the slug from the URI
$slug = Text::cut($this->uri, $start, $end);
if (Text::isEmpty($slug)) {
return '';
}
if ($slug[0] == '/') {
return ltrim($slug, '/');
}
if ($filter == HTML_PATH_ROOT) {
return $slug;
}
return false;
}
示例8: get_class
/** @var Question $objQuestionTmp */
$objQuestionTmp = Question::read($id);
$question_class = get_class($objQuestionTmp);
$clone_link = '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&clone_question=' . $id . '">' . Display::return_icon('cd.gif', get_lang('Copy'), array(), ICON_SIZE_SMALL) . '</a>';
$edit_link = '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&type=' . $objQuestionTmp->selectType() . '&myid=1&editQuestion=' . $id . '">' . Display::return_icon('edit.png', get_lang('Modify'), array(), ICON_SIZE_SMALL) . '</a>';
if ($objExercise->edit_exercise_in_lp == true) {
$delete_link = '<a id="delete_' . $id . '" class="opener" href="' . api_get_self() . '?' . api_get_cidreq() . '&exerciseId=' . $exerciseId . '&deleteQuestion=' . $id . '" >' . Display::return_icon('delete.png', get_lang('RemoveFromTest'), array(), ICON_SIZE_SMALL) . '</a>';
}
$edit_link = Display::tag('div', $edit_link, array('style' => 'float:left; padding:0px; margin:0px'));
$clone_link = Display::tag('div', $clone_link, array('style' => 'float:left; padding:0px; margin:0px'));
$delete_link = Display::tag('div', $delete_link, array('style' => 'float:left; padding:0px; margin:0px'));
$actions = Display::tag('div', $edit_link . $clone_link . $delete_link, array('class' => 'edition', 'style' => 'width:100px; right:10px; margin-top: 0px; position: absolute; top: 10%;'));
$title = Security::remove_XSS($objQuestionTmp->selectTitle());
$move = Display::return_icon('all_directions.png', get_lang('Move'), array('class' => 'moved', 'style' => 'margin-bottom:-0.5em;'));
// Question name
$questionName = Display::tag('div', '<a href="#" title = "' . $title . '">' . $move . ' ' . Text::cut($title, 42) . '</a>', array('style' => $styleQuestion));
// Question type.
list($typeImg, $typeExpl) = $objQuestionTmp->get_type_icon_html();
$question_media = null;
if (!empty($objQuestionTmp->parent_id)) {
$objQuestionMedia = Question::read($objQuestionTmp->parent_id);
$question_media = ' ' . Question::getMediaLabel($objQuestionMedia->question);
}
$questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), ICON_SIZE_MEDIUM), array('style' => $styleType));
// Question category.
$category_labels = Testcategory::return_category_labels($objQuestionTmp->category_list, $category_list);
if (empty($category_labels)) {
$category_labels = "";
}
$questionCategory = Display::tag('div', '<a href="#" style="padding:0px; margin:0px;">' . $category_labels . $question_media . '</a>', array('style' => $styleCat));
// Question level.
示例9: array
}
$label_attributes = array();
$label_attributes['class'] = 'checkbox';
$label_attributes['for'] = $check_id;
$label_attributes['class'] = "checkbox";
if (in_array($objQuestionTmp->type, Question::question_type_no_review())) {
$attributes['disabled'] = 'disabled';
}
$checkbox = Display::input('checkbox', 'remind_list[' . $questionId . ']', '', $attributes);
$url = $urlMainExercise . 'exercise_submit.php?exerciseId=' . $objExercise->id . '&num=' . $counter . '&reminder=1';
$counter++;
if ($objExercise->type == ONE_PER_PAGE) {
$question_title = Display::url($counter . '. ' . Text::cut($objQuestionTmp->selectTitle(), 40), $url);
$question_title = $counter . '. ' . Text::cut($objQuestionTmp->selectTitle(), 40);
} else {
$question_title = $counter . '. ' . Text::cut($objQuestionTmp->selectTitle(), 40);
}
//Check if the question doesn't have an answer
if (!in_array($questionId, $exercise_result)) {
$question_title = Display::label($question_title, 'warning');
}
$rootCategories = null;
global $app;
$repo = $app['orm.em']->getRepository('Entity\\CQuizCategory');
foreach ($objQuestionTmp->category_list as $categoryId) {
$cat = $repo->find($categoryId);
$parentCat = $repo->getPath($cat);
if (isset($parentCat[0])) {
$rootCategories .= $parentCat[0]->getTitle();
}
}
示例10: intval
$document_id = intval($_GET['id']);
$course_info = api_get_course_info();
$course_code = api_get_course_id();
if (empty($course_info)) {
api_not_allowed(true);
}
//Generate path
if (!$document_id) {
$document_id = DocumentManager::get_document_id($course_info, $header_file);
}
$document_data = DocumentManager::get_document_data_by_id($document_id, $course_code);
if (empty($document_data)) {
api_not_allowed(true);
}
$header_file = $document_data['path'];
$name_to_show = Text::cut($header_file, 80);
$path_array = explode('/', str_replace('\\', '/', $header_file));
$path_array = array_map('urldecode', $path_array);
$header_file = implode('/', $path_array);
$file = Security::remove_XSS(urldecode($document_data['path']));
$file_root = $course_info['path'] . '/document' . str_replace('%2F', '/', $file);
$file_url_sys = api_get_path(SYS_COURSE_PATH) . $file_root;
$file_url_web = api_get_path(WEB_COURSE_PATH) . $file_root;
if (!file_exists($file_url_sys)) {
api_not_allowed(true);
}
if (is_dir($file_url_sys)) {
api_not_allowed(true);
}
//Check user visibility
//$is_visible = DocumentManager::is_visible_by_id($document_id, $course_info, api_get_session_id(), api_get_user_id());
示例11: get_lang
if (!empty($production_list) || !empty($file_list) || $count_pending_invitations > 0) {
//Pending invitations
if (!isset($_GET['u']) || isset($_GET['u']) && $_GET['u'] == api_get_user_id()) {
if ($count_pending_invitations > 0) {
$invitations .= '<div><h3>' . get_lang('PendingInvitations') . '</h3></div>';
for ($i = 0; $i < $count_pending_invitations; $i++) {
$user_invitation_id = $pending_invitations[$i]['user_sender_id'];
$invitations .= '<div id="dpending_' . $user_invitation_id . '" class="friend_invitations">';
$invitations .= '<div style="float:left;width:60px;" >';
$invitations .= '<img style="margin-bottom:5px;" src="' . $list_get_path_web[$i]['dir'] . '/' . $list_get_path_web[$i]['file'] . '" width="60px">';
$invitations .= '</div>';
$invitations .= '<div style="padding-left:70px;">';
$user_invitation_info = api_get_user_info($user_invitation_id);
$invitations .= '<a href="' . $user_invitation_info['profile_url'] . '">' . $user_invitation_info['complete_name'] . '</a>';
$invitations .= '<br />';
$invitations .= Security::remove_XSS(Text::cut($pending_invitations[$i]['content'], 50), STUDENT, true);
$invitations .= '<br />';
$invitations .= '<a id="btn_accepted_' . $user_invitation_id . '" class="btn" onclick="register_friend(this)" href="javascript:void(0)">' . get_lang('SocialAddToFriends') . '</a>';
$invitations .= '<div id="id_response"></div>';
$invitations .= '</div>';
$invitations .= '</div>';
}
$social_right_content .= SocialManager::social_wrapper_div($invitations, 4);
}
}
//--Productions
$production_list = UserManager::build_production_list($user_id);
$product_content = '';
if (!empty($production_list)) {
$product_content .= '<div><h3>' . get_lang('MyProductions') . '</h3></div>';
$product_content .= $production_list;
示例12: display_blog_posts
/**
* Shows the posts of a blog
* @author Toon Keppens
*
* @param Integer $blog_id
*/
public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20)
{
// Init
$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
$course_id = api_get_course_int_id();
// Get posts and authors
$sql = "SELECT post.*, user.lastname, user.firstname, user.username FROM {$tbl_blogs_posts} post\n\t\t\t\t\tINNER JOIN {$tbl_users} user ON post.author_id = user.user_id\n\t\t\t\tWHERE \tpost.blog_id = '" . (int) $blog_id . "' AND\n\t\t\t\t\t\tpost.c_id = {$course_id} AND\n\t\t\t\t\t\t{$filter}\n\t\t\t\tORDER BY post_id DESC LIMIT 0," . (int) $max_number_of_posts;
$result = Database::query($sql);
// Display
if (Database::num_rows($result) > 0) {
$limit = 200;
while ($blog_post = Database::fetch_array($result)) {
// Get number of comments
$sql = "SELECT COUNT(1) as number_of_comments FROM {$tbl_blogs_comments} WHERE c_id = {$course_id} AND blog_id = '" . (int) $blog_id . "' AND post_id = '" . (int) $blog_post['post_id'] . "'";
$tmp = Database::query($sql);
$blog_post_comments = Database::fetch_array($tmp);
// Prepare data
$blog_post_id = $blog_post['post_id'];
$blog_post_text = Text::make_clickable(stripslashes($blog_post['full_text']));
$blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
// Create an introduction text (but keep FULL sentences)
$introduction_text = "";
$words = 0;
$blog_post_text_cut = Text::cut($blog_post_text, $limit);
$words = strlen($blog_post_text);
if ($words >= $limit) {
$readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>';
$introduction_text = $blog_post_text_cut;
} else {
$introduction_text = $blog_post_text;
$readMoreLink = '';
}
$introduction_text = stripslashes($introduction_text);
echo '<div class="blogpost">';
echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . stripslashes($blog_post['title']) . '</a></span>';
echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>';
echo '<div class="blogpost_introduction" id="blogpost_introduction_' . $blog_post_id . '">' . $introduction_text . $readMoreLink . '</div>';
echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>';
$file_name_array = get_blog_attachment($blog_id, $blog_post_id, 0);
if (!empty($file_name_array)) {
echo '<br /><br />';
echo Display::return_icon('attachment.gif', get_lang('Attachment'));
echo '<a href="download.php?file=';
echo $file_name_array['path'];
echo ' "> ' . $file_name_array['filename'] . ' </a><br />';
echo '</span>';
}
$username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title' => $username)) . ' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>';
echo '</div>';
}
} else {
if ($filter == '1=1') {
echo get_lang('NoArticles');
} else {
echo get_lang('NoArticleMatches');
}
}
}
示例13: returnBreadcrumb
/**
* Return breadcrumb
* @return string
*/
public function returnBreadcrumb()
{
$interbreadcrumb = $this->app['breadcrumb'];
$session_id = api_get_session_id();
$session_name = api_get_session_name($session_id);
$_course = api_get_course_info();
$user_id = api_get_user_id();
$course_id = api_get_course_id();
/* Plugins for banner section */
$web_course_path = api_get_path(WEB_COURSE_PATH);
/* If the user is a coach he can see the users who are logged in its session */
$navigation = array();
// part 1: Course Homepage. If we are in a course then the first breadcrumb is a link to the course homepage
// hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb
$session_name = Text::cut($session_name, MAX_LENGTH_BREADCRUMB);
$my_session_name = is_null($session_name) ? '' : ' (' . $session_name . ')';
if (!empty($_course) && !isset($_GET['hide_course_breadcrumb'])) {
$navigation_item['url'] = $web_course_path . $_course['path'] . '/index.php' . (!empty($session_id) ? '?id_session=' . $session_id : '');
$course_title = Text::cut($_course['name'], MAX_LENGTH_BREADCRUMB);
switch (api_get_setting('breadcrumbs_course_homepage')) {
case 'get_lang':
$navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH) . 'home.png', get_lang('CourseHomepageLink')) . ' ' . get_lang('CourseHomepageLink');
break;
case 'course_code':
$navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH) . 'home.png', $_course['official_code']) . ' ' . $_course['official_code'];
break;
case 'session_name_and_course_title':
$navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH) . 'home.png', $_course['name'] . $my_session_name) . ' ' . $course_title . $my_session_name;
break;
default:
if (api_get_session_id() != -1) {
$navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH) . 'home.png', $_course['name'] . $my_session_name) . ' ' . $course_title . $my_session_name;
} else {
$navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH) . 'home.png', $_course['name']) . ' ' . $course_title;
}
break;
}
$navigation[] = $navigation_item;
}
// Part 2: breadcrumbs.
// If there is an array $interbreadcrumb defined then these have to appear before the last breadcrumb
// (which is the tool itself)
if (isset($interbreadcrumb) && is_array($interbreadcrumb)) {
foreach ($interbreadcrumb as $breadcrumb_step) {
if ($breadcrumb_step['url'] != '#') {
$sep = strrchr($breadcrumb_step['url'], '?') ? '&' : '?';
$navigation_item['url'] = $breadcrumb_step['url'] . $sep . api_get_cidreq();
} else {
$navigation_item['url'] = '#';
}
$navigation_item['title'] = $breadcrumb_step['name'];
// titles for shared folders
if ($breadcrumb_step['name'] == 'shared_folder') {
$navigation_item['title'] = get_lang('UserFolders');
} elseif (strstr($breadcrumb_step['name'], 'shared_folder_session_')) {
$navigation_item['title'] = get_lang('UserFolders');
} elseif (strstr($breadcrumb_step['name'], 'sf_user_')) {
$userinfo = api_get_user_info(substr($breadcrumb_step['name'], 8));
$navigation_item['title'] = $userinfo['complete_name'];
} elseif ($breadcrumb_step['name'] == 'chat_files') {
$navigation_item['title'] = get_lang('ChatFiles');
} elseif ($breadcrumb_step['name'] == 'images') {
$navigation_item['title'] = get_lang('Images');
} elseif ($breadcrumb_step['name'] == 'video') {
$navigation_item['title'] = get_lang('Video');
} elseif ($breadcrumb_step['name'] == 'audio') {
$navigation_item['title'] = get_lang('Audio');
} elseif ($breadcrumb_step['name'] == 'flash') {
$navigation_item['title'] = get_lang('Flash');
} elseif ($breadcrumb_step['name'] == 'gallery') {
$navigation_item['title'] = get_lang('Gallery');
}
// Fixes breadcrumb title now we applied the Security::remove_XSS and we cut the string depending of the MAX_LENGTH_BREADCRUMB value
$navigation_item['title'] = Text::cut($navigation_item['title'], MAX_LENGTH_BREADCRUMB);
$navigation_item['title'] = Security::remove_XSS($navigation_item['title']);
$navigation[] = $navigation_item;
}
}
// part 3: The tool itself. If we are on the course homepage we do not want to display the title of the course because this
// is the same as the first part of the breadcrumbs (see part 1)
$final_navigation = array();
$counter = 0;
foreach ($navigation as $index => $navigation_info) {
if (!empty($navigation_info['title'])) {
if ($navigation_info['url'] == '#') {
$final_navigation[$index] = $navigation_info['title'];
} else {
$final_navigation[$index] = '<a href="' . $navigation_info['url'] . '" class="" target="_top">' . $navigation_info['title'] . '</a>';
}
$counter++;
}
}
$html = '';
if (!empty($final_navigation)) {
$lis = '';
$i = 0;
//.........这里部分代码省略.........
示例14: api_get_course_int_id
$data[$id]['name'] = Text::cut($question_obj->question, 100);
} else {
$data[$id]['name'] = '-';
}
$data[$id]['answer'] = $answer_info;
$data[$id]['correct'] = '-';
$count = ExerciseLib::get_number_students_answer_hotspot_count($answer_id, $question_id, $exercise_id, api_get_course_int_id(), api_get_session_id());
$percentage = 0;
if (!empty($count_students)) {
$percentage = $count / $count_students * 100;
}
$data[$id]['attempts'] = Display::bar_progress($percentage, false, $count . ' / ' . $count_students);
break;
default:
if ($mainCounter == 1) {
$data[$id]['name'] = Text::cut($question_obj->question, 100);
} else {
$data[$id]['name'] = '-';
}
$data[$id]['answer'] = $answer_info;
$data[$id]['correct'] = $correct_answer;
$count = ExerciseLib::get_number_students_answer_count($answer_id, $question_id, $exercise_id, api_get_course_int_id(), api_get_session_id());
$percentage = 0;
if (!empty($count_students)) {
$percentage = $count / $count_students * 100;
}
$data[$id]['attempts'] = Display::bar_progress($percentage, false, $count . ' / ' . $count_students);
break;
}
$id++;
$mainCounter++;
示例15: save_notification
/**
* Save message notification
* @param array message type NOTIFICATION_TYPE_MESSAGE, NOTIFICATION_TYPE_INVITATION, NOTIFICATION_TYPE_GROUP
* @param array recipients: user list of ids
* @param string title
* @param string content of the message
* @param array result of api_get_user_info() or UserGroup->get()
*/
public function save_notification($type, $user_list, $title, $content, $sender_info = array(), $text_content = null)
{
$this->type = intval($type);
$content = $this->format_content($content, $sender_info);
$sender_id = 0;
if (!empty($sender_info) && isset($sender_info['user_id'])) {
$sender_id = $sender_info['user_id'];
$this->set_sender_info($sender_id);
}
$setting_to_check = '';
$avoid_my_self = false;
$default_status = self::NOTIFY_MESSAGE_AT_ONCE;
switch ($this->type) {
case self::NOTIFICATION_TYPE_MESSAGE:
$setting_to_check = 'mail_notify_message';
$default_status = self::NOTIFY_MESSAGE_AT_ONCE;
break;
case self::NOTIFICATION_TYPE_INVITATION:
$setting_to_check = 'mail_notify_invitation';
$default_status = self::NOTIFY_INVITATION_AT_ONCE;
break;
case self::NOTIFICATION_TYPE_GROUP:
$setting_to_check = 'mail_notify_group_message';
$default_status = self::NOTIFY_GROUP_AT_ONCE;
$avoid_my_self = true;
break;
}
$setting_info = UserManager::get_extra_field_information_by_name($setting_to_check);
if (!empty($user_list)) {
foreach ($user_list as $user_id) {
if ($avoid_my_self) {
if ($user_id == api_get_user_id()) {
continue;
}
}
$user_info = api_get_user_info($user_id);
//Extra field was deleted or removed? Use the default status
if (empty($setting_info)) {
$user_setting = $default_status;
} else {
$extra_data = UserManager::get_extra_user_data($user_id);
$user_setting = $extra_data[$setting_to_check];
}
$params = array();
switch ($user_setting) {
//No notifications
case self::NOTIFY_MESSAGE_NO:
case self::NOTIFY_INVITATION_NO:
case self::NOTIFY_GROUP_NO:
break;
//Send notification right now!
//Send notification right now!
case self::NOTIFY_MESSAGE_AT_ONCE:
case self::NOTIFY_INVITATION_AT_ONCE:
case self::NOTIFY_GROUP_AT_ONCE:
if (!empty($user_info['mail'])) {
$name = api_get_person_name($user_info['firstname'], $user_info['lastname']);
if (!empty($sender_info['complete_name']) && !empty($sender_info['email'])) {
$extra_headers = array();
$extra_headers['reply_to']['mail'] = $sender_info['email'];
$extra_headers['reply_to']['name'] = $sender_info['complete_name'];
api_mail_html($name, $user_info['mail'], Security::filter_terms($title), Security::filter_terms($content), $sender_info['complete_name'], $sender_info['email'], $extra_headers, array(), null, $text_content);
} else {
api_mail_html($name, $user_info['mail'], Security::filter_terms($title), Security::filter_terms($content), $sender_info['complete_name'], $sender_info['email'], array(), null, $text_content);
}
}
$params['sent_at'] = api_get_utc_datetime();
// Saving the notification to be sent some day.
// Saving the notification to be sent some day.
default:
$params['dest_user_id'] = $user_id;
$params['dest_mail'] = $user_info['mail'];
$params['title'] = $title;
$params['content'] = Text::cut($content, $this->max_content_length);
$params['send_freq'] = $user_setting;
$params['sender_id'] = $sender_id;
$this->save($params);
break;
}
}
}
}