From 19ae300aca500ec6ef4076e7e67b68be45165f3c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 17 Jan 2019 13:21:46 +0100 Subject: [PATCH] lib: Remove all traces of `Icinga\Module\Businessprocess\Html` refs #130 --- application/controllers/NodeController.php | 2 +- application/controllers/ProcessController.php | 164 ++++++++--------- library/Businessprocess/HostNode.php | 4 +- library/Businessprocess/ImportedNode.php | 20 +- library/Businessprocess/MonitoredNode.php | 6 +- library/Businessprocess/Node.php | 7 +- .../Businessprocess/Renderer/Breadcrumb.php | 30 +-- library/Businessprocess/Renderer/Renderer.php | 45 +++-- .../Businessprocess/Renderer/TileRenderer.php | 56 +++--- .../Renderer/TileRenderer/NodeTile.php | 174 +++++++++--------- .../Businessprocess/Renderer/TreeRenderer.php | 127 +++++++------ .../Businessprocess/Storage/ConfigDiff.php | 4 +- .../Web/Component/ActionBar.php | 4 +- .../Web/Component/BpDashboardTile.php | 56 +++--- .../Businessprocess/Web/Component/Content.php | 6 +- .../Web/Component/Controls.php | 6 +- .../Web/Component/Dashboard.php | 43 +++-- .../Web/Component/DashboardAction.php | 27 ++- .../Component/RenderedProcessActionBar.php | 132 ++++++------- .../Businessprocess/Web/Component/Tabs.php | 4 +- library/Businessprocess/Web/Controller.php | 12 +- .../Web/Form/QuickBaseForm.php | 4 +- 22 files changed, 454 insertions(+), 479 deletions(-) diff --git a/application/controllers/NodeController.php b/application/controllers/NodeController.php index ff9b972..6445db0 100644 --- a/application/controllers/NodeController.php +++ b/application/controllers/NodeController.php @@ -53,7 +53,7 @@ class NodeController extends Controller )->setPath($path); $bc = Breadcrumb::create($renderer); - $bc->attributes()->set('data-base-target', '_next'); + $bc->getAttributes()->set('data-base-target', '_next'); $content->add($bc); } } diff --git a/application/controllers/ProcessController.php b/application/controllers/ProcessController.php index 360c0a3..bdabee5 100644 --- a/application/controllers/ProcessController.php +++ b/application/controllers/ProcessController.php @@ -5,11 +5,6 @@ namespace Icinga\Module\Businessprocess\Controllers; use Icinga\Date\DateFormatter; use Icinga\Module\Businessprocess\BpConfig; use Icinga\Module\Businessprocess\BpNode; -use Icinga\Module\Businessprocess\Html\Element; -use Icinga\Module\Businessprocess\Html\HtmlString; -use Icinga\Module\Businessprocess\Html\HtmlTag; -use Icinga\Module\Businessprocess\Html\Icon; -use Icinga\Module\Businessprocess\Html\Link; use Icinga\Module\Businessprocess\Node; use Icinga\Module\Businessprocess\Renderer\Breadcrumb; use Icinga\Module\Businessprocess\Renderer\Renderer; @@ -23,11 +18,13 @@ use Icinga\Module\Businessprocess\Web\Component\ActionBar; use Icinga\Module\Businessprocess\Web\Component\RenderedProcessActionBar; use Icinga\Module\Businessprocess\Web\Component\Tabs; use Icinga\Module\Businessprocess\Web\Controller; -use Icinga\Module\Businessprocess\Web\Url; use Icinga\Util\Json; use Icinga\Web\Notification; +use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; use Icinga\Web\Widget\Tabextension\OutputFormat; +use ipl\Html\Html; +use ipl\Html\HtmlString; class ProcessController extends Controller { @@ -45,7 +42,7 @@ class ProcessController extends Controller $this->setTitle($title); $this->controls() ->add($this->tabsForCreate()->activate('create')) - ->add(HtmlTag::h1($title)); + ->add(Html::tag('h1', null, $title)); $this->content()->add( $this->loadForm('bpConfig') @@ -66,7 +63,7 @@ class ProcessController extends Controller $this->setTitle($title); $this->controls() ->add($this->tabsForCreate()->activate('upload')) - ->add(HtmlTag::h1($title)); + ->add(Html::tag('h1', null, $title)); $this->content()->add( $this->loadForm('BpUpload') @@ -113,9 +110,9 @@ class ProcessController extends Controller } $bp->addError(sprintf('There are %d missing nodes: %s', $count, implode(', ', $missing))); } - $this->content()->addContent($this->showHints($bp)); - $this->content()->addContent($this->showWarnings($bp)); - $this->content()->addContent($this->showErrors($bp)); + $this->content()->add($this->showHints($bp)); + $this->content()->add($this->showWarnings($bp)); + $this->content()->add($this->showErrors($bp)); $this->content()->add($renderer); $this->loadActionForm($bp, $node); $this->setDynamicAutorefresh(); @@ -126,27 +123,23 @@ class ProcessController extends Controller $controls = $this->controls(); if ($this->showFullscreen) { - $controls->attributes()->add('class', 'want-fullscreen'); - $controls->add( - Link::create( - Icon::create('resize-small'), - $this->url()->without('showFullscreen')->without('view'), - null, - array( - 'style' => 'float: right', - 'title' => $this->translate( - 'Leave full screen and switch back to normal mode' - ) - ) - ) - ); + $controls->getAttributes()->add('class', 'want-fullscreen'); + $controls->add(Html::tag( + 'a', + [ + 'href' => $this->url()->without('showFullscreen')->without('view'), + 'title' => $this->translate('Leave full screen and switch back to normal mode'), + 'style' => 'float: right' + ], + Html::tag('i', ['class' => 'icon icon-resize-small']) + )); } if (! ($this->showFullscreen || $this->view->compact)) { $controls->add($this->getProcessTabs($bp, $renderer)); } if (! $this->view->compact) { - $controls->add(Element::create('h1')->setContent($this->view->title)); + $controls->add(Html::tag('h1')->setContent($this->view->title)); } $controls->add(Breadcrumb::create($renderer)); if (! $this->showFullscreen && ! $this->view->compact) { @@ -259,7 +252,7 @@ class ProcessController extends Controller } if ($form) { - $this->content()->prependContent(HtmlString::create((string) $form)); + $this->content()->prepend(HtmlString::create((string) $form)); } } @@ -283,9 +276,9 @@ class ProcessController extends Controller protected function showWarnings(BpConfig $bp) { if ($bp->hasWarnings()) { - $ul = Element::create('ul', array('class' => 'warning')); + $ul = Html::tag('ul', array('class' => 'warning')); foreach ($bp->getWarnings() as $warning) { - $ul->createElement('li')->addContent($warning); + $ul->add(Html::tag('li')->setContent($warning)); } return $ul; @@ -297,9 +290,9 @@ class ProcessController extends Controller protected function showErrors(BpConfig $bp) { if ($bp->hasWarnings()) { - $ul = Element::create('ul', array('class' => 'error')); + $ul = Html::tag('ul', array('class' => 'error')); foreach ($bp->getErrors() as $msg) { - $ul->createElement('li')->addContent($msg); + $ul->add(Html::tag('li')->setContent($msg)); } return $ul; @@ -310,40 +303,41 @@ class ProcessController extends Controller protected function showHints(BpConfig $bp) { - $ul = Element::create('ul', array('class' => 'error')); + $ul = Html::tag('ul', ['class' => 'error']); foreach ($bp->getErrors() as $error) { - $ul->createElement('li')->addContent($error); + $ul->add(Html::tag('li')->setContent($error)); } if ($bp->hasChanges()) { - $ul->createElement('li')->setSeparator(' ')->addContent(sprintf( + $li = Html::tag('li')->setSeparator(' '); + $li->add(sprintf( $this->translate('This process has %d pending change(s).'), $bp->countChanges() - ))->addContent( - Link::create( - $this->translate('Store'), - 'businessprocess/process/config', - array('config' => $bp->getName()) - ) - )->addContent( - Link::create( - $this->translate('Dismiss'), - $this->url()->with('dismissChanges', true), - null - ) - ); + ))->add(Html::tag( + 'a', + ['href' => Url::fromPath('businessprocess/process/config', ['config' => $bp->getName()])], + $this->translate('Store') + ))->add(Html::tag( + 'a', + ['href' => $this->url()->with('dismissChanges', true)], + $this->translate('Dismiss') + )); + $ul->add($li); } if ($bp->hasSimulations()) { - $ul->createElement('li')->setSeparator(' ')->addContent(sprintf( + $li = Html::tag('li')->setSeparator(' '); + $li->add(sprintf( $this->translate('This process shows %d simulated state(s).'), $bp->countSimulations() - ))->addContent(Link::create( - $this->translate('Dismiss'), - $this->url()->with('dismissSimulations', true) + ))->add(Html::tag( + 'a', + ['href' => $this->url()->with('dismissSimulations', true)], + $this->translate('Dismiss') )); + $ul->add($li); } - if ($ul->hasContent()) { + if (! $ul->isEmpty()) { return $ul; } else { return null; @@ -380,7 +374,7 @@ class ProcessController extends Controller $this->setTitle($title); $this->controls() ->add($this->tabsForConfig($bp)->activate('source')) - ->add(HtmlTag::h1($title)) + ->add(Html::tag('h1', null, $title)) ->add($this->createConfigActionBar($bp, $showDiff)); $this->setViewScript('process/source'); @@ -424,7 +418,7 @@ class ProcessController extends Controller $this->setTitle($title); $this->controls() ->add($this->tabsForConfig($bp)->activate('config')) - ->add(HtmlTag::h1($title)) + ->add(Html::tag('h1', null, $title)) ->add($this->createConfigActionBar($bp)); $url = Url::fromPath( @@ -446,48 +440,42 @@ class ProcessController extends Controller if ($showDiff) { $params = array('config' => $config->getName()); - $actionBar->add( - Link::create( - $this->translate('Source'), - 'businessprocess/process/source', - $params, - array( - 'class' => 'icon-doc-text', - 'title' => $this->translate('Show source code'), - ) - ) - ); + $actionBar->add(Html::tag( + 'a', + [ + 'href' => Url::fromPath('businessprocess/process/source', $params), + 'class' => 'icon-doc-text', + 'title' => $this->translate('Show source code') + ], + $this->translate('Source') + )); } else { $params = array( 'config' => $config->getName(), 'showDiff' => true ); - $actionBar->add( - Link::create( - $this->translate('Diff'), - 'businessprocess/process/source', - $params, - array( - 'class' => 'icon-flapping', - 'title' => $this->translate('Highlight changes'), - ) - ) - ); + $actionBar->add(Html::tag( + 'a', + [ + 'href' => Url::fromPath('businessprocess/process/source', $params), + 'class' => 'icon-flapping', + 'title' => $this->translate('Highlight changes') + ], + $this->translate('Diff') + )); } - $actionBar->add( - Link::create( - $this->translate('Download'), - 'businessprocess/process/download', - array('config' => $config->getName()), - array( - 'target' => '_blank', - 'class' => 'icon-download', - 'title' => $this->translate('Download process configuration') - ) - ) - ); + $actionBar->add(Html::tag( + 'a', + [ + 'href' => Url::fromPath('businessprocess/process/download', ['config' => $config->getName()]), + 'class' => 'icon-download', + 'target' => '_blank', + 'title' => $this->translate('Download process configuration') + ], + $this->translate('Download') + )); return $actionBar; } diff --git a/library/Businessprocess/HostNode.php b/library/Businessprocess/HostNode.php index 2e273c3..d700a5b 100644 --- a/library/Businessprocess/HostNode.php +++ b/library/Businessprocess/HostNode.php @@ -2,8 +2,8 @@ namespace Icinga\Module\Businessprocess; -use Icinga\Module\Businessprocess\Html\Link; use Icinga\Module\Businessprocess\Web\Url; +use ipl\Html\Html; class HostNode extends MonitoredNode { @@ -69,6 +69,6 @@ class HostNode extends MonitoredNode public function getLink() { - return Link::create($this->hostname, $this->getUrl()); + return Html::tag('a', ['href' => $this->getUrl()], $this->hostname); } } diff --git a/library/Businessprocess/ImportedNode.php b/library/Businessprocess/ImportedNode.php index d7eeee3..00c65f7 100644 --- a/library/Businessprocess/ImportedNode.php +++ b/library/Businessprocess/ImportedNode.php @@ -3,11 +3,11 @@ namespace Icinga\Module\Businessprocess; use Icinga\Application\Config; -use Icinga\Module\Businessprocess\Html\Link; use Icinga\Module\Businessprocess\State\MonitoringState; use Icinga\Module\Businessprocess\Storage\LegacyStorage; -use Icinga\Module\Businessprocess\Web\Url; use Exception; +use Icinga\Web\Url; +use ipl\Html\Html; class ImportedNode extends Node { @@ -226,13 +226,15 @@ class ImportedNode extends Node */ public function getLink() { - return Link::create( - $this->getAlias(), - 'businessprocess/process/show', - array( - 'config' => $this->configName, - 'node' => $this->nodeName - ) + return Html::tag( + 'a', + [ + 'href' => Url::fromPath('businessprocess/process/show', [ + 'config' => $this->configName, + 'node' => $this->nodeName + ]) + ], + $this->getAlias() ); } } diff --git a/library/Businessprocess/MonitoredNode.php b/library/Businessprocess/MonitoredNode.php index 68e4866..3c4167d 100644 --- a/library/Businessprocess/MonitoredNode.php +++ b/library/Businessprocess/MonitoredNode.php @@ -2,7 +2,7 @@ namespace Icinga\Module\Businessprocess; -use Icinga\Module\Businessprocess\Html\Link; +use ipl\Html\Html; abstract class MonitoredNode extends Node { @@ -11,9 +11,9 @@ abstract class MonitoredNode extends Node public function getLink() { if ($this->isMissing()) { - return Link::create($this->getAlias(), '#'); + return Html::tag('a', ['href' => '#'], $this->getAlias()); } else { - return Link::create($this->getAlias(), $this->getUrl()); + return Html::tag('a', ['href' => $this->getUrl()], $this->getAlias()); } } } diff --git a/library/Businessprocess/Node.php b/library/Businessprocess/Node.php index 4fc35cf..856def7 100644 --- a/library/Businessprocess/Node.php +++ b/library/Businessprocess/Node.php @@ -3,7 +3,7 @@ namespace Icinga\Module\Businessprocess; use Icinga\Exception\ProgrammingError; -use Icinga\Module\Businessprocess\Html\Link; +use ipl\Html\Html; abstract class Node { @@ -368,12 +368,9 @@ abstract class Node return $this->className; } - /** - * @return Link - */ public function getLink() { - return Link::create($this->getAlias(), '#'); + return Html::tag('a', ['href' => '#'], $this->getAlias()); } public function operatorHtml() diff --git a/library/Businessprocess/Renderer/Breadcrumb.php b/library/Businessprocess/Renderer/Breadcrumb.php index e1f47d5..42c197d 100644 --- a/library/Businessprocess/Renderer/Breadcrumb.php +++ b/library/Businessprocess/Renderer/Breadcrumb.php @@ -3,14 +3,12 @@ namespace Icinga\Module\Businessprocess\Renderer; use Icinga\Module\Businessprocess\BpNode; -use Icinga\Module\Businessprocess\Html\BaseElement; -use Icinga\Module\Businessprocess\Html\Element; -use Icinga\Module\Businessprocess\Html\Link; -use Icinga\Module\Businessprocess\Html\Icon; use Icinga\Module\Businessprocess\Renderer\TileRenderer\NodeTile; use Icinga\Module\Businessprocess\Web\Url; +use ipl\Html\BaseHtmlElement; +use ipl\Html\Html; -class Breadcrumb extends BaseElement +class Breadcrumb extends BaseHtmlElement { protected $tag = 'ul'; @@ -32,16 +30,18 @@ class Breadcrumb extends BaseElement $bpUrl->remove('action'); } - $breadcrumb->add(Element::create('li')->add( - Link::create( - Icon::create('dashboard'), - Url::fromPath('businessprocess'), - null, - ['title' => mt('businessprocess', 'Show Overview')] + $breadcrumb->add(Html::tag('li')->add( + Html::tag( + 'a', + [ + 'href' => Url::fromPath('businessprocess'), + 'title' => mt('businessprocess', 'Show Overview') + ], + Html::tag('i', ['class' => 'icon icon-dashboard']) ) )); - $breadcrumb->add(Element::create('li')->add( - Link::create($bp->getTitle(), $bpUrl) + $breadcrumb->add(Html::tag('li')->add( + Html::tag('a', ['href' => $bpUrl], $bp->getTitle()) )); $path = $renderer->getCurrentPath(); @@ -52,7 +52,7 @@ class Breadcrumb extends BaseElement static::renderNode($bp->getNode($node), $path, $renderer) ); } - $breadcrumb->addContent($parts); + $breadcrumb->add($parts); return $breadcrumb; } @@ -70,7 +70,7 @@ class Breadcrumb extends BaseElement $renderer = clone($renderer); $renderer->lock()->setIsBreadcrumb(); $p = new NodeTile($renderer, (string) $node, $node, $path); - $p->attributes()->add('class', $renderer->getNodeClasses($node)); + $p->getAttributes()->add('class', $renderer->getNodeClasses($node)); $p->setTag('li'); return $p; } diff --git a/library/Businessprocess/Renderer/Renderer.php b/library/Businessprocess/Renderer/Renderer.php index 8231ce5..e076438 100644 --- a/library/Businessprocess/Renderer/Renderer.php +++ b/library/Businessprocess/Renderer/Renderer.php @@ -6,14 +6,14 @@ use Icinga\Date\DateFormatter; use Icinga\Exception\ProgrammingError; use Icinga\Module\Businessprocess\BpNode; use Icinga\Module\Businessprocess\BpConfig; -use Icinga\Module\Businessprocess\Html\Container; -use Icinga\Module\Businessprocess\Html\Element; -use Icinga\Module\Businessprocess\Html\Html; -use Icinga\Module\Businessprocess\Html\HtmlString; use Icinga\Module\Businessprocess\Node; use Icinga\Module\Businessprocess\Web\Url; +use ipl\Html\BaseHtmlElement; +use ipl\Html\Html; +use ipl\Html\HtmlDocument; +use ipl\Html\HtmlString; -abstract class Renderer extends Html +abstract class Renderer extends HtmlDocument { /** @var BpConfig */ protected $config; @@ -122,7 +122,7 @@ abstract class Renderer extends Html /** * @param $summary - * @return Container + * @return BaseHtmlElement */ public function renderStateBadges($summary) { @@ -136,26 +136,24 @@ abstract class Renderer extends Html continue; } - $elements[] = Element::create( + $elements[] = Html::tag( 'span', - array( - 'class' => array( + [ + 'class' => [ 'badge', 'badge-' . strtolower($state) - ), + ], // TODO: We should translate this in this module 'title' => mt('monitoring', $state) - ) - )->setContent($cnt); + ], + $cnt + ); } if (!empty($elements)) { - $container = Container::create( - array('class' => 'badges') - )/* ->renderIfEmpty(false) */; - + $container = Html::tag('div', ['class' => 'badges']); foreach ($elements as $element) { - $container->addContent($element); + $container->add($element); } return $container; @@ -306,13 +304,14 @@ abstract class Renderer extends Html return HtmlString::create(''); } - return Element::create( + return Html::tag( 'span', - array( - 'class' => array('relative-time', 'time-since'), - 'title' => DateFormatter::formatDateTime($time), - ) - )->setContent(DateFormatter::timeSince($time, $timeOnly)); + [ + 'class' => ['relative-time', 'time-since'], + 'title' => DateFormatter::formatDateTime($time) + ], + DateFormatter::timeSince($time, $timeOnly) + ); } protected function createUnboundParent(BpConfig $bp) diff --git a/library/Businessprocess/Renderer/TileRenderer.php b/library/Businessprocess/Renderer/TileRenderer.php index 5972a28..6977c40 100644 --- a/library/Businessprocess/Renderer/TileRenderer.php +++ b/library/Businessprocess/Renderer/TileRenderer.php @@ -2,10 +2,8 @@ namespace Icinga\Module\Businessprocess\Renderer; -use Icinga\Module\Businessprocess\Html\Container; -use Icinga\Module\Businessprocess\Html\Icon; -use Icinga\Module\Businessprocess\Html\Link; use Icinga\Module\Businessprocess\Renderer\TileRenderer\NodeTile; +use ipl\Html\Html; class TileRenderer extends Renderer { @@ -15,14 +13,12 @@ class TileRenderer extends Renderer public function render() { $bp = $this->config; - $nodesDiv = Container::create( - array( - 'class' => array( - 'tiles', - $this->howMany() - ), - 'data-base-target' => '_next', - ) + $nodesDiv = Html::tag( + 'div', + [ + 'class' => ['tiles', $this->howMany()], + 'data-base-target' => '_next' + ] ); $nodes = $this->getChildNodes(); @@ -50,7 +46,7 @@ class TileRenderer extends Renderer $this->add($this->addNewNode()); } - $nodesDiv->addContent($this->getContent()); + $nodesDiv->add($this->getContent()); $this->setContent($nodesDiv); return parent::render(); @@ -80,30 +76,26 @@ class TileRenderer extends Renderer protected function addNewNode() { - $div = Container::create( - array('class' => 'addnew', 'data-base-target' => '_self') - ); + $div = Html::tag('div', ['class' => 'addnew', 'data-base-target' => '_self']); - $actions = Container::create( - array('class'=> 'actions') - ); + $actions = Html::tag('div', ['class'=> 'actions']); - $link = Link::create( - $this->translate('Add'), - $this->getUrl()->with('action', 'add'), - null, - array( - 'title' => $this->translate('Add a new business process node') - ) + $link = Html::tag( + 'a', + [ + 'href' => $this->getUrl()->with('action', 'add'), + 'title' => mt('businessprocess', 'Add a new business process node') + ], + mt('businessprocess', 'Add') ); $actions->add( - Link::create( - Icon::create('plus'), - $this->getUrl()->with('action', 'add'), - null, - array( - 'title' => $this->translate('Add a new business process node') - ) + Html::tag( + 'a', + [ + 'href' => $this->getUrl()->with('action', 'add'), + 'title' => mt('businessprocess', 'Add a new business process node') + ], + Html::tag('i', ['class' => 'icon icon-plus']) ) ); diff --git a/library/Businessprocess/Renderer/TileRenderer/NodeTile.php b/library/Businessprocess/Renderer/TileRenderer/NodeTile.php index fc4ce3b..2325143 100644 --- a/library/Businessprocess/Renderer/TileRenderer/NodeTile.php +++ b/library/Businessprocess/Renderer/TileRenderer/NodeTile.php @@ -4,18 +4,15 @@ namespace Icinga\Module\Businessprocess\Renderer\TileRenderer; use Icinga\Module\Businessprocess\BpNode; use Icinga\Module\Businessprocess\HostNode; -use Icinga\Module\Businessprocess\Html\BaseElement; -use Icinga\Module\Businessprocess\Html\Container; -use Icinga\Module\Businessprocess\Html\HtmlString; -use Icinga\Module\Businessprocess\Html\Icon; -use Icinga\Module\Businessprocess\Html\Link; use Icinga\Module\Businessprocess\ImportedNode; use Icinga\Module\Businessprocess\MonitoredNode; use Icinga\Module\Businessprocess\Node; use Icinga\Module\Businessprocess\Renderer\Renderer; use Icinga\Module\Businessprocess\ServiceNode; +use ipl\Html\BaseHtmlElement; +use ipl\Html\Html; -class NodeTile extends BaseElement +class NodeTile extends BaseHtmlElement { protected $tag = 'div'; @@ -28,7 +25,7 @@ class NodeTile extends BaseElement protected $path; /** - * @var Container + * @var BaseHtmlElement */ private $actions; @@ -57,11 +54,12 @@ class NodeTile extends BaseElement protected function addActions() { - $this->actions = Container::create( - array( + $this->actions = Html::tag( + 'div', + [ 'class' => 'actions', 'data-base-target' => '_self' - ) + ] ); return $this->add($this->actions); @@ -72,7 +70,7 @@ class NodeTile extends BaseElement $renderer = $this->renderer; $node = $this->node; - $attributes = $this->attributes(); + $attributes = $this->getAttributes(); $attributes->add('class', $renderer->getNodeClasses($node)); $attributes->add('id', 'bp-' . (string) $node); @@ -83,9 +81,9 @@ class NodeTile extends BaseElement if ($node instanceof BpNode) { if ($renderer->isBreadcrumb()) { - $link->addContent($renderer->renderStateBadges($node->getStateSummary())); + $link->add($renderer->renderStateBadges($node->getStateSummary())); } else { - $this->addContent($renderer->renderStateBadges($node->getStateSummary())); + $this->add($renderer->renderStateBadges($node->getStateSummary())); } } @@ -168,32 +166,22 @@ class NodeTile extends BaseElement } /** - * @return Link + * @return BaseHtmlElement */ protected function getMainNodeLink() { $node = $this->node; $url = $this->getMainNodeUrl($node); if ($node instanceof ServiceNode) { - $link = Link::create( - $node->getAlias(), - $url, - null, - array('data-base-target' => '_next') - ); + $link = Html::tag('a', ['href' => $url, 'data-base-target' => '_next'], $node->getAlias()); } elseif ($node instanceof HostNode) { - $link = Link::create( - $node->getHostname(), - $url, - null, - array('data-base-target' => '_next') - ); + $link = Html::tag('a', ['href' => $url, 'data-base-target' => '_next'], $node->getHostname()); } else { - $link = Link::create($node->getAlias(), $url); + $link = Html::tag('a', ['href' => $url], $node->getAlias()); if ($node instanceof ImportedNode) { - $link->attributes()->add('data-base-target', '_next'); + $link->getAttributes()->add('data-base-target', '_next'); } else { - $link->attributes()->add('data-base-target', '_self'); + $link->getAttributes()->add('data-base-target', '_self'); } } @@ -206,56 +194,54 @@ class NodeTile extends BaseElement $url = $this->getMainNodeUrl($node); if ($node instanceof BpNode) { - $this->actions()->add(Link::create( - Icon::create('dashboard'), - $url->with('mode', 'tile'), - null, - array( - 'title' => $this->translate('Show tiles for this subtree'), - 'data-base-target' => '_self' - ) - ))->add(Link::create( - Icon::create('sitemap'), - $url->with('mode', 'tree'), - null, - array( - 'title' => $this->translate('Show this subtree as a tree'), - 'data-base-target' => '_next' - ) + $this->actions()->add(Html::tag( + 'a', + [ + 'data-base-target' => '_self', + 'href' => $url->with('mode', 'tile'), + 'title' => mt('businessprocess', 'Show tiles for this subtree') + ], + Html::tag('i', ['class' => 'icon icon-dashboard']) + ))->add(Html::tag( + 'a', + [ + 'data-base-target' => '_next', + 'href' => $url->with('mode', 'tree'), + 'title' => mt('businessprocess', 'Show this subtree as a tree') + ], + Html::tag('i', ['class' => 'icon icon-sitemap']) )); $url = $node->getInfoUrl(); if ($url !== null) { - $link = Link::create( - Icon::create('info-circled'), - $url, - null, - array( - 'title' => sprintf('%s: %s', $this->translate('More information'), $url), - 'class' => 'node-info' - ) + $link = Html::tag( + 'a', + [ + 'href' => $url, + 'class' => 'node-info', + 'title' => sprintf('%s: %s', mt('businessprocess', 'More information'), $url) + ], + Html::tag('i', ['class' => 'icon icon-circled']) ); if (preg_match('#^http(?:s)?://#', $url)) { - $link->addAttributes(array('target' => '_blank')); + $link->addAttributes(['target' => '_blank']); } $this->actions()->add($link); } } else { // $url = $this->makeMonitoredNodeUrl($node); if ($node instanceof ServiceNode) { - $this->actions()->add(Link::create( - Icon::create('service'), - $node->getUrl(), - null, - array('data-base-target' => '_next') + $this->actions()->add(Html::tag( + 'a', + ['href' => $node->getUrl(), 'data-base-target' => '_next'], + Html::tag('i', ['class' => 'icon icon-service']) )); } elseif ($node instanceof HostNode) { - $this->actions()->add(Link::create( - Icon::create('host'), - $node->getUrl(), - null, - array('data-base-target' => '_next') + $this->actions()->add(Html::tag( + 'a', + ['href' => $node->getUrl(), 'data-base-target' => '_next'], + Html::tag('i', ['class' => 'icon icon-host']) )); } } @@ -266,21 +252,29 @@ class NodeTile extends BaseElement $node = $this->node; $renderer = $this->renderer; if ($node instanceof MonitoredNode) { - $this->actions()->add(Link::create( - Icon::create('magic'), - $renderer->getUrl()->with('action', 'simulation') - ->with('simulationnode', $this->name), - null, - array('title' => $this->translate( - 'Show the business impact of this node by simulating a specific state' - )) + $this->actions()->add(Html::tag( + 'a', + [ + 'href' => $renderer->getUrl() + ->with('action', 'simulation') + ->with('simulationnode', $this->name), + 'title' => mt( + 'businessprocess', + 'Show the business impact of this node by simulating a specific state' + ) + ], + Html::tag('i', ['class' => 'icon icon-magic']) )); - $this->actions()->add(Link::create( - Icon::create('edit'), - $renderer->getUrl()->with('action', 'editmonitored')->with('editmonitorednode', $node->getName()), - null, - array('title' => $this->translate('Modify this monitored node')) + $this->actions()->add(Html::tag( + 'a', + [ + 'href' => $renderer->getUrl() + ->with('action', 'editmonitored') + ->with('editmonitorednode', $node->getName()), + 'title' => mt('businessprocess', 'Modify this monitored node') + ], + Html::tag('i', ['class' => 'icon icon-edit']) )); } @@ -291,11 +285,15 @@ class NodeTile extends BaseElement } if ($node instanceof BpNode) { - $this->actions()->add(Link::create( - Icon::create('edit'), - $renderer->getUrl()->with('action', 'edit')->with('editnode', $node->getName()), - null, - array('title' => $this->translate('Modify this business process node')) + $this->actions()->add(Html::tag( + 'a', + [ + 'href' => $renderer->getUrl() + ->with('action', 'edit') + ->with('editnode', $node->getName()), + 'title' => mt('businessprocess', 'Modify this business process node') + ], + Html::tag('i', ['class' => 'icon icon-edit']) )); } @@ -304,11 +302,13 @@ class NodeTile extends BaseElement 'deletenode' => $node->getName(), ); - $this->actions()->add(Link::create( - Icon::create('cancel'), - $renderer->getUrl()->with($params), - null, - array('title' => $this->translate('Delete this node')) + $this->actions()->add(Html::tag( + 'a', + [ + 'href' => $renderer->getUrl()->with($params), + 'title' => mt('businessprocess', 'Delete this node') + ], + Html::tag('i', ['class' => 'icon icon-cancle']) )); } } diff --git a/library/Businessprocess/Renderer/TreeRenderer.php b/library/Businessprocess/Renderer/TreeRenderer.php index 01f1bf9..9fc27b8 100644 --- a/library/Businessprocess/Renderer/TreeRenderer.php +++ b/library/Businessprocess/Renderer/TreeRenderer.php @@ -4,12 +4,9 @@ namespace Icinga\Module\Businessprocess\Renderer; use Icinga\Module\Businessprocess\BpNode; use Icinga\Module\Businessprocess\BpConfig; -use Icinga\Module\Businessprocess\Html\Container; -use Icinga\Module\Businessprocess\Html\Element; -use Icinga\Module\Businessprocess\Html\Icon; -use Icinga\Module\Businessprocess\Html\Link; use Icinga\Module\Businessprocess\Node; -use Icinga\Module\Businessprocess\Web\Url; +use ipl\Html\BaseHtmlElement; +use ipl\Html\Html; class TreeRenderer extends Renderer { @@ -19,11 +16,12 @@ class TreeRenderer extends Renderer public function render() { $bp = $this->config; - $this->add(Container::create( - array( + $this->add(Html::tag( + 'div', + [ 'id' => $bp->getHtmlId(), 'class' => 'bp' - ), + ], $this->renderBp($bp) )); @@ -79,16 +77,16 @@ class TreeRenderer extends Renderer /** * @param Node $node - * @return Icon[] + * @return BaseHtmlElement[] */ public function getNodeIcons(Node $node) { $icons = array(); if ($node->isInDowntime()) { - $icons[] = Icon::create('moon'); + $icons[] = Html::tag('i', ['class' => 'icon icon-moon']); } if ($node->isAcknowledged()) { - $icons[] = Icon::create('ok'); + $icons[] = Html::tag('i', ['class' => 'icon icon-ok']); } return $icons; } @@ -102,17 +100,17 @@ class TreeRenderer extends Renderer */ public function renderNode(BpConfig $bp, Node $node, $path = array()) { - $table = Element::create( + $table = Html::tag( 'table', - array( + [ 'id' => $this->getId($node, $path), 'class' => array( 'bp', $node->getObjectClassName() ) - ) + ] ); - $attributes = $table->attributes(); + $attributes = $table->getAttributes(); $attributes->add('class', $this->getStateClassNames($node)); if ($node->isHandled()) { $attributes->add('class', 'handled'); @@ -123,57 +121,68 @@ class TreeRenderer extends Renderer $attributes->add('class', 'node'); } - $tbody = $table->createElement('tbody'); - $tr = $tbody->createElement('tr'); + $tbody = Html::tag('tbody'); + $table->add($tbody); + $tr = Html::tag('tr'); + $tbody->add($tr); if ($node instanceof BpNode) { - $tr->createElement( + $tr->add(Html::tag( 'th', - array( - 'rowspan' => $node->countChildren() + 1 + ($this->isLocked() ? 0 : 1) - ) - )->createElement( - 'span', - array('class' => 'op') - )->setContent($node->operatorHtml()); + ['rowspan' => $node->countChildren() + 1 + ($this->isLocked() ? 0 : 1)], + Html::tag('span', ['class' => 'op'], $node->operatorHtml()) + )); } - $td = $tr->createElement('td'); + $td = Html::tag('td'); + $tr->add($td); if ($node instanceof BpNode && $node->hasInfoUrl()) { $td->add($this->createInfoAction($node)); } if (! $this->isLocked()) { - $td->addContent($this->getActionIcons($bp, $node)); + $td->add($this->getActionIcons($bp, $node)); } $link = $node->getLink(); - $link->attributes()->set('data-base-target', '_next'); - $link->addContent($this->getNodeIcons($node)); + $link->getAttributes()->set('data-base-target', '_next'); + $link->add($this->getNodeIcons($node)); if ($node->hasChildren()) { - $link->addContent($this->renderStateBadges($node->getStateSummary())); + $link->add($this->renderStateBadges($node->getStateSummary())); } if ($time = $node->getLastStateChange()) { - $since = $this->timeSince($time)->prependContent( + $since = $this->timeSince($time)->prepend( sprintf(' (%s ', $node->getStateName()) - )->addContent(')'); - $link->addContent($since); + )->add(')'); + $link->add($since); } - $td->addContent($link); + $td->add($link); foreach ($node->getChildren() as $name => $child) { - $tbody->createElement('tr')->createElement('td')->setContent( - $this->renderNode($bp, $child, $this->getCurrentPath()) - ); + $tbody->add(Html::tag( + 'tr', + null, + Html::tag( + 'td', + null, + $this->renderNode($bp, $child, $this->getCurrentPath()) + ) + )); } if (! $this->isLocked() && $node instanceof BpNode && $bp->getMetadata()->canModify()) { - $tbody->createElement('tr')->createElement('td')->setContent( - $this->renderAddNewNode($node) - ); + $tbody->add(Html::tag( + 'tr', + null, + Html::tag( + 'td', + null, + $this->renderAddNewNode($node) + ) + )); } return $table; @@ -200,7 +209,7 @@ class TreeRenderer extends Renderer 'action' => 'edit', 'editnode' => $node->getName() )), - $this->translate('Modify this node') + mt('businessprocess', 'Modify this node') ); } @@ -213,7 +222,7 @@ class TreeRenderer extends Renderer 'action' => 'simulation', 'simulationnode' => $node->getName() )), - $this->translate('Simulate a specific state') + mt('businessprocess', 'Simulate a specific state') ); } @@ -223,33 +232,35 @@ class TreeRenderer extends Renderer return $this->actionIcon( 'help', $url, - sprintf('%s: %s', $this->translate('More information'), $url) + sprintf('%s: %s', mt('businessprocess', 'More information'), $url) ); } protected function actionIcon($icon, $url, $title) { - return Link::create( - Icon::create($icon), - $url, - null, - array( + return Html::tag( + 'a', + [ + 'href' => $url, 'title' => $title, - 'style' => 'float: right', - ) + 'style' => 'float: right' + ], + Html::tag('i', ['class' => 'icon icon-' . $icon]) ); } protected function renderAddNewNode($parent) { - return Link::create( - $this->translate('Add'), - $this->getUrl()->with('action', 'add')->with('node', $parent->getName()), - null, - array( - 'class' => 'addnew icon-plus', - 'title' => $this->translate('Add a new business process node') - ) + return Html::tag( + 'a', + [ + 'href' => $this->getUrl() + ->with('action', 'add') + ->with('node', $parent->getName()), + 'title' => mt('businessprocess', 'Add a new business process node'), + 'class' => 'addnew icon-plus' + ], + mt('businessprocess', 'Add') ); } } diff --git a/library/Businessprocess/Storage/ConfigDiff.php b/library/Businessprocess/Storage/ConfigDiff.php index fc3b1d9..495151e 100644 --- a/library/Businessprocess/Storage/ConfigDiff.php +++ b/library/Businessprocess/Storage/ConfigDiff.php @@ -7,9 +7,9 @@ use Diff_Renderer_Html_Inline; use Diff_Renderer_Html_SideBySide; use Diff_Renderer_Text_Context; use Diff_Renderer_Text_Unified; -use Icinga\Module\Businessprocess\Html\Renderable; +use ipl\Html\ValidHtml; -class ConfigDiff implements Renderable +class ConfigDiff implements ValidHtml { protected $a; diff --git a/library/Businessprocess/Web/Component/ActionBar.php b/library/Businessprocess/Web/Component/ActionBar.php index 3453af2..94458dc 100644 --- a/library/Businessprocess/Web/Component/ActionBar.php +++ b/library/Businessprocess/Web/Component/ActionBar.php @@ -2,9 +2,9 @@ namespace Icinga\Module\Businessprocess\Web\Component; -use Icinga\Module\Businessprocess\Html\BaseElement; +use ipl\Html\BaseHtmlElement; -class ActionBar extends BaseElement +class ActionBar extends BaseHtmlElement { protected $contentSeparator = ' '; diff --git a/library/Businessprocess/Web/Component/BpDashboardTile.php b/library/Businessprocess/Web/Component/BpDashboardTile.php index af81804..17d3a0c 100644 --- a/library/Businessprocess/Web/Component/BpDashboardTile.php +++ b/library/Businessprocess/Web/Component/BpDashboardTile.php @@ -3,15 +3,12 @@ namespace Icinga\Module\Businessprocess\Web\Component; use Icinga\Module\Businessprocess\BpConfig; -use Icinga\Module\Businessprocess\Html\BaseElement; -use Icinga\Module\Businessprocess\Html\Container; -use Icinga\Module\Businessprocess\Html\Element; -use Icinga\Module\Businessprocess\Html\Icon; -use Icinga\Module\Businessprocess\Html\Link; -use Icinga\Module\Businessprocess\Html\Text; -use Icinga\Module\Businessprocess\Web\Url; +use Icinga\Web\Url; +use ipl\Html\BaseHtmlElement; +use ipl\Html\Html; +use ipl\Html\Text; -class BpDashboardTile extends BaseElement +class BpDashboardTile extends BaseHtmlElement { protected $tag = 'div'; @@ -19,33 +16,32 @@ class BpDashboardTile extends BaseElement public function __construct(BpConfig $bp, $title, $description, $icon, $url, $urlParams = null, $attributes = null) { - $this->add( - Container::create( - ['class' => 'bp-link', 'data-base-target' => '_main'], - Link::create( - Icon::create($icon), - $url, - $urlParams, - $attributes - )->add( - Element::create('span', array('class' => 'header'))->addContent($title) - )->addContent($description) - ) - ); + if (! isset($attributes['href'])) { + $attributes['href'] = Url::fromPath($url, $urlParams ?: []); + } - $tiles = Container::create(['class' => 'bp-root-tiles']); + $this->add(Html::tag( + 'div', + ['class' => 'bp-link', 'data-base-target' => '_main'], + Html::tag('a', $attributes, Html::tag('i', ['class' => 'icon icon-' . $icon])) + ->add(Html::tag('span', ['class' => 'header'], $title)) + ->add($description) + )); + + $tiles = Html::tag('div', ['class' => 'bp-root-tiles']); foreach ($bp->getChildren() as $node) { $state = strtolower($node->getStateName()); - $tiles->add( - Link::create( - Text::create(' ')->setEscaped(), - $url, - $urlParams + ['node' => $node->getName()], - ['class' => "badge state-{$state}", 'title' => $node->getAlias()] - ) - ); + $tiles->add(Html::tag( + 'a', + [ + 'href' => Url::fromPath($url, $urlParams ?: [])->with(['node' => $node->getName()]), + 'class' => "badge state-{$state}", + 'title' => $node->getAlias() + ], + Text::create(' ')->setEscaped() + )); } $this->add($tiles); diff --git a/library/Businessprocess/Web/Component/Content.php b/library/Businessprocess/Web/Component/Content.php index f8336ce..6d14197 100644 --- a/library/Businessprocess/Web/Component/Content.php +++ b/library/Businessprocess/Web/Component/Content.php @@ -2,10 +2,12 @@ namespace Icinga\Module\Businessprocess\Web\Component; -use Icinga\Module\Businessprocess\Html\Container; +use ipl\Html\BaseHtmlElement; -class Content extends Container +class Content extends BaseHtmlElement { + protected $tag = 'div'; + protected $contentSeparator = "\n"; protected $defaultAttributes = array('class' => 'content'); diff --git a/library/Businessprocess/Web/Component/Controls.php b/library/Businessprocess/Web/Component/Controls.php index 861a852..259cbbb 100644 --- a/library/Businessprocess/Web/Component/Controls.php +++ b/library/Businessprocess/Web/Component/Controls.php @@ -2,10 +2,12 @@ namespace Icinga\Module\Businessprocess\Web\Component; -use Icinga\Module\Businessprocess\Html\Container; +use ipl\Html\BaseHtmlElement; -class Controls extends Container +class Controls extends BaseHtmlElement { + protected $tag = 'div'; + protected $contentSeparator = "\n"; protected $defaultAttributes = array('class' => 'controls'); diff --git a/library/Businessprocess/Web/Component/Dashboard.php b/library/Businessprocess/Web/Component/Dashboard.php index 10eec7a..eb3b092 100644 --- a/library/Businessprocess/Web/Component/Dashboard.php +++ b/library/Businessprocess/Web/Component/Dashboard.php @@ -3,13 +3,12 @@ namespace Icinga\Module\Businessprocess\Web\Component; use Icinga\Authentication\Auth; -use Icinga\Module\Businessprocess\Html\BaseElement; -use Icinga\Module\Businessprocess\Html\Container; -use Icinga\Module\Businessprocess\Html\HtmlTag; use Icinga\Module\Businessprocess\State\MonitoringState; use Icinga\Module\Businessprocess\Storage\Storage; +use ipl\Html\BaseHtmlElement; +use ipl\Html\Html; -class Dashboard extends BaseElement +class Dashboard extends BaseHtmlElement { /** @var string */ protected $contentSeparator = "\n"; @@ -40,21 +39,22 @@ class Dashboard extends BaseElement // TODO: Auth? $processes = $storage->listProcessNames(); $this->add( - HtmlTag::h1($this->translate('Welcome to your Business Process Overview')) + Html::tag('h1', null, mt('businessprocess', 'Welcome to your Business Process Overview')) ); - $this->add( - HtmlTag::p( - $this->translate( - 'From here you can reach all your defined Business Process' - . ' configurations, create new or modify existing ones' - ) + $this->add(Html::tag( + 'p', + null, + mt( + 'businessprocess', + 'From here you can reach all your defined Business Process' + . ' configurations, create new or modify existing ones' ) - ); + )); if ($auth->hasPermission('businessprocess/create')) { $this->add( new DashboardAction( - $this->translate('Create'), - $this->translate('Create a new Business Process configuration'), + mt('businessprocess', 'Create'), + mt('businessprocess', 'Create a new Business Process configuration'), 'plus', 'businessprocess/process/create', null, @@ -62,8 +62,8 @@ class Dashboard extends BaseElement ) )->add( new DashboardAction( - $this->translate('Upload'), - $this->translate('Upload an existing Business Process configuration'), + mt('businessprocess', 'Upload'), + mt('businessprocess', 'Upload an existing Business Process configuration'), 'upload', 'businessprocess/process/upload', null, @@ -71,10 +71,13 @@ class Dashboard extends BaseElement ) ); } elseif (empty($processes)) { - $this->addContent( - Container::create() - ->add(HtmlTag::h1($this->translate('Not available'))) - ->add(HtmlTag::p($this->translate('No Business Process has been defined for you'))) + $this->add( + Html::tag('div') + ->add(Html::tag('h1', null, mt('businessprocess', 'Not available'))) + ->add(Html::tag('p', null, mt( + 'businessprocess', + 'No Business Process has been defined for you' + ))) ); } diff --git a/library/Businessprocess/Web/Component/DashboardAction.php b/library/Businessprocess/Web/Component/DashboardAction.php index b413871..5ed1845 100644 --- a/library/Businessprocess/Web/Component/DashboardAction.php +++ b/library/Businessprocess/Web/Component/DashboardAction.php @@ -2,12 +2,11 @@ namespace Icinga\Module\Businessprocess\Web\Component; -use Icinga\Module\Businessprocess\Html\BaseElement; -use Icinga\Module\Businessprocess\Html\Element; -use Icinga\Module\Businessprocess\Html\Icon; -use Icinga\Module\Businessprocess\Html\Link; +use Icinga\Web\Url; +use ipl\Html\BaseHtmlElement; +use ipl\Html\Html; -class DashboardAction extends BaseElement +class DashboardAction extends BaseHtmlElement { protected $tag = 'div'; @@ -15,15 +14,13 @@ class DashboardAction extends BaseElement public function __construct($title, $description, $icon, $url, $urlParams = null, $attributes = null) { - $this->add( - Link::create( - Icon::create($icon), - $url, - $urlParams, - $attributes - )->add( - Element::create('span', array('class' => 'header'))->addContent($title) - )->addContent($description) - ); + if (! isset($attributes['href'])) { + $attributes['href'] = Url::fromPath($url, $urlParams ?: []); + } + + $this->add(Html::tag('a', $attributes) + ->add(Html::tag('i', ['class' => 'icon icon-' . $icon])) + ->add(Html::tag('span', ['class' => 'header'], $title)) + ->add($description)); } } diff --git a/library/Businessprocess/Web/Component/RenderedProcessActionBar.php b/library/Businessprocess/Web/Component/RenderedProcessActionBar.php index 5d61cf9..ede4698 100644 --- a/library/Businessprocess/Web/Component/RenderedProcessActionBar.php +++ b/library/Businessprocess/Web/Component/RenderedProcessActionBar.php @@ -4,10 +4,10 @@ namespace Icinga\Module\Businessprocess\Web\Component; use Icinga\Authentication\Auth; use Icinga\Module\Businessprocess\BpConfig; -use Icinga\Module\Businessprocess\Html\Link; use Icinga\Module\Businessprocess\Renderer\Renderer; use Icinga\Module\Businessprocess\Renderer\TreeRenderer; -use Icinga\Module\Businessprocess\Web\Url; +use Icinga\Web\Url; +use ipl\Html\Html; class RenderedProcessActionBar extends ActionBar { @@ -16,87 +16,73 @@ class RenderedProcessActionBar extends ActionBar $meta = $config->getMetadata(); if ($renderer instanceof TreeRenderer) { - $this->add( - Link::create( - $this->translate('Tiles'), - $url->with('mode', 'tile'), - null, - array( - 'class' => 'icon-dashboard', - 'title' => $this->translate('Switch to Tile view'), - ) - ) - ); + $this->add(Html::tag( + 'a', + [ + 'href' => $url->with('mode', 'tile'), + 'title' => mt('businessprocess', 'Switch to Tile view'), + 'class' => 'icon-dashboard' + ], + mt('businessprocess', 'Tiles') + )); } else { - $this->add( - Link::create( - $this->translate('Tree'), - $url->with('mode', 'tree'), - null, - array( - 'class' => 'icon-sitemap', - 'title' => $this->translate('Switch to Tree view'), - ) - ) - ); + $this->add(Html::tag( + 'a', + [ + 'href' => $url->with('mode', 'tree'), + 'title' => mt('businessprocess', 'Switch to Tree view'), + 'class' => 'icon-sitemap' + ], + mt('businessprocess', 'Tree') + )); } - $this->add( - Link::create( - $this->translate('Fullscreen'), - $url->with('showFullscreen', true), - null, - array( - 'class' => 'icon-resize-full-alt', - 'title' => $this->translate('Switch to fullscreen mode'), - 'data-base-target' => '_main', - ) - ) - ); + $this->add(Html::tag( + 'a', + [ + 'data-base-target' => '_main', + 'href' => $url->with('showFullscreen', true), + 'title' => mt('businessprocess', 'Switch to fullscreen mode'), + 'class' => 'icon-resize-full-alt' + ], + mt('businessprocess', 'Fullscreen') + )); $hasChanges = $config->hasSimulations() || $config->hasBeenChanged(); if ($renderer->isLocked()) { - $this->add( - Link::create( - $this->translate('Editing locked'), - $url->with('unlocked', true), - null, - array( - 'class' => 'icon-lock', - 'title' => $this->translate('Click to unlock editing for this process'), - ) - ) - ); + $this->add(Html::tag( + 'a', + [ + 'href' => $url->with('unlocked', true), + 'title' => mt('businessprocess', 'Click to unlock editing for this process'), + 'class' => 'icon-lock' + ], + mt('businessprocess', 'Editing locked') + )); } elseif (! $hasChanges) { - $this->add( - Link::create( - $this->translate('Editing unlocked'), - $url->without('unlocked')->without('action'), - null, - array( - 'class' => 'icon-lock-open', - 'title' => $this->translate('Click to lock editing for this process'), - ) - ) - ); + $this->add(Html::tag( + 'a', + [ + 'href' => $url->without('unlocked')->without('action'), + 'title' => mt('businessprocess', 'Click to lock editing for this process'), + 'class' => 'icon-lock-open' + ], + mt('businessprocess', 'Editing unlocked') + )); } - if ($renderer->wantsRootNodes() && ( - ($hasChanges || (! $renderer->isLocked())) && $meta->canModify() - )) { - $this->add( - Link::create( - $this->translate('Config'), - 'businessprocess/process/config', - $this->currentProcessParams($url), - array( - 'class' => 'icon-wrench', - 'title' => $this->translate('Modify this process'), - 'data-base-target' => '_next', - ) - ) - ); + if ($renderer->wantsRootNodes() && (($hasChanges || (! $renderer->isLocked())) && $meta->canModify())) { + $this->add(Html::tag( + 'a', + [ + 'data-base-target' => '_next', + 'href' => Url::fromPath('businessprocess/process/config', $this->currentProcessParams($url)), + 'title' => mt('businessprocess', 'Modify this process'), + 'class' => 'icon-wrench' + ], + mt('businessprocess', 'Config') + )); } } diff --git a/library/Businessprocess/Web/Component/Tabs.php b/library/Businessprocess/Web/Component/Tabs.php index 72fc48e..aaa444e 100644 --- a/library/Businessprocess/Web/Component/Tabs.php +++ b/library/Businessprocess/Web/Component/Tabs.php @@ -2,8 +2,8 @@ namespace Icinga\Module\Businessprocess\Web\Component; -use Icinga\Module\Businessprocess\Html\Renderable; +use ipl\Html\ValidHtml; -class Tabs extends WtfTabs implements Renderable +class Tabs extends WtfTabs implements ValidHtml { } diff --git a/library/Businessprocess/Web/Controller.php b/library/Businessprocess/Web/Controller.php index 15689b1..b69f20e 100644 --- a/library/Businessprocess/Web/Controller.php +++ b/library/Businessprocess/Web/Controller.php @@ -4,7 +4,6 @@ namespace Icinga\Module\Businessprocess\Web; use Icinga\Application\Icinga; use Icinga\Module\Businessprocess\BpConfig; -use Icinga\Module\Businessprocess\Html\HtmlTag; use Icinga\Module\Businessprocess\Modification\ProcessChanges; use Icinga\Module\Businessprocess\Storage\LegacyStorage; use Icinga\Module\Businessprocess\Storage\Storage; @@ -16,6 +15,7 @@ use Icinga\Module\Businessprocess\Web\Form\FormLoader; use Icinga\Web\Controller as ModuleController; use Icinga\Web\Notification; use Icinga\Web\View; +use ipl\Html\Html; class Controller extends ModuleController { @@ -86,9 +86,9 @@ class Controller extends ModuleController protected function controls() { if ($this->view->controls === null) { - $controls = $this->view->controls = Controls::create(); + $controls = $this->view->controls = new Controls(); if ($this->view->compact) { - $controls->attributes()->add('class', 'compact'); + $controls->getAttributes()->add('class', 'compact'); } } @@ -101,9 +101,9 @@ class Controller extends ModuleController protected function content() { if ($this->view->content === null) { - $content = $this->view->content = Content::create(); + $content = $this->view->content = new Content(); if ($this->view->compact) { - $content->attributes()->add('class', 'compact'); + $content->getAttributes()->add('class', 'compact'); } } @@ -187,7 +187,7 @@ class Controller extends ModuleController $args = func_get_args(); array_shift($args); $this->view->title = vsprintf($title, $args); - $this->controls()->add(HtmlTag::h1($this->view->title)); + $this->controls()->add(Html::tag('h1', null, $this->view->title)); return $this; } diff --git a/library/Businessprocess/Web/Form/QuickBaseForm.php b/library/Businessprocess/Web/Form/QuickBaseForm.php index a0246ee..3ef7b66 100644 --- a/library/Businessprocess/Web/Form/QuickBaseForm.php +++ b/library/Businessprocess/Web/Form/QuickBaseForm.php @@ -4,10 +4,10 @@ namespace Icinga\Module\Businessprocess\Web\Form; use Icinga\Application\Icinga; use Icinga\Application\Modules\Module; -use Icinga\Module\Businessprocess\Html\Renderable; +use ipl\Html\ValidHtml; use Zend_Form; -abstract class QuickBaseForm extends Zend_Form implements Renderable +abstract class QuickBaseForm extends Zend_Form implements ValidHtml { /** * The Icinga module this form belongs to. Usually only set if the