本文整理匯總了PHP中Sabre\VObject\Component::children方法的典型用法代碼示例。如果您正苦於以下問題:PHP Component::children方法的具體用法?PHP Component::children怎麽用?PHP Component::children使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sabre\VObject\Component
的用法示例。
在下文中一共展示了Component::children方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: convertVCard30toVCard21
/**
* Converts a vcalendar 1.0 component to an icalendar 2.0 component.
*
* @param Sabre_VObject_Component $vobject
*/
public static function convertVCard30toVCard21(Sabre\VObject\Component $vobject)
{
$qpProperies = array('NOTE', 'FN', 'N');
if ($vobject->version == '3.0') {
//vcard 3.0 uses EMAIL;TYPE=INTERNET,HOME:mschering@intermesh.nl
//We must convert that into EMAIL;INTERNET;HOME:mschering@intermesh.nl for 2.1
$children = $vobject->children();
foreach ($children as $property) {
if (!empty($property['TYPE'])) {
$types = explode(',', $property['TYPE']);
$property->name .= ';' . implode(';', $types);
unset($property['TYPE']);
}
}
$vobject->version = '2.1';
foreach ($qpProperies as $propName) {
self::_quotedPrintableEncode($vobject, $propName);
}
}
}
示例2: serializeComponent
protected function serializeComponent(Component $vObj)
{
$this->cWrite('cyan', 'BEGIN');
$this->cWrite('red', ':');
$this->cWrite('yellow', $vObj->name . "\n");
/**
* Gives a component a 'score' for sorting purposes.
*
* This is solely used by the childrenSort method.
*
* A higher score means the item will be lower in the list.
* To avoid score collisions, each "score category" has a reasonable
* space to accomodate elements. The $key is added to the $score to
* preserve the original relative order of elements.
*
* @param int $key
* @param array $array
*
* @return int
*/
$sortScore = function ($key, $array) {
if ($array[$key] instanceof Component) {
// We want to encode VTIMEZONE first, this is a personal
// preference.
if ($array[$key]->name === 'VTIMEZONE') {
$score = 300000000;
return $score + $key;
} else {
$score = 400000000;
return $score + $key;
}
} else {
// Properties get encoded first
// VCARD version 4.0 wants the VERSION property to appear first
if ($array[$key] instanceof Property) {
if ($array[$key]->name === 'VERSION') {
$score = 100000000;
return $score + $key;
} else {
// All other properties
$score = 200000000;
return $score + $key;
}
}
}
};
$children = $vObj->children();
$tmp = $children;
uksort($children, function ($a, $b) use($sortScore, $tmp) {
$sA = $sortScore($a, $tmp);
$sB = $sortScore($b, $tmp);
return $sA - $sB;
});
foreach ($children as $child) {
if ($child instanceof Component) {
$this->serializeComponent($child);
} else {
$this->serializeProperty($child);
}
}
$this->cWrite('cyan', 'END');
$this->cWrite('red', ':');
$this->cWrite('yellow', $vObj->name . "\n");
}
示例3: removeXOCAttrFromComponent
/**
* remove certain X-OC-* properties from a Sabre Component
* @param Component &$component
*/
public static function removeXOCAttrFromComponent(Component &$component)
{
foreach ($component->children() as $child) {
if ($child instanceof Component) {
self::removeXOCAttrFromComponent($child);
} elseif (substr($child->name, 0, 5) === 'X-OC-') {
switch ($child->name) {
case 'X-OC-ETAG':
case 'X-OC-URI':
unset($component->{$child->name});
break;
default:
break;
}
}
}
}