~fusonic/chive/1.1

« back to all changes in this revision

Viewing changes to yii/zii/widgets/CPortlet.php

  • Committer: Matthias Burtscher
  • Date: 2010-02-12 09:12:35 UTC
  • Revision ID: matthias.burtscher@fusonic.net-20100212091235-jqxrb62klx872ajc
* Updated Yii to 1.1.0
* Removed CodePress and CodeMirror
* Updated jQuery and some plugins
* Cleaned some code ...

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * CPortlet class file.
 
4
 *
 
5
 * @author Qiang Xue <qiang.xue@gmail.com>
 
6
 * @link http://www.yiiframework.com/
 
7
 * @copyright Copyright &copy; 2008-2010 Yii Software LLC
 
8
 * @license http://www.yiiframework.com/license/
 
9
 */
 
10
 
 
11
/**
 
12
 * CPortlet is the base class for portlet widgets.
 
13
 *
 
14
 * A portlet displays a fragment of content, usually in terms of a block
 
15
 * on the side bars of a Web page.
 
16
 *
 
17
 * To specify the content of the portlet, override the {@link renderContent}
 
18
 * method, or insert the content code between the {@link CController::beginWidget}
 
19
 * and {@link CController::endWidget} calls. For example,
 
20
 *
 
21
 * <pre>
 
22
 * &lt;?php $this->beginWidget('zii.widgets.CPortlet'); ?&gt;
 
23
 *     ...insert content here...
 
24
 * &lt;?php $this->endWidget(); ?&gt;
 
25
 * </pre>
 
26
 *
 
27
 * A portlet also has an optional {@link title}. One may also override {@link renderDecoration}
 
28
 * to further customize the decorative display of a portlet (e.g. adding min/max buttons).
 
29
 *
 
30
 * @author Qiang Xue <qiang.xue@gmail.com>
 
31
 * @version $Id: CPortlet.php 104 2010-01-09 20:46:58Z qiang.xue $
 
32
 * @package zii.widgets
 
33
 * @since 1.1
 
34
 */
 
35
class CPortlet extends CWidget
 
36
{
 
37
        /**
 
38
         * @var string the tag name for the portlet container tag. Defaults to 'div'.
 
39
         */
 
40
        public $tagName='div';
 
41
        /**
 
42
         * @var array the HTML attributes for the portlet container tag.
 
43
         */
 
44
        public $htmlOptions=array('class'=>'portlet');
 
45
        /**
 
46
         * @var string the title of the portlet. Defaults to null.
 
47
         * When this is not set, Decoration will not be displayed.
 
48
         * Note that the title will not be HTML-encoded when rendering.
 
49
         */
 
50
        public $title;
 
51
        /**
 
52
         * @var string the CSS class for the decoration container tag. Defaults to 'portlet-decoration'.
 
53
         */
 
54
        public $decorationCssClass='portlet-decoration';
 
55
        /**
 
56
         * @var string the CSS class for the portlet title tag. Defaults to 'portlet-title'.
 
57
         */
 
58
        public $titleCssClass='portlet-title';
 
59
        /**
 
60
         * @var string the CSS class for the content container tag. Defaults to 'portlet-content'.
 
61
         */
 
62
        public $contentCssClass='portlet-content';
 
63
 
 
64
        /**
 
65
         * Initializes the widget.
 
66
         * This renders the open tags needed by the portlet.
 
67
         * It also renders the decoration, if any.
 
68
         */
 
69
        public function init()
 
70
        {
 
71
                $this->htmlOptions['id']=$this->getId();
 
72
                echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
 
73
                $this->renderDecoration();
 
74
                echo "<div class=\"{$this->contentCssClass}\">\n";
 
75
        }
 
76
 
 
77
        /**
 
78
         * Renders the content of the portlet.
 
79
         */
 
80
        public function run()
 
81
        {
 
82
                $this->renderContent();
 
83
                echo "</div>\n";
 
84
                echo CHtml::closeTag($this->tagName);
 
85
        }
 
86
 
 
87
        /**
 
88
         * Renders the decoration for the portlet.
 
89
         * The default implementation will render the title if it is set.
 
90
         */
 
91
        protected function renderDecoration()
 
92
        {
 
93
                if($this->title!==null)
 
94
                {
 
95
                        echo "<div class=\"{$this->decorationCssClass}\">\n";
 
96
                        echo "<div class=\"{$this->titleCssClass}\">{$this->title}</div>\n";
 
97
                        echo "</div>\n";
 
98
                }
 
99
        }
 
100
 
 
101
        /**
 
102
         * Renders the content of the portlet.
 
103
         * Child classes should override this method to render the actual content.
 
104
         */
 
105
        protected function renderContent()
 
106
        {
 
107
        }
 
108
}
 
 
b'\\ No newline at end of file'