public function _default()
 {
     $breadcrumbs = BreadCrumbs::getInstance()->addCrumb(Converter::symb2Ttl(P))->addCrumb('All');
     $data = new EmailSubscriberEntityRepository();
     $table = CmsTable::getInstance()->addData($data)->addColumn(ColumnData::getInstance('email')->dataType('email')->enableOrderableColumn())->addColumn(ColumnData::getInstance('ts')->title('Date')->dataType('ts2date')->enableOrderableColumn())->addColumn(ColumnEdit::getInstance('edit')->href('?p=' . P . '&do=edit&id={%id%}')->width('1%')->value('Edit'))->addColumn(ColumnActive::getInstance('active')->href('?p=' . P . '&do=_active&id={%id%}')->enableOrderableColumn()->ajax(true))->addColumn(ColumnDelete::getInstance('delete')->href('?p=' . P . '&do=_delete&id={%id%}'));
     echo $breadcrumbs;
     echo $table;
 }
 /** Main view */
 public function _default()
 {
     $feedback_collection = new FeedbackRepository();
     $feedback_collection->addOrderByField('date_created', true);
     echo Columns::getInstance()->add('<a href="?p=' . P . '&do=_remove_unconfirmed" class="btn btn-danger">Remove unconfirmed</a>
         &nbsp;&nbsp;&nbsp;&nbsp;<a href="?p=' . P . '&do=_remove_dupes" class="btn btn-warning">Remove duplicate emails</a>', ['align' => 'right']);
     echo CmsTable::getInstance()->addData($feedback_collection)->addColumn(ColumnData::getInstance('date_created')->enableOrderableColumn()->disableNewlines()->enableRightAlign()->setHref('?p=' . P . '&do=view&id={%id%}')->dataType('ts2datetime')->setTitle('Date'))->addColumn(ColumnData::getInstance('name')->enableOrderableColumn())->addColumn(ColumnData::getInstance('phone')->enableOrderableColumn())->addColumn(ColumnData::getInstance('email')->enableOrderableColumn()->dataType('email'))->addColumn(ColumnAccept::getInstance('done')->setHref('?p=' . P . '&do=_done&id={%id%}')->enableOrderableColumn())->addColumn(ColumnDelete::getInstance()->setHref('?p=' . P . '&do=_delete&id={%id%}'))->attachFilterForm(FilterForm::getInstance()->setWidth('100%')->addFilter('Email', Text::getInstance('email')->actAs('like')));
 }
 public function _default()
 {
     $breadcrumbs = BreadCrumbs::getInstance()->addCrumb(ucfirst(P))->addCrumb('All Reviews');
     $reviews = new ReviewEntityRepository();
     $reviews->addSimpleSelectFields(['id', 'title', 'active', 'image']);
     $reviews->addSimpleSelectFieldsAsString('"0" as `images`');
     $reviews->addOrderByField('id');
     $images = new ImageRepository();
     $images->addSimpleSelectFieldsAsString('(SELECT COUNT(*) FROM `' . $images->getDbTableName() . '` WHERE `item_id` = `' . $reviews->getDbTableName() . '`.`id` AND `item_type` = "review") AS `images`');
     $reviews->mergeWithCollection($images, 'id', 'item_id', 'left');
     $table = CmsTable::getInstance()->addData($reviews)->addColumn(ColumnImg::getInstance('image')->imgHeight('100'))->addColumn(ColumnEdit::getInstance('title')->enableOrderableColumn()->enableTranslationColumn()->setHref('?p=' . P . '&do=edit&id={%id%}'))->addColumn(ColumnData::getInstance('images')->enableOrderableColumn()->setWidth('1%')->enableRightAlign()->setHref('?p=' . P . '&do=images&id={%id%}'))->addColumn(ColumnActive::getInstance('active')->setHref('?p=' . P . '&do=_active&id={%id%}')->enableOrderableColumn()->enableAjax())->addColumn(ColumnDelete::getInstance('delete')->setHref('?p=' . P . '&do=_delete&id={%id%}'));
     echo Columns::getInstance()->add($breadcrumbs)->add('<a class="btn btn-success" href="?p=' . P . '&do=add">Add Review</a>', ['align' => 'right']);
     echo $table;
 }
 /** Tags */
 public function tags()
 {
     $tags = new ArticleTagEntityRepository();
     echo BreadCrumbs::getInstance()->addCrumb(__('Articles'))->addCrumb(__('Tags'));
     echo Columns::getInstance()->add('<a class="btn btn-success" href="?p=' . P . '&do=tags_add">' . __('Add Tag') . '</a><br><br>', ['align' => 'right']);
     echo CmsTable::getInstance()->addData($tags)->addColumn(ColumnData::getInstance('title')->enableTranslationColumn())->addColumn(ColumnEdit::getInstance('edit'))->addColumn(ColumnActive::getInstance('active'))->addColumn(ColumnDelete::getInstance('delete'));
 }
示例#5
0
 /** Categories */
 public static function categories()
 {
     $categories = new FaqCategoryEntityRepository();
     $categories->addOrderByField('id');
     echo Columns::getInstance()->add('<a class="btn btn-success" href="?p=' . P . '&do=categories_add">Add Category</a>', ['align' => 'right']);
     echo '<br>';
     echo CmsTable::getInstance()->addData($categories)->addColumn(ColumnEdit::getInstance('title')->setHref('?p=' . P . '&do=categories_edit&id={%id%}')->enableOrderableColumn()->enableTranslationColumn())->addColumn(ColumnDelete::getInstance()->setHref('?p=' . P . '&do=_categories_delete&id={%id%}'));
 }
示例#6
0
 public static function outputTable(array $params)
 {
     // Check columns
     if (!isset($params['columns'])) {
         $params['columns'] = [];
     }
     // Check order column
     if (isset($params['order']) && !isset($params['columns']['order'])) {
         $params['columns']['order'] = ['type' => 'order'];
     }
     // Check active column
     if (isset($params['active']) && !isset($params['columns']['active'])) {
         $params['columns']['active'] = ['type' => 'active'];
     }
     // Check edit column
     if (isset($params['edit']) && !isset($params['columns']['edit'])) {
         $params['columns']['edit'] = ['type' => 'edit'];
     }
     // Check delete column
     if (isset($params['delete']) && !isset($params['columns']['delete'])) {
         $params['columns']['delete'] = ['type' => 'delete'];
     }
     // Check params are supplied
     if (!isset($params['data'])) {
         $params['data'] = [];
     }
     $table = new CmsTable();
     $table->addData($params['data']);
     // Table title
     if (isset($params['title'])) {
         $table->setHeadingTitle($params['title']);
     }
     foreach ($params['columns'] as $column_key => $column_param) {
         if (!is_array($column_param)) {
             $column_key = $column_param;
             $column_param = ['type' => 'data'];
         }
         if (!isset($column_param['type'])) {
             $column_param['type'] = 'data';
         }
         $column = NULL;
         switch ($column_param['type']) {
             case 'data':
                 $column = new ColumnData($column_key);
                 break;
             case 'date':
                 $column = new ColumnData($column_key);
                 $column->setDataTypeAsTsToDatetime();
                 break;
             case 'email':
                 $column = new ColumnData($column_key);
                 $column->setDataTypeAsEmail();
                 break;
             case 'accept':
                 $column = new ColumnAccept($column_key);
                 break;
             case 'order':
                 $column = new ColumnOrder($column_key);
                 break;
             case 'edit':
                 $column = ColumnEdit::getInstance($column_key);
                 break;
             case 'active':
                 $column = ColumnActive::getInstance($column_key);
                 break;
             case 'delete':
                 $column = ColumnDelete::getInstance($column_key);
                 break;
             case 'gallery':
                 $column = new ColumnGallery($column_key);
                 break;
             case 'image':
                 $column = new ColumnImg($column_key);
                 break;
             case 'bool':
             case 'done':
                 $column = new ColumnDone($column_key);
                 break;
             default:
                 dump('Unknown column type "' . $column_param['type'] . '"');
                 break;
         }
         // Disable cutting long texts by column
         if (isset($column_param['cut_long_strings'])) {
             if (!$column_param['cut_long_strings']) {
                 $column->disableCutLongStrings();
             }
         }
         // Disable cutting long texts by entire table
         if (isset($params['cut_long_strings'])) {
             if (!$params['cut_long_strings']) {
                 $column->disableCutLongStrings();
             }
         }
         // Is multi-translatable data in column
         if (isset($column_param['translation']) && $column_param['translation']) {
             $column->enableTranslationColumn();
         }
         // Is orderable
         if (isset($column_param['order']) && $column_param['order']) {
             $column->enableOrderableColumn();
         }
         // Is dragable
         if (isset($column_param['order_drag']) && $column_param['order_drag']) {
             $column->enableDraggable();
         }
         // Title
         if (isset($column_param['title'])) {
             $column->setTitle($column_param['title']);
         }
         // Images for gallery
         if (isset($column_param['images'])) {
             $column->setImages($column_param['images']);
         }
         // Width of column
         if (isset($column_param['narrow'])) {
             $column->enableNarrowWidth();
         }
         if (isset($column_param['width'])) {
             $column->setWidth($column_param['width']);
         }
         // Link
         if (isset($column_param['href'])) {
             $column->setHref($column_param['href']);
         }
         // Paired array
         if (isset($column_param['pairs'])) {
             $column->setPairedDataOptionsForKeys($column_param['pairs']);
         }
         // Value for column
         if (isset($column_param['value'])) {
             $column->setValue($column_param['value']);
         }
         // Add to filters
         if (isset($column_param['filter']) && !isset($params['filters'][$column_key])) {
             $params['filters'][$column_key] = [];
         }
         if ($column) {
             $table->addColumn($column);
         }
     }
     // Apply filter
     if (isset($params['filters']) || isset($params['caption'])) {
         $filter_form = new FilterForm();
         // Top caption above table
         if (isset($params['caption'])) {
             $filter_form->setCaption($params['caption']);
         }
         // Render filters
         if (isset($params['filters'])) {
             foreach ($params['filters'] as $filter_key => $filter_data) {
                 // Title is obligate
                 if (!isset($filter_data['title'])) {
                     $filter_data['title'] = ucfirst(__($filter_key));
                 }
                 // Default type
                 if (!isset($filter_data['type'])) {
                     $filter_data['type'] = 'text';
                     $filter_data['like'] = true;
                 }
                 //Filter types
                 $filter = NULL;
                 switch ($filter_data['type']) {
                     case 'text':
                         $filter = Text::getInstance($filter_key);
                         break;
                     case 'select':
                         $filter = Select::getInstance($filter_key);
                         $filter->ignoreValue(-1);
                         // For "empty" value
                         break;
                     default:
                         dump('Unknown filter type "' . $filter_data['type'] . '"');
                         break;
                 }
                 // Options for selects
                 if (isset($filter_data['options'])) {
                     $filter->setOptions($filter_data['options']);
                 }
                 // Ignore values in selects
                 if (isset($filter_data['ignore'])) {
                     $filter->ignoreValue($filter_data['ignore']);
                 }
                 // Like search
                 if (isset($filter_data['like'])) {
                     $filter->enableActAsLike();
                 }
                 if ($filter) {
                     $filter_form->addFilter($filter_data['title'], $filter);
                 }
             }
         }
         $table->attachFilterForm($filter_form);
     }
     return $table;
 }
 public function setting_options()
 {
     $id = abs((int) $_GET['id']);
     if (!$id) {
         return;
     }
     $setting = new CustomSetting($id);
     $breadcrumbs = BreadCrumbs::getInstance()->addCrumb(ucfirst(P))->addCrumb($setting->getModule())->addCrumb($setting->getKey());
     $options = new CustomSettingOptionRepository();
     $options->setWhereSettingId($id);
     $table = CmsTable::getInstance()->setHeadingTitle('Options')->addData($options)->addColumn(ColumnData::getInstance('option_name')->enableOrderableColumn())->addColumn(ColumnEdit::getInstance('edit')->href('?p=' . P . '&do=setting_options_edit&id={%id%}')->width('1%')->value(__('Edit')))->addColumn(ColumnDelete::getInstance('delete')->href('?p=' . P . '&do=_setting_options_delete&id={%id%}'));
     $columns = Columns::getInstance()->add($breadcrumbs)->add('<a class="btn btn-success" href="?p=' . P . '&do=setting_options_add&id=' . $id . '">Add Setting Option</a>', ['align' => 'right']);
     echo $columns;
     echo $table;
 }