| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <title>Type HowTo - Custom list view</title> |
| 5 | <link rel="stylesheet" type="text/css" href="style/layout.css"> |
| 6 | <link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"> |
| 7 | </head> |
| 8 | <body> |
| 9 | <div style="text-align: center;"> |
| 10 | <h1>Type HowTo - Custom list view<br> |
| 11 | </h1> |
| 12 | <br> |
| 13 | <br> |
| 14 | <div style="text-align: left;"><br> |
| 15 | <h2>1. Default list attributes<br> |
| 16 | </h2> |
| 17 | Here you can specify what attributes are shown as default in the list |
| 18 | view.<br> |
| 19 | <br> |
| 20 | The <span style="font-style: italic;">default attributes</span> are |
| 21 | specified |
| 22 | with <span style="font-weight: bold;">getDefaultListAttributes()</span><span |
| 23 | style="font-weight: bold;"></span>.<br> |
| 24 | <br> |
| 25 | <span style="font-weight: bold; text-decoration: underline;">Example:</span><br |
| 26 | style="font-weight: bold; text-decoration: underline;"> |
| 27 | <br> |
| 28 | Our <span style="font-style: italic;">smbDomain</span> type will show |
| 29 | the attributes "#sambaDomainName;#sambaSID" by default.<br> |
| 30 | <br> |
| 31 | <div class="mod-code"> |
| 32 | * Returns the default attribute list for this |
| 33 | account type.<br> |
| 34 | *<br> |
| 35 | * @return string attribute list<br> |
| 36 | */<br> |
| 37 | <span style="font-weight: bold;">function</span> <span |
| 38 | style="color: rgb(255, 0, 0);">getDefaultListAttributes()</span> {<br> |
| 39 | return |
| 40 | "#sambaDomainName;#sambaSID";<br> |
| 41 | }<br> |
| 42 | </div> |
| 43 | <br> |
| 44 | <br> |
| 45 | <h2>2. Pretranslated attribute descriptions<br> |
| 46 | </h2> |
| 47 | You can provide translated descriptions for common attributes. This way |
| 48 | the user only specifies the attributes and LAM will show a description |
| 49 | for each language.<br> |
| 50 | <br> |
| 51 | The descriptions are specified with <span style="font-weight: bold;">getListAttributeDescriptions()</span><span |
| 52 | style="font-weight: bold;"></span>.<br> |
| 53 | <br> |
| 54 | <span style="font-weight: bold; text-decoration: underline;">Example:</span><br |
| 55 | style="font-weight: bold; text-decoration: underline;"> |
| 56 | <br> |
| 57 | Our <span style="font-style: italic;">smbDomain</span> type has |
| 58 | descriptions for sambaSID and sambaDomainName.<br> |
| 59 | <br> |
| 60 | <div class="mod-code"> |
| 61 | * Returns a list of attributes which have a |
| 62 | translated description.<br> |
| 63 | * This is used for the head row in the list view.<br> |
| 64 | *<br> |
| 65 | * @return array list of descriptions<br> |
| 66 | */<br> |
| 67 | <span style="font-weight: bold;">function</span> <span |
| 68 | style="color: rgb(255, 0, 0);">getListAttributeDescriptions()</span> {<br> |
| 69 | return array(<br> |
| 70 | "sambaSID" |
| 71 | => _("Domain SID"),<br> |
| 72 | |
| 73 | "sambaDomainName" => _("Domain name")<br> |
| 74 | );<br> |
| 75 | }<br> |
| 76 | </div> |
| 77 | <br> |
| 78 | <br> |
| 79 | <br> |
| 80 | <h2>3. Specifying a custom list view</h2> |
| 81 | The default list view has only very generic labels for the buttons and |
| 82 | navigation bar. So you should at least provide some new labels which |
| 83 | fit to your type.<br> |
| 84 | <br> |
| 85 | The class name of your list view is specified with <span |
| 86 | style="font-weight: bold;">getListClassName()</span><span |
| 87 | style="font-weight: bold;"></span>.<br> |
| 88 | <br> |
| 89 | <span style="font-weight: bold; text-decoration: underline;">Example:</span><br |
| 90 | style="font-weight: bold; text-decoration: underline;"> |
| 91 | <br> |
| 92 | Our <span style="font-style: italic;">smbDomain</span> type sets the |
| 93 | list view class to <span style="font-style: italic;">lamSmbDomainList</span>. |
| 94 | The list class is defined in the same file as your type class |
| 95 | (smbDomain.inc in this case).<br> |
| 96 | The labels are set in the constructor. Do not forget to call the parent |
| 97 | constructor first.<br> |
| 98 | <br> |
| 99 | If you want to change more than just the labels, take a look at <span |
| 100 | style="font-weight: bold;">lib/lists.inc</span> and <span |
| 101 | style="font-weight: bold;">lib/types/user.inc</span>. When a list is |
| 102 | displayed then the <span style="font-weight: bold;">showPage()</span> |
| 103 | function is called. You can overwrite this function to display a |
| 104 | completely new list or just one of the other functions.<br> |
| 105 | <br> |
| 106 | <div class="mod-code"> |
| 107 | * Returns the class name for the list object.<br> |
| 108 | *<br> |
| 109 | * @return string class name<br> |
| 110 | */<br> |
| 111 | function <span style="color: rgb(255, 0, 0);">getListClassName()</span> |
| 112 | {<br> |
| 113 | return "lamSmbDomainList";<br> |
| 114 | }<br> |
| 115 | <br> |
| 116 | <br> |
| 117 | /**<br> |
| 118 | * Generates the list view.<br> |
| 119 | *<br> |
| 120 | * @package lists<br> |
| 121 | * @author Roland Gruber<br> |
| 122 | * <br> |
| 123 | */<br> |
| 124 | class <span style="color: rgb(255, 0, 0);">lamSmbDomainList</span> |
| 125 | extends <span style="font-weight: bold;">lamList</span> {<br> |
| 126 | <br> |
| 127 | /**<br> |
| 128 | * Constructor<br> |
| 129 | *<br> |
| 130 | * @param string $type account type<br> |
| 131 | * @return lamList list object<br> |
| 132 | */<br> |
| 133 | function lamSmbDomainList($type) {<br> |
| 134 | parent::lamList($type);<br> |
| 135 | $this->labels = array(<br> |
| 136 | 'nav' => |
| 137 | _("%s domain(s) found"),<br> |
| 138 | |
| 139 | 'error_noneFound' => _("No domains found!"),<br> |
| 140 | 'newEntry' |
| 141 | => _("New domain"),<br> |
| 142 | 'deleteEntry' |
| 143 | => _("Delete domain"),<br> |
| 144 | 'createPDF' |
| 145 | => _("Create PDF for selected domain(s)"),<br> |
| 146 | 'createPDFAll' |
| 147 | => _("Create PDF for all domains"));<br> |
| 148 | }<br> |
| 149 | <br> |
| 150 | }<br> |
| 151 | </div> |
| 152 | <br> |
| 153 | <br> |
| 154 | <br> |
| 155 | <br> |
| 156 | </div> |
| 157 | </div> |
| 158 | </body> |
| 159 | </html> |