AlbumQuery.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 Photos
  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. * @see Zend_Gdata_Photos_UserQuery
  23. */
  24. require_once('Zend/Gdata/Photos/UserQuery.php');
  25. /**
  26. * Assists in constructing album queries for various entries.
  27. * Instances of this class can be provided in many places where a URL is
  28. * required.
  29. *
  30. * For information on submitting queries to a server, see the service
  31. * class, Zend_Gdata_Photos.
  32. *
  33. * @category Zend
  34. * @package Zend_Gdata
  35. * @subpackage Photos
  36. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  37. * @license http://framework.zend.com/license/new-bsd New BSD License
  38. */
  39. class Zend_Gdata_Photos_AlbumQuery extends Zend_Gdata_Photos_UserQuery
  40. {
  41. /**
  42. * The name of the album to query for. Mutually exclusive with AlbumId.
  43. *
  44. * @var string
  45. */
  46. protected $_albumName = null;
  47. /**
  48. * The ID of the album to query for. Mutually exclusive with AlbumName.
  49. *
  50. * @var string
  51. */
  52. protected $_albumId = null;
  53. /**
  54. * Set the album name to query for. When set, this album's photographs
  55. * be returned. If not set or null, the default user's feed will be
  56. * returned instead.
  57. *
  58. * NOTE: AlbumName and AlbumId are mutually exclusive. Setting one will
  59. * automatically set the other to null.
  60. *
  61. * @param string $value The name of the album to retrieve, or null to
  62. * clear.
  63. * @return Zend_Gdata_Photos_AlbumQuery The query object.
  64. */
  65. public function setAlbumName($value)
  66. {
  67. $this->_albumId = null;
  68. $this->_albumName = $value;
  69. return $this;
  70. }
  71. /**
  72. * Get the album name which is to be returned.
  73. *
  74. * @see setAlbumName
  75. * @return string The name of the album to retrieve.
  76. */
  77. public function getAlbumName()
  78. {
  79. return $this->_albumName;
  80. }
  81. /**
  82. * Set the album ID to query for. When set, this album's photographs
  83. * be returned. If not set or null, the default user's feed will be
  84. * returned instead.
  85. *
  86. * NOTE: Album and AlbumId are mutually exclusive. Setting one will
  87. * automatically set the other to null.
  88. *
  89. * @param string $value The ID of the album to retrieve, or null to
  90. * clear.
  91. * @return Zend_Gdata_Photos_AlbumQuery The query object.
  92. */
  93. public function setAlbumId($value)
  94. {
  95. $this->_albumName = null;
  96. $this->_albumId = $value;
  97. return $this;
  98. }
  99. /**
  100. * Get the album ID which is to be returned.
  101. *
  102. * @see setAlbum
  103. * @return string The ID of the album to retrieve.
  104. */
  105. public function getAlbumId()
  106. {
  107. return $this->_albumId;
  108. }
  109. /**
  110. * Returns the URL generated for this query, based on it's current
  111. * parameters.
  112. *
  113. * @return string A URL generated based on the state of this query.
  114. * @throws Zend_Gdata_App_InvalidArgumentException
  115. */
  116. public function getQueryUrl($incomingUri = '')
  117. {
  118. $uri = '';
  119. if ($this->getAlbumName() !== null && $this->getAlbumId() === null) {
  120. $uri .= '/album/' . $this->getAlbumName();
  121. } elseif ($this->getAlbumName() === null && $this->getAlbumId() !== null) {
  122. $uri .= '/albumid/' . $this->getAlbumId();
  123. } elseif ($this->getAlbumName() !== null && $this->getAlbumId() !== null) {
  124. require_once 'Zend/Gdata/App/InvalidArgumentException.php';
  125. throw new Zend_Gdata_App_InvalidArgumentException(
  126. 'AlbumName and AlbumId cannot both be non-null');
  127. } else {
  128. require_once 'Zend/Gdata/App/InvalidArgumentException.php';
  129. throw new Zend_Gdata_App_InvalidArgumentException(
  130. 'AlbumName and AlbumId cannot both be null');
  131. }
  132. $uri .= $incomingUri;
  133. return parent::getQueryUrl($uri);
  134. }
  135. }