Subversion Repositories eFlore/Applications.cel

Rev

Rev 580 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 580 Rev 612
Line 27... Line 27...
27
 * @author    James Stewart <james@jystewart.net>
27
 * @author    James Stewart <james@jystewart.net>
28
 * @version    Release: @package_version@
28
 * @version    Release: @package_version@
29
 * @package XML_Feed_Parser
29
 * @package XML_Feed_Parser
30
 * @todo    Find a Relax NG URI we can use
30
 * @todo    Find a Relax NG URI we can use
31
 */
31
 */
32
class XML_Feed_Parser_RSS1 extends XML_Feed_Parser_Type
32
class XmlFeedParserRss1 extends XmlFeedParserType {
33
{
-
 
34
    /**
33
    /**
35
     * The URI of the RelaxNG schema used to (optionally) validate the feed 
34
     * The URI of the RelaxNG schema used to (optionally) validate the feed 
36
     * @var string
35
     * @var string
37
     */
36
     */
38
    protected $relax = 'rss10.rng';
37
    protected $relax = 'rss10.rng';
Line 51... Line 50...
51
 
50
 
52
    /**
51
    /**
53
     * The class used to represent individual items 
52
     * The class used to represent individual items 
54
     * @var string
53
     * @var string
55
     */
54
     */
Line 56... Line 55...
56
    protected $itemClass = 'XML_Feed_Parser_RSS1Element';
55
    protected $itemClass = 'XmlFeedParserRss1Element';
57
    
56
    
58
    /**
57
    /**
59
     * The element containing entries 
58
     * The element containing entries 
Line 115... Line 114...
115
     * Our constructor does nothing more than its parent.
114
     * Our constructor does nothing more than its parent.
116
     * 
115
     * 
117
     * @param    DOMDocument    $xml    A DOM object representing the feed
116
     * @param    DOMDocument    $xml    A DOM object representing the feed
118
     * @param    bool (optional) $string    Whether or not to validate this feed
117
     * @param    bool (optional) $string    Whether or not to validate this feed
119
     */
118
     */
120
    function __construct(DOMDocument $model, $strict = false)
119
    function __construct(DOMDocument $model, $strict = false) {
121
    {
-
 
122
        $this->model = $model;
120
        $this->model = $model;
123
        if ($strict) {
121
        if ($strict) {
124
            if (! $this->relaxNGValidate()) {
122
            if (! $this->relaxNGValidate()) {
125
                throw new XML_Feed_Parser_Exception('Failed required validation');
123
                throw new XML_Feed_Parser_Exception('Failed required validation');
126
            }
124
            }
Line 144... Line 142...
144
     * method does not have to seek out the entry if it's requested that way.
142
     * method does not have to seek out the entry if it's requested that way.
145
     *
143
     *
146
     * @param    string    $id    any valid ID.
144
     * @param    string    $id    any valid ID.
147
     * @return    XML_Feed_Parser_RSS1Element
145
     * @return    XML_Feed_Parser_RSS1Element
148
     */
146
     */
149
    function getEntryById($id)
147
    function getEntryById($id) {
150
    {
-
 
151
        if (isset($this->idMappings[$id])) {
148
        if (isset($this->idMappings[$id])) {
152
            return $this->entries[$this->idMappings[$id]];
149
            return $this->entries[$this->idMappings[$id]];
153
        }
150
        }
Line 154... Line 151...
154
 
151
 
Line 169... Line 166...
169
    /**
166
    /**
170
     * Get details of the image associated with the feed.
167
     * Get details of the image associated with the feed.
171
     *
168
     *
172
     * @return  array|false an array simply containing the child elements
169
     * @return  array|false an array simply containing the child elements
173
     */
170
     */
174
    protected function getImage()
171
    protected function getImage() {
175
    {
-
 
176
        $images = $this->model->getElementsByTagName('image');
172
        $images = $this->model->getElementsByTagName('image');
177
        if ($images->length > 0) {
173
        if ($images->length > 0) {
178
            $image = $images->item(0);
174
            $image = $images->item(0);
179
            $details = array();
175
            $details = array();
180
            if ($image->hasChildNodes()) {
176
            if ($image->hasChildNodes()) {
Line 199... Line 195...
199
     * The textinput element is little used, but in the interests of
195
     * The textinput element is little used, but in the interests of
200
     * completeness we will support it.
196
     * completeness we will support it.
201
     *
197
     *
202
     * @return  array|false
198
     * @return  array|false
203
     */
199
     */
204
    protected function getTextInput()
200
    protected function getTextInput() {
205
    {
-
 
206
        $inputs = $this->model->getElementsByTagName('textinput');
201
        $inputs = $this->model->getElementsByTagName('textinput');
207
        if ($inputs->length > 0) {
202
        if ($inputs->length > 0) {
208
            $input = $inputs->item(0);
203
            $input = $inputs->item(0);
209
            $results = array();
204
            $results = array();
210
            $results['title'] = isset(
205
            $results['title'] = isset(
Line 239... Line 234...
239
     * turn in order to simulate the atom author element and will return it
234
     * turn in order to simulate the atom author element and will return it
240
     * as text.
235
     * as text.
241
     *
236
     *
242
     * @return  array|false
237
     * @return  array|false
243
     */
238
     */
244
    function getAuthor()
239
    function getAuthor() {
245
    {
-
 
246
        $options = array('creator', 'contributor', 'publisher');
240
        $options = array('creator', 'contributor', 'publisher');
247
        foreach ($options as $element) {
241
        foreach ($options as $element) {
248
            $test = $this->model->getElementsByTagName($element);
242
            $test = $this->model->getElementsByTagName($element);
249
            if ($test->length > 0) {
243
            if ($test->length > 0) {
250
                return $test->item(0)->value;
244
                return $test->item(0)->value;
Line 259... Line 253...
259
     * In RSS1 a link is a text element but in order to ensure that we resolve
253
     * In RSS1 a link is a text element but in order to ensure that we resolve
260
     * URLs properly we have a special function for them.
254
     * URLs properly we have a special function for them.
261
     *
255
     *
262
     * @return  string
256
     * @return  string
263
     */
257
     */
264
    function getLink($offset = 0, $attribute = 'href', $params = false)
258
    function getLink($offset = 0, $attribute = 'href', $params = false) {
265
    {
-
 
266
        $links = $this->model->getElementsByTagName('link');
259
        $links = $this->model->getElementsByTagName('link');
267
        if ($links->length <= $offset) {
260
        if ($links->length <= $offset) {
268
            return false;
261
            return false;
269
        }
262
        }
270
        $link = $links->item($offset);
263
        $link = $links->item($offset);
271
        return $this->addBase($link->nodeValue, $link);
264
        return $this->addBase($link->nodeValue, $link);
272
    }
265
    }
273
}
266
}
274
 
-
 
275
?>
267
?>
276
268