📄 reporttemplate.tmpl
字号:
#encoding UTF-8## $Id: ReportTemplate.tmpl 4148 2007-08-21 08:47:53Z jodal $## ## Copyright 2003-2005 Norwegian University of Science and Technology#### This file is part of Network Administration Visualized (NAV)#### NAV is free software; you can redistribute it and/or modify## it under the terms of the GNU General Public License as published by## the Free Software Foundation; either version 2 of the License, or## (at your option) any later version.#### NAV is distributed in the hope that it will be useful,## but WITHOUT ANY WARRANTY; without even the implied warranty of## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the## GNU General Public License for more details.#### You should have received a copy of the GNU General Public License## along with NAV; if not, write to the Free Software## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA###### Author: Magnar Sveen <magnars@idi.ntnu.no>###### Extends the MainTemplate for header-information, nav-logo and navigation-bar.## Builds html for the Report Generator with data in this form:#### $report## +-- header :: name of the report## +-- navigator## | +-- previous :: uri to previous page (optional)## | +-- view :: info about current page## | +-- next :: uri to next page (optional)## +-- table## +-- header## | +-- cells :: array of cells## | +-- uri :: link (optional)## | +-- text :: name of the column## | +-- explanation :: description of data in the column (optional)## +-- rows## | +-- cells :: array of cells## | +-- uri :: link (optional)## | +-- text :: the bread and butter of the table## +-- footer## +-- cells :: array of cells## +-- sum :: sum of values in the column (optional)#### The template uses images in $imagefolder/ragen/, where $imagefolder## is inherited from MainTemplate and defaults to "/images".#### This template can easily be used for other tables, as long as the indata is## structured in the same way.#### To illustrate:#### import ReportTemplate from foo.bar.ReportTemplate## page = ReportTemplate()## page.report = fillReportWithData()###extends MainTemplate#block additionalCSS$default_table_CSS()#end block additionalCSS#block additionalJavaScript<script type="text/javascript" src="/js/table.js"></script>#end block additionalJavaScript#block content<h2>Report</h2>#if $search>0<h3>Advanced Search</h3><p><a href="${old_uri}adv=">Close Search</a></p><div class="infobox" style="float: right"><h4>Operator usage</h4><ul> <li>= - "equals", enter null for empty string</li> <li>~ - case insensitive search, use * as wildcard</li> <li>[:] - "between", takes two colon-separated arguments</li> <li>(,,) - "is one of", takes a comma-separated list of any size as argument. </li></ul><p><, >, <= and >= needs no explanation.</p><p>All these operators may be negated by clicking the "not" checkbox.</p></div><form action="" method="get"><input type="hidden" name="adv" value="1"/><table class="vertitable">#set $counter = 0#for $a in $report.form<tr> <th><label for="adv${counter}">$a.title</label></th> <td><input type="checkbox" name="not_${a.raw}" id="not_adv${counter}"#slurp#if $neg.has_key($a.raw) checked="1"#slurp#end if> </td> <td><label for="not_adv${counter}">not</label></td> <td>#if $operator.has_key($a.raw)$selectoptiondraw("op_"+$a.raw, $operatorlist, $operators,$operator[$a.raw], $descriptions)#else$selectoptiondraw("op_"+$a.raw, $operatorlist, $operators,"", $descriptions)#end if </td> <td> <input type="text" name="$a.raw" id="adv${counter}"#slurp#if $contents.has_key($a.raw) value="$contents[$a.raw]"#slurp#end if> </td></tr>#set $counter += 1#end for<tr> <th></th> <td colspan="4"> <button type="submit" name="r4g3n53nd">Search</button> </td></tr></table></form>#else<p><a href="${old_uri}adv=1">Advanced Search</a></p>#end if## ----------------------------------------------------------------------- REPORT ---- ###if $report#set $rowcount = len($report.table.rows) + 1#set $columncount = len($report.table.header.cells) <table class="listtable reporttable">## --- TITLE ROW ---- ## <caption>#if $report.navigator.previous <span class="previous"> <a title="previous page" href="$report.navigator.previous"><<</a> </span>#end if $report.header#if $report.navigator.next <span class="next"> <a title="next page" href="$report.navigator.next">>></a> </span>#end if <br /><span class="subtitle">$report.navigator.view</span> </caption>## --- HEADER ROW ---- ## <thead> <tr>#for $cell in $report.table.header.cells#if $cell.uri <th><a class="navbar" href="$cell.uri" title="$cell.explanation">$cell.text</a></th>#else <th><a class="navbar" title="$cell.explanation">$cell.text</a></th>#end if#end for </tr> </thead>## --- DATA ROWS ---- ## <tbody>#for $row in $report.table.rows <tr class="$rowcycler">#for $cell in $row.cells <td class="$cellcycler">#if $cell.uri <a href="$cell.uri">$cell.text</a>#else $cell.text#end if </td>#end for </tr>#end for </tbody>## --- FOOTER ---- ###if $report.table.footer#set $cols = len($report.table.header.cells) <tr class="tablesum">#for $cell in $report.table.footer.cells <th>$cell.sum</th>#end for </tr>#end if## --- FOOTER NAVIGATION ---- ## <tbody class="footer"> <tr> <th colspan="0">#if $report.navigator.previous <span class="previous"> <a title="previous page" href="$report.navigator.previous"><<</a> </span>#end if <span>$report.navigator.view</span>#if $report.navigator.next <span class="next"> <a title="next page" href="$report.navigator.next">>></a> </span>#end if </th> </tr> </tbody></table>#else<p class="error">No results found!</p>#end if#end block content#def selectoptiondraw($name, $elementlist, $elementdict, $selected="", $descriptiondict=None)<select name="$name">#for $element in $elementlist <option value="$element"#slurp#if $element == $selected selected="1"#slurp#end if#if $descriptiondict.has_key($element) title="$descriptiondict[$element]"#slurp#end if>#slurp$elementdict[$element]#slurp</option>#end for</select>#end def
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -