当前位置: 首页>>代码示例>>PHP>>正文


PHP Utils::Utf8_truncate方法代码示例

本文整理汇总了PHP中Utils::Utf8_truncate方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::Utf8_truncate方法的具体用法?PHP Utils::Utf8_truncate怎么用?PHP Utils::Utf8_truncate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Utils的用法示例。


在下文中一共展示了Utils::Utf8_truncate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GetMessage


//.........这里部分代码省略.........
     }
     foreach ($response["data"]["from"] as &$from) {
         $output->from = $from[1];
     }
     $output->reply_to = array();
     //OX 0 - no prio, 2 - high, 1 - most important, 3 - normal, 5 - lowest
     //AS 0 - low, 1 - normal, 2 - important
     $normalPrio = array(0, 3);
     $highPrio = array(1, 2);
     $lowPrio = array(4, 5);
     if (in_array($response["data"]["priority"], $normalPrio)) {
         $output->importance = 1;
         ZLog::Write(LOGLEVEL_DEBUG, 'OXEmailSync::GetMessage(' . $folderid . ', ' . $id . '): Priority is "Normal"');
     } else {
         if (in_array($response["data"]["priority"], $highPrio)) {
             $output->importance = 2;
             ZLog::Write(LOGLEVEL_DEBUG, 'OXEmailSync::GetMessage(' . $folderid . ', ' . $id . '): Priority is "High"');
         } else {
             if (in_array($response["data"]["priority"], $lowPrio)) {
                 $output->importance = 0;
                 ZLog::Write(LOGLEVEL_DEBUG, 'OXEmailSync::GetMessage(' . $folderid . ', ' . $id . '): Priority is "Low"');
             }
         }
     }
     $output->subject = $response["data"]["subject"];
     // Though the unseen key is not in data we can assume the messages returned are in fact unseen
     // because of the "unseen" => true parameter to OX API (?)
     $output->read = array_key_exists("unseen", $response["data"]) && $response["data"]["unseen"] == "true" ? false : false;
     $output->datereceived = $this->OXUtils->timestampOXtoPHP($response["data"]["received_date"]);
     foreach ($response["data"]["attachments"] as $attachment) {
         ZLog::Write(LOGLEVEL_DEBUG, 'OXEmailSync::GetMessage(' . $folderid . ', ' . $id . '): Attachment "' . $attachment['id'] . '" has Contenttype "' . $attachment['content_type'] . '"');
         // Extract text/html and text/plain parts:
         $textPlain = "";
         $textHtml = "";
         if ($attachment['content_type'] == "text/plain") {
             $textPlain = html_entity_decode(str_replace("<br>", "\n", $attachment['content']), ENT_NOQUOTES, 'UTF-8');
             // OX sends the Umlauts as HTML-Tags. So we mus convert them :(.
         } else {
             if ($attachment['content_type'] == "text/html") {
                 $textHtml = $attachment['content'];
             }
         }
     }
     // Does our client understand AS-Version >= 12.0 ?
     if (Request::GetProtocolVersion() >= 12.0 && $bpReturnType == SYNC_BODYPREFERENCE_MIME) {
         $output->asbody = new SyncBaseBody();
         // For MIME-Message we need to get the Mail in "raw":
         $MIMEresponse = $this->OXConnector->OXreqGET('/ajax/mail', array('action' => 'get', 'session' => $this->OXConnector->getSession(), 'folder' => $folderid, 'id' => $id, 'unseen' => 'true', 'src' => 'true', 'timezone' => 'UTC'));
         ZLog::Write(LOGLEVEL_DEBUG, 'OXEmailSync::GetMessage(' . $folderid . ', ' . $id . '): MIME-Response: "' . print_r($MIMEresponse, true));
         $output->asbody->data = $MIMEresponse["data"];
         $output->asbody->type = SYNC_BODYPREFERENCE_MIME;
         $output->nativebodytype = SYNC_BODYPREFERENCE_MIME;
         $output->asbody->estimatedDataSize = strlen($output->asbody->data);
         $output->messageclass = "IPM.Note";
         $output->internetcpid = INTERNET_CPID_UTF8;
         $output->contentclass = "urn:content-classes:message";
         $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation());
         if (strlen($output->asbody->data) > $truncsize) {
             $output->asbody->data = Utils::Utf8_truncate($output->asbody->data, $truncsize);
             $output->asbody->truncated = 1;
         }
     } else {
         if (Request::GetProtocolVersion() >= 12.0 && !empty($textHtml) && $bpReturnType == SYNC_BODYPREFERENCE_HTML) {
             // HTML-Mails:
             $output->asbody = new SyncBaseBody();
             $output->asbody->data = $textHtml;
             $output->asbody->type = SYNC_BODYPREFERENCE_HTML;
             $output->nativebodytype = SYNC_BODYPREFERENCE_HTML;
             $output->asbody->estimatedDataSize = strlen($output->asbody->data);
             $output->messageclass = "IPM.Note";
             $output->internetcpid = INTERNET_CPID_UTF8;
             $output->contentclass = "urn:content-classes:message";
             $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation());
             if (strlen($output->asbody->data) > $truncsize) {
                 $output->asbody->data = Utils::Utf8_truncate($output->asbody->data, $truncsize);
                 $output->asbody->truncated = 1;
             }
         } else {
             if (Request::GetProtocolVersion() >= 12.0 && !empty($textPlain)) {
                 // Text-Mails:
                 $output->asbody = new SyncBaseBody();
                 $output->asbody->data = $textPlain;
                 // $textHtml;
                 $output->asbody->type = SYNC_BODYPREFERENCE_PLAIN;
                 $output->nativebodytype = SYNC_BODYPREFERENCE_PLAIN;
                 $output->asbody->estimatedDataSize = strlen($output->asbody->data);
                 $bpo = $contentparameters->BodyPreference($output->asbody->type);
                 if (Request::GetProtocolVersion() >= 14.0 && $bpo->GetPreview()) {
                     $output->asbody->preview = Utils::Utf8_truncate(Utils::ConvertHtmlToText($plainBody), $bpo->GetPreview());
                 }
             } else {
                 // Default action is to only send the textPlain-Part via AS2.5
                 $output->body = $textPlain;
                 $output->nativebodytype = SYNC_BODYPREFERENCE_PLAIN;
             }
         }
     }
     // ZLog::Write(LOGLEVEL_DEBUG, 'OXEmailSync::GetMessage(' . $folderid . ', ' . $id . ') Output: ' . print_r($output, true));
     return $output;
 }
开发者ID:aniesshsethh,项目名称:z-push-ox,代码行数:101,代码来源:emails.php

