PageRenderTime 61ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/php/Contact_Vcard_Build.php

https://bitbucket.org/adarshj/convenient_website
PHP | 2411 lines | 796 code | 398 blank | 1217 comment | 134 complexity | eb8448150be6287d8efa01e216c551ff MD5 | raw file
Possible License(s): Apache-2.0, MPL-2.0-no-copyleft-exception, LGPL-2.1, BSD-2-Clause, GPL-2.0, LGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4 |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2002 The PHP Group |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 of the PHP license, |
  9. // | that is bundled with this package in the file LICENSE, and is |
  10. // | available at through the world-wide-web at |
  11. // | http://www.php.net/license/2_02.txt. |
  12. // | If you did not receive a copy of the PHP license and are unable to |
  13. // | obtain it through the world-wide-web, please send a note to |
  14. // | license@php.net so we can mail you a copy immediately. |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Paul M. Jones <pmjones@php.net> |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Contact_Vcard_Build.php,v 1.2 2005/05/28 14:49:56 pmjones Exp $
  20. /**
  21. *
  22. * This class builds a single vCard (version 3.0 or 2.1).
  23. *
  24. * General note: we use the terms "set" "add" and "get" as function
  25. * prefixes.
  26. *
  27. * "Set" means there is only one iteration of a component, and it has
  28. * only one value repetition, so you set the whole thing at once.
  29. *
  30. * "Add" means eith multiple iterations of a component are allowed, or
  31. * that there is only one iteration allowed but there can be multiple
  32. * value repetitions, so you add iterations or repetitions to the current
  33. * stack.
  34. *
  35. * "Get" returns the full vCard line for a single iteration.
  36. *
  37. * @author Paul M. Jones <pmjones@php.net>
  38. *
  39. * @package Contact_Vcard
  40. *
  41. * @version @package_version@
  42. *
  43. */
  44. // Part numbers for N components
  45. define('VCARD_N_FAMILY', 0);
  46. define('VCARD_N_GIVEN', 1);
  47. define('VCARD_N_ADDL', 2);
  48. define('VCARD_N_PREFIX', 3);
  49. define('VCARD_N_SUFFIX', 4);
  50. // Part numbers for ADR components
  51. define('VCARD_ADR_POB', 0);
  52. define('VCARD_ADR_EXTEND', 1);
  53. define('VCARD_ADR_STREET', 2);
  54. define('VCARD_ADR_LOCALITY', 3);
  55. define('VCARD_ADR_REGION', 4);
  56. define('VCARD_ADR_POSTCODE', 5);
  57. define('VCARD_ADR_COUNTRY', 6);
  58. // Part numbers for GEO components
  59. define('VCARD_GEO_LAT', 0);
  60. define('VCARD_GEO_LON', 1);
  61. require_once 'PEAR.php';
  62. class Contact_Vcard_Build extends PEAR {
  63. /**
  64. *
  65. * Values for vCard components.
  66. *
  67. * @access public
  68. *
  69. * @var array
  70. *
  71. */
  72. var $value = array();
  73. /**
  74. *
  75. * Parameters for vCard components.
  76. *
  77. * @access public
  78. *
  79. * @var array
  80. *
  81. */
  82. var $param = array();
  83. /**
  84. *
  85. * Tracks which component (N, ADR, TEL, etc) value was last set or added.
  86. * Used when adding parameters automatically to the proper component.
  87. *
  88. * @access public
  89. *
  90. * @var string
  91. *
  92. */
  93. var $autoparam = null;
  94. /**
  95. *
  96. * Constructor.
  97. *
  98. * @access public
  99. *
  100. * @param string $version The vCard version to build; affects which
  101. * parameters are allowed and which components are returned by
  102. * fetch().
  103. *
  104. * @return void
  105. *
  106. * @see Contact_Vcard_Build::fetch()
  107. *
  108. */
  109. function Contact_Vcard_Build($version = '3.0')
  110. {
  111. $this->PEAR();
  112. $this->setErrorHandling(PEAR_ERROR_PRINT);
  113. $this->setVersion($version);
  114. }
  115. /**
  116. *
  117. * Prepares a string so it may be safely used as vCard values. DO
  118. * NOT use this with binary encodings. Operates on text in-place;
  119. * does not return a value. Recursively descends into arrays.
  120. *
  121. * Escapes a string so that...
  122. * ; => \;
  123. * , => \,
  124. * newline => literal \n
  125. *
  126. * @access public
  127. *
  128. * @param mixed $text The string or array or strings to escape.
  129. *
  130. * @return mixed Void on success, or a PEAR_Error object on failure.
  131. *
  132. */
  133. function escape(&$text)
  134. {
  135. if (is_object($text)) {
  136. return $this->raiseError('The escape() method works only with string literals and arrays.');
  137. } elseif (is_array($text)) {
  138. foreach ($text as $key => $val) {
  139. $this->escape($val);
  140. $text[$key] = $val;
  141. }
  142. } else {
  143. // escape colons not led by a backslash
  144. $regex = '(?<!\\\\)(\:)';
  145. $text = preg_replace("/$regex/i", "\\:", $text);
  146. // escape semicolons not led by a backslash
  147. $regex = '(?<!\\\\)(\;)';
  148. $text = preg_replace("/$regex/i", "\\;", $text);
  149. // escape commas not led by a backslash
  150. $regex = '(?<!\\\\)(\,)';
  151. $text = preg_replace("/$regex/i", "\\,", $text);
  152. // escape newlines
  153. $regex = '\\n';
  154. $text = preg_replace("/$regex/i", "\\n", $text);
  155. }
  156. }
  157. /**
  158. *
  159. * Adds a parameter value for a given component and parameter name.
  160. *
  161. * Note that although vCard 2.1 allows you to specify a parameter
  162. * value without a name (e.g., "HOME" instead of "TYPE=HOME") this
  163. * class is not so lenient. ;-) You must specify a parameter name
  164. * (TYPE, ENCODING, etc) when adding a parameter. Call multiple
  165. * times if you want to add multiple values to the same parameter.
  166. * E.g.:
  167. *
  168. * $vcard = new Contact_Vcard_Build();
  169. *
  170. * // set "TYPE=HOME,PREF" for the first TEL component
  171. * $vcard->addParam('TEL', 0, 'TYPE', 'HOME');
  172. * $vcard->addParam('TEL', 0, 'TYPE', 'PREF');
  173. *
  174. * @access public
  175. *
  176. * @param string $param_name The parameter name, such as TYPE, VALUE,
  177. * or ENCODING.
  178. *
  179. * @param string $param_value The parameter value.
  180. *
  181. * @param string $comp The vCard component for which this is a
  182. * paramter (ADR, TEL, etc). If null, will be the component that was
  183. * last set or added-to.
  184. *
  185. * @param mixed $iter An integer vCard component iteration that this
  186. * is a param for. E.g., if you have more than one ADR component, 0
  187. * refers to the first ADR, 1 to the second ADR, and so on. If null,
  188. * the parameter will be added to the last component iteration
  189. * available.
  190. *
  191. * @return mixed Void on success, or a PEAR_Error object on failure.
  192. *
  193. */
  194. function addParam($param_name, $param_value, $comp = null,
  195. $iter = null)
  196. {
  197. // if component is not specified, default to the last component
  198. // that was set or added.
  199. if ($comp === null) {
  200. $comp = $this->autoparam;
  201. }
  202. // using a null iteration means the param should be associated
  203. // with the latest/most-recent iteration of the selected
  204. // component.
  205. if ($iter === null) {
  206. $iter = $this->countIter($comp) - 1;
  207. }
  208. // massage the text arguments
  209. $comp = strtoupper(trim($comp));
  210. $param_name = strtoupper(trim($param_name));
  211. $param_value = trim($param_value);
  212. if (! is_integer($iter) || $iter < 0) {
  213. return $this->raiseError("$iter is not a valid iteration number for $comp; must be a positive integer.");
  214. } else {
  215. $result = $this->validateParam($param_name, $param_value, $comp, $iter);
  216. if (PEAR::isError($result)) {
  217. return $result;
  218. } else {
  219. $this->param[$comp][$iter][$param_name][] = $param_value;
  220. }
  221. }
  222. }
  223. /**
  224. *
  225. * Validates parameter names and values based on the vCard version
  226. * (2.1 or 3.0).
  227. *
  228. * @access public
  229. *
  230. * @param string $name The parameter name (e.g., TYPE or ENCODING).
  231. *
  232. * @param string $text The parameter value (e.g., HOME or BASE64).
  233. *
  234. * @param string $comp Optional, the component name (e.g., ADR or
  235. * PHOTO). Only used for error messaging.
  236. *
  237. * @param string $iter Optional, the iteration of the component.
  238. * Only used for error messaging.
  239. *
  240. * @return mixed Boolean true if the parameter is valid, or a
  241. * PEAR_Error object if not.
  242. *
  243. */
  244. function validateParam($name, $text, $comp = null, $iter = null)
  245. {
  246. $name = strtoupper($name);
  247. $text = strtoupper($text);
  248. // all param values must have only the characters A-Z 0-9 and -.
  249. if (preg_match('/[^a-zA-Z0-9\-]/i', $text)) {
  250. $result = $this->raiseError("vCard [$comp] [$iter] [$name]: The parameter value may contain only a-z, A-Z, 0-9, and dashes (-).");
  251. } elseif ($this->value['VERSION'][0][0][0] == '2.1') {
  252. // Validate against version 2.1 (pretty strict)
  253. $types = array (
  254. 'DOM', 'INTL', 'POSTAL', 'PARCEL','HOME', 'WORK',
  255. 'PREF', 'VOICE', 'FAX', 'MSG', 'CELL', 'PAGER',
  256. 'BBS', 'MODEM', 'CAR', 'ISDN', 'VIDEO',
  257. 'AOL', 'APPLELINK', 'ATTMAIL', 'CIS', 'EWORLD',
  258. 'INTERNET', 'IBMMAIL', 'MCIMAIL',
  259. 'POWERSHARE', 'PRODIGY', 'TLX', 'X400',
  260. 'GIF', 'CGM', 'WMF', 'BMP', 'MET', 'PMB', 'DIB',
  261. 'PICT', 'TIFF', 'PDF', 'PS', 'JPEG', 'QTIME',
  262. 'MPEG', 'MPEG2', 'AVI',
  263. 'WAVE', 'AIFF', 'PCM',
  264. 'X509', 'PGP'
  265. );
  266. switch ($name) {
  267. case 'TYPE':
  268. if (! in_array($text, $types)) {
  269. $result = $this->raiseError("vCard 2.1 [$comp] [$iter]: $text is not a recognized TYPE.");
  270. } else {
  271. $result = true;
  272. }
  273. break;
  274. case 'ENCODING':
  275. if ($text != '7BIT' &&
  276. $text != '8BIT' &&
  277. $text != 'BASE64' &&
  278. $text != 'QUOTED-PRINTABLE') {
  279. $result = $this->raiseError("vCard 2.1 [$comp] [$iter]: $text is not a recognized ENCODING.");
  280. } else {
  281. $result = true;
  282. }
  283. break;
  284. case 'CHARSET':
  285. // all charsets are OK
  286. $result = true;
  287. break;
  288. case 'LANGUAGE':
  289. // all languages are OK
  290. $result = true;
  291. break;
  292. case 'VALUE':
  293. if ($text != 'INLINE' &&
  294. $text != 'CONTENT-ID' &&
  295. $text != 'CID' &&
  296. $text != 'URL' &&
  297. $text != 'VCARD') {
  298. $result = $this->raiseError("vCard 2.1 [$comp] [$iter]: $text is not a recognized VALUE.");
  299. } else {
  300. $result = true;
  301. }
  302. break;
  303. default:
  304. $result = $this->raiseError("vCard 2.1 [$comp] [$iter]: $name is an unknown or invalid parameter name.");
  305. break;
  306. }
  307. } elseif ($this->value['VERSION'][0][0][0] == '3.0') {
  308. // Validate against version 3.0 (pretty lenient)
  309. switch ($name) {
  310. case 'TYPE':
  311. // all types are OK
  312. $result = true;
  313. break;
  314. case 'LANGUAGE':
  315. // all languages are OK
  316. $result = true;
  317. break;
  318. case 'ENCODING':
  319. if ($text != '8BIT' &&
  320. $text != 'B') {
  321. $result = $this->raiseError("vCard 3.0 [$comp] [$iter]: The only allowed ENCODING parameters are 8BIT and B.");
  322. } else {
  323. $result = true;
  324. }
  325. break;
  326. case 'VALUE':
  327. if ($text != 'BINARY' &&
  328. $text != 'PHONE-NUMBER' &&
  329. $text != 'TEXT' &&
  330. $text != 'URI' &&
  331. $text != 'UTC-OFFSET' &&
  332. $text != 'VCARD') {
  333. $result = $this->raiseError("vCard 3.0 [$comp] [$iter]: The only allowed VALUE parameters are BINARY, PHONE-NUMBER, TEXT, URI, UTC-OFFSET, and VCARD.");
  334. } else {
  335. $result = true;
  336. }
  337. break;
  338. default:
  339. $result = $this->raiseError("vCard 3.0 [$comp] [$iter]: Unknown or invalid parameter name ($name).");
  340. break;
  341. }
  342. } else {
  343. $result = $this->raiseError("[$comp] [$iter] Unknown vCard version number or other error.");
  344. }
  345. return $result;
  346. }
  347. /**
  348. *
  349. * Gets back the parameter string for a given component.
  350. *
  351. * @access public
  352. *
  353. * @param string $comp The component to get parameters for (ADR, TEL,
  354. * etc).
  355. *
  356. * @param int $iter The vCard component iteration to get the param
  357. * list for. E.g., if you have more than one ADR component, 0 refers
  358. * to the first ADR, 1 to the second ADR, and so on.
  359. *
  360. * @return string
  361. *
  362. */
  363. function getParam($comp, $iter = 0)
  364. {
  365. $comp = strtoupper($comp);
  366. $text = '';
  367. if (isset($this->param[$comp][$iter]) &&
  368. is_array($this->param[$comp][$iter])) {
  369. // loop through the array of parameters for
  370. // the component
  371. foreach ($this->param[$comp][$iter] as $param_name => $param_val) {
  372. // if there were previous parameter names, separate with
  373. // a semicolon
  374. if ($text != '') {
  375. $text .= ';';
  376. }
  377. if ($param_val === null) {
  378. // no parameter value was specified, which is typical
  379. // for vCard version 2.1 -- the name is the value.
  380. $this->escape($param_name);
  381. $text .= $param_name;
  382. } else {
  383. // set the parameter name...
  384. $text .= strtoupper($param_name) . '=';
  385. // ...then escape and comma-separate the parameter
  386. // values.
  387. $this->escape($param_val);
  388. $text .= implode(',', $param_val);
  389. }
  390. }
  391. }
  392. // if there were no parameters, this will be blank.
  393. return $text;
  394. }
  395. /**
  396. *
  397. * Resets the vCard values and params to be blank.
  398. *
  399. * @access public
  400. *
  401. * @param string $version The vCard version to reset to ('2.1' or
  402. * '3.0' -- default is the same version as previously set).
  403. *
  404. * @return void
  405. *
  406. */
  407. function reset($version = null)
  408. {
  409. $prev = $this->value['VERSION'][0][0][0];
  410. $this->value = array();
  411. $this->param = array();
  412. $this->autoparam = null;
  413. if ($version === null) {
  414. $this->setVersion($prev);
  415. } else {
  416. $this->setVersion($version);
  417. }
  418. }
  419. /**
  420. *
  421. * Gets the left-side/prefix/before-the-colon (metadata) part of a
  422. * vCard line, including the component identifier, the parameter
  423. * list, and a colon.
  424. *
  425. * @access public
  426. *
  427. * @param string $comp The component to get metadata for (ADR, TEL,
  428. * etc).
  429. *
  430. * @param int $iter The vCard component iteration to get the metadata
  431. * for. E.g., if you have more than one ADR component, 0 refers to
  432. * the first ADR, 1 to the second ADR, and so on.
  433. *
  434. * @return string The line prefix metadata.
  435. *
  436. */
  437. function getMeta($comp, $iter = 0)
  438. {
  439. $params = $this->getParam($comp, $iter);
  440. if (trim($params) == '') {
  441. // no parameters
  442. $text = $comp . ':';
  443. } else {
  444. // has parameters. put an extra semicolon in.
  445. $text = $comp . ';' . $params . ':';
  446. }
  447. return $text;
  448. }
  449. /**
  450. *
  451. * Generic, all-purpose method to store a string or array in
  452. * $this->value, in a way suitable for later output as a vCard
  453. * element. This forces the value to be the passed text or array
  454. * value, overriding any prior values.
  455. *
  456. * @access public
  457. *
  458. * @param string $comp The component to set the value for ('N',
  459. * 'ADR', etc).
  460. *
  461. * @param int $iter The component-iteration to set the value for.
  462. *
  463. * @param int $part The part number of the component-iteration to set
  464. * the value for.
  465. *
  466. * @param mixed $text A string or array; the set of repeated values
  467. * for this component-iteration part.
  468. *
  469. * @return void
  470. *
  471. */
  472. function setValue($comp, $iter, $part, $text)
  473. {
  474. $comp = strtoupper($comp);
  475. settype($text, 'array');
  476. $this->value[$comp][$iter][$part] = $text;
  477. $this->autoparam = $comp;
  478. }
  479. /**
  480. *
  481. * Generic, all-purpose method to add a repetition of a string or
  482. * array in $this->value, in a way suitable for later output as a
  483. * vCard element. This appends the value to be the passed text or
  484. * array value, leaving any prior values in place.
  485. *
  486. * @access public
  487. *
  488. * @param string $comp The component to set the value for ('N',
  489. * 'ADR', etc).
  490. *
  491. * @param int $iter The component-iteration to set the value for.
  492. *
  493. * @param int $part The part number of the component-iteration to set
  494. * the value for.
  495. *
  496. * @param mixed $text A string or array; the set of repeated values
  497. * for this component-iteration part.
  498. *
  499. * @return void
  500. *
  501. */
  502. function addValue($comp, $iter, $part, $text)
  503. {
  504. $comp = strtoupper($comp);
  505. settype($text, 'array');
  506. foreach ($text as $val) {
  507. $this->value[$comp][$iter][$part][] = $val;
  508. }
  509. $this->autoparam = $comp;
  510. }
  511. /**
  512. *
  513. * Generic, all-purpose method to get back the data stored in $this->value.
  514. *
  515. * @access public
  516. *
  517. * @param string $comp The component to set the value for ('N',
  518. * 'ADR', etc).
  519. *
  520. * @param int $iter The component-iteration to set the value for.
  521. *
  522. * @param int $part The part number of the component-iteration to get
  523. * the value for.
  524. *
  525. * @param mixed $rept The repetition number within the part to get;
  526. * if null, get all repetitions of the part within the iteration.
  527. *
  528. * @return string The value, escaped and delimited, of all
  529. * repetitions in the component-iteration part (or specific
  530. * repetition within the part).
  531. *
  532. */
  533. function getValue($comp, $iter = 0, $part = 0, $rept = null)
  534. {
  535. if ($rept === null &&
  536. is_array($this->value[$comp][$iter][$part]) ) {
  537. // get all repetitions of a part
  538. $list = array();
  539. foreach ($this->value[$comp][$iter][$part] as $key => $val) {
  540. $list[] = trim($val);
  541. }
  542. $this->escape($list);
  543. return implode(',', $list);
  544. } else {
  545. // get a specific repetition of a part
  546. $text = trim($this->value[$comp][$iter][$part][$rept]);
  547. $this->escape($text);
  548. return $text;
  549. }
  550. }
  551. /**
  552. *
  553. * Sets the full N component of the vCard. Will replace all other
  554. * values. There can only be one N component per vCard.
  555. *
  556. * @access public
  557. *
  558. * @param mixed $family Single (string) or multiple (array)
  559. * family/last name.
  560. *
  561. * @param mixed $given Single (string) or multiple (array)
  562. * given/first name.
  563. *
  564. * @param mixed $addl Single (string) or multiple (array)
  565. * additional/middle name.
  566. *
  567. * @param mixed $prefix Single (string) or multiple (array) honorific
  568. * prefix such as Mr., Miss, etc.
  569. *
  570. * @param mixed $suffix Single (string) or multiple (array) honorific
  571. * suffix such as III, Jr., Ph.D., etc.
  572. *
  573. * @return void
  574. *
  575. */
  576. function setName($family, $given, $addl, $prefix, $suffix)
  577. {
  578. $this->autoparam = 'N';
  579. $this->setValue('N', 0, VCARD_N_FAMILY, $family);
  580. $this->setValue('N', 0, VCARD_N_GIVEN, $given);
  581. $this->setValue('N', 0, VCARD_N_ADDL, $addl);
  582. $this->setValue('N', 0, VCARD_N_PREFIX, $prefix);
  583. $this->setValue('N', 0, VCARD_N_SUFFIX, $suffix);
  584. }
  585. /**
  586. *
  587. * Gets back the full N component (first iteration only, since there
  588. * can only be one N component per vCard).
  589. *
  590. * @access public
  591. *
  592. * @return string The first N component-interation of the vCard.
  593. *
  594. */
  595. function getName()
  596. {
  597. return $this->getMeta('N', 0) .
  598. $this->getValue('N', 0, VCARD_N_FAMILY) . ';' .
  599. $this->getValue('N', 0, VCARD_N_GIVEN) . ';' .
  600. $this->getValue('N', 0, VCARD_N_ADDL) . ';' .
  601. $this->getValue('N', 0, VCARD_N_PREFIX) . ';' .
  602. $this->getValue('N', 0, VCARD_N_SUFFIX);
  603. }
  604. /**
  605. *
  606. * Sets the FN component of the card. If no text is passed as the
  607. * FN value, constructs an FN automatically from N components. There
  608. * is only one FN iteration per vCard.
  609. *
  610. * @access public
  611. *
  612. * @param string $text Override the automatic generation of FN from N
  613. * elements with the specified text.
  614. *
  615. * @return mixed Void on success, or a PEAR_Error object on failure.
  616. *
  617. */
  618. function setFormattedName($text = null)
  619. {
  620. $this->autoparam = 'FN';
  621. if ($text === null) {
  622. // no text was specified for the FN, so build it
  623. // from the current N components if an N exists
  624. if (is_array($this->value['N'])) {
  625. // build from N.
  626. // first (given) name, first iteration, first repetition
  627. $text .= $this->getValue('N', 0, VCARD_N_GIVEN, 0);
  628. // add a space after, if there was text
  629. if ($text != '') {
  630. $text .= ' ';
  631. }
  632. // last (family) name, first iteration, first repetition
  633. $text .= $this->getValue('N', 0, VCARD_N_FAMILY, 0);
  634. // add a space after, if there was text
  635. if ($text != '') {
  636. $text .= ' ';
  637. }
  638. // last-name suffix, first iteration, first repetition
  639. $text .= $this->getValue('N', 0, VCARD_N_SUFFIX, 0);
  640. } else {
  641. // no N exists, and no FN was set, so return.
  642. return $this->raiseError('FN not specified and N not set; cannot set FN.');
  643. }
  644. }
  645. $this->setValue('FN', 0, 0, $text);
  646. }
  647. /**
  648. *
  649. * Gets back the full FN component value. Only ever returns iteration
  650. * zero, because only one FN component is allowed per vCard.
  651. *
  652. * @access public
  653. *
  654. * @return string The FN value of the vCard.
  655. *
  656. */
  657. function getFormattedName()
  658. {
  659. return $this->getMeta('FN', 0) . $this->getValue('FN', 0, 0);
  660. }
  661. /**
  662. *
  663. * Sets the version of the the vCard. Only one iteration.
  664. *
  665. * @access public
  666. *
  667. * @param string $text The text value of the verson text ('3.0' or '2.1').
  668. *
  669. * @return mixed Void on success, or a PEAR_Error object on failure.
  670. *
  671. */
  672. function setVersion($text = '3.0')
  673. {
  674. $this->autoparam = 'VERSION';
  675. if ($text != '3.0' && $text != '2.1') {
  676. return $this->raiseError('Version must be 3.0 or 2.1 to be valid.');
  677. } else {
  678. $this->setValue('VERSION', 0, 0, $text);
  679. }
  680. }
  681. /**
  682. *
  683. * Gets back the version of the the vCard. Only one iteration.
  684. *
  685. * @access public
  686. *
  687. * @return string The data-source of the vCard.
  688. *
  689. */
  690. function getVersion()
  691. {
  692. return $this->getMeta('VERSION', 0) .
  693. $this->getValue('VERSION', 0);
  694. }
  695. /**
  696. *
  697. * Sets the data-source of the the vCard. Only one iteration.
  698. *
  699. * @access public
  700. *
  701. * @param string $text The text value of the data-source text.
  702. *
  703. * @return void
  704. *
  705. */
  706. function setSource($text)
  707. {
  708. $this->autoparam = 'SOURCE';
  709. $this->setValue('SOURCE', 0, 0, $text);
  710. }
  711. /**
  712. *
  713. * Gets back the data-source of the the vCard. Only one iteration.
  714. *
  715. * @access public
  716. *
  717. * @return string The data-source of the vCard.
  718. *
  719. */
  720. function getSource()
  721. {
  722. return $this->getMeta('SOURCE', 0) .
  723. $this->getValue('SOURCE', 0, 0);
  724. }
  725. /**
  726. *
  727. * Sets the displayed name of the vCard data-source. Only one iteration.
  728. * If no name is specified, copies the value of SOURCE.
  729. *
  730. * @access public
  731. *
  732. * @param string $text The text value of the displayed data-source
  733. * name. If null, copies the value of SOURCE.
  734. *
  735. * @return mixed Void on success, or a PEAR_Error object on failure.
  736. *
  737. */
  738. function setSourceName($text = null)
  739. {
  740. $this->autoparam = 'NAME';
  741. if ($text === null) {
  742. if (is_array($this->value['SOURCE'])) {
  743. $text = $this->getValue('SOURCE', 0, 0);
  744. } else {
  745. return $this->raiseError('NAME not specified and SOURCE not set; cannot set NAME.');
  746. }
  747. }
  748. $this->setValue('NAME', 0, 0, $text);
  749. }
  750. /**
  751. *
  752. * Gets back the displayed data-source name of the the vCard. Only
  753. * one iteration.
  754. *
  755. * @access public
  756. *
  757. * @return string The data-source name of the vCard.
  758. *
  759. */
  760. function getSourceName()
  761. {
  762. return $this->getMeta('NAME', 0) .
  763. $this->getValue('NAME', 0, 0);
  764. }
  765. /**
  766. *
  767. * Sets the value of the PHOTO component. There is only one allowed
  768. * per vCard.
  769. *
  770. * @access public
  771. *
  772. * @param string $text The value to set for this component.
  773. *
  774. * @return void
  775. *
  776. */
  777. function setPhoto($text)
  778. {
  779. $this->autoparam = 'PHOTO';
  780. $this->setValue('PHOTO', 0, 0, $text);
  781. }
  782. /**
  783. *
  784. * Gets back the value of the PHOTO component. There is only one
  785. * allowed per vCard.
  786. *
  787. * @access public
  788. *
  789. * @return string The value of this component.
  790. *
  791. */
  792. function getPhoto()
  793. {
  794. return $this->getMeta('PHOTO') .
  795. $this->getValue('PHOTO', 0, 0);
  796. }
  797. /**
  798. *
  799. * Sets the value of the LOGO component. There is only one allowed
  800. * per vCard.
  801. *
  802. * @access public
  803. *
  804. * @param string $text The value to set for this component.
  805. *
  806. * @return void
  807. *
  808. */
  809. function setLogo($text)
  810. {
  811. $this->autoparam = 'LOGO';
  812. $this->setValue('LOGO', 0, 0, $text);
  813. }
  814. /**
  815. *
  816. * Gets back the value of the LOGO component. There is only one
  817. * allowed per vCard.
  818. *
  819. * @access public
  820. *
  821. * @return string The value of this component.
  822. *
  823. */
  824. function getLogo()
  825. {
  826. return $this->getMeta('LOGO') . $this->getValue('LOGO', 0, 0);
  827. }
  828. /**
  829. *
  830. * Sets the value of the SOUND component. There is only one allowed
  831. * per vCard.
  832. *
  833. * @access public
  834. *
  835. * @param string $text The value to set for this component.
  836. *
  837. * @return void
  838. *
  839. */
  840. function setSound($text)
  841. {
  842. $this->autoparam = 'SOUND';
  843. $this->setValue('SOUND', 0, 0, $text);
  844. }
  845. /**
  846. *
  847. * Gets back the value of the SOUND component. There is only one
  848. * allowed per vCard.
  849. *
  850. * @access public
  851. *
  852. * @return string The value of this component.
  853. *
  854. */
  855. function getSound()
  856. {
  857. return $this->getMeta('SOUND') .
  858. $this->getValue('SOUND', 0, 0);
  859. }
  860. /**
  861. *
  862. * Sets the value of the KEY component. There is only one allowed
  863. * per vCard.
  864. *
  865. * @access public
  866. *
  867. * @param string $text The value to set for this component.
  868. *
  869. * @return void
  870. *
  871. */
  872. function setKey($text)
  873. {
  874. $this->autoparam = 'KEY';
  875. $this->setValue('KEY', 0, 0, $text);
  876. }
  877. /**
  878. *
  879. * Gets back the value of the KEY component. There is only one
  880. * allowed per vCard.
  881. *
  882. * @access public
  883. *
  884. * @return string The value of this component.
  885. *
  886. */
  887. function getKey()
  888. {
  889. return $this->getMeta('KEY') . $this->getValue('KEY', 0, 0);
  890. }
  891. /**
  892. *
  893. * Sets the value of the BDAY component. There is only one allowed
  894. * per vCard. Date format is "yyyy-mm-dd[Thh:ii[:ss[Z|-06:00]]]".
  895. *
  896. * @access public
  897. *
  898. * @param string $text The value to set for this component.
  899. *
  900. * @return void
  901. *
  902. */
  903. function setBirthday($text)
  904. {
  905. $this->autoparam = 'BDAY';
  906. $this->setValue('BDAY', 0, 0, $text);
  907. }
  908. /**
  909. *
  910. * Gets back the value of the BDAY component. There is only one
  911. * allowed per vCard.
  912. *
  913. * @access public
  914. *
  915. * @return string The value of this component.
  916. *
  917. */
  918. function getBirthday()
  919. {
  920. return $this->getMeta('BDAY') . $this->getValue('BDAY', 0, 0);
  921. }
  922. /**
  923. *
  924. * Sets the value of the TZ component. There is only one allowed per
  925. * vCard.
  926. *
  927. * @access public
  928. *
  929. * @param string $text The value to set for this component.
  930. *
  931. * @return void
  932. *
  933. */
  934. function setTZ($text)
  935. {
  936. $this->autoparam = 'TZ';
  937. $this->setValue('TZ', 0, 0, $text);
  938. }
  939. /**
  940. *
  941. * Gets back the value of the TZ component. There is only one
  942. * allowed per vCard.
  943. *
  944. * @access public
  945. *
  946. * @return string The value of this component.
  947. *
  948. */
  949. function getTZ()
  950. {
  951. return $this->getMeta('TZ') . $this->getValue('TZ', 0, 0);
  952. }
  953. /**
  954. *
  955. * Sets the value of the MAILER component. There is only one allowed
  956. * per vCard.
  957. *
  958. * @access public
  959. *
  960. * @param string $text The value to set for this component.
  961. *
  962. * @return void
  963. *
  964. */
  965. function setMailer($text)
  966. {
  967. $this->autoparam = 'MAILER';
  968. $this->setValue('MAILER', 0, 0, $text);
  969. }
  970. /**
  971. *
  972. * Gets back the value of the MAILER component. There is only one
  973. * allowed per vCard.
  974. *
  975. * @access public
  976. *
  977. * @return string The value of this component.
  978. *
  979. */
  980. function getMailer()
  981. {
  982. return $this->getMeta('MAILER') .
  983. $this->getValue('MAILER', 0, 0);
  984. }
  985. /**
  986. *
  987. * Sets the value of the NOTE component. There is only one allowed
  988. * per vCard.
  989. *
  990. * @access public
  991. *
  992. * @param string $text The value to set for this component.
  993. *
  994. * @return void
  995. *
  996. */
  997. function setNote($text)
  998. {
  999. $this->autoparam = 'NOTE';
  1000. $this->setValue('NOTE', 0, 0, $text);
  1001. }
  1002. /**
  1003. *
  1004. * Gets back the value of the NOTE component. There is only one
  1005. * allowed per vCard.
  1006. *
  1007. * @access public
  1008. *
  1009. * @return string The value of this component.
  1010. *
  1011. */
  1012. function getNote()
  1013. {
  1014. return $this->getMeta('NOTE') . $this->getValue('NOTE', 0, 0);
  1015. }
  1016. /**
  1017. *
  1018. * Sets the value of the TITLE component. There is only one allowed
  1019. * per vCard.
  1020. *
  1021. * @access public
  1022. *
  1023. * @param string $text The value to set for this component.
  1024. *
  1025. * @return void
  1026. *
  1027. */
  1028. function setTitle($text)
  1029. {
  1030. $this->autoparam = 'TITLE';
  1031. $this->setValue('TITLE', 0, 0, $text);
  1032. }
  1033. /**
  1034. *
  1035. * Gets back the value of the TITLE component. There is only one
  1036. * allowed per vCard.
  1037. *
  1038. * @access public
  1039. *
  1040. * @return string The value of this component.
  1041. *
  1042. */
  1043. function getTitle()
  1044. {
  1045. return $this->getMeta('TITLE') .
  1046. $this->getValue('TITLE', 0, 0);
  1047. }
  1048. /**
  1049. *
  1050. * Sets the value of the ROLE component. There is only one allowed
  1051. * per vCard.
  1052. *
  1053. * @access public
  1054. *
  1055. * @param string $text The value to set for this component.
  1056. *
  1057. * @return void
  1058. *
  1059. */
  1060. function setRole($text)
  1061. {
  1062. $this->autoparam = 'ROLE';
  1063. $this->setValue('ROLE', 0, 0, $text);
  1064. }
  1065. /**
  1066. *
  1067. * Gets back the value of the ROLE component. There is only one
  1068. * allowed per vCard.
  1069. *
  1070. * @access public
  1071. *
  1072. * @return string The value of this component.
  1073. *
  1074. */
  1075. function getRole()
  1076. {
  1077. return $this->getMeta('ROLE') . $this->getValue('ROLE', 0, 0);
  1078. }
  1079. /**
  1080. *
  1081. * Sets the value of the URL component. There is only one allowed
  1082. * per vCard.
  1083. *
  1084. * @access public
  1085. *
  1086. * @param string $text The value to set for this component.
  1087. *
  1088. * @return void
  1089. *
  1090. */
  1091. function setURL($text)
  1092. {
  1093. $this->autoparam = 'URL';
  1094. $this->setValue('URL', 0, 0, $text);
  1095. }
  1096. /**
  1097. *
  1098. * Gets back the value of the URL component. There is only one
  1099. * allowed per vCard.
  1100. *
  1101. * @access public
  1102. *
  1103. * @return string The value of this component.
  1104. *
  1105. */
  1106. function getURL()
  1107. {
  1108. return $this->getMeta('URL') . $this->getValue('URL', 0, 0);
  1109. }
  1110. /**
  1111. *
  1112. * Sets the value of the CLASS component. There is only one allowed
  1113. * per vCard.
  1114. *
  1115. * @access public
  1116. *
  1117. * @param string $text The value to set for this component.
  1118. *
  1119. * @return void
  1120. *
  1121. */
  1122. function setClass($text)
  1123. {
  1124. $this->autoparam = 'CLASS';
  1125. $this->setValue('CLASS', 0, 0, $text);
  1126. }
  1127. /**
  1128. *
  1129. * Gets back the value of the CLASS component. There is only one
  1130. * allowed per vCard.
  1131. *
  1132. * @access public
  1133. *
  1134. * @return string The value of this component.
  1135. *
  1136. */
  1137. function getClass()
  1138. {
  1139. return $this->getMeta('CLASS') .
  1140. $this->getValue('CLASS', 0, 0);
  1141. }
  1142. /**
  1143. *
  1144. * Sets the value of the SORT-STRING component. There is only one
  1145. * allowed per vCard.
  1146. *
  1147. * @access public
  1148. *
  1149. * @param string $text The value to set for this component.
  1150. *
  1151. * @return void
  1152. *
  1153. */
  1154. function setSortString($text)
  1155. {
  1156. $this->autoparam = 'SORT-STRING';
  1157. $this->setValue('SORT-STRING', 0, 0, $text);
  1158. }
  1159. /**
  1160. *
  1161. * Gets back the value of the SORT-STRING component. There is only
  1162. * one allowed per vCard.
  1163. *
  1164. * @access public
  1165. *
  1166. * @return string The value of this component.
  1167. *
  1168. */
  1169. function getSortString()
  1170. {
  1171. return $this->getMeta('SORT-STRING') .
  1172. $this->getValue('SORT-STRING', 0, 0);
  1173. }
  1174. /**
  1175. *
  1176. * Sets the value of the PRODID component. There is only one allowed
  1177. * per vCard.
  1178. *
  1179. * @access public
  1180. *
  1181. * @param string $text The value to set for this component.
  1182. *
  1183. * @return void
  1184. *
  1185. */
  1186. function setProductID($text)
  1187. {
  1188. $this->autoparam = 'PRODID';
  1189. $this->setValue('PRODID', 0, 0, $text);
  1190. }
  1191. /**
  1192. *
  1193. * Gets back the value of the PRODID component. There is only one
  1194. * allowed per vCard.
  1195. *
  1196. * @access public
  1197. *
  1198. * @return string The value of this component.
  1199. *
  1200. */
  1201. function getProductID()
  1202. {
  1203. return $this->getMeta('PRODID') .
  1204. $this->getValue('PRODID', 0, 0);
  1205. }
  1206. /**
  1207. *
  1208. * Sets the value of the REV component. There is only one allowed
  1209. * per vCard.
  1210. *
  1211. * @access public
  1212. *
  1213. * @param string $text The value to set for this component.
  1214. *
  1215. * @return void
  1216. *
  1217. */
  1218. function setRevision($text)
  1219. {
  1220. $this->autoparam = 'REV';
  1221. $this->setValue('REV', 0, 0, $text);
  1222. }
  1223. /**
  1224. *
  1225. * Gets back the value of the REV component. There is only one
  1226. * allowed per vCard.
  1227. *
  1228. * @access public
  1229. *
  1230. * @return string The value of this component.
  1231. *
  1232. */
  1233. function getRevision()
  1234. {
  1235. return $this->getMeta('REV') . $this->getValue('REV', 0, 0);
  1236. }
  1237. /**
  1238. *
  1239. * Sets the value of the UID component. There is only one allowed
  1240. * per vCard.
  1241. *
  1242. * @access public
  1243. *
  1244. * @param string $text The value to set for this component.
  1245. *
  1246. * @return void
  1247. *
  1248. */
  1249. function setUniqueID($text)
  1250. {
  1251. $this->autoparam = 'UID';
  1252. $this->setValue('UID', 0, 0, $text);
  1253. }
  1254. /**
  1255. *
  1256. * Gets back the value of the UID component. There is only one
  1257. * allowed per vCard.
  1258. *
  1259. * @access public
  1260. *
  1261. * @return string The value of this component.
  1262. *
  1263. */
  1264. function getUniqueID()
  1265. {
  1266. return $this->getMeta('UID') . $this->getValue('UID', 0, 0);
  1267. }
  1268. /**
  1269. *
  1270. * Sets the value of the AGENT component. There is only one allowed
  1271. * per vCard.
  1272. *
  1273. * @access public
  1274. *
  1275. * @param string $text The value to set for this component.
  1276. *
  1277. * @return void
  1278. *
  1279. */
  1280. function setAgent($text)
  1281. {
  1282. $this->autoparam = 'AGENT';
  1283. $this->setValue('AGENT', 0, 0, $text);
  1284. }
  1285. /**
  1286. *
  1287. * Gets back the value of the AGENT component. There is only one
  1288. * allowed per vCard.
  1289. *
  1290. * @access public
  1291. *
  1292. * @return string The value of this component.
  1293. *
  1294. */
  1295. function getAgent()
  1296. {
  1297. return $this->getMeta('AGENT') .
  1298. $this->getValue('AGENT', 0, 0);
  1299. }
  1300. /**
  1301. *
  1302. * Sets the value of both parts of the GEO component. There is only
  1303. * one GEO component allowed per vCard.
  1304. *
  1305. * @access public
  1306. *
  1307. * @param string $lat The value to set for the longitude part
  1308. * (decimal, + or -).
  1309. *
  1310. * @param string $lon The value to set for the latitude part
  1311. * (decimal, + or -).
  1312. *
  1313. * @return void
  1314. *
  1315. */
  1316. function setGeo($lat, $lon)
  1317. {
  1318. $this->autoparam = 'GEO';
  1319. $this->setValue('GEO', 0, VCARD_GEO_LAT, $lat);
  1320. $this->setValue('GEO', 0, VCARD_GEO_LON, $lon);
  1321. }
  1322. /**
  1323. *
  1324. * Gets back the value of the GEO component. There is only one
  1325. * allowed per vCard.
  1326. *
  1327. * @access public
  1328. *
  1329. * @return string The value of this component.
  1330. *
  1331. */
  1332. function getGeo()
  1333. {
  1334. return $this->getMeta('GEO', 0) .
  1335. $this->getValue('GEO', 0, VCARD_GEO_LAT, 0) . ';' .
  1336. $this->getValue('GEO', 0, VCARD_GEO_LON, 0);
  1337. }
  1338. /**
  1339. *
  1340. * Sets the value of one entire ADR iteration. There can be zero,
  1341. * one, or more ADR components in a vCard.
  1342. *
  1343. * @access public
  1344. *
  1345. * @param mixed $pob String (one repetition) or array (multiple
  1346. * reptitions) of the p.o. box part of the ADR component iteration.
  1347. *
  1348. * @param mixed $extend String (one repetition) or array (multiple
  1349. * reptitions) of the "extended address" part of the ADR component
  1350. * iteration.
  1351. *
  1352. * @param mixed $street String (one repetition) or array (multiple
  1353. * reptitions) of the street address part of the ADR component
  1354. * iteration.
  1355. *
  1356. * @param mixed $locality String (one repetition) or array (multiple
  1357. * reptitions) of the locailty (e.g., city) part of the ADR component
  1358. * iteration.
  1359. *
  1360. * @param mixed $region String (one repetition) or array (multiple
  1361. * reptitions) of the region (e.g., state, province, or governorate)
  1362. * part of the ADR component iteration.
  1363. *
  1364. * @param mixed $postcode String (one repetition) or array (multiple
  1365. * reptitions) of the postal code (e.g., ZIP code) part of the ADR
  1366. * component iteration.
  1367. *
  1368. * @param mixed $country String (one repetition) or array (multiple
  1369. * reptitions) of the country-name part of the ADR component
  1370. * iteration.
  1371. *
  1372. * @return void
  1373. *
  1374. */
  1375. function addAddress($pob, $extend, $street, $locality, $region,
  1376. $postcode, $country)
  1377. {
  1378. $this->autoparam = 'ADR';
  1379. $iter = $this->countIter('ADR');
  1380. $this->setValue('ADR', $iter, VCARD_ADR_POB, $pob);
  1381. $this->setValue('ADR', $iter, VCARD_ADR_EXTEND, $extend);
  1382. $this->setValue('ADR', $iter, VCARD_ADR_STREET, $street);
  1383. $this->setValue('ADR', $iter, VCARD_ADR_LOCALITY, $locality);
  1384. $this->setValue('ADR', $iter, VCARD_ADR_REGION, $region);
  1385. $this->setValue('ADR', $iter, VCARD_ADR_POSTCODE, $postcode);
  1386. $this->setValue('ADR', $iter, VCARD_ADR_COUNTRY, $country);
  1387. }
  1388. /**
  1389. *
  1390. * Gets back the value of one ADR component iteration.
  1391. *
  1392. * @access public
  1393. *
  1394. * @param int $iter The component iteration-number to get the value
  1395. * for.
  1396. *
  1397. * @return mixed The value of this component iteration, or a
  1398. * PEAR_Error if the iteration is not valid.
  1399. *
  1400. */
  1401. function getAddress($iter)
  1402. {
  1403. if (! is_integer($iter) || $iter < 0) {
  1404. return $this->raiseError('ADR iteration number not valid.');
  1405. } else {
  1406. return $this->getMeta('ADR', $iter) .
  1407. $this->getValue('ADR', $iter, VCARD_ADR_POB) . ';' .
  1408. $this->getValue('ADR', $iter, VCARD_ADR_EXTEND) . ';' .
  1409. $this->getValue('ADR', $iter, VCARD_ADR_STREET) . ';' .
  1410. $this->getValue('ADR', $iter, VCARD_ADR_LOCALITY) . ';' .
  1411. $this->getValue('ADR', $iter, VCARD_ADR_REGION) . ';' .
  1412. $this->getValue('ADR', $iter, VCARD_ADR_POSTCODE) . ';' .
  1413. $this->getValue('ADR', $iter, VCARD_ADR_COUNTRY);
  1414. }
  1415. }
  1416. /**
  1417. *
  1418. * Sets the value of one LABEL component iteration. There can be
  1419. * zero, one, or more component iterations in a vCard.
  1420. *
  1421. * @access public
  1422. *
  1423. * @param string $text The value to set for this component.
  1424. *
  1425. * @return void
  1426. *
  1427. */
  1428. function addLabel($text)
  1429. {
  1430. $this->autoparam = 'LABEL';
  1431. $iter = $this->countIter('LABEL');
  1432. $this->setValue('LABEL', $iter, 0, $text);
  1433. }
  1434. /**
  1435. *
  1436. * Gets back the value of one iteration of the LABEL component.
  1437. * There can be zero, one, or more component iterations in a vCard.
  1438. *
  1439. * @access public
  1440. *
  1441. * @param int $iter The component iteration-number to get the value
  1442. * for.
  1443. *
  1444. * @return mixed The value of this component, or a PEAR_Error if
  1445. * the iteration number is not valid.
  1446. *
  1447. */
  1448. function getLabel($iter)
  1449. {
  1450. if (! is_integer($iter) || $iter < 0) {
  1451. return $this->raiseError('LABEL iteration number not valid.');
  1452. } else {
  1453. return $this->getMeta('LABEL', $iter) .
  1454. $this->getValue('LABEL', $iter, 0);
  1455. }
  1456. }
  1457. /**
  1458. *
  1459. * Sets the value of one TEL component iteration. There can be zero,
  1460. * one, or more component iterations in a vCard.
  1461. *
  1462. * @access public
  1463. *
  1464. * @param string $text The value to set for this component.
  1465. *
  1466. * @return void
  1467. *
  1468. */
  1469. function addTelephone($text)
  1470. {
  1471. $this->autoparam = 'TEL';
  1472. $iter = $this->countIter('TEL');
  1473. $this->setValue('TEL', $iter, 0, $text);
  1474. }
  1475. /**
  1476. *
  1477. * Gets back the value of one iteration of the TEL component. There
  1478. * can be zero, one, or more component iterations in a vCard.
  1479. *
  1480. * @access public
  1481. *
  1482. * @param int $iter The component iteration-number to get the value
  1483. * for.
  1484. *
  1485. * @return mixed The value of this component, or a PEAR_Error if the
  1486. * iteration number is not valid.
  1487. *
  1488. */
  1489. function getTelephone($iter)
  1490. {
  1491. if (! is_integer($iter) || $iter < 0) {
  1492. return $this->raiseError('TEL iteration number not valid.');
  1493. } else {
  1494. return $this->getMeta('TEL', $iter) .
  1495. $this->getValue('TEL', $iter, 0);
  1496. }
  1497. }
  1498. /**
  1499. *
  1500. * Sets the value of one EMAIL component iteration. There can be zero,
  1501. * one, or more component iterations in a vCard.
  1502. *
  1503. * @access public
  1504. *
  1505. * @param string $text The value to set for this component.
  1506. *
  1507. * @return void
  1508. *
  1509. */
  1510. function addEmail($text)
  1511. {
  1512. $this->autoparam = 'EMAIL';
  1513. $iter = $this->countIter('EMAIL');
  1514. $this->setValue('EMAIL', $iter, 0, $text);
  1515. }
  1516. /**
  1517. *
  1518. * Gets back the value of one iteration of the EMAIL component. There can
  1519. * be zero, one, or more component iterations in a vCard.
  1520. *
  1521. * @access public
  1522. *
  1523. * @param int $iter The component iteration-number to get the value
  1524. * for.
  1525. *
  1526. * @return mixed The value of this component, or a PEAR_Error if the
  1527. * iteration number is not valid.
  1528. *
  1529. */
  1530. function getEmail($iter)
  1531. {
  1532. if (! is_integer($iter) || $iter < 0) {
  1533. return $this->raiseError('EMAIL iteration number not valid.');
  1534. } else {
  1535. return $this->getMeta('EMAIL', $iter) .
  1536. $this->getValue('EMAIL', $iter, 0);
  1537. }
  1538. }
  1539. /**
  1540. *
  1541. * Sets the full value of the NICKNAME component. There is only one
  1542. * component iteration allowed per vCard, but there may be multiple
  1543. * value repetitions in the iteration.
  1544. *
  1545. * @access public
  1546. *
  1547. * @param mixed $text String (one repetition) or array (multiple
  1548. * reptitions) of the component iteration value.
  1549. *
  1550. * @return void
  1551. *
  1552. */
  1553. function addNickname($text)
  1554. {
  1555. $this->autoparam = 'NICKNAME';
  1556. $this->addValue('NICKNAME', 0, 0, $text);
  1557. }
  1558. /**
  1559. *
  1560. * Gets back the value of the NICKNAME component. There is only one
  1561. * component allowed per vCard, but there may be multiple value
  1562. * repetitions in the iteration.
  1563. *
  1564. * @access public
  1565. *
  1566. * @return string The value of this component.
  1567. *
  1568. */
  1569. function getNickname()
  1570. {
  1571. return $this->getMeta('NICKNAME') .
  1572. $this->getValue('NICKNAME', 0, 0);
  1573. }
  1574. /**
  1575. *
  1576. * Sets the full value of the CATEGORIES component. There is only
  1577. * one component iteration allowed per vCard, but there may be
  1578. * multiple value repetitions in the iteration.
  1579. *
  1580. * @access public
  1581. *
  1582. * @param mixed $text String (one repetition) or array (multiple
  1583. * reptitions) of the component iteration value.
  1584. *
  1585. * @return void
  1586. *
  1587. */
  1588. function addCategories($text, $append = true)
  1589. {
  1590. $this->autoparam = 'CATEGORIES';
  1591. $this->addValue('CATEGORIES', 0, 0, $text);
  1592. }
  1593. /**
  1594. *
  1595. * Gets back the value of the CATEGORIES component. There is only
  1596. * one component allowed per vCard, but there may be multiple value
  1597. * repetitions in the iteration.
  1598. *
  1599. * @access public
  1600. *
  1601. * @return string The value of this component.
  1602. *
  1603. */
  1604. function getCategories()
  1605. {
  1606. return $this->getMeta('CATEGORIES', 0) .
  1607. $this->getValue('CATEGORIES', 0, 0);
  1608. }
  1609. /**
  1610. *
  1611. * Sets the full value of the ORG component. There can be only one
  1612. * ORG component in a vCard.
  1613. *
  1614. * The ORG component can have one or more parts (as opposed to
  1615. * repetitions of values within those parts). The first part is the
  1616. * highest-level organization, the second part is the next-highest,
  1617. * the third part is the third-highest, and so on. There can by any
  1618. * number of parts in one ORG iteration. (This is different from
  1619. * other components, such as NICKNAME, where an iteration has only
  1620. * one part but may have many repetitions within that part.)
  1621. *
  1622. * @access public
  1623. *
  1624. * @param mixed $text String (one ORG part) or array (of ORG
  1625. * parts) to use as the value for the component iteration.
  1626. *
  1627. * @return void
  1628. *
  1629. */
  1630. function addOrganization($text)
  1631. {
  1632. $

Large files files are truncated, but you can click here to view the full file