/**
  * Execute hook
  *
  * @param array $params
  */
 public static function execute($params)
 {
     $router = Di::getDefault()->get('router');
     if (!preg_match("/^\\/centreon-customview/", $router->getCurrentUri())) {
         return;
     }
     $user = $_SESSION['user'];
     $bookmarkedViews = CustomviewRepository::getCustomViewsOfUser($user->getId());
     $publicViews = CustomviewRepository::getPublicViews();
     foreach ($publicViews as $viewId => $view) {
         if (isset($bookmarkedViews[$viewId])) {
             unset($publicViews[$viewId]);
         }
     }
     return array('template' => 'displayLeftMenu.tpl', 'variables' => array('bookmarkedViews' => $bookmarkedViews, 'publicViews' => $publicViews));
 }
    /**
     * Action for custom view
     *
     * @method get
     * @route /[i:id]?
     */
    public function customviewAction()
    {
        if (isset($_SESSION['customview_filters'])) {
            unset($_SESSION['customview_filters']);
        }
        $this->currentView = CustomviewRepository::getCurrentView($this->user->getId(), $this->getParams());
        $template = Di::getDefault()->get('template');
        $template->addCss('jquery.gridster.min.css')->addCss('centreon-widget.css')->addCss('centreon-wizard.css')->addCss('select2.css')->addCss('select2-bootstrap.css');
        $template->addJs('jquery.gridster.min.js')->addJs('jquery.gridster.with-extras.min.js')->addJs('centreon-wizard.js')->addJs('bootbox.min.js')->addJs('jquery.select2/select2.min.js');
        $customViews = CustomviewRepository::getCustomViewsOfUser($this->user->getId());
        $jsonPosition = "[]";
        if (isset($customViews[$this->currentView]) && $customViews[$this->currentView]['position']) {
            $jsonPosition = $customViews[$this->currentView]['position'];
        }
        $widgets = WidgetRepository::getWidgetsFromViewId($this->currentView);
        $jsonWidgets = "[]";
        if (is_array($widgets)) {
            $jsonWidgets = json_encode($widgets);
        }
        $gridJs = '
            $(function() {
                ' . $this->getJsFunctionSavePos() . '
                ' . $this->getJsFunctionRemoveWidget() . '
                ' . $this->getJsInitGrid($jsonPosition, $jsonWidgets) . '
                ' . $this->getJsEditView("#view_add", "{$this->baseUrl}/centreon-customview/updateview") . '
                ' . $this->getJsEditView("#view_settings", "{$this->baseUrl}/centreon-customview/updateview/{$this->currentView}") . '
                ' . $this->getJsDeleteView() . '
                ' . $this->getJsDefault() . '
                ' . $this->getJsBookmark() . '
                ' . $this->getJsWidgetList() . '
                ' . $this->getJsRemoveWidget() . '
                ' . $this->getJsWidgetSettings() . '
            });';
        $template->addCustomJs($gridJs);
        $filters = CustomviewRepository::getViewFilters($this->currentView);
        $options = '<option value=""></option>';
        foreach ($filters as $k => $v) {
            $options .= sprintf('<option value="%s">%s</option>', $k, $v);
        }
        $filterHtml = '
<div class="filter-div col-md-2"> 
    <div class="remove-filter fa fa-times-circle"></div> 
    <div> 
        <select class="filter-name form-control input-sm"> 
            ' . $options . '
        </select> 
    </div> 
    <div>
        <select class="filter-cmp form-control input-sm">
            <option value="' . CustomviewRepository::EQUAL . '">equal</option>
            <option value="' . CustomviewRepository::NOT_EQUAL . '">not equal</option>
            <option value="' . CustomviewRepository::CONTAINS . '">contains</option>
            <option value="' . CustomviewRepository::NOT_CONTAINS . '">not contains</option>
            <option value="' . CustomviewRepository::GREATER . '">greater than</option>
            <option value="' . CustomviewRepository::GREATER_EQUAL . '">greater or equal</option>
            <option value="' . CustomviewRepository::LESSER . '">lesser than</option>
            <option value="' . CustomviewRepository::LESSER_EQUAL . '">lesser or equal</option>
        </select>
    </div>
    <div> 
        <input type="text" class="filter-value form-control input-sm"></input> 
    </div> 
</div>';
        $template->assign('filterHtml', $filterHtml);
        $template->assign('filterHtmlForJs', str_replace(array("\r", "\n"), "", $filterHtml));
        $template->display('file:[CentreonCustomviewModule]customview.tpl');
    }