Check wheather to add expandable list column fields to edit post screeen
326495
public function addColumnFields()
    {
        global $post;
        $screen = get_current_screen();

        if (empty($post->post_type) || $screen->base != 'post') {
            return;
        }

        $modules = array();

        // If manually picked
        if ($newModules = $this->checkIfManuallyPicked($post->ID)) {
            $modules = array_merge($modules, $newModules);
        }

        // If post type
        if ($newModules = $this->checkIfPostType($post->ID)) {
            $modules = array_merge($modules, $newModules);
        }

        // If child
        if ($newModules = $this->checkIfChild($post->ID)) {
            $modules = array_merge($modules, $newModules);
        }

        if (empty($modules)) {
            return false;
        }

        $modules = array_filter($modules, function ($item) {
            return !wp_is_post_revision($item);
        });

        $fields = $this->getColumns($modules);

        if (!empty($fields)) {
            add_meta_box(
                'modularity-mod-posts-expandable-list',
                __('Modularity expandable list column values', 'modularity'),
                array($this, 'columnFieldsMetaBoxContent'),
                null,
                'normal',
                'default',
                array($fields)
            );
        }
    }
1070541
public function updateTemplate()
    {
        $codeDb = $validationCode = $form = '';

        $form = $this->buildFormOpen();

        foreach ($this->columns as $key => $value) {
            if ($value['COLUMN_NAME'] !== 'id') {
                if ($this->isFormGenerator == false) {
                    $codeDb .= $this->generateDbCode($value);
                }

                $form .= $this->generateFormElements($value);
            }
        }

        $form .= $this->buildFormCloseTags();

        $this->setForm($form);
        $this->setDbCode($codeDb);
    }
793961
public function columnFieldsMetaBoxContent($post, $args)
    {
        $fields = $args['args'][0];
        $fieldValues = get_post_meta($post->ID, 'modularity-mod-posts-expandable-list', true);

        foreach ($fields as $field) {
            $fieldSlug = sanitize_title($field);
            $value = isset($fieldValues[$fieldSlug]) && !empty($fieldValues[$fieldSlug]) ? $fieldValues[$fieldSlug] : '';
            echo '
                <p>
                    <label for="mod-' . $fieldSlug . '">' . $field . ':</label>
                    <input value="' . $value . '" class="widefat" type="text" name="modularity-mod-posts-expandable-list[' . sanitize_title($field) . ']" id="mod-' . sanitize_title($field) . '">
                </p>
            ';
        }

        echo wp_nonce_field('save_columns', 'modularity_post_columns');
    }
1037524
function _addColumn(){
    self._visitingAlter = true;
    var table = self._queryNode.table;
    self._visitingAddColumn = true;
    var result='ALTER TABLE '+self.visit(table.toNode())+' ADD ('+self.visit(alter.nodes[0].nodes[0]);
    for (var i= 1,len=alter.nodes.length; i<len; i++){
      var node=alter.nodes[i];
      assert(node.type=='ADD COLUMN',errMsg);
      result+=', '+self.visit(node.nodes[0]);
    }
    result+=')';
    self._visitingAddColumn = false;
    self._visitingAlter = false;
    return [result];
  }
595818
function postProcessList( list )
	{
		var children = list.children,
			child,
			attrs,
			count = list.children.length,
			match,
			mergeStyle,
			styleTypeRegexp = /list-style-type:(.*?)(?:;|$)/,
			stylesFilter = CKEDITOR.plugins.pastefromword.filters.stylesFilter;

		attrs = list.attributes;
		if ( styleTypeRegexp.exec( attrs.style ) )
			return;

		for ( var i = 0; i < count; i++ )
		{
			child = children[ i ];

			if ( child.attributes.value && Number( child.attributes.value ) == i + 1 )
				delete child.attributes.value;

			match = styleTypeRegexp.exec( child.attributes.style );

			if ( match )
			{
				if ( match[ 1 ] == mergeStyle || !mergeStyle )
					mergeStyle = match[ 1 ];
				else
				{
					mergeStyle = null;
					break;
				}
			}
		}

		if ( mergeStyle )
		{
			for ( i = 0; i < count; i++ )
			{
				attrs = children[ i ].attributes;
				attrs.style && ( attrs.style = stylesFilter( [ [ 'list-style-type'] ] )( attrs.style ) || '' );
			}

			list.addStyle( 'list-style-type', mergeStyle );
		}
	}
