summaryrefslogtreecommitdiff
path: root/zend/library/Zend/Gdata/Photos/AlbumQuery.php
blob: ee00322692989ec28408c4f9d34e02c8369e587e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php

/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Gdata
 * @subpackage Photos
 * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: AlbumQuery.php 24593 2012-01-05 20:35:02Z matthew $
 */

/**
 * @see Zend_Gdata_Photos_UserQuery
 */
require_once('Zend/Gdata/Photos/UserQuery.php');

/**
 * Assists in constructing album queries for various entries.
 * Instances of this class can be provided in many places where a URL is
 * required.
 *
 * For information on submitting queries to a server, see the service
 * class, Zend_Gdata_Photos.
 *
 * @category   Zend
 * @package    Zend_Gdata
 * @subpackage Photos
 * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Gdata_Photos_AlbumQuery extends Zend_Gdata_Photos_UserQuery
{

    /**
     * The name of the album to query for. Mutually exclusive with AlbumId.
     *
     * @var string
     */
    protected $_albumName = null;

    /**
     * The ID of the album to query for. Mutually exclusive with AlbumName.
     *
     * @var string
     */
    protected $_albumId = null;

    /**
     * Set the album name to query for. When set, this album's photographs
     * be returned. If not set or null, the default user's feed will be
     * returned instead.
     *
     * NOTE: AlbumName and AlbumId are mutually exclusive. Setting one will
     *       automatically set the other to null.
     *
     * @param string $value The name of the album to retrieve, or null to
     *          clear.
     * @return Zend_Gdata_Photos_AlbumQuery The query object.
     */
     public function setAlbumName($value)
     {
         $this->_albumId = null;
         $this->_albumName = $value;

         return $this;
     }

    /**
     * Get the album name which is to be returned.
     *
     * @see setAlbumName
     * @return string The name of the album to retrieve.
     */
    public function getAlbumName()
    {
        return $this->_albumName;
    }

    /**
     * Set the album ID to query for. When set, this album's photographs
     * be returned. If not set or null, the default user's feed will be
     * returned instead.
     *
     * NOTE: Album and AlbumId are mutually exclusive. Setting one will
     *       automatically set the other to null.
     *
     * @param string $value The ID of the album to retrieve, or null to
     *          clear.
     * @return Zend_Gdata_Photos_AlbumQuery The query object.
     */
     public function setAlbumId($value)
     {
         $this->_albumName = null;
         $this->_albumId = $value;

         return $this;
     }

    /**
     * Get the album ID which is to be returned.
     *
     * @see setAlbum
     * @return string The ID of the album to retrieve.
     */
    public function getAlbumId()
    {
        return $this->_albumId;
    }

    /**
     * Returns the URL generated for this query, based on it's current
     * parameters.
     *
     * @return string A URL generated based on the state of this query.
     * @throws Zend_Gdata_App_InvalidArgumentException
     */
    public function getQueryUrl($incomingUri = '')
    {
        $uri = '';
        if ($this->getAlbumName() !== null && $this->getAlbumId() === null) {
            $uri .= '/album/' . $this->getAlbumName();
        } elseif ($this->getAlbumName() === null && $this->getAlbumId() !== null) {
            $uri .= '/albumid/' . $this->getAlbumId();
        } elseif ($this->getAlbumName() !== null && $this->getAlbumId() !== null) {
            require_once 'Zend/Gdata/App/InvalidArgumentException.php';
            throw new Zend_Gdata_App_InvalidArgumentException(
                    'AlbumName and AlbumId cannot both be non-null');
        } else {
            require_once 'Zend/Gdata/App/InvalidArgumentException.php';
            throw new Zend_Gdata_App_InvalidArgumentException(
                    'AlbumName and AlbumId cannot both be null');
        }
        $uri .= $incomingUri;
        return parent::getQueryUrl($uri);
    }

}