Расширение таблицы ms2Gallery
        Всем привет! 
Есть необходимость добавить парочку полей в окошко свойств ms2Gallery:
 
Таким образом присоединяются новые поля, которые добавили в БД (modx_ms2_resource_files).
    
    
                                                                                
            Есть необходимость добавить парочку полей в окошко свойств ms2Gallery:
Таким образом присоединяются новые поля, которые добавили в БД (modx_ms2_resource_files).
switch ($modx->event->name){
	case "OnMODXInit":
        $map = array(
            'msResourceFile' => array(
                'fields' => array(
                    'top' => 0,
                    'left' => 0,
                ),
                'fieldMeta' => array(
                    'top' => array(
                        'dbtype' => 'int',
                        'precision' => 4,
                        'phptype' => 'integer',
                        'null' => false,
                        'default' => 0,
                    ),
                    'left' => array(
                        'dbtype' => 'int',
                        'precision' => 4,
                        'phptype' => 'integer',
                        'null' => false,
                        'default' => 0,
                    ),
                ),
            ),
        );
        
        $ms2Gallery = $modx->getService('ms2gallery', 'ms2Gallery', MODX_CORE_PATH . 'components/ms2gallery/model/ms2gallery/');
        
        foreach ($map as $class => $data) {
            $modx->loadClass($class);
            foreach ($data as $tmp => $fields) {
                if ($tmp == 'fields') {
                    foreach ($fields as $field => $value) {
                        foreach (array('fields', 'fieldMeta', 'indexes') as $key) {
                            if (isset($data[$key][$field])) {
                                $modx->map[$class][$key][$field] = $data[$key][$field];
                            }
                        }
                    }
                }
            }
        }
        break;
}    Комментарии: 3
                Присоединить вроде присоединил, а как вывести в окошко, не сообразил ещё)
                    switch ($modx->event->name){
	case "OnMODXInit":
        $map = array(
            'ms2Gallery' => array(
                'fields' => array(
                    'newfield' => 1,
                ),
                'fieldMeta' => array(
                    'newfield' => array(
                        'dbtype' => 'decimal',
                        'precision' => '12,2',
                        'phptype' => 'float',
                        'null' => true,
                        'default' => 0.0,
                    ),
                ),
            ),
        );
        
        $ms2Gallery = $modx->getService('ms2gallery', 'ms2Gallery', MODX_CORE_PATH . 'components/ms2gallery/model/ms2gallery/');
        
        foreach ($map as $class => $data) {
            $modx->loadClass($class);
            foreach ($data as $tmp => $fields) {
                if ($tmp == 'fields') {
                    foreach ($fields as $field => $value) {
                        foreach (array('fields', 'fieldMeta', 'indexes') as $key) {
                            if (isset($data[$key][$field])) {
                                $modx->map[$class][$key][$field] = $data[$key][$field];
                            }
                        }
                    }
                }
            }
        }
        break;
}            
                Можно, конечно, вывести новые поля таким образом: 
