~ubuntu-branches/ubuntu/vivid/php-horde-icalendar/vivid-proposed

« back to all changes in this revision

Viewing changes to Horde_Icalendar-2.0.8/lib/Horde/Icalendar/Vtodo.php

  • Committer: Package Import Robot
  • Author(s): Mathieu Parent
  • Date: 2014-06-05 20:31:26 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20140605203126-geamf8wv7cvfrruh
Tags: 2.0.9-1
New upstream version 2.0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/**
3
 
 * Class representing vTodos.
4
 
 *
5
 
 * Copyright 2003-2014 Horde LLC (http://www.horde.org/)
6
 
 *
7
 
 * See the enclosed file COPYING for license information (LGPL). If you
8
 
 * did not receive this file, see http://www.horde.org/licenses/lgpl21.
9
 
 *
10
 
 * @author   Mike Cochrane <mike@graftonhall.co.nz>
11
 
 * @category Horde
12
 
 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
13
 
 * @package  Icalendar
14
 
 */
15
 
class Horde_Icalendar_Vtodo extends Horde_Icalendar
16
 
{
17
 
    /**
18
 
     * The component type of this class.
19
 
     *
20
 
     * @var string
21
 
     */
22
 
    public $type = 'vTodo';
23
 
 
24
 
    /**
25
 
     * TODO
26
 
     *
27
 
     * @return TODO
28
 
     */
29
 
    public function exportvCalendar()
30
 
    {
31
 
        return $this->_exportvData('VTODO');
32
 
    }
33
 
 
34
 
    /**
35
 
     * Convert this todo to an array of attributes.
36
 
     *
37
 
     * @return array  Array containing the details of the todo in a hash
38
 
     *                as used by Horde applications.
39
 
     */
40
 
    public function toArray()
41
 
    {
42
 
        $todo = array();
43
 
 
44
 
        try {
45
 
            $name = $this->getAttribute('SUMMARY');
46
 
            if (!is_array($name)) {
47
 
                $todo['name'] = $name;
48
 
            }
49
 
        } catch (Horde_Icalendar_Exception $e) {}
50
 
 
51
 
        try {
52
 
            $desc = $this->getAttribute('DESCRIPTION');
53
 
            if (!is_array($desc)) {
54
 
                $todo['desc'] = $desc;
55
 
            }
56
 
        } catch (Horde_Icalendar_Exception $e) {}
57
 
 
58
 
        try {
59
 
            $priority = $this->getAttribute('PRIORITY');
60
 
            if (!is_array($priority)) {
61
 
                $todo['priority'] = $priority;
62
 
            }
63
 
        } catch (Horde_Icalendar_Exception $e) {}
64
 
 
65
 
        try {
66
 
            $due = $this->getAttribute('DTSTAMP');
67
 
            if (!is_array($due)) {
68
 
                $todo['due'] = $due;
69
 
            }
70
 
        } catch (Horde_Icalendar_Exception $e) {}
71
 
 
72
 
        return $todo;
73
 
    }
74
 
 
75
 
    /**
76
 
     * Set the attributes for this todo item from an array.
77
 
     *
78
 
     * @param array $todo  Array containing the details of the todo in
79
 
     *                     the same format that toArray() exports.
80
 
     */
81
 
    public function fromArray($todo)
82
 
    {
83
 
        if (isset($todo['name'])) {
84
 
            $this->setAttribute('SUMMARY', $todo['name']);
85
 
        }
86
 
        if (isset($todo['desc'])) {
87
 
            $this->setAttribute('DESCRIPTION', $todo['desc']);
88
 
        }
89
 
 
90
 
        if (isset($todo['priority'])) {
91
 
            $this->setAttribute('PRIORITY', $todo['priority']);
92
 
        }
93
 
 
94
 
        if (isset($todo['due'])) {
95
 
            $this->setAttribute('DTSTAMP', $todo['due']);
96
 
        }
97
 
    }
98
 
 
99
 
}