示例2: setMessageBody

 /**
  * Sets the message body
  *
  * @param MAPIMessage       $mapimessage
  * @param ContentParameters $contentparameters
  * @param SyncObject        $message
  */
 private function setMessageBody($mapimessage, $contentparameters, &$message)
 {
     //get the available body preference types
     $bpTypes = $contentparameters->GetBodyPreference();
     if ($bpTypes !== false) {
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("BodyPreference types: %s", implode(', ', $bpTypes)));
         //do not send mime data if the client requests it
         if ($contentparameters->GetMimeSupport() == SYNC_MIMESUPPORT_NEVER && ($key = array_search(SYNC_BODYPREFERENCE_MIME, $bpTypes) !== false)) {
             unset($bpTypes[$key]);
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("Remove mime body preference type because the device required no mime support. BodyPreference types: %s", implode(', ', $bpTypes)));
         }
         //get the best fitting preference type
         $bpReturnType = Utils::GetBodyPreferenceBestMatch($bpTypes);
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("GetBodyPreferenceBestMatch: %d", $bpReturnType));
         $bpo = $contentparameters->BodyPreference($bpReturnType);
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("bpo: truncation size:'%d', allornone:'%d', preview:'%d'", $bpo->GetTruncationSize(), $bpo->GetAllOrNone(), $bpo->GetPreview()));
         $this->setMessageBodyForType($mapimessage, $bpReturnType, $message);
         //only set the truncation size data if device set it in request
         if ($bpo->GetTruncationSize() != false && $bpReturnType != SYNC_BODYPREFERENCE_MIME && $message->asbody->estimatedDataSize > $bpo->GetTruncationSize() && $contentparameters->GetTruncation() != SYNC_TRUNCATION_ALL) {
             $message->asbody->data = Utils::Utf8_truncate($message->asbody->data, $bpo->GetTruncationSize());
             $message->asbody->truncated = 1;
         }
         // set the preview or windows phones won't show the preview of an email
         if (Request::GetProtocolVersion() >= 14.0 && $bpo->GetPreview()) {
             $message->asbody->preview = Utils::Utf8_truncate(MAPIUtils::readPropStream($mapimessage, PR_BODY), $bpo->GetPreview());
         }
     } else {
         // Override 'body' for truncation
         $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation());
         $this->setMessageBodyForType($mapimessage, SYNC_BODYPREFERENCE_PLAIN, $message);
         if ($message->bodysize > $truncsize) {
             $message->body = Utils::Utf8_truncate($message->body, $truncsize);
             $message->bodytruncated = 1;
         }
         if (!isset($message->body) || strlen($message->body) == 0) {
             $message->body = " ";
         }
         if ($contentparameters->GetMimeSupport() == SYNC_MIMESUPPORT_ALWAYS) {
             //set the html body for iphone in AS 2.5 version
             $this->imtoinet($mapimessage, $message);
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:z-push-svn,代码行数:50,代码来源:mapiprovider.php

示例3: GetTask

 protected function GetTask($id, $contentparameters)
 {
     $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation());
     $tasks = $this->models->execute_kw(ODOO_DB, $this->uid, $this->password, 'project.task', 'search_read', [[['user_id', '=', $this->uid], ['id', '=', intval(substr($id, 5))]]], ['fields' => ['stage_id', 'tag_ids', 'description', 'date_last_stage_update', 'date_deadline', 'priority', 'date_start', 'name']]);
     if (!count($tasks)) {
         $message = new SyncTask();
         $message->deleted = 1;
         return $message;
     }
     $task = $tasks[0];
     $stage = $this->models->execute_kw(ODOO_DB, $this->uid, $this->password, 'project.task.type', 'read', [$task['stage_id'][0]], ['fields' => []]);
     ZLog::Write(LOGLEVEL_DEBUG, 'Odoo::GetMessage: $stage = (' . print_r($stage, true)) . ')';
     if (count($stage) == 0) {
         return false;
     }
     $categories = [];
     if (isset($task['tag_ids'])) {
         $categories = $this->models->execute_kw(ODOO_DB, $this->uid, $this->password, 'project.tags', 'read', [$task['tag_ids']], ['fields' => []]);
     }
     if (isset($task['categ_ids'])) {
         $categories = $this->models->execute_kw(ODOO_DB, $this->uid, $this->password, 'project.tags', 'read', [$task['categ_ids']], ['fields' => []]);
     }
     ZLog::Write(LOGLEVEL_DEBUG, 'Odoo::GetMessage: $categories = (' . print_r($categories, true)) . ')';
     $message = new SyncTask();
     $body = $task['description'];
     $message->bodytruncated = false;
     if (strlen($body) > $truncsize) {
         $body = Utils::Utf8_truncate($body, $truncsize);
         $message->bodytruncated = true;
     }
     $message->body = str_replace("\n", "\r\n", str_replace("\r", "", $body));
     $message->asbody = new SyncBaseBody();
     $message->asbody->data = $body;
     $message->complete = 0;
     if ($stage['fold']) {
         $message->complete = 1;
         $message->datecompleted = strtotime($task['date_last_stage_update']);
     }
     if ($task['date_deadline']) {
         $message->duedate = strtotime($task['date_deadline']);
         $message->utcduedate = strtotime($task['date_deadline']);
     }
     $message->importance = intval($task['priority']);
     $message->sensitivity = 0;
     $message->startdate = strtotime($task['date_start']);
     $message->utcstartdate = strtotime($task['date_start']);
     $message->subject = $task['name'];
     $message->categories = array_map(function ($category) {
         return $category['name'];
     }, $categories);
     ZLog::Write(LOGLEVEL_DEBUG, 'Odoo::GetMessage: $message = (' . print_r($message, true) . ')');
     return $message;
 }
开发者ID:funbaker,项目名称:odoozpush,代码行数:53,代码来源:odoo.php

示例4: _ParseVEventToSyncObject


//.........这里部分代码省略.........
                         // was 1
                         break;
                     case "CONFIRMED":
                         $message->meetingstatus = "1";
                         // was 3
                         break;
                     case "CANCELLED":
                         $message->meetingstatus = "5";
                         // could also be 7
                         break;
                 }
                 break;
             case "ATTENDEE":
                 $attendee = new SyncAttendee();
                 $att_email = str_ireplace("MAILTO:", "", $property->Value());
                 $attendee->email = $att_email;
                 $att_cn = $property->GetParameterValue("CN");
                 if ($att_cn) {
                     $attendee->name = $att_cn;
                 }
                 if (isset($message->attendees) && is_array($message->attendees)) {
                     $message->attendees[] = $attendee;
                 } else {
                     $message->attendees = array($attendee);
                 }
                 break;
             case "DESCRIPTION":
                 if (Request::GetProtocolVersion() >= 12.0) {
                     $message->asbody = new SyncBaseBody();
                     $message->asbody->data = str_replace("\n", "\r\n", str_replace("\r", "", Utils::ConvertHtmlToText($property->Value())));
                     // truncate body, if requested
                     if (strlen($message->asbody->data) > $truncsize) {
                         $message->asbody->truncated = 1;
                         $message->asbody->data = Utils::Utf8_truncate($message->asbody->data, $truncsize);
                     } else {
                         $message->asbody->truncated = 0;
                     }
                     $message->nativebodytype = SYNC_BODYPREFERENCE_PLAIN;
                 } else {
                     $body = $property->Value();
                     // truncate body, if requested
                     if (strlen($body) > $truncsize) {
                         $body = Utils::Utf8_truncate($body, $truncsize);
                         $message->bodytruncated = 1;
                     } else {
                         $body = $body;
                         $message->bodytruncated = 0;
                     }
                     $body = str_replace("\n", "\r\n", str_replace("\r", "", $body));
                     $message->body = $body;
                 }
                 break;
             case "CATEGORIES":
                 $categories = explode(",", $property->Value());
                 $message->categories = $categories;
                 break;
             case "EXDATE":
                 $exception = new SyncAppointmentException();
                 $exception->deleted = "1";
                 $exception->exceptionstarttime = Utils::MakeUTCDate($property->Value());
                 if (!isset($message->exceptions)) {
                     $message->exceptions = array();
                 }
                 $message->exceptions[] = $exception;
                 break;
                 //We can ignore the following