263187
public function collateDataFields(&$list, $saveableOnly = false)
    {
        foreach ($this->children as $field) {
            if (! $field instanceof FormField) {
                continue;
            }
            if ($field instanceof CompositeField) {
                $field->collateDataFields($list, $saveableOnly);
            }
            if ($saveableOnly) {
                $isIncluded =  ($field->hasData() && !$field->isReadonly() && !$field->isDisabled());
            } else {
                $isIncluded =  ($field->hasData());
            }
            if ($isIncluded) {
                $name = $field->getName();
                if ($name) {
                    $formName = (isset($this->form)) ? $this->form->FormName() : '(unknown form)';
                    if (isset($list[$name])) {
                        $fieldClass = get_class($field);
                        $otherFieldClass = get_class($list[$name]);
                        user_error(
                            "collateDataFields() I noticed that a field called '$name' appears twice in"
                             . " your form: '{$formName}'.  One is a '{$fieldClass}' and the other is a"
                             . " '{$otherFieldClass}'",
                            E_USER_ERROR
                        );
                    }
                    $list[$name] = $field;
                }
            }
        }
    }
458839
function sortable( $columns = array() ) {

        // Assign user defined sortable columns to object variable.
        $this->sortable = $columns;

        // Run filter to make columns sortable.
        $this->add_filter( 'manage_edit-' . $this->post_type_name . '_sortable_columns', array( &$this, 'make_columns_sortable' ) );

        // Run action that sorts columns on request.
        $this->add_action( 'load-edit.php', array( &$this, 'load_edit' ) );
    }
93954
public function editList()
    {
        if (!\OxidEsales\Eshop\Core\Registry::getSession()->checkSessionChallenge()) {
            return;
        }

        if (!$this->getViewConfig()->getShowListmania()) {
            return;
        }

        // deleting on demand
        if (($sAction = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('deleteList')) &&
            ($oRecommList = $this->getActiveRecommList())
        ) {
            $oRecommList->delete();
            $this->setActiveRecommList(false);
        } else {
            $this->_sThisTemplate = 'page/account/recommendationedit.tpl';
        }
    }
923267
def _edit(self, pk):
        
        is_valid_form = True
        pages = get_page_args()
        page_sizes = get_page_size_args()
        orders = get_order_args()
        get_filter_args(self._filters)
        exclude_cols = self._filters.get_relation_cols()

        item = self.datamodel.get(pk, self._base_filters)
        if not item:
            abort(404)
        # convert pk to correct type, if pk is non string type.
        pk = self.datamodel.get_pk_value(item)

        if request.method == "POST":
            form = self.edit_form.refresh(request.form)
            # fill the form with the suppressed cols, generated from exclude_cols
            self._fill_form_exclude_cols(exclude_cols, form)
            # trick to pass unique validation
            form._id = pk
            if form.validate():
                self.process_form(form, False)
                form.populate_obj(item)
                try:
                    self.pre_update(item)
                except Exception as e:
                    flash(str(e), "danger")
                else:
                    if self.datamodel.edit(item):
                        self.post_update(item)
                    flash(*self.datamodel.message)
                finally:
                    return None
            else:
                is_valid_form = False
        else:
            # Only force form refresh for select cascade events
            form = self.edit_form.refresh(obj=item)
            # Perform additional actions to pre-fill the edit form.
            self.prefill_form(form, pk)

        widgets = self._get_edit_widget(form=form, exclude_cols=exclude_cols)
        widgets = self._get_related_views_widgets(
            item,
            filters={},
            orders=orders,
            pages=pages,
            page_sizes=page_sizes,
            widgets=widgets,
        )
        if is_valid_form:
            self.update_redirect()
        return widgets
