<li><?php echo link_to_option_selectable('Symfonyについて', '/about-symfony', $compare_function2, null, $class_on); ?> </li> <li><?php echo link_to_option_selectable('ニュース', '/news/', $compare_function2, null, $class_on); ?> </li> <li><?php echo link_to_option_selectable('イベント', '/events/', $compare_function2, null, $class_on); ?> </li> <li><?php echo link_to_option_selectable('ブログ', '/blog/', $compare_function2, null, $class_on); ?> </li> <li><?php echo link_to_option_selectable('日本語ドキュメント', '/docs', $compare_function2, null, $class_on); ?> </li> <li><?php echo link_to_option_selectable('コミュニティ', '/community', $compare_function2, null, $class_on); ?> </li> <?php include_partial('global/global_admin_menu'); ?> </ul> </div> <!-- end #navbar -->
$t->is(link_to_page('foo', '/test/foo/'), '<a href="/module/action/test/foo/">foo</a>', '第2階層スラッシュ付'); $t->is(link_to_page('foo', '/test//foo'), '<a href="/module/action/test/foo">foo</a>', '途中の連続スラッシュは自動削除'); $t->is(link_to_page('foo', '/test', array('class' => 'bar')), '<a class="bar" href="/module/action/test">foo</a>', 'link_toのオプションはそのまま有効'); // link_to_option_selectable() $t->diag('link_to_option_selectable() リンクタグ生成はlink_to_page()に依存'); $test_function_true = function ($param) { return true; }; $test_function_false = function ($param) { return false; }; $t->is(link_to_option_selectable('foo', '/test', $test_function_true, array(), array('opt' => '1'), array('opt' => '0')), '<a title="foo" opt="1" href="/module/action/test">foo</a>', '条件true時は、true時オプションが適用される'); $t->is(link_to_option_selectable('foo', '/test', $test_function_false, array(), array('opt' => '1'), array('opt' => '0')), '<a title="foo" opt="0" href="/module/action/test">foo</a>', '条件false時は、false時オプションが適用される'); $t->is(link_to_option_selectable('foo', '/test', $test_function_true, array('defopt' => 'default'), array('opt' => '1'), array('opt' => '0')), '<a defopt="default" opt="1" href="/module/action/test">foo</a>', 'デフォルトオプションとマージされる'); $t->is(link_to_option_selectable('foo', '/test', $test_function_true, array('opt' => 'default'), array('opt' => '1'), array('opt' => '0')), '<a opt="1" href="/module/action/test">foo</a>', 'デフォルトオプションとマージされる(上書き)'); $t->is(link_to_option_selectable('foo', '/test', null, array('opt' => 'default'), array('opt' => '1'), array('opt' => '0')), '<a opt="default" href="/module/action/test">foo</a>', '比較関数がない場合はデフォルトオプションのみ有効'); // renderIndexItem() $t->diag('renderIndexItem() 内部でrenderIndexItemList()を呼び出す'); $indexdata = null; $t->is(renderIndexItem($indexdata), '', 'データが空の場合は何も出力されない'); $indexdata = new stdClass(); $indexdata->type = 'testtype'; $indexdata->text = 'hogehoge'; $indexdata->id = 'testid'; $indexdata->children = array(); $t->is(renderIndexItem($indexdata), "<li><a href=\"#testid\">hogehoge</a></li>\n", '単一データ。liタグにて出力される。idデータがアンカーリンクとなる。'); $indexdata2 = new stdClass(); $indexdata2->type = 'testtype2'; $indexdata2->text = 'hogehoge2'; $indexdata2->id = 'testid2'; $indexdata2->children = array();