mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
various: cleanup, sop using deprecated methods
This commit is contained in:
parent
403df971a1
commit
4f8c60bb46
@ -104,7 +104,7 @@ class DataController extends ActionController
|
||||
$this->addListTabs($listId, 'entries');
|
||||
|
||||
$table = new DatalistEntryTable($this->db());
|
||||
$table->attributes()->set('data-base-target', '_self');
|
||||
$table->getAttributes()->set('data-base-target', '_self');
|
||||
$table->setList($list);
|
||||
$this->content()->add([$form, $table]);
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ class ServiceController extends ObjectController
|
||||
);
|
||||
$table = (new IcingaAppliedServiceTable($this->db()))
|
||||
->setService($service);
|
||||
$table->attributes()->set('data-base-target', '_self');
|
||||
$table->getAttributes()->set('data-base-target', '_self');
|
||||
|
||||
$this->content()->add($table);
|
||||
}
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
namespace Icinga\Module\Director\Controllers;
|
||||
|
||||
use dipl\Html\Html;
|
||||
use Icinga\Module\Director\Objects\IcingaHost;
|
||||
use Icinga\Module\Director\Objects\IcingaService;
|
||||
use Icinga\Module\Director\Web\Controller\ActionController;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
use dipl\Html\Util;
|
||||
use Icinga\Module\Director\Objects\HostApplyMatches;
|
||||
|
||||
class SuggestController extends ActionController
|
||||
@ -46,7 +46,7 @@ class SuggestController extends ActionController
|
||||
$matches[] = $this->highlight($str, $search);
|
||||
}
|
||||
} else {
|
||||
$matches[] = Util::escapeForHtml($str);
|
||||
$matches[] = Html::escapeForHtml($str);
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@ class SuggestController extends ActionController
|
||||
protected function highlight($val, $search)
|
||||
{
|
||||
$search = ($search);
|
||||
$val = Util::escapeForHtml($val);
|
||||
$val = Html::escapeForHtml($val);
|
||||
return preg_replace(
|
||||
'/(' . preg_quote($search, '/') . ')/i',
|
||||
'<strong>\1</strong>',
|
||||
|
@ -246,7 +246,7 @@ class IcingaHostForm extends DirectorObjectForm
|
||||
{
|
||||
/** @var BaseElement $link */
|
||||
foreach ($links->getContent() as $link) {
|
||||
$link->attributes()->add('style', 'text-decoration: strike');
|
||||
$link->getAttributes()->add('style', 'text-decoration: strike');
|
||||
}
|
||||
$links->add('aha');
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ use Icinga\Module\Director\Db;
|
||||
use Icinga\Web\Widget\Tab;
|
||||
use dipl\Html\Html;
|
||||
use dipl\Html\HtmlString;
|
||||
use dipl\Html\Util;
|
||||
use dipl\Translation\TranslationHelper;
|
||||
use dipl\Web\Widget\Tabs;
|
||||
use Zend_Db_Select as ZfSelect;
|
||||
@ -65,7 +64,7 @@ abstract class Dashboard extends Html implements Countable
|
||||
$this->add(Html::tag(
|
||||
'p',
|
||||
null,
|
||||
HtmlString::create(nl2br(Util::escapeForHtml($description)))
|
||||
HtmlString::create(nl2br(Html::escapeForHtml($description)))
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -218,6 +218,7 @@ abstract class DbObject
|
||||
{
|
||||
$this->connection = $connection;
|
||||
$this->db = $connection->getDbAdapter();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -987,6 +988,7 @@ abstract class DbObject
|
||||
* @param DbConnection|null $connection
|
||||
*
|
||||
* @return static
|
||||
* @throws IE
|
||||
*/
|
||||
public static function create($properties = array(), DbConnection $connection = null)
|
||||
{
|
||||
@ -1004,6 +1006,10 @@ abstract class DbObject
|
||||
return array_key_exists($class, self::$prefetched);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @return static|bool
|
||||
*/
|
||||
protected static function getPrefetched($key)
|
||||
{
|
||||
$class = get_called_class();
|
||||
@ -1065,6 +1071,13 @@ abstract class DbObject
|
||||
return self::$prefetchStats;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param DbConnection $connection
|
||||
* @return static
|
||||
* @throws IE
|
||||
* @throws NotFoundError
|
||||
*/
|
||||
public static function loadWithAutoIncId($id, DbConnection $connection)
|
||||
{
|
||||
/* Need to cast to int, otherwise the id will be matched against
|
||||
@ -1084,9 +1097,17 @@ abstract class DbObject
|
||||
$obj->setConnection($connection)
|
||||
->set($obj->autoincKeyName, $id)
|
||||
->loadFromDb();
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param DbConnection $connection
|
||||
* @return static
|
||||
* @throws IE
|
||||
* @throws NotFoundError
|
||||
*/
|
||||
public static function load($id, DbConnection $connection)
|
||||
{
|
||||
if ($prefetched = static::getPrefetched($id)) {
|
||||
@ -1096,6 +1117,7 @@ abstract class DbObject
|
||||
/** @var DbObject $obj */
|
||||
$obj = new static;
|
||||
$obj->setConnection($connection)->setKey($id)->loadFromDb();
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
@ -1105,6 +1127,7 @@ abstract class DbObject
|
||||
* @param string|null $keyColumn
|
||||
*
|
||||
* @return static[]
|
||||
* @throws IE
|
||||
*/
|
||||
public static function loadAll(DbConnection $connection, $query = null, $keyColumn = null)
|
||||
{
|
||||
@ -1138,6 +1161,7 @@ abstract class DbObject
|
||||
* @param bool $force
|
||||
*
|
||||
* @return static[]
|
||||
* @throws IE
|
||||
*/
|
||||
public static function prefetchAll(DbConnection $connection, $force = false)
|
||||
{
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace Icinga\Module\Director;
|
||||
|
||||
use dipl\Html\Html;
|
||||
use Icinga\Module\Director\Objects\DirectorDeploymentLog;
|
||||
use dipl\Html\Link;
|
||||
use dipl\Html\Util as iplUtil;
|
||||
use dipl\Html\ValidHtml;
|
||||
|
||||
class StartupLogRenderer implements ValidHtml
|
||||
@ -20,7 +20,7 @@ class StartupLogRenderer implements ValidHtml
|
||||
public function render()
|
||||
{
|
||||
$deployment = $this->deployment;
|
||||
$log = iplUtil::escapeForHtml($deployment->get('startup_log'));
|
||||
$log = Html::escapeForHtml($deployment->get('startup_log'));
|
||||
$lines = array();
|
||||
$severity = 'information';
|
||||
$sevPattern = '/^(debug|notice|information|warning|critical)\/(\w+)/';
|
||||
|
@ -189,7 +189,7 @@ abstract class ActionController extends Controller implements ControlsAndContent
|
||||
$this->view = $viewRenderer->view;
|
||||
if ($this->getOriginalUrl()->getParam('view') === 'compact') {
|
||||
if ($this->view->controls) {
|
||||
$this->controls()->attributes()->add('style', 'display: none;');
|
||||
$this->controls()->getAttributes()->add('style', 'display: none;');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -177,7 +177,7 @@ abstract class ObjectController extends ActionController
|
||||
$form->handleRequest();
|
||||
$this->content()->add($form);
|
||||
$table = new IcingaObjectDatafieldTable($object);
|
||||
$table->attributes()->set('data-base-target', '_self');
|
||||
$table->getAttributes()->set('data-base-target', '_self');
|
||||
$table->renderTo($this);
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ class ExtensibleSetElement extends BaseElement
|
||||
$this->addAddMore();
|
||||
|
||||
if ($this->isSorted()) {
|
||||
$this->attributes()->add('class', 'sortable');
|
||||
$this->getAttributes()->add('class', 'sortable');
|
||||
}
|
||||
if (null !== $this->description) {
|
||||
$this->addDescription($this->description);
|
||||
@ -204,7 +204,7 @@ class ExtensibleSetElement extends BaseElement
|
||||
private function eventuallyAddAutosuggestion(BaseElement $element)
|
||||
{
|
||||
if ($this->suggestionContext !== null) {
|
||||
$attrs = $element->attributes();
|
||||
$attrs = $element->getAttributes();
|
||||
$attrs->add('class', 'director-suggest');
|
||||
$attrs->set([
|
||||
'autocomplete' => 'off',
|
||||
@ -270,7 +270,7 @@ class ExtensibleSetElement extends BaseElement
|
||||
)
|
||||
);
|
||||
if ($cnt !== 0) { // TODO: was === 0?!
|
||||
$field->attributes()->add('class', 'extend-set');
|
||||
$field->getAttributes()->add('class', 'extend-set');
|
||||
}
|
||||
|
||||
if ($this->suggestionContext === null) {
|
||||
@ -324,7 +324,7 @@ class ExtensibleSetElement extends BaseElement
|
||||
'id' => $this->id . $this->suffix($this->chosenOptionCount),
|
||||
'value' => $val
|
||||
]);
|
||||
$text->attributes()->set([
|
||||
$text->getAttributes()->set([
|
||||
'autocomplete' => 'off',
|
||||
'autocorrect' => 'off',
|
||||
'autocapitalize' => 'off',
|
||||
@ -343,7 +343,7 @@ class ExtensibleSetElement extends BaseElement
|
||||
private function addRemainingAttributes(BaseElement $element)
|
||||
{
|
||||
if ($this->remainingAttribs !== null) {
|
||||
$element->attributes()->add($this->remainingAttribs);
|
||||
$element->getAttributes()->add($this->remainingAttribs);
|
||||
}
|
||||
|
||||
return $element;
|
||||
@ -360,7 +360,7 @@ class ExtensibleSetElement extends BaseElement
|
||||
|
||||
private function disableElement(BaseElement $element)
|
||||
{
|
||||
$element->attributes()->set('disabled', 'disabled');
|
||||
$element->getAttributes()->set('disabled', 'disabled');
|
||||
return $element;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class ActivityLogTable extends ZfQueryBasedTable
|
||||
|
||||
public function assemble()
|
||||
{
|
||||
$this->attributes()->add('class', 'activity-log');
|
||||
$this->getAttributes()->add('class', 'activity-log');
|
||||
}
|
||||
|
||||
public function setLastDeployedId($id)
|
||||
|
@ -56,7 +56,7 @@ class ApplyRulesTable extends ZfQueryBasedTable
|
||||
]);
|
||||
|
||||
if ($row->disabled === 'y') {
|
||||
$tr->attributes()->add('class', 'disabled');
|
||||
$tr->getAttributes()->add('class', 'disabled');
|
||||
}
|
||||
|
||||
return $tr;
|
||||
|
@ -24,7 +24,7 @@ class ConfigFileDiffTable extends ZfQueryBasedTable
|
||||
public static function load($leftSum, $rightSum, Db $connection)
|
||||
{
|
||||
$table = new static($connection);
|
||||
$table->attributes()->add('class', 'config-diff');
|
||||
$table->getAttributes()->add('class', 'config-diff');
|
||||
return $table->setLeftChecksum($leftSum)
|
||||
->setRightChecksum($rightSum);
|
||||
}
|
||||
@ -36,7 +36,7 @@ class ConfigFileDiffTable extends ZfQueryBasedTable
|
||||
$row->file_path,
|
||||
]);
|
||||
|
||||
$tr->attributes()->add('class', 'file-' . $row->file_action);
|
||||
$tr->getAttributes()->add('class', 'file-' . $row->file_action);
|
||||
return $tr;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ class CustomvarVariantsTable extends ZfQueryBasedTable
|
||||
{
|
||||
$table = new static($db);
|
||||
$table->varName = $varName;
|
||||
$table->attributes()->set('class', 'common-table');
|
||||
$table->getAttributes()->set('class', 'common-table');
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ class DeploymentLogTable extends ZfQueryBasedTable
|
||||
|
||||
public function assemble()
|
||||
{
|
||||
$this->attributes()->add('class', 'deployment-log');
|
||||
$this->getAttributes()->add('class', 'deployment-log');
|
||||
}
|
||||
|
||||
public function renderRow($row)
|
||||
|
@ -24,7 +24,7 @@ class GeneratedConfigFileTable extends ZfQueryBasedTable
|
||||
{
|
||||
$table = new static($db);
|
||||
$table->config = $config;
|
||||
$table->attributes()->set('data-base-target', '_self');
|
||||
$table->getAttributes()->set('data-base-target', '_self');
|
||||
return $table;
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ class GeneratedConfigFileTable extends ZfQueryBasedTable
|
||||
]);
|
||||
|
||||
if ($row->file_path === $this->activeFile) {
|
||||
$tr->attributes()->add('class', 'active');
|
||||
$tr->getAttributes()->add('class', 'active');
|
||||
}
|
||||
|
||||
return $tr;
|
||||
|
@ -25,7 +25,7 @@ class IcingaCommandArgumentTable extends ZfQueryBasedTable
|
||||
|
||||
public function assemble()
|
||||
{
|
||||
$this->attributes()->set('data-base-target', '_self');
|
||||
$this->getAttributes()->set('data-base-target', '_self');
|
||||
}
|
||||
|
||||
public function renderRow($row)
|
||||
|
@ -29,7 +29,7 @@ class IcingaHostAppliedForServiceTable extends SimpleQueryBasedTable
|
||||
public static function load(IcingaHost $host, CustomVariableDictionary $dict)
|
||||
{
|
||||
$table = (new static())->setHost($host)->setDictionary($dict);
|
||||
$table->attributes()->set('data-base-target', '_self');
|
||||
$table->getAttributes()->set('data-base-target', '_self');
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ class IcingaHostAppliedServicesTable extends SimpleQueryBasedTable
|
||||
public static function load(IcingaHost $host)
|
||||
{
|
||||
$table = (new static())->setHost($host);
|
||||
$table->attributes()->set('data-base-target', '_self');
|
||||
$table->getAttributes()->set('data-base-target', '_self');
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ class IcingaHostServiceTable extends ZfQueryBasedTable
|
||||
{
|
||||
$table = new static($host->getConnection());
|
||||
$table->setHost($host);
|
||||
$table->attributes()->set('data-base-target', '_self');
|
||||
$table->getAttributes()->set('data-base-target', '_self');
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ class IcingaObjectDatafieldTable extends SimpleQueryBasedTable
|
||||
]);
|
||||
|
||||
if (! $definedOnThis) {
|
||||
$row->attributes()->add('class', 'disabled');
|
||||
$row->getAttributes()->add('class', 'disabled');
|
||||
}
|
||||
|
||||
return $row;
|
||||
|
@ -33,7 +33,7 @@ class IcingaServiceSetServiceTable extends ZfQueryBasedTable
|
||||
{
|
||||
$table = new static($set->getConnection());
|
||||
$table->set = $set;
|
||||
$table->attributes()->set('data-base-target', '_self');
|
||||
$table->getAttributes()->set('data-base-target', '_self');
|
||||
return $table;
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ class IcingaServiceSetServiceTable extends ZfQueryBasedTable
|
||||
]);
|
||||
|
||||
if ($row->disabled === 'y') {
|
||||
$tr->attributes()->add('class', 'disabled');
|
||||
$tr->getAttributes()->add('class', 'disabled');
|
||||
}
|
||||
|
||||
return $tr;
|
||||
|
@ -19,7 +19,7 @@ class IcingaTimePeriodRangeTable extends ZfQueryBasedTable
|
||||
{
|
||||
$table = new static($period->getConnection());
|
||||
$table->period = $period;
|
||||
$table->attributes()->set('data-base-target', '_self');
|
||||
$table->getAttributes()->set('data-base-target', '_self');
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ class ImportsourceHookTable extends SimpleQueryBasedTable
|
||||
|
||||
protected function assemble()
|
||||
{
|
||||
$this->attributes()->add('class', 'raw-data-table collapsed');
|
||||
$this->getAttributes()->add('class', 'raw-data-table collapsed');
|
||||
}
|
||||
|
||||
public function getColumns()
|
||||
|
@ -21,7 +21,7 @@ class ImportsourceTable extends ZfQueryBasedTable
|
||||
|
||||
protected function assemble()
|
||||
{
|
||||
$this->attributes()->add('class', 'syncstate');
|
||||
$this->getAttributes()->add('class', 'syncstate');
|
||||
parent::assemble();
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ class ImportsourceTable extends ZfQueryBasedTable
|
||||
}
|
||||
|
||||
$tr = $this::row([$caption]);
|
||||
$tr->attributes()->add('class', $row->import_state);
|
||||
$tr->getAttributes()->add('class', $row->import_state);
|
||||
|
||||
return $tr;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ class JobTable extends ZfQueryBasedTable
|
||||
|
||||
protected function assemble()
|
||||
{
|
||||
$this->attributes()->add('class', 'jobs');
|
||||
$this->getAttributes()->add('class', 'jobs');
|
||||
parent::assemble();
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ class JobTable extends ZfQueryBasedTable
|
||||
}
|
||||
|
||||
$tr = $this::row([$caption]);
|
||||
$tr->attributes()->add('class', $this->getJobClasses($row));
|
||||
$tr->getAttributes()->add('class', $this->getJobClasses($row));
|
||||
|
||||
return $tr;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ class ObjectsTable extends ZfQueryBasedTable
|
||||
$classes[] = 'disabled';
|
||||
}
|
||||
if (! empty($classes)) {
|
||||
$tr->attributes()->add('class', $classes);
|
||||
$tr->getAttributes()->add('class', $classes);
|
||||
}
|
||||
|
||||
return $tr;
|
||||
|
@ -60,7 +60,7 @@ class ObjectsTableService extends ObjectsTable
|
||||
|
||||
$hostField = static::td(Link::create($caption, $url));
|
||||
if ($row->host === null) {
|
||||
$hostField->attributes()->add('class', 'error');
|
||||
$hostField->getAttributes()->add('class', 'error');
|
||||
}
|
||||
$tr = static::tr([
|
||||
$hostField,
|
||||
@ -68,7 +68,7 @@ class ObjectsTableService extends ObjectsTable
|
||||
]);
|
||||
|
||||
if ($row->host_disabled === 'y' || $row->disabled === 'y') {
|
||||
$tr->attributes()->add('class', 'disabled');
|
||||
$tr->getAttributes()->add('class', 'disabled');
|
||||
}
|
||||
return $tr;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class PropertymodifierTable extends ZfQueryBasedTable
|
||||
|
||||
protected function assemble()
|
||||
{
|
||||
$this->attributes()->set('data-base-target', '_self');
|
||||
$this->getAttributes()->set('data-base-target', '_self');
|
||||
}
|
||||
|
||||
public function getColumns()
|
||||
|
@ -14,7 +14,7 @@ class SyncRunTable extends ZfQueryBasedTable
|
||||
public static function create(SyncRule $rule)
|
||||
{
|
||||
$table = new static($rule->getConnection());
|
||||
$table->attributes()
|
||||
$table->getAttributes()
|
||||
->set('data-base-target', '_self')
|
||||
->add('class', 'history');
|
||||
$table->rule = $rule;
|
||||
|
@ -26,7 +26,7 @@ class SyncpropertyTable extends ZfQueryBasedTable
|
||||
public static function create(SyncRule $rule)
|
||||
{
|
||||
$table = new static($rule->getConnection());
|
||||
$table->attributes()->set('data-base-target', '_self');
|
||||
$table->getAttributes()->set('data-base-target', '_self');
|
||||
$table->rule = $rule;
|
||||
return $table;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ class SyncruleTable extends ZfQueryBasedTable
|
||||
|
||||
protected function assemble()
|
||||
{
|
||||
$this->attributes()->add('class', 'syncstate');
|
||||
$this->getAttributes()->add('class', 'syncstate');
|
||||
parent::assemble();
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ class SyncruleTable extends ZfQueryBasedTable
|
||||
}
|
||||
|
||||
$tr = $this::row([$caption, $row->object_type]);
|
||||
$tr->attributes()->add('class', $row->sync_state);
|
||||
$tr->getAttributes()->add('class', $row->sync_state);
|
||||
|
||||
return $tr;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class InspectTreeRenderer extends BaseElement
|
||||
$hasChildren = property_exists($node, 'children');
|
||||
$li = Html::tag('li');
|
||||
if (! $hasChildren) {
|
||||
$li->attributes()->add('class', 'collapsed');
|
||||
$li->getAttributes()->add('class', 'collapsed');
|
||||
}
|
||||
|
||||
if ($hasChildren) {
|
||||
|
@ -56,7 +56,7 @@ class TemplateTreeRenderer extends BaseElement
|
||||
|
||||
$li = Html::tag('li');
|
||||
if (! $hasChildren) {
|
||||
$li->attributes()->add('class', 'collapsed');
|
||||
$li->getAttributes()->add('class', 'collapsed');
|
||||
}
|
||||
|
||||
if ($hasChildren) {
|
||||
|
@ -6,7 +6,6 @@ use Icinga\Module\Director\IcingaConfig\IcingaConfigFile;
|
||||
use dipl\Html\Html;
|
||||
use dipl\Html\HtmlString;
|
||||
use dipl\Html\Link;
|
||||
use dipl\Html\Util;
|
||||
use dipl\Translation\TranslationHelper;
|
||||
|
||||
class ShowConfigFile extends Html
|
||||
@ -32,7 +31,7 @@ class ShowConfigFile extends Html
|
||||
|
||||
protected function prepareContent()
|
||||
{
|
||||
$source = $this->linkObjects(Util::escapeForHtml($this->file->getContent()));
|
||||
$source = $this->linkObjects(Html::escapeForHtml($this->file->getContent()));
|
||||
if ($this->highlight) {
|
||||
$source = $this->highlight(
|
||||
$source,
|
||||
|
@ -19,7 +19,7 @@ class SyncRunDetails extends NameValueTable
|
||||
public function __construct(SyncRun $run)
|
||||
{
|
||||
$this->run = $run;
|
||||
$this->attributes()->add('data-base-target', '_next'); // eigentlich nur runSummary
|
||||
$this->getAttributes()->add('data-base-target', '_next'); // eigentlich nur runSummary
|
||||
$this->addNameValuePairs([
|
||||
$this->translate('Start time') => $run->start_time,
|
||||
$this->translate('Duration') => sprintf('%.2fs', $run->duration_ms / 1000),
|
||||
|
Loading…
x
Reference in New Issue
Block a user