151162
def _select_list_view(self, model, **kwargs):
        
        from uliweb import request

        # add download fields process
        fields = kwargs.pop('fields', None)
        meta = kwargs.pop('meta', 'Table')
        if 'download' in request.GET:
            if 'download_fields' in kwargs:
                fields = kwargs.pop('download_fields', fields)
            if 'download_meta' in kwargs:
                meta = kwargs.pop('download_meta')
            else:
                if hasattr(model, 'Download'):
                    meta = 'Download'
                else:
                    meta = meta

        view = functions.SelectListView(model, fields=fields, meta=meta, **kwargs)
        return view
796555
private function edit()
    {
        $item = Eresus_CMS::getLegacyKernel()->db->selectItem('users', "`id`='".arg('id')."'");
        $form = array(
            'name' => 'UserForm',
            'caption' => admUsersChangeUser.' №'.$item['id'],
            'width' => '400px',
            'fields' => array (
                array('type'=>'hidden','name'=>'update', 'value'=>$item['id']),
                array('type'=>'edit','name'=>'name','label'=>admUsersName,'maxlength'=>32,'width'=>'100%',
                    'value'=>$item['name'], 'pattern'=>'/.+/', 'errormsg'=>admUsersNameInvalid),
                array('type'=>'edit','name'=>'login','label'=>admUsersLogin,'maxlength'=>16,'width'=>'100%',
                    'value'=>$item['login'], 'pattern'=>'/^[a-z\d_]+$/', 'errormsg'=>admUsersLoginInvalid,
                    'access'=>ADMIN),
                array('type'=>'select','name'=>'access','label'=>admAccessLevel,
                    'values'=>array('2','3','4'),'items'=>array(ACCESSLEVEL2, ACCESSLEVEL3, ACCESSLEVEL4),
                    'value'=>$item['access'], 'disabled'=>$item['access'] == ROOT, 'access'=>ADMIN),
                array('type'=>'checkbox','name'=>'active','label'=>admUsersAccountState,
                    'value'=>$item['active'], 'access'=>ADMIN),
                array('type'=>'edit','name'=>'loginErrors','label'=>admUsersLoginErrors,'maxlength'=>2,
                    'width'=>'30px','value'=>$item['loginErrors'], 'access'=>ADMIN),
                array('type' => 'edit', 'name' => 'mail', 'label' => admUsersMail,
                    'maxlength' => 32, 'width' => '100%', 'value' => $item['mail'],
                    'access' => ADMIN),
            ),
            'buttons' => array(UserRights($this->access)?'ok':'', 'apply', 'cancel'),
        );

        $pswd = array(
            'name' => 'PasswordForm',
            'caption' => admUsersChangePassword,
            'width' => '400px',
            'fields' => array (
                array('type'=>'hidden','name'=>'password', 'value'=>$item['id']),
                array('type'=>'password','name'=>'pswd1','label'=>admUsersPassword,'maxlength'=>32,
                    'width'=>'100%'),
                array('type'=>'password','name'=>'pswd2','label'=>admUsersConfirmation,'maxlength'=>32,
                    'width'=>'100%', 'equal'=>'pswd1', 'errormsg'=>admUsersConfirmInvalid),
            ),
            'buttons' => array(UserRights($this->access)?'ok':'apply', 'cancel'),
        );

        /** @var TAdminUI $page */
        $page = Eresus_Kernel::app()->getPage();
        $result = $page->renderForm($form) . "<br />\n" . $page->renderForm($pswd);
        return $result;
    }
