Query.php 3.7 KB

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