[ Index ]
 

Code source de Horde 3.1.3

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

title

Body

[fermer]

/lib/SyncML/Command/ -> Map.php (source)

   1  <?php
   2  
   3  include_once  'SyncML/Command.php';
   4  
   5  /**
   6   * The SyncML_Map class provides a SyncML implementation of
   7   * the Map command as defined in SyncML Representation Protocol,
   8   * version 1.0.1 5.5.8.
   9   *
  10   * $Horde: framework/SyncML/SyncML/Command/Map.php,v 1.1.10.6 2006/01/01 21:28:36 jan Exp $
  11   *
  12   * Copyright 2004-2006 Karsten Fourmont <karsten@horde.org>
  13   *
  14   * See the enclosed file COPYING for license information (LGPL). If you
  15   * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  16   *
  17   * @author  Karsten Fourmont <karsten@horde.org>
  18   * @since   Horde 3.0
  19   * @package SyncML
  20   */
  21  class SyncML_Command_Map extends SyncML_Command {
  22  
  23      /**
  24       * @var string
  25       */
  26      var $_sourceLocURI;
  27  
  28      /**
  29       * @var string
  30       */
  31      var $_targetLocURI;
  32  
  33      var $_mapTarget;
  34      var $_mapSource;
  35  
  36      function output($currentCmdID, &$output)
  37      {
  38          $attrs = array();
  39  
  40          $state = &$_SESSION['SyncML.state'];
  41  
  42          $status = &new SyncML_Command_Status($state->isAuthorized() ? RESPONSE_OK : RESPONSE_INVALID_CREDENTIALS, 'Map');
  43          $status->setCmdRef($this->_cmdID);
  44          if ($this->_sourceLocURI != null) {
  45              $status->setSourceRef($this->_sourceLocURI);
  46          }
  47          if ($this->_targetLocURI != null) {
  48              $status->setTargetRef($this->_targetLocURI);
  49          }
  50  
  51          $currentCmdID = $status->output($currentCmdID, $output);
  52  
  53          return $currentCmdID;
  54      }
  55  
  56      /**
  57       * Setter for property sourceURI.
  58       *
  59       * @param string $sourceURI  New value of property sourceURI.
  60       */
  61      function setSourceLocURI($sourceURI)
  62      {
  63          $this->_sourceURI = $sourceURI;
  64      }
  65  
  66      function getTargetLocURI()
  67      {
  68          return $this->_targetURI;
  69      }
  70  
  71      /**
  72       * Setter for property targetURI.
  73       *
  74       * @param string $targetURI  New value of property targetURI.
  75       */
  76      function setTargetURI($targetURI)
  77      {
  78          $this->_targetURI = $targetURI;
  79      }
  80  
  81      function startElement($uri, $element, $attrs)
  82      {
  83          parent::startElement($uri, $element, $attrs);
  84  
  85          switch (count($this->_Stack)) {
  86          case 2:
  87              if ($element == 'MapItem') {
  88                  unset($this->_mapTarget);
  89                  unset($this->_mapSource);
  90              }
  91              break;
  92          }
  93      }
  94  
  95      function endElement($uri, $element)
  96      {
  97          global $backend;
  98  
  99          switch (count($this->_Stack)) {
 100          case 1:
 101              $state = &$_SESSION['SyncML.state'];
 102              $sync = & $state->getSync($this->_targetLocURI);
 103              break;
 104  
 105          case 2:
 106              if ($element == 'MapItem') {
 107                  $state = &$_SESSION['SyncML.state'];
 108                  $sync = & $state->getSync($this->_targetLocURI);
 109                  if (!$state->isAuthorized()) {
 110                      $backend->logMessage('Not Authorized in MapItem!',
 111                                           __FILE__, __LINE__, PEAR_LOG_ERR);
 112                  } else {
 113                      // Overwrite existing data by removing it first.
 114                      $backend->createUidMap($state->getSyncIdentifier(),
 115                                             $this->_targetLocURI,
 116                                             $this->_mapSource,
 117                                             $this->_mapTarget);
 118  
 119                      $backend->logMessage('created Map for source='
 120                                           . $this->_mapSource
 121                                           . ' and target=' . $this->_mapTarget
 122                                           . ' in db ' . $this->_targetLocURI,
 123                                           __FILE__, __LINE__, PEAR_LOG_DEBUG);
 124  
 125                  }
 126              }
 127              break;
 128  
 129          case 3:
 130              if ($element == 'LocURI') {
 131                  if ($this->_Stack[1] == 'Source') {
 132                      $this->_sourceLocURI = trim($this->_chars);
 133                  } elseif ($this->_Stack[1] == 'Target') {
 134                      $this->_targetLocURI = trim($this->_chars);
 135                  }
 136              }
 137              break;
 138  
 139          case 4:
 140              if ($element == 'LocURI') {
 141                  if ($this->_Stack[2] == 'Source') {
 142                      $this->_mapSource = trim($this->_chars);
 143                  } elseif ($this->_Stack[2] == 'Target') {
 144                      $this->_mapTarget = trim($this->_chars);
 145                  }
 146              }
 147              break;
 148          }
 149  
 150          parent::endElement($uri, $element);
 151      }
 152  
 153  }


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