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 29... Line 29...
29
 * @version    Release: @package_version@
29
 * @version    Release: @package_version@
30
 * @package XML_Feed_Parser
30
 * @package XML_Feed_Parser
31
 * @todo    Support for RDF:List
31
 * @todo    Support for RDF:List
32
 * @todo    Ensure xml:lang is accessible to users
32
 * @todo    Ensure xml:lang is accessible to users
33
 */
33
 */
34
class XML_Feed_Parser_RSS11 extends XML_Feed_Parser_Type
34
class XmlFeedParserRss11 extends XmlFeedParserType {
35
{
-
 
36
    /**
35
    /**
37
     * The URI of the RelaxNG schema used to (optionally) validate the feed 
36
     * The URI of the RelaxNG schema used to (optionally) validate the feed 
38
     * @var string
37
     * @var string
39
     */
38
     */
40
    protected $relax = 'rss11.rng';
39
    protected $relax = 'rss11.rng';
Line 53... Line 52...
53
 
52
 
54
    /**
53
    /**
55
     * The class used to represent individual items 
54
     * The class used to represent individual items 
56
     * @var string
55
     * @var string
57
     */
56
     */
Line 58... Line 57...
58
    protected $itemClass = 'XML_Feed_Parser_RSS1Element';
57
    protected $itemClass = 'XmlFeedParserRss11Element';
59
    
58
    
60
    /**
59
    /**
61
     * The element containing entries 
60
     * The element containing entries 
Line 116... Line 115...
116
     * Our constructor does nothing more than its parent.
115
     * Our constructor does nothing more than its parent.
117
     * 
116
     * 
118
     * @param    DOMDocument    $xml    A DOM object representing the feed
117
     * @param    DOMDocument    $xml    A DOM object representing the feed
119
     * @param    bool (optional) $string    Whether or not to validate this feed
118
     * @param    bool (optional) $string    Whether or not to validate this feed
120
     */
119
     */
121
    function __construct(DOMDocument $model, $strict = false)
120
    function __construct(DOMDocument $model, $strict = false) {
122
    {
-
 
123
        $this->model = $model;
121
        $this->model = $model;
Line 124... Line 122...
124
 
122
 
125
        if ($strict) {
123
        if ($strict) {
126
            if (! $this->relaxNGValidate()) {
124
            if (! $this->relaxNGValidate()) {
Line 145... Line 143...
145
     * with RSS1.0 since RSS1.1 does not require the rdf:about attribute for items.
143
     * with RSS1.0 since RSS1.1 does not require the rdf:about attribute for items.
146
     *
144
     *
147
     * @param    string    $id    any valid ID.
145
     * @param    string    $id    any valid ID.
148
     * @return    XML_Feed_Parser_RSS1Element
146
     * @return    XML_Feed_Parser_RSS1Element
149
     */
147
     */
150
    function getEntryById($id)
148
    function getEntryById($id) {
151
    {
-
 
152
        if (isset($this->idMappings[$id])) {
149
        if (isset($this->idMappings[$id])) {
153
            return $this->entries[$this->idMappings[$id]];
150
            return $this->entries[$this->idMappings[$id]];
154
        }
151
        }
Line 155... Line 152...
155
 
152
 
Line 165... Line 162...
165
    /**
162
    /**
166
     * Get details of the image associated with the feed.
163
     * Get details of the image associated with the feed.
167
     *
164
     *
168
     * @return  array|false an array simply containing the child elements
165
     * @return  array|false an array simply containing the child elements
169
     */
166
     */
170
    protected function getImage()
167
    protected function getImage() {
171
    {
-
 
172
        $images = $this->model->getElementsByTagName('image');
168
        $images = $this->model->getElementsByTagName('image');
173
        if ($images->length > 0) {
169
        if ($images->length > 0) {
174
            $image = $images->item(0);
170
            $image = $images->item(0);
175
            $details = array();
171
            $details = array();
176
            if ($image->hasChildNodes()) {
172
            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 238... Line 233...
238
     * turn in order to simulate the atom author element and will return it
233
     * turn in order to simulate the atom author element and will return it
239
     * as text.
234
     * as text.
240
     *
235
     *
241
     * @return  array|false
236
     * @return  array|false
242
     */
237
     */
243
    function getAuthor()
238
    function getAuthor() {
244
    {
-
 
245
        $options = array('creator', 'contributor', 'publisher');
239
        $options = array('creator', 'contributor', 'publisher');
246
        foreach ($options as $element) {
240
        foreach ($options as $element) {
247
            $test = $this->model->getElementsByTagName($element);
241
            $test = $this->model->getElementsByTagName($element);
248
            if ($test->length > 0) {
242
            if ($test->length > 0) {
249
                return $test->item(0)->value;
243
                return $test->item(0)->value;
Line 258... Line 252...
258
     * In RSS1 a link is a text element but in order to ensure that we resolve
252
     * In RSS1 a link is a text element but in order to ensure that we resolve
259
     * URLs properly we have a special function for them.
253
     * URLs properly we have a special function for them.
260
     *
254
     *
261
     * @return  string
255
     * @return  string
262
     */
256
     */
263
    function getLink($offset = 0, $attribute = 'href', $params = false)
257
    function getLink($offset = 0, $attribute = 'href', $params = false) {
264
    {
-
 
265
        $links = $this->model->getElementsByTagName('link');
258
        $links = $this->model->getElementsByTagName('link');
266
        if ($links->length <= $offset) {
259
        if ($links->length <= $offset) {
267
            return false;
260
            return false;
268
        }
261
        }
269
        $link = $links->item($offset);
262
        $link = $links->item($offset);
270
        return $this->addBase($link->nodeValue, $link);
263
        return $this->addBase($link->nodeValue, $link);
271
    }
264
    }
272
}
265
}
273
 
-
 
274
?>
266
?>
275
267