VolumeQuery.php 3.0 KB

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