initDefaultButtons() protected method

Initializes the default buttons (view, update and delete).
protected initDefaultButtons ( )
 protected function initDefaultButtons()
 {
     parent::initDefaultButtons();
     /* Кнопка просмотра на фронте */
     if ($this->frontViewButtonLabel === null) {
         $this->frontViewButtonLabel = Yii::t('zii', 'View');
     }
     $button = array('label' => $this->frontViewButtonLabel, 'url' => $this->frontViewButtonUrl ?: function ($data) {
         try {
             return $data->{$this->frontViewGetUrlMethodName}();
         } catch (\Exception $e) {
             return null;
         }
     }, 'options' => $this->frontViewButtonOptions, 'icon' => $this->frontViewButtonIcon);
     if (isset($this->buttons['front_view'])) {
         $this->buttons['front_view'] = array_merge($button, $this->buttons['front_view']);
     } else {
         /* показывать кнопку только если задали ей свой url, или модель имеет метод для получения url*/
         $button['visible'] = function ($row, $data) {
             // todo: найти нормальный способ узнавания есть ли у модели метод
             try {
                 return $this->frontViewButtonUrl || method_exists($data, $this->frontViewGetUrlMethodName) || (bool) $data->{$this->frontViewGetUrlMethodName}();
             } catch (\Exception $e) {
                 return false;
             }
         };
         $this->buttons['front_view'] = $button;
     }
 }
 /**
  * Initializes the default buttons (view, update and delete).
  */
 protected function initDefaultButtons()
 {
     parent::initDefaultButtons();
     /**
      * add custom with msgbox instead
      */
     $this->buttons['delete']['click'] = strtr($this->buttons['delete']['click'], array('yiiGridView' => 'yiiJsonGridView'));
 }
 /**
  *### .initDefaultButtons()
  *
  * Initializes the default buttons (view, update and delete).
  */
 protected function initDefaultButtons()
 {
     parent::initDefaultButtons();
     if ($this->viewButtonType !== false && !isset($this->buttons['view']['type'])) {
         $this->buttons['view']['type'] = $this->viewButtonType;
     }
     if ($this->updateButtonType !== false && !isset($this->buttons['update']['type'])) {
         $this->buttons['update']['type'] = $this->updateButtonType;
     }
     if ($this->deleteButtonType !== false && !isset($this->buttons['delete']['type'])) {
         $this->buttons['delete']['type'] = $this->deleteButtonType;
     }
 }
 protected function initDefaultButtons()
 {
     $this->template = '{audit} {view} {update} {delete}';
     parent::initDefaultButtons();
     if ($this->auditButtonLabel === null) {
         $this->auditButtonLabel = Yii::t("AudittrailModule.main", "Auditrail");
     }
     $button = array('label' => $this->auditButtonLabel, 'url' => $this->auditButtonUrl, 'imageUrl' => $this->auditButtonImageUrl, 'options' => $this->auditButtonOptions, 'icon' => $this->auditButtonIcon);
     if (isset($this->buttons['audit'])) {
         $this->buttons['audit'] = array_merge($button, $this->buttons['audit']);
     } else {
         $this->buttons['audit'] = $button;
     }
 }
Ejemplo n.º 5
0
    /**
     *
     */
    protected function initDefaultButtons()
    {
        parent::initDefaultButtons();
        $this->template = '<div class="btn-group">' . $this->template . '</div>';
        if ($this->frontViewButtonLabel === null) {
            $this->frontViewButtonLabel = Yii::t('zii', 'View');
        }
        if ($this->frontViewButtonUrl) {
            $this->buttons['front_view'] = ['label' => $this->frontViewButtonLabel, 'url' => $this->frontViewButtonUrl, 'options' => $this->frontViewButtonOptions, 'icon' => $this->frontViewButtonIcon];
        } else {
            $this->buttons['front_view'] = ['visible' => function () {
                return false;
            }];
        }
        if (is_string($this->deleteConfirmation)) {
            $confirmation = "if(!confirm(" . \CJavaScript::encode($this->deleteConfirmation) . ")) return false;";
        } else {
            $confirmation = '';
        }
        if (Yii::app()->request->enableCsrfValidation) {
            $csrfTokenName = Yii::app()->getRequest()->csrfTokenName;
            $csrfToken = Yii::app()->getRequest()->csrfToken;
            $csrf = "\n\t\tdata:{ '{$csrfTokenName}':'{$csrfToken}' },";
        } else {
            $csrf = '';
        }
        if ($this->afterDelete === null) {
            $this->afterDelete = 'function(){}';
        }
        $this->buttons['delete']['click'] = <<<EOD
function() {
\t{$confirmation}
\tvar th = this,
\t\tafterDelete = {$this->afterDelete};
\tjQuery('#{$this->grid->id}').yiiGridView('update', {
\t\ttype: 'POST',
\t\turl: jQuery(this).attr('href'),{$csrf}
\t\tsuccess: function(data) {
\t\t\tjQuery('#{$this->grid->id}').yiiGridView('update', {url: document.location.href });
\t\t\tafterDelete(th, true, data);
\t\t},
\t\terror: function(XHR) {
\t\t\treturn afterDelete(th, false, XHR);
\t\t}
\t});
\treturn false;
}
EOD;
    }
Ejemplo n.º 6
0
 /**
  *
  */
 protected function initDefaultButtons()
 {
     parent::initDefaultButtons();
     $this->template = '<div class="btn-group">' . $this->template . '</div>';
     if ($this->frontViewButtonLabel === null) {
         $this->frontViewButtonLabel = Yii::t('zii', 'View');
     }
     if ($this->frontViewButtonUrl) {
         $this->buttons['front_view'] = ['label' => $this->frontViewButtonLabel, 'url' => $this->frontViewButtonUrl, 'options' => $this->frontViewButtonOptions, 'icon' => $this->frontViewButtonIcon];
     } else {
         $this->buttons['front_view'] = ['visible' => function () {
             return false;
         }];
     }
 }