开发者ID:alanturing1,项目名称:Z-Push-contrib,代码行数:67,代码来源:caldav.php

示例5: GetMessage

 /**
  * Returns the actual SyncXXX object type.
  *
  * @param string            $folderid           id of the parent folder
  * @param string            $id                 id of the message
  * @param ContentParameters $contentparameters  parameters of the requested message (truncation, mimesupport etc)
  *
  * @access public
  * @return object/false     false if the message could not be retrieved
  */
 public function GetMessage($folderid, $id, $contentparameters)
 {
     $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation());
     $mimesupport = $contentparameters->GetMimeSupport();
     $bodypreference = $contentparameters->GetBodyPreference();
     /* fmbiete's contribution r1528, ZP-320 */
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->GetMessage('%s','%s')", $folderid, $id));
     $folderImapid = $this->getImapIdFromFolderId($folderid);
     // Get flags, etc
     $stat = $this->StatMessage($folderid, $id);
     if ($stat) {
         $this->imap_reopenFolder($folderImapid);
         $mail = @imap_fetchheader($this->mbox, $id, FT_UID) . @imap_body($this->mbox, $id, FT_PEEK | FT_UID);
         $mobj = new Mail_mimeDecode($mail);
         $message = $mobj->decode(array('decode_headers' => true, 'decode_bodies' => true, 'include_bodies' => true, 'charset' => 'utf-8'));
         /* BEGIN fmbiete's contribution r1528, ZP-320 */
         $output = new SyncMail();
         //Select body type preference
         $bpReturnType = SYNC_BODYPREFERENCE_PLAIN;
         if ($bodypreference !== false) {
             $bpReturnType = Utils::GetBodyPreferenceBestMatch($bodypreference);
             // changed by mku ZP-330
         }
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->GetMessage - getBodyPreferenceBestMatch: %d", $bpReturnType));
         //Get body data
         $this->getBodyRecursive($message, "plain", $plainBody);
         $this->getBodyRecursive($message, "html", $htmlBody);
         if ($plainBody == "") {
             $plainBody = Utils::ConvertHtmlToText($htmlBody);
         }
         $htmlBody = str_replace("\n", "\r\n", str_replace("\r", "", $htmlBody));
         $plainBody = str_replace("\n", "\r\n", str_replace("\r", "", $plainBody));
         if (Request::GetProtocolVersion() >= 12.0) {
             $output->asbody = new SyncBaseBody();
             switch ($bpReturnType) {
                 case SYNC_BODYPREFERENCE_PLAIN:
                     $output->asbody->data = $plainBody;
                     break;
                 case SYNC_BODYPREFERENCE_HTML:
                     if ($htmlBody == "") {
                         $output->asbody->data = $plainBody;
                         $bpReturnType = SYNC_BODYPREFERENCE_PLAIN;
                     } else {
                         $output->asbody->data = $htmlBody;
                     }
                     break;
                 case SYNC_BODYPREFERENCE_MIME:
                     //We don't need to create a new MIME mail, we already have one!!
                     $output->asbody->data = $mail;
                     break;
                 case SYNC_BODYPREFERENCE_RTF:
                     ZLog::Write(LOGLEVEL_DEBUG, "BackendIMAP->GetMessage RTF Format NOT CHECKED");
                     $output->asbody->data = base64_encode($plainBody);
                     break;
             }
             // truncate body, if requested
             if (strlen($output->asbody->data) > $truncsize) {
                 $output->asbody->data = Utils::Utf8_truncate($output->asbody->data, $truncsize);
                 $output->asbody->truncated = 1;
             }
             $output->asbody->type = $bpReturnType;
             $output->nativebodytype = $bpReturnType;
             $output->asbody->estimatedDataSize = strlen($output->asbody->data);
             $bpo = $contentparameters->BodyPreference($output->asbody->type);
             if (Request::GetProtocolVersion() >= 14.0 && $bpo->GetPreview()) {
                 $output->asbody->preview = Utils::Utf8_truncate(Utils::ConvertHtmlToText($plainBody), $bpo->GetPreview());
             } else {
                 $output->asbody->truncated = 0;
             }
         } else {
             // ASV_2.5
             $output->bodytruncated = 0;
             /* BEGIN fmbiete's contribution r1528, ZP-320 */
             if ($bpReturnType == SYNC_BODYPREFERENCE_MIME) {
                 if (strlen($mail) > $truncsize) {
                     $output->mimedata = Utils::Utf8_truncate($mail, $truncsize);
                     $output->mimetruncated = 1;
                 } else {
                     $output->mimetruncated = 0;
                     $output->mimedata = $mail;
                 }
                 $output->mimesize = strlen($output->mimedata);
             } else {
                 // truncate body, if requested
                 if (strlen($plainBody) > $truncsize) {
                     $output->body = Utils::Utf8_truncate($plainBody, $truncsize);
                     $output->bodytruncated = 1;
                 } else {
                     $output->body = $plainBody;
                     $output->bodytruncated = 0;
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:z-push-svn,代码行数:101,代码来源:imap.php

示例6: _ParseLDAPMessage

 private function _ParseLDAPMessage($result_id, $entry_id, $truncsize = -1)
 {
     $contact = new SyncContact();
     $values = ldap_get_attributes($this->ldap_link, $entry_id);
     for ($i = 0; $i < $values["count"]; $i++) {
         $name = $values[$i];
         $value = $values[$name][0];
         switch ($name) {
             //person
             case "cn":
             case "fileAs":
                 $contact->fileas = $value;
                 break;
             case "sn":
                 $contact->lastname = $value;
                 break;
                 //inetOrgPerson
             //inetOrgPerson
             case "departmentNumber":
                 $contact->department = $value;
                 break;
             case "givenName":
                 $contact->firstname = $value;
                 break;
             case "homePhone":
                 $contact->homephonenumber = $value;
                 if ($values[$name]["count"] >= 2) {
                     $contact->home2phonenumber = $values[$name][1];
                 }
                 break;
             case "jpegPhoto":
                 $contact->picture = base64_encode($value);
                 break;
             case "labeledURI":
                 $contact->webpage = $value;
                 break;
             case "mail":
                 $contact->email1address = $value;
                 if ($values[$name]["count"] >= 2) {
                     $contact->email2address = $values[$name][1];
                 }
                 if ($values[$name]["count"] >= 3) {
                     $contact->email3address = $values[$name][2];
                 }
                 break;
             case "mobile":
                 $contact->mobilephonenumber = $value;
                 break;
             case "o":
                 $contact->companyname = $value;
                 break;
             case "pager":
                 $contact->pagernumber = $value;
                 break;
             case "secretary":
             case "assistantName":
                 $contact->assistantname = $value;
                 break;
                 //organizationalPerson
             //organizationalPerson
             case "l":
                 $contact->businesscity = $value;
                 break;
             case "ou":
                 $contact->department = $value;
                 break;
             case "physicalDeliveryOfficeName":
                 $contact->officelocation = $value;
                 break;
             case "postalCode":
                 $contact->businesspostalcode = $value;
                 break;
             case "st":
                 $contact->businessstate = $value;
                 break;
             case "street":
                 $contact->businessstreet = $value;
                 break;
             case "telephoneNumber":
                 $contact->businessphonenumber = $value;
                 if ($values[$name]["count"] >= 2) {
                     $contact->business2phonenumber = $values[$name][1];
                 }
                 break;
             case "title":
                 $contact->title = $value;
                 break;
             case "description":
             case "note":
                 if (Request::GetProtocolVersion() >= 12.0) {
                     $contact->asbody = new SyncBaseBody();
                     $contact->asbody->type = SYNC_BODYPREFERENCE_PLAIN;
                     $contact->asbody->data = $value;
                     if ($truncsize > 0 && $truncsize < strlen($contact->asbody->data)) {
                         $contact->asbody->truncated = 1;
                         $contact->asbody->data = Utils::Utf8_truncate($contact->asbody->data, $truncsize);
                     } else {
                         $contact->asbody->truncated = 0;
                     }
                     $contact->asbody->estimatedDataSize = strlen($contact->asbody->data);
//.........这里部分代码省略.........
开发者ID:inkoss,项目名称:karoshi-server,代码行数:101,代码来源:ldap.php

示例7: GetMessage

 /**
  * Returns the actual SyncXXX object type.
  *
  * @param string            $folderid           id of the parent folder
  * @param string            $id                 id of the message
  * @param ContentParameters $contentparameters  parameters of the requested message (truncation, mimesupport etc)
  *
  * @access public
  * @return object/false     false if the message could not be retrieved
  */
 public function GetMessage($folderid, $id, $contentparameters)
 {
     $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation());
     $mimesupport = $contentparameters->GetMimeSupport();
     $bodypreference = $contentparameters->GetBodyPreference();
     /* fmbiete's contribution r1528, ZP-320 */
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->GetMessage('%s','%s')", $folderid, $id));
     $folderImapid = $this->getImapIdFromFolderId($folderid);
     // Get flags, etc
     $stat = $this->StatMessage($folderid, $id);
     if ($stat) {
         $this->imap_reopen_folder($folderImapid);
         $mail = @imap_fetchheader($this->mbox, $id, FT_UID) . @imap_body($this->mbox, $id, FT_PEEK | FT_UID);
         if (empty($mail)) {
             throw new StatusException(sprintf("BackendIMAP->GetMessage(): Error, message not found, maybe was moved"), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT);
         }
         $mobj = new Mail_mimeDecode($mail);
         $message = $mobj->decode(array('decode_headers' => true, 'decode_bodies' => true, 'include_bodies' => true, 'charset' => 'utf-8'));
         /* BEGIN fmbiete's contribution r1528, ZP-320 */
         $output = new SyncMail();
         //Select body type preference
         $bpReturnType = SYNC_BODYPREFERENCE_PLAIN;
         if ($bodypreference !== false) {
             $bpReturnType = Utils::GetBodyPreferenceBestMatch($bodypreference);
             // changed by mku ZP-330
         }
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->GetMessage - getBodyPreferenceBestMatch: %d", $bpReturnType));
         if (is_smime($message)) {
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->GetMessage - Message is SMIME, forcing to work with MIME"));
             $bpReturnType = SYNC_BODYPREFERENCE_MIME;
         }
         //Get body data
         Mail_mimeDecode::getBodyRecursive($message, "plain", $plainBody);
         Mail_mimeDecode::getBodyRecursive($message, "html", $htmlBody);
         if ($plainBody == "") {
             $plainBody = Utils::ConvertHtmlToText($htmlBody);
         }
         $htmlBody = str_replace("\n", "\r\n", str_replace("\r", "", $htmlBody));
         $plainBody = str_replace("\n", "\r\n", str_replace("\r", "", $plainBody));
         if (Request::GetProtocolVersion() >= 12.0) {
             $output->asbody = new SyncBaseBody();
             switch ($bpReturnType) {
                 case SYNC_BODYPREFERENCE_PLAIN:
                     $output->asbody->data = $plainBody;
                     break;
                 case SYNC_BODYPREFERENCE_HTML:
                     if ($htmlBody == "") {
                         $output->asbody->data = $plainBody;
                         $bpReturnType = SYNC_BODYPREFERENCE_PLAIN;
                     } else {
                         $output->asbody->data = $htmlBody;
                     }
                     break;
                 case SYNC_BODYPREFERENCE_MIME:
                     if (is_smime($message)) {
                         $output->asbody->data = $mail;
                     } else {
                         $output->asbody->data = build_mime_message($message);
                     }
                     break;
                 case SYNC_BODYPREFERENCE_RTF:
                     ZLog::Write(LOGLEVEL_DEBUG, "BackendIMAP->GetMessage RTF Format NOT CHECKED");
                     $output->asbody->data = base64_encode($plainBody);
                     break;
             }
             // truncate body, if requested, but never truncate MIME messages
             if ($bpReturnType !== SYNC_BODYPREFERENCE_MIME && strlen($output->asbody->data) > $truncsize) {
                 $output->asbody->data = Utils::Utf8_truncate($output->asbody->data, $truncsize);
                 $output->asbody->truncated = 1;
             } else {
                 $output->asbody->truncated = 0;
             }
             $output->asbody->type = $bpReturnType;
             if ($bpReturnType == SYNC_BODYPREFERENCE_MIME) {
                 $output->nativebodytype = SYNC_BODYPREFERENCE_PLAIN;
                 // http://msdn.microsoft.com/en-us/library/ee220018%28v=exchg.80%29.aspx
             } else {
                 $output->nativebodytype = $bpReturnType;
             }
             $output->asbody->estimatedDataSize = strlen($output->asbody->data);
             $bpo = $contentparameters->BodyPreference($output->asbody->type);
             if (Request::GetProtocolVersion() >= 14.0 && $bpo->GetPreview()) {
                 $output->asbody->preview = Utils::Utf8_truncate(Utils::ConvertHtmlToText($plainBody), $bpo->GetPreview());
             }
         } else {
             // ASV_2.5
             $output->bodytruncated = 0;
             /* BEGIN fmbiete's contribution r1528, ZP-320 */
             if ($bpReturnType == SYNC_BODYPREFERENCE_MIME) {
                 // truncate body, if requested, but never truncate MIME messages
//.........这里部分代码省略.........
开发者ID:alanturing1,项目名称:Z-Push-contrib,代码行数:101,代码来源:imap.php

示例8: GetMessage

 /**
  * Returns the actual SyncXXX object type.
  *
  * @param string            $folderid           id of the parent folder
  * @param string            $id                 id of the message
  * @param ContentParameters $contentparameters  parameters of the requested message (truncation, mimesupport etc)
  *
  * @access public
  * @return object/false     false if the message could not be retrieved
  */
 public function GetMessage($folderid, $id, $contentparameters)
 {
     $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation());
     $mimesupport = $contentparameters->GetMimeSupport();
     $bodypreference = $contentparameters->GetBodyPreference();
     /* fmbiete's contribution r1528, ZP-320 */
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->GetMessage('%s', '%s', '%s')", $folderid, $id, implode(",", $bodypreference)));
     $folderImapid = $this->getImapIdFromFolderId($folderid);
     // Get flags, etc
     $stat = $this->StatMessage($folderid, $id);
     if ($stat) {
         $this->imap_reopen_folder($folderImapid);
         $mail = @imap_fetchheader($this->mbox, $id, FT_UID) . @imap_body($this->mbox, $id, FT_PEEK | FT_UID);
         if (empty($mail)) {
             throw new StatusException(sprintf("BackendIMAP->GetMessage(): Error, message not found, maybe was moved"), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT);
         }
         $mobj = new Mail_mimeDecode($mail);
         $message = $mobj->decode(array('decode_headers' => true, 'decode_bodies' => true, 'include_bodies' => true, 'rfc_822bodies' => true, 'charset' => 'utf-8'));
         $is_multipart = is_multipart($message);
         $is_smime = is_smime($message);
         $is_encrypted = $is_smime ? is_encrypted($message) : false;
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->GetMessage(): Message is multipart: %d, smime: %d, smime encrypted: %d", $is_multipart, $is_smime, $is_encrypted));
         //Select body type preference
         $bpReturnType = SYNC_BODYPREFERENCE_PLAIN;
         if ($bodypreference !== false) {
             $bpReturnType = Utils::GetBodyPreferenceBestMatch($bodypreference);
             // changed by mku ZP-330
         }
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->GetMessage(): getBodyPreferenceBestMatch: %d", $bpReturnType));
         // Prefered format is MIME -OR- message is SMIME -OR- the device supports MIME (iPhone) and doesn't really understand HTML
         if ($bpReturnType == SYNC_BODYPREFERENCE_MIME || $is_smime || in_array(SYNC_BODYPREFERENCE_MIME, $bodypreference)) {
             $bpReturnType = SYNC_BODYPREFERENCE_MIME;
         }
         // We need the text body even though MIME is used, for the preview
         $textBody = "";
         Mail_mimeDecode::getBodyRecursive($message, "html", $textBody, true);
         if (strlen($textBody) > 0) {
             if ($bpReturnType != SYNC_BODYPREFERENCE_MIME) {
                 $bpReturnType = SYNC_BODYPREFERENCE_HTML;
             }
         } else {
             Mail_mimeDecode::getBodyRecursive($message, "plain", $textBody, true);
             if ($bpReturnType != SYNC_BODYPREFERENCE_MIME) {
                 $bpReturnType = SYNC_BODYPREFERENCE_PLAIN;
             }
         }
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->GetMessage(): after thinking a bit we will use: %d", $bpReturnType));
         $output = new SyncMail();
         if (Request::GetProtocolVersion() >= 12.0) {
             $output->asbody = new SyncBaseBody();
             switch ($bpReturnType) {
                 case SYNC_BODYPREFERENCE_PLAIN:
                     $output->asbody->data = $textBody;
                     break;
                 case SYNC_BODYPREFERENCE_HTML:
                     $output->asbody->data = $textBody;
                     break;
                 case SYNC_BODYPREFERENCE_MIME:
                     if ($is_smime) {
                         $output->asbody->data = $mail;
                         if ($is_encrypted) {
                             // #190, KD 2015-06-04 - If message body is encrypted we'd drop it as data should only be in the attachment but... there's no good way to let only headers through...
                             $truncsize = 500;
                         }
                     } else {
                         $output->asbody->data = build_mime_message($message);
                     }
                     break;
                 case SYNC_BODYPREFERENCE_RTF:
                     ZLog::Write(LOGLEVEL_DEBUG, "BackendIMAP->GetMessage(): RTF Format NOT CHECKED");
                     $output->asbody->data = base64_encode($textBody);
                     break;
             }
             // truncate body, if requested.
             // MIME should not be truncated, but encrypted messages are truncated always to a minimal fixed size
             if (($bpReturnType !== SYNC_BODYPREFERENCE_MIME || $is_encrypted) && strlen($output->asbody->data) > $truncsize) {
                 $output->asbody->data = Utils::Utf8_truncate($output->asbody->data, $truncsize);
                 $output->asbody->truncated = 1;
             } else {
                 $output->asbody->truncated = 0;
             }
             $output->asbody->type = $bpReturnType;
             if ($bpReturnType == SYNC_BODYPREFERENCE_MIME) {
                 // NativeBodyType can be only (1 => PLAIN, 2 => HTML, 3 => RTF). MIME uses 1
                 $output->nativebodytype = SYNC_BODYPREFERENCE_PLAIN;
             } else {
                 $output->nativebodytype = $bpReturnType;
             }
             $output->asbody->estimatedDataSize = strlen($output->asbody->data);
             $bpo = $contentparameters->BodyPreference($output->asbody->type);
//.........这里部分代码省略.........
开发者ID:peterbeck,项目名称:Z-Push-contrib,代码行数:101,代码来源:imap.php

示例9: ParseFromVCard


//.........这里部分代码省略.........
         foreach ($vcard['adr'] as $adr) {
             if (empty($adr['type'])) {
                 $a = 'other';
             } elseif (in_array('home', $adr['type'])) {
                 $a = 'home';
             } elseif (in_array('work', $adr['type'])) {
                 $a = 'business';
             } else {
                 $a = 'other';
             }
             if (!empty($adr['val'][2])) {
                 $b = $a . 'street';
                 $message->{$b} = $adr['val'][2];
             }
             if (!empty($adr['val'][3])) {
                 $b = $a . 'city';
                 $message->{$b} = $adr['val'][3];
             }
             if (!empty($adr['val'][4])) {
                 $b = $a . 'state';
                 $message->{$b} = $adr['val'][4];
             }
             if (!empty($adr['val'][5])) {
                 $b = $a . 'postalcode';
                 $message->{$b} = $adr['val'][5];
             }
             if (!empty($adr['val'][6])) {
                 $b = $a . 'country';
                 $message->{$b} = $adr['val'][6];
             }
         }
     }
     if (!empty($vcard['fn'][0]['val'][0])) {
         $message->fileas = $vcard['fn'][0]['val'][0];
     }
     if (!empty($vcard['n'][0]['val'][0])) {
         $message->lastname = $vcard['n'][0]['val'][0];
     }
     if (!empty($vcard['n'][0]['val'][1])) {
         $message->firstname = $vcard['n'][0]['val'][1];
     }
     if (!empty($vcard['n'][0]['val'][2])) {
         $message->middlename = $vcard['n'][0]['val'][2];
     }
     if (!empty($vcard['n'][0]['val'][3])) {
         $message->title = $vcard['n'][0]['val'][3];
     }
     if (!empty($vcard['n'][0]['val'][4])) {
         $message->suffix = $vcard['n'][0]['val'][4];
     }
     if (!empty($vcard['nickname'][0]['val'][0])) {
         $message->nickname = $vcard['nickname'][0]['val'][0];
     }
     if (!empty($vcard['bday'][0]['val'][0])) {
         $tz = date_default_timezone_get();
         date_default_timezone_set('UTC');
         $message->birthday = strtotime($vcard['bday'][0]['val'][0]);
         date_default_timezone_set($tz);
     }
     if (!empty($vcard['org'][0]['val'][0])) {
         $message->companyname = $vcard['org'][0]['val'][0];
     }
     if (!empty($vcard['note'][0]['val'][0])) {
         if (Request::GetProtocolVersion() >= 12.0) {
             $message->asbody = new SyncBaseBody();
             $message->asbody->type = SYNC_BODYPREFERENCE_PLAIN;
             $message->asbody->data = $vcard['note'][0]['val'][0];
             if ($truncsize > 0 && $truncsize < strlen($message->asbody->data)) {
                 $message->asbody->truncated = 1;
                 $message->asbody->data = Utils::Utf8_truncate($message->asbody->data, $truncsize);
             } else {
                 $message->asbody->truncated = 0;
             }
             $message->asbody->estimatedDataSize = strlen($message->asbody->data);
         } else {
             $message->body = $vcard['note'][0]['val'][0];
             if ($truncsize > 0 && $truncsize < strlen($message->body)) {
                 $message->bodytruncated = 1;
                 $message->body = Utils::Utf8_truncate($message->body, $truncsize);
             } else {
                 $message->bodytruncated = 0;
             }
             $message->bodysize = strlen($message->body);
         }
     }
     if (!empty($vcard['role'][0]['val'][0])) {
         $message->jobtitle = $vcard['role'][0]['val'][0];
     }
     //$vcard['title'][0]['val'][0]
     if (!empty($vcard['url'][0]['val'][0])) {
         $message->webpage = $vcard['url'][0]['val'][0];
     }
     if (!empty($vcard['categories'][0]['val'])) {
         $message->categories = $vcard['categories'][0]['val'];
     }
     if (!empty($vcard['photo'][0]['val'][0])) {
         $message->picture = base64_encode($vcard['photo'][0]['val'][0]);
     }
     return $message;
 }
开发者ID:alanturing1,项目名称:Z-Push-contrib,代码行数:101,代码来源:carddav.php

示例10: GetMessage

 /**
  * Returns the actual SyncXXX object type.
  *
  * @param string            $folderid           id of the parent folder
  * @param string            $id                 id of the message
  * @param ContentParameters $contentparameters  parameters of the requested message (truncation, mimesupport etc)
  *
  * @access public
  * @return object/false     false if the message could not be retrieved
  */
 public function GetMessage($folderid, $id, $contentparameters)
 {
     $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation());
     $mimesupport = $contentparameters->GetMimeSupport();
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->GetMessage('%s','%s')", $folderid, $id));
     $folderImapid = $this->getImapIdFromFolderId($folderid);
     // Get flags, etc
     $stat = $this->StatMessage($folderid, $id);
     if ($stat) {
         $this->imap_reopenFolder($folderImapid);
         $mail = @imap_fetchheader($this->mbox, $id, FT_UID) . @imap_body($this->mbox, $id, FT_PEEK | FT_UID);
         $mobj = new Mail_mimeDecode($mail);
         $message = $mobj->decode(array('decode_headers' => true, 'decode_bodies' => true, 'include_bodies' => true, 'charset' => 'utf-8'));
         $output = new SyncMail();
         $body = $this->getBody($message);
         $output->bodysize = strlen($body);
         // truncate body, if requested
         if (strlen($body) > $truncsize) {
             $body = Utils::Utf8_truncate($body, $truncsize);
             $output->bodytruncated = 1;
         } else {
             $body = $body;
             $output->bodytruncated = 0;
         }
         $body = str_replace("\n", "\r\n", str_replace("\r", "", $body));
         $output->body = $body;
         $output->datereceived = isset($message->headers["date"]) ? $this->cleanupDate($message->headers["date"]) : null;
         $output->messageclass = "IPM.Note";
         $output->subject = isset($message->headers["subject"]) ? $message->headers["subject"] : "";
         $output->read = $stat["flags"];
         $output->from = isset($message->headers["from"]) ? $message->headers["from"] : null;
         $Mail_RFC822 = new Mail_RFC822();
         $toaddr = $ccaddr = $replytoaddr = array();
         if (isset($message->headers["to"])) {
             $toaddr = $Mail_RFC822->parseAddressList($message->headers["to"]);
         }
         if (isset($message->headers["cc"])) {
             $ccaddr = $Mail_RFC822->parseAddressList($message->headers["cc"]);
         }
         if (isset($message->headers["reply_to"])) {
             $replytoaddr = $Mail_RFC822->parseAddressList($message->headers["reply_to"]);
         }
         $output->to = array();
         $output->cc = array();
         $output->reply_to = array();
         foreach (array("to" => $toaddr, "cc" => $ccaddr, "reply_to" => $replytoaddr) as $type => $addrlist) {
             foreach ($addrlist as $addr) {
                 $address = $addr->mailbox . "@" . $addr->host;
                 $name = $addr->personal;
                 if (!isset($output->displayto) && $name != "") {
                     $output->displayto = $name;
                 }
                 if ($name == "" || $name == $address) {
                     $fulladdr = w2u($address);
                 } else {
                     if (substr($name, 0, 1) != '"' && substr($name, -1) != '"') {
                         $fulladdr = "\"" . w2u($name) . "\" <" . w2u($address) . ">";
                     } else {
                         $fulladdr = w2u($name) . " <" . w2u($address) . ">";
                     }
                 }
                 array_push($output->{$type}, $fulladdr);
             }
         }
         // convert mime-importance to AS-importance
         if (isset($message->headers["x-priority"])) {
             $mimeImportance = preg_replace("/\\D+/", "", $message->headers["x-priority"]);
             if ($mimeImportance > 3) {
                 $output->importance = 0;
             }
             if ($mimeImportance == 3) {
                 $output->importance = 1;
             }
             if ($mimeImportance < 3) {
                 $output->importance = 2;
             }
         }
         // Attachments are only searched in the top-level part
         if (isset($message->parts)) {
             $mparts = $message->parts;
             for ($i = 0; $i < count($mparts); $i++) {
                 $part = $mparts[$i];
                 //recursively add parts
                 if ($part->ctype_primary == "multipart" && ($part->ctype_secondary == "mixed" || $part->ctype_secondary == "alternative" || $part->ctype_secondary == "related")) {
                     foreach ($part->parts as $spart) {
                         $mparts[] = $spart;
                     }
                     continue;
                 }
                 //add part as attachment if it's disposition indicates so or if it is not a text part
//.........这里部分代码省略.........
开发者ID:karanikn,项目名称:php-addressbook,代码行数:101,代码来源:imap.php

示例11: setMessageBody

 /**
  * Sets the message body.
  *
  * @param MAPIMessage       $mapimessage
  * @param ContentParameters $contentparameters
  * @param SyncObject        $message
  */
 private function setMessageBody($mapimessage, $contentparameters, &$message)
 {
     //get the available body preference types
     $bpTypes = $contentparameters->GetBodyPreference();
     if ($bpTypes !== false) {
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("BodyPreference types: %s", implode(', ', $bpTypes)));
         //do not send mime data if the client requests it
         if ($contentparameters->GetMimeSupport() == SYNC_MIMESUPPORT_NEVER && ($key = array_search(SYNC_BODYPREFERENCE_MIME, $bpTypes) !== false)) {
             unset($bpTypes[$key]);
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("Remove mime body preference type because the device required no mime support. BodyPreference types: %s", implode(', ', $bpTypes)));
         }
         //get the best fitting preference type
         $bpReturnType = Utils::GetBodyPreferenceBestMatch($bpTypes);
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("GetBodyPreferenceBestMatch: %d", $bpReturnType));
         $bpo = $contentparameters->BodyPreference($bpReturnType);
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("bpo: truncation size:'%d', allornone:'%d', preview:'%d'", $bpo->GetTruncationSize(), $bpo->GetAllOrNone(), $bpo->GetPreview()));
         $this->setMessageBodyForType($mapimessage, $bpReturnType, $message);
         //only set the truncation size data if device set it in request
         if ($bpo->GetTruncationSize() != false && $bpReturnType != SYNC_BODYPREFERENCE_MIME && $message->asbody->estimatedDataSize > $bpo->GetTruncationSize()) {
             // Truncated plaintext requests are used on iOS for the preview in the email list. All images and links should be removed - see https://jira.z-hub.io/browse/ZP-1025
             if ($bpReturnType == SYNC_BODYPREFERENCE_PLAIN) {
                 ZLog::Write(LOGLEVEL_DEBUG, "MAPIProvider->setMessageBody(): truncated plain-text body requested, stripping all links and images");
                 // Get more data because of the filtering it's most probably going down in size. It's going to be truncated to the correct size below.
                 $plainbody = stream_get_contents($message->asbody->data, $bpo->GetTruncationSize() * 3);
                 $message->asbody->data = StringStreamWrapper::Open(preg_replace('/<http(s){0,1}:\\/\\/.*?>/i', '', $plainbody));
             }
             // truncate data stream
             ftruncate($message->asbody->data, $bpo->GetTruncationSize());
             $message->asbody->truncated = 1;
         }
         // set the preview or windows phones won't show the preview of an email
         if (Request::GetProtocolVersion() >= 14.0 && $bpo->GetPreview()) {
             $message->asbody->preview = Utils::Utf8_truncate(MAPIUtils::readPropStream($mapimessage, PR_BODY), $bpo->GetPreview());
         }
     } else {
         // Override 'body' for truncation
         $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation());
         $this->setMessageBodyForType($mapimessage, SYNC_BODYPREFERENCE_PLAIN, $message);
         if ($message->bodysize > $truncsize) {
             $message->body = Utils::Utf8_truncate($message->body, $truncsize);
             $message->bodytruncated = 1;
         }
         if (!isset($message->body) || strlen($message->body) == 0) {
             $message->body = " ";
         }
         if ($contentparameters->GetMimeSupport() == SYNC_MIMESUPPORT_ALWAYS) {
             //set the html body for iphone in AS 2.5 version
             $this->imtoinet($mapimessage, $message);
         }
     }
 }
开发者ID:EGroupware,项目名称:z-push,代码行数:58,代码来源:mapiprovider.php

示例12: stream_truncate

 /**
  * Truncates the stream to the new size.
  *
  * @param int $new_size
  * @return boolean
  */
 public function stream_truncate($new_size)
 {
     // cut the string!
     $this->stringstream = Utils::Utf8_truncate($this->stringstream, $new_size);
     $this->streamlength = strlen($this->stringstream);
     if ($this->position > $this->streamlength) {
         ZLog::Write(LOGLEVEL_WARN, sprintf("StringStreamWrapper->stream_truncate(): stream position (%d) ahead of new size of %d. Repositioning pointer to end of stream.", $this->position, $this->streamlength));
         $this->position = $this->streamlength;
     }
     return true;
 }
开发者ID:EGroupware,项目名称:z-push,代码行数:17,代码来源:stringstreamwrapper.php

示例13: _ParseVCardToAS

 /**
  * Convert a VCard to ActiveSync format
  * @param vcard $data
  * @param ContentParameters $contentparameters
  * @return SyncContact
  */
 private function _ParseVCardToAS($data, $contentparameters)
 {
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV->_ParseVCardToAS(vCard[%s])", $data));
     $truncsize = Utils::GetTruncSize($contentparameters->GetTruncation());
     $vCard = new vCard(false, $data);
     if (count($vCard) != 1) {
         ZLog::Write(LOGLEVEL_WARN, sprintf("BackendCardDAV->_ParseVCardToAS(): Error parsing vCard[%s]", $data));
         return false;
     }
     $card = $vCard->access();
     $mapping = array('fn' => 'fileas', 'n' => array('LastName' => 'lastname', 'FirstName' => 'firstname'), 'tel' => array('home' => 'homephonenumber', 'cell' => 'mobilephonenumber', 'work' => 'businessphonenumber', 'fax' => 'businessfaxnumber', 'pager' => 'pagernumber'), 'email' => array('work' => 'email1address', 'home' => 'email2address'), 'url' => array('work' => 'webpage', 'home' => 'webpage'), 'bday' => 'birthday', 'title' => 'jobtitle', 'note' => 'body', 'org' => array('Name' => 'companyname', 'Unit1' => 'department'), 'adr' => array('work' => array('POBox' => '', 'ExtendedAddress' => '', 'StreetAddress' => 'businessstreet', 'Locality' => 'businesscity', 'Region' => 'businessstate', 'PostalCode' => 'businesspostalcode', 'Country' => 'businesscountry'), 'home' => array('POBox' => '', 'ExtendedAddress' => '', 'StreetAddress' => 'homestreet', 'Locality' => 'homecity', 'Region' => 'homestate', 'PostalCode' => 'homepostalcode', 'Country' => 'homecountry')), 'photo' => array('jpeg' => 'picture'), 'x-aim' => 'imaddress');
     $message = new SyncContact();
     foreach ($mapping as $vcard_attribute => $ms_attribute) {
         //ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV->_ParseVCardToAS(vCard[%s] => ms[%s])", $vcard_attribute, $ms_attribute));
         if (empty($card[$vcard_attribute])) {
             continue;
         }
         if (is_array($card[$vcard_attribute])) {
             // tel;email;url;org
             foreach ($card[$vcard_attribute] as $key => $value) {
                 if (empty($value) || empty($ms_attribute[$key])) {
                     continue;
                 }
                 // adr
                 if (is_array($value)) {
                     foreach ($value as $adrkey => $adrvalue) {
                         if (empty($adrvalue) || empty($ms_attribute[$key][$adrkey])) {
                             continue;
                         }
                         $message->{$ms_attribute}[$key][$adrkey] = $adrvalue;
                     }
                 } else {
                     $message->{$ms_attribute}[$key] = $value;
                 }
             }
         } else {
             if ($vcard_attribute === "note" && !empty($card[$vcard_attribute])) {
                 $body = $card[$vcard_attribute];
                 // truncate body, if requested
                 if (strlen($body) > $truncsize) {
                     $body = Utils::Utf8_truncate($body, $truncsize);
                     $message->bodytruncated = 1;
                 } else {
                     $body = $body;
                     $message->bodytruncated = 0;
                 }
                 $body = str_replace("\n", "\r\n", str_replace("\r", "", $body));
                 $message->body = $body;
                 $message->bodysize = strlen($body);
             } else {
                 if ($vcard_attribute === "bday" && !empty($card[$vcard_attribute])) {
                     $tz = date_default_timezone_get();
                     date_default_timezone_set('UTC');
                     $message->{$ms_attribute} = strtotime($card[$vcard_attribute]);
                     date_default_timezone_set($tz);
                 } else {
                     $message->{$ms_attribute} = $card[$vcard_attribute];
                 }
             }
         }
     }
     if (isset($card['nickname']) && !empty($card['nickname']) && is_array($card['nickname'])) {
         $message->nickname = $card['nickname'][0];
     }
     if (isset($card['categories']) && !empty($card['categories'])) {
         $message->categories = implode(',', $card['categories']);
         $itemTagNames = array();
         for ($i = 0; $i < count($card['categories']); $i++) {
             //print $card['categories'][$i] ."\n";
             $itemTagNames[] = $card['categories'][$i];
         }
         //print "message->categories=". $card['categories'] ."\n";
         $message->categories = $itemTagNames;
     }
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV->_ParseVCardToAS(vCard fileas [%s])", $message->fileas));
     return $message;
     /*
     	$mapping = array(
     		'FN' => 'fileas',
     		'N' => 'lastname;firstname',
     		'NICKNAME' => 'nickname', // Only one in active Sync
     		'TEL;TYPE=home' => 'homephonenumber',
     		'TEL;TYPE=cell' => 'mobilephonenumber',
     		'TEL;TYPE=work' => 'businessphonenumber',
     		'TEL;TYPE=fax' => 'businessfaxnumber',
     		'TEL;TYPE=pager' => 'pagernumber',
     		'EMAIL;TYPE=work' => 'email1address',
     		'EMAIL;TYPE=home' => 'email2address',
     		'URL;TYPE=home' => 'webpage', // does not exist in ActiveSync
     		'URL;TYPE=work' => 'webpage',
     		'BDAY' => 'birthday',
     		// 'ROLE' => 'jobtitle', iOS take it as 'TITLE' Does not make sense?
     		'TITLE' => 'jobtitle',
     		'NOTE' => 'body',
//.........这里部分代码省略.........
开发者ID:netconstructor,项目名称:sogosync,代码行数:101,代码来源:carddav.php

示例14: stream_read

 /**
  * Reads from stream
  *
  * @param int $len      amount of bytes to be read
  *
  * @access public
  * @return string
  */
 public function stream_read($len)
 {
     $len = $this->position + $len > $this->streamlength ? $this->streamlength - $this->position : $len;
     // read 4 additional bytes from the stream so we can always truncate correctly
     if ($this->toTruncate && $this->position + $len >= $this->streamlength) {
         $len += 4;
     }
     if ($this->mapistream) {
         $data = mapi_stream_read($this->mapistream, $len);
     } else {
         $data = "";
     }
     $this->position += strlen($data);
     // we need to truncate UTF8 compatible if ftruncate() was called
     if ($this->toTruncate && $this->position >= $this->streamlength) {
         $data = Utils::Utf8_truncate($data, $this->streamlength);
     }
     return $data;
 }
开发者ID:EGroupware,项目名称:z-push,代码行数:27,代码来源:mapistreamwrapper.php

示例15: define

<?php

// Test MIME preview
// This code will extract the preview text for a message
require_once 'vendor/autoload.php';
define('LOGLEVEL', LOGLEVEL_DEBUG);
define('LOGUSERLEVEL', LOGLEVEL_DEVICEID);
$file = "testing/samples/messages/zpush-html-preview-bug.txt";
$mobj = new Mail_mimeDecode(file_get_contents($file));
$message = $mobj->decode(array('decode_headers' => true, 'decode_bodies' => true, 'include_bodies' => true, 'rfc_822bodies' => true, 'charset' => 'utf-8'));
unset($mobj);
$previewText = "";
Mail_mimeDecode::getBodyRecursive($message, "plain", $previewText, true);
if (strlen($previewText) == 0) {
    printf("No Plain part found\n");
    Mail_mimeDecode::getBodyRecursive($message, "html", $previewText, true);
    $previewText = Utils::ConvertHtmlToText($previewText);
}
printf("%s\n", Utils::Utf8_truncate($previewText, 250));
开发者ID:polytan02,项目名称:z-push_ynh,代码行数:19,代码来源:testing-mime_preview.php


注:本文中的Utils::Utf8_truncate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。