| [ Index ] |
|
Code source de Horde 3.1.3 |
1 <?php 2 /** 3 * The SyncML_Device_Synthesis:: class provides functionality that is 4 * specific to the Synthesis.ch SyncML clients. 5 * 6 * Copyright 2005-2006 Karsten Fourmont <karsten@horde.org> 7 * 8 * See the enclosed file COPYING for license information (LGPL). If you did not 9 * receive this file, see http://www.fsf.org/copyleft/lgpl.html. 10 * 11 * $Horde: framework/SyncML/SyncML/Device/Synthesis.php,v 1.2.2.5 2006/05/01 12:05:14 jan Exp $ 12 * 13 * @author Karsten Fourmont <karsten@horde.org> 14 * @package SyncML 15 */ 16 class SyncML_Device_Synthesis extends SyncML_Device { 17 18 /** 19 * Converts the content from the backend to a format suitable for the 20 * client device. 21 * 22 * Strips the uid (primary key) information as client and server might use 23 * different ones. 24 * 25 * @param string $content The content to convert 26 * @param string $contentType The contentType of content as returned from 27 * the backend 28 * @return array array($newcontent, $newcontentType): 29 * the converted content and the 30 * (possibly changed) new ContentType. 31 */ 32 function convertServer2Client($content, $contentType) 33 { 34 global $backend; 35 36 list($content, $contentType) = 37 parent::convertServer2Client($content, $contentType); 38 39 40 // Some special priority handling is required. Synthesis uses 41 // 1 (high), 2 (medium), 3(low), at least for my windows mobile device. 42 // convert these to valid priority settings: 43 $content = preg_replace('/(\r\n|\r|\n)PRIORITY:[1-2](\r\n|\r|\n)/', '\1PRIORITY:1\2', $content, 1); 44 $content = preg_replace('/(\r\n|\r|\n)PRIORITY:[3](\r\n|\r|\n)/', '\1PRIORITY:2\2', $content, 1); 45 $content = preg_replace('/(\r\n|\r|\n)PRIORITY:[4-9](\r\n|\r|\n)/', '\1PRIORITY:3\2', $content, 1); 46 47 48 // Windows Mobile also expects DUE DATES like DUE:20060419T000000 49 if (preg_match('/(\r\n|\r|\n)DUE:(........T......Z)(\r\n|\r|\n)/', 50 $content,$m)) { 51 $m[2] = $this->UTC2LocalDate($m[2]); 52 $content = preg_replace('/(\r\n|\r|\n)DUE:(........T......Z)(\r\n|\r|\n)/', 53 '\1DUE:' . $m[2] . '\3', $content, 1); 54 } 55 56 57 if (DEBUGLOG_ICALENDARDATA) { 58 $fp = @fopen('/tmp/sync/log.txt', 'a'); 59 if ($fp) { 60 @fwrite($fp, "\noutput converted for client ($contentType):\n"); 61 @fwrite($fp, $content . "\n"); 62 @fclose($fp); 63 } 64 } 65 66 return array($content, $contentType); 67 } 68 69 /** 70 * Convert the content. 71 * 72 * Currently strips uid (primary key) information as client and 73 * server might use different ones. 74 * 75 * @param string $content The content to convert. 76 * @param string $contentType The contentType of the content. 77 * @return array array($newcontent, $newcontentType): 78 * the converted content and the 79 * (possibly changed) new ContentType. 80 */ 81 function convertClient2Server($content, $contentType) 82 { 83 list($content, $contentType) = 84 parent::convertClient2Server($content, $contentType); 85 86 // Some special priority handling is required. Synthesis uses 87 // 1 (high), 2 (medium), 3(low), at least for my windows mobile device. 88 // convert these to valid priority settings: 89 $content = preg_replace('/(\r\n|\r|\n)PRIORITY:3(\r\n|\r|\n)/', '\1PRIORITY:5\2', $content, 1); 90 $content = preg_replace('/(\r\n|\r|\n)PRIORITY:2(\r\n|\r|\n)/', '\1PRIORITY:3\2', $content, 1); 91 92 if (DEBUGLOG_ICALENDARDATA) { 93 $fp = @fopen('/tmp/sync/log.txt', 'a'); 94 if ($fp) { 95 @fwrite($fp, "\ninput converted for server: $contentType\n"); 96 @fwrite($fp,$content . "\n"); 97 @fclose($fp); 98 } 99 } 100 101 return array($content, $contentType); 102 103 } 104 105 106 /* Static helper function: converts a UTC Timestamp like 20060418T220000Z 107 * into a local date like 20060419T000000. This is actually more than 108 * stripping the time part: we need to convert to local time first to ensure 109 * we get the right date! 110 */ 111 function UTC2LocalDate($s) 112 { 113 $t = Horde_iCalendar::_parseDateTime($s); 114 return date('Ymd', $t) . 'T000000'; 115 } 116 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |