AlbumQuery.php 4.5 KB

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