2
0

Query.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Gdata
  17. * @subpackage Gapps
  18. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * Zend_Gdata_Query
  23. */
  24. require_once('Zend/Gdata/Query.php');
  25. /**
  26. * Zend_Gdata_Gapps
  27. */
  28. require_once('Zend/Gdata/Gapps.php');
  29. /**
  30. * Assists in constructing queries for Google Apps entries. This class
  31. * provides common methods used by all other Google Apps query classes.
  32. *
  33. * This class should never be instantiated directly. Instead, instantiate a
  34. * class which inherits from this class.
  35. *
  36. * @category Zend
  37. * @package Zend_Gdata
  38. * @subpackage Gapps
  39. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  40. * @license http://framework.zend.com/license/new-bsd New BSD License
  41. */
  42. abstract class Zend_Gdata_Gapps_Query extends Zend_Gdata_Query
  43. {
  44. /**
  45. * The domain which is being administered via the Provisioning API.
  46. *
  47. * @var string
  48. */
  49. protected $_domain = null;
  50. /**
  51. * Create a new instance.
  52. *
  53. * @param string $domain (optional) The Google Apps-hosted domain to use
  54. * when constructing query URIs.
  55. */
  56. public function __construct($domain = null)
  57. {
  58. parent::__construct();
  59. $this->_domain = $domain;
  60. }
  61. /**
  62. * Set domain for this service instance. This should be a fully qualified
  63. * domain, such as 'foo.example.com'.
  64. *
  65. * This value is used when calculating URLs for retrieving and posting
  66. * entries. If no value is specified, a URL will have to be manually
  67. * constructed prior to using any methods which interact with the Google
  68. * Apps provisioning service.
  69. *
  70. * @param string $value The domain to be used for this session.
  71. */
  72. public function setDomain($value)
  73. {
  74. $this->_domain = $value;
  75. }
  76. /**
  77. * Get domain for this service instance. This should be a fully qualified
  78. * domain, such as 'foo.example.com'. If no domain is set, null will be
  79. * returned.
  80. *
  81. * @see setDomain
  82. * @return string The domain to be used for this session, or null if not
  83. * set.
  84. */
  85. public function getDomain()
  86. {
  87. return $this->_domain;
  88. }
  89. /**
  90. * Returns the base URL used to access the Google Apps service, based
  91. * on the current domain. The current domain can be temporarily
  92. * overridden by providing a fully qualified domain as $domain.
  93. *
  94. * @see setDomain
  95. * @param string $domain (optional) A fully-qualified domain to use
  96. * instead of the default domain for this service instance.
  97. */
  98. public function getBaseUrl($domain = null)
  99. {
  100. if ($domain !== null) {
  101. return Zend_Gdata_Gapps::APPS_BASE_FEED_URI . '/' . $domain;
  102. }
  103. else if ($this->_domain !== null) {
  104. return Zend_Gdata_Gapps::APPS_BASE_FEED_URI . '/' . $this->_domain;
  105. }
  106. else {
  107. require_once 'Zend/Gdata/App/InvalidArgumentException.php';
  108. throw new Zend_Gdata_App_InvalidArgumentException(
  109. 'Domain must be specified.');
  110. }
  111. }
  112. }