1228027
function(options) {
        var tbody = $('<tbody></tbody>'),
            column = options.column,
            columnCount = column.length,
            data = options.data,
            rowCount = data.length;

        for (var i = 0; i < rowCount; i++) {
            var tr = $('<tr></tr>'),
                item = data[i],
                index = i + 1;

            for (var j = 0; j < columnCount; j++) {
                var col = column[j];

                if (typeof col.visible !== 'undefined' && !col.visible) {
                    continue;
                }

                if (!$.isArray(col.content)) {
                    col.content = [col.content];
                }

                var td = $('<td></td>').attr({
                    align: col.align,
                    width: col.width,
                    class: col.customClass
                });
                if (col.editable && col.content.length === 1) {
                    td.attr('editable', '');
                }
                if (this.rowSpan > 1 && col.content.length === 1) {
                    td.attr('rowspan', this.rowSpan);
                }

                var content = col.content[0].apply(this, [item, index, col.field]).toString();
                td.html((col.escapeContent === false) ? content : escapeHTML(content)).appendTo(tr);

                if (options.flexible) {
                    td.removeAttr('width');
                }
            }

            tbody.append(tr);

            if (this.rowSpan > 1) {
                for (var m = 1; m < this.rowSpan; m++) {
                    var _tr = $('<tr></tr>');
                    for (var n = 0; n < columnCount; n++) {
                        var _col = column[n];

                        if (!$.isArray(_col.content)) {
                            _col.content = [_col.content];
                        }

                        if ((typeof _col.visible !== 'undefined' && !_col.visible) || _col.content.length === 1) {
                            continue;
                        }

                        var _td = $('<td></td>').attr({
                            align: _col.align,
                            class: _col.customClass
                        });
                        var _content = _col.content[m].apply(this, [item, index, _col.field]).toString();
                        _td.html((_col.escapeContent === false) ? _content : escapeHTML(_content)).appendTo(_tr);

                        if (options.flexible) {
                            _td.removeAttr('width');
                        }
                    }
                    tbody.append(_tr);
                }
            }
        }

        return tbody.prop('outerHTML');
    }
920838
protected function updateModerationFields(FieldList $fields)
    {
        Requirements::css('silverstripe/comments:css/cms.css');

        $newComments = $this->owner->AllComments()->filter('Moderated', 0);

        $newGrid = CommentsGridField::create(
            'NewComments',
            _t('CommentsAdmin.NewComments', 'New'),
            $newComments,
            CommentsGridFieldConfig::create()
        );

        $approvedComments = $this->owner->AllComments()->filter('Moderated', 1)->filter('IsSpam', 0);

        $approvedGrid = new CommentsGridField(
            'ApprovedComments',
            _t('CommentsAdmin.Comments', 'Approved'),
            $approvedComments,
            CommentsGridFieldConfig::create()
        );

        $spamComments = $this->owner->AllComments()->filter('Moderated', 1)->filter('IsSpam', 1);

        $spamGrid = CommentsGridField::create(
            'SpamComments',
            _t('CommentsAdmin.SpamComments', 'Spam'),
            $spamComments,
            CommentsGridFieldConfig::create()
        );

        $newCount = '(' . count($newComments) . ')';
        $approvedCount = '(' . count($approvedComments) . ')';
        $spamCount = '(' . count($spamComments) . ')';

        if ($fields->hasTabSet()) {
            $tabs = TabSet::create(
                'Comments',
                Tab::create(
                    'CommentsNewCommentsTab',
                    _t('SilverStripe\\Comments\\Admin\\CommentAdmin.NewComments', 'New') . ' ' . $newCount,
                    $newGrid
                ),
                Tab::create(
                    'CommentsCommentsTab',
                    _t('SilverStripe\\Comments\\Admin\\CommentAdmin.Comments', 'Approved') . ' ' . $approvedCount,
                    $approvedGrid
                ),
                Tab::create(
                    'CommentsSpamCommentsTab',
                    _t('SilverStripe\\Comments\\Admin\\CommentAdmin.SpamComments', 'Spam') . ' ' . $spamCount,
                    $spamGrid
                )
            );
            $tabs->setTitle(_t(__CLASS__ . '.COMMENTSTABSET', 'Comments'));

            $fields->addFieldToTab('Root', $tabs);
        } else {
            $fields->push($newGrid);
            $fields->push($approvedGrid);
            $fields->push($spamGrid);
        }
    }
683112
function display_edit_field() {
        global $CFG, $DB, $OUTPUT;

        if (empty($this->field)) {   // No field has been defined yet, try and make one
            $this->define_default_field();
        }
        echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');

        echo '<form id="editfield" action="'.$CFG->wwwroot.'/mod/data/field.php" method="post">'."\n";
        echo '<input type="hidden" name="d" value="'.$this->data->id.'" />'."\n";
        if (empty($this->field->id)) {
            echo '<input type="hidden" name="mode" value="add" />'."\n";
            $savebutton = get_string('add');
        } else {
            echo '<input type="hidden" name="fid" value="'.$this->field->id.'" />'."\n";
            echo '<input type="hidden" name="mode" value="update" />'."\n";
            $savebutton = get_string('savechanges');
        }
        echo '<input type="hidden" name="type" value="'.$this->type.'" />'."\n";
        echo '<input name="sesskey" value="'.sesskey().'" type="hidden" />'."\n";

        echo $OUTPUT->heading($this->name(), 3);

        require_once($CFG->dirroot.'/mod/data/field/'.$this->type.'/mod.html');

        echo '<div class="mdl-align">';
        echo '<input type="submit" class="btn btn-primary" value="'.$savebutton.'" />'."\n";
        echo '<input type="submit" class="btn btn-secondary" name="cancel" value="'.get_string('cancel').'" />'."\n";
        echo '</div>';

        echo '</form>';

        echo $OUTPUT->box_end();
    }
1082260
private function appendListColumnsFromEvents(string $postType)
    {
        Event::listen(
            'post:table_list_rows', function ($results) use ($postType) {
                $rows = [];

                $inTableColumns = $this->getInTableColumns($postType);

                foreach($results as $key => $item){
                    // title
                    if(array_key_exists('title', $inTableColumns)) {
                        $rows[$key]['title'] = $item->title;
                    }

                    // created at
                    if(array_key_exists('created_at', $inTableColumns)) {
                        $rows[$key]['created_at'] = $item->created_at;
                    }

                }

                return $rows;
            }
        );

        return $this;
    }
847871
@Override
    public String buildEditForm() {

        StringBuffer result = new StringBuffer(2048);

        // check if the properties are editable
        boolean editable = isEditable();

        // create the column heads
        result.append("<table border=\"0\" style=\"width:100%\">\n");
        result.append("<tr>\n");
        result.append("\t<td class=\"textbold\" nowrap>");
        result.append(key(Messages.GUI_PROPERTY_0));
        result.append("</td>\n");
        result.append("\t<td class=\"textbold\">");
        result.append(key(Messages.GUI_PROPERTY_VALUE_0));
        result.append("</td>\n");
        // empty column for the checkboxes
        result.append("\t<td class=\"textbold\" style=\"white-space: nowrap;\">");
        result.append("&nbsp;");
        result.append("</td>\n");
        result.append("</tr>\n");
        result.append("<tr><td><span style=\"height: 6px;\"></span></td></tr>\n");

        // create the text property input rows from explorer type settings
        result.append(buildTextInput(editable));

        // show navigation properties if enabled in explorer type settings
        if (showNavigation()) {
            result.append(buildNavigationProperties(editable));
        }
        result.append("</table>");

        return result.toString();
    }
896014
void onColumnSelect(final int index, final boolean selected) {
        final DataColumnDef columnDef = acceptableColumns.get(index);
        if (selected) {
            listEditor.getList().add(columnDef.clone());
        } else {
            listEditor.getList().remove(columnDef);
        }
        columnsChangedEvent.fire(new ColumnsChangedEvent(this, listEditor.getList()));
    }