fields setup, theme tweaks

This commit is contained in:
Dro1d.Ru 2018-04-16 19:47:56 +05:00
parent 7b06c0dad4
commit 02a931c128
37 changed files with 1502 additions and 32 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 844 B

View file

@ -14,8 +14,8 @@ var dash_cache_select = function() {
if (!selected || !selected.length || selected.length!=1) return;
desk_post(url('dash/system/info'),{'type':'cache','file':selected[0].data, 'token':token()}, this.bind(this, function(response){
if (response && response.length>0) {
$(this.element).find('.cache-infobar').append('<div style="cursor:default;padding:0px;margin:10px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.cache-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:10px 0px"></div>');
$(this.element).find('.cache-infobar').append('<div style="cursor:default;padding:0px;margin:5px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.cache-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:5px 0px"></div>');
for (var i=0; i<response.length; i++) {
$(this.element).find('.cache-infobar').append('<div style="font-weight:normal;padding:2px 0px;cursor:default;text-overflow:ellipsis;overflow:hidden" title="'+response[i].split('>').slice(-1)[0]+'">'+response[i]+'</div>');
}

View file

@ -19,8 +19,8 @@ var dash_comments_select = function() {
if (!selected || !selected.length || selected.length!=1) return;
desk_post(url('dash/comments/info'),{'type':'comment','item':selected[0].data, 'token':token()}, this.bind(this, function(response){
if (response && response.length>0) {
$(this.element).find('.comment-infobar').append('<div style="cursor:default;padding:0px;margin:10px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.comment-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:10px 0px"></div>');
$(this.element).find('.comment-infobar').append('<div style="cursor:default;padding:0px;margin:5px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.comment-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:5px 0px"></div>');
for (var i=0; i<response.length; i++) {
$(this.element).find('.comment-infobar').append('<div style="font-weight:normal;padding:2px 0px;cursor:default;text-overflow:ellipsis;overflow:hidden" title="'+response[i].split('>').slice(-1)[0]+'">'+response[i]+'</div>');
}

View file

@ -64,8 +64,8 @@ var dash_files_select = function() {
if (!selected || !selected.length || selected.length!=1) return;
desk_post(url('dash/files/info'),{'dirroot':this.options.data.root,'file':selected[0].data, 'token':token()}, this.bind(this, function(response){
if (response && response.length>0) {
$(this.element).find('.filemanager-infobar').append('<div style="cursor:default;padding:0px;margin:10px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.filemanager-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:10px 0px"></div>');
$(this.element).find('.filemanager-infobar').append('<div style="cursor:default;padding:0px;margin:5px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.filemanager-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:5px 0px"></div>');
for (var i=0; i<response.length; i++) {
$(this.element).find('.filemanager-infobar').append('<div style="font-weight:normal;padding:2px 0px;cursor:default;text-overflow:ellipsis;overflow:hidden" title="'+response[i].split('>').slice(-1)[0]+'">'+response[i]+'</div>');
}

View file

@ -23,8 +23,8 @@ var dash_logs_select = function() {
if (!selected || !selected.length || selected.length!=1) return;
desk_post(url('dash/system/info'),{'type':'logs','file':selected[0].data, 'token':token()}, this.bind(this, function(response){
if (response && response.length>0) {
$(this.element).find('.logs-infobar').append('<div style="cursor:default;padding:0px;margin:10px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.logs-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:10px 0px"></div>');
$(this.element).find('.logs-infobar').append('<div style="cursor:default;padding:0px;margin:5px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.logs-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:5px 0px"></div>');
for (var i=0; i<response.length; i++) {
$(this.element).find('.logs-infobar').append('<div style="font-weight:normal;padding:2px 0px;cursor:default;text-overflow:ellipsis;overflow:hidden" title="'+response[i].split('>').slice(-1)[0]+'">'+response[i]+'</div>');
}

View file

@ -94,8 +94,8 @@ var dash_records_select = function() {
if (!selected || !selected.length || selected.length!=1) return;
desk_post(url('dash/records/info'),{'item':selected[0].data, 'token':token()}, this.bind(this, function(response){
if (response && typeof(response.info)!="undefined" && response.info.length>0) {
$(this.element).find('.record-infobar').append('<div style="cursor:default;padding:0px;margin:10px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.record-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:10px 0px"></div>');
$(this.element).find('.record-infobar').append('<div style="cursor:default;padding:0px;margin:5px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.record-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:5px 0px"></div>');
for (var i=0; i<response.info.length; i++) {
$(this.element).find('.record-infobar').append('<div style="font-weight:normal;padding:2px 0px;cursor:default;text-overflow:ellipsis;overflow:hidden" title="'+response.info[i].split('>').slice(-1)[0]+'">'+response.info[i]+'</div>');
}

View file

@ -56,8 +56,8 @@ var dash_users_select = function() {
if (!selected || !selected.length || selected.length!=1) return;
desk_post(url('dash/users/info'),{'user_id':selected[0].data, 'token':token()}, this.bind(this, function(response){
if (response && response.length>0) {
$(this.element).find('.user-infobar').append('<div style="cursor:default;padding:0px;margin:10px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.user-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:10px 0px"></div>');
$(this.element).find('.user-infobar').append('<div style="cursor:default;padding:0px;margin:5px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.user-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:5px 0px"></div>');
for (var i=0; i<response.length; i++) {
var title = response[i].replace(/^.+title="([^"]+?)".+$/, '$1');
$(this.element).find('.user-infobar').append('<div style="font-weight:normal;padding:2px 0px;cursor:default;text-overflow:ellipsis;overflow:hidden" title="'+title+': '+response[i].split('>').slice(-1)[0]+'">'+response[i]+'</div>');

View file

@ -14,8 +14,8 @@ var dash_eform_select = function() {
if (!selected || !selected.length || selected.length!=1) return;
desk_post(url('eform/dash/info'),{'item':selected[0].data, 'token':token()}, this.bind(this, function(response){
if (response && response.length>0) {
$(this.element).find('.eform-infobar').append('<div style="cursor:default;padding:0px;margin:10px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.eform-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:10px 0px"></div>');
$(this.element).find('.eform-infobar').append('<div style="cursor:default;padding:0px;margin:5px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.eform-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:5px 0px"></div>');
for (var i=0; i<response.length; i++) {
$(this.element).find('.eform-infobar').append('<div style="font-weight:normal;padding:2px 0px;cursor:default;text-overflow:ellipsis;overflow:hidden" title="'+response[i].split('>').slice(-1)[0]+'">'+response[i]+'</div>');
}

286
assets/js/fields/dash.js Normal file
View file

@ -0,0 +1,286 @@
var dash_fields_group_load = function() {
for (var i=0; i<this.options.bodyItems.length; i++) {
if (typeof(this.options.bodyItems[i].activated)!="undefined" &&
this.options.bodyItems[i].activated == 0
) {
$(this.options.bodyItems[i].element).addClass('inactive');
}
}
};
var dash_fields_group_language = function(element) {
var language = this.options.data.language;
var id = $(element).attr('id');
var item = this.findMenuItemByProperty('id',id);
if (item && typeof(item.language)!="undefined") {
if (item.language!=language) {
this.options.data.language=item.language;
desk_window_reload(this);
$(element).parents('ul').find('.glyphicon-ok').removeClass('glyphicon-ok').addClass('glyphicon-filter');
$(element).find('.glyphicon').removeClass('glyphicon-filter').addClass('glyphicon-ok');
} else {
this.options.data.language='';
desk_window_reload(this);
$(element).parents('ul').find('.glyphicon-ok').removeClass('glyphicon-ok').addClass('glyphicon-filter');
}
}
};
var dash_fields_group_drag = function() {
this.isContentDragging = false;
this.dragStartY = null;
this.dragStartItem = null;
this.dragOverItem = null;
this.dragReplaced = false;
this.dragImage = new Image(); this.dragImage.src=dash_fields_blank_src;
$(this.content).bind('dragstart',this.bind(this,function(e){
if (this.isDisabled()) return;
if (typeof(e.originalEvent.target)=="undefined") return;
//if ($(e.originalEvent.target).parents('li').children('a').hasClass('inactive')) return;
this.isContentDragging = true;
this.dragStartY = e.originalEvent.pageY;
this.dragStartItem = $(e.originalEvent.target).parents('li').children('a').attr('id');
e.originalEvent.dataTransfer.setDragImage(this.dragImage,-10,0);
$(this.content).find('#'+this.dragStartItem).parent('li').css('opacity',.5);
for (var i=0; i<this.options.bodyItems.length; i++) {
this.options.bodyItems[i].is_dragged = false;
}
}));
$(this.content).bind('dragover',this.bind(this,function(e){
if (this.isDisabled()) return;
if (typeof(e.originalEvent.target)=="undefined" || !this.isContentDragging) return;
var item = $(e.originalEvent.target).parents('li').children('a');
if ($(item).length==0 || $(item).parents('#'+this.getId()).length==0) return;
//if ($(item).hasClass('inactive')) return;
if ($(item).parent('li').hasClass('tmp-drag-fields-item')) return;
if (this.dragReplaced && $(item).attr('id') == this.dragStartItem) {
var startItem = this.findBodyItemByProperty('id',this.dragStartItem);
var endItem = this.findBodyItemByProperty('id',this.dragOverItem);
if (startItem && endItem && typeof(startItem.sort_order)!="undefined" && typeof(endItem.sort_order)!="undefined") {
var start_order = startItem.sort_order;
var end_order = endItem.sort_order;
startItem.sort_order = end_order;
endItem.sort_order = start_order;
startItem.is_dragged = true;
endItem.is_dragged = true;
}
this.dragOverItem = null;
this.dragStartY = e.originalEvent.pageY;
this.dragReplaced = false;
}
if (this.dragStartItem!=$(item).attr('id') && this.dragOverItem!=$(item).attr('id')) {
this.dragOverItem=$(item).attr('id');
var tmp = '<li class="tmp-drag-fields-item"></li>';
if (e.originalEvent.pageY > this.dragStartY) {
$(this.content).find('#'+this.dragOverItem).parent('li').after(tmp);
} else {
$(this.content).find('#'+this.dragOverItem).parent('li').before(tmp);
}
$(this.content).find('li.tmp-drag-fields-item').replaceWith($(this.content).find('#'+this.dragStartItem).parent('li'));
this.dragReplaced = true;
}
}));
$(this.element).bind('drop',this.bind(this,function(e){
if (this.isDisabled()) return;
var dragged = [];
var orders = [];
for (var i=0; i<this.options.bodyItems.length; i++) {
if (typeof(this.options.bodyItems[i].sort_order)!="undefined" && typeof(this.options.bodyItems[i].is_dragged)!="undefined" && this.options.bodyItems[i].is_dragged) {
dragged.push(this.options.bodyItems[i].data);
orders.push(this.options.bodyItems[i].sort_order);
}
}
if (dragged.length>1 && orders.length>1) {
desk_window_request(this, url('fields/dash/groupdrag'),{'items':dragged,'orders':orders});
}
}));
$(this.content).bind('dragend',this.bind(this,function(e){
$(this.content).find('#'+this.dragStartItem).parent('li').css('opacity',1);
this.isContentDragging = false;
this.dragStartY = null;
this.dragStartItem = null;
this.dragOverItem = null;
this.dragReplaced = false;
$(this.content).find('li.tmp-drag-fields-item').remove();
}));
};
var dash_fields_group_fields = function() {
var selected = this.getSelectedContentItems();
if (selected && selected.length==1) {
var data = {'items':[selected[0].data]};
desk_call(dash_fields_fields_wnd, null, {
'data':data
});
}
};
var dash_fields_item_create = function() {
var data = {
'data': {
'items': [],
'group_id': this.options.data.items[0]
},
'reload': this.className,
'onClose':function(){
desk_window_reload_all(this.options.reload);
}
};
desk_call(dash_fields_field_wnd, null, data);
};
var dash_fields_item_edit = function() {
var selected = this.getSelectedContentItems();
if (selected && selected.length==1) {
var data = {
'data':{
'items': [selected[0].data],
'group_id': this.options.data.items[0]
},
'reload': this.className,
'onClose':function(){
desk_window_reload_all(this.options.reload);
}
};
desk_call(dash_fields_field_wnd, null, data);
}
};
var dash_fields_field_form_init = function() {
$(this.content).find('select.field-types-select').eq(0).change(this.bind(this, function(){
var val = $(this.content).find('select.field-types-select').eq(0).val();
if (val == 'radio' || val == 'select') {
$(this.content).find('.form_field_values_wrapper').show();
desk_call(dash_fields_field_values_init, this);
} else {
$(this.content).find('.form_field_values_wrapper').hide();
}
}));
var values = $(this.content).find('input.field-values-hidden').eq(0).val();
if (values.length>0) {
$(this.content).find('.form_field_values_wrapper').show();
desk_call(dash_fields_field_values_init, this);
var vals = values.split(',');
for (var i=0; i<vals.length; i++) {
var w = $(this.content).find('.field-values-input-wrapper').last();
$(w).parent().append('<div class="field-values-input-wrapper" style="position:relative;margin-top:10px">'+w.html()+'</div>');
$(this.content).find('input.field-values-input').last().val(vals[i]);
}
$(this.content).find('.field-values-input-wrapper').eq(0).remove();
desk_call(dash_fields_field_values_init, this);
}
};
var dash_fields_field_values_init = function() {
var total = $(this.content).find('input.field-values-input').length;
$(this.content).find('input.field-values-input').each(function(index){
if (!$(this).parent().hasClass('field-values-input-wrapper')) {
$(this).wrap('<div class="field-values-input-wrapper" style="position:relative"></div>');
}
$(this).parent('.field-values-input-wrapper').children('.field-values-input-remove').remove();
$(this).parent('.field-values-input-wrapper').children('.field-values-input-add').remove();
if (index<total-1) {
$(this).parent('.field-values-input-wrapper').append('<span class="glyphicon glyphicon-minus-sign field-values-input-remove" style="position:absolute;right:4px;top:10px;cursor:pointer"></span>');
} else {
$(this).parent('.field-values-input-wrapper').append('<span class="glyphicon glyphicon-plus-sign field-values-input-add" style="position:absolute;right:4px;top:10px;cursor:pointer"></span>');
}
});
$(this.content).find('.field-values-input-add').unbind('click').click(this.bind(this, function(){
var w = $(this.content).find('.field-values-input-wrapper').eq(0);
$(w).parent().append('<div class="field-values-input-wrapper" style="position:relative;margin-top:10px">'+w.html()+'</div>');
$(this.content).find('input.field-values-input').last().val('');
desk_call(dash_fields_field_values_init, this);
}));
$(this.content).find('.field-values-input-remove').unbind('click').click(function(){
$(this).parent('.field-values-input-wrapper').remove();
});
};
var dash_fields_fields_load = function() {
for (var i=0; i<this.options.bodyItems.length; i++) {
if (typeof(this.options.bodyItems[i].activated)!="undefined" &&
this.options.bodyItems[i].activated == 0
) {
$(this.options.bodyItems[i].element).addClass('inactive');
}
}
};
var dash_fields_fields_drag = function() {
this.isContentDragging = false;
this.dragStartY = null;
this.dragStartItem = null;
this.dragOverItem = null;
this.dragReplaced = false;
this.dragImage = new Image(); this.dragImage.src=dash_fields_blank_src;
$(this.content).bind('dragstart',this.bind(this,function(e){
if (this.isDisabled()) return;
if (typeof(e.originalEvent.target)=="undefined") return;
//if ($(e.originalEvent.target).parents('li').children('a').hasClass('inactive')) return;
this.isContentDragging = true;
this.dragStartY = e.originalEvent.pageY;
this.dragStartItem = $(e.originalEvent.target).parents('li').children('a').attr('id');
e.originalEvent.dataTransfer.setDragImage(this.dragImage,-10,0);
$(this.content).find('#'+this.dragStartItem).parent('li').css('opacity',.5);
for (var i=0; i<this.options.bodyItems.length; i++) {
this.options.bodyItems[i].is_dragged = false;
}
}));
$(this.content).bind('dragover',this.bind(this,function(e){
if (this.isDisabled()) return;
if (typeof(e.originalEvent.target)=="undefined" || !this.isContentDragging) return;
var item = $(e.originalEvent.target).parents('li').children('a');
if ($(item).length==0 || $(item).parents('#'+this.getId()).length==0) return;
//if ($(item).hasClass('inactive')) return;
if ($(item).parent('li').hasClass('tmp-drag-fields-item')) return;
if (this.dragReplaced && $(item).attr('id') == this.dragStartItem) {
var startItem = this.findBodyItemByProperty('id',this.dragStartItem);
var endItem = this.findBodyItemByProperty('id',this.dragOverItem);
if (startItem && endItem && typeof(startItem.sort_order)!="undefined" && typeof(endItem.sort_order)!="undefined") {
var start_order = startItem.sort_order;
var end_order = endItem.sort_order;
startItem.sort_order = end_order;
endItem.sort_order = start_order;
startItem.is_dragged = true;
endItem.is_dragged = true;
}
this.dragOverItem = null;
this.dragStartY = e.originalEvent.pageY;
this.dragReplaced = false;
}
if (this.dragStartItem!=$(item).attr('id') && this.dragOverItem!=$(item).attr('id')) {
this.dragOverItem=$(item).attr('id');
var tmp = '<li class="tmp-drag-fields-item"></li>';
if (e.originalEvent.pageY > this.dragStartY) {
$(this.content).find('#'+this.dragOverItem).parent('li').after(tmp);
} else {
$(this.content).find('#'+this.dragOverItem).parent('li').before(tmp);
}
$(this.content).find('li.tmp-drag-fields-item').replaceWith($(this.content).find('#'+this.dragStartItem).parent('li'));
this.dragReplaced = true;
}
}));
$(this.element).bind('drop',this.bind(this,function(e){
if (this.isDisabled()) return;
var dragged = [];
var orders = [];
for (var i=0; i<this.options.bodyItems.length; i++) {
if (typeof(this.options.bodyItems[i].sort_order)!="undefined" && typeof(this.options.bodyItems[i].is_dragged)!="undefined" && this.options.bodyItems[i].is_dragged) {
dragged.push(this.options.bodyItems[i].data);
orders.push(this.options.bodyItems[i].sort_order);
}
}
if (dragged.length>1 && orders.length>1) {
desk_window_request(this, url('fields/dash/fielddrag'),{'items':dragged,'orders':orders});
}
}));
$(this.content).bind('dragend',this.bind(this,function(e){
$(this.content).find('#'+this.dragStartItem).parent('li').css('opacity',1);
this.isContentDragging = false;
this.dragStartY = null;
this.dragStartItem = null;
this.dragOverItem = null;
this.dragReplaced = false;
$(this.content).find('li.tmp-drag-fields-item').remove();
}));
};

View file

@ -400,8 +400,8 @@ var dash_forum_topics_select = function() {
if (!selected || !selected.length || selected.length!=1) return;
desk_post(url('forum/dash/topicinfo'),{'topic_id':selected[0].data, 'token':token()}, this.bind(this, function(response){
if (response && response.length>0) {
$(this.element).find('.topics-infobar').append('<div style="cursor:default;padding:0px;margin:10px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.topics-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:10px 0px"></div>');
$(this.element).find('.topics-infobar').append('<div style="cursor:default;padding:0px;margin:5px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.topics-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:5px 0px"></div>');
for (var i=0; i<response.length; i++) {
var title = response[i].replace(/^.+title="([^"]+?)".+$/, '$1');
$(this.element).find('.topics-infobar').append('<div style="font-weight:normal;padding:2px 0px;cursor:default;text-overflow:ellipsis;overflow:hidden" title="'+title+': '+response[i].split('>').slice(-1)[0]+'">'+response[i]+'</div>');

View file

@ -26,8 +26,8 @@ var dash_votes_select = function() {
if (!selected || !selected.length || selected.length!=1) return;
desk_post(url('vote/dash/info'),{'item':selected[0].data, 'token':token()}, this.bind(this, function(response){
if (response && response.length>0) {
$(this.element).find('.vote-infobar').append('<div style="cursor:default;padding:0px;margin:10px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.vote-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:10px 0px"></div>');
$(this.element).find('.vote-infobar').append('<div style="cursor:default;padding:0px;margin:5px 0px 0px"><span class="glyphicon glyphicon-info-sign"></span> '+t('Information')+':</div>');
$(this.element).find('.vote-infobar').append('<div style="border-top:1px solid #B3B6D1;border-bottom:1px solid #EDEDF6;height:1px;padding:0px;margin:5px 0px"></div>');
for (var i=0; i<response.length; i++) {
$(this.element).find('.vote-infobar').append('<div style="font-weight:normal;padding:2px 0px;cursor:default;text-overflow:ellipsis;overflow:hidden" title="'+response[i].split('>').slice(-1)[0]+'">'+response[i]+'</div>');
}

View file

@ -255,6 +255,7 @@ class Dash {
$this->addPanelGroup($this->_panel_settings_group);
}
if (!empty($this->_panel_modules_group['rel'])) {
usort($this->_panel_modules_group['rel'], array($this, 'sortPanelModuleItems'));
$this->addPanelGroup($this->_panel_modules_group);
}
}
@ -270,6 +271,13 @@ class Dash {
public function getPanelItems() {
return $this->_panel_items;
}
public static function sortPanelModuleItems($a, $b) {
if (!is_array($a) || !is_array($b)) return 0;
if (!array_key_exists('label', $a) || !array_key_exists('label', $b)) return 0;
if ($a['label'] == $b['label']) return 0;
return $a['label'] < $b['label'] ? -1 : 1;
}
public function getPanelCallbacks() {
return $this->_panel_callbacks;

View file

@ -563,11 +563,13 @@ class Records extends Model {
$record = new Zira\Models\Record($id);
if (!$record->loaded()) return array();
/**
if ($record->front_page) {
$info[] = '<span class="glyphicon glyphicon-home"></span> ' . Zira\Locale::t('ID: %s', $record->id);
} else {
$info[] = '<span class="glyphicon glyphicon-tag"></span> ' . Zira\Locale::t('ID: %s', $record->id);
}
**/
//$info[] = '<span class="glyphicon glyphicon-paperclip"></span> ' . Zira\Helper::html($record->title);
$info[] = '<span class="glyphicon glyphicon-thumbs-up"></span> ' . Zira\Locale::t('Rating: %s', Zira\Helper::html($record->rating));
$info[] = '<span class="glyphicon glyphicon-comment"></span> ' . Zira\Locale::t('Comments: %s', Zira\Helper::html($record->comments));

View file

@ -155,7 +155,7 @@ class Modules extends Window {
if (array_key_exists('name', $meta['meta'])) $name = Zira\Locale::tm($meta['meta']['name'], $module);
if (array_key_exists('description', $meta['meta'])) $description = Zira\Locale::tm($meta['meta']['description'], $module);
if (array_key_exists('author', $meta['meta'])) $author = $meta['meta']['author'];
if (array_key_exists('version', $meta['meta'])) $version = $meta['meta']['version'];
//if (array_key_exists('version', $meta['meta'])) $version = $meta['meta']['version'];
}
}
@ -166,6 +166,15 @@ class Modules extends Window {
$items[]=$this->createBodyFileItem($title, $description, $key, null, false, array('activated'=>in_array($key, $active_modules),'installable'=>count($tables)>0,'installed'=>$installed));
}
usort($items, array($this, 'sortModules'));
$this->setBodyItems($items);
}
public static function sortModules($a, $b) {
if (!is_array($a) || !is_array($b)) return 0;
if (!array_key_exists('title', $a) || !array_key_exists('title', $b)) return 0;
if ($a['title'] == $b['title']) return 0;
return $a['title'] < $b['title'] ? -1 : 1;
}
}

View file

@ -0,0 +1,46 @@
<?php
/**
* Zira project.
* dash.php
* (c)2018 http://dro1d.ru
*/
namespace Fields\Controllers;
use Zira;
use Fields;
class Dash extends \Dash\Controller {
public function _before() {
parent::_before();
Zira\View::setAjax(true);
}
protected function getFieldsWindowModel() {
$window = new Fields\Windows\Fields();
return new Fields\Models\Fields($window);
}
protected function getGroupsWindowModel() {
$window = new Fields\Windows\Groups();
return new Fields\Models\Groups($window);
}
public function groupdrag() {
if (Zira\Request::isPost()) {
$items = Zira\Request::post('items');
$orders = Zira\Request::post('orders');
$response = $this->getGroupsWindowModel()->drag($items, $orders);
Zira\Page::render($response);
}
}
public function fielddrag() {
if (Zira\Request::isPost()) {
$items = Zira\Request::post('items');
$orders = Zira\Request::post('orders');
$response = $this->getFieldsWindowModel()->drag($items, $orders);
Zira\Page::render($response);
}
}
}

39
fields/fields.php Normal file
View file

@ -0,0 +1,39 @@
<?php
/**
* Zira project.
* fields.php
* (c)2018 http://dro1d.ru
*/
namespace Fields;
use Zira;
use Dash;
class Fields {
private static $_instance;
public static function getInstance() {
if (self::$_instance === null) {
self::$_instance = new self();
}
return self::$_instance;
}
public function beforeDispatch() {
}
public function bootstrap() {
if (ENABLE_CONFIG_DATABASE && Dash\Dash::getInstance()->isPanelEnabled() && Zira\Permission::check(Zira\Permission::TO_ACCESS_DASHBOARD) && Zira\Permission::check(Zira\Permission::TO_CHANGE_LAYOUT)) {
Dash\Dash::loadDashLanguage();
Dash\Dash::getInstance()->addPanelModulesGroupItem('glyphicon glyphicon-tags', Zira\Locale::tm('Extra fields', 'fields', null, Dash\Dash::getDashLanguage()), null, 'fieldGroupsWindow()');
Dash\Dash::getInstance()->registerModuleWindowClass('fieldGroupsWindow', 'Fields\Windows\Groups', 'Fields\Models\Groups');
Dash\Dash::getInstance()->registerModuleWindowClass('fieldGroupWindow', 'Fields\Windows\Group', 'Fields\Models\Groups');
Dash\Dash::getInstance()->registerModuleWindowClass('fieldsItemWindow', 'Fields\Windows\Fields', 'Fields\Models\Fields');
Dash\Dash::getInstance()->registerModuleWindowClass('fieldItemWindow', 'Fields\Windows\Field', 'Fields\Models\Fields');
Dash\Dash::unloadDashLanguage();
}
}
}

99
fields/forms/field.php Normal file
View file

@ -0,0 +1,99 @@
<?php
/**
* Zira project.
* field.php
* (c)2018 http://dro1d.ru
*/
namespace Fields\Forms;
use Zira;
use Zira\Form;
use Zira\Locale;
class Field extends Form
{
protected $_id = 'fields-item-form';
protected $_label_class = 'col-sm-4 control-label';
protected $_input_wrap_class = 'col-sm-8';
protected $_input_offset_wrap_class = 'col-sm-offset-4 col-sm-8';
protected $_select_wrapper_class = 'col-sm-8';
protected $_checkbox_inline_label = true;
public function __construct()
{
parent::__construct($this->_id);
}
protected function _init()
{
$this->setRenderPanel(false);
$this->setFormClass('form-horizontal dash-window-form');
}
protected function _render()
{
$types = \Fields\Models\Field::getTypes();
foreach($types as $var=>$val) {
$types[$var] = Locale::tm($val, 'eform');
}
$html = $this->open();
$html .= $this->input(Locale::t('Title').'*', 'title');
$html .= $this->textarea(Locale::t('Description'), 'description');
$html .= $this->select(Locale::tm('Type','fields').'*', 'field_type', $types, array('class'=>'form-control field-types-select'));
$html .= Zira\Helper::tag_open('div', array('class'=>'form_field_values_wrapper', 'style'=>'display:none'));
$html .= $this->input(Locale::tm('Field values','fields').'*', 'form_field_values[]', array('class'=>'form-control field-values-input', 'id'=>''));
$html .= Zira\Helper::tag_close('div');
$html .= $this->checkbox(Locale::tm('add to record description','fields'), 'preview', null, false);
$html .= $this->checkbox(Locale::tm('field is active','fields'), 'active', null, false);
$html .= $this->hidden('id');
$html .= $this->hidden('field_group_id');
$html .= $this->hidden('field_values', array('class'=>'field-values-hidden'));
$html .= $this->close();
return $html;
}
protected function _validate() {
$validator = $this->getValidator();
$validator->registerCustom(array(get_class(), 'checkGroup'), array('field_group_id'), Locale::t('An error occurred'));
$validator->registerCustom(array(get_class(), 'checkType'), array('field_type'), Locale::t('Invalid value "%s"',Locale::t('Type')));
$validator->registerString('title',null,255,true,Locale::t('Invalid value "%s"',Locale::t('Title')));
$validator->registerNoTags('title',Locale::t('Invalid value "%s"',Locale::t('Title')));
$validator->registerUtf8('title',Locale::t('Invalid value "%s"',Locale::t('Title')));
$validator->registerNoTags('description',Locale::t('Invalid value "%s"',Locale::t('Description')));
$validator->registerUtf8('description',Locale::t('Invalid value "%s"',Locale::t('Description')));
$type = $this->getValue('field_type');
if ($type == 'radio' || $type == 'select') {
$validator->registerCustom(array(get_class(), 'checkValues'), 'form_field_values', Locale::t('Invalid value "%s"', Locale::t('Field values')));
}
}
public static function checkGroup($group_id) {
$group = new \Fields\Models\Group($group_id);
return $group->loaded();
}
public static function checkType($type) {
$types = \Fields\Models\Field::getTypes();
return array_key_exists($type, $types);
}
public static function checkValues($values) {
if (!is_array($values)) return false;
$co = 0;
foreach($values as $value) {
if (strpos($value, '"')!==false) return false;
if (strpos($value, ',')!==false) return false;
if (preg_match('/[<][a-z\/][^>]*[>]/si', $value)) return false;
if (Zira\Helper::utf8BadMatch($value)) return false;
if (!empty($value)) $co++;
}
return $co>0;
}
}

92
fields/forms/group.php Normal file
View file

@ -0,0 +1,92 @@
<?php
/**
* Zira project.
* group.php
* (c)2018 http://dro1d.ru
*/
namespace Fields\Forms;
use Zira;
use Zira\Form;
use Zira\Locale;
class Group extends Form
{
protected $_id = 'fields-group-form';
protected $_label_class = 'col-sm-4 control-label';
protected $_input_wrap_class = 'col-sm-8';
protected $_input_offset_wrap_class = 'col-sm-offset-4 col-sm-8';
protected $_select_wrapper_class = 'col-sm-8';
protected $_checkbox_inline_label = true;
public function __construct()
{
parent::__construct($this->_id);
}
protected function _init()
{
$this->setRenderPanel(false);
$this->setFormClass('form-horizontal dash-window-form');
}
protected function _render()
{
$placeholders = \Fields\Models\Group::getPlaceholders();
$categories = array(Zira\Category::ROOT_CATEGORY_ID => Locale::t('All pages')) + Zira\Models\Category::getArray();
$html = $this->open();
$html .= $this->input(Locale::t('Title').'*', 'title');
$html .= $this->textarea(Locale::t('Description'), 'description');
$html .= $this->select(Locale::t('Placeholder').'*','placeholder',$placeholders);
if (count(Zira\Config::get('languages'))<2) {
$html .= $this->hidden('language');
} else {
$languagesArr = array_merge(array(''=>Locale::t('All languages')), Locale::getLanguagesArray());
$html .= $this->select(Locale::t('Language').'*','language',$languagesArr, array('class'=>'form-control language-select'));
}
$html .= $this->select(Locale::t('Category'),'category_id',$categories);
$html .= $this->checkbox(Locale::tm('group is active','fields'), 'active', null, false);
$html .= $this->hidden('id');
$html .= $this->close();
return $html;
}
protected function _validate() {
$validator = $this->getValidator();
$validator->registerString('title',null,255,true,Locale::t('Invalid value "%s"',Locale::t('Title')));
$validator->registerNoTags('title',Locale::t('Invalid value "%s"',Locale::t('Title')));
$validator->registerUtf8('title',Locale::t('Invalid value "%s"',Locale::t('Title')));
$validator->registerNoTags('description',Locale::t('Invalid value "%s"',Locale::t('Description')));
$validator->registerUtf8('description',Locale::t('Invalid value "%s"',Locale::t('Description')));
$validator->registerString('placeholder', null, 255, true, Locale::t('Invalid value "%s"',Locale::t('Placeholder')));
$validator->registerCustom(array(get_class(), 'checkPlaceholder'), 'placeholder', Locale::t('Invalid value "%s"',Locale::t('Placeholder')));
$validator->registerCustom(array(get_class(), 'checkLanguage'), 'language', Locale::t('An error occurred'));
$validator->registerCustom(array(get_class(), 'checkCategory'), 'category_id', Locale::t('An error occurred'));
}
public static function checkPlaceholder($placeholder) {
$placeholders = \Fields\Models\Group::getPlaceholders();
return array_key_exists($placeholder, $placeholders);
}
public static function checkLanguage($language) {
if (empty($language)) return true;
return in_array($language , Zira\Config::get('languages'));
}
public static function checkCategory($category_id) {
if (!is_numeric($category_id)) return false;
if ($category_id==Zira\Category::ROOT_CATEGORY_ID) return true;
$category = new Zira\Models\Category($category_id);
return $category->loaded();
}
}

View file

@ -0,0 +1,51 @@
<?php
/**
* Zira project.
* fieldgroup.php
* (c)2018 http://dro1d.ru
*/
namespace Fields\Install;
use Zira\Db\Table;
use Zira\Db\Field;
class Fieldgroup extends Table {
protected $_table = 'field_groups';
public function __construct() {
parent::__construct($this->_table);
}
public function getFields() {
return array(
'id' => Field::primary(),
'title' => Field::string(true),
'description' => Field::string(false),
'placeholder' => Field::string(true),
'category_id' => Field::int(true, true),
'language' => Field::string(false),
'sort_order' => Field::int(true, false, 0),
'active' => Field::int(true, true, 0),
'tpl' => Field::string(false)
);
}
public function getKeys() {
return array(
'search' => array('sort_order', 'active', 'category_id', 'language')
);
}
public function getUnique() {
return array(
);
}
public function getDefaults() {
return array(
);
}
}

View file

@ -0,0 +1,51 @@
<?php
/**
* Zira project.
* fielditem.php
* (c)2018 http://dro1d.ru
*/
namespace Fields\Install;
use Zira\Db\Table;
use Zira\Db\Field;
class Fielditem extends Table {
protected $_table = 'field_items';
public function __construct() {
parent::__construct($this->_table);
}
public function getFields() {
return array(
'id' => Field::primary(),
'field_group_id' => Field::int(true, true),
'field_type' => Field::string(true),
'field_values' => Field::text(),
'title' => Field::string(true),
'description' => Field::string(false),
'sort_order' => Field::int(true, false, 0),
'active' => Field::int(true, true, 0),
'preview' => Field::int(true, true, 0)
);
}
public function getKeys() {
return array(
'search' => array('sort_order', 'active', 'field_group_id')
);
}
public function getUnique() {
return array(
);
}
public function getDefaults() {
return array(
);
}
}

View file

@ -0,0 +1,49 @@
<?php
/**
* Zira project.
* fieldvalue.php
* (c)2018 http://dro1d.ru
*/
namespace Fields\Install;
use Zira\Db\Table;
use Zira\Db\Field;
class Fieldvalue extends Table {
protected $_table = 'field_values';
public function __construct() {
parent::__construct($this->_table);
}
public function getFields() {
return array(
'id' => Field::primary(),
'record_id' => Field::int(true, true),
'field_item_id' => Field::int(true, true),
'field_group_id' => Field::int(true, true),
'content' => Field::text(),
'mark' => Field::string(true),
'date_added' => Field::datetime(true)
);
}
public function getKeys() {
return array(
'search' => array('record_id')
);
}
public function getUnique() {
return array(
);
}
public function getDefaults() {
return array(
);
}
}

51
fields/models/field.php Normal file
View file

@ -0,0 +1,51 @@
<?php
/**
* Zira project.
* field.php
* (c)2018 http://dro1d.ru
*/
namespace Fields\Models;
use Zira;
use Zira\Orm;
class Field extends Orm {
public static $table = 'field_items';
public static $pk = 'id';
public static $alias = 'fld_itm';
protected static $_types = array(
'input' => 'Text field',
'textarea' => 'Text area',
'checkbox' => 'Check box',
'radio' => 'Radio button',
'select' => 'Select dropdown',
'file' => 'File',
'image' => 'Image',
'link' => 'URL address',
'html' => 'HTML code'
);
public static function getTable() {
return self::$table;
}
public static function getPk() {
return self::$pk;
}
public static function getAlias() {
return self::$alias;
}
public static function getReferences() {
return array(
);
}
public static function getTypes() {
return self::$_types;
}
}

118
fields/models/fields.php Normal file
View file

@ -0,0 +1,118 @@
<?php
/**
* Zira project.
* fields.php
* (c)2018 http://dro1d.ru
*/
namespace Fields\Models;
use Zira;
use Dash;
use Zira\Permission;
class Fields extends Dash\Models\Model {
public function save($data) {
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
return array('error' => Zira\Locale::t('Permission denied'));
}
$form = new \Fields\Forms\Field();
if ($form->isValid()) {
$id = (int)$form->getValue('id');
if ($id) {
$field = new \Fields\Models\Field($id);
if (!$field->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
} else {
$max_order = \Fields\Models\Field::getCollection()->max('sort_order')->get('mx');
$field = new \Fields\Models\Field();
$field->sort_order = ++$max_order;
}
$field->title = $form->getValue('title');
$field->description = $form->getValue('description');
$field->field_group_id = $form->getValue('field_group_id');
$field->field_type = $form->getValue('field_type');
$form_field_values = $form->getValue('form_field_values');
if (is_array($form_field_values) && !empty($form_field_values)) {
$_field_values = '';
foreach($form_field_values as $form_field_value) {
if (empty($form_field_value)) continue;
if (strlen($_field_values)>0) $_field_values .= ',';
$_field_values .= $form_field_value;
}
if (empty($_field_values)) $_field_values = null;
$field->field_values = $_field_values;
} else {
$field->field_values = null;
}
$field->preview = (int)$form->getValue('preview') ? 1 : 0;
$field->active = (int)$form->getValue('active') ? 1 : 0;
$field->save();
return array('message'=>Zira\Locale::t('Successfully saved'), 'close'=>true);
} else {
return array('error'=>$form->getError());
}
}
public function delete($data) {
if (empty($data) || !is_array($data)) return array('error' => Zira\Locale::t('An error occurred'));
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
return array('error'=>Zira\Locale::t('Permission denied'));
}
foreach($data as $field_id) {
$field = new \Fields\Models\Field($field_id);
if (!$field->loaded()) {
return array('error' => Zira\Locale::t('An error occurred'));
}
// deleting active field is not allowed
if ($field->active) {
return array('error' => Zira\Locale::tm('Cannot delete active field', 'fields'));
}
$field->delete();
\Fields\Models\Value::getCollection()
->where('field_item_id','=',$field_id)
->delete()
->execute();
}
return array('reload' => $this->getJSClassName());
}
public function drag($items, $orders) {
if (empty($items) || !is_array($items) || count($items)<2 || empty($orders) || !is_array($orders) || count($orders)<2 || count($items)!=count($orders)) {
return array('error' => Zira\Locale::t('An error occurred'));
}
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
return array('error'=>Zira\Locale::t('Permission denied'));
}
$_items = array();
$_orders = array();
foreach($items as $id) {
$_item = new \Fields\Models\Field($id);
if (!$_item->loaded()) {
return array('error' => Zira\Locale::t('An error occurred'));
}
$_items []= $_item;
$_orders []= $_item->sort_order;
}
foreach($orders as $order) {
if (!in_array($order, $_orders)) {
return array('error' => Zira\Locale::t('An error occurred'));
}
}
foreach($_items as $index=>$item) {
$item->sort_order = intval($orders[$index]);
$item->save();
}
return array('reload'=>$this->getJSClassName());
}
}

45
fields/models/group.php Normal file
View file

@ -0,0 +1,45 @@
<?php
/**
* Zira project.
* group.php
* (c)2018 http://dro1d.ru
*/
namespace Fields\Models;
use Zira;
use Zira\Orm;
class Group extends Orm {
public static $table = 'field_groups';
public static $pk = 'id';
public static $alias = 'fld_grp';
public static function getTable() {
return self::$table;
}
public static function getPk() {
return self::$pk;
}
public static function getAlias() {
return self::$alias;
}
public static function getReferences() {
return array(
);
}
public static function getPlaceholders() {
return array(
Zira\View::VAR_SIDEBAR_LEFT => Zira\Locale::t('Left sidebar'),
Zira\View::VAR_SIDEBAR_RIGHT => Zira\Locale::t('Right sidebar'),
Zira\View::VAR_CONTENT_TOP => Zira\Locale::t('Before content'),
Zira\View::VAR_CONTENT => Zira\Locale::t('Content'),
Zira\View::VAR_CONTENT_BOTTOM => Zira\Locale::t('After content')
);
}
}

118
fields/models/groups.php Normal file
View file

@ -0,0 +1,118 @@
<?php
/**
* Zira project.
* groups.php
* (c)2018 http://dro1d.ru
*/
namespace Fields\Models;
use Zira;
use Dash;
use Fields;
use Zira\Permission;
class Groups extends Dash\Models\Model {
public function save($data) {
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
return array('error' => Zira\Locale::t('Permission denied'));
}
$form = new Fields\Forms\Group();
if ($form->isValid()) {
$id = (int)$form->getValue('id');
if ($id) {
$group = new Fields\Models\Group($id);
if (!$group->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
} else {
$max_order = Fields\Models\Group::getCollection()->max('sort_order')->get('mx');
$group = new Fields\Models\Group();
$group->sort_order = ++$max_order;
}
$group->title = $form->getValue('title');
$group->description = $form->getValue('description');
$group->placeholder = $form->getValue('placeholder');
$group->category_id = (int)$form->getValue('category_id');
$language = $form->getValue('language');
if (empty($language)) $language = null;
$group->language = $language;
$group->active = (int)$form->getValue('active') ? 1 : 0;
$group->save();
return array('message'=>Zira\Locale::t('Successfully saved'), 'close'=>true);
} else {
return array('error'=>$form->getError());
}
}
public function delete($data) {
if (empty($data) || !is_array($data)) return array('error' => Zira\Locale::t('An error occurred'));
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
return array('error'=>Zira\Locale::t('Permission denied'));
}
foreach($data as $group_id) {
$group = new Fields\Models\Group($group_id);
if (!$group->loaded()) {
return array('error' => Zira\Locale::t('An error occurred'));
};
// deleting non-empty group is not allowed
$co = Fields\Models\Field::getCollection()
->count()
->where('field_group_id','=',$group_id)
->get('co');
if ($co>0) return array('error' => Zira\Locale::tm('Cannot delete group that have fields', 'fields'));
$group->delete();
/**
Fields\Models\Field::getCollection()
->where('field_group_id','=',$group_id)
->delete()
->execute();
Fields\Models\Value::getCollection()
->where('field_group_id','=',$group_id)
->delete()
->execute();
*/
}
return array('reload' => $this->getJSClassName());
}
public function drag($items, $orders) {
if (empty($items) || !is_array($items) || count($items)<2 || empty($orders) || !is_array($orders) || count($orders)<2 || count($items)!=count($orders)) {
return array('error' => Zira\Locale::t('An error occurred'));
}
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
return array('error'=>Zira\Locale::t('Permission denied'));
}
$_items = array();
$_orders = array();
foreach($items as $id) {
$_item = new Fields\Models\Group($id);
if (!$_item->loaded()) {
return array('error' => Zira\Locale::t('An error occurred'));
}
$_items []= $_item;
$_orders []= $_item->sort_order;
}
foreach($orders as $order) {
if (!in_array($order, $_orders)) {
return array('error' => Zira\Locale::t('An error occurred'));
}
}
foreach($_items as $index=>$item) {
$item->sort_order = intval($orders[$index]);
$item->save();
}
return array('reload'=>$this->getJSClassName());
}
}

35
fields/models/value.php Normal file
View file

@ -0,0 +1,35 @@
<?php
/**
* Zira project.
* value.php
* (c)2018 http://dro1d.ru
*/
namespace Fields\Models;
use Zira;
use Zira\Orm;
class Value extends Orm {
public static $table = 'field_values';
public static $pk = 'id';
public static $alias = 'fld_val';
public static function getTable() {
return self::$table;
}
public static function getPk() {
return self::$pk;
}
public static function getAlias() {
return self::$alias;
}
public static function getReferences() {
return array(
);
}
}

5
fields/module.meta Normal file
View file

@ -0,0 +1,5 @@
[meta]
name = Extra fields
description = Record extra fields
author = Zira
version = 1.0

66
fields/windows/field.php Normal file
View file

@ -0,0 +1,66 @@
<?php
/**
* Zira project.
* field.php
* (c)2018 http://dro1d.ru
*/
namespace Fields\Windows;
use Zira;
use Dash;
use Zira\Permission;
class Field extends Dash\Windows\Window {
protected static $_icon_class = 'glyphicon glyphicon-tags';
protected static $_title = 'Record extra field';
//protected $_help_url = 'zira/help/extra-field';
public $item;
public function init() {
$this->setIconClass(self::$_icon_class);
$this->setTitle(Zira\Locale::t(self::$_title));
$this->setSidebarEnabled(false);
$this->setSaveActionEnabled(true);
}
public function create() {
$this->setOnLoadJSCallback(
$this->createJSCallback(
'desk_window_form_init(this);'.
'desk_call(dash_fields_field_form_init, this);'
)
);
}
public function load() {
$group_id = Zira\Request::post('group_id');
if (empty($group_id)) return array('error' => Zira\Locale::t('An error occurred'));
if (!empty($this->item)) $this->item=intval($this->item);
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
return array('error' => Zira\Locale::t('Permission denied'));
}
$group = new \Fields\Models\Group($group_id);
if (!$group->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
$form = new \Fields\Forms\Field();
if (!empty($this->item)) {
$field = new \Fields\Models\Field($this->item);
if (!$field->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
$form->setValues($field->toArray());
$this->setTitle(Zira\Locale::tm(self::$_title,'fields').' - '.$group->title.' - '.$field->title);
} else {
$form->setValues(array(
'field_group_id' => $group->id,
'active'=>1
));
$this->setTitle(Zira\Locale::tm('New record extra field','fields').' - '.$group->title);
}
$this->setBodyContent($form);
}
}

87
fields/windows/fields.php Normal file
View file

@ -0,0 +1,87 @@
<?php
/**
* Zira project.
* fields.php
* (c)2018 http://dro1d.ru
*/
namespace Fields\Windows;
use Dash\Dash;
use Dash\Windows\Window;
use Zira;
use Zira\Permission;
class Fields extends Window {
protected static $_icon_class = 'glyphicon glyphicon-tags';
protected static $_title = 'Record extra fields';
//protected $_help_url = 'zira/help/extra-fields';
public $item;
public function init() {
$this->setIconClass(self::$_icon_class);
$this->setTitle(Zira\Locale::t(self::$_title));
$this->setViewSwitcherEnabled(false);
$this->setSelectionLinksEnabled(true);
$this->setSidebarEnabled(false);
$this->setBodyViewListVertical(true);
$this->setOnCreateItemJSCallback(
$this->createJSCallback('desk_call(dash_fields_item_create, this)')
);
$this->setOnEditItemJSCallback(
$this->createJSCallback('desk_call(dash_fields_item_edit, this)')
);
$this->setDeleteActionEnabled(true);
}
public function create() {
$this->addDefaultToolbarItem(
$this->createToolbarButton(Zira\Locale::tm('Add field', 'fields'), Zira\Locale::tm('Add field', 'fields'), 'glyphicon glyphicon-plus-sign', 'desk_call(dash_fields_item_create, this)', 'create')
);
$this->setOnOpenJSCallback(
$this->createJSCallback(
'desk_call(dash_fields_fields_drag, this);'
)
);
$this->addDefaultOnLoadScript(
'desk_call(dash_fields_fields_load, this);'
);
$this->setData(array(
'items' => array($this->item)
));
}
public function load() {
if (!empty($this->item)) $this->item=intval($this->item);
else return array('error'=>Zira\Locale::t('An error occurred'));
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
$this->setBodyItems(array());
return array('error'=>Zira\Locale::t('Permission denied'));
}
$group = new \Fields\Models\Group($this->item);
if (!$group->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
$query = \Fields\Models\Field::getCollection();
$query->where('field_group_id', '=', $group->id);
$query->order_by('sort_order', 'asc');
$rows = $query->get();
$items = array();
foreach($rows as $row) {
$items[]=$this->createBodyItem(Zira\Helper::html($row->title), Zira\Helper::html($row->description), Zira\Helper::imgUrl('drag.png'), $row->id, null, false, array('activated'=>$row->active,'sort_order'=>$row->sort_order));
}
$this->setBodyItems($items);
$this->setTitle(Zira\Locale::tm(self::$_title,'fields').' - '.$group->title);
}
}

60
fields/windows/group.php Normal file
View file

@ -0,0 +1,60 @@
<?php
/**
* Zira project.
* group.php
* (c)2018 http://dro1d.ru
*/
namespace Fields\Windows;
use Zira;
use Dash;
use Zira\Permission;
class Group extends Dash\Windows\Window {
protected static $_icon_class = 'glyphicon glyphicon-tags';
protected static $_title = 'Extra field group';
//protected $_help_url = 'zira/help/extra-field-group';
public $item;
public function init() {
$this->setIconClass(self::$_icon_class);
$this->setTitle(Zira\Locale::t(self::$_title));
$this->setSidebarEnabled(false);
$this->setSaveActionEnabled(true);
}
public function create() {
$this->setOnLoadJSCallback(
$this->createJSCallback(
'desk_window_form_init(this);'
)
);
}
public function load() {
if (!empty($this->item)) $this->item=intval($this->item);
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
return array('error' => Zira\Locale::t('Permission denied'));
}
$form = new \Fields\Forms\Group();
if (!empty($this->item)) {
$group = new \Fields\Models\Group($this->item);
if (!$group->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
$form->setValues($group->toArray());
$this->setTitle(Zira\Locale::tm(self::$_title,'fields').' - '.$group->title);
} else {
$form->setValues(array(
'placeholder' => Zira\View::VAR_CONTENT,
'active'=>1
));
$this->setTitle(Zira\Locale::tm('New extra field group','fields'));
}
$this->setBodyContent($form);
}
}

122
fields/windows/groups.php Normal file
View file

@ -0,0 +1,122 @@
<?php
/**
* Zira project.
* groups.php
* (c)2018 http://dro1d.ru
*/
namespace Fields\Windows;
use Dash\Dash;
use Dash\Windows\Window;
use Zira;
use Zira\Permission;
class Groups extends Window {
protected static $_icon_class = 'glyphicon glyphicon-tags';
protected static $_title = 'Extra field groups';
//protected $_help_url = 'zira/help/extra-field-groups';
public function init() {
$this->setIconClass(self::$_icon_class);
$this->setTitle(Zira\Locale::t(self::$_title));
$this->setViewSwitcherEnabled(false);
$this->setSelectionLinksEnabled(true);
$this->setSidebarEnabled(true);
$this->setBodyViewListVertical(true);
$this->setCreateActionWindowClass(\Fields\Windows\Group::getClass());
$this->setEditActionWindowClass(\Fields\Windows\Group::getClass());
$this->setDeleteActionEnabled(true);
}
public function create() {
$this->addDefaultMenuDropdownItem(
$this->createMenuDropdownSeparator()
);
$this->addDefaultMenuDropdownItem(
$this->createMenuDropdownItem(Zira\Locale::tm('Group fields', 'fields'), 'glyphicon glyphicon-tags', 'desk_call(dash_fields_group_fields, this);', 'edit', true, array('typo'=>'groupfields'))
);
$this->addDefaultContextMenuItem(
$this->createContextMenuSeparator()
);
$this->addDefaultContextMenuItem(
$this->createContextMenuItem(Zira\Locale::tm('Group fields', 'fields'), 'glyphicon glyphicon-tags', 'desk_call(dash_fields_group_fields, this);', 'edit', true, array('typo'=>'groupfields'))
);
$this->setOnOpenJSCallback(
$this->createJSCallback(
'desk_call(dash_fields_group_drag, this);'
)
);
$this->addDefaultOnLoadScript(
'desk_call(dash_fields_group_load, this);'
);
$this->setData(array(
'language' => ''
));
$this->addVariables(array(
'dash_fields_blank_src' => Zira\Helper::imgUrl('blank.png'),
'dash_fields_fields_wnd' => Dash::getInstance()->getWindowJSName(\Fields\Windows\Fields::getClass()),
'dash_fields_field_wnd' => Dash::getInstance()->getWindowJSName(\Fields\Windows\Field::getClass())
));
$this->includeJS('fields/dash');
}
public function load() {
if (!Permission::check(Permission::TO_CHANGE_LAYOUT)) {
$this->setData(array(
'language' => ''
));
$this->setBodyItems(array());
return array('error'=>Zira\Locale::t('Permission denied'));
}
$language= (string)Zira\Request::post('language');
if (!empty($language) && !in_array($language, Zira\Config::get('languages'))) {
$language = '';
}
$query = \Fields\Models\Group::getCollection();
if (!empty($language)) {
$query->where('language', '=', $language);
}
$query->order_by('sort_order', 'asc');
$rows = $query->get();
$items = array();
foreach($rows as $row) {
$items[]=$this->createBodyItem(Zira\Helper::html($row->title), Zira\Helper::html($row->description), Zira\Helper::imgUrl('drag.png'), $row->id, 'desk_call(dash_fields_group_fields, this);', false, array('activated'=>$row->active,'sort_order'=>$row->sort_order));
}
$this->setBodyItems($items);
$menu = array(
$this->createMenuItem($this->getDefaultMenuTitle(), $this->getDefaultMenuDropdown())
);
if (count(Zira\Config::get('languages'))>1) {
$langMenu = array();
foreach(Zira\Locale::getLanguagesArray() as $lang_key=>$lang_name) {
if (!empty($language) && $language==$lang_key) $icon = 'glyphicon glyphicon-ok';
else $icon = 'glyphicon glyphicon-filter';
$langMenu []= $this->createMenuDropdownItem($lang_name, $icon, 'desk_call(dash_fields_group_language, this, element);', 'language', false, array('language'=>$lang_key));
}
$menu []= $this->createMenuItem(Zira\Locale::t('Languages'), $langMenu);
}
$this->setMenuItems($menu);
$this->setData(array(
'language' => $language
));
}
}

View file

@ -137,7 +137,7 @@ class Forum {
$messages = \Forum\Models\Message::getNewMessagesCount();
if ($messages == 0) return false;
return array(
'message'=>Zira\Locale::t('%s forum messages was posted', $messages),
'message'=>Zira\Locale::tm('%s forum messages was posted', 'forum', $messages),
'callback'=>Dash\Dash::getInstance()->getWindowJSName(\Forum\Windows\Forums::getClass())
);
}

29
languages/ru/fields.php Normal file
View file

@ -0,0 +1,29 @@
<?php
return array(
'Extra fields' => 'Экстра поля',
'Record extra fields' => 'Дополнительные поля записей',
'Extra field groups' => 'Группы дополнительных полей',
'New extra field group' => 'Новая группа экстра полей',
'Extra field group' => 'Группа экстра полей',
'New record extra field' => 'Новое экстра поле записи',
'Record extra field' => 'Экстра поле записи',
'group is active' => 'группа активна',
'field is active' => 'поле активно',
'Cannot delete group that have fields' => 'Невозможно удалить группу, которая имеет поля',
'Cannot delete active field' => 'Невозможно удалить активное поле',
'Group fields' => 'Поля группы',
'Add field' => 'Добавить поле',
'Text field' => 'Текстовая строка',
'File' => 'Файл',
'Check box' => 'Галочка',
'Radio button' => 'Переключатель',
'Text area' => 'Текстовое поле',
'Select dropdown' => 'Выпадающий список',
'Image' => 'Изображение',
'URL address' => 'URL адрес',
'HTML code' => 'HTML код',
'Type' => 'Тип',
'Field values' => 'Значения поля',
'add to record description' => 'добавить в описание записи'
);

View file

@ -486,7 +486,7 @@ body.dashboard-window-sidebar-resizing {
border-bottom: 1px solid #EDEDF6;
border-top: 1px solid #B3B6D1;
padding: 0px;
margin: 7px 14px;
margin: 3px 14px;
}
.dashboard-window .dashboard-window-sidebar .dashboard-sidebar-content-wrapper ul {
list-style-type: none;

View file

@ -66,7 +66,7 @@ body.dashboard-window-sidebar-resizing {
min-height: 70px;
background-color: #C1C5D1;
border: 1px solid #99A5BA;
border: 1px solid rgb(143, 155, 162);
border: 1px solid rgb(191, 191, 198);
box-shadow: 0px 0px 4px rgba(85, 70, 113, 0.41), inset 0px 0px 3px #CCC9DB;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
@ -86,8 +86,8 @@ body.dashboard-window-sidebar-resizing {
}
.dashboard-window-focused {
background-color: #BEBDDB;
background-color: rgb(201, 204, 210);
box-shadow: 0px 0px 4px rgba(85, 70, 113, 0.41), 0px 0px 3px #CCC9DB inset;
background-color: rgb(203, 203, 203);
box-shadow: 0px 0px 4px rgba(203, 191, 227, 0.4), 0px 0px 3px #F2F1F3 inset;
}
.dashboard-window-maximized.dashboard-window-focused {
background-color: #D7D7E1;
@ -209,8 +209,9 @@ body.dashboard-window-sidebar-resizing {
.dashboard-window .dashboard-window-footer {
position: relative;
width: 100%;
height: 16px;
border-top: 1px solid #efefef;
height: 14px;
border-top: 1px solid #ddd;
background: #ddd;
overflow: hidden;
-webkit-touch-callout: none;
-webkit-user-select: none;
@ -220,7 +221,8 @@ body.dashboard-window-sidebar-resizing {
user-select: none;
}
.dashboard-window-focused .dashboard-window-footer {
border-top: 1px solid #F1F6F6;
border-top: 1px solid #e0e2ed;
background: #e0e2ed;
}
.dashboard-window .dashboard-window-header .dashboard-window-title {
display: block;
@ -494,7 +496,7 @@ body.dashboard-window-sidebar-resizing {
border-bottom: 1px solid #EDEDF6;
border-top: 1px solid #B3B6D1;
padding: 0px;
margin: 7px 14px;
margin: 3px 14px;
}
.dashboard-window .dashboard-window-sidebar .dashboard-sidebar-content-wrapper ul {
list-style-type: none;
@ -649,8 +651,8 @@ body.dashboard-window-sidebar-resizing {
}
.dashboard-window .dashboard-window-footer .dashboard-footer-content-wrapper {
margin: 0px 10px;
color: #434A5F;
text-shadow: none;
color: #878890;
text-shadow: 0px 1px #fff;
font-size: 12px;
line-height: 12px;
white-space: nowrap;

View file

@ -486,7 +486,7 @@ body.dashboard-window-sidebar-resizing {
border-bottom: 1px solid #EDEDF6;
border-top: 1px solid #B3B6D1;
padding: 0px;
margin: 7px 14px;
margin: 3px 14px;
}
.dashboard-window .dashboard-window-sidebar .dashboard-sidebar-content-wrapper ul {
list-style-type: none;

View file

@ -10,7 +10,7 @@ namespace Zira;
use Dash\Dash;
class Zira {
const VERSION = '1.1.0';
const VERSION = '1.2.0';
private static $_instance;
public static function getInstance() {