~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/Gdata/App/BaseMediaSource.php

  • Committer: Mustafa A. Hashmi
  • Date: 2008-12-04 13:32:21 UTC
  • Revision ID: mhashmi@zivios.org-20081204133221-0nd1trunwevijj38
Inclusion of new installation framework with ties to zend layout and dojo layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * Zend Framework
 
5
 *
 
6
 * LICENSE
 
7
 *
 
8
 * This source file is subject to the new BSD license that is bundled
 
9
 * with this package in the file LICENSE.txt.
 
10
 * It is also available through the world-wide-web at this URL:
 
11
 * http://framework.zend.com/license/new-bsd
 
12
 * If you did not receive a copy of the license and are unable to
 
13
 * obtain it through the world-wide-web, please send an email
 
14
 * to license@zend.com so we can send you a copy immediately.
 
15
 *
 
16
 * @category   Zend
 
17
 * @package    Zend_Gdata
 
18
 * @subpackage App
 
19
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
20
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
21
 */
 
22
 
 
23
/**
 
24
 * @see Zend_Gdata_App_MediaSource
 
25
 */
 
26
require_once 'Zend/Gdata/App/MediaSource.php';
 
27
 
 
28
/**
 
29
 * Concrete class to use a file handle as an attachment within a MediaEntry.
 
30
 *
 
31
 * @category   Zend
 
32
 * @package    Zend_Gdata
 
33
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
34
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
35
 */
 
36
abstract class Zend_Gdata_App_BaseMediaSource implements Zend_Gdata_App_MediaSource
 
37
{
 
38
 
 
39
    /**
 
40
     * The content type for the attached file (example image/png)
 
41
     *
 
42
     * @var string
 
43
     */
 
44
    protected $_contentType = null;
 
45
 
 
46
    /**
 
47
     * The slug header value representing the attached file title, or null if
 
48
     * no slug should be used.  The slug header is only necessary in some cases,
 
49
     * usually when a multipart upload is not being performed.
 
50
     *
 
51
     * @var string
 
52
     */
 
53
    protected $_slug = null;
 
54
    
 
55
    /** 
 
56
     * The content type for the attached file (example image/png)
 
57
     *
 
58
     * @return string The content type
 
59
     */
 
60
    public function getContentType()
 
61
    {
 
62
        return $this->_contentType;
 
63
    }
 
64
 
 
65
    /** 
 
66
     * Set the content type for the file attached (example image/png)
 
67
     *
 
68
     * @param string $value The content type
 
69
     * @return Zend_Gdata_App_MediaFileSource Provides a fluent interface
 
70
     */
 
71
    public function setContentType($value)
 
72
    {
 
73
        $this->_contentType = $value;
 
74
        return $this;
 
75
    }
 
76
 
 
77
    /**
 
78
     * Returns the Slug header value.  Used by some services to determine the 
 
79
     * title for the uploaded file.  Returns null if no slug should be used.
 
80
     *
 
81
     * @return string
 
82
     */
 
83
    public function getSlug(){
 
84
        return $this->_slug;
 
85
    }
 
86
 
 
87
    /**
 
88
     * Sets the Slug header value.  Used by some services to determine the 
 
89
     * title for the uploaded file.  A null value indicates no slug header.
 
90
     *
 
91
     * @var string The slug value
 
92
     * @return Zend_Gdata_App_MediaSource Provides a fluent interface
 
93
     */
 
94
    public function setSlug($value){
 
95
        $this->_slug = $value;
 
96
        return $this;
 
97
    }
 
98
 
 
99
 
 
100
    /**
 
101
     * Magic getter to allow acces like $source->foo to call $source->getFoo()
 
102
     * Alternatively, if no getFoo() is defined, but a $_foo protected variable
 
103
     * is defined, this is returned.
 
104
     *
 
105
     * TODO Remove ability to bypass getFoo() methods??
 
106
     *
 
107
     * @param string $name The variable name sought
 
108
     */
 
109
    public function __get($name)
 
110
    {
 
111
        $method = 'get'.ucfirst($name);
 
112
        if (method_exists($this, $method)) {
 
113
            return call_user_func(array(&$this, $method));
 
114
        } else if (property_exists($this, "_${name}")) {
 
115
            return $this->{'_' . $name};
 
116
        } else {
 
117
            require_once 'Zend/Gdata/App/InvalidArgumentException.php';
 
118
            throw new Zend_Gdata_App_InvalidArgumentException(
 
119
                    'Property ' . $name . ' does not exist');
 
120
        }
 
121
    }
 
122
 
 
123
    /**
 
124
     * Magic setter to allow acces like $source->foo='bar' to call
 
125
     * $source->setFoo('bar') automatically.
 
126
     *
 
127
     * Alternatively, if no setFoo() is defined, but a $_foo protected variable
 
128
     * is defined, this is returned.
 
129
     *
 
130
     * @param string $name
 
131
     * @param string $value
 
132
     */
 
133
    public function __set($name, $val)
 
134
    {
 
135
        $method = 'set'.ucfirst($name);
 
136
        if (method_exists($this, $method)) {
 
137
            return call_user_func(array(&$this, $method), $val);
 
138
        } else if (isset($this->{'_' . $name}) || is_null($this->{'_' . $name})) {
 
139
            $this->{'_' . $name} = $val;
 
140
        } else {
 
141
            require_once 'Zend/Gdata/App/InvalidArgumentException.php';
 
142
            throw new Zend_Gdata_App_InvalidArgumentException(
 
143
                    'Property ' . $name . '  does not exist');
 
144
        }
 
145
    }
 
146
 
 
147
    /**
 
148
     * Magic __isset method
 
149
     *
 
150
     * @param string $name
 
151
     */
 
152
    public function __isset($name)
 
153
    {
 
154
        $rc = new ReflectionClass(get_class($this));
 
155
        $privName = '_' . $name;
 
156
        if (!($rc->hasProperty($privName))) {
 
157
            require_once 'Zend/Gdata/App/InvalidArgumentException.php';
 
158
            throw new Zend_Gdata_App_InvalidArgumentException(
 
159
                    'Property ' . $name . ' does not exist');
 
160
        } else {
 
161
            if (isset($this->{$privName})) {
 
162
                if (is_array($this->{$privName})) {
 
163
                    if (count($this->{$privName}) > 0) {
 
164
                        return true;
 
165
                    } else {
 
166
                        return false;
 
167
                    }
 
168
                } else {
 
169
                    return true;
 
170
                }
 
171
            } else {
 
172
                return false;
 
173
            }
 
174
        }
 
175
    }
 
176
    
 
177
}