当前位置: 首页>>代码示例>>PHP>>正文


PHP Horde_Icalendar::getComponentCount方法代码示例

本文整理汇总了PHP中Horde_Icalendar::getComponentCount方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Icalendar::getComponentCount方法的具体用法?PHP Horde_Icalendar::getComponentCount怎么用?PHP Horde_Icalendar::getComponentCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Horde_Icalendar的用法示例。


在下文中一共展示了Horde_Icalendar::getComponentCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: exit

 */
require_once 'Horde/Cli.php';
require_once 'Horde/Icalendar.php';
// This only works on the command line.
if (!Horde_Cli::runningFromCLI()) {
    exit("Must be run from the command line\n");
}
// Load the CLI environment - make sure there's no time limit, init
// some variables, etc.
$cli = Horde_Cli::init();
if (empty($argv[1])) {
    $cli->fatal('No file specified on the command line.');
}
$input_file = $argv[1];
if (!file_exists($input_file)) {
    $cli->fatal($input_file . ' does not exist.');
}
if (!is_readable($input_file)) {
    $cli->fatal($input_file . ' is not readable.');
}
$cli->writeln($cli->blue('Parsing ' . $input_file . ' ...'));
$data = file_get_contents($input_file);
$ical = new Horde_Icalendar();
if (!$ical->parseVCalendar($data)) {
    $cli->fatal('iCalendar parsing failed.');
}
$cli->writeln($cli->green('Parsing successful, found ' . $ical->getComponentCount() . ' component(s).'));
$components = $ical->getComponents();
foreach ($components as $component) {
    var_dump($component->toHash(true));
}
开发者ID:jubinpatel,项目名称:horde,代码行数:31,代码来源:parser.php

示例2: replace

 /**
  * Replaces the contact identified by UID with the content represented in
  * the specified contentType.
  *
  * @param string $uid            Idenfity the contact to replace.
  * @param mixed  $content        The content of the contact.
  * @param string $contentType    What format is the data in? Currently
  *                               supports array, text/directory,
  *                               text/vcard, text/x-vcard and activesync.
  * @param string|array $sources  The source(s) where the contact will be
  *                               replaced.
  *
  * @return boolean  Success or failure.
  * @throws Turba_Exception
  */
 public function replace($uid, $content, $contentType, $sources = null)
 {
     if (empty($uid)) {
         throw new Turba_Exception(_("Invalid contact unique ID"));
     }
     $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver');
     foreach ($this->_getSources($sources) as $source) {
         $sdriver = $driver->create($source);
         // Check permissions.
         if (!$sdriver->hasPermission(Horde_Perms::EDIT)) {
             continue;
         }
         $result = $sdriver->search(array('__uid' => $uid));
         if (!count($result)) {
             continue;
         } elseif (count($result) > 1) {
             throw new Turba_Exception(sprintf(_("Multiple contacts found with same unique ID %s."), $uid));
         }
         $object = $result->objects[0];
         switch ($contentType) {
             case 'activesync':
                 $content = $sdriver->fromASContact($content);
                 foreach ($content as $attribute => $value) {
                     if ($attribute != '__key') {
                         $object->setValue($attribute, $value);
                     }
                 }
                 return $object->store();
             case 'array':
                 break;
             case 'text/x-vcard':
             case 'text/vcard':
             case 'text/directory':
                 $iCal = new Horde_Icalendar();
                 if (!$iCal->parsevCalendar($content)) {
                     throw new Turba_Exception(_("There was an error importing the iCalendar data."));
                 }
                 switch ($iCal->getComponentCount()) {
                     case 0:
                         throw new Turba_Exception(_("No vCard data was found."));
                     case 1:
                         $content = $sdriver->toHash($iCal->getComponent(0));
                         break;
                     default:
                         throw new Turba_Exception(_("Only one vcard supported."));
                 }
                 break;
             default:
                 throw new Turba_Exception(sprintf(_("Unsupported Content-Type: %s"), $contentType));
         }
         foreach ($content as $attribute => $value) {
             if ($attribute != '__key') {
                 $object->setValue($attribute, $value);
             }
         }
         return $object->store();
     }
     throw new Turba_Exception(sprintf(_("Object %s not found."), $uid));
 }
开发者ID:Gomez,项目名称:horde,代码行数:74,代码来源:Api.php


注:本文中的Horde_Icalendar::getComponentCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。