示例#1
0
 public function testFoldingWithNewLines()
 {
     $str_75 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012346789abcdefghijklmnopqrstuvwxyz012346789^%CDE";
     //New lines with \r\n
     $string = 'ABCDEF\\n abcdef\\n' . $str_75 . $str_75 . '\\nHello world';
     $expected = 'ABCDEF\\n abcdef\\nABCDEFGHIJKLMNOPQRSTUVWXYZ012346789abcdefghijklmnopqrstuvw' . "\r\n " . 'xyz012346789^%CDEABCDEFGHIJKLMNOPQRSTUVWXYZ012346789abcdefghijklmnopqrstuvw' . "\r\n " . 'xyz012346789^%CDE\\nHello world';
     $this->assertEquals($expected, eventorganiser_fold_ical_text($string));
 }
示例#2
0
文件: ical.php 项目: blogfor/king
        $description = eventorganiser_escape_ical_text($description);
        if (!empty($description)) {
            echo eventorganiser_fold_ical_text("DESCRIPTION: {$description}") . "\r\n";
        }
        $description = wpautop(html_entity_decode(get_the_content(), ENT_COMPAT, 'UTF-8'));
        $description = str_replace("\r\n", '', $description);
        //Remove new lines
        $description = str_replace("\n", '', $description);
        $description = eventorganiser_escape_ical_text($description);
        echo eventorganiser_fold_ical_text("X-ALT-DESC;FMTTYPE=text/html: {$description}") . "\r\n";
        $cats = get_the_terms(get_the_ID(), 'event-category');
        if ($cats && !is_wp_error($cats)) {
            $cat_names = wp_list_pluck($cats, 'name');
            $cat_names = array_map('eventorganiser_escape_ical_text', $cat_names);
            echo 'CATEGORIES:' . implode(',', $cat_names) . "\r\n";
        }
        if (eo_get_venue()) {
            $venue = eo_get_venue_name(eo_get_venue());
            echo "LOCATION:" . eventorganiser_fold_ical_text(eventorganiser_escape_ical_text($venue)) . "\r\n";
            echo "GEO:" . implode(';', eo_get_venue_latlng($venue)) . "\r\n";
        }
        if (get_the_author_meta('ID')) {
            $author_name = eventorganiser_escape_ical_text(get_the_author());
            $author_email = eventorganiser_escape_ical_text(get_the_author_meta('user_email'));
            echo eventorganiser_fold_ical_text('ORGANIZER;CN="' . $author_name . '":MAILTO:' . $author_email) . "\r\n";
        }
        echo eventorganiser_fold_ical_text('URL;VALUE=URI:' . get_permalink()) . "\r\n";
        echo "END:VEVENT\r\n";
    }
}
echo "END:VCALENDAR\r\n";