~ubuntu-branches/ubuntu/saucy/horde3/saucy

« back to all changes in this revision

Viewing changes to lib/Horde/UI/Widget.php

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2005-05-04 23:08:08 UTC
  • Revision ID: james.westby@ubuntu.com-20050504230808-p4hf3hk28o3v7wir
Tags: upstream-3.0.4
ImportĀ upstreamĀ versionĀ 3.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * The Horde_UI_Widget:: class provides base functionality for other Horde
 
4
 * UI elements.
 
5
 *
 
6
 * $Horde: framework/UI/UI/Widget.php,v 1.7.10.1 2005/01/03 12:19:19 jan Exp $
 
7
 *
 
8
 * Copyright 2003-2005 Jason M. Felice <jfelice@cronosys.com>
 
9
 *
 
10
 * See the enclosed file LICENSE for license information (LGPL).
 
11
 *
 
12
 * @version $Revision: 1.7.10.1 $
 
13
 * @since   Horde_UI 0.0.1
 
14
 * @package Horde_UI
 
15
 */
 
16
class Horde_UI_Widget {
 
17
 
 
18
    /**
 
19
     * Any variables that should be preserved in all of the widget's
 
20
     * links.
 
21
     * @var array $_preserve
 
22
     */
 
23
    var $_preserve = array();
 
24
 
 
25
    /**
 
26
     * The name of this widget.  This is used as the basename for variables
 
27
     * we access and manipulate.
 
28
     * @var string $_name
 
29
     */
 
30
    var $_name;
 
31
 
 
32
    /**
 
33
     * A reference to a Variables:: object this widget will use and
 
34
     * manipulate.
 
35
     * @var object Variables $_vars
 
36
     */
 
37
    var $_vars;
 
38
 
 
39
    /**
 
40
     * An array of name => value pairs which configure how this widget
 
41
     * behaves.
 
42
     */
 
43
    var $_config;
 
44
 
 
45
    /**
 
46
     * Construct a new UI Widget interface.
 
47
     *
 
48
     * @access public
 
49
     *
 
50
     * @param string $name      The name of the variable which will track this
 
51
     *                          UI widget's state.
 
52
     * @param Variables &$vars  A Variables:: object.
 
53
     * @param array $config     The widget's configuration.
 
54
     */
 
55
    function Horde_UI_Widget($name, &$vars, $config = array())
 
56
    {
 
57
        $this->_name = $name;
 
58
        $this->_vars = &$vars;
 
59
        $this->_config = $config;
 
60
    }
 
61
 
 
62
    /**
 
63
     * Instruct Horde_UI_Widget:: to preserve a variable.
 
64
     *
 
65
     * @access public
 
66
     *
 
67
     * @param string $var   The name of the variable to preserve.
 
68
     * @param mixed $value  The value of the variable to preserve.
 
69
     */
 
70
    function preserve($var, $value)
 
71
    {
 
72
        $this->_preserve[$var] = $value;
 
73
    }
 
74
 
 
75
    /**
 
76
     * @access private
 
77
     */
 
78
    function _addPreserved($link)
 
79
    {
 
80
        foreach ($this->_preserve as $varName => $varValue) {
 
81
            $link = Util::addParameter($link, $varName, $varValue);
 
82
        }
 
83
        return $link;
 
84
    }
 
85
 
 
86
    /**
 
87
     * Render the widget.
 
88
     *
 
89
     * @abstract
 
90
     *
 
91
     * @param optional mixed $data  The widget's state data.
 
92
     */
 
93
    function render() {}
 
94
 
 
95
}