Display first lines of gredebook object description in gredebook table - ref #6588

1.9.x
Hubert Borderiou 12 years ago
parent 8fc49f9443
commit 262a5f11c4
  1. 3
      main/gradebook/lib/gradebook_data_generator.class.php
  2. 33
      main/inc/lib/main_api.lib.php

@ -97,7 +97,8 @@ class GradebookDataGenerator
$row = array ();
$row[] = $item;
$row[] = $item->get_name();
$row[] = $item->get_description();
// display the 2 first line of description, and all description on mouseover (https://support.chamilo.org/issues/6588)
$row[] = '<span title="'.api_remove_tags_with_space($item->get_description()).'">'.api_get_short_text_from_html($item->get_description(), 160).'</span>';
$row[] = $item->get_weight();
/*if (api_is_allowed_to_edit(null, true)) {
$row[] = $this->build_date_column($item);

@ -6551,3 +6551,36 @@ function api_get_user_blocked_by_captcha($username)
}
return false;
}
/**
* Remove tags from HTML anf return the $in_number_char first non-HTML char
* Postfix the text with "..." if it has been truncated.
* @return string
* @author hubert borderiou
*/
function api_get_short_text_from_html($in_html, $in_number_char) {
$out_res = api_remove_tags_with_space($in_html, false);
$postfix = "...";
if (strlen($out_res) > $in_number_char) {
$out_res = substr($out_res, 0, $in_number_char).$postfix;
}
return $out_res;
}
/**
* Replace tags with a space in a text.
* If $in_double_quote_replace, replace " with '' (for HTML attribute purpose, for exemple)
* @return string
* @author hubert borderiou
*/
function api_remove_tags_with_space($in_html, $in_double_quote_replace = true) {
$out_res = $in_html;
if ($in_double_quote_replace) {
$out_res = str_replace('"', "''", $out_res);
}
// avoid text stuck together when tags are removed, adding a space after >
$out_res = str_replace (">", "> ", $out_res);
$out_res = strip_tags($out_res);
return $out_res;
}
Loading…
Cancel
Save