mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 08:14:03 +02:00
Merge remote-tracking branch 'origin/master' into feature/redesign-7144
This commit is contained in:
commit
da47c7fc7e
6
.gitignore
vendored
6
.gitignore
vendored
@ -5,8 +5,8 @@
|
||||
!.git*
|
||||
!.vagrant-puppet/*
|
||||
|
||||
# Exclude enabled modules
|
||||
config/enabledModules/
|
||||
|
||||
# Exclude application log files
|
||||
var/log/*
|
||||
|
||||
# Exclude symlink you need for packaging
|
||||
/debian
|
||||
|
@ -47,7 +47,7 @@ class WebCommand extends Command
|
||||
readlink('/proc/self/exe'),
|
||||
$socket,
|
||||
$basedir,
|
||||
ICINGA_LIBDIR . '/Icinga/Application/webrouter.php'
|
||||
Icinga::app()->getLibraryDir('/Icinga/Application/webrouter.php')
|
||||
);
|
||||
|
||||
// TODO: Store webserver log, switch uid, log index.php includes, pid file
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
use Icinga\Authentication\Backend\AutoLoginBackend;
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use Icinga\Form\Authentication\LoginForm;
|
||||
use Icinga\Forms\Authentication\LoginForm;
|
||||
use Icinga\Authentication\AuthChain;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Logger;
|
||||
|
@ -8,11 +8,11 @@ use Icinga\Application\Modules\Module;
|
||||
use Icinga\Web\Widget;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Form\Config\GeneralConfigForm;
|
||||
use Icinga\Form\Config\AuthenticationBackendReorderForm;
|
||||
use Icinga\Form\Config\AuthenticationBackendConfigForm;
|
||||
use Icinga\Form\Config\ResourceConfigForm;
|
||||
use Icinga\Form\ConfirmRemovalForm;
|
||||
use Icinga\Forms\Config\GeneralConfigForm;
|
||||
use Icinga\Forms\Config\AuthenticationBackendReorderForm;
|
||||
use Icinga\Forms\Config\AuthenticationBackendConfigForm;
|
||||
use Icinga\Forms\Config\ResourceConfigForm;
|
||||
use Icinga\Forms\ConfirmRemovalForm;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@ use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Exception\IcingaException;
|
||||
use Icinga\Exception\NotReadableError;
|
||||
use Icinga\File\Ini\IniWriter;
|
||||
use Icinga\Form\Dashboard\AddUrlForm;
|
||||
use Icinga\Forms\Dashboard\AddUrlForm;
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Web\Widget\Dashboard;
|
||||
|
@ -6,7 +6,7 @@ use Icinga\Web\Controller\BasePreferenceController;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Web\Widget\Tab;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Form\PreferenceForm;
|
||||
use Icinga\Forms\PreferenceForm;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\User\Preferences\PreferencesStore;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form\Authentication;
|
||||
namespace Icinga\Forms\Authentication;
|
||||
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Url;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form\Config\Authentication;
|
||||
namespace Icinga\Forms\Config\Authentication;
|
||||
|
||||
use Zend_Validate_Callback;
|
||||
use Icinga\Web\Form;
|
||||
|
@ -2,12 +2,11 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form\Config\Authentication;
|
||||
namespace Icinga\Forms\Config\Authentication;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Authentication\Backend\DbUserBackend;
|
||||
|
||||
@ -89,7 +88,7 @@ class DbBackendForm extends Form
|
||||
*
|
||||
* @see Form::onSuccess()
|
||||
*/
|
||||
public function onSuccess(Request $request)
|
||||
public function onSuccess()
|
||||
{
|
||||
if (false === static::isValidAuthenticationBackend($this)) {
|
||||
return false;
|
||||
|
@ -2,12 +2,11 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form\Config\Authentication;
|
||||
namespace Icinga\Forms\Config\Authentication;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Exception\AuthenticationException;
|
||||
use Icinga\Authentication\Backend\LdapUserBackend;
|
||||
@ -119,7 +118,7 @@ class LdapBackendForm extends Form
|
||||
*
|
||||
* @see Form::onSuccess()
|
||||
*/
|
||||
public function onSuccess(Request $request)
|
||||
public function onSuccess()
|
||||
{
|
||||
if (false === static::isValidAuthenticationBackend($this)) {
|
||||
return false;
|
||||
|
@ -2,19 +2,18 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form\Config;
|
||||
namespace Icinga\Forms\Config;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Form\ConfigForm;
|
||||
use Icinga\Forms\ConfigForm;
|
||||
use Icinga\Web\Notification;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Platform;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Form\Config\Authentication\DbBackendForm;
|
||||
use Icinga\Form\Config\Authentication\LdapBackendForm;
|
||||
use Icinga\Form\Config\Authentication\AutologinBackendForm;
|
||||
use Icinga\Forms\Config\Authentication\DbBackendForm;
|
||||
use Icinga\Forms\Config\Authentication\LdapBackendForm;
|
||||
use Icinga\Forms\Config\Authentication\AutologinBackendForm;
|
||||
|
||||
class AuthenticationBackendConfigForm extends ConfigForm
|
||||
{
|
||||
@ -192,7 +191,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
||||
*
|
||||
* @see Form::onSuccess()
|
||||
*/
|
||||
public function onSuccess(Request $request)
|
||||
public function onSuccess()
|
||||
{
|
||||
if (($el = $this->getElement('force_creation')) === null || false === $el->isChecked()) {
|
||||
$backendForm = $this->getBackendForm($this->getElement('type')->getValue());
|
||||
@ -202,7 +201,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
||||
}
|
||||
}
|
||||
|
||||
$authBackend = $request->getQuery('auth_backend');
|
||||
$authBackend = $this->request->getQuery('auth_backend');
|
||||
try {
|
||||
if ($authBackend === null) { // create new backend
|
||||
$this->add($this->getValues());
|
||||
@ -230,9 +229,9 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
||||
*
|
||||
* @throws ConfigurationError In case the backend name is missing in the request or is invalid
|
||||
*/
|
||||
public function onRequest(Request $request)
|
||||
public function onRequest()
|
||||
{
|
||||
$authBackend = $request->getQuery('auth_backend');
|
||||
$authBackend = $this->request->getQuery('auth_backend');
|
||||
if ($authBackend !== null) {
|
||||
if ($authBackend === '') {
|
||||
throw new ConfigurationError(t('Authentication backend name missing'));
|
||||
|
@ -2,12 +2,11 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form\Config;
|
||||
namespace Icinga\Forms\Config;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Web\Notification;
|
||||
use Icinga\Form\ConfigForm;
|
||||
use Icinga\Forms\ConfigForm;
|
||||
|
||||
class AuthenticationBackendReorderForm extends ConfigForm
|
||||
{
|
||||
@ -30,17 +29,26 @@ class AuthenticationBackendReorderForm extends ConfigForm
|
||||
return $this->config->keys();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Form::createElements()
|
||||
*/
|
||||
public function createElements(array $formData)
|
||||
{
|
||||
// This adds just a dummy element to be able to utilize Form::getValue as part of onSuccess()
|
||||
$this->addElement('hidden', 'backend_newpos');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the authentication backend order and save the configuration
|
||||
*
|
||||
* @see Form::onSuccess()
|
||||
*/
|
||||
public function onSuccess(Request $request)
|
||||
public function onSuccess()
|
||||
{
|
||||
$formData = $this->getRequestData($request);
|
||||
if (isset($formData['backend_newpos'])) {
|
||||
$newPosData = $this->getValue('backend_newpos');
|
||||
if ($newPosData) {
|
||||
$configForm = $this->getConfigForm();
|
||||
list($backendName, $position) = explode('|', $formData['backend_newpos'], 2);
|
||||
list($backendName, $position) = explode('|', $newPosData, 2);
|
||||
|
||||
try {
|
||||
if ($configForm->move($backendName, $position)->save()) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form\Config\General;
|
||||
namespace Icinga\Forms\Config\General;
|
||||
|
||||
use DateTimeZone;
|
||||
use Icinga\Application\Icinga;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form\Config\General;
|
||||
namespace Icinga\Forms\Config\General;
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Logger;
|
||||
|
@ -2,13 +2,12 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form\Config;
|
||||
namespace Icinga\Forms\Config;
|
||||
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Web\Notification;
|
||||
use Icinga\Form\ConfigForm;
|
||||
use Icinga\Form\Config\General\LoggingConfigForm;
|
||||
use Icinga\Form\Config\General\ApplicationConfigForm;
|
||||
use Icinga\Forms\ConfigForm;
|
||||
use Icinga\Forms\Config\General\LoggingConfigForm;
|
||||
use Icinga\Forms\Config\General\ApplicationConfigForm;
|
||||
|
||||
/**
|
||||
* Form class for application-wide and logging specific settings
|
||||
@ -38,7 +37,7 @@ class GeneralConfigForm extends ConfigForm
|
||||
/**
|
||||
* @see Form::onSuccess()
|
||||
*/
|
||||
public function onSuccess(Request $request)
|
||||
public function onSuccess()
|
||||
{
|
||||
$sections = array();
|
||||
foreach ($this->getValues() as $sectionAndPropertyName => $value) {
|
||||
@ -62,7 +61,7 @@ class GeneralConfigForm extends ConfigForm
|
||||
/**
|
||||
* @see Form::onRequest()
|
||||
*/
|
||||
public function onRequest(Request $request)
|
||||
public function onRequest()
|
||||
{
|
||||
$values = array();
|
||||
foreach ($this->config as $section => $properties) {
|
||||
|
@ -2,13 +2,11 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form\Config\Resource;
|
||||
namespace Icinga\Forms\Config\Resource;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Web\Form\Element\Number;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Application\Platform;
|
||||
|
||||
@ -68,14 +66,13 @@ class DbResourceForm extends Form
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Number(
|
||||
array(
|
||||
'required' => true,
|
||||
'name' => 'port',
|
||||
'label' => t('Port'),
|
||||
'description' => t('The port to use'),
|
||||
'value' => 3306
|
||||
)
|
||||
'number',
|
||||
'port',
|
||||
array(
|
||||
'required' => true,
|
||||
'label' => t('Port'),
|
||||
'description' => t('The port to use'),
|
||||
'value' => 3306
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
@ -115,7 +112,7 @@ class DbResourceForm extends Form
|
||||
*
|
||||
* @see Form::onSuccess()
|
||||
*/
|
||||
public function onSuccess(Request $request)
|
||||
public function onSuccess()
|
||||
{
|
||||
if (false === static::isValidResource($this)) {
|
||||
return false;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form\Config\Resource;
|
||||
namespace Icinga\Forms\Config\Resource;
|
||||
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Form\Validator\ReadablePathValidator;
|
||||
|
@ -2,13 +2,11 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form\Config\Resource;
|
||||
namespace Icinga\Forms\Config\Resource;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Web\Form\Element\Number;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
|
||||
/**
|
||||
@ -49,14 +47,13 @@ class LdapResourceForm extends Form
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Number(
|
||||
array(
|
||||
'required' => true,
|
||||
'name' => 'port',
|
||||
'label' => t('Port'),
|
||||
'description' => t('The port of the LDAP server to use for authentication'),
|
||||
'value' => 389
|
||||
)
|
||||
'number',
|
||||
'port',
|
||||
array(
|
||||
'required' => true,
|
||||
'label' => t('Port'),
|
||||
'description' => t('The port of the LDAP server to use for authentication'),
|
||||
'value' => 389
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
@ -96,7 +93,7 @@ class LdapResourceForm extends Form
|
||||
*
|
||||
* @see Form::onSuccess()
|
||||
*/
|
||||
public function onSuccess(Request $request)
|
||||
public function onSuccess()
|
||||
{
|
||||
if (false === static::isValidResource($this)) {
|
||||
return false;
|
||||
|
@ -2,12 +2,11 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form\Config\Resource;
|
||||
namespace Icinga\Forms\Config\Resource;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
|
||||
@ -57,7 +56,7 @@ class LivestatusResourceForm extends Form
|
||||
*
|
||||
* @see Form::onSuccess()
|
||||
*/
|
||||
public function onSuccess(Request $request)
|
||||
public function onSuccess()
|
||||
{
|
||||
if (false === static::isValidResource($this)) {
|
||||
return false;
|
||||
|
@ -2,16 +2,15 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form\Config;
|
||||
namespace Icinga\Forms\Config;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Web\Notification;
|
||||
use Icinga\Form\ConfigForm;
|
||||
use Icinga\Form\Config\Resource\DbResourceForm;
|
||||
use Icinga\Form\Config\Resource\FileResourceForm;
|
||||
use Icinga\Form\Config\Resource\LdapResourceForm;
|
||||
use Icinga\Form\Config\Resource\LivestatusResourceForm;
|
||||
use Icinga\Forms\ConfigForm;
|
||||
use Icinga\Forms\Config\Resource\DbResourceForm;
|
||||
use Icinga\Forms\Config\Resource\FileResourceForm;
|
||||
use Icinga\Forms\Config\Resource\LdapResourceForm;
|
||||
use Icinga\Forms\Config\Resource\LivestatusResourceForm;
|
||||
use Icinga\Application\Platform;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
|
||||
@ -128,7 +127,7 @@ class ResourceConfigForm extends ConfigForm
|
||||
*
|
||||
* @see Form::onSuccess()
|
||||
*/
|
||||
public function onSuccess(Request $request)
|
||||
public function onSuccess()
|
||||
{
|
||||
if (($el = $this->getElement('force_creation')) === null || false === $el->isChecked()) {
|
||||
$resourceForm = $this->getResourceForm($this->getElement('type')->getValue());
|
||||
@ -138,7 +137,7 @@ class ResourceConfigForm extends ConfigForm
|
||||
}
|
||||
}
|
||||
|
||||
$resource = $request->getQuery('resource');
|
||||
$resource = $this->request->getQuery('resource');
|
||||
try {
|
||||
if ($resource === null) { // create new resource
|
||||
$this->add($this->getValues());
|
||||
@ -166,9 +165,9 @@ class ResourceConfigForm extends ConfigForm
|
||||
*
|
||||
* @throws ConfigurationError In case the backend name is missing in the request or is invalid
|
||||
*/
|
||||
public function onRequest(Request $request)
|
||||
public function onRequest()
|
||||
{
|
||||
$resource = $request->getQuery('resource');
|
||||
$resource = $this->request->getQuery('resource');
|
||||
if ($resource !== null) {
|
||||
if ($resource === '') {
|
||||
throw new ConfigurationError(t('Resource name missing'));
|
||||
|
@ -2,7 +2,7 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form;
|
||||
namespace Icinga\Forms;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Web\Form;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form;
|
||||
namespace Icinga\Forms;
|
||||
|
||||
use Icinga\Web\Form;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form\Dashboard;
|
||||
namespace Icinga\Forms\Dashboard;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Web\Widget\Dashboard;
|
||||
|
@ -1,13 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Form;
|
||||
namespace Icinga\Forms;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Protocol\Ldap\Exception as LdapException;
|
||||
use Icinga\Protocol\Ldap\Connection;
|
||||
use Icinga\Protocol\Dns;
|
||||
use Icinga\Web\Form\Element\Note;
|
||||
use Icinga\Web\Form;
|
||||
|
||||
/**
|
||||
@ -68,13 +67,12 @@ class LdapDiscoveryForm extends Form
|
||||
|
||||
if (false) {
|
||||
$this->addElement(
|
||||
new Note(
|
||||
'additional_description',
|
||||
array(
|
||||
'value' => t('No Ldap servers found on this domain.'
|
||||
. ' You can try to specify host and port and try again, or just skip this step and '
|
||||
. 'configure the server manually.'
|
||||
)
|
||||
'note',
|
||||
'additional_description',
|
||||
array(
|
||||
'value' => t('No Ldap servers found on this domain.'
|
||||
. ' You can try to specify host and port and try again, or just skip this step and '
|
||||
. 'configure the server manually.'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -2,7 +2,7 @@
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form;
|
||||
namespace Icinga\Forms;
|
||||
|
||||
use Exception;
|
||||
use DateTimeZone;
|
||||
@ -12,10 +12,8 @@ use Icinga\User\Preferences;
|
||||
use Icinga\User\Preferences\PreferencesStore;
|
||||
use Icinga\Util\TimezoneDetect;
|
||||
use Icinga\Util\Translator;
|
||||
use Icinga\Web\Controller\ControllerTabCollector;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Notification;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Web\Session;
|
||||
|
||||
/**
|
||||
@ -86,7 +84,7 @@ class PreferenceForm extends Form
|
||||
*
|
||||
* @see Form::onSuccess()
|
||||
*/
|
||||
public function onSuccess(Request $request)
|
||||
public function onSuccess()
|
||||
{
|
||||
$this->preferences = new Preferences($this->store->load());
|
||||
|
||||
@ -122,7 +120,7 @@ class PreferenceForm extends Form
|
||||
*
|
||||
* @see Form::onRequest()
|
||||
*/
|
||||
public function onRequest(Request $request)
|
||||
public function onRequest()
|
||||
{
|
||||
$auth = Manager::getInstance();
|
||||
$values = $auth->getUser()->getPreferences()->get('icingaweb');
|
||||
@ -237,7 +235,7 @@ class PreferenceForm extends Form
|
||||
if ($detect->success()) {
|
||||
return $detect->getTimezoneName();
|
||||
} else {
|
||||
return date_default_timezone_get();
|
||||
return @date_default_timezone_get();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,198 +0,0 @@
|
||||
# The Container Component (app/container)
|
||||
|
||||
The container component is the most basic building block for icingaweb. Even when displaying an empty controller,
|
||||
you always have at least two containers in your viewport which are implicitly created: The main and the detail container.
|
||||
|
||||
Container handle the following tasks:
|
||||
|
||||
* Updating the url part responsible for the container
|
||||
* Handling Url changes like they occur when the browser history is used by synchronizing their content with the
|
||||
associated Url part
|
||||
* Informing subcomponents about changes in the container
|
||||
|
||||
|
||||
## The Container Api
|
||||
|
||||
You can find the sourcecode for containers along with jsdoc comments at *./public/js/icinga/components/container.js*.
|
||||
Here we will discuss the most important calls and their synopsis:
|
||||
|
||||
### Accessing Containers:
|
||||
|
||||
The container component returns a 'Container' object which allows you to access responsible containers for dom nodes via
|
||||
the following methods:
|
||||
|
||||
* using `new Container($myDomNodes)` which returns a stateless container object wrapping the container responsible for
|
||||
the first node in $myDomNodes
|
||||
* using `Container.getMainContainer()` or `Container.getDetailContainer()` which remove the main or detail container
|
||||
(this one is stateful with a few notes, read on)
|
||||
|
||||
**Note:** `new Container($('#icingamain')) != Container.getMainContainer()`, but
|
||||
`(new Container($('#icingamain'))).containerDom == Container.getMainContainer().containerDom`
|
||||
|
||||
** Example #1 getting the container responsible for a dom node **
|
||||
|
||||
**HTML**
|
||||
|
||||
<div id="icingamain">
|
||||
<div class="myNode">
|
||||
Some kind of node
|
||||
</div>
|
||||
<div id="somecontainer" data-icinga-component="app/container">
|
||||
<div class="mySecondNode">
|
||||
Some other kind of node
|
||||
<p>
|
||||
Insert your lorem ipsum here
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
**JS**:
|
||||
|
||||
require(['jquery', 'app/container'], function($, Container) {
|
||||
var firstContainer = new Container($('.myNode')); // firstContainer wraps '#icingamain'
|
||||
var mainContainer = Container.getMainContainer(); // also wraps '#icingamain'
|
||||
var secondContainer = new Container($('.myNode p')); // #somecontainer is wrapped by secondContainer
|
||||
|
||||
firstContainer.someProperty = 'What a nice property!';
|
||||
mainContainer.someState = 'I have some state';
|
||||
console.log(firstContainer.someProperty); // return 'What a nice property'
|
||||
console.log(main.someProperty); // return 'undefined'
|
||||
console.log(Container.getMainContainer().someState) // return 'I have some state' when page hasn't been refreshed
|
||||
});
|
||||
|
||||
## Containers And The Browser Url
|
||||
|
||||
As noted before (and indicated by the `getMainContainer()` and `getDetailContainer()` function), the main and detail
|
||||
container have a special role. Considering the following Url:
|
||||
|
||||
http://my.monitoringhost.org/icingaweb/monitoring/list/host?page=4&detail=%2Fmonitoring%2Fshow%2Fhost%3Fhost%3Dlocalhost
|
||||
|
||||
This URL displays the 4th page of your host list in the main container (monitoring/list/host?page=4) and the host information
|
||||
for localhost in the detail container (monitoring/show/host?host=localhost). When you split this Url up in logical pieces
|
||||
it looks like this:
|
||||
|
||||
http://my.monitoringhost.org/icingaweb/monitoring/list/host?page=4&detail=%2Fmonitoring%2Fshow%2Fhost%3Fhost%3Dlocalhost
|
||||
\___________ _______________________/\_________ ______________/ \_ ____/\________________ _______________________/
|
||||
\/ \/ \/ \/
|
||||
1. Base URL 2.Main container URL and Query 3.Detail param 4. Encoded detail URL and params
|
||||
|
||||
1. **Base URL** : I don't think this needs much explanation.
|
||||
2. **Main container URL and query** : This is the *normal* part of your Url and denotes the controller route that is
|
||||
being displayed in your main container
|
||||
3. **Detail parameter**: This parameter will be ignored by the main container and used for rendering the detail container,
|
||||
if omitted there's simple no detail view to be displayed
|
||||
4 **Encoded detail URL**: The value of the "detail" parameter is the Url (without the base Url) that returns the content
|
||||
of the detail area
|
||||
|
||||
|
||||
### Updating A Container's Url
|
||||
|
||||
If you want your container to display content from a different Url, you can use the *replaceDomFromUrl()* on your
|
||||
Container object:
|
||||
|
||||
**Example #2 Updating A Containers URL**
|
||||
|
||||
**HTML:**
|
||||
|
||||
<div id="icingamain">
|
||||
<div id"mainSub"></div>
|
||||
</div>
|
||||
<div id="icingadetail">
|
||||
<div id"detailSub"></div>
|
||||
</div>
|
||||
|
||||
**JS:**
|
||||
|
||||
// this loads the page with the new main container
|
||||
require(['jquery', 'app/container'], function($, Container) {
|
||||
new Container('#mainSub').replaceDomFormUrl('/another/url');
|
||||
}
|
||||
|
||||
// this loads the page with the new detail container
|
||||
require(['jquery', 'app/container'], function($, Container) {
|
||||
new Container('#detailSub').replaceDomFormUrl('/another/url');
|
||||
}
|
||||
|
||||
// this does NOT work:
|
||||
require(['jquery', 'app/container'], function($, Container) {
|
||||
Container.getMainContainer().replaceDomFormUrl('/another/url');
|
||||
// will never be reached due to a reload
|
||||
Container.getMainContainer().replaceDomFormUrl('/another/url2');
|
||||
}
|
||||
|
||||
// this loads the page with both main and detail changed (this is rarely needed and should be avoided)
|
||||
require(['icinga', 'jquery', 'app/container'], function('Icinga', $, Container) {
|
||||
// it's better to use this:
|
||||
var mainContainer = Container.getMainContainer();
|
||||
var detailContainer = Container.getDetailContainer();
|
||||
|
||||
mainContainer.updateContainerHref('/another/url'); // first update the main container href
|
||||
detailContainer.updateContainerHref('/another/url2'); // update the detail href
|
||||
|
||||
var url = mainContainer.getContainerHref(detailContainer.getContainerHref()); // fetch the new url
|
||||
Icinga.replaceBodyFromUrl(url); // and update manual
|
||||
}
|
||||
|
||||
This results in the URL changing to './another/url?detail=%2Fanother%2Fdetail%2Furl.
|
||||
The advantage of using a Container instance with the subelements (i.e. '\#mainSub') over calling getMain/DetailContainer
|
||||
directly is that you don't need to know in what container your view is displayed - when you move 'mainSub' into the
|
||||
detail container, the detail container would be updated afterwards.
|
||||
|
||||
**NOTE**: You should read the '...' section in order to understand why you shouldn't do it like in this example
|
||||
|
||||
### How container refresh states are handled
|
||||
|
||||
If you refresh containers content (load url or replace dom), the container displaya a loading
|
||||
mask as default behaviour. To disable this mask and handle it yourself, you can register own events:
|
||||
|
||||
**Example #3 Load indicator events**
|
||||
|
||||
require(['icinga', 'jquery', 'app/container'], function('Icinga', $, Container) {
|
||||
var mainContainer = Container.getMainContainer();
|
||||
|
||||
// Detach the default behaviour from container
|
||||
mainContainer.removeDefaultLoadIndicator();
|
||||
|
||||
var showFunction = function() {
|
||||
console.log('container is loading');
|
||||
};
|
||||
|
||||
var hideFunction = function() {
|
||||
console.log('container content refreshed');
|
||||
};
|
||||
|
||||
// Install new handlers
|
||||
mainContainer.registerOnShowLoadIndicator(showFunction);
|
||||
mainContainer.registerOnHideLoadIndicator(hideFunction);
|
||||
};
|
||||
|
||||
**Example #4 Use this for your components**
|
||||
|
||||
Please have a look into [components documentation](components.md) for detailed information about components.
|
||||
|
||||
define(['components/app/container', 'jquery', 'logging', 'URIjs/URI', 'URIjs/URITemplate'],
|
||||
function(Container, $, logger, URI) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Master/Detail grid component handling history, link behaviour, selection (@TODO 3788) and updates of
|
||||
* grids
|
||||
*
|
||||
* @param {HTMLElement} The outer element to apply the behaviour on
|
||||
*/
|
||||
return function(gridDomNode) {
|
||||
/**
|
||||
* Constructor method for this component
|
||||
*/
|
||||
this.construct = function(target) {
|
||||
// Container object for the component
|
||||
this.container = new Container(target);
|
||||
|
||||
// Detach default handlers
|
||||
this.container.removeDefaultLoadIndicator();
|
||||
};
|
||||
|
||||
this.construct(gridDomNode);
|
||||
};
|
||||
};
|
@ -31,7 +31,7 @@
|
||||
%define prefixdir %{_datadir}/%{name}
|
||||
%define usermodparam -a -G
|
||||
%define logdir %{_localstatedir}/log/%{name}
|
||||
%define docdir %{sharedir}/log
|
||||
%define docdir %{sharedir}/doc
|
||||
|
||||
%if "%{_vendor}" == "suse"
|
||||
%define phpname php5
|
||||
@ -179,7 +179,8 @@ install -D -m0644 packages/rpm/etc/httpd/conf.d/icingaweb.conf %{buildroot}/%{ap
|
||||
%{__mkdir} -p %{buildroot}/%{_sysconfdir}/%{name}/modules/monitoring
|
||||
%{__mkdir} -p %{buildroot}/%{_sysconfdir}/%{name}/enabledModules
|
||||
|
||||
%{__cp} -r application doc library modules public %{buildroot}/%{sharedir}/
|
||||
# make sure to install local icingacli for setup wizard token generation & webserver config
|
||||
%{__cp} -r application doc library modules public bin %{buildroot}/%{sharedir}/
|
||||
|
||||
## config
|
||||
# authentication is db only
|
||||
@ -194,8 +195,8 @@ install -D -m0644 packages/rpm/etc/%{name}/modules/monitoring/instances.ini %{bu
|
||||
ln -s %{sharedir}/modules/monitoring %{buildroot}/%{_sysconfdir}/%{name}/enabledModules/monitoring
|
||||
## config
|
||||
|
||||
# install icingacli
|
||||
install -D -m0755 packages/rpm/usr/bin/icingacli %{buildroot}/usr/bin/icingacli
|
||||
# symlink icingacli
|
||||
ln -sf %{buildroot}/%{sharedir}/bin/icingacli %{buildroot}/usr/bin/icingacli
|
||||
|
||||
%pre
|
||||
# Add apacheuser in the icingacmd group
|
||||
|
@ -13,7 +13,6 @@ use Icinga\Exception\NotReadableError;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Util\DateTimeFactory;
|
||||
use Icinga\Util\Translator;
|
||||
use Icinga\Util\TimezoneDetect;
|
||||
use Icinga\Exception\IcingaException;
|
||||
|
||||
/**
|
||||
@ -139,7 +138,6 @@ abstract class ApplicationBootstrap
|
||||
$this->configDir = $canonical ? $canonical : $configDir;
|
||||
|
||||
$this->setupAutoloader();
|
||||
$this->setupZendAutoloader();
|
||||
|
||||
set_include_path(
|
||||
implode(
|
||||
@ -277,6 +275,18 @@ abstract class ApplicationBootstrap
|
||||
return $this->getDirWithSubDir($this->configDir, $subDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Icinga library directory
|
||||
*
|
||||
* @param string $subDir Optional sub directory to get
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLibraryDir($subDir = null)
|
||||
{
|
||||
return $this->getDirWithSubDir($this->libDir, $subDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the bootstrapping directory
|
||||
*
|
||||
@ -323,7 +333,7 @@ abstract class ApplicationBootstrap
|
||||
/**
|
||||
* Register the Zend Autoloader
|
||||
*
|
||||
* @return self
|
||||
* @return $this
|
||||
*/
|
||||
protected function setupZendAutoloader()
|
||||
{
|
||||
@ -331,17 +341,12 @@ abstract class ApplicationBootstrap
|
||||
|
||||
\Zend_Loader_Autoloader::getInstance();
|
||||
|
||||
// Unfortunately this is needed to get the Zend Plugin loader working:
|
||||
set_include_path(
|
||||
implode(
|
||||
PATH_SEPARATOR,
|
||||
array($this->libDir, get_include_path())
|
||||
)
|
||||
\Zend_Paginator::addScrollingStylePrefixPath(
|
||||
'Icinga_Web_Paginator_ScrollingStyle_', $this->libDir . '/Icinga/Web/Paginator/ScrollingStyle'
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup module manager
|
||||
*
|
||||
|
@ -27,7 +27,9 @@ class EmbeddedWeb extends ApplicationBootstrap
|
||||
*/
|
||||
protected function bootstrap()
|
||||
{
|
||||
return $this->loadConfig()
|
||||
return $this
|
||||
->setupZendAutoloader()
|
||||
->loadConfig()
|
||||
->setupErrorHandling()
|
||||
->setupTimezone()
|
||||
->setupModuleManager()
|
||||
|
@ -763,7 +763,7 @@ class Module
|
||||
$this->app->getLoader()->registerNamespace('Icinga\\Module\\' . $moduleName, $moduleLibraryDir);
|
||||
if (is_dir($this->getFormDir())) {
|
||||
$this->app->getLoader()->registerNamespace(
|
||||
'Icinga\\Module\\' . $moduleName. '\\Form',
|
||||
'Icinga\\Module\\' . $moduleName. '\\Forms',
|
||||
$this->getFormDir()
|
||||
);
|
||||
}
|
||||
|
@ -90,6 +90,7 @@ class Web extends ApplicationBootstrap
|
||||
protected function bootstrap()
|
||||
{
|
||||
return $this
|
||||
->setupZendAutoloader()
|
||||
->setupLogging()
|
||||
->setupErrorHandling()
|
||||
->loadConfig()
|
||||
@ -326,14 +327,14 @@ class Web extends ApplicationBootstrap
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup an autoloader namespace for Icinga\Form
|
||||
* Setup an autoloader namespace for Icinga\Forms
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
private function setupFormNamespace()
|
||||
{
|
||||
$this->getLoader()->registerNamespace(
|
||||
'Icinga\\Form',
|
||||
'Icinga\\Forms',
|
||||
$this->getApplicationDir('forms')
|
||||
);
|
||||
return $this;
|
||||
|
@ -66,7 +66,7 @@ class Loader
|
||||
public function __construct(App $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->coreAppDir = $app->getBaseDir('clicommands');
|
||||
$this->coreAppDir = $app->getApplicationDir('clicommands');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,6 +11,7 @@ use Zend_View_Interface;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Web\Form\Decorator\NoScriptApply;
|
||||
use Icinga\Web\Form\Element\CsrfCounterMeasure;
|
||||
use Icinga\Web\Form\FormElement;
|
||||
|
||||
/**
|
||||
* Base class for forms providing CSRF protection, confirmation logic and auto submission
|
||||
@ -36,6 +37,13 @@ class Form extends Zend_Form
|
||||
*/
|
||||
protected $created = false;
|
||||
|
||||
/**
|
||||
* The request associated with this form
|
||||
*
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* The callback to call instead of Form::onSuccess()
|
||||
*
|
||||
@ -111,7 +119,7 @@ class Form extends Zend_Form
|
||||
* Create a new form
|
||||
*
|
||||
* Accepts an additional option `onSuccess' which is a callback that is called instead of this
|
||||
* form's method. It is called using the following signature: (Request $request, Form $form).
|
||||
* form's method. It is called using the following signature: (Form $form).
|
||||
*
|
||||
* @see Zend_Form::__construct()
|
||||
*
|
||||
@ -355,11 +363,9 @@ class Form extends Zend_Form
|
||||
*
|
||||
* Intended to be implemented by concrete form classes. The base implementation returns always FALSE.
|
||||
*
|
||||
* @param Request $request The valid request used to process this form
|
||||
*
|
||||
* @return null|bool Return FALSE in case no redirect should take place
|
||||
*/
|
||||
public function onSuccess(Request $request)
|
||||
public function onSuccess()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -368,10 +374,8 @@ class Form extends Zend_Form
|
||||
* Perform actions when no form dependent data was sent
|
||||
*
|
||||
* Intended to be implemented by concrete form classes.
|
||||
*
|
||||
* @param Request $request The current request
|
||||
*/
|
||||
public function onRequest(Request $request)
|
||||
public function onRequest()
|
||||
{
|
||||
|
||||
}
|
||||
@ -437,8 +441,8 @@ class Form extends Zend_Form
|
||||
* `disableLoadDefaultDecorators' option to any other value than `true'. For loading custom element decorators use
|
||||
* the 'decorators' option.
|
||||
*
|
||||
* @param string $type String element type
|
||||
* @param string $name The name of the element to add
|
||||
* @param string $type The type of the element
|
||||
* @param string $name The name of the element
|
||||
* @param mixed $options The options for the element
|
||||
*
|
||||
* @return Zend_Form_Element
|
||||
@ -460,7 +464,9 @@ class Form extends Zend_Form
|
||||
$options = array('decorators' => static::$defaultElementDecorators);
|
||||
}
|
||||
|
||||
$el = parent::createElement($type, $name, $options);
|
||||
if (($el = $this->createIcingaFormElement($type, $name, $options)) === null) {
|
||||
$el = parent::createElement($type, $name, $options);
|
||||
}
|
||||
|
||||
if ($el && $el->getAttrib('autosubmit')) {
|
||||
$noScript = new NoScriptApply(); // Non-JS environments
|
||||
@ -549,15 +555,17 @@ class Form extends Zend_Form
|
||||
{
|
||||
if ($request === null) {
|
||||
$request = $this->getRequest();
|
||||
} else {
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
$formData = $this->getRequestData($request);
|
||||
$formData = $this->getRequestData();
|
||||
if ($this->getUidDisabled() || $this->wasSent($formData)) {
|
||||
$this->populate($formData); // Necessary to get isSubmitted() to work
|
||||
if (! $this->getSubmitLabel() || $this->isSubmitted()) {
|
||||
if ($this->isValid($formData)
|
||||
&& (($this->onSuccess !== null && false !== call_user_func($this->onSuccess, $request, $this))
|
||||
|| ($this->onSuccess === null && false !== $this->onSuccess($request)))) {
|
||||
&& (($this->onSuccess !== null && false !== call_user_func($this->onSuccess, $this))
|
||||
|| ($this->onSuccess === null && false !== $this->onSuccess()))) {
|
||||
$this->getResponse()->redirectAndExit($this->getRedirectUrl());
|
||||
}
|
||||
} else {
|
||||
@ -565,7 +573,7 @@ class Form extends Zend_Form
|
||||
$this->isValidPartial($formData);
|
||||
}
|
||||
} else {
|
||||
$this->onRequest($request);
|
||||
$this->onRequest();
|
||||
}
|
||||
|
||||
return $request;
|
||||
@ -691,29 +699,19 @@ class Form extends Zend_Form
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the request data based on this form's request method
|
||||
* Return the request associated with this form
|
||||
*
|
||||
* @param Request $request The request to fetch the data from
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRequestData(Request $request)
|
||||
{
|
||||
if (strtolower($request->getMethod()) === $this->getMethod()) {
|
||||
return $request->{'get' . ($request->isPost() ? 'Post' : 'Query')}();
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current request
|
||||
* Returns the global request if none has been set for this form yet.
|
||||
*
|
||||
* @return Request
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return Icinga::app()->getFrontController()->getRequest();
|
||||
if ($this->request === null) {
|
||||
$this->request = Icinga::app()->getFrontController()->getRequest();
|
||||
}
|
||||
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -726,6 +724,39 @@ class Form extends Zend_Form
|
||||
return Icinga::app()->getFrontController()->getResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the request data based on this form's request method
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getRequestData()
|
||||
{
|
||||
if (strtolower($this->request->getMethod()) === $this->getMethod()) {
|
||||
return $this->request->{'get' . ($this->request->isPost() ? 'Post' : 'Query')}();
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new element located in the Icinga Web 2 library
|
||||
*
|
||||
* @param string $type The type of the element
|
||||
* @param string $name The name of the element
|
||||
* @param mixed $options The options for the element
|
||||
*
|
||||
* @return NULL|FormElement NULL in case the element is not found in the Icinga Web 2 library
|
||||
*
|
||||
* @see Form::$defaultElementDecorators For Icinga Web 2's default element decorators.
|
||||
*/
|
||||
protected function createIcingaFormElement($type, $name, $options = null)
|
||||
{
|
||||
$className = 'Icinga\\Web\\Form\\Element\\' . ucfirst($type);
|
||||
if (class_exists($className)) {
|
||||
return new $className($name, $options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render this form
|
||||
*
|
||||
|
@ -4,14 +4,14 @@
|
||||
|
||||
namespace Icinga\Web\Form\Element;
|
||||
|
||||
use Zend_Form_Element;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Web\Form\FormElement;
|
||||
|
||||
/**
|
||||
* A button
|
||||
*/
|
||||
class Button extends Zend_Form_Element
|
||||
class Button extends FormElement
|
||||
{
|
||||
/**
|
||||
* Use formButton view helper by default
|
||||
|
@ -4,12 +4,12 @@
|
||||
|
||||
namespace Icinga\Web\Form\Element;
|
||||
|
||||
use Zend_Form_Element;
|
||||
use Icinga\Web\Form\FormElement;
|
||||
|
||||
/**
|
||||
* A note
|
||||
*/
|
||||
class Note extends Zend_Form_Element
|
||||
class Note extends FormElement
|
||||
{
|
||||
/**
|
||||
* Form view helper to use for rendering
|
||||
|
@ -118,7 +118,7 @@ class JavaScript
|
||||
}
|
||||
|
||||
if ($minified) {
|
||||
require_once 'IcingaVendor/JShrink/Minifier.php';
|
||||
require_once 'JShrink/Minifier.php';
|
||||
$out .= Minifier::minify($js, array('flaggedComments' => false));
|
||||
} else {
|
||||
$out .= $js;
|
||||
|
@ -41,7 +41,7 @@ class LessCompiler
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
require_once 'IcingaVendor/lessphp/lessc.inc.php';
|
||||
require_once 'lessphp/lessc.inc.php';
|
||||
$this->lessc = new lessc();
|
||||
|
||||
$this->lessc->setVariables(
|
||||
|
@ -73,28 +73,28 @@ EOD;
|
||||
*
|
||||
* @var int The value in px
|
||||
*/
|
||||
private $width = 28;
|
||||
private $width = 16;
|
||||
|
||||
/**
|
||||
* The height of the rendered chart
|
||||
*
|
||||
* @var int The value in px
|
||||
*/
|
||||
private $height = 28;
|
||||
private $height = 16;
|
||||
|
||||
/**
|
||||
* PieChart border width
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $borderWidth = 0;
|
||||
private $borderWidth = 1;
|
||||
|
||||
/**
|
||||
* The color of the border
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $borderColor = '#888';
|
||||
private $borderColor = '#fff';
|
||||
|
||||
/**
|
||||
* The title of the chart
|
||||
|
@ -8,7 +8,6 @@ use LogicException;
|
||||
use InvalidArgumentException;
|
||||
use Icinga\Web\Session\SessionNamespace;
|
||||
use Icinga\Web\Form\Decorator\ElementDoubler;
|
||||
use Icinga\Web\Form\Element\Button;
|
||||
|
||||
/**
|
||||
* Container and controller for form based wizards
|
||||
@ -208,7 +207,7 @@ class Wizard
|
||||
}
|
||||
|
||||
$this->setupPage($page, $request);
|
||||
$requestData = $page->getRequestData($request);
|
||||
$requestData = $this->getRequestData($page, $request);
|
||||
if ($page->wasSent($requestData)) {
|
||||
if (($requestedPage = $this->getRequestedPage($requestData)) !== null) {
|
||||
$isValid = false;
|
||||
@ -239,6 +238,23 @@ class Wizard
|
||||
return $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the request data based on given form's request method
|
||||
*
|
||||
* @param Form $page The page to fetch the data for
|
||||
* @param Request $request The request to fetch the data from
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getRequestData(Form $page, Request $request)
|
||||
{
|
||||
if (strtolower($request->getMethod()) === $page->getMethod()) {
|
||||
return $request->{'get' . ($request->isPost() ? 'Post' : 'Query')}();
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the requested page
|
||||
*
|
||||
@ -270,7 +286,7 @@ class Wizard
|
||||
$request = $currentPage->getRequest();
|
||||
}
|
||||
|
||||
$requestData = $currentPage->getRequestData($request);
|
||||
$requestData = $this->getRequestData($currentPage, $request);
|
||||
if (isset($requestData[static::BTN_NEXT])) {
|
||||
return static::FORWARD;
|
||||
} elseif (isset($requestData[static::BTN_PREV])) {
|
||||
@ -427,60 +443,55 @@ class Wizard
|
||||
$index = array_search($page, $pages, true);
|
||||
if ($index === 0) {
|
||||
$page->addElement(
|
||||
new Button(
|
||||
static::BTN_NEXT,
|
||||
array(
|
||||
'type' => 'submit',
|
||||
'value' => $pages[1]->getName(),
|
||||
'label' => t('Next'),
|
||||
'decorators' => array('ViewHelper')
|
||||
)
|
||||
'button',
|
||||
static::BTN_NEXT,
|
||||
array(
|
||||
'type' => 'submit',
|
||||
'value' => $pages[1]->getName(),
|
||||
'label' => t('Next'),
|
||||
'decorators' => array('ViewHelper')
|
||||
)
|
||||
);
|
||||
} elseif ($index < count($pages) - 1) {
|
||||
$page->addElement(
|
||||
new Button(
|
||||
static::BTN_PREV,
|
||||
array(
|
||||
'type' => 'submit',
|
||||
'value' => $pages[$index - 1]->getName(),
|
||||
'label' => t('Back'),
|
||||
'decorators' => array('ViewHelper')
|
||||
)
|
||||
'button',
|
||||
static::BTN_PREV,
|
||||
array(
|
||||
'type' => 'submit',
|
||||
'value' => $pages[$index - 1]->getName(),
|
||||
'label' => t('Back'),
|
||||
'decorators' => array('ViewHelper')
|
||||
)
|
||||
);
|
||||
$page->addElement(
|
||||
new Button(
|
||||
static::BTN_NEXT,
|
||||
array(
|
||||
'type' => 'submit',
|
||||
'value' => $pages[$index + 1]->getName(),
|
||||
'label' => t('Next'),
|
||||
'decorators' => array('ViewHelper')
|
||||
)
|
||||
'button',
|
||||
static::BTN_NEXT,
|
||||
array(
|
||||
'type' => 'submit',
|
||||
'value' => $pages[$index + 1]->getName(),
|
||||
'label' => t('Next'),
|
||||
'decorators' => array('ViewHelper')
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$page->addElement(
|
||||
new Button(
|
||||
static::BTN_PREV,
|
||||
array(
|
||||
'type' => 'submit',
|
||||
'value' => $pages[$index - 1]->getName(),
|
||||
'label' => t('Back'),
|
||||
'decorators' => array('ViewHelper')
|
||||
)
|
||||
'button',
|
||||
static::BTN_PREV,
|
||||
array(
|
||||
'type' => 'submit',
|
||||
'value' => $pages[$index - 1]->getName(),
|
||||
'label' => t('Back'),
|
||||
'decorators' => array('ViewHelper')
|
||||
)
|
||||
);
|
||||
$page->addElement(
|
||||
new Button(
|
||||
static::BTN_NEXT,
|
||||
array(
|
||||
'type' => 'submit',
|
||||
'value' => $page->getName(),
|
||||
'label' => t('Finish'),
|
||||
'decorators' => array('ViewHelper')
|
||||
)
|
||||
'button',
|
||||
static::BTN_NEXT,
|
||||
array(
|
||||
'type' => 'submit',
|
||||
'value' => $page->getName(),
|
||||
'label' => t('Finish'),
|
||||
'decorators' => array('ViewHelper')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
https://github.com/tedivm/JShrink/releases/tag/v1.0.0
|
@ -1,9 +0,0 @@
|
||||
|
||||
CREDITS
|
||||
|
||||
Almost everything written by Edward Z. Yang (Ambush Commander). Lots of thanks
|
||||
to the DevNetwork Community for their help (see docs/ref-devnetwork.html for
|
||||
more details), Feyd especially (namely IPv6 and optimization). Thanks to RSnake
|
||||
for letting me package his fantastic XSS cheatsheet for a smoketest.
|
||||
|
||||
vim: et sw=4 sts=4
|
@ -1,374 +0,0 @@
|
||||
|
||||
Install
|
||||
How to install HTML Purifier
|
||||
|
||||
HTML Purifier is designed to run out of the box, so actually using the
|
||||
library is extremely easy. (Although... if you were looking for a
|
||||
step-by-step installation GUI, you've downloaded the wrong software!)
|
||||
|
||||
While the impatient can get going immediately with some of the sample
|
||||
code at the bottom of this library, it's well worth reading this entire
|
||||
document--most of the other documentation assumes that you are familiar
|
||||
with these contents.
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
1. Compatibility
|
||||
|
||||
HTML Purifier is PHP 5 only, and is actively tested from PHP 5.0.5 and
|
||||
up. It has no core dependencies with other libraries. PHP
|
||||
4 support was deprecated on December 31, 2007 with HTML Purifier 3.0.0.
|
||||
HTML Purifier is not compatible with zend.ze1_compatibility_mode.
|
||||
|
||||
These optional extensions can enhance the capabilities of HTML Purifier:
|
||||
|
||||
* iconv : Converts text to and from non-UTF-8 encodings
|
||||
* bcmath : Used for unit conversion and imagecrash protection
|
||||
* tidy : Used for pretty-printing HTML
|
||||
|
||||
These optional libraries can enhance the capabilities of HTML Purifier:
|
||||
|
||||
* CSSTidy : Clean CSS stylesheets using %Core.ExtractStyleBlocks
|
||||
* Net_IDNA2 (PEAR) : IRI support using %Core.EnableIDNA
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
2. Reconnaissance
|
||||
|
||||
A big plus of HTML Purifier is its inerrant support of standards, so
|
||||
your web-pages should be standards-compliant. (They should also use
|
||||
semantic markup, but that's another issue altogether, one HTML Purifier
|
||||
cannot fix without reading your mind.)
|
||||
|
||||
HTML Purifier can process these doctypes:
|
||||
|
||||
* XHTML 1.0 Transitional (default)
|
||||
* XHTML 1.0 Strict
|
||||
* HTML 4.01 Transitional
|
||||
* HTML 4.01 Strict
|
||||
* XHTML 1.1
|
||||
|
||||
...and these character encodings:
|
||||
|
||||
* UTF-8 (default)
|
||||
* Any encoding iconv supports (with crippled internationalization support)
|
||||
|
||||
These defaults reflect what my choices would be if I were authoring an
|
||||
HTML document, however, what you choose depends on the nature of your
|
||||
codebase. If you don't know what doctype you are using, you can determine
|
||||
the doctype from this identifier at the top of your source code:
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
...and the character encoding from this code:
|
||||
|
||||
<meta http-equiv="Content-type" content="text/html;charset=ENCODING">
|
||||
|
||||
If the character encoding declaration is missing, STOP NOW, and
|
||||
read 'docs/enduser-utf8.html' (web accessible at
|
||||
http://htmlpurifier.org/docs/enduser-utf8.html). In fact, even if it is
|
||||
present, read this document anyway, as many websites specify their
|
||||
document's character encoding incorrectly.
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
3. Including the library
|
||||
|
||||
The procedure is quite simple:
|
||||
|
||||
require_once '/path/to/library/HTMLPurifier.auto.php';
|
||||
|
||||
This will setup an autoloader, so the library's files are only included
|
||||
when you use them.
|
||||
|
||||
Only the contents in the library/ folder are necessary, so you can remove
|
||||
everything else when using HTML Purifier in a production environment.
|
||||
|
||||
If you installed HTML Purifier via PEAR, all you need to do is:
|
||||
|
||||
require_once 'HTMLPurifier.auto.php';
|
||||
|
||||
Please note that the usual PEAR practice of including just the classes you
|
||||
want will not work with HTML Purifier's autoloading scheme.
|
||||
|
||||
Advanced users, read on; other users can skip to section 4.
|
||||
|
||||
Autoload compatibility
|
||||
----------------------
|
||||
|
||||
HTML Purifier attempts to be as smart as possible when registering an
|
||||
autoloader, but there are some cases where you will need to change
|
||||
your own code to accomodate HTML Purifier. These are those cases:
|
||||
|
||||
PHP VERSION IS LESS THAN 5.1.2, AND YOU'VE DEFINED __autoload
|
||||
Because spl_autoload_register() doesn't exist in early versions
|
||||
of PHP 5, HTML Purifier has no way of adding itself to the autoload
|
||||
stack. Modify your __autoload function to test
|
||||
HTMLPurifier_Bootstrap::autoload($class)
|
||||
|
||||
For example, suppose your autoload function looks like this:
|
||||
|
||||
function __autoload($class) {
|
||||
require str_replace('_', '/', $class) . '.php';
|
||||
return true;
|
||||
}
|
||||
|
||||
A modified version with HTML Purifier would look like this:
|
||||
|
||||
function __autoload($class) {
|
||||
if (HTMLPurifier_Bootstrap::autoload($class)) return true;
|
||||
require str_replace('_', '/', $class) . '.php';
|
||||
return true;
|
||||
}
|
||||
|
||||
Note that there *is* some custom behavior in our autoloader; the
|
||||
original autoloader in our example would work for 99% of the time,
|
||||
but would fail when including language files.
|
||||
|
||||
AN __autoload FUNCTION IS DECLARED AFTER OUR AUTOLOADER IS REGISTERED
|
||||
spl_autoload_register() has the curious behavior of disabling
|
||||
the existing __autoload() handler. Users need to explicitly
|
||||
spl_autoload_register('__autoload'). Because we use SPL when it
|
||||
is available, __autoload() will ALWAYS be disabled. If __autoload()
|
||||
is declared before HTML Purifier is loaded, this is not a problem:
|
||||
HTML Purifier will register the function for you. But if it is
|
||||
declared afterwards, it will mysteriously not work. This
|
||||
snippet of code (after your autoloader is defined) will fix it:
|
||||
|
||||
spl_autoload_register('__autoload')
|
||||
|
||||
Users should also be on guard if they use a version of PHP previous
|
||||
to 5.1.2 without an autoloader--HTML Purifier will define __autoload()
|
||||
for you, which can collide with an autoloader that was added by *you*
|
||||
later.
|
||||
|
||||
|
||||
For better performance
|
||||
----------------------
|
||||
|
||||
Opcode caches, which greatly speed up PHP initialization for scripts
|
||||
with large amounts of code (HTML Purifier included), don't like
|
||||
autoloaders. We offer an include file that includes all of HTML Purifier's
|
||||
files in one go in an opcode cache friendly manner:
|
||||
|
||||
// If /path/to/library isn't already in your include path, uncomment
|
||||
// the below line:
|
||||
// require '/path/to/library/HTMLPurifier.path.php';
|
||||
|
||||
require 'HTMLPurifier.includes.php';
|
||||
|
||||
Optional components still need to be included--you'll know if you try to
|
||||
use a feature and you get a class doesn't exists error! The autoloader
|
||||
can be used in conjunction with this approach to catch classes that are
|
||||
missing. Simply add this afterwards:
|
||||
|
||||
require 'HTMLPurifier.autoload.php';
|
||||
|
||||
Standalone version
|
||||
------------------
|
||||
|
||||
HTML Purifier has a standalone distribution; you can also generate
|
||||
a standalone file from the full version by running the script
|
||||
maintenance/generate-standalone.php . The standalone version has the
|
||||
benefit of having most of its code in one file, so parsing is much
|
||||
faster and the library is easier to manage.
|
||||
|
||||
If HTMLPurifier.standalone.php exists in the library directory, you
|
||||
can use it like this:
|
||||
|
||||
require '/path/to/HTMLPurifier.standalone.php';
|
||||
|
||||
This is equivalent to including HTMLPurifier.includes.php, except that
|
||||
the contents of standalone/ will be added to your path. To override this
|
||||
behavior, specify a new HTMLPURIFIER_PREFIX where standalone files can
|
||||
be found (usually, this will be one directory up, the "true" library
|
||||
directory in full distributions). Don't forget to set your path too!
|
||||
|
||||
The autoloader can be added to the end to ensure the classes are
|
||||
loaded when necessary; otherwise you can manually include them.
|
||||
To use the autoloader, use this:
|
||||
|
||||
require 'HTMLPurifier.autoload.php';
|
||||
|
||||
For advanced users
|
||||
------------------
|
||||
|
||||
HTMLPurifier.auto.php performs a number of operations that can be done
|
||||
individually. These are:
|
||||
|
||||
HTMLPurifier.path.php
|
||||
Puts /path/to/library in the include path. For high performance,
|
||||
this should be done in php.ini.
|
||||
|
||||
HTMLPurifier.autoload.php
|
||||
Registers our autoload handler HTMLPurifier_Bootstrap::autoload($class).
|
||||
|
||||
You can do these operations by yourself--in fact, you must modify your own
|
||||
autoload handler if you are using a version of PHP earlier than PHP 5.1.2
|
||||
(See "Autoload compatibility" above).
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
4. Configuration
|
||||
|
||||
HTML Purifier is designed to run out-of-the-box, but occasionally HTML
|
||||
Purifier needs to be told what to do. If you answer no to any of these
|
||||
questions, read on; otherwise, you can skip to the next section (or, if you're
|
||||
into configuring things just for the heck of it, skip to 4.3).
|
||||
|
||||
* Am I using UTF-8?
|
||||
* Am I using XHTML 1.0 Transitional?
|
||||
|
||||
If you answered no to any of these questions, instantiate a configuration
|
||||
object and read on:
|
||||
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
|
||||
|
||||
4.1. Setting a different character encoding
|
||||
|
||||
You really shouldn't use any other encoding except UTF-8, especially if you
|
||||
plan to support multilingual websites (read section three for more details).
|
||||
However, switching to UTF-8 is not always immediately feasible, so we can
|
||||
adapt.
|
||||
|
||||
HTML Purifier uses iconv to support other character encodings, as such,
|
||||
any encoding that iconv supports <http://www.gnu.org/software/libiconv/>
|
||||
HTML Purifier supports with this code:
|
||||
|
||||
$config->set('Core.Encoding', /* put your encoding here */);
|
||||
|
||||
An example usage for Latin-1 websites (the most common encoding for English
|
||||
websites):
|
||||
|
||||
$config->set('Core.Encoding', 'ISO-8859-1');
|
||||
|
||||
Note that HTML Purifier's support for non-Unicode encodings is crippled by the
|
||||
fact that any character not supported by that encoding will be silently
|
||||
dropped, EVEN if it is ampersand escaped. If you want to work around
|
||||
this, you are welcome to read docs/enduser-utf8.html for a fix,
|
||||
but please be cognizant of the issues the "solution" creates (for this
|
||||
reason, I do not include the solution in this document).
|
||||
|
||||
|
||||
4.2. Setting a different doctype
|
||||
|
||||
For those of you using HTML 4.01 Transitional, you can disable
|
||||
XHTML output like this:
|
||||
|
||||
$config->set('HTML.Doctype', 'HTML 4.01 Transitional');
|
||||
|
||||
Other supported doctypes include:
|
||||
|
||||
* HTML 4.01 Strict
|
||||
* HTML 4.01 Transitional
|
||||
* XHTML 1.0 Strict
|
||||
* XHTML 1.0 Transitional
|
||||
* XHTML 1.1
|
||||
|
||||
|
||||
4.3. Other settings
|
||||
|
||||
There are more configuration directives which can be read about
|
||||
here: <http://htmlpurifier.org/live/configdoc/plain.html> They're a bit boring,
|
||||
but they can help out for those of you who like to exert maximum control over
|
||||
your code. Some of the more interesting ones are configurable at the
|
||||
demo <http://htmlpurifier.org/demo.php> and are well worth looking into
|
||||
for your own system.
|
||||
|
||||
For example, you can fine tune allowed elements and attributes, convert
|
||||
relative URLs to absolute ones, and even autoparagraph input text! These
|
||||
are, respectively, %HTML.Allowed, %URI.MakeAbsolute and %URI.Base, and
|
||||
%AutoFormat.AutoParagraph. The %Namespace.Directive naming convention
|
||||
translates to:
|
||||
|
||||
$config->set('Namespace.Directive', $value);
|
||||
|
||||
E.g.
|
||||
|
||||
$config->set('HTML.Allowed', 'p,b,a[href],i');
|
||||
$config->set('URI.Base', 'http://www.example.com');
|
||||
$config->set('URI.MakeAbsolute', true);
|
||||
$config->set('AutoFormat.AutoParagraph', true);
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
5. Caching
|
||||
|
||||
HTML Purifier generates some cache files (generally one or two) to speed up
|
||||
its execution. For maximum performance, make sure that
|
||||
library/HTMLPurifier/DefinitionCache/Serializer is writeable by the webserver.
|
||||
|
||||
If you are in the library/ folder of HTML Purifier, you can set the
|
||||
appropriate permissions using:
|
||||
|
||||
chmod -R 0755 HTMLPurifier/DefinitionCache/Serializer
|
||||
|
||||
If the above command doesn't work, you may need to assign write permissions
|
||||
to all. This may be necessary if your webserver runs as nobody, but is
|
||||
not recommended since it means any other user can write files in the
|
||||
directory. Use:
|
||||
|
||||
chmod -R 0777 HTMLPurifier/DefinitionCache/Serializer
|
||||
|
||||
You can also chmod files via your FTP client; this option
|
||||
is usually accessible by right clicking the corresponding directory and
|
||||
then selecting "chmod" or "file permissions".
|
||||
|
||||
Starting with 2.0.1, HTML Purifier will generate friendly error messages
|
||||
that will tell you exactly what you have to chmod the directory to, if in doubt,
|
||||
follow its advice.
|
||||
|
||||
If you are unable or unwilling to give write permissions to the cache
|
||||
directory, you can either disable the cache (and suffer a performance
|
||||
hit):
|
||||
|
||||
$config->set('Core.DefinitionCache', null);
|
||||
|
||||
Or move the cache directory somewhere else (no trailing slash):
|
||||
|
||||
$config->set('Cache.SerializerPath', '/home/user/absolute/path');
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
6. Using the code
|
||||
|
||||
The interface is mind-numbingly simple:
|
||||
|
||||
$purifier = new HTMLPurifier($config);
|
||||
$clean_html = $purifier->purify( $dirty_html );
|
||||
|
||||
That's it! For more examples, check out docs/examples/ (they aren't very
|
||||
different though). Also, docs/enduser-slow.html gives advice on what to
|
||||
do if HTML Purifier is slowing down your application.
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
7. Quick install
|
||||
|
||||
First, make sure library/HTMLPurifier/DefinitionCache/Serializer is
|
||||
writable by the webserver (see Section 5: Caching above for details).
|
||||
If your website is in UTF-8 and XHTML Transitional, use this code:
|
||||
|
||||
<?php
|
||||
require_once '/path/to/htmlpurifier/library/HTMLPurifier.auto.php';
|
||||
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$purifier = new HTMLPurifier($config);
|
||||
$clean_html = $purifier->purify($dirty_html);
|
||||
?>
|
||||
|
||||
If your website is in a different encoding or doctype, use this code:
|
||||
|
||||
<?php
|
||||
require_once '/path/to/htmlpurifier/library/HTMLPurifier.auto.php';
|
||||
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$config->set('Core.Encoding', 'ISO-8859-1'); // replace with your encoding
|
||||
$config->set('HTML.Doctype', 'HTML 4.01 Transitional'); // replace with your doctype
|
||||
$purifier = new HTMLPurifier($config);
|
||||
|
||||
$clean_html = $purifier->purify($dirty_html);
|
||||
?>
|
||||
|
||||
vim: et sw=4 sts=4
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user