本文整理汇总了PHP中rfc2445_is_xname函数的典型用法代码示例。如果您正苦于以下问题:PHP rfc2445_is_xname函数的具体用法?PHP rfc2445_is_xname怎么用?PHP rfc2445_is_xname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rfc2445_is_xname函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_property
function add_property($name, $value = NULL, $parameters = NULL)
{
// Uppercase first of all
$name = strtoupper($name);
// Are we trying to add a valid property?
$xname = false;
if (!isset($this->valid_properties[$name])) {
// If not, is it an x-name as per RFC 2445?
if (!rfc2445_is_xname($name)) {
return false;
}
// Since this is an xname, all components are supposed to allow this property
$xname = true;
}
// Create a property object of the correct class
if ($xname) {
$property = new iCalendar_property_x();
$property->set_name($name);
} else {
$classname = 'iCalendar_property_' . strtolower(str_replace('-', '_', $name));
$property = new $classname();
}
// If $value is NULL, then this property must define a default value.
if ($value === NULL) {
$value = $property->default_value();
if ($value === NULL) {
return false;
}
}
// Set this property's parent component to ourselves, because some
// properties behave differently according to what component they apply to.
$property->set_parent_component($this->name);
// Set parameters before value; this helps with some properties which
// accept a VALUE parameter, and thus change their default value type.
// The parameters must be valid according to property specifications
if (!empty($parameters)) {
foreach ($parameters as $paramname => $paramvalue) {
if (!$property->set_parameter($paramname, $paramvalue)) {
return false;
}
}
// Some parameters interact among themselves (e.g. ENCODING and VALUE)
// so make sure that after the dust settles, these invariants hold true
if (!$property->invariant_holds()) {
return false;
}
}
// $value MUST be valid according to the property data type
if (!$property->set_value($value)) {
return false;
}
// If this property is restricted to only once, blindly overwrite value
if (!$xname && $this->valid_properties[$name] & RFC2445_ONCE) {
$this->properties[$name] = array($property);
} else {
$this->properties[$name][] = $property;
}
// Finally: after all these, does the component invariant hold?
if (!$this->invariant_holds()) {
// If not, completely undo the property addition
array_pop($this->properties[$name]);
if (empty($this->properties[$name])) {
unset($this->properties[$name]);
}
return false;
}
return true;
}
示例2: rfc2445_is_valid_value
//.........这里部分代码省略.........
if ($month == '' || $month < 1 || $month > 12) {
return false;
}
}
}
unset($vars['BYMONTH']);
if (isset($vars['BYSETPOS'])) {
if (empty($vars['BYSETPOS'])) {
return false;
}
$sets = explode(',', $vars['BYSETPOS']);
foreach ($sets as $set) {
if (!rfc2445_is_valid_value($set, RFC2445_TYPE_INTEGER)) {
return false;
}
$set = abs(intval($set));
if ($set == 0 || $set > 366) {
return false;
}
}
}
unset($vars['BYSETPOS']);
if (isset($vars['WKST'])) {
if (!in_array($vars['WKST'], $weekdays)) {
return false;
}
}
unset($vars['WKST']);
// Any remaining vars must be x-names
if (empty($vars)) {
return true;
}
foreach ($vars as $name => $var) {
if (!rfc2445_is_xname($name)) {
return false;
}
}
// At last, all is OK!
return true;
break;
case RFC2445_TYPE_TEXT:
return true;
break;
case RFC2445_TYPE_TIME:
if (is_int($value)) {
if ($value < 0) {
return false;
}
$value = "{$value}";
} else {
if (!is_string($value)) {
return false;
}
}
if (strlen($value) == 7) {
if (strtoupper(substr($value, -1)) != 'Z') {
return false;
}
$value = substr($value, 0, 6);
}
if (strlen($value) != 6) {
return false;
}
$h = intval(substr($value, 0, 2));
$m = intval(substr($value, 2, 2));
$s = intval(substr($value, 4, 2));
示例3: set_name
function set_name($name)
{
$name = strtoupper($name);
if (rfc2445_is_xname($name)) {
$this->name = $name;
return true;
}
return false;
}
示例4: is_valid_value
function is_valid_value(&$parent_property, $parameter, $value)
{
switch ($parameter) {
// These must all be a URI
case 'ALTREP':
case 'DIR':
return rfc2445_is_valid_value($value, RFC2445_TYPE_URI);
break;
// These must be CAL-ADDRESS, which is equivalent to URI
// These must be CAL-ADDRESS, which is equivalent to URI
case 'DELEGATED-FROM':
case 'DELEGATED-TO':
case 'MEMBER':
case 'SENT-BY':
return rfc2445_is_valid_value($value, RFC2445_TYPE_CAL_ADDRESS);
break;
// These are textual parameters, so the MUST NOT contain double quotes
// These are textual parameters, so the MUST NOT contain double quotes
case 'CN':
return strpos($value, '"') === false;
break;
// These have enumerated legal values
// These have enumerated legal values
case 'CUTYPE':
$value = strtoupper($value);
return $value == 'INDIVIDUAL' || $value == 'GROUP' || $value == 'RESOURCE' || $value == 'ROOM' || $value == 'UNKNOWN' || rfc2445_is_xname($value);
break;
case 'ENCODING':
$value = strtoupper($value);
return $value == '8BIT' || $value == 'BASE64' || rfc2445_is_xname($value);
break;
case 'FBTYPE':
$value = strtoupper($value);
return $value == 'FREE' || $value == 'BUSY' || $value == 'BUSY-UNAVAILABLE' || $value == 'BUSY-TENTATIVE' || rfc2445_is_xname($value);
break;
case 'FMTTYPE':
$fmttypes = array('TEXT' => array('PLAIN', 'RICHTEXT', 'ENRICHED', 'TAB-SEPARATED-VALUES', 'HTML', 'SGML', 'VND.LATEX-Z', 'VND.FMI.FLEXSTOR'), 'MULTIPART' => array('MIXED', 'ALTERNATIVE', 'DIGEST', 'PARALLEL', 'APPLEDOUBLE', 'HEADER-SET', 'FORM-DATA', 'RELATED', 'REPORT', 'VOICE-MESSAGE', 'SIGNED', 'ENCRYPTED', 'BYTERANGES'), 'MESSAGE' => array('RFC822', 'PARTIAL', 'EXTERNAL-BODY', 'NEWS', 'HTTP'), 'APPLICATION' => array('OCTET-STREAM', 'POSTSCRIPT', 'ODA', 'ATOMICMAIL', 'ANDREW-INSET', 'SLATE', 'WITA', 'DEC-DX', 'DCA-RFT', 'ACTIVEMESSAGE', 'RTF', 'APPLEFILE', 'MAC-BINHEX40', 'NEWS-MESSAGE-ID', 'NEWS-TRANSMISSION', 'WORDPERFECT5.1', 'PDF', 'ZIP', 'MACWRITEII', 'MSWORD', 'REMOTE-PRINTING', 'MATHEMATICA', 'CYBERCASH', 'COMMONGROUND', 'IGES', 'RISCOS', 'ESHOP', 'X400-BP', 'SGML', 'CALS-1840', 'PGP-ENCRYPTED', 'PGP-SIGNATURE', 'PGP-KEYS', 'VND.FRAMEMAKER', 'VND.MIF', 'VND.MS-EXCEL', 'VND.MS-POWERPOINT', 'VND.MS-PROJECT', 'VND.MS-WORKS', 'VND.MS-TNEF', 'VND.SVD', 'VND.MUSIC-NIFF', 'VND.MS-ARTGALRY', 'VND.TRUEDOC', 'VND.KOAN', 'VND.STREET-STREAM', 'VND.FDF', 'SET-PAYMENT-INITIATION', 'SET-PAYMENT', 'SET-REGISTRATION-INITIATION', 'SET-REGISTRATION', 'VND.SEEMAIL', 'VND.BUSINESSOBJECTS', 'VND.MERIDIAN-SLINGSHOT', 'VND.XARA', 'SGML-OPEN-CATALOG', 'VND.RAPID', 'VND.ENLIVEN', 'VND.JAPANNET-REGISTRATION-WAKEUP', 'VND.JAPANNET-VERIFICATION-WAKEUP', 'VND.JAPANNET-PAYMENT-WAKEUP', 'VND.JAPANNET-DIRECTORY-SERVICE', 'VND.INTERTRUST.DIGIBOX', 'VND.INTERTRUST.NNCP'), 'IMAGE' => array('JPEG', 'GIF', 'IEF', 'G3FAX', 'TIFF', 'CGM', 'NAPLPS', 'VND.DWG', 'VND.SVF', 'VND.DXF', 'PNG', 'VND.FPX', 'VND.NET-FPX'), 'AUDIO' => array('BASIC', '32KADPCM', 'VND.QCELP'), 'VIDEO' => array('MPEG', 'QUICKTIME', 'VND.VIVO', 'VND.MOTOROLA.VIDEO', 'VND.MOTOROLA.VIDEOP'));
$value = strtoupper($value);
if (rfc2445_is_xname($value)) {
return true;
}
@(list($type, $subtype) = explode('/', $value));
if (empty($type) || empty($subtype)) {
return false;
}
if (!isset($fmttypes[$type]) || !in_array($subtype, $fmttypes[$type])) {
return false;
}
return true;
break;
case 'LANGUAGE':
$value = strtoupper($value);
$parts = explode('-', $value);
foreach ($parts as $part) {
if (empty($part)) {
return false;
}
if (strspn($part, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') != strlen($part)) {
return false;
}
}
return true;
break;
case 'PARTSTAT':
$value = strtoupper($value);
switch ($parent_property->parent_component) {
case 'VEVENT':
return $value == 'NEEDS-ACTION' || $value == 'ACCEPTED' || $value == 'DECLINED' || $value == 'TENTATIVE' || $value == 'DELEGATED' || rfc2445_is_xname($value);
break;
case 'VTODO':
return $value == 'NEEDS-ACTION' || $value == 'ACCEPTED' || $value == 'DECLINED' || $value == 'TENTATIVE' || $value == 'DELEGATED' || $value == 'COMPLETED' || $value == 'IN-PROCESS' || rfc2445_is_xname($value);
break;
case 'VJOURNAL':
return $value == 'NEEDS-ACTION' || $value == 'ACCEPTED' || $value == 'DECLINED' || rfc2445_is_xname($value);
break;
}
return false;
break;
case 'RANGE':
$value = strtoupper($value);
return $value == 'THISANDPRIOR' || $value == 'THISANDFUTURE';
break;
case 'RELATED':
$value = strtoupper($value);
return $value == 'START' || $value == 'END';
break;
case 'RELTYPE':
$value = strtoupper($value);
return $value == 'PARENT' || $value == 'CHILD' || $value == 'SIBLING' || rfc2445_is_xname($value);
break;
case 'ROLE':
$value = strtoupper($value);
return $value == 'CHAIR' || $value == 'REQ-PARTICIPANT' || $value == 'OPT-PARTICIPANT' || $value == 'NON-PARTICIPANT' || rfc2445_is_xname($value);
break;
case 'RSVP':
$value = strtoupper($value);
return $value == 'TRUE' || $value == 'FALSE';
break;
case 'TZID':
if (empty($value)) {
//.........这里部分代码省略.........