本文整理汇总了PHP中OC_Image::__toString方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Image::__toString方法的具体用法?PHP OC_Image::__toString怎么用?PHP OC_Image::__toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Image
的用法示例。
在下文中一共展示了OC_Image::__toString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateImageProperty
/**
* @brief modifies a vcard property array with the image
*/
public function updateImageProperty(&$property, $entry, $version = null)
{
$image = new \OC_Image();
$image->loadFromData($entry);
if (strcmp($version, '4.0') == 0) {
$type = $image->mimeType();
} else {
$arrayType = explode('/', $image->mimeType());
$type = strtoupper(array_pop($arrayType));
}
$property->add('ENCODING', 'b');
$property->add('TYPE', $type);
$property->setValue($image->__toString());
}
示例2: bailOut
OCP\Util::writeLog('contacts', 'savecrop.php, x: ' . $x1 . ' y: ' . $y1 . ' w: ' . $w . ' h: ' . $h, OCP\Util::DEBUG);
if ($image->crop($x1, $y1, $w, $h)) {
if ($image->width() <= 200 && $image->height() <= 200 || $image->resize(200)) {
$vcard = OCA\Contacts\App::getContactVCard($id);
if (!$vcard) {
OC_Cache::remove($tmpkey);
bailOut(OCA\Contacts\App::$l10n->t('Error getting contact object.'));
}
if ($vcard->__isset('PHOTO')) {
OCP\Util::writeLog('contacts', 'savecrop.php: PHOTO property exists.', OCP\Util::DEBUG);
$property = $vcard->__get('PHOTO');
if (!$property) {
OC_Cache::remove($tmpkey);
bailOut(OCA\Contacts\App::$l10n->t('Error getting PHOTO property.'));
}
$property->setValue($image->__toString());
$property->parameters[] = new Sabre\VObject\Parameter('ENCODING', 'b');
$property->parameters[] = new Sabre\VObject\Parameter('TYPE', $image->mimeType());
$vcard->__set('PHOTO', $property);
} else {
OCP\Util::writeLog('contacts', 'savecrop.php: files: Adding PHOTO property.', OCP\Util::DEBUG);
// For vCard 3.0 the type must be e.g. JPEG or PNG
// For version 4.0 the full mimetype should be used.
// https://tools.ietf.org/html/rfc2426#section-3.1.4
$type = $vcard->VERSION == '4.0' ? $image->mimeType() : strtoupper(array_pop(explode('/', $image->mimeType())));
$vcard->add('PHOTO', $image->__toString(), array('ENCODING' => 'b', 'TYPE' => $type));
}
$now = new DateTime();
$vcard->{'REV'} = $now->format(DateTime::W3C);
if (!OCA\Contacts\VCard::edit($id, $vcard)) {
bailOut(OCA\Contacts\App::$l10n->t('Error saving contact.'));
示例3: updateVCardImageProperty
/**
* @brief modifies a vcard property array with the image
*/
public function updateVCardImageProperty(&$v_property, $ldap_entry, $version)
{
for ($i = 0; $i < count($v_property); $i++) {
$image = new \OC_Image();
$image->loadFromData($ldap_entry);
if (strcmp($version, '4.0') == 0) {
$type = $image->mimeType();
} else {
$arrayType = explode('/', $image->mimeType());
$type = strtoupper(array_pop($arrayType));
}
$v_property[$i]->add('ENCODING', 'b');
$v_property[$i]->add('TYPE', $type);
$v_property[$i]->setValue($image->__toString());
}
}
示例4: unlink
// create a new file because of caching issues.
if ($image->save($tmpfname)) {
unlink($tmp_path);
$card = OC_Contacts_App::getContactVCard($id);
if (!$card) {
unlink($tmpfname);
bailOut('Error getting contact object.');
}
if ($card->__isset('PHOTO')) {
OCP\Util::writeLog('contacts', 'savecrop.php: PHOTO property exists.', OCP\Util::DEBUG);
$property = $card->__get('PHOTO');
if (!$property) {
unlink($tmpfname);
bailOut('Error getting PHOTO property.');
}
$property->setValue($image->__toString());
$property->parameters[] = new Sabre_VObject_Parameter('ENCODING', 'b');
$property->parameters[] = new Sabre_VObject_Parameter('TYPE', $image->mimeType());
$card->__set('PHOTO', $property);
} else {
OCP\Util::writeLog('contacts', 'savecrop.php: files: Adding PHOTO property.', OCP\Util::DEBUG);
$card->addProperty('PHOTO', $image->__toString(), array('ENCODING' => 'b', 'TYPE' => $image->mimeType()));
}
$now = new DateTime();
$card->setString('REV', $now->format(DateTime::W3C));
if (!OC_Contacts_VCard::edit($id, $card)) {
bailOut('Error saving contact.');
}
unlink($tmpfname);
//$result=array( "status" => "success", 'mime'=>$image->mimeType(), 'tmp'=>$tmp_path);
$tmpl = new OCP\Template("contacts", "part.contactphoto");
示例5: toVcard
/**
* Parse contact details into the Contact object
* @param array $contact
* @return Sabre\VObject\Component
*/
public static function toVcard($contact)
{
$vcard = new \Sabre\VObject\Component('VCARD');
$vcard->setUID();
$vcard = self::_addPropertyStrings($contact, $vcard);
if (isset($contact[self::CONTACT_PHONE])) {
foreach ($contact[self::CONTACT_PHONE] as $phone) {
if (!isset($phone['value'])) {
continue;
}
$vcard->addProperty(self::CONTACT_PHONE, $phone['value']);
$line = count($vcard->children) - 1;
foreach ($phone['type'] as $type) {
$vcard->children[$line]->parameters[] = new \Sabre\VObject\Parameter('TYPE', $type);
}
}
}
if (isset($contact[self::CONTACT_CATEGORIES])) {
$categories = array();
foreach ($contact[self::CONTACT_CATEGORIES] as $categoryId) {
$categoryData = Request::getGroupDetails($categoryId);
preg_match('/<title>(.*)<\\/title>/i', $categoryData, $matches);
if (@$matches[1]) {
$categories[] = $matches[1];
}
}
if (count($categories)) {
$vcard->setString(self::CONTACT_CATEGORIES, implode(',', $categories));
}
}
if (isset($contact[self::CONTACT_ADDRESS])) {
foreach ($contact[self::CONTACT_ADDRESS] as $address) {
$vcard->addProperty(self::CONTACT_ADDRESS, $address);
$line = count($vcard->children) - 1;
$vcard->children[$line]->parameters[] = new \Sabre\VObject\Parameter('TYPE', $address['type']);
}
}
if (isset($contact[self::CONTACT_EMAIL])) {
foreach ($contact[self::CONTACT_EMAIL] as $email) {
$vcard->addProperty(self::CONTACT_EMAIL, $email['value']);
$line = count($vcard->children) - 1;
$vcard->children[$line]->parameters[] = new \Sabre\VObject\Parameter('TYPE', $email['type']);
}
}
if (isset($contact[self::CONTACT_PHOTO]) && !empty($contact[self::CONTACT_PHOTO])) {
$data = Request::getContactImage($contact[self::CONTACT_PHOTO]);
$img = new \OC_Image();
if ($img->loadFromData($data)) {
$vcard->addProperty(self::CONTACT_PHOTO, $img->__toString(), array('ENCODING' => 'b', 'TYPE' => $img->mimeType()));
} else {
App::log('Unable to parse the image provided by Google. ', \OCP\Util::WARN);
}
}
return $vcard;
}