[ 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/ -> Map.php (source)

   1  <?php
   2  
   3  include_once 'Horde/SyncML/State.php';
   4  include_once 'Horde/SyncML/Command.php';
   5  
   6  /**
   7   * The Horde_SyncML_Map class provides a SyncML implementation of
   8   * the Map command as defined in SyncML Representation Protocol,
   9   * version 1.0.1 5.5.8.
  10   *
  11   * $Horde: framework/SyncML/SyncML/Command/Map.php,v 1.1 2004/07/02 19:24:44 chuck Exp $
  12   *
  13   * Copyright 2004 Karsten Fourmont <fourmont@gmx.de>
  14   *
  15   * See the enclosed file COPYING for license information (LGPL). If you
  16   * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  17   *
  18   * @author  Karsten Fourmont <fourmont@gmx.de>
  19   * @version $Revision: 18602 $
  20   * @since   Horde 3.0
  21   * @package Horde_SyncML
  22   */
  23  class Horde_SyncML_Command_Map extends Horde_SyncML_Command {
  24  
  25      /**
  26       * @var string $_sourceURI
  27       */
  28      var $_sourceLocURI;
  29  
  30      /**
  31       * @var string $_targetURI
  32       */
  33      var $_targetLocURI;
  34  
  35      /**
  36       * Use in xml tag.
  37       */
  38      var $_isInSource;
  39  
  40      var $_mapTarget;
  41      var $_mapSource;
  42  
  43      function output($currentCmdID, &$output)
  44      {
  45          $attrs = array();
  46  
  47          $state = $_SESSION['SyncML.state'];
  48  
  49          $status = &new Horde_SyncML_Command_Status($state->isAuthorized() ? RESPONSE_OK : RESPONSE_INVALID_CREDENTIALS, 'Map');
  50          $status->setCmdRef($this->_cmdID);
  51          if ($this->_sourceLocURI != null) {
  52              $status->setSourceRef($this->_sourceLocURI);
  53          }
  54          if ($this->_targetLocURI != null) {
  55              $status->setTargetRef($this->_targetLocURI);
  56          }
  57  
  58          $currentCmdID = $status->output($currentCmdID, $output);
  59  
  60          return $currentCmdID;
  61      }
  62  
  63      /**
  64       * Setter for property sourceURI.
  65       *
  66       * @param string $sourceURI  New value of property sourceURI.
  67       */
  68      function setSourceLocURI($sourceURI)
  69      {
  70          $this->_sourceURI = $sourceURI;
  71      }
  72  
  73      function getTargetLocURI()
  74      {
  75          return $this->_targetURI;
  76      }
  77  
  78      /**
  79       * Setter for property targetURI.
  80       *
  81       * @param string $targetURI  New value of property targetURI.
  82       */
  83      function setTargetURI($targetURI)
  84      {
  85          $this->_targetURI = $targetURI;
  86      }
  87  
  88      function startElement($uri, $element, $attrs)
  89      {
  90          parent::startElement($uri, $element, $attrs);
  91  
  92          switch ($this->_xmlStack) {
  93          case 2:
  94              if ($element == 'Target') {
  95                  $this->_isInSource = false;
  96              }
  97              if ($element == 'Source') {
  98                  $this->_isInSource = true;
  99              }
 100              if ($element == 'MapItem') {
 101                  unset($this->_mapTarget);
 102                  unset($this->_mapSource);
 103              }
 104              break;
 105  
 106          case 3:
 107              if ($element == 'Target') {
 108                  $this->_isInSource = false;
 109              }
 110              if ($element == 'Source') {
 111                  $this->_isInSource = true;
 112              }
 113              break;
 114          }
 115      }
 116  
 117      function endElement($uri, $element)
 118      {
 119          switch ($this->_xmlStack) {
 120          case 1:
 121              $state = $_SESSION['SyncML.state'];
 122              $sync = $state->getSync($this->_targetLocURI);
 123  
 124              if (!$sync) {
 125              }
 126  
 127              $_SESSION['SyncML.state'] = $state;
 128              break;
 129  
 130          case 2:
 131              if ($element == 'MapItem') {
 132                  $state = $_SESSION['SyncML.state'];
 133                  $sync = $state->getSync($this->_targetLocURI);
 134                  if (!$state->isAuthorized()) {
 135                      Horde::logMessage('SyncML: Not Authorized in the middle of MapItem!', __FILE__, __LINE__, PEAR_LOG_ERR);
 136                  } else {
 137                      Horde::logMessage("SyncML: creating Map for source=" .
 138                                        $this->_mapSource . " and target=" . $this->_mapTarget, __FILE__, __LINE__, PEAR_LOG_DEBUG);
 139                      // Overwrite existing data by removing it first:
 140                      $r = $state->setUID($this->_targetLocURI, $this->_mapSource, $this->_mapTarget);
 141                      if (is_a($r, 'PEAR_Error')) {
 142                          Horde::logMessage('SyncML: PEAR Error: ' . $r->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
 143                          return false;
 144                      }
 145                  }
 146              }
 147              break;
 148  
 149          case 3:
 150              if ($element == 'LocURI') {
 151                  if ($this->_isInSource) {
 152                      $this->_sourceLocURI = trim($this->_chars);
 153                  } else {
 154                      $targetLocURIData = explode('?/',trim($this->_chars));
 155  
 156              $this->_targetLocURI = $targetLocURIData[0];
 157              
 158              if(isset($targetLocURIData[1]))
 159              {
 160                  $this->_targetLocURIParameters = $targetLocURIData[1];
 161              }
 162                  }
 163              }
 164              break;
 165  
 166          case 4:
 167              if ($element == 'LocURI') {
 168                  if ($this->_isInSource) {
 169                      $this->_mapSource = trim($this->_chars);
 170                  } else {
 171                      $this->_mapTarget = trim($this->_chars);
 172                  }
 173              }
 174              break;
 175          }
 176  
 177          parent::endElement($uri, $element);
 178      }
 179  
 180  }


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