Example #1
0
 /**
  * Get HTML code for header
  * @param Table $table
  * @return string
  */
 public function getHeaderCode(\mpf\widgets\datatable\Table $table)
 {
     $label = $this->getLabel();
     if (!$this->order) {
         return $label;
     }
     $order = $this->dataProvider->getOrder();
     $prefix = '';
     $this->iconArrowUp = str_replace(array('%DATATABLE_ASSETS%', '%SIZE%'), array($table->getAssetsURL(), $this->iconSize . 'x' . $this->iconSize), $this->iconArrowUp);
     $this->iconArrowDown = str_replace(array('%DATATABLE_ASSETS%', '%SIZE%'), array($table->getAssetsURL(), $this->iconSize . 'x' . $this->iconSize), $this->iconArrowDown);
     if ('%MPF_ASSETS%' == substr($this->iconArrowUp, 0, 12)) {
         $this->iconArrowUp = AssetsPublisher::get()->mpfAssetFile(substr($this->iconArrowUp, 12));
     }
     if ('%MPF_ASSETS%' == substr($this->iconArrowDown, 0, 12)) {
         $this->iconArrowDown = AssetsPublisher::get()->mpfAssetFile(substr($this->iconArrowDown, 12));
     }
     if ($order[0] == (is_string($this->order) ? $this->order : '`' . $this->name . '`')) {
         $prefix = 'ASC' == $order[1] ? Html::get()->image($this->iconArrowUp, 'Order Descendent', ['class' => 'order-by-img']) : Html::get()->image($this->iconArrowDown, 'Order Ascendent', ['class' => 'order-by-img']);
     }
     return $this->dataProvider->getColumnOrderLink(is_string($this->order) ? $this->order : '`' . $this->name . '`', $prefix . $label);
 }
Example #2
0
 protected function getForm($row, Table $table)
 {
     $this->formHTMLOptions['style'] = (isset($this->formHTMLOptions['style']) ? $this->formHTMLOptions['style'] : '') . 'display:none;';
     $this->formHTMLOptions['method'] = 'post';
     $this->formHTMLOptions['is-ajax'] = $this->ajax ? '1' : '0';
     $this->formHTMLOptions['action'] = $this->url ? is_array($this->url) ? WebApp::get()->request()->createURL($this->url[0], $this->url[1], isset($this->url[2]) ? $this->url[2] : [], isset($this->url[3]) ? $this->url[3] : null) : $this->url : '';
     $form = Form::get()->openForm($this->formHTMLOptions);
     switch ($this->type) {
         case 'input':
         case 'password':
         case 'email':
             $form .= Form::get()->input($this->name, str_replace('input', 'text', $this->type), $row->{$this->name}, $this->inputHTMLOptions);
             break;
         case 'date':
             $form .= Form::get()->input($this->name, str_replace('input', 'date', $this->type), $row->{$this->name}, $this->inputHTMLOptions);
             break;
         case 'select':
             $form .= Form::get()->select($this->name, $this->options, $row->{$this->name}, $this->inputHTMLOptions);
             break;
         case 'default':
             trigger_error("Invalid type {$this->type}!");
             break;
     }
     $form .= Form::get()->hiddenInput($this->key, $row->{$this->key});
     $this->saveButtonIcon = str_replace(array('%DATATABLE_ASSETS%', '%SIZE%'), array($table->getAssetsURL(), $this->iconSize . 'x' . $this->iconSize), $this->saveButtonIcon);
     $this->cancelButtonIcon = str_replace(array('%DATATABLE_ASSETS%', '%SIZE%'), array($table->getAssetsURL(), $this->iconSize . 'x' . $this->iconSize), $this->cancelButtonIcon);
     if ('%MPF_ASSETS%' == substr($this->saveButtonIcon, 0, 12)) {
         $this->saveButtonIcon = AssetsPublisher::get()->mpfAssetFile(substr($this->saveButtonIcon, 12));
     }
     if ('%MPF_ASSETS%' == substr($this->cancelButtonIcon, 0, 12)) {
         $this->cancelButtonIcon = AssetsPublisher::get()->mpfAssetFile(substr($this->cancelButtonIcon, 12));
     }
     if ($this->showSaveButton) {
         $form .= Form::get()->imageButton($this->saveButtonIcon, $this->saveButtonLabel, '', '', ['class' => 'inline-save-button']);
     }
     if ($this->showCancelButton) {
         $form .= Form::get()->imageButton($this->cancelButtonIcon, $this->cancelButtonLabel, '', '', ['class' => 'inline-cancel-button']);
     }
     return $form . Form::get()->closeForm();
 }
Example #3
0
 /**
  * Get HTML img tag for icon or an empty string if there is no icon
  * @param string $title
  * @param \mpf\widgets\datatable\Table $table
  * @return string
  */
 public function getIcon($title, Table $table)
 {
     if ($this->icon) {
         $icon = str_replace(array('%DATATABLE_ASSETS%', '%SIZE%'), array($table->getAssetsURL(), $this->iconSize . 'x' . $this->iconSize), $this->icon);
         if ('%MPF_ASSETS%' == substr($icon, 0, 12)) {
             $icon = AssetsPublisher::get()->mpfAssetFile(substr($icon, 12));
         }
         return Html::get()->image($icon, $title);
     }
     return '';
 }