~ubuntu-branches/ubuntu/natty/moodle/natty

« back to all changes in this revision

Viewing changes to lib/bennu/iCalendar_rfc2445.php

  • Committer: Bazaar Package Importer
  • Author(s): Tomasz Muras
  • Date: 2010-10-30 12:19:28 UTC
  • mfrom: (1.1.12 upstream) (3.1.10 squeeze)
  • Revision ID: james.westby@ubuntu.com-20101030121928-qzobi6mctpnk4dif
Tags: 1.9.9.dfsg2-2
* Added Romanian translation
* Updated Japanese translation (closes: #596820)
* Backporting security fixes from Moodle 1.9.10 (closes: #601384)
   - Updated embedded CAS to 1.1.3
   - Added patch for MDL-24523:
     clean_text() not filtering text in markdown format
   - Added patch for MDL-24810 and upgraded customized HTML Purifier to 4.2.0 
   - Added patch for MDL-24258:
     students can delete their forum posts later than $CFG->maxeditingtime 
     under certain conditions
   - Added patch for MDL-23377:
     Can't delete quiz attempts in course without enrolled students

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php // $Id: iCalendar_rfc2445.php,v 1.2 2006/11/23 20:30:57 martinlanghoff Exp $
 
1
<?php // $Id: iCalendar_rfc2445.php,v 1.2.10.3 2009/11/19 10:16:53 skodak Exp $
2
2
 
3
3
/**
4
4
 *  BENNU - PHP iCalendar library
9
9
 *  See http://bennu.sourceforge.net/ for more information and downloads.
10
10
 *
11
11
 * @author Ioannis Papaioannou 
12
 
 * @version $Id: iCalendar_rfc2445.php,v 1.2 2006/11/23 20:30:57 martinlanghoff Exp $
 
12
 * @version $Id: iCalendar_rfc2445.php,v 1.2.10.3 2009/11/19 10:16:53 skodak Exp $
13
13
 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
14
14
 */
15
15
 
54
54
 
55
55
 
56
56
function rfc2445_fold($string) {
57
 
    if(strlen($string) <= RFC2445_FOLDED_LINE_LENGTH) {
 
57
    if(mb_strlen($string, 'utf-8') <= RFC2445_FOLDED_LINE_LENGTH) {
58
58
        return $string;
59
59
    }
60
60
 
61
61
    $retval = '';
62
 
 
63
 
    while(strlen($string) > RFC2445_FOLDED_LINE_LENGTH) {
64
 
        $retval .= substr($string, 0, RFC2445_FOLDED_LINE_LENGTH - 1) . RFC2445_CRLF . ' ';
65
 
        $string  = substr($string, RFC2445_FOLDED_LINE_LENGTH - 1);
 
62
  
 
63
    $i=0;
 
64
    $len_count=0;
 
65
 
 
66
    //multi-byte string, get the correct length
 
67
    $section_len = mb_strlen($string, 'utf-8');
 
68
 
 
69
    while($len_count<$section_len) {
 
70
        
 
71
        //get the current portion of the line
 
72
        $section = mb_substr($string, ($i * RFC2445_FOLDED_LINE_LENGTH), (RFC2445_FOLDED_LINE_LENGTH), 'utf-8');
 
73
 
 
74
        //increment the length we've processed by the length of the new portion
 
75
        $len_count += mb_strlen($section, 'utf-8');
 
76
        
 
77
        /* Add the portion to the return value, terminating with CRLF.HTAB
 
78
           As per RFC 2445, CRLF.HTAB will be replaced by the processor of the 
 
79
           data */
 
80
        $retval .= $section.RFC2445_CRLF.RFC2445_WSP;
 
81
        
 
82
        $i++;
66
83
    }
67
84
 
68
 
    $retval .= $string;
69
 
    
70
85
    return $retval;
71
86
 
72
87
}