mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
Merge remote-tracking branch 'origin/master' into feature/redesign-7144
This commit is contained in:
commit
b1f2a16305
@ -6,6 +6,7 @@ namespace Icinga\Application;
|
|||||||
|
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use LogicException;
|
||||||
use Icinga\Application\Modules\Manager as ModuleManager;
|
use Icinga\Application\Modules\Manager as ModuleManager;
|
||||||
use Icinga\Data\ResourceFactory;
|
use Icinga\Data\ResourceFactory;
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
@ -293,10 +294,24 @@ abstract class ApplicationBootstrap
|
|||||||
* This is usually /public for Web and EmbeddedWeb and /bin for the CLI
|
* This is usually /public for Web and EmbeddedWeb and /bin for the CLI
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
|
*
|
||||||
|
* @throws LogicException If the base directory can not be detected
|
||||||
*/
|
*/
|
||||||
public function getBootstrapDirectory()
|
public function getBootstrapDirectory()
|
||||||
{
|
{
|
||||||
return dirname(realpath($_SERVER['SCRIPT_FILENAME']));
|
$script = $_SERVER['SCRIPT_FILENAME'];
|
||||||
|
$canonical = realpath($script);
|
||||||
|
if ($canonical !== false) {
|
||||||
|
$dir = dirname($canonical);
|
||||||
|
} elseif (substr($script, -14) === '/webrouter.php') {
|
||||||
|
// If Icinga Web 2 is served using PHP's built-in webserver with our webrouter.php script, the $_SERVER
|
||||||
|
// variable SCRIPT_FILENAME is set to DOCUMENT_ROOT/webrouter.php which is not a valid path to
|
||||||
|
// realpath but DOCUMENT_ROOT here still is the bootstrapping directory
|
||||||
|
$dir = dirname($script);
|
||||||
|
} else {
|
||||||
|
throw new LogicException('Can\'t detected base directory');
|
||||||
|
}
|
||||||
|
return $dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -444,6 +459,7 @@ abstract class ApplicationBootstrap
|
|||||||
return false; // Continue with the normal error handler
|
return false; // Continue with the normal error handler
|
||||||
}
|
}
|
||||||
switch($errno) {
|
switch($errno) {
|
||||||
|
case E_NOTICE:
|
||||||
case E_WARNING:
|
case E_WARNING:
|
||||||
case E_STRICT:
|
case E_STRICT:
|
||||||
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
|
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
|
||||||
|
@ -33,7 +33,6 @@ class EmbeddedWeb extends ApplicationBootstrap
|
|||||||
->setupErrorHandling()
|
->setupErrorHandling()
|
||||||
->setupTimezone()
|
->setupTimezone()
|
||||||
->setupModuleManager()
|
->setupModuleManager()
|
||||||
->loadCoreModules()
|
|
||||||
->loadEnabledModules();
|
->loadEnabledModules();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,17 @@ abstract class Filter
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract function toQueryString();
|
abstract public function isExpression();
|
||||||
|
|
||||||
|
abstract public function isChain();
|
||||||
|
|
||||||
|
abstract public function isEmpty();
|
||||||
|
|
||||||
|
abstract public function toQueryString();
|
||||||
|
|
||||||
|
abstract public function andFilter(Filter $filter);
|
||||||
|
|
||||||
|
abstract public function orFilter(Filter $filter);
|
||||||
|
|
||||||
public function getUrlParams()
|
public function getUrlParams()
|
||||||
{
|
{
|
||||||
@ -96,7 +106,7 @@ abstract class Filter
|
|||||||
|
|
||||||
public function getParentId()
|
public function getParentId()
|
||||||
{
|
{
|
||||||
if ($self->isRootNode()) {
|
if ($this->isRootNode()) {
|
||||||
throw new ProgrammingError('Filter root nodes have no parent');
|
throw new ProgrammingError('Filter root nodes have no parent');
|
||||||
}
|
}
|
||||||
return substr($this->id, 0, strrpos($this->id, '-'));
|
return substr($this->id, 0, strrpos($this->id, '-'));
|
||||||
|
@ -30,4 +30,14 @@ class FilterAnd extends FilterChain
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function andFilter(Filter $filter)
|
||||||
|
{
|
||||||
|
return $this->addFilter($filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function orFilter(Filter $filter)
|
||||||
|
{
|
||||||
|
return Filter::matchAny($this, $filter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,6 +166,16 @@ abstract class FilterChain extends Filter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isExpression()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isChain()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function isEmpty()
|
public function isEmpty()
|
||||||
{
|
{
|
||||||
return empty($this->filters);
|
return empty($this->filters);
|
||||||
@ -174,7 +184,8 @@ abstract class FilterChain extends Filter
|
|||||||
public function addFilter(Filter $filter)
|
public function addFilter(Filter $filter)
|
||||||
{
|
{
|
||||||
$this->filters[] = $filter;
|
$this->filters[] = $filter;
|
||||||
$filter->setId($this->getId() . '-' . (count($this->filters)));
|
$filter->setId($this->getId() . '-' . $this->count());
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function &filters()
|
public function &filters()
|
||||||
@ -182,6 +193,11 @@ abstract class FilterChain extends Filter
|
|||||||
return $this->filters;
|
return $this->filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function count()
|
||||||
|
{
|
||||||
|
return count($this->filters);
|
||||||
|
}
|
||||||
|
|
||||||
public function __clone()
|
public function __clone()
|
||||||
{
|
{
|
||||||
foreach ($this->filters as & $filter) {
|
foreach ($this->filters as & $filter) {
|
||||||
|
@ -19,6 +19,16 @@ class FilterExpression extends Filter
|
|||||||
$this->expression = $expression;
|
$this->expression = $expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isExpression()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isChain()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function isEmpty()
|
public function isEmpty()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -97,4 +107,14 @@ class FilterExpression extends Filter
|
|||||||
return (bool) preg_match($pattern, $row->{$this->column});
|
return (bool) preg_match($pattern, $row->{$this->column});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function andFilter(Filter $filter)
|
||||||
|
{
|
||||||
|
return Filter::matchAll($this, $filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function orFilter(Filter $filter)
|
||||||
|
{
|
||||||
|
return Filter::matchAny($this, $filter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,16 @@ class FilterNot extends FilterChain
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function andFilter(Filter $filter)
|
||||||
|
{
|
||||||
|
return Filter::matchAll($this, $filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function orFilter(Filter $filter)
|
||||||
|
{
|
||||||
|
return Filter::matchAny($filter);
|
||||||
|
}
|
||||||
|
|
||||||
public function toQueryString()
|
public function toQueryString()
|
||||||
{
|
{
|
||||||
$parts = array();
|
$parts = array();
|
||||||
|
@ -19,4 +19,22 @@ class FilterOr extends FilterChain
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setOperatorName($name)
|
||||||
|
{
|
||||||
|
if ($this->count() > 1 && $name === 'NOT') {
|
||||||
|
return Filter::not(clone $this);
|
||||||
|
}
|
||||||
|
return parent::setOperatorName($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function andFilter(Filter $filter)
|
||||||
|
{
|
||||||
|
return Filter::matchAll($this, $filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function orFilter(Filter $filter)
|
||||||
|
{
|
||||||
|
return $this->addFilter($filter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,16 @@ class Request extends Zend_Controller_Request_Http
|
|||||||
*/
|
*/
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
private $url;
|
||||||
|
|
||||||
|
public function getUrl()
|
||||||
|
{
|
||||||
|
if ($this->url === null) {
|
||||||
|
$this->url = Url::fromRequest($this);
|
||||||
|
}
|
||||||
|
return $this->url;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for user
|
* Setter for user
|
||||||
*
|
*
|
||||||
|
@ -34,7 +34,7 @@ abstract class AbstractWidget
|
|||||||
protected static $view;
|
protected static $view;
|
||||||
|
|
||||||
// TODO: Should we kick this?
|
// TODO: Should we kick this?
|
||||||
protected $properties;
|
protected $properties = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for widget properties
|
* Getter for widget properties
|
||||||
|
@ -8,7 +8,9 @@ use Icinga\Data\Filter\Filter;
|
|||||||
use Icinga\Data\Filter\FilterExpression;
|
use Icinga\Data\Filter\FilterExpression;
|
||||||
use Icinga\Data\Filter\FilterChain;
|
use Icinga\Data\Filter\FilterChain;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter
|
* Filter
|
||||||
@ -24,6 +26,16 @@ class FilterEditor extends AbstractWidget
|
|||||||
|
|
||||||
protected $query;
|
protected $query;
|
||||||
|
|
||||||
|
protected $url;
|
||||||
|
|
||||||
|
protected $addTo;
|
||||||
|
|
||||||
|
protected $cachedColumnSelect;
|
||||||
|
|
||||||
|
protected $preserveParams = array();
|
||||||
|
|
||||||
|
protected $ignoreParams = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
@ -36,10 +48,200 @@ class FilterEditor extends AbstractWidget
|
|||||||
*/
|
*/
|
||||||
public function __construct($props)
|
public function __construct($props)
|
||||||
{
|
{
|
||||||
$this->filter = $props['filter'];
|
if (array_key_exists('filter', $props)) {
|
||||||
if (array_key_exists('query', $props)) {
|
$this->setFilter($props['filter']);
|
||||||
$this->query = $props['query'];
|
|
||||||
}
|
}
|
||||||
|
if (array_key_exists('query', $props)) {
|
||||||
|
$this->setQuery($props['query']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFilter(Filter $filter)
|
||||||
|
{
|
||||||
|
$this->filter = $filter;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
if ($this->filter === null) {
|
||||||
|
$this->filter = Filter::fromQueryString((string) $this->url()->getParams());
|
||||||
|
}
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUrl($url)
|
||||||
|
{
|
||||||
|
$this->url = $url;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function url()
|
||||||
|
{
|
||||||
|
if ($this->url === null) {
|
||||||
|
$this->url = Url::fromRequest();
|
||||||
|
}
|
||||||
|
return $this->url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setQuery($query)
|
||||||
|
{
|
||||||
|
$this->query = $query;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ignoreParams()
|
||||||
|
{
|
||||||
|
$this->ignoreParams = func_get_args();
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function preserveParams()
|
||||||
|
{
|
||||||
|
$this->preserveParams = func_get_args();
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function redirectNow($url)
|
||||||
|
{
|
||||||
|
$response = Icinga::app()->getFrontController()->getResponse();
|
||||||
|
$response->redirectAndExit($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function mergeRootExpression($filter, $column, $sign, $expression)
|
||||||
|
{
|
||||||
|
$found = false;
|
||||||
|
if ($filter->isChain() && $filter->getOperatorName() === 'AND') {
|
||||||
|
foreach ($filter->filters() as $f) {
|
||||||
|
if ($f->isExpression()
|
||||||
|
&& $f->getColumn() === $column
|
||||||
|
&& $f->getSign() === $sign
|
||||||
|
) {
|
||||||
|
$f->setExpression($expression);
|
||||||
|
$found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif ($filter->isExpression()) {
|
||||||
|
if ($filter->getColumn() === $column && $filter->getSign() === $sign) {
|
||||||
|
$filter->setExpression($expression);
|
||||||
|
$found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! $found) {
|
||||||
|
$filter = $filter->andFilter(
|
||||||
|
Filter::expression($column, $sign, $expression)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handleRequest($request)
|
||||||
|
{
|
||||||
|
$this->setUrl($request->getUrl()->without($this->ignoreParams));
|
||||||
|
$params = $this->url()->getParams();
|
||||||
|
|
||||||
|
$preserve = array();
|
||||||
|
foreach ($this->preserveParams as $key) {
|
||||||
|
if (null !== ($value = $params->shift($key))) {
|
||||||
|
$preserve[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$add = $params->shift('addFilter');
|
||||||
|
$remove = $params->shift('removeFilter');
|
||||||
|
$strip = $params->shift('stripFilter');
|
||||||
|
$modify = $params->shift('modifyFilter');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$search = null;
|
||||||
|
if ($request->isPost()) {
|
||||||
|
$search = $request->getPost('q');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($search === null) {
|
||||||
|
$search = $params->shift('q');
|
||||||
|
}
|
||||||
|
|
||||||
|
$filter = $this->getFilter();
|
||||||
|
|
||||||
|
if ($search !== null) {
|
||||||
|
if (strpos($search, '=') === false) {
|
||||||
|
// TODO: Ask the view for (multiple) search columns
|
||||||
|
switch($request->getActionName()) {
|
||||||
|
case 'services':
|
||||||
|
$searchCol = 'service_description';
|
||||||
|
break;
|
||||||
|
case 'hosts':
|
||||||
|
$searchCol = 'host_name';
|
||||||
|
break;
|
||||||
|
case 'hostgroups':
|
||||||
|
$searchCol = 'hostgroup';
|
||||||
|
break;
|
||||||
|
case 'servicegroups':
|
||||||
|
$searchCol = 'servicegroup';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$searchCol = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($searchCol === null) {
|
||||||
|
throw new Exception('Cannot search here');
|
||||||
|
}
|
||||||
|
$filter = $this->mergeRootExpression($filter, $searchCol, '=', "*$search*");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
list($k, $v) = preg_split('/=/', $search);
|
||||||
|
$filter = $this->mergeRootExpression($filter, $k, '=', $v);
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = $this->url()->setQueryString(
|
||||||
|
$filter->toQueryString()
|
||||||
|
)->addParams($preserve);
|
||||||
|
if ($modify) {
|
||||||
|
$url->getParams()->add('modifyFilter');
|
||||||
|
}
|
||||||
|
$this->redirectNow($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($remove) {
|
||||||
|
$redirect = $this->url();
|
||||||
|
if ($filter->getById($remove)->isRootNode()) {
|
||||||
|
$redirect->setQueryString('');
|
||||||
|
} else {
|
||||||
|
$filter->removeId($remove);
|
||||||
|
$redirect->setQueryString($filter->toQueryString())->getParams()->add('modifyFilter');
|
||||||
|
}
|
||||||
|
$this->redirectNow($redirect->addParams($preserve));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($strip) {
|
||||||
|
$redirect = $this->url();
|
||||||
|
$filter->replaceById($strip, $filter->getById($strip . '-1'));
|
||||||
|
$redirect->setQueryString($filter->toQueryString())->getParams()->add('modifyFilter');
|
||||||
|
$this->redirectNow($redirect->addParams($preserve));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($modify) {
|
||||||
|
if ($request->isPost()) {
|
||||||
|
if ($request->get('cancel') === 'Cancel') {
|
||||||
|
$this->redirectNow($this->url()->without('modifyFilter'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$filter = $this->applyChanges($request->getPost());
|
||||||
|
$url = $this->url()->setQueryString($filter->toQueryString())->addParams($preserve);
|
||||||
|
$url->getParams()->add('modifyFilter');
|
||||||
|
$this->redirectNow($url);
|
||||||
|
}
|
||||||
|
$this->url()->getParams()->add('modifyFilter');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($add) {
|
||||||
|
$this->addFilterToId($add);
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function select($name, $list, $selected, $attributes = null)
|
protected function select($name, $list, $selected, $attributes = null)
|
||||||
@ -50,9 +252,12 @@ class FilterEditor extends AbstractWidget
|
|||||||
} else {
|
} else {
|
||||||
$attributes = $view->propertiesToString($attributes);
|
$attributes = $view->propertiesToString($attributes);
|
||||||
}
|
}
|
||||||
$html = '<select name="' . $view->escape($name) . '"' . $attributes . ' class="autosubmit">' . "\n";
|
$html = sprintf(
|
||||||
|
'<select name="%s"%s class="autosubmit">' . "\n",
|
||||||
|
$view->escape($name),
|
||||||
|
$attributes
|
||||||
|
);
|
||||||
|
|
||||||
asort($list);
|
|
||||||
foreach ($list as $k => $v) {
|
foreach ($list as $k => $v) {
|
||||||
$active = '';
|
$active = '';
|
||||||
if ($k === $selected) {
|
if ($k === $selected) {
|
||||||
@ -69,100 +274,169 @@ class FilterEditor extends AbstractWidget
|
|||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function markIndex($idx)
|
protected function addFilterToId($id)
|
||||||
|
{
|
||||||
|
$this->addTo = $id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function removeIndex($idx)
|
||||||
{
|
{
|
||||||
$this->selectedIdx = $idx;
|
$this->selectedIdx = $idx;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeIndex($idx)
|
protected function removeLink(Filter $filter)
|
||||||
{
|
{
|
||||||
$this->selectedIdx = $idx;
|
return $this->view()->qlink(
|
||||||
return $this;
|
'',
|
||||||
|
$this->url()->with('removeFilter', $filter->getId()),
|
||||||
|
null,
|
||||||
|
array(
|
||||||
|
'title' => t('Click to remove this part of your filter'),
|
||||||
|
'class' => 'icon-cancel'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function addLink(Filter $filter)
|
||||||
|
{
|
||||||
|
return $this->view()->qlink(
|
||||||
|
'',
|
||||||
|
$this->url()->with('addFilter', $filter->getId()),
|
||||||
|
null,
|
||||||
|
array(
|
||||||
|
'title' => t('Click to add another filter'),
|
||||||
|
'class' => 'icon-plus'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function stripLink(Filter $filter)
|
||||||
|
{
|
||||||
|
return $this->view()->qlink(
|
||||||
|
'',
|
||||||
|
$this->url()->with('stripFilter', $filter->getId()),
|
||||||
|
null,
|
||||||
|
array(
|
||||||
|
'title' => t('Strip this filter'),
|
||||||
|
'class' => 'icon-minus'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function cancelLink()
|
||||||
|
{
|
||||||
|
return $this->view()->qlink(
|
||||||
|
'',
|
||||||
|
$this->url()->without('addFilter'),
|
||||||
|
null,
|
||||||
|
array(
|
||||||
|
'title' => t('Cancel this operation'),
|
||||||
|
'class' => 'icon-cancel'
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function renderFilter($filter, $level = 0)
|
protected function renderFilter($filter, $level = 0)
|
||||||
{
|
{
|
||||||
$html = '';
|
if ($level === 0 && $filter->isChain() && $filter->isEmpty()) {
|
||||||
$url = Url::fromRequest();
|
return '<ul class="datafilter"><li style="background-color: #ffb">' . $this->renderNewFilter() . '</li></ul>';
|
||||||
|
}
|
||||||
$view = $this->view();
|
|
||||||
$idx = $filter->getId();
|
|
||||||
$markUrl = clone($url);
|
|
||||||
$markUrl->setParam('fIdx', $idx);
|
|
||||||
|
|
||||||
$removeUrl = clone $url;
|
|
||||||
$removeUrl->setParam('removeFilter', $idx);
|
|
||||||
$removeLink = ' <a href="' . $removeUrl . '" title="'
|
|
||||||
. $view->escape(t('Click to remove this part of your filter'))
|
|
||||||
. '">' . $view->icon('cancel') . '</a>';
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Temporarilly removed, not implemented yet
|
|
||||||
$addUrl = clone($url);
|
|
||||||
$addUrl->setParam('addToId', $idx);
|
|
||||||
$addLink = ' <a href="' . $addUrl . '" title="'
|
|
||||||
. $view->escape(t('Click to add another operator below this one'))
|
|
||||||
. '">' . t('Operator') . ' (&, !, |)</a>';
|
|
||||||
$addLink .= ' <a href="' . $addUrl . '" title="'
|
|
||||||
. $view->escape(t('Click to add a filter expression to this operator'))
|
|
||||||
. '">' . t('Expression') . ' (=, <, >, <=, >=)</a>';
|
|
||||||
*/
|
|
||||||
$selectedIndex = ($idx === $this->selectedIdx ? ' -<--' : '');
|
|
||||||
$selectIndex = ' <a href="' . $markUrl . '">o</a>';
|
|
||||||
|
|
||||||
if ($filter instanceof FilterChain) {
|
if ($filter instanceof FilterChain) {
|
||||||
$parts = array();
|
return $this->renderFilterChain($filter, $level);
|
||||||
$i = 0;
|
} elseif ($filter instanceof FilterExpression) {
|
||||||
|
return $this->renderFilterExpression($filter);
|
||||||
foreach ($filter->filters() as $f) {
|
|
||||||
$i++;
|
|
||||||
$parts[] = $this->renderFilter($f, $level + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$op = $this->select(
|
|
||||||
'operator_' . $filter->getId(),
|
|
||||||
array(
|
|
||||||
'OR' => 'OR',
|
|
||||||
'AND' => 'AND',
|
|
||||||
'NOT' => 'NOT'
|
|
||||||
),
|
|
||||||
$filter->getOperatorName(),
|
|
||||||
array('style' => 'width: 5em')
|
|
||||||
) . $removeLink; // Disabled: . ' ' . t('Add') . ': ' . $addLink;
|
|
||||||
$html .= '<span class="handle"> </span>';
|
|
||||||
|
|
||||||
if ($level === 0) {
|
|
||||||
$html .= $op;
|
|
||||||
if (! empty($parts)) {
|
|
||||||
$html .= '<ul class="datafilter"><li>'
|
|
||||||
. implode('</li><li>', $parts)
|
|
||||||
. '</li></ul>';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$html .= $op . "<ul>\n <li>\n" . implode("</li>\n <li>", $parts) . "</li>\n</ul>\n";
|
|
||||||
}
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($filter instanceof FilterExpression) {
|
|
||||||
$u = $url->without($filter->getColumn());
|
|
||||||
} else {
|
} else {
|
||||||
throw new ProgrammingError('Got a Filter being neither expression nor chain');
|
throw new ProgrammingError('Got a Filter being neither expression nor chain');
|
||||||
}
|
}
|
||||||
$value = $filter->getExpression();
|
}
|
||||||
|
|
||||||
|
protected function renderFilterChain(FilterChain $filter, $level)
|
||||||
|
{
|
||||||
|
$html = '<span class="handle"> </span>'
|
||||||
|
. $this->selectOperator($filter)
|
||||||
|
. $this->removeLink($filter)
|
||||||
|
. ($filter->count() === 1 ? $this->stripLink($filter) : '')
|
||||||
|
. $this->addLink($filter);
|
||||||
|
|
||||||
|
if ($filter->isEmpty() && ! $this->addTo) {
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
$parts = array();
|
||||||
|
foreach ($filter->filters() as $f) {
|
||||||
|
$parts[] = '<li>' . $this->renderFilter($f, $level + 1) . '</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->addTo && $this->addTo == $filter->getId()) {
|
||||||
|
$parts[] = '<li style="background: #ffb">' . $this->renderNewFilter() .$this->cancelLink(). '</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$class = $level === 0 ? ' class="datafilter"' : '';
|
||||||
|
$html .= sprintf(
|
||||||
|
"<ul%s>\n%s</ul>\n",
|
||||||
|
$class,
|
||||||
|
implode("", $parts)
|
||||||
|
);
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function renderFilterExpression(FilterExpression $filter)
|
||||||
|
{
|
||||||
|
if ($this->addTo && $this->addTo === $filter->getId()) {
|
||||||
|
return
|
||||||
|
preg_replace(
|
||||||
|
'/ class="autosubmit"/',
|
||||||
|
' class="autofocus"',
|
||||||
|
$this->selectOperator()
|
||||||
|
)
|
||||||
|
. '<ul><li>'
|
||||||
|
. $this->selectColumn($filter)
|
||||||
|
. $this->selectSign($filter)
|
||||||
|
. $this->text($filter)
|
||||||
|
. $this->removeLink($filter)
|
||||||
|
. $this->addLink($filter)
|
||||||
|
. '</li><li style="background-color: #ffb">'
|
||||||
|
. $this->renderNewFilter() .$this->cancelLink()
|
||||||
|
. '</li></ul>'
|
||||||
|
;
|
||||||
|
} else {
|
||||||
|
return $this->selectColumn($filter)
|
||||||
|
. $this->selectSign($filter)
|
||||||
|
. $this->text($filter)
|
||||||
|
. $this->removeLink($filter)
|
||||||
|
. $this->addLink($filter)
|
||||||
|
;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function text(Filter $filter = null)
|
||||||
|
{
|
||||||
|
$value = $filter === null ? '' : $filter->getExpression();
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$value = '(' . implode('|', $value) . ')';
|
$value = '(' . implode('|', $value) . ')';
|
||||||
}
|
}
|
||||||
$html .= $this->selectColumn($filter) . ' '
|
return sprintf(
|
||||||
. $this->selectSign($filter)
|
'<input type="text" name="%s" value="%s" />',
|
||||||
. ' <input type="text" name="'
|
$this->elementId('value', $filter),
|
||||||
. 'value_' . $idx
|
$value
|
||||||
. '" value="'
|
);
|
||||||
. $value
|
}
|
||||||
. '" /> ' . $removeLink;
|
|
||||||
|
|
||||||
return $html;
|
protected function renderNewFilter()
|
||||||
|
{
|
||||||
|
$html = $this->selectColumn()
|
||||||
|
. $this->selectSign()
|
||||||
|
. $this->text();
|
||||||
|
|
||||||
|
return preg_replace(
|
||||||
|
'/ class="autosubmit"/',
|
||||||
|
'',
|
||||||
|
$html
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function arrayForSelect($array)
|
protected function arrayForSelect($array)
|
||||||
@ -179,9 +453,33 @@ class FilterEditor extends AbstractWidget
|
|||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function selectSign($filter)
|
protected function elementId($prefix, Filter $filter = null)
|
||||||
|
{
|
||||||
|
if ($filter === null) {
|
||||||
|
return $prefix . '_new_' . ($this->addTo ?: '0');
|
||||||
|
} else {
|
||||||
|
return $prefix . '_' . $filter->getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function selectOperator(Filter $filter = null)
|
||||||
|
{
|
||||||
|
$ops = array(
|
||||||
|
'AND' => 'AND',
|
||||||
|
'OR' => 'OR',
|
||||||
|
'NOT' => 'NOT'
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->select(
|
||||||
|
$this->elementId('operator', $filter),
|
||||||
|
$ops,
|
||||||
|
$filter === null ? null : $filter->getOperatorName(),
|
||||||
|
array('style' => 'width: 5em')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function selectSign(Filter $filter = null)
|
||||||
{
|
{
|
||||||
$name = 'sign_' . $filter->getId();
|
|
||||||
$signs = array(
|
$signs = array(
|
||||||
'=' => '=',
|
'=' => '=',
|
||||||
'!=' => '!=',
|
'!=' => '!=',
|
||||||
@ -192,17 +490,30 @@ class FilterEditor extends AbstractWidget
|
|||||||
);
|
);
|
||||||
|
|
||||||
return $this->select(
|
return $this->select(
|
||||||
$name,
|
$this->elementId('sign', $filter),
|
||||||
$signs,
|
$signs,
|
||||||
$filter->getSign(),
|
$filter === null ? null : $filter->getSign(),
|
||||||
array('style' => 'width: 4em')
|
array('style' => 'width: 4em')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
protected function selectColumn($filter)
|
|
||||||
|
protected function selectColumn(Filter $filter = null)
|
||||||
{
|
{
|
||||||
$name = 'column_' . $filter->getId();
|
$active = $filter === null ? null : $filter->getColumn();
|
||||||
$cols = $this->arrayForSelect($this->query->getColumns());
|
|
||||||
$active = $filter->getColumn();
|
if ($this->query === null) {
|
||||||
|
return sprintf(
|
||||||
|
'<input type="text" name="%s" value="%s" />',
|
||||||
|
$this->elementId('column', $filter),
|
||||||
|
$this->view()->escape($active) // Escape attribute?
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->cachedColumnSelect === null) {
|
||||||
|
$this->cachedColumnSelect = $this->arrayForSelect($this->query->getColumns());
|
||||||
|
asort($this->cachedColumnSelect);
|
||||||
|
}
|
||||||
|
$cols = $this->cachedColumnSelect;
|
||||||
$seen = false;
|
$seen = false;
|
||||||
foreach ($cols as $k => & $v) {
|
foreach ($cols as $k => & $v) {
|
||||||
$v = str_replace('_', ' ', ucfirst($v));
|
$v = str_replace('_', ' ', ucfirst($v));
|
||||||
@ -215,32 +526,169 @@ class FilterEditor extends AbstractWidget
|
|||||||
$cols[$active] = str_replace('_', ' ', ucfirst(ltrim($active, '_')));
|
$cols[$active] = str_replace('_', ' ', ucfirst(ltrim($active, '_')));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->query === null) {
|
return $this->select($this->elementId('column', $filter), $cols, $active);
|
||||||
return sprintf(
|
|
||||||
'<input type="text" name="%s" value="%s" />',
|
|
||||||
$name,
|
|
||||||
$filter->getColumn()
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return $this->select(
|
|
||||||
$name,
|
|
||||||
$cols,
|
|
||||||
$active
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function applyChanges($changes)
|
||||||
|
{
|
||||||
|
$filter = $this->filter;
|
||||||
|
$pairs = array();
|
||||||
|
$addTo = null;
|
||||||
|
$add = array();
|
||||||
|
foreach ($changes as $k => $v) {
|
||||||
|
if (preg_match('/^(column|value|sign|operator)((?:_new)?)_([\d-]+)$/', $k, $m)) {
|
||||||
|
if ($m[2] === '_new') {
|
||||||
|
if ($addTo !== null && $addTo !== $m[3]) {
|
||||||
|
throw new \Exception('F...U');
|
||||||
|
}
|
||||||
|
$addTo = $m[3];
|
||||||
|
$add[$m[1]] = $v;
|
||||||
|
} else {
|
||||||
|
$pairs[$m[3]][$m[1]] = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$operators = array();
|
||||||
|
foreach ($pairs as $id => $fs) {
|
||||||
|
if (array_key_exists('operator', $fs)) {
|
||||||
|
$operators[$id] = $fs['operator'];
|
||||||
|
} else {
|
||||||
|
$f = $filter->getById($id);
|
||||||
|
$f->setColumn($fs['column']);
|
||||||
|
if ($f->getSign() !== $fs['sign']) {
|
||||||
|
if ($f->isRootNode()) {
|
||||||
|
$filter = $f->setSign($fs['sign']);
|
||||||
|
} else {
|
||||||
|
$filter->replaceById($id, $f->setSign($fs['sign']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$f->setExpression($fs['value']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
krsort($operators, version_compare(PHP_VERSION, '5.4.0') >= 0 ? SORT_NATURAL : SORT_REGULAR);
|
||||||
|
foreach ($operators as $id => $operator) {
|
||||||
|
$f = $filter->getById($id);
|
||||||
|
if ($f->getOperatorName() !== $operator) {
|
||||||
|
if ($f->isRootNode()) {
|
||||||
|
$filter = $f->setOperatorName($operator);
|
||||||
|
} else {
|
||||||
|
$filter->replaceById($id, $f->setOperatorName($operator));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($addTo !== null) {
|
||||||
|
if ($addTo === '0') {
|
||||||
|
$filter = Filter::expression($add['column'], $add['sign'], $add['value']);
|
||||||
|
} else {
|
||||||
|
$parent = $filter->getById($addTo);
|
||||||
|
$f = Filter::expression($add['column'], $add['sign'], $add['value']);
|
||||||
|
if ($add['operator']) {
|
||||||
|
switch($add['operator']) {
|
||||||
|
case 'AND':
|
||||||
|
if ($parent->isExpression()) {
|
||||||
|
if ($parent->isRootNode()) {
|
||||||
|
$filter = Filter::matchAll(clone $parent, $f);
|
||||||
|
} else {
|
||||||
|
$filter = $filter->replaceById($addTo, Filter::matchAll(clone $parent, $f));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$parent->addFilter(Filter::matchAll($f));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'OR':
|
||||||
|
if ($parent->isExpression()) {
|
||||||
|
if ($parent->isRootNode()) {
|
||||||
|
$filter = Filter::matchAny(clone $parent, $f);
|
||||||
|
} else {
|
||||||
|
$filter = $filter->replaceById($addTo, Filter::matchAny(clone $parent, $f));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$parent->addFilter(Filter::matchAny($f));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'NOT':
|
||||||
|
if ($parent->isExpression()) {
|
||||||
|
if ($parent->isRootNode()) {
|
||||||
|
$filter = Filter::not(Filter::matchAll($parent, $f));
|
||||||
|
} else {
|
||||||
|
$filter = $filter->replaceById($addTo, Filter::not(Filter::matchAll($parent, $f)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$parent->addFilter(Filter::not($f));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$parent->addFilter($f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function renderSearch()
|
||||||
|
{
|
||||||
|
$html = ' <form method="post" class="inline" action="'
|
||||||
|
. $this->url()
|
||||||
|
. '"><input type="text" name="q" style="width: 8em" class="search" value="" placeholder="'
|
||||||
|
. t('Search...')
|
||||||
|
. '" /></form>';
|
||||||
|
|
||||||
|
if ($this->filter->isEmpty()) {
|
||||||
|
$title = t('Filter this list');
|
||||||
|
} else {
|
||||||
|
$title = t('Modify this filter');
|
||||||
|
if (! $this->filter->isEmpty()) {
|
||||||
|
$title .= ': ' . $this->filter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $html
|
||||||
|
. '<a href="'
|
||||||
|
. $this->url()->with('modifyFilter', true)
|
||||||
|
. '" title="'
|
||||||
|
. $title
|
||||||
|
. '">'
|
||||||
|
. '<i class="icon-filter"></i>'
|
||||||
|
. '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return '<h3>'
|
if (! $this->url()->getParam('modifyFilter')) {
|
||||||
. t('Modify this filter')
|
return $this->renderSearch() . $this->shorten($this->filter, 50);
|
||||||
. '</h3>'
|
}
|
||||||
|
return $this->renderSearch()
|
||||||
. '<form action="'
|
. '<form action="'
|
||||||
. Url::fromRequest()
|
. Url::fromRequest()
|
||||||
. '" class="filterEditor" method="POST">'
|
. '" class="filterEditor" method="POST">'
|
||||||
. '<ul class="tree"><li>'
|
. '<ul class="tree"><li>'
|
||||||
. $this->renderFilter($this->filter)
|
. $this->renderFilter($this->filter)
|
||||||
. '</li></ul><br /><input type="submit" name="submit" value="Apply" />'
|
. '</li></ul>'
|
||||||
|
. '<div style="float: right">'
|
||||||
|
. '<input type="submit" name="submit" value="Apply" />'
|
||||||
|
. '<input type="submit" name="cancel" value="Cancel" />'
|
||||||
|
. '</div>'
|
||||||
. '</form>';
|
. '</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function shorten($string, $length)
|
||||||
|
{
|
||||||
|
if (strlen($string) > $length) {
|
||||||
|
return substr($string, 0, $length) . '...';
|
||||||
|
}
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->render();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return 'ERROR in FilterEditor: ' . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ EOT;
|
|||||||
*/
|
*/
|
||||||
private $dropdownTpl = <<< 'EOT'
|
private $dropdownTpl = <<< 'EOT'
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a href="#" class="dropdown-toggle">⌄</a>
|
<a href="#" class="dropdown-toggle"><i class="icon-down-open"></i></a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
{TABS}
|
{TABS}
|
||||||
</ul>
|
</ul>
|
||||||
|
1576
library/vendor/Zend/Locale/Data.php
vendored
Normal file
1576
library/vendor/Zend/Locale/Data.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
285
library/vendor/Zend/Locale/Data/Translation.php
vendored
Normal file
285
library/vendor/Zend/Locale/Data/Translation.php
vendored
Normal file
@ -0,0 +1,285 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Zend Framework
|
||||||
|
*
|
||||||
|
* LICENSE
|
||||||
|
*
|
||||||
|
* This source file is subject to the new BSD license that is bundled
|
||||||
|
* with this package in the file LICENSE.txt.
|
||||||
|
* It is also available through the world-wide-web at this URL:
|
||||||
|
* http://framework.zend.com/license/new-bsd
|
||||||
|
* If you did not receive a copy of the license and are unable to
|
||||||
|
* obtain it through the world-wide-web, please send an email
|
||||||
|
* to license@zend.com so we can send you a copy immediately.
|
||||||
|
*
|
||||||
|
* @category Zend
|
||||||
|
* @package Zend_Locale
|
||||||
|
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
|
||||||
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Definition class for all Windows locales
|
||||||
|
*
|
||||||
|
* Based on this two lists:
|
||||||
|
* @link http://msdn.microsoft.com/en-us/library/39cwe7zf.aspx
|
||||||
|
* @link http://msdn.microsoft.com/en-us/library/cdax410z.aspx
|
||||||
|
* @link http://msdn.microsoft.com/en-us/goglobal/bb964664.aspx
|
||||||
|
* @link http://msdn.microsoft.com/en-us/goglobal/bb895996.aspx
|
||||||
|
*
|
||||||
|
* @category Zend
|
||||||
|
* @package Zend_Locale
|
||||||
|
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
|
||||||
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||||
|
*/
|
||||||
|
class Zend_Locale_Data_Translation
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Locale Translation for Full Named Locales
|
||||||
|
*
|
||||||
|
* @var array $localeTranslation
|
||||||
|
*/
|
||||||
|
public static $languageTranslation = array(
|
||||||
|
'Afrikaans' => 'af',
|
||||||
|
'Albanian' => 'sq',
|
||||||
|
'Amharic' => 'am',
|
||||||
|
'Arabic' => 'ar',
|
||||||
|
'Armenian' => 'hy',
|
||||||
|
'Assamese' => 'as',
|
||||||
|
'Azeri' => 'az',
|
||||||
|
'Azeri Latin' => 'az_Latn',
|
||||||
|
'Azeri Cyrillic' => 'az_Cyrl',
|
||||||
|
'Basque' => 'eu',
|
||||||
|
'Belarusian' => 'be',
|
||||||
|
'Bengali' => 'bn',
|
||||||
|
'Bengali Latin' => 'bn_Latn',
|
||||||
|
'Bosnian' => 'bs',
|
||||||
|
'Bulgarian' => 'bg',
|
||||||
|
'Burmese' => 'my',
|
||||||
|
'Catalan' => 'ca',
|
||||||
|
'Cherokee' => 'chr',
|
||||||
|
'Chinese' => 'zh',
|
||||||
|
'Croatian' => 'hr',
|
||||||
|
'Czech' => 'cs',
|
||||||
|
'Danish' => 'da',
|
||||||
|
'Divehi' => 'dv',
|
||||||
|
'Dutch' => 'nl',
|
||||||
|
'English' => 'en',
|
||||||
|
'Estonian' => 'et',
|
||||||
|
'Faroese' => 'fo',
|
||||||
|
'Faeroese' => 'fo',
|
||||||
|
'Farsi' => 'fa',
|
||||||
|
'Filipino' => 'fil',
|
||||||
|
'Finnish' => 'fi',
|
||||||
|
'French' => 'fr',
|
||||||
|
'Frisian' => 'fy',
|
||||||
|
'Gaelic' => 'gd',
|
||||||
|
'Galician' => 'gl',
|
||||||
|
'Georgian' => 'ka',
|
||||||
|
'German' => 'de',
|
||||||
|
'Greek' => 'el',
|
||||||
|
'Guarani' => 'gn',
|
||||||
|
'Gujarati' => 'gu',
|
||||||
|
'Hausa' => 'ha',
|
||||||
|
'Hawaiian' => 'haw',
|
||||||
|
'Hebrew' => 'he',
|
||||||
|
'Hindi' => 'hi',
|
||||||
|
'Hungarian' => 'hu',
|
||||||
|
'Icelandic' => 'is',
|
||||||
|
'Igbo' => 'ig',
|
||||||
|
'Indonesian' => 'id',
|
||||||
|
'Inuktitut' => 'iu',
|
||||||
|
'Italian' => 'it',
|
||||||
|
'Japanese' => 'ja',
|
||||||
|
'Kannada' => 'kn',
|
||||||
|
'Kanuri' => 'kr',
|
||||||
|
'Kashmiri' => 'ks',
|
||||||
|
'Kazakh' => 'kk',
|
||||||
|
'Khmer' => 'km',
|
||||||
|
'Konkani' => 'kok',
|
||||||
|
'Korean' => 'ko',
|
||||||
|
'Kyrgyz' => 'ky',
|
||||||
|
'Lao' => 'lo',
|
||||||
|
'Latin' => 'la',
|
||||||
|
'Latvian' => 'lv',
|
||||||
|
'Lithuanian' => 'lt',
|
||||||
|
'Macedonian' => 'mk',
|
||||||
|
'Malay' => 'ms',
|
||||||
|
'Malayalam' => 'ml',
|
||||||
|
'Maltese' => 'mt',
|
||||||
|
'Manipuri' => 'mni',
|
||||||
|
'Maori' => 'mi',
|
||||||
|
'Marathi' => 'mr',
|
||||||
|
'Mongolian' => 'mn',
|
||||||
|
'Nepali' => 'ne',
|
||||||
|
'Norwegian' => 'no',
|
||||||
|
'Norwegian Bokmal' => 'nb',
|
||||||
|
'Norwegian Nynorsk' => 'nn',
|
||||||
|
'Oriya' => 'or',
|
||||||
|
'Oromo' => 'om',
|
||||||
|
'Papiamentu' => 'pap',
|
||||||
|
'Pashto' => 'ps',
|
||||||
|
'Polish' => 'pl',
|
||||||
|
'Portuguese' => 'pt',
|
||||||
|
'Punjabi' => 'pa',
|
||||||
|
'Quecha' => 'qu',
|
||||||
|
'Quechua' => 'qu',
|
||||||
|
'Rhaeto-Romanic' => 'rm',
|
||||||
|
'Romanian' => 'ro',
|
||||||
|
'Russian' => 'ru',
|
||||||
|
'Sami' => 'smi',
|
||||||
|
'Sami Inari' => 'smn',
|
||||||
|
'Sami Lule' => 'smj',
|
||||||
|
'Sami Northern' => 'se',
|
||||||
|
'Sami Skolt' => 'sms',
|
||||||
|
'Sami Southern' => 'sma',
|
||||||
|
'Sanskrit' => 'sa',
|
||||||
|
'Serbian' => 'sr',
|
||||||
|
'Serbian Latin' => 'sr_Latn',
|
||||||
|
'Serbian Cyrillic' => 'sr_Cyrl',
|
||||||
|
'Sindhi' => 'sd',
|
||||||
|
'Sinhalese' => 'si',
|
||||||
|
'Slovak' => 'sk',
|
||||||
|
'Slovenian' => 'sl',
|
||||||
|
'Somali' => 'so',
|
||||||
|
'Sorbian' => 'wen',
|
||||||
|
'Spanish' => 'es',
|
||||||
|
'Swahili' => 'sw',
|
||||||
|
'Swedish' => 'sv',
|
||||||
|
'Syriac' => 'syr',
|
||||||
|
'Tajik' => 'tg',
|
||||||
|
'Tamazight' => 'tmh',
|
||||||
|
'Tamil' => 'ta',
|
||||||
|
'Tatar' => 'tt',
|
||||||
|
'Telugu' => 'te',
|
||||||
|
'Thai' => 'th',
|
||||||
|
'Tibetan' => 'bo',
|
||||||
|
'Tigrigna' => 'ti',
|
||||||
|
'Tsonga' => 'ts',
|
||||||
|
'Tswana' => 'tn',
|
||||||
|
'Turkish' => 'tr',
|
||||||
|
'Turkmen' => 'tk',
|
||||||
|
'Uighur' => 'ug',
|
||||||
|
'Ukrainian' => 'uk',
|
||||||
|
'Urdu' => 'ur',
|
||||||
|
'Uzbek' => 'uz',
|
||||||
|
'Uzbek Latin' => 'uz_Latn',
|
||||||
|
'Uzbek Cyrillic' => 'uz_Cyrl',
|
||||||
|
'Venda' => 've',
|
||||||
|
'Vietnamese' => 'vi',
|
||||||
|
'Welsh' => 'cy',
|
||||||
|
'Xhosa' => 'xh',
|
||||||
|
'Yiddish' => 'yi',
|
||||||
|
'Yoruba' => 'yo',
|
||||||
|
'Zulu' => 'zu',
|
||||||
|
);
|
||||||
|
|
||||||
|
public static $regionTranslation = array(
|
||||||
|
'Albania' => 'AL',
|
||||||
|
'Algeria' => 'DZ',
|
||||||
|
'Argentina' => 'AR',
|
||||||
|
'Armenia' => 'AM',
|
||||||
|
'Australia' => 'AU',
|
||||||
|
'Austria' => 'AT',
|
||||||
|
'Bahrain' => 'BH',
|
||||||
|
'Bangladesh' => 'BD',
|
||||||
|
'Belgium' => 'BE',
|
||||||
|
'Belize' => 'BZ',
|
||||||
|
'Bhutan' => 'BT',
|
||||||
|
'Bolivia' => 'BO',
|
||||||
|
'Bosnia Herzegovina' => 'BA',
|
||||||
|
'Brazil' => 'BR',
|
||||||
|
'Brazilian' => 'BR',
|
||||||
|
'Brunei Darussalam' => 'BN',
|
||||||
|
'Cameroon' => 'CM',
|
||||||
|
'Canada' => 'CA',
|
||||||
|
'Chile' => 'CL',
|
||||||
|
'China' => 'CN',
|
||||||
|
'Colombia' => 'CO',
|
||||||
|
'Costa Rica' => 'CR',
|
||||||
|
"Cote d'Ivoire" => 'CI',
|
||||||
|
'Czech Republic' => 'CZ',
|
||||||
|
'Dominican Republic' => 'DO',
|
||||||
|
'Denmark' => 'DK',
|
||||||
|
'Ecuador' => 'EC',
|
||||||
|
'Egypt' => 'EG',
|
||||||
|
'El Salvador' => 'SV',
|
||||||
|
'Eritrea' => 'ER',
|
||||||
|
'Ethiopia' => 'ET',
|
||||||
|
'Finland' => 'FI',
|
||||||
|
'France' => 'FR',
|
||||||
|
'Germany' => 'DE',
|
||||||
|
'Greece' => 'GR',
|
||||||
|
'Guatemala' => 'GT',
|
||||||
|
'Haiti' => 'HT',
|
||||||
|
'Honduras' => 'HN',
|
||||||
|
'Hong Kong' => 'HK',
|
||||||
|
'Hong Kong SAR' => 'HK',
|
||||||
|
'Hungary' => 'HU',
|
||||||
|
'Iceland' => 'IS',
|
||||||
|
'India' => 'IN',
|
||||||
|
'Indonesia' => 'ID',
|
||||||
|
'Iran' => 'IR',
|
||||||
|
'Iraq' => 'IQ',
|
||||||
|
'Ireland' => 'IE',
|
||||||
|
'Italy' => 'IT',
|
||||||
|
'Jamaica' => 'JM',
|
||||||
|
'Japan' => 'JP',
|
||||||
|
'Jordan' => 'JO',
|
||||||
|
'Korea' => 'KR',
|
||||||
|
'Kuwait' => 'KW',
|
||||||
|
'Lebanon' => 'LB',
|
||||||
|
'Libya' => 'LY',
|
||||||
|
'Liechtenstein' => 'LI',
|
||||||
|
'Luxembourg' => 'LU',
|
||||||
|
'Macau' => 'MO',
|
||||||
|
'Macao SAR' => 'MO',
|
||||||
|
'Malaysia' => 'MY',
|
||||||
|
'Mali' => 'ML',
|
||||||
|
'Mexico' => 'MX',
|
||||||
|
'Moldava' => 'MD',
|
||||||
|
'Monaco' => 'MC',
|
||||||
|
'Morocco' => 'MA',
|
||||||
|
'Netherlands' => 'NL',
|
||||||
|
'New Zealand' => 'NZ',
|
||||||
|
'Nicaragua' => 'NI',
|
||||||
|
'Nigeria' => 'NG',
|
||||||
|
'Norway' => 'NO',
|
||||||
|
'Oman' => 'OM',
|
||||||
|
'Pakistan' => 'PK',
|
||||||
|
'Panama' => 'PA',
|
||||||
|
'Paraguay' => 'PY',
|
||||||
|
"People's Republic of China" => 'CN',
|
||||||
|
'Peru' => 'PE',
|
||||||
|
'Philippines' => 'PH',
|
||||||
|
'Poland' => 'PL',
|
||||||
|
'Portugal' => 'PT',
|
||||||
|
'PRC' => 'CN',
|
||||||
|
'Puerto Rico' => 'PR',
|
||||||
|
'Qatar' => 'QA',
|
||||||
|
'Reunion' => 'RE',
|
||||||
|
'Russia' => 'RU',
|
||||||
|
'Saudi Arabia' => 'SA',
|
||||||
|
'Senegal' => 'SN',
|
||||||
|
'Singapore' => 'SG',
|
||||||
|
'Slovakia' => 'SK',
|
||||||
|
'South Africa' => 'ZA',
|
||||||
|
'Spain' => 'ES',
|
||||||
|
'Sri Lanka' => 'LK',
|
||||||
|
'Sweden' => 'SE',
|
||||||
|
'Switzerland' => 'CH',
|
||||||
|
'Syria' => 'SY',
|
||||||
|
'Taiwan' => 'TW',
|
||||||
|
'The Netherlands' => 'NL',
|
||||||
|
'Trinidad' => 'TT',
|
||||||
|
'Tunisia' => 'TN',
|
||||||
|
'UAE' => 'AE',
|
||||||
|
'United Kingdom' => 'GB',
|
||||||
|
'United States' => 'US',
|
||||||
|
'Uruguay' => 'UY',
|
||||||
|
'Venezuela' => 'VE',
|
||||||
|
'Yemen' => 'YE',
|
||||||
|
'Zimbabwe' => 'ZW',
|
||||||
|
);
|
||||||
|
}
|
36
library/vendor/Zend/Locale/Exception.php
vendored
Normal file
36
library/vendor/Zend/Locale/Exception.php
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Zend Framework
|
||||||
|
*
|
||||||
|
* LICENSE
|
||||||
|
*
|
||||||
|
* This source file is subject to the new BSD license that is bundled
|
||||||
|
* with this package in the file LICENSE.txt.
|
||||||
|
* It is also available through the world-wide-web at this URL:
|
||||||
|
* http://framework.zend.com/license/new-bsd
|
||||||
|
* If you did not receive a copy of the license and are unable to
|
||||||
|
* obtain it through the world-wide-web, please send an email
|
||||||
|
* to license@zend.com so we can send you a copy immediately.
|
||||||
|
*
|
||||||
|
* @category Zend
|
||||||
|
* @package Zend_Locale
|
||||||
|
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
|
||||||
|
* @version $Id$
|
||||||
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zend_Exception
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Zend
|
||||||
|
* @package Zend_Locale
|
||||||
|
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
|
||||||
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||||
|
*/
|
||||||
|
class Zend_Locale_Exception extends Zend_Exception
|
||||||
|
{
|
||||||
|
}
|
1321
library/vendor/Zend/Locale/Format.php
vendored
Normal file
1321
library/vendor/Zend/Locale/Format.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
354
library/vendor/Zend/Locale/Math.php
vendored
Normal file
354
library/vendor/Zend/Locale/Math.php
vendored
Normal file
@ -0,0 +1,354 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Zend Framework
|
||||||
|
*
|
||||||
|
* LICENSE
|
||||||
|
*
|
||||||
|
* This source file is subject to the new BSD license that is bundled
|
||||||
|
* with this package in the file LICENSE.txt.
|
||||||
|
* It is also available through the world-wide-web at this URL:
|
||||||
|
* http://framework.zend.com/license/new-bsd
|
||||||
|
* If you did not receive a copy of the license and are unable to
|
||||||
|
* obtain it through the world-wide-web, please send an email
|
||||||
|
* to license@zend.com so we can send you a copy immediately.
|
||||||
|
*
|
||||||
|
* @category Zend
|
||||||
|
* @package Zend_Locale
|
||||||
|
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
|
||||||
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility class for proxying math function to bcmath functions, if present,
|
||||||
|
* otherwise to PHP builtin math operators, with limited detection of overflow conditions.
|
||||||
|
* Sampling of PHP environments and platforms suggests that at least 80% to 90% support bcmath.
|
||||||
|
* Thus, this file should be as light as possible.
|
||||||
|
*
|
||||||
|
* @category Zend
|
||||||
|
* @package Zend_Locale
|
||||||
|
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
|
||||||
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Zend_Locale_Math
|
||||||
|
{
|
||||||
|
// support unit testing without using bcmath functions
|
||||||
|
public static $_bcmathDisabled = false;
|
||||||
|
|
||||||
|
public static $add = array('Zend_Locale_Math', 'Add');
|
||||||
|
public static $sub = array('Zend_Locale_Math', 'Sub');
|
||||||
|
public static $pow = array('Zend_Locale_Math', 'Pow');
|
||||||
|
public static $mul = array('Zend_Locale_Math', 'Mul');
|
||||||
|
public static $div = array('Zend_Locale_Math', 'Div');
|
||||||
|
public static $comp = array('Zend_Locale_Math', 'Comp');
|
||||||
|
public static $sqrt = array('Zend_Locale_Math', 'Sqrt');
|
||||||
|
public static $mod = array('Zend_Locale_Math', 'Mod');
|
||||||
|
public static $scale = 'bcscale';
|
||||||
|
|
||||||
|
public static function isBcmathDisabled()
|
||||||
|
{
|
||||||
|
return self::$_bcmathDisabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Surprisingly, the results of this implementation of round()
|
||||||
|
* prove better than the native PHP round(). For example, try:
|
||||||
|
* round(639.795, 2);
|
||||||
|
* round(267.835, 2);
|
||||||
|
* round(0.302515, 5);
|
||||||
|
* round(0.36665, 4);
|
||||||
|
* then try:
|
||||||
|
* Zend_Locale_Math::round('639.795', 2);
|
||||||
|
*/
|
||||||
|
public static function round($op1, $precision = 0)
|
||||||
|
{
|
||||||
|
if (self::$_bcmathDisabled) {
|
||||||
|
$op1 = round($op1, $precision);
|
||||||
|
if (strpos((string) $op1, 'E') === false) {
|
||||||
|
return self::normalize(round($op1, $precision));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($op1, 'E') !== false) {
|
||||||
|
$op1 = self::floatalize($op1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$op1 = trim(self::normalize($op1));
|
||||||
|
$length = strlen($op1);
|
||||||
|
if (($decPos = strpos($op1, '.')) === false) {
|
||||||
|
$op1 .= '.0';
|
||||||
|
$decPos = $length;
|
||||||
|
$length += 2;
|
||||||
|
}
|
||||||
|
if ($precision < 0 && abs($precision) > $decPos) {
|
||||||
|
return '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
$digitsBeforeDot = $length - ($decPos + 1);
|
||||||
|
if ($precision >= ($length - ($decPos + 1))) {
|
||||||
|
return $op1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($precision === 0) {
|
||||||
|
$triggerPos = 1;
|
||||||
|
$roundPos = -1;
|
||||||
|
} elseif ($precision > 0) {
|
||||||
|
$triggerPos = $precision + 1;
|
||||||
|
$roundPos = $precision;
|
||||||
|
} else {
|
||||||
|
$triggerPos = $precision;
|
||||||
|
$roundPos = $precision -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$triggerDigit = $op1[$triggerPos + $decPos];
|
||||||
|
if ($precision < 0) {
|
||||||
|
// zero fill digits to the left of the decimal place
|
||||||
|
$op1 = substr($op1, 0, $decPos + $precision) . str_pad('', abs($precision), '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($triggerDigit >= '5') {
|
||||||
|
if ($roundPos + $decPos == -1) {
|
||||||
|
return str_pad('1', $decPos + 1, '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
$roundUp = str_pad('', $length, '0');
|
||||||
|
$roundUp[$decPos] = '.';
|
||||||
|
$roundUp[$roundPos + $decPos] = '1';
|
||||||
|
|
||||||
|
if ($op1 > 0) {
|
||||||
|
if (self::$_bcmathDisabled) {
|
||||||
|
return Zend_Locale_Math_PhpMath::Add($op1, $roundUp, $precision);
|
||||||
|
}
|
||||||
|
return self::Add($op1, $roundUp, $precision);
|
||||||
|
} else {
|
||||||
|
if (self::$_bcmathDisabled) {
|
||||||
|
return Zend_Locale_Math_PhpMath::Sub($op1, $roundUp, $precision);
|
||||||
|
}
|
||||||
|
return self::Sub($op1, $roundUp, $precision);
|
||||||
|
}
|
||||||
|
} elseif ($precision >= 0) {
|
||||||
|
return substr($op1, 0, $decPos + ($precision ? $precision + 1: 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (string) $op1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a scientific notation to float
|
||||||
|
* Additionally fixed a problem with PHP <= 5.2.x with big integers
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
*/
|
||||||
|
public static function floatalize($value)
|
||||||
|
{
|
||||||
|
$value = strtoupper($value);
|
||||||
|
if (strpos($value, 'E') === false) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$number = substr($value, 0, strpos($value, 'E'));
|
||||||
|
if (strpos($number, '.') !== false) {
|
||||||
|
$post = strlen(substr($number, strpos($number, '.') + 1));
|
||||||
|
$mantis = substr($value, strpos($value, 'E') + 1);
|
||||||
|
if ($mantis < 0) {
|
||||||
|
$post += abs((int) $mantis);
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = number_format($value, $post, '.', '');
|
||||||
|
} else {
|
||||||
|
$value = number_format($value, 0, '.', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalizes an input to standard english notation
|
||||||
|
* Fixes a problem of BCMath with setLocale which is PHP related
|
||||||
|
*
|
||||||
|
* @param integer $value Value to normalize
|
||||||
|
* @return string Normalized string without BCMath problems
|
||||||
|
*/
|
||||||
|
public static function normalize($value)
|
||||||
|
{
|
||||||
|
$convert = localeconv();
|
||||||
|
$value = str_replace($convert['thousands_sep'], "",(string) $value);
|
||||||
|
$value = str_replace($convert['positive_sign'], "", $value);
|
||||||
|
$value = str_replace($convert['decimal_point'], ".",$value);
|
||||||
|
if (!empty($convert['negative_sign']) and (strpos($value, $convert['negative_sign']))) {
|
||||||
|
$value = str_replace($convert['negative_sign'], "", $value);
|
||||||
|
$value = "-" . $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Localizes an input from standard english notation
|
||||||
|
* Fixes a problem of BCMath with setLocale which is PHP related
|
||||||
|
*
|
||||||
|
* @param integer $value Value to normalize
|
||||||
|
* @return string Normalized string without BCMath problems
|
||||||
|
*/
|
||||||
|
public static function localize($value)
|
||||||
|
{
|
||||||
|
$convert = localeconv();
|
||||||
|
$value = str_replace(".", $convert['decimal_point'], (string) $value);
|
||||||
|
if (!empty($convert['negative_sign']) and (strpos($value, "-"))) {
|
||||||
|
$value = str_replace("-", $convert['negative_sign'], $value);
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes exponential numbers to plain string numbers
|
||||||
|
* Fixes a problem of BCMath with numbers containing exponents
|
||||||
|
*
|
||||||
|
* @param integer $value Value to erase the exponent
|
||||||
|
* @param integer $scale (Optional) Scale to use
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function exponent($value, $scale = null)
|
||||||
|
{
|
||||||
|
if (!extension_loaded('bcmath')) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$split = explode('e', $value);
|
||||||
|
if (count($split) == 1) {
|
||||||
|
$split = explode('E', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($split) > 1) {
|
||||||
|
$value = bcmul($split[0], bcpow(10, $split[1], $scale), $scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BCAdd - fixes a problem of BCMath and exponential numbers
|
||||||
|
*
|
||||||
|
* @param string $op1
|
||||||
|
* @param string $op2
|
||||||
|
* @param integer $scale
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function Add($op1, $op2, $scale = null)
|
||||||
|
{
|
||||||
|
$op1 = self::exponent($op1, $scale);
|
||||||
|
$op2 = self::exponent($op2, $scale);
|
||||||
|
|
||||||
|
return bcadd($op1, $op2, $scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BCSub - fixes a problem of BCMath and exponential numbers
|
||||||
|
*
|
||||||
|
* @param string $op1
|
||||||
|
* @param string $op2
|
||||||
|
* @param integer $scale
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function Sub($op1, $op2, $scale = null)
|
||||||
|
{
|
||||||
|
$op1 = self::exponent($op1, $scale);
|
||||||
|
$op2 = self::exponent($op2, $scale);
|
||||||
|
return bcsub($op1, $op2, $scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BCPow - fixes a problem of BCMath and exponential numbers
|
||||||
|
*
|
||||||
|
* @param string $op1
|
||||||
|
* @param string $op2
|
||||||
|
* @param integer $scale
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function Pow($op1, $op2, $scale = null)
|
||||||
|
{
|
||||||
|
$op1 = self::exponent($op1, $scale);
|
||||||
|
$op2 = self::exponent($op2, $scale);
|
||||||
|
return bcpow($op1, $op2, $scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BCMul - fixes a problem of BCMath and exponential numbers
|
||||||
|
*
|
||||||
|
* @param string $op1
|
||||||
|
* @param string $op2
|
||||||
|
* @param integer $scale
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function Mul($op1, $op2, $scale = null)
|
||||||
|
{
|
||||||
|
$op1 = self::exponent($op1, $scale);
|
||||||
|
$op2 = self::exponent($op2, $scale);
|
||||||
|
return bcmul($op1, $op2, $scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BCDiv - fixes a problem of BCMath and exponential numbers
|
||||||
|
*
|
||||||
|
* @param string $op1
|
||||||
|
* @param string $op2
|
||||||
|
* @param integer $scale
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function Div($op1, $op2, $scale = null)
|
||||||
|
{
|
||||||
|
$op1 = self::exponent($op1, $scale);
|
||||||
|
$op2 = self::exponent($op2, $scale);
|
||||||
|
return bcdiv($op1, $op2, $scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BCSqrt - fixes a problem of BCMath and exponential numbers
|
||||||
|
*
|
||||||
|
* @param string $op1
|
||||||
|
* @param integer $scale
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function Sqrt($op1, $scale = null)
|
||||||
|
{
|
||||||
|
$op1 = self::exponent($op1, $scale);
|
||||||
|
return bcsqrt($op1, $scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BCMod - fixes a problem of BCMath and exponential numbers
|
||||||
|
*
|
||||||
|
* @param string $op1
|
||||||
|
* @param string $op2
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function Mod($op1, $op2)
|
||||||
|
{
|
||||||
|
$op1 = self::exponent($op1);
|
||||||
|
$op2 = self::exponent($op2);
|
||||||
|
return bcmod($op1, $op2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BCComp - fixes a problem of BCMath and exponential numbers
|
||||||
|
*
|
||||||
|
* @param string $op1
|
||||||
|
* @param string $op2
|
||||||
|
* @param integer $scale
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function Comp($op1, $op2, $scale = null)
|
||||||
|
{
|
||||||
|
$op1 = self::exponent($op1, $scale);
|
||||||
|
$op2 = self::exponent($op2, $scale);
|
||||||
|
return bccomp($op1, $op2, $scale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!extension_loaded('bcmath')
|
||||||
|
|| (defined('TESTS_ZEND_LOCALE_BCMATH_ENABLED') && !TESTS_ZEND_LOCALE_BCMATH_ENABLED)
|
||||||
|
) {
|
||||||
|
Zend_Locale_Math_PhpMath::disable();
|
||||||
|
}
|
52
library/vendor/Zend/Locale/Math/Exception.php
vendored
Normal file
52
library/vendor/Zend/Locale/Math/Exception.php
vendored
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Zend Framework
|
||||||
|
*
|
||||||
|
* LICENSE
|
||||||
|
*
|
||||||
|
* This source file is subject to the new BSD license that is bundled
|
||||||
|
* with this package in the file LICENSE.txt.
|
||||||
|
* It is also available through the world-wide-web at this URL:
|
||||||
|
* http://framework.zend.com/license/new-bsd
|
||||||
|
* If you did not receive a copy of the license and are unable to
|
||||||
|
* obtain it through the world-wide-web, please send an email
|
||||||
|
* to license@zend.com so we can send you a copy immediately.
|
||||||
|
*
|
||||||
|
* @category Zend
|
||||||
|
* @package Zend_Locale
|
||||||
|
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
|
||||||
|
* @version $Id$
|
||||||
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zend_Exception
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Zend
|
||||||
|
* @package Zend_Locale
|
||||||
|
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
|
||||||
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||||
|
*/
|
||||||
|
class Zend_Locale_Math_Exception extends Zend_Locale_Exception
|
||||||
|
{
|
||||||
|
protected $op1 = null;
|
||||||
|
protected $op2 = null;
|
||||||
|
protected $result = null;
|
||||||
|
|
||||||
|
public function __construct($message, $op1 = null, $op2 = null, $result = null)
|
||||||
|
{
|
||||||
|
$this->op1 = $op1;
|
||||||
|
$this->op2 = $op2;
|
||||||
|
$this->result = $result;
|
||||||
|
parent::__construct($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResults()
|
||||||
|
{
|
||||||
|
return array($this->op1, $this->op2, $this->result);
|
||||||
|
}
|
||||||
|
}
|
239
library/vendor/Zend/Locale/Math/PhpMath.php
vendored
Normal file
239
library/vendor/Zend/Locale/Math/PhpMath.php
vendored
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Zend Framework
|
||||||
|
*
|
||||||
|
* LICENSE
|
||||||
|
*
|
||||||
|
* This source file is subject to the new BSD license that is bundled
|
||||||
|
* with this package in the file LICENSE.txt.
|
||||||
|
* It is also available through the world-wide-web at this URL:
|
||||||
|
* http://framework.zend.com/license/new-bsd
|
||||||
|
* If you did not receive a copy of the license and are unable to
|
||||||
|
* obtain it through the world-wide-web, please send an email
|
||||||
|
* to license@zend.com so we can send you a copy immediately.
|
||||||
|
*
|
||||||
|
* @category Zend
|
||||||
|
* @package Zend_Locale
|
||||||
|
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
|
||||||
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility class for proxying math function to bcmath functions, if present,
|
||||||
|
* otherwise to PHP builtin math operators, with limited detection of overflow conditions.
|
||||||
|
* Sampling of PHP environments and platforms suggests that at least 80% to 90% support bcmath.
|
||||||
|
* This file should only be loaded for the 10% to 20% lacking access to the bcmath extension.
|
||||||
|
*
|
||||||
|
* @category Zend
|
||||||
|
* @package Zend_Locale
|
||||||
|
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
|
||||||
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||||
|
*/
|
||||||
|
class Zend_Locale_Math_PhpMath extends Zend_Locale_Math
|
||||||
|
{
|
||||||
|
public static function disable()
|
||||||
|
{
|
||||||
|
self::$_bcmathDisabled = true;
|
||||||
|
self::$add = array('Zend_Locale_Math_PhpMath', 'Add');
|
||||||
|
self::$sub = array('Zend_Locale_Math_PhpMath', 'Sub');
|
||||||
|
self::$pow = array('Zend_Locale_Math_PhpMath', 'Pow');
|
||||||
|
self::$mul = array('Zend_Locale_Math_PhpMath', 'Mul');
|
||||||
|
self::$div = array('Zend_Locale_Math_PhpMath', 'Div');
|
||||||
|
self::$comp = array('Zend_Locale_Math_PhpMath', 'Comp');
|
||||||
|
self::$sqrt = array('Zend_Locale_Math_PhpMath', 'Sqrt');
|
||||||
|
self::$mod = array('Zend_Locale_Math_PhpMath', 'Mod');
|
||||||
|
self::$scale = array('Zend_Locale_Math_PhpMath', 'Scale');
|
||||||
|
|
||||||
|
self::$defaultScale = 0;
|
||||||
|
self::$defaultPrecision = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static $defaultScale;
|
||||||
|
public static $defaultPrecision;
|
||||||
|
|
||||||
|
|
||||||
|
public static function Add($op1, $op2, $scale = null)
|
||||||
|
{
|
||||||
|
if ($scale === null) {
|
||||||
|
$scale = Zend_Locale_Math_PhpMath::$defaultScale;
|
||||||
|
$precision = Zend_Locale_Math_PhpMath::$defaultPrecision;
|
||||||
|
} else {
|
||||||
|
$precision = pow(10, -$scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($op1)) {
|
||||||
|
$op1 = 0;
|
||||||
|
}
|
||||||
|
$op1 = self::normalize($op1);
|
||||||
|
$op2 = self::normalize($op2);
|
||||||
|
$result = $op1 + $op2;
|
||||||
|
if (is_infinite($result) or (abs($result - $op2 - $op1) > $precision)) {
|
||||||
|
throw new Zend_Locale_Math_Exception("addition overflow: $op1 + $op2 != $result", $op1, $op2, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::round(self::normalize($result), $scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function Sub($op1, $op2, $scale = null)
|
||||||
|
{
|
||||||
|
if ($scale === null) {
|
||||||
|
$scale = Zend_Locale_Math_PhpMath::$defaultScale;
|
||||||
|
$precision = Zend_Locale_Math_PhpMath::$defaultPrecision;
|
||||||
|
} else {
|
||||||
|
$precision = pow(10, -$scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($op1)) {
|
||||||
|
$op1 = 0;
|
||||||
|
}
|
||||||
|
$op1 = self::normalize($op1);
|
||||||
|
$op2 = self::normalize($op2);
|
||||||
|
$result = $op1 - $op2;
|
||||||
|
if (is_infinite($result) or (abs($result + $op2 - $op1) > $precision)) {
|
||||||
|
throw new Zend_Locale_Math_Exception("subtraction overflow: $op1 - $op2 != $result", $op1, $op2, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::round(self::normalize($result), $scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function Pow($op1, $op2, $scale = null)
|
||||||
|
{
|
||||||
|
if ($scale === null) {
|
||||||
|
$scale = Zend_Locale_Math_PhpMath::$defaultScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
$op1 = self::normalize($op1);
|
||||||
|
$op2 = self::normalize($op2);
|
||||||
|
|
||||||
|
// BCMath extension doesn't use decimal part of the power
|
||||||
|
// Provide the same behavior
|
||||||
|
$op2 = ($op2 > 0) ? floor($op2) : ceil($op2);
|
||||||
|
|
||||||
|
$result = pow($op1, $op2);
|
||||||
|
if (is_infinite($result) or is_nan($result)) {
|
||||||
|
throw new Zend_Locale_Math_Exception("power overflow: $op1 ^ $op2", $op1, $op2, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::round(self::normalize($result), $scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function Mul($op1, $op2, $scale = null)
|
||||||
|
{
|
||||||
|
if ($scale === null) {
|
||||||
|
$scale = Zend_Locale_Math_PhpMath::$defaultScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($op1)) {
|
||||||
|
$op1 = 0;
|
||||||
|
}
|
||||||
|
$op1 = self::normalize($op1);
|
||||||
|
$op2 = self::normalize($op2);
|
||||||
|
$result = $op1 * $op2;
|
||||||
|
if (is_infinite($result) or is_nan($result)) {
|
||||||
|
throw new Zend_Locale_Math_Exception("multiplication overflow: $op1 * $op2 != $result", $op1, $op2, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::round(self::normalize($result), $scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function Div($op1, $op2, $scale = null)
|
||||||
|
{
|
||||||
|
if ($scale === null) {
|
||||||
|
$scale = Zend_Locale_Math_PhpMath::$defaultScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($op2)) {
|
||||||
|
throw new Zend_Locale_Math_Exception("can not divide by zero", $op1, $op2, null);
|
||||||
|
}
|
||||||
|
if (empty($op1)) {
|
||||||
|
$op1 = 0;
|
||||||
|
}
|
||||||
|
$op1 = self::normalize($op1);
|
||||||
|
$op2 = self::normalize($op2);
|
||||||
|
$result = $op1 / $op2;
|
||||||
|
if (is_infinite($result) or is_nan($result)) {
|
||||||
|
throw new Zend_Locale_Math_Exception("division overflow: $op1 / $op2 != $result", $op1, $op2, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::round(self::normalize($result), $scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function Sqrt($op1, $scale = null)
|
||||||
|
{
|
||||||
|
if ($scale === null) {
|
||||||
|
$scale = Zend_Locale_Math_PhpMath::$defaultScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($op1)) {
|
||||||
|
$op1 = 0;
|
||||||
|
}
|
||||||
|
$op1 = self::normalize($op1);
|
||||||
|
$result = sqrt($op1);
|
||||||
|
if (is_nan($result)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::round(self::normalize($result), $scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function Mod($op1, $op2)
|
||||||
|
{
|
||||||
|
if (empty($op1)) {
|
||||||
|
$op1 = 0;
|
||||||
|
}
|
||||||
|
if (empty($op2)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
$op1 = self::normalize($op1);
|
||||||
|
$op2 = self::normalize($op2);
|
||||||
|
if ((int)$op2 == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
$result = $op1 % $op2;
|
||||||
|
if (is_nan($result) or (($op1 - $result) % $op2 != 0)) {
|
||||||
|
throw new Zend_Locale_Math_Exception("modulus calculation error: $op1 % $op2 != $result", $op1, $op2, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::normalize($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function Comp($op1, $op2, $scale = null)
|
||||||
|
{
|
||||||
|
if ($scale === null) {
|
||||||
|
$scale = Zend_Locale_Math_PhpMath::$defaultScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($op1)) {
|
||||||
|
$op1 = 0;
|
||||||
|
}
|
||||||
|
$op1 = self::normalize($op1);
|
||||||
|
$op2 = self::normalize($op2);
|
||||||
|
if ($scale <> 0) {
|
||||||
|
$op1 = self::round($op1, $scale);
|
||||||
|
$op2 = self::round($op2, $scale);
|
||||||
|
} else {
|
||||||
|
$op1 = ($op1 > 0) ? floor($op1) : ceil($op1);
|
||||||
|
$op2 = ($op2 > 0) ? floor($op2) : ceil($op2);
|
||||||
|
}
|
||||||
|
if ($op1 > $op2) {
|
||||||
|
return 1;
|
||||||
|
} else if ($op1 < $op2) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function Scale($scale)
|
||||||
|
{
|
||||||
|
if ($scale > 9) {
|
||||||
|
throw new Zend_Locale_Math_Exception("can not scale to precision $scale", $scale, null, null);
|
||||||
|
}
|
||||||
|
self::$defaultScale = $scale;
|
||||||
|
self::$defaultPrecision = pow(10, -$scale);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Zend_Locale_Math_PhpMath::disable(); // disable use of bcmath functions
|
@ -46,7 +46,6 @@ class Monitoring_ListController extends Controller
|
|||||||
$url = clone($this->url);
|
$url = clone($this->url);
|
||||||
|
|
||||||
if ($this->getRequest()->isPost()) {
|
if ($this->getRequest()->isPost()) {
|
||||||
|
|
||||||
if ($request->getPost('sort')) {
|
if ($request->getPost('sort')) {
|
||||||
$url->setParam('sort', $request->getPost('sort'));
|
$url->setParam('sort', $request->getPost('sort'));
|
||||||
if ($request->getPost('dir')) {
|
if ($request->getPost('dir')) {
|
||||||
@ -56,32 +55,6 @@ class Monitoring_ListController extends Controller
|
|||||||
}
|
}
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
$q = $this->getRequest()->getPost('q');
|
|
||||||
if ($q) {
|
|
||||||
list($k, $v) = preg_split('/=/', $q);
|
|
||||||
$url->addParams(array($k => $v));
|
|
||||||
return $url;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$q = $url->shift('q');
|
|
||||||
if ($q !== null) {
|
|
||||||
$action = $this->_request->getActionName();
|
|
||||||
switch($action) {
|
|
||||||
case 'services':
|
|
||||||
$this->params->remove('q')->set('service_description', '*' . $q . '*');
|
|
||||||
break;
|
|
||||||
case 'hosts':
|
|
||||||
$this->params->remove('q')->set('host_name', '*' . $q . '*');
|
|
||||||
break;
|
|
||||||
case 'hostgroups':
|
|
||||||
$this->params->remove('q')->set('hostgroup', '*' . $q . '*');
|
|
||||||
break;
|
|
||||||
case 'servicegroups':
|
|
||||||
$this->params->remove('q')->set('servicegroup', '*' . $q . '*');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -145,7 +118,7 @@ class Monitoring_ListController extends Controller
|
|||||||
'host_max_check_attempts'
|
'host_max_check_attempts'
|
||||||
), $this->extraColumns()));
|
), $this->extraColumns()));
|
||||||
|
|
||||||
$this->applyFilters($query);
|
$this->filterQuery($query);
|
||||||
|
|
||||||
$this->setupSortControl(array(
|
$this->setupSortControl(array(
|
||||||
'host_last_check' => $this->translate('Last Check'),
|
'host_last_check' => $this->translate('Last Check'),
|
||||||
@ -235,7 +208,7 @@ class Monitoring_ListController extends Controller
|
|||||||
), $this->extraColumns());
|
), $this->extraColumns());
|
||||||
$query = $this->backend->select()->from('serviceStatus', $columns);
|
$query = $this->backend->select()->from('serviceStatus', $columns);
|
||||||
|
|
||||||
$this->applyFilters($query);
|
$this->filterQuery($query);
|
||||||
$this->setupSortControl(array(
|
$this->setupSortControl(array(
|
||||||
'service_last_check' => $this->translate('Last Service Check'),
|
'service_last_check' => $this->translate('Last Service Check'),
|
||||||
'service_severity' => $this->translate('Severity'),
|
'service_severity' => $this->translate('Severity'),
|
||||||
@ -308,7 +281,7 @@ class Monitoring_ListController extends Controller
|
|||||||
))->order('downtime_is_in_effect', 'DESC')
|
))->order('downtime_is_in_effect', 'DESC')
|
||||||
->order('downtime_scheduled_start', 'DESC');
|
->order('downtime_scheduled_start', 'DESC');
|
||||||
|
|
||||||
$this->applyFilters($query);
|
$this->filterQuery($query);
|
||||||
|
|
||||||
$this->setupSortControl(array(
|
$this->setupSortControl(array(
|
||||||
'downtime_is_in_effect' => $this->translate('Is In Effect'),
|
'downtime_is_in_effect' => $this->translate('Is In Effect'),
|
||||||
@ -344,7 +317,7 @@ class Monitoring_ListController extends Controller
|
|||||||
'notification_start_time',
|
'notification_start_time',
|
||||||
'notification_state'
|
'notification_state'
|
||||||
));
|
));
|
||||||
$this->applyFilters($query);
|
$this->filterQuery($query);
|
||||||
$this->view->notifications = $query->paginate();
|
$this->view->notifications = $query->paginate();
|
||||||
$this->setupSortControl(array(
|
$this->setupSortControl(array(
|
||||||
'notification_start_time' => $this->translate('Notification Start')
|
'notification_start_time' => $this->translate('Notification Start')
|
||||||
@ -377,7 +350,7 @@ class Monitoring_ListController extends Controller
|
|||||||
'contact_notify_host_flapping',
|
'contact_notify_host_flapping',
|
||||||
'contact_notify_host_downtime',
|
'contact_notify_host_downtime',
|
||||||
));
|
));
|
||||||
$this->applyFilters($query);
|
$this->filterQuery($query);
|
||||||
$this->view->contacts = $query->paginate();
|
$this->view->contacts = $query->paginate();
|
||||||
|
|
||||||
$this->setupSortControl(array(
|
$this->setupSortControl(array(
|
||||||
@ -406,7 +379,7 @@ class Monitoring_ListController extends Controller
|
|||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
|
|
||||||
$orientation = $this->params->shift('vertical', 0) ? 'vertical' : 'horizontal';
|
$orientation = $this->params->shift('vertical', 0) ? 'vertical' : 'horizontal';
|
||||||
|
/*
|
||||||
$orientationBox = new SelectBox(
|
$orientationBox = new SelectBox(
|
||||||
'orientation',
|
'orientation',
|
||||||
array(
|
array(
|
||||||
@ -417,16 +390,16 @@ class Monitoring_ListController extends Controller
|
|||||||
'horizontal'
|
'horizontal'
|
||||||
);
|
);
|
||||||
$orientationBox->applyRequest($this->getRequest());
|
$orientationBox->applyRequest($this->getRequest());
|
||||||
|
*/
|
||||||
$query = $this->backend->select()->from(
|
$query = $this->backend->select()->from(
|
||||||
'eventgrid',
|
'eventgrid',
|
||||||
array('day', $form->getValue('state'))
|
array('day', $form->getValue('state'))
|
||||||
);
|
);
|
||||||
$this->params->remove(array('objecttype', 'from', 'to', 'state', 'btn_submit'));
|
$this->params->remove(array('objecttype', 'from', 'to', 'state', 'btn_submit'));
|
||||||
$this->applyFilters($query);
|
$this->filterQuery($query);
|
||||||
$this->view->summary = $query->getQuery()->fetchAll();
|
$this->view->summary = $query->getQuery()->fetchAll();
|
||||||
$this->view->column = $form->getValue('state');
|
$this->view->column = $form->getValue('state');
|
||||||
$this->view->orientationBox = $orientationBox;
|
// $this->view->orientationBox = $orientationBox;
|
||||||
$this->view->orientation = $orientation;
|
$this->view->orientation = $orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,7 +417,7 @@ class Monitoring_ListController extends Controller
|
|||||||
'contact_email',
|
'contact_email',
|
||||||
'contact_pager',
|
'contact_pager',
|
||||||
))->order('contactgroup_alias');
|
))->order('contactgroup_alias');
|
||||||
$this->applyFilters($query);
|
$this->filterQuery($query);
|
||||||
|
|
||||||
// Fetch and prepare all contact groups:
|
// Fetch and prepare all contact groups:
|
||||||
$contactgroups = $query->getQuery()->fetchAll();
|
$contactgroups = $query->getQuery()->fetchAll();
|
||||||
@ -481,7 +454,7 @@ class Monitoring_ListController extends Controller
|
|||||||
'host' => 'comment_host',
|
'host' => 'comment_host',
|
||||||
'service' => 'comment_service'
|
'service' => 'comment_service'
|
||||||
));
|
));
|
||||||
$this->applyFilters($query);
|
$this->filterQuery($query);
|
||||||
$this->view->comments = $query->paginate();
|
$this->view->comments = $query->paginate();
|
||||||
|
|
||||||
$this->setupSortControl(
|
$this->setupSortControl(
|
||||||
@ -519,7 +492,7 @@ class Monitoring_ListController extends Controller
|
|||||||
'services_warning_unhandled',
|
'services_warning_unhandled',
|
||||||
'services_pending'
|
'services_pending'
|
||||||
));
|
));
|
||||||
$this->applyFilters($query);
|
$this->filterQuery($query);
|
||||||
$this->view->servicegroups = $query->paginate();
|
$this->view->servicegroups = $query->paginate();
|
||||||
$this->setupSortControl(array(
|
$this->setupSortControl(array(
|
||||||
'servicegroup_name' => $this->translate('Servicegroup Name')
|
'servicegroup_name' => $this->translate('Servicegroup Name')
|
||||||
@ -550,7 +523,7 @@ class Monitoring_ListController extends Controller
|
|||||||
'services_warning_unhandled',
|
'services_warning_unhandled',
|
||||||
'services_pending'
|
'services_pending'
|
||||||
));
|
));
|
||||||
$this->applyFilters($query);
|
$this->filterQuery($query);
|
||||||
$this->view->hostgroups = $query->paginate();
|
$this->view->hostgroups = $query->paginate();
|
||||||
$this->setupSortControl(array(
|
$this->setupSortControl(array(
|
||||||
'hostgroup_name' => $this->translate('Hostgroup Name')
|
'hostgroup_name' => $this->translate('Hostgroup Name')
|
||||||
@ -581,7 +554,7 @@ class Monitoring_ListController extends Controller
|
|||||||
$this->setupSortControl(array(
|
$this->setupSortControl(array(
|
||||||
'timestamp' => 'Occurence'
|
'timestamp' => 'Occurence'
|
||||||
));
|
));
|
||||||
$this->applyFilters($query);
|
$this->filterQuery($query);
|
||||||
$this->view->history = $query->paginate();
|
$this->view->history = $query->paginate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -599,7 +572,7 @@ class Monitoring_ListController extends Controller
|
|||||||
'service_output',
|
'service_output',
|
||||||
'service_handled'
|
'service_handled'
|
||||||
));
|
));
|
||||||
$this->applyFilters($query);
|
$this->filterQuery($query);
|
||||||
$this->setupSortControl(array(
|
$this->setupSortControl(array(
|
||||||
'host_name' => $this->translate('Hostname'),
|
'host_name' => $this->translate('Hostname'),
|
||||||
'service_description' => $this->translate('Service description')
|
'service_description' => $this->translate('Service description')
|
||||||
@ -610,52 +583,20 @@ class Monitoring_ListController extends Controller
|
|||||||
$this->view->verticalPaginator = $pivot->paginateYAxis();
|
$this->view->verticalPaginator = $pivot->paginateYAxis();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function applyFilters($query)
|
protected function filterQuery($query)
|
||||||
{
|
{
|
||||||
$params = clone $this->params;
|
$editor = Widget::create('filterEditor')
|
||||||
$request = $this->getRequest();
|
->setQuery($query)
|
||||||
|
->preserveParams('limit', 'sort', 'dir', 'format', 'view', 'backend')
|
||||||
|
->ignoreParams('page', 'objecttype', 'from', 'to', 'state', 'btn_submit')
|
||||||
|
->handleRequest($this->getRequest());
|
||||||
|
$query->applyFilter($editor->getFilter());
|
||||||
|
|
||||||
$limit = $params->shift('limit');
|
$this->view->filterEditor = $editor;
|
||||||
$sort = $params->shift('sort');
|
$this->view->filter = $editor->getFilter();
|
||||||
$dir = $params->shift('dir');
|
|
||||||
$page = $params->shift('page');
|
|
||||||
$format = $params->shift('format');
|
|
||||||
$view = $params->shift('view');
|
|
||||||
$backend = $params->shift('backend');
|
|
||||||
$modifyFilter = $params->shift('modifyFilter', false);
|
|
||||||
$removeFilter = $params->shift('removeFilter', false);
|
|
||||||
|
|
||||||
$filter = Filter::fromQueryString((string) $params);
|
if ($sort = $this->params->get('sort')) {
|
||||||
$this->view->filterPreview = Widget::create('filterWidget', $filter);
|
$query->order($sort, $this->params->get('dir'));
|
||||||
|
|
||||||
if ($removeFilter) {
|
|
||||||
$redirect = $this->url->without('page');
|
|
||||||
if ($filter->getById($removeFilter)->isRootNode()) {
|
|
||||||
$redirect->setQueryString('');
|
|
||||||
} else {
|
|
||||||
$filter->removeId($removeFilter);
|
|
||||||
$redirect->setQueryString($filter->toQueryString())
|
|
||||||
->getParams()->add('modifyFilter');
|
|
||||||
}
|
|
||||||
$this->redirectNow($redirect);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($modifyFilter) {
|
|
||||||
if ($this->_request->isPost()) {
|
|
||||||
$filter = $filter->applyChanges($this->_request->getPost());
|
|
||||||
$this->redirectNow($this->url->without('page')->setQueryString($filter->toQueryString()));
|
|
||||||
}
|
|
||||||
$this->view->filterEditor = Widget::create('filterEditor', array(
|
|
||||||
'filter' => $filter,
|
|
||||||
'query' => $query
|
|
||||||
));
|
|
||||||
}
|
|
||||||
if (! $filter->isEmpty()) {
|
|
||||||
$query->applyFilter($filter);
|
|
||||||
}
|
|
||||||
$this->view->filter = $filter;
|
|
||||||
if ($sort) {
|
|
||||||
$query->order($sort, $dir);
|
|
||||||
}
|
}
|
||||||
$this->applyRestrictions($query);
|
$this->applyRestrictions($query);
|
||||||
$this->handleFormatRequest($query);
|
$this->handleFormatRequest($query);
|
||||||
|
@ -166,7 +166,7 @@ class Monitoring_ShowController extends Controller
|
|||||||
'notification_contact',
|
'notification_contact',
|
||||||
'notification_start_time',
|
'notification_start_time',
|
||||||
'notification_state'
|
'notification_state'
|
||||||
));
|
))->order('notification_start_time');
|
||||||
|
|
||||||
$notifications->where('contact_object_id', $contact->contact_object_id);
|
$notifications->where('contact_object_id', $contact->contact_object_id);
|
||||||
|
|
||||||
|
@ -2,5 +2,5 @@
|
|||||||
$helpMessage = $this->translate('Press and hold the Ctrl key while clicking on rows to select multiple rows or press and hold the Shift key to select a range of rows.', 'multiselection');
|
$helpMessage = $this->translate('Press and hold the Ctrl key while clicking on rows to select multiple rows or press and hold the Shift key to select a range of rows.', 'multiselection');
|
||||||
?>
|
?>
|
||||||
<div class="selection-info">
|
<div class="selection-info">
|
||||||
<span class="selection-info-count">0</span> <?= $this->translate('row(s) selected', 'multiselection') ?> <?= $this->icon('flash', $helpMessage) ?>
|
<span class="selection-info-count">0</span> <?= $this->translate('row(s) selected', 'multiselection') ?> <?= $this->icon('help', $helpMessage) ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -6,12 +6,15 @@ $currentUrl = Url::fromRequest()->getRelativeUrl();
|
|||||||
|
|
||||||
?><h3 class="tinystatesummary" <?= $this->compact ? ' data-base-target="col1"' : '' ?>>
|
?><h3 class="tinystatesummary" <?= $this->compact ? ' data-base-target="col1"' : '' ?>>
|
||||||
<?= $this->qlink(sprintf($this->translate('%s services:'), $this->stats->services_total), $selfUrl) ?>
|
<?= $this->qlink(sprintf($this->translate('%s services:'), $this->stats->services_total), $selfUrl) ?>
|
||||||
|
<?php if ($this->stats->services_ok): ?>
|
||||||
<span class="state ok<?= $currentUrl === Url::fromPath($selfUrl, array('service_state' => 0))->getRelativeUrl() ? ' active' : '' ?>"><?= $this->qlink(
|
<span class="state ok<?= $currentUrl === Url::fromPath($selfUrl, array('service_state' => 0))->getRelativeUrl() ? ' active' : '' ?>"><?= $this->qlink(
|
||||||
$this->stats->services_ok,
|
$this->stats->services_ok,
|
||||||
$selfUrl,
|
$selfUrl,
|
||||||
array('service_state' => 0),
|
array('service_state' => 0),
|
||||||
array('title' => sprintf($this->translate('Services with state %s'), strtoupper($this->translate('ok'))))
|
array('title' => sprintf($this->translate('Services with state %s'), strtoupper($this->translate('ok'))))
|
||||||
) ?></span>
|
) ?></span>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $state) {
|
foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $state) {
|
||||||
|
@ -8,14 +8,8 @@ use Icinga\Web\Widget\Chart\HistoryColorGrid;
|
|||||||
<div class="controls">
|
<div class="controls">
|
||||||
<?= $this->tabs->render($this); ?>
|
<?= $this->tabs->render($this); ?>
|
||||||
<div class="fake-controls">
|
<div class="fake-controls">
|
||||||
<br />
|
|
||||||
<?= $form ?>
|
<?= $form ?>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
|
||||||
<?php if (! $this->filterEditor): ?>
|
|
||||||
<?= $this->filterPreview ?>
|
|
||||||
<?php endif ?>
|
|
||||||
<?= $this->filterEditor ?>
|
|
||||||
</div>
|
</div>
|
||||||
<? endif; ?>
|
<? endif; ?>
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
<div style="margin: 1em" class="dontprint">
|
<div style="margin: 1em" class="dontprint">
|
||||||
<?= $this->translate('Sort by'); ?> <?= $this->sortControl->render($this); ?>
|
<?= $this->translate('Sort by'); ?> <?= $this->sortControl->render($this); ?>
|
||||||
</div>
|
</div>
|
||||||
<?= $form ?>
|
|
||||||
<br />
|
|
||||||
<?= $this->widget('limiter', array('url' => $this->url, 'max' => $this->history->count())); ?>
|
<?= $this->widget('limiter', array('url' => $this->url, 'max' => $this->history->count())); ?>
|
||||||
<?= $this->paginationControl($history, null, null, array('preserve' => $this->preserve)); ?>
|
<?= $this->paginationControl($history, null, null, array('preserve' => $this->preserve)); ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -9,9 +9,6 @@ if ($this->compact): ?>
|
|||||||
<div style="margin: 1em;" class="dontprint">
|
<div style="margin: 1em;" class="dontprint">
|
||||||
<?= $this->render('list/components/hostssummary.phtml') ?>
|
<?= $this->render('list/components/hostssummary.phtml') ?>
|
||||||
<?= $this->translate('Sort by') ?> <?= $this->sortControl->render($this) ?>
|
<?= $this->translate('Sort by') ?> <?= $this->sortControl->render($this) ?>
|
||||||
<?php if (! $this->filterEditor): ?>
|
|
||||||
<?= $this->filterPreview ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?= $this->widget('limiter')->setMaxLimit($this->hosts->count()) ?>
|
<?= $this->widget('limiter')->setMaxLimit($this->hosts->count()) ?>
|
||||||
|
@ -8,10 +8,9 @@ if (!$this->compact): ?>
|
|||||||
<?= $this->tabs ?>
|
<?= $this->tabs ?>
|
||||||
<div style="margin: 1em;" class="dontprint">
|
<div style="margin: 1em;" class="dontprint">
|
||||||
<?= $this->render('list/components/servicesummary.phtml') ?>
|
<?= $this->render('list/components/servicesummary.phtml') ?>
|
||||||
|
<div style="float: right">
|
||||||
<?= $this->translate('Sort by') ?> <?= $this->sortControl ?>
|
<?= $this->translate('Sort by') ?> <?= $this->sortControl ?>
|
||||||
<?php if (! $this->filterEditor): ?>
|
</div>
|
||||||
<?= $this->filterPreview ?>
|
|
||||||
<?php endif ?>
|
|
||||||
</div>
|
</div>
|
||||||
<?php if ($this->limit === 0): ?>
|
<?php if ($this->limit === 0): ?>
|
||||||
<?= $this->widget('limiter') ?>
|
<?= $this->widget('limiter') ?>
|
||||||
@ -19,8 +18,10 @@ if (!$this->compact): ?>
|
|||||||
<?= $this->widget('limiter')->setCurrentPageCount($this->services->count()) ?>
|
<?= $this->widget('limiter')->setCurrentPageCount($this->services->count()) ?>
|
||||||
<?= $this->paginationControl($services, null, null, array('preserve' => $this->preserve)) ?>
|
<?= $this->paginationControl($services, null, null, array('preserve' => $this->preserve)) ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?= $this->selectionToolbar('multi', $this->href('monitoring/services/show?' . $this->filter->toQueryString())) ?>
|
<!--
|
||||||
|
<?= $this->selectionToolbar('multi', $this->href('monitoring/services/show?' . $this->filterEditor->getFilter()->toQueryString())) ?>
|
||||||
<?= $this->render('list/components/selectioninfo.phtml') ?>
|
<?= $this->render('list/components/selectioninfo.phtml') ?>
|
||||||
|
-->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user