VolumeQuery.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 Books
  18. * @copyright Copyright (c) 2005-2009 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_Books
  23. */
  24. require_once('Zend/Gdata/Books.php');
  25. /**
  26. * Zend_Gdata_Query
  27. */
  28. require_once('Zend/Gdata/Query.php');
  29. /**
  30. * Assists in constructing queries for Books volumes
  31. *
  32. * @category Zend
  33. * @package Zend_Gdata
  34. * @subpackage Books
  35. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  36. * @license http://framework.zend.com/license/new-bsd New BSD License
  37. */
  38. class Zend_Gdata_Books_VolumeQuery extends Zend_Gdata_Query
  39. {
  40. /**
  41. * Create Gdata_Books_VolumeQuery object
  42. *
  43. * @param string|null $url If non-null, pre-initializes the instance to
  44. * use a given URL.
  45. */
  46. public function __construct($url = null)
  47. {
  48. parent::__construct($url);
  49. }
  50. /**
  51. * Sets the minimum level of viewability of volumes to return in the search results
  52. *
  53. * @param string|null $value The minimum viewability - 'full' or 'partial'
  54. * @return Zend_Gdata_Books_VolumeQuery Provides a fluent interface
  55. */
  56. public function setMinViewability($value = null)
  57. {
  58. switch ($value) {
  59. case 'full_view':
  60. $this->_params['min-viewability'] = 'full';
  61. break;
  62. case 'partial_view':
  63. $this->_params['min-viewability'] = 'partial';
  64. break;
  65. case null:
  66. unset($this->_params['min-viewability']);
  67. break;
  68. }
  69. return $this;
  70. }
  71. /**
  72. * Minimum viewability of volumes to include in search results
  73. *
  74. * @return string|null min-viewability
  75. */
  76. public function getMinViewability()
  77. {
  78. if (array_key_exists('min-viewability', $this->_params)) {
  79. return $this->_params['min-viewability'];
  80. } else {
  81. return null;
  82. }
  83. }
  84. /**
  85. * Returns the generated full query URL
  86. *
  87. * @return string The URL
  88. */
  89. public function getQueryUrl()
  90. {
  91. if (isset($this->_url)) {
  92. $url = $this->_url;
  93. } else {
  94. $url = Zend_Gdata_Books::VOLUME_FEED_URI;
  95. }
  96. if ($this->getCategory() !== null) {
  97. $url .= '/-/' . $this->getCategory();
  98. }
  99. $url = $url . $this->getQueryString();
  100. return $url;
  101. }
  102. }