예제 #1
0
파일: interface.php 프로젝트: xtha/salt
function renderIndex()
{
    global $indexlayout;
    ?>
<table border=0 cellpadding=0 cellspacing=0 width='100%'>
	<tr>
		<td>
			<div style='text-align: center; margin: 10px; '>
			<table width='100%' cellspacing=0 cellpadding=20 class=mainmenu border=0>
<?php 
    foreach ($indexlayout as $row) {
        echo '<tr>';
        foreach ($row as $column) {
            if ($column === NULL) {
                echo '<td>&nbsp;</td>';
            } else {
                renderIndexItem($column);
            }
        }
        echo '</tr>';
    }
    ?>
			</table>
			</div>
		</td>
	</tr>
</table>
<?php 
}
예제 #2
0
$indexdata2 = new stdClass();
$indexdata2->type = 'testtype2';
$indexdata2->text = 'hogehoge2';
$indexdata2->id = 'testid2';
$indexdata2->children = array();
$indexdata3 = new stdClass();
$indexdata3->type = 'testtype3';
$indexdata3->text = 'hogehoge3';
$indexdata3->id = 'testid3';
$indexdata3->children = array($indexdata2);
$indexdata = new stdClass();
$indexdata->type = 'testtype';
$indexdata->text = 'hogehoge';
$indexdata->id = 'testid';
$indexdata->children = array($indexdata2, $indexdata3);
$t->is(renderIndexItem($indexdata), "<li><a href=\"#testid\">hogehoge</a>\n<ul>\n<li><a href=\"#testid2\">hogehoge2</a></li>\n<li><a href=\"#testid3\">hogehoge3</a>\n<ul>\n<li><a href=\"#testid2\">hogehoge2</a></li>\n</ul>\n</li>\n</ul>\n</li>\n", '階層データ。第3階層まで。');
// renderIndexItemList()
$t->diag('renderIndexItemList() 内部でrenderIndexItem()を呼び出す');
$t->is(renderIndexItemList(array()), "", '空データの場合は何も出力されない。');
$indexdata = new stdClass();
$indexdata->type = 'testtype';
$indexdata->text = 'hogehoge';
$indexdata->id = 'testid';
$indexdata->children = array();
$t->is(renderIndexItemList(array($indexdata)), "\n<ul>\n<li><a href=\"#testid\">hogehoge</a></li>\n</ul>\n", '単一データ');
$indexdata2 = new stdClass();
$indexdata2->type = 'testtype2';
$indexdata2->text = 'hogehoge2';
$indexdata2->id = 'testid2';
$indexdata2->children = array();
$indexdata3 = new stdClass();
예제 #3
0
/**
 * renderIndexItemList()
 * 階層付の索引を出力する。
 * データ構造は以下のようなオブジェクトの配列
 * array(
 *   StdClass (
 *     'type'->'h1',
 *     'text'->'hogehoge',
 *     'id'->'hogehoge',
 *     'children'->array(
 *       StdClass (
 *         'type'->'h2',
 *         'text'->'foobar',
 *         'id'->'foobar',
 *         'children'->array(
 *         )
 *       )
 *     )
 *   )
 * )
 *
 * @param mixed $list
 * @return string
 */
function renderIndexItemList($list)
{
    $ret = '';
    if (count($list) < 1) {
        return '';
    }
    $ret .= "\n<ul>\n";
    foreach ($list as $element) {
        $ret .= renderIndexItem($element);
    }
    $ret .= "</ul>\n";
    return $ret;
}