Lighter tab html, support casting to string

This commit is contained in:
Thomas Gelf 2014-02-18 17:49:12 +00:00
parent 73fdcdef47
commit 34316ccbca
2 changed files with 24 additions and 15 deletions
library/Icinga/Web/Widget

View File

@ -240,7 +240,7 @@ class Tab implements Widget
}
}
$tab = '<a' . $tagParams .' href="' . $this->url->getAbsoluteUrl()
. '" data-icinga-target="self">' . $caption . '</a>';
. '">' . $caption . '</a>';
} else {
$tab = $caption;
}

View File

@ -29,10 +29,11 @@
namespace Icinga\Web\Widget;
use \Icinga\Exception\ProgrammingError;
use \Icinga\Web\Widget\Tabextension\Tabextension;
use \Zend_View_Abstract;
use \Countable;
use Icinga\Exception\ProgrammingError;
use Icinga\Web\Widget\Tabextension\Tabextension;
use Icinga\Application\Icinga;
use Zend_View_Abstract;
use Countable;
/**
* Navigation tab widget
@ -45,9 +46,9 @@ class Tabs implements Countable, Widget
* @var string
*/
private $baseTpl = <<< 'EOT'
<ul class="nav nav-tabs">
{TABS}
{DROPDOWN}
<ul class="tabs">
{TABS}
{DROPDOWN}
</ul>
EOT;
@ -57,13 +58,11 @@ EOT;
* @var string
*/
private $dropdownTpl = <<< 'EOT'
<li class="dropdown pull-right ">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" style="margin-top:3px">
<i style="" class="caret"></i> Actions
</a>
<ul class="dropdown-menu">
{TABS}
</ul>
<li class="dropdown">
<a href="#" class="dropdown-toggle"></a>
<ul class="dropdown-menu">
{TABS}
</ul>
</li>
EOT;
@ -285,6 +284,16 @@ EOT;
return $html;
}
public function __toString()
{
try {
$html = $this->render(Icinga::app()->getViewRenderer()->view);
} catch (Exception $e) {
return htmlspecialchars($e->getMessage());
}
return $html;
}
/**
* Return the number of tabs
*