[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/phpgwapi/inc/horde/Horde/SyncML/Command/Sync/ -> SyncElement.php (source)

   1  <?php
   2  
   3  include_once 'Horde/SyncML/Command.php';
   4  
   5  /**
   6   * $Horde: framework/SyncML/SyncML/Command/Sync/SyncElement.php,v 1.11 2004/07/02 19:24:44 chuck Exp $
   7   *
   8   * Copyright 2003-2004 Anthony Mills <amills@pyramid6.com>
   9   * Copyright 2005-2006 Lars Kneschke <l.kneschke@metaways.de>
  10   *
  11   * See the enclosed file COPYING for license information (LGPL). If you
  12   * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  13   *
  14   * @author  Anthony Mills <amills@pyramid6.com>
  15   * @version $Revision: 21249 $
  16   * @since   Horde 3.0
  17   * @package Horde_SyncML
  18   */
  19  class Horde_SyncML_Command_Sync_SyncElement extends Horde_SyncML_Command {
  20  
  21      var $_luid;
  22      var $_guid;
  23      var $_isSource;
  24      var $_content;
  25      var $_contentType;
  26      var $_status = RESPONSE_OK;
  27      var $_items;
  28      
  29      function &factory($command, $params = null) {
  30          include_once 'Horde/SyncML/Command/Sync/SyncElementItem.php';
  31          @include_once 'Horde/SyncML/Command/Sync/' . $command . '.php';
  32          
  33          $class = 'Horde_SyncML_Command_Sync_' . $command;
  34          
  35          if (class_exists($class)) {
  36              #Horde::logMessage('SyncML: Class definition of ' . $class . ' found in SyncElement::factory.', __FILE__, __LINE__, PEAR_LOG_DEBUG);
  37              return $element = &new $class($params);
  38          } else {
  39              Horde::logMessage('SyncML: Class definition of ' . $class . ' not found in SyncElement::factory.', __FILE__, __LINE__, PEAR_LOG_DEBUG);
  40              require_once 'PEAR.php';
  41              return PEAR::raiseError('Class definition of ' . $class . ' not found.');
  42          }
  43      }
  44  
  45  	function startElement($uri, $element, $attrs) {
  46          parent::startElement($uri, $element, $attrs);
  47          
  48          switch ($this->_xmlStack) {
  49              case 3:
  50                  if ($element == 'Source') {
  51                      $this->_isSource = true;
  52                  }
  53                  break;
  54          }
  55      }
  56      
  57  	function endElement($uri, $element) {
  58          $search = array('/ *\n/','/ *$/m');
  59          $replace = array('','');
  60          
  61          switch ($this->_xmlStack) {
  62              case 1:
  63                  // Need to add sync elements to the Sync method?
  64                  #error_log('total # of items: '.count($this->_items));
  65                  #error_log(print_r($this->_items[10], true));
  66                  break;
  67              case 2;
  68                  if($element == 'Item') {
  69                      $item = new Horde_SyncML_Command_Sync_SyncElementItem();
  70  
  71                      if($this->_luid) {
  72                          $item->setLocURI($this->_luid);
  73                          $item->setContent($this->_content);
  74                          $item->setContentType($this->_contentType);
  75                      
  76                          if($this->_contentSize)
  77                              $item->setContentType($this->_contentSize);
  78                          if($this->_moreData)
  79                              $item->setMoreData($this->_moreData);
  80                              
  81                          $this->_items[$this->_luid] = $item;
  82                      }
  83                      
  84                      unset($this->_content);
  85                      unset($this->_contentSize);
  86                      unset($this->_luid);
  87                  }
  88                  break;
  89              case 3:
  90                  if ($element == 'Source') {
  91                      $this->_isSource = false;
  92                  } elseif ($element == 'Data') {
  93                      $this->_content = $this->_chars;
  94                  } elseif ($element == 'MoreData') {
  95                      $this->_moreData = TRUE;
  96                  } elseif ($element == 'Type') {
  97                      if(empty($this->_contentType))
  98                          $this->_contentType = trim($this->_chars);
  99                  }
 100                  break;
 101              
 102              case 4:
 103                  if ($element == 'LocURI' && $this->_isSource) {
 104                      $this->_luid = trim($this->_chars);
 105                  } elseif ($element == 'Type') {
 106                      $this->_contentType = trim($this->_chars);
 107                  } elseif ($element == 'Size') {
 108                      $this->_contentSize = trim($this->_chars);
 109                  }
 110                  break;
 111          }
 112          
 113          parent::endElement($uri, $element);
 114      }
 115      
 116  	function getSyncElementItems() {
 117          return (array)$this->_items;
 118      }
 119  
 120      function getLocURI()
 121      {
 122          return $this->_luid;
 123      }
 124  
 125      function getGUID()
 126      {
 127          return $this->_guid;
 128      }
 129  
 130      function setLocURI($luid)
 131      {
 132          $this->_luid = $luid;
 133      }
 134  
 135      function setGUID($guid)
 136      {
 137          $this->_guid = $guid;
 138      }
 139  
 140      function setContentType($c)
 141      {
 142          $this->_contentType = $c;
 143      }
 144  
 145      function getContentType()
 146      {
 147          return $this->_contentType;
 148      }
 149  
 150      function getContent()
 151      {
 152          return $this->_content;
 153      }
 154  
 155      function setContent($content)
 156      {
 157          $this->_content = $content;
 158      }
 159      
 160      function setStatus($_status)
 161      {
 162          $this->_status = $_status;
 163      }
 164  }


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7