Думаю, нужно сделать добавление полей, как в статье Дополнительные поля профиля юзера (не extended), но не могу найти событие в документации extJS, по которому вызывается попап окно.
Кто знает подсказки?)
                    case 'OnDocFormRender':
        $modx->controller->addLastJavascript('/assets/js/ms2g.js');
	break;Содержимое файла:Ext.extend(ms2Gallery.window.Image, MODx.Window, {
    getFields: function (config) {
        var src = config.record['type'] == 'image'
            ? config.record['url']
            : config.record['thumbnail'];
        var img = MODx.config['connectors_url'] + 'system/phpthumb.php?src='
            + src
            + '&w=333&h=198&f=jpg&q=90&zc=0&far=1&HTTP_MODAUTH='
            + MODx.siteId + '&wctx=mgr&source='
            + config.record['source'];
        var fields = {
            ms2gallery_source: config.record['source_name'],
            ms2gallery_size: config.record['size'],
            ms2gallery_createdon: config.record['createdon'],
            ms2gallery_exif_date: config.record['exif_date'],
            //ms2gallery_rank: config.record['rank'],
        };
        var details = '';
        for (var i in fields) {
            if (!fields.hasOwnProperty(i)) {
                continue;
            }
            if (fields[i]) {
                details += '<tr><th>' + _(i) + ':</th><td>' + fields[i] + '</td></tr>';
            }
        }
        return [
            {xtype: 'hidden', name: 'id', id: this.ident + '-id'},
            {
                layout: 'column',
                border: false,
                anchor: '100%',
                items: [{
                    columnWidth: .5,
                    layout: 'form',
                    defaults: {msgTarget: 'under'},
                    border: false,
                    items: [{
                        xtype: 'displayfield',
                        hideLabel: true,
                        html: '\
                        <a href="' + config.record['url'] + '" target="_blank" class="ms2gallery-window-link">\
                            <img src="' + img + '" class="ms2gallery-window-thumb" />\
                        </a>\
                        <table class="ms2gallery-window-details">' + details + '</table>'
                    }]
                }, {
                    columnWidth: .5,
                    layout: 'form',
                    defaults: {msgTarget: 'under'},
                    border: false,
                    items: [{
                        layout: 'column',
                        border: false,
                        anchor: '100%',
                        items: [{
                            columnWidth: .75,
                            layout: 'form',
                            items: [{
                                xtype: 'textfield',
                                fieldLabel: _('ms2gallery_file_name'),
                                name: 'file',
                                id: this.ident + '-file',
                                anchor: '100%'
                            }]
                        }, {
                            columnWidth: .25,
                            layout: 'form',
                            items: [{
                                xtype: 'xcheckbox',
                                fieldLabel: _('ms2gallery_file_active'),
                                name: 'active',
                                id: this.ident + '-active',
                                anchor: '100%',
                                ctCls: 'ms2gallery-cba'
                            }]
                        }]
                    }, {
                        xtype: 'textfield',
                        fieldLabel: _('ms2gallery_file_title'),
                        name: 'name',
                        id: this.ident + '-name',
                        anchor: '100%'
                    }, {
                        xtype: 'textfield',
                        fieldLabel: _('ms2gallery_file_alt'),
                        name: 'alt',
                        id: this.ident + '-alt',
                        anchor: '100%'
					}, {
                        xtype: 'numberfield',
                        decimalPrecision: 0,
                        fieldLabel: _('ms2gallery_top'),
                        name: 'top',
                        id: this.ident + '-top',
                        anchor: '100%',
                        value: 100
                    }, {
                        xtype: 'numberfield',
                        decimalPrecision: 0,
                        fieldLabel: _('ms2gallery_left'),
                        name: 'left',
                        id: this.ident + '-left',
                        anchor: '100%'
                    }, {
                        xtype: 'ms2gallery-combo-tags',
                        fieldLabel: _('ms2gallery_file_tags'),
                        name: 'tags',
                        id: this.ident + '-tags',
                        anchor: '100%',
                        value: config.record['tags']
                    }]
                }]
            }, {
                layout: 'column',
                border: false,
                anchor: '100%',
                items: [{
                    columnWidth: .5,
                    layout: 'form',
                    defaults: {msgTarget: 'under'},
                    border: false,
                    items: [{
                        xtype: 'textarea',
                        fieldLabel: _('ms2gallery_file_add'),
                        name: 'add',
                        id: this.ident + '-add',
                        anchor: '100%',
                        height: 50
                    }]
                }, {
                    columnWidth: .5,
                    layout: 'form',
                    defaults: {msgTarget: 'under'},
                    border: false,
                    items: [{
                        xtype: 'textarea',
                        fieldLabel: _('ms2gallery_file_description'),
                        name: 'description',
                        id: this.ident + '-description',
                        anchor: '100%',
                        height: 50
                    }]
                }]
            }
        ];
    },
    getKeys: function () {
        return [{
            key: Ext.EventObject.ENTER,
            shift: true,
            fn: this.submit,
            scope: this
        }];
    }
});Но мне кажется это не совсем правильно, не выводится содержимое этих полей из БД (но если ввести значения и сохранить, запись в БД идёт). Думаю, нужно сделать добавление полей, как в статье Дополнительные поля профиля юзера (не extended), но не могу найти событие в документации extJS, по которому вызывается попап окно.
Кто знает подсказки?)
                Там не на вызов окна надо вешать свой обработчик. Есть способ поступить несколько хитрее, вот здесь принцип описан.
Я на днях расширял таким образом окно редактирования комментария в Тикетс. Добавил туда форму UserFiles (спасибо, Володя, за такую возможность).
                    Я на днях расширял таким образом окно редактирования комментария в Тикетс. Добавил туда форму UserFiles (спасибо, Володя, за такую возможность).
                            Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.