本文整理汇总了PHP中Sabre\VObject\Component::getDocumentType方法的典型用法代码示例。如果您正苦于以下问题:PHP Component::getDocumentType方法的具体用法?PHP Component::getDocumentType怎么用?PHP Component::getDocumentType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sabre\VObject\Component
的用法示例。
在下文中一共展示了Component::getDocumentType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readProperty
/**
* Reads a property or component from a line.
*
* @return void
*/
protected function readProperty($line)
{
if ($this->options & self::OPTION_FORGIVING) {
$propNameToken = 'A-Z0-9\\-\\._\\/';
} else {
$propNameToken = 'A-Z0-9\\-\\.';
}
$paramNameToken = 'A-Z0-9\\-';
$safeChar = '^";:,';
$qSafeChar = '^"';
$regex = "/\n ^(?P<name> [{$propNameToken}]+ ) (?=[;:]) # property name\n |\n (?<=:)(?P<propValue> .+)\$ # property value\n |\n ;(?P<paramName> [{$paramNameToken}]+) (?=[=;:]) # parameter name\n |\n (=|,)(?P<paramValue> # parameter value\n (?: [{$safeChar}]*) |\n \"(?: [{$qSafeChar}]+)\"\n ) (?=[;:,])\n /xi";
//echo $regex, "\n"; die();
preg_match_all($regex, $line, $matches, PREG_SET_ORDER);
$property = ['name' => null, 'parameters' => [], 'value' => null];
$lastParam = null;
/**
* Looping through all the tokens.
*
* Note that we are looping through them in reverse order, because if a
* sub-pattern matched, the subsequent named patterns will not show up
* in the result.
*/
foreach ($matches as $match) {
if (isset($match['paramValue'])) {
if ($match['paramValue'] && $match['paramValue'][0] === '"') {
$value = substr($match['paramValue'], 1, -1);
} else {
$value = $match['paramValue'];
}
$value = $this->unescapeParam($value);
if (is_null($lastParam)) {
throw new ParseException('Invalid Mimedir file. Line starting at ' . $this->startLine . ' did not follow iCalendar/vCard conventions');
}
if (is_null($property['parameters'][$lastParam])) {
$property['parameters'][$lastParam] = $value;
} elseif (is_array($property['parameters'][$lastParam])) {
$property['parameters'][$lastParam][] = $value;
} else {
$property['parameters'][$lastParam] = [$property['parameters'][$lastParam], $value];
}
continue;
}
if (isset($match['paramName'])) {
$lastParam = strtoupper($match['paramName']);
if (!isset($property['parameters'][$lastParam])) {
$property['parameters'][$lastParam] = null;
}
continue;
}
if (isset($match['propValue'])) {
$property['value'] = $match['propValue'];
continue;
}
if (isset($match['name']) && $match['name']) {
$property['name'] = strtoupper($match['name']);
continue;
}
// @codeCoverageIgnoreStart
throw new \LogicException('This code should not be reachable');
// @codeCoverageIgnoreEnd
}
if (is_null($property['value'])) {
$property['value'] = '';
}
if (!$property['name']) {
if ($this->options & self::OPTION_IGNORE_INVALID_LINES) {
return false;
}
throw new ParseException('Invalid Mimedir file. Line starting at ' . $this->startLine . ' did not follow iCalendar/vCard conventions');
}
// vCard 2.1 states that parameters may appear without a name, and only
// a value. We can deduce the value based on it's name.
//
// Our parser will get those as parameters without a value instead, so
// we're filtering these parameters out first.
$namedParameters = [];
$namelessParameters = [];
foreach ($property['parameters'] as $name => $value) {
if (!is_null($value)) {
$namedParameters[$name] = $value;
} else {
$namelessParameters[] = $name;
}
}
$propObj = $this->root->createProperty($property['name'], null, $namedParameters);
foreach ($namelessParameters as $namelessParameter) {
$propObj->add(null, $namelessParameter);
}
if (strtoupper($propObj['ENCODING']) === 'QUOTED-PRINTABLE') {
$propObj->setQuotedPrintableValue($this->extractQuotedPrintableValue());
} else {
$charset = $this->charset;
if ($this->root->getDocumentType() === Document::VCARD21 && isset($propObj['CHARSET'])) {
// vCard 2.1 allows the character set to be specified per property.
$charset = (string) $propObj['CHARSET'];
//.........这里部分代码省略.........