forum module added, minor fixes
This commit is contained in:
parent
54f2812e5b
commit
31ff906aa3
|
@ -118,6 +118,10 @@
|
|||
border-left: 2px solid #b2b5fd;
|
||||
padding-left: 4px;
|
||||
}
|
||||
.contenteditable q:before,
|
||||
.contenteditable q:after {
|
||||
content: '';
|
||||
}
|
||||
.contenteditable code {
|
||||
border-radius: 0;
|
||||
border-left: 2px solid #b1566f;
|
||||
|
|
157
assets/css/forum/forum.css
Normal file
157
assets/css/forum/forum.css
Normal file
|
@ -0,0 +1,157 @@
|
|||
.forum-messages-panel.messages-panel {
|
||||
|
||||
}
|
||||
.forum-messages-panel.messages-panel nav {
|
||||
background: linear-gradient(to bottom,#F6F6F6,#ECECEC);
|
||||
}
|
||||
.forum-message-wrapper .forum-avatar-wrapper {
|
||||
display: block;
|
||||
float: left;
|
||||
margin-bottom: 10px;
|
||||
vertical-align: top;
|
||||
min-width: 150px;
|
||||
background: #F2F2F2;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #E9E9E9;
|
||||
}
|
||||
.forum-message-wrapper .forum-avatar-wrapper img {
|
||||
max-width: 100px;
|
||||
height: auto;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.forum-message-wrapper .forum-avatar-wrapper .forum-group-super-admin {
|
||||
color: #A2559C;
|
||||
}
|
||||
.forum-message-wrapper .forum-avatar-wrapper .forum-group-admin {
|
||||
color: #447D7D;
|
||||
}
|
||||
.forum-message-wrapper .forum-message {
|
||||
display: block;
|
||||
vertical-align: top;
|
||||
margin-left: 180px;
|
||||
}
|
||||
.forum-info {
|
||||
background-image: linear-gradient(to bottom, #D7E7F8 0px, #D5E6F9 100%);
|
||||
color: #205471;
|
||||
}
|
||||
.forum-label {
|
||||
position: relative;
|
||||
top: -2px;
|
||||
padding: 5px 10px;
|
||||
margin-right: 7px;
|
||||
}
|
||||
.forum-bottom-label {
|
||||
top: 5px;
|
||||
padding: 10px 20px;
|
||||
}
|
||||
.forum-user-info {
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.forum-info-wrapper .link {
|
||||
float: right;
|
||||
}
|
||||
.forum-info-wrapper .note {
|
||||
float: right;
|
||||
cursor: default;
|
||||
}
|
||||
.forum-list.list .list-item {
|
||||
background-color: #fff;
|
||||
border: 1px solid #F5F5F5;
|
||||
box-shadow: 0px 0px 2px #efefef;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.forum-list.list .list-item.even,
|
||||
.forum-list.list .list-item.even-b,
|
||||
.forum-list.list .list-item.odd-b {
|
||||
background-color: #fdfdfd;
|
||||
}
|
||||
.forum-list.list .list-item a.list-title:link,
|
||||
.forum-list.list .list-item a.list-title:visited,
|
||||
.forum-list.list .list-item .list-title-wrapper a:link,
|
||||
.forum-list.list .list-item .list-title-wrapper a:visited {
|
||||
color: #41566B;
|
||||
}
|
||||
.forum-list.list .list-item a.list-title:hover {
|
||||
text-decoration: none;
|
||||
color: #4573A1;
|
||||
}
|
||||
.forum-list.list .list-item .list-title-wrapper {
|
||||
background-color: #F8F8F8;
|
||||
}
|
||||
.forum-list.list .list-item.even .list-title-wrapper,
|
||||
.forum-list.list .list-item.even-b .list-title-wrapper,
|
||||
.forum-list.list .list-item.odd-b .list-title-wrapper {
|
||||
background-color: #F0F0F0;
|
||||
}
|
||||
.forum-list.forum-top-list.list .list-item .list-title-wrapper {
|
||||
background-color: #E4E6E9;
|
||||
}
|
||||
.forum-list.list .list-item .list-title-wrapper .forum-right-item {
|
||||
float: right;
|
||||
font-size: 16px;
|
||||
margin-top: 3px;
|
||||
}
|
||||
.forum-list.list .list-item .list-content-wrapper {
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.forum-list.list .list-item .list-info-wrapper {
|
||||
background: #F8F8F8;
|
||||
margin-top: 0px;
|
||||
padding-top: 10px;
|
||||
border-top: #fefefe;
|
||||
}
|
||||
.forum-list.forum-top-list.list .list-item .list-info-wrapper {
|
||||
background-color: #EFEFF0;
|
||||
}
|
||||
.forum-list.list .list-item .list-info,
|
||||
.forum-list.list .list-item .list-info a:link,
|
||||
.forum-list.list .list-item .list-info a:visited {
|
||||
color: #505559;
|
||||
font-size: 14px;
|
||||
}
|
||||
.forum-page-header.page-header {
|
||||
border: none;
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
.forum-page-header.page-header a:link,
|
||||
.forum-page-header.page-header a:visited {
|
||||
color: #333;
|
||||
}
|
||||
.forum-page-header.page-header a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
.forum-btn.btn {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.forum-list.list .list-item .list-info-wrapper a.forum-like:link,
|
||||
.forum-list.list .list-item .list-info-wrapper a.forum-like:visited {
|
||||
color: #1d7690;
|
||||
text-decoration: none;
|
||||
margin-right: 0px;
|
||||
}
|
||||
.forum-list.list .list-item .list-info-wrapper a.forum-like:hover,
|
||||
.forum-list.list .list-item .list-info-wrapper a.forum-like.active {
|
||||
color: #114150;
|
||||
text-decoration: none;
|
||||
}
|
||||
.forum-list.list .list-item .list-info-wrapper a.forum-dislike:link,
|
||||
.forum-list.list .list-item .list-info-wrapper a.forum-dislike:visited {
|
||||
color: #a41748;
|
||||
text-decoration: none;
|
||||
}
|
||||
.forum-list.list .list-item .list-info-wrapper a.forum-dislike:hover,
|
||||
.forum-list.list .list-item .list-info-wrapper a.forum-dislike.active {
|
||||
color: #550e2a;
|
||||
text-decoration: none;
|
||||
}
|
||||
.forum-list.list .list-item .list-info-wrapper .forum-rating-value .positive-rating {
|
||||
color: green;
|
||||
}
|
||||
.forum-list.list .list-item .list-info-wrapper .forum-rating-value .negative-rating {
|
||||
color: red;
|
||||
}
|
|
@ -1,13 +1,8 @@
|
|||
var dash_eform_select = function() {
|
||||
var selected = this.getSelectedContentItems();
|
||||
if (selected && selected.length > 0) {
|
||||
this.disableItemsByProperty('typo', 'page');
|
||||
for (var i = 0; i < selected.length; i++) {
|
||||
if (typeof(selected[i].inactive) != "undefined" && !selected[i].inactive) {
|
||||
this.enableItemsByProperty('typo', 'page');
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.disableItemsByProperty('typo', 'page');
|
||||
if (selected && selected.length == 1 && typeof(selected[0].inactive) != "undefined" && !selected[0].inactive) {
|
||||
this.enableItemsByProperty('typo', 'page');
|
||||
}
|
||||
if (selected && selected.length && selected.length==1 && (typeof(this.info_last_item)=="undefined" || this.info_last_item!=selected[0].data || $(this.element).find('.eform-infobar').html().length==0)) {
|
||||
this.info_last_item = selected[0].data;
|
||||
|
|
|
@ -41,9 +41,13 @@
|
|||
$(this).parent().children('.emoji-buttons').append('<a href="javascript:void(0)" title="'+t('Code')+'" class="emoji-button emoji-code-button"></a>');
|
||||
$(this).parent().children('.emoji-buttons').children('.emoji-code-button').click(zira_bind(this, emoji_input_code));
|
||||
// handle form submit
|
||||
$(this).parents('form').eq(0).bind('xhr-submit-start', zira_bind(this, emoji_submit));
|
||||
$(this).parents('form').eq(0).bind('xhr-submit-success', zira_bind(this, emoji_submit_success));
|
||||
$(this).parents('form').eq(0).bind('xhr-submit-error', zira_bind(this, emoji_submit_error));
|
||||
if ($(this).parents('form').eq(0).hasClass('xhr-form')) {
|
||||
$(this).parents('form').eq(0).bind('xhr-submit-start', zira_bind(this, emoji_submit));
|
||||
$(this).parents('form').eq(0).bind('xhr-submit-success', zira_bind(this, emoji_submit_success));
|
||||
$(this).parents('form').eq(0).bind('xhr-submit-error', zira_bind(this, emoji_submit_error));
|
||||
} else {
|
||||
$(this).parents('form').eq(0).submit(zira_bind(this, emoji_submit));
|
||||
}
|
||||
// creating contenteditable
|
||||
if (typeof(emoji_paste.contentEditable)!="undefined" && emoji_paste.contentEditable) {
|
||||
$(this).after('<div class="emoji-editable contenteditable" id="'+$(this).attr('id')+'-editable" contenteditable="true"></div>');
|
||||
|
|
342
assets/js/forum/dash.js
Normal file
342
assets/js/forum/dash.js
Normal file
|
@ -0,0 +1,342 @@
|
|||
var dash_forum_forums_select = function() {
|
||||
var selected = this.getSelectedContentItems();
|
||||
this.disableItemsByProperty('typo', 'page');
|
||||
if (selected && selected.length == 1 && typeof(selected[0].inactive) != "undefined" && !selected[0].inactive) {
|
||||
this.enableItemsByProperty('typo', 'page');
|
||||
}
|
||||
};
|
||||
|
||||
var dash_forum_forums_load = function() {
|
||||
for (var i=0; i<this.options.bodyItems.length; i++) {
|
||||
if (typeof(this.options.bodyItems[i].inactive)!="undefined" && this.options.bodyItems[i].inactive) {
|
||||
$(this.options.bodyItems[i].element).addClass('inactive');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var dash_forum_category_filter = function(cat_id) {
|
||||
if (this.options.data.category_id == cat_id) return;
|
||||
var item = this.findMenuItemByProperty('category_id',cat_id);
|
||||
if (item) {
|
||||
$(item.element).parents('ul').find('.glyphicon-ok').removeClass('glyphicon-ok').addClass('glyphicon-filter');
|
||||
$(item.element).find('.glyphicon').removeClass('glyphicon-filter').addClass('glyphicon-ok');
|
||||
}
|
||||
this.options.data.category_id = cat_id;
|
||||
desk_window_reload(this);
|
||||
};
|
||||
|
||||
var dash_forum_categories = function() {
|
||||
var data = {
|
||||
'data': {
|
||||
'items': []
|
||||
},
|
||||
'reload': this.className,
|
||||
'onClose':function(){
|
||||
desk_window_reload_all(this.options.reload);
|
||||
}
|
||||
};
|
||||
desk_call(dash_forum_categories_wnd, null, data);
|
||||
};
|
||||
|
||||
var dash_forum_forum_create = function() {
|
||||
var data = {
|
||||
'data': {
|
||||
'items': [],
|
||||
'category_id': this.options.data.category_id
|
||||
},
|
||||
'reload': this.className,
|
||||
'onClose':function(){
|
||||
desk_window_reload_all(this.options.reload);
|
||||
}
|
||||
};
|
||||
desk_call(dash_forum_forum_wnd, null, data);
|
||||
};
|
||||
|
||||
var dash_forum_forum_edit = function() {
|
||||
var selected = this.getSelectedContentItems();
|
||||
if (selected && selected.length==1) {
|
||||
var data = {
|
||||
'data':{
|
||||
'items': [selected[0].data],
|
||||
'category_id': this.options.data.category_id
|
||||
},
|
||||
'reload': this.className,
|
||||
'onClose':function(){
|
||||
desk_window_reload_all(this.options.reload);
|
||||
}
|
||||
};
|
||||
desk_call(dash_forum_forum_wnd, null, data);
|
||||
}
|
||||
};
|
||||
|
||||
var dash_forum_categories_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_eform_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') || $(item).parent('li').hasClass('tmp-drag-category-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-category-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-category-item').replaceWith($(this.content).find('#'+this.dragStartItem).parent('li'));
|
||||
this.dragReplaced = true;
|
||||
}
|
||||
}));
|
||||
$(this.content).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('forum/dash/dragcategory'),{'categories':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-category-item').remove();
|
||||
}));
|
||||
};
|
||||
|
||||
var dash_forum_forums_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_eform_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') || $(item).parent('li').hasClass('tmp-drag-forum-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-forum-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-forum-item').replaceWith($(this.content).find('#'+this.dragStartItem).parent('li'));
|
||||
this.dragReplaced = true;
|
||||
}
|
||||
}));
|
||||
$(this.content).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('forum/dash/dragforum'),{'forums':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-forum-item').remove();
|
||||
}));
|
||||
};
|
||||
|
||||
var dash_forum_page = function() {
|
||||
var selected = this.getSelectedContentItems();
|
||||
if (selected.length==1 && typeof(selected[0].page)!="undefined") {
|
||||
window.location.href=url(selected[0].page);
|
||||
}
|
||||
};
|
||||
|
||||
var dash_forum_settings = function() {
|
||||
var data = {
|
||||
'data': {
|
||||
'items': []
|
||||
},
|
||||
'reload': this.className,
|
||||
'onClose':function(){
|
||||
desk_window_reload_all(this.options.reload);
|
||||
}
|
||||
};
|
||||
desk_call(dash_forum_settings_wnd, null, data);
|
||||
};
|
||||
|
||||
var dash_forum_threads = function() {
|
||||
var selected = this.getSelectedContentItems();
|
||||
if (selected && selected.length==1) {
|
||||
var data = {
|
||||
'data':{
|
||||
'items': [selected[0].data]
|
||||
},
|
||||
'reload': this.className,
|
||||
'onClose':function(){
|
||||
desk_window_reload_all(this.options.reload);
|
||||
}
|
||||
};
|
||||
desk_call(dash_forum_threads_wnd, null, data);
|
||||
}
|
||||
};
|
||||
|
||||
var dash_forum_thread_create = function() {
|
||||
var data = {
|
||||
'data':{
|
||||
'forum_id': this.options.data.items[0],
|
||||
'category_id': this.options.data.category_id
|
||||
},
|
||||
'reload': this.className,
|
||||
'onClose':function(){
|
||||
desk_window_reload_all(this.options.reload);
|
||||
}
|
||||
};
|
||||
desk_call(dash_forum_thread_wnd, null, data);
|
||||
};
|
||||
|
||||
var dash_forum_thread_edit = function() {
|
||||
var selected = this.getSelectedContentItems();
|
||||
if (selected && selected.length==1) {
|
||||
var data = {
|
||||
'data':{
|
||||
'forum_id': this.options.data.items[0],
|
||||
'category_id': this.options.data.category_id,
|
||||
'items': [selected[0].data]
|
||||
},
|
||||
'reload': this.className,
|
||||
'onClose':function(){
|
||||
desk_window_reload_all(this.options.reload);
|
||||
}
|
||||
};
|
||||
desk_call(dash_forum_thread_wnd, null, data);
|
||||
}
|
||||
};
|
||||
|
||||
var dash_forum_messages = function() {
|
||||
var selected = this.getSelectedContentItems();
|
||||
if (selected && selected.length==1) {
|
||||
var data = {
|
||||
'data':{
|
||||
'items': [selected[0].data]
|
||||
},
|
||||
'reload': this.className,
|
||||
'onClose':function(){
|
||||
desk_window_reload_all(this.options.reload);
|
||||
}
|
||||
};
|
||||
desk_call(dash_forum_messages_wnd, null, data);
|
||||
}
|
||||
};
|
||||
|
||||
var dash_forum_message_create = function() {
|
||||
var data = {
|
||||
'data':{
|
||||
'topic_id': this.options.data.items[0]
|
||||
},
|
||||
'reload': this.className,
|
||||
'onClose':function(){
|
||||
desk_window_reload_all(this.options.reload);
|
||||
}
|
||||
};
|
||||
desk_call(dash_forum_message_wnd, null, data);
|
||||
};
|
||||
|
||||
var dash_forum_message_edit = function() {
|
||||
var selected = this.getSelectedContentItems();
|
||||
if (selected && selected.length==1) {
|
||||
var data = {
|
||||
'data':{
|
||||
'topic_id': this.options.data.items[0],
|
||||
'items': [selected[0].data]
|
||||
},
|
||||
'reload': this.className,
|
||||
'onClose':function(){
|
||||
desk_window_reload_all(this.options.reload);
|
||||
}
|
||||
};
|
||||
desk_call(dash_forum_message_wnd, null, data);
|
||||
}
|
||||
};
|
79
assets/js/forum/forum.js
Normal file
79
assets/js/forum/forum.js
Normal file
|
@ -0,0 +1,79 @@
|
|||
(function($){
|
||||
$(document).ready(function(){
|
||||
zira_init_forum_rating();
|
||||
zira_init_forum_reply();
|
||||
});
|
||||
|
||||
zira_forum_form_submit_success = function(response) {
|
||||
var form = $('.container #content form#form-forum-message-form');
|
||||
if ($(form).length==0) return;
|
||||
$(form).get(0).reset();
|
||||
|
||||
if (typeof(response)!="undefined" &&
|
||||
typeof(response.redirect)!="undefined" &&
|
||||
response.redirect.indexOf('http')<0
|
||||
) {
|
||||
window.location.href=response.redirect;
|
||||
}
|
||||
};
|
||||
|
||||
zira_init_forum_rating = function() {
|
||||
$('.container #content .forum-list a.forum-rating').unbind('click').click(function(e){
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
if ($(this).hasClass('active')) return;
|
||||
zira_poll.call(this, function(response){
|
||||
if (typeof(response.rating)=="undefined") return;
|
||||
$(this).addClass('active');
|
||||
var rating = response.rating;
|
||||
if (rating>0) rating = '<span class="positive-rating">+'+rating+'</span>';
|
||||
else if (rating<0) rating = '<span class="negative-rating">'+rating+'</span>';
|
||||
$(this).parent().children('.forum-rating-value').html(rating);
|
||||
}, function(){
|
||||
zira_error(t('An error occurred'));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
zira_init_forum_reply = function() {
|
||||
$('.container #content .forum-list a.forum-reply-inline').unbind('click').click(function (e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
var user = $(this).parent('.list-title-wrapper').children('a[rel=author]').text();
|
||||
var content = $(this).parents('.list-item').find('.forum-message').html();
|
||||
|
||||
var form = $('.container #content form#form-forum-message-form');
|
||||
var textarea = $(form).find('#message');
|
||||
var editable = $(form).find('#message-editable');
|
||||
|
||||
if ($(editable).length>0) {
|
||||
$(editable).html('<q><b>@'+user+':</b><br />'+content+'</q>'+'<span>‌</span>');
|
||||
focusEditable($(editable).get(0));
|
||||
} else {
|
||||
$(textarea).val('[quote][b]@'+user+':[/b]'+"\r\n"+content.replace(/<([a-z]+).*?>[\s\S]*?<[\/]\1>/gi, '').replace(/<[a-z\/].*?>/gi, '')+'[/quote]'+"\r\n");
|
||||
$(textarea).get(0).focus();
|
||||
}
|
||||
|
||||
var top = $(form).parents('.form-panel').offset().top;
|
||||
$('html, body').animate({'scrollTop': top}, 500);
|
||||
});
|
||||
};
|
||||
|
||||
function focusEditable(el) {
|
||||
el.focus();
|
||||
if (typeof window.getSelection != "undefined" && typeof document.createRange != "undefined") {
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(el);
|
||||
range.collapse(false);
|
||||
var sel = window.getSelection();
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(range);
|
||||
} else if (typeof document.body.createTextRange != "undefined") {
|
||||
var textRange = document.body.createTextRange();
|
||||
textRange.moveToElementText(el);
|
||||
textRange.collapse(false);
|
||||
textRange.select();
|
||||
}
|
||||
}
|
||||
})(jQuery);
|
|
@ -72,11 +72,11 @@
|
|||
}
|
||||
|
||||
if (response.error) {
|
||||
$(this).trigger('xhr-submit-error');
|
||||
$(this).trigger('xhr-submit-error', response);
|
||||
} else {
|
||||
$(this).trigger('xhr-submit-success');
|
||||
$(this).trigger('xhr-submit-success', response);
|
||||
}
|
||||
$(this).trigger('xhr-submit-end');
|
||||
$(this).trigger('xhr-submit-end', response);
|
||||
}
|
||||
|
||||
function xhrSendError(text,status) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[meta]
|
||||
name = Email forms
|
||||
description = Add email forms to your website
|
||||
description = Accept email messages from your website
|
||||
author = Zira
|
||||
version = 1.0
|
|
@ -11,7 +11,7 @@ use Dash;
|
|||
use Zira;
|
||||
use Zira\Permission;
|
||||
|
||||
class Eformfields extends Dash\WIndows\Window {
|
||||
class Eformfields extends Dash\Windows\Window {
|
||||
protected static $_icon_class = 'glyphicon glyphicon-list';
|
||||
protected static $_title = 'Form fields';
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ use Zira;
|
|||
use Eform;
|
||||
use Zira\Permission;
|
||||
|
||||
class Eforms extends Dash\WIndows\Window {
|
||||
class Eforms extends Dash\Windows\Window {
|
||||
protected static $_icon_class = 'glyphicon glyphicon-send';
|
||||
protected static $_title = 'Email forms';
|
||||
|
||||
|
@ -41,7 +41,7 @@ class Eforms extends Dash\WIndows\Window {
|
|||
$this->createMenuDropdownSeparator()
|
||||
);
|
||||
$this->addDefaultMenuDropdownItem(
|
||||
$this->createMenuDropdownItem(Zira\Locale::t('Open page'), 'glyphicon glyphicon-new-window', 'desk_call(dash_eform_page, this);', 'edit', true, array('typo'=>'page'))
|
||||
$this->createMenuDropdownItem(Zira\Locale::tm('Open page', 'eform'), 'glyphicon glyphicon-new-window', 'desk_call(dash_eform_page, this);', 'edit', true, array('typo'=>'page'))
|
||||
);
|
||||
|
||||
$this->addDefaultContextMenuItem(
|
||||
|
@ -54,7 +54,7 @@ class Eforms extends Dash\WIndows\Window {
|
|||
$this->createContextMenuSeparator()
|
||||
);
|
||||
$this->addDefaultContextMenuItem(
|
||||
$this->createContextMenuItem(Zira\Locale::t('Open page'), 'glyphicon glyphicon-new-window', 'desk_call(dash_eform_page, this);', 'edit', true, array('typo'=>'page'))
|
||||
$this->createContextMenuItem(Zira\Locale::tm('Open page', 'eform'), 'glyphicon glyphicon-new-window', 'desk_call(dash_eform_page, this);', 'edit', true, array('typo'=>'page'))
|
||||
);
|
||||
|
||||
$this->setSidebarContent('<div class="eform-infobar" style="white-space:nowrap;text-overflow: ellipsis;width:100%;overflow:hidden"></div>');
|
||||
|
|
46
forum/controllers/dash.php
Normal file
46
forum/controllers/dash.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* dash.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Controllers;
|
||||
|
||||
use Zira;
|
||||
use Forum;
|
||||
|
||||
class Dash extends \Dash\Controller {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
Zira\View::setAjax(true);
|
||||
}
|
||||
|
||||
protected function getCategoriesWindowModel() {
|
||||
$window = new Forum\Windows\Categories();
|
||||
return new Forum\Models\Categories($window);
|
||||
}
|
||||
|
||||
protected function getForumsWindowModel() {
|
||||
$window = new Forum\Windows\Forums();
|
||||
return new Forum\Models\Forums($window);
|
||||
}
|
||||
|
||||
public function dragcategory() {
|
||||
if (Zira\Request::isPost()) {
|
||||
$categories = Zira\Request::post('categories');
|
||||
$orders = Zira\Request::post('orders');
|
||||
$response = $this->getCategoriesWindowModel()->drag($categories, $orders);
|
||||
Zira\Page::render($response);
|
||||
}
|
||||
}
|
||||
|
||||
public function dragforum() {
|
||||
if (Zira\Request::isPost()) {
|
||||
$forums = Zira\Request::post('forums');
|
||||
$orders = Zira\Request::post('orders');
|
||||
$response = $this->getForumsWindowModel()->drag($forums, $orders);
|
||||
Zira\Page::render($response);
|
||||
}
|
||||
}
|
||||
}
|
476
forum/controllers/index.php
Normal file
476
forum/controllers/index.php
Normal file
|
@ -0,0 +1,476 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* index.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Controllers;
|
||||
|
||||
use Zira;
|
||||
use Forum;
|
||||
|
||||
class Index extends Zira\Controller {
|
||||
public function index() {
|
||||
$categories = Forum\Models\Category::getCollection()
|
||||
->order_by('sort_order', 'asc')
|
||||
->get();
|
||||
|
||||
foreach($categories as $category) {
|
||||
$category->forums = Forum\Models\Forum::getCollection()
|
||||
->select(Forum\Models\Forum::getFields())
|
||||
->left_join(Zira\Models\User::getClass(), array('user_firstname' => 'firstname', 'user_secondname' => 'secondname', 'user_username' => 'username'))
|
||||
->where('category_id', '=', $category->id)
|
||||
->and_where('active', '=', 1)
|
||||
->order_by('sort_order', 'asc')
|
||||
->get();
|
||||
}
|
||||
|
||||
$title = Zira\Config::get('forum_title') ? Zira\Locale::t(Zira\Config::get('forum_title')) : Zira\Locale::tm('Forum','forum');
|
||||
$meta_title = Zira\Config::get('forum_meta_title') ? Zira\Locale::t(Zira\Config::get('forum_meta_title')) : $title;
|
||||
$description = Zira\Config::get('forum_description') ? Zira\Locale::t(Zira\Config::get('forum_description')) : '';
|
||||
$meta_description = Zira\Config::get('forum_meta_description') ? Zira\Locale::t(Zira\Config::get('forum_meta_description')) : $description;
|
||||
$keywords = Zira\Config::get('forum_meta_keywords') ? Zira\Locale::t(Zira\Config::get('forum_meta_keywords')) : '';
|
||||
|
||||
Zira\Page::addTitle($meta_title);
|
||||
Zira\Page::setKeywords($keywords);
|
||||
Zira\Page::setDescription($meta_description);
|
||||
|
||||
Zira\Page::addBreadcrumb(Forum\Forum::ROUTE, Zira\Locale::tm('Forum', 'forum'));
|
||||
|
||||
if (Zira\Config::get('forum_layout')) {
|
||||
Zira\Page::setLayout(Zira\Config::get('forum_layout'));
|
||||
}
|
||||
Zira\Page::setView('forum/page');
|
||||
|
||||
Zira\View::addPlaceholderView(Zira\View::VAR_CONTENT, array('categories'=>$categories), 'forum/index');
|
||||
|
||||
Zira\Page::render(array(
|
||||
Zira\Page::VIEW_PLACEHOLDER_TITLE => $title,
|
||||
Zira\Page::VIEW_PLACEHOLDER_DESCRIPTION => $description,
|
||||
Zira\Page::VIEW_PLACEHOLDER_CONTENT => ''
|
||||
));
|
||||
}
|
||||
|
||||
public function group($category_id) {
|
||||
if (empty($category_id)) Zira\Response::notFound();
|
||||
|
||||
$category = Forum\Models\Category::getCollection()
|
||||
->where('id','=',$category_id)
|
||||
->get(0);
|
||||
|
||||
if (!$category) Zira\Response::notFound();
|
||||
|
||||
// checking permission
|
||||
if ($category->access_check && !Zira\Permission::check(Zira\Permission::TO_VIEW_RECORDS)) {
|
||||
if (!Zira\User::isAuthorized()) {
|
||||
Zira\Response::redirect('user/login?redirect='.Forum\Models\Category::generateUrl($category), true);
|
||||
} else {
|
||||
Zira\Response::forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
$rows = Forum\Models\Forum::getCollection()
|
||||
->select(Forum\Models\Forum::getFields())
|
||||
->left_join(Zira\Models\User::getClass(), array('user_firstname'=>'firstname', 'user_secondname'=>'secondname', 'user_username'=>'username'))
|
||||
->where('category_id','=',$category->id)
|
||||
->and_where('active','=',1)
|
||||
->order_by('sort_order','asc')
|
||||
->get();
|
||||
|
||||
$title = Zira\Locale::t($category->title);
|
||||
$meta_title = $category->meta_title ? Zira\Locale::t($category->meta_title) : $title;
|
||||
$description = $category->description ? Zira\Locale::t($category->description) : '';
|
||||
$meta_description = $category->meta_description ? Zira\Locale::t($category->meta_description) : $description;
|
||||
$keywords = $category->meta_keywords ? Zira\Locale::t($category->meta_keywords) : '';
|
||||
|
||||
Zira\Page::addTitle($meta_title);
|
||||
Zira\Page::setKeywords($keywords);
|
||||
Zira\Page::setDescription($meta_description);
|
||||
|
||||
Zira\Page::addBreadcrumb(Forum\Forum::ROUTE, Zira\Locale::tm('Forum', 'forum'));
|
||||
Zira\Page::addBreadcrumb(Forum\Models\Category::generateUrl($category), Zira\Locale::t($category->title));
|
||||
|
||||
if ($category->layout) {
|
||||
Zira\Page::setLayout($category->layout);
|
||||
} else if (Zira\Config::get('forum_layout')) {
|
||||
Zira\Page::setLayout(Zira\Config::get('forum_layout'));
|
||||
}
|
||||
Zira\Page::setView('forum/page');
|
||||
|
||||
Zira\View::addPlaceholderView(Zira\View::VAR_CONTENT, array('items'=>$rows), 'forum/group');
|
||||
|
||||
Zira\Page::render(array(
|
||||
Zira\Page::VIEW_PLACEHOLDER_TITLE => $title,
|
||||
Zira\Page::VIEW_PLACEHOLDER_DESCRIPTION => $description,
|
||||
Zira\Page::VIEW_PLACEHOLDER_CONTENT => ''
|
||||
));
|
||||
}
|
||||
|
||||
public function threads($forum_id) {
|
||||
if (empty($forum_id)) Zira\Response::notFound();
|
||||
|
||||
$category_fields = Forum\Models\Category::getFields();
|
||||
$_category_fields = array();
|
||||
foreach($category_fields as $field) {
|
||||
$_category_fields['category_'.$field] = $field;
|
||||
}
|
||||
|
||||
$forum = Forum\Models\Forum::getCollection()
|
||||
->select(Forum\Models\Forum::getFields())
|
||||
->join(Forum\Models\Category::getClass(), $_category_fields)
|
||||
->where('id','=',$forum_id)
|
||||
->get(0);
|
||||
|
||||
if (!$forum || !$forum->active) Zira\Response::notFound();
|
||||
|
||||
// checking permission
|
||||
if (($forum->access_check || $forum->category_access_check) && !Zira\Permission::check(Zira\Permission::TO_VIEW_RECORDS)) {
|
||||
if (!Zira\User::isAuthorized()) {
|
||||
Zira\Response::redirect('user/login?redirect='.Forum\Models\Forum::generateUrl($forum), true);
|
||||
} else {
|
||||
Zira\Response::forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
$sticky = Forum\Models\Topic::getCollection()
|
||||
->select(Forum\Models\Topic::getFields())
|
||||
->left_join(Zira\Models\User::getClass(), array('user_firstname'=>'firstname', 'user_secondname'=>'secondname', 'user_username'=>'username'))
|
||||
->where('category_id','=',$forum->category_id)
|
||||
->and_where('forum_id','=',$forum->id)
|
||||
->and_where('sticky','=',1)
|
||||
->order_by('id','desc')
|
||||
->get();
|
||||
|
||||
$total = Forum\Models\Topic::getCollection()
|
||||
->count()
|
||||
->where('category_id','=',$forum->category_id)
|
||||
->and_where('forum_id','=',$forum->id)
|
||||
->and_where('sticky','=',0)
|
||||
->get('co');
|
||||
|
||||
$limit = Zira\Config::get('forum_limit') ? intval(Zira\Config::get('forum_limit')) : 10;
|
||||
$page = (int)Zira\Request::get('page');
|
||||
$pages = ceil($total / $limit);
|
||||
if ($page>$pages) $page = $pages;
|
||||
if ($page<1) $page = 1;
|
||||
|
||||
$topics = Forum\Models\Topic::getCollection()
|
||||
->select(Forum\Models\Topic::getFields())
|
||||
->left_join(Zira\Models\User::getClass(), array('user_firstname'=>'firstname', 'user_secondname'=>'secondname', 'user_username'=>'username'))
|
||||
->where('category_id','=',$forum->category_id)
|
||||
->and_where('forum_id','=',$forum->id)
|
||||
->and_where('sticky','=',0)
|
||||
->order_by('id','desc')
|
||||
->limit($limit, ($page-1)*$limit)
|
||||
->get();
|
||||
|
||||
$title = Zira\Locale::t($forum->title);
|
||||
$meta_title = $forum->meta_title ? Zira\Locale::t($forum->meta_title) : $title;
|
||||
$description = $forum->description ? Zira\Locale::t($forum->description) : '';
|
||||
$meta_description = $forum->meta_description ? Zira\Locale::t($forum->meta_description) : $description;
|
||||
$keywords = $forum->meta_keywords ? Zira\Locale::t($forum->meta_keywords) : '';
|
||||
|
||||
Zira\Page::addTitle($meta_title);
|
||||
Zira\Page::setKeywords($keywords);
|
||||
Zira\Page::setDescription($meta_description);
|
||||
|
||||
Zira\Page::addBreadcrumb(Forum\Forum::ROUTE, Zira\Locale::tm('Forum', 'forum'));
|
||||
Zira\Page::addBreadcrumb(Forum\Models\Category::generateUrl($forum->category_id), Zira\Locale::t($forum->category_title));
|
||||
|
||||
if ($forum->category_layout) {
|
||||
Zira\Page::setLayout($forum->category_layout);
|
||||
} else if (Zira\Config::get('forum_layout')) {
|
||||
Zira\Page::setLayout(Zira\Config::get('forum_layout'));
|
||||
}
|
||||
Zira\Page::setView('forum/page');
|
||||
|
||||
$pagination = new Zira\Pagination();
|
||||
$pagination->setLimit($limit);
|
||||
$pagination->setTotal($total);
|
||||
$pagination->setPages($pages);
|
||||
$pagination->setPage($page);
|
||||
|
||||
Zira\View::addPlaceholderView(Zira\View::VAR_CONTENT, array(
|
||||
'top_items'=>$sticky,
|
||||
'items'=>$topics,
|
||||
'pagination' => $pagination,
|
||||
'compose_url' => Forum\Forum::ROUTE.'/compose/'.$forum->id,
|
||||
'category_title' => $forum->category_title,
|
||||
'category_url' => Forum\Models\Category::generateUrl($forum->category_id),
|
||||
'info' => $forum->info
|
||||
), 'forum/threads');
|
||||
|
||||
Zira\Page::render(array(
|
||||
Zira\Page::VIEW_PLACEHOLDER_TITLE => $title,
|
||||
Zira\Page::VIEW_PLACEHOLDER_DESCRIPTION => $description,
|
||||
Zira\Page::VIEW_PLACEHOLDER_CONTENT => ''
|
||||
));
|
||||
}
|
||||
|
||||
public function thread($topic_id) {
|
||||
if (empty($topic_id)) Zira\Response::notFound();
|
||||
|
||||
$category_fields = Forum\Models\Category::getFields();
|
||||
$_category_fields = array();
|
||||
foreach($category_fields as $field) {
|
||||
$_category_fields['category_'.$field] = $field;
|
||||
}
|
||||
|
||||
$forum_fields = Forum\Models\Forum::getFields();
|
||||
$_forum_fields = array();
|
||||
foreach($forum_fields as $field) {
|
||||
$_forum_fields['forum_'.$field] = $field;
|
||||
}
|
||||
|
||||
$topic = Forum\Models\Topic::getCollection()
|
||||
->select(Forum\Models\Topic::getFields())
|
||||
->join(Forum\Models\Category::getClass(), $_category_fields)
|
||||
->join(Forum\Models\Forum::getClass(), $_forum_fields)
|
||||
->where('id','=',$topic_id)
|
||||
->get(0);
|
||||
|
||||
if (!$topic || !$topic->forum_active) Zira\Response::notFound();
|
||||
|
||||
// checking permission
|
||||
if (($topic->forum_access_check || $topic->category_access_check) && !Zira\Permission::check(Zira\Permission::TO_VIEW_RECORDS)) {
|
||||
if (!Zira\User::isAuthorized()) {
|
||||
Zira\Response::redirect('user/login?redirect='.Forum\Models\Topic::generateUrl($topic), true);
|
||||
} else {
|
||||
Zira\Response::forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
$total = null;
|
||||
$limit = Zira\Config::get('forum_limit') ? intval(Zira\Config::get('forum_limit')) : 10;
|
||||
$page = (int)Zira\Request::get('page');
|
||||
|
||||
$form = new Forum\Forms\Reply();
|
||||
if ($topic->active && Zira\Request::isPost() && $form->isValid()) {
|
||||
if (!($message=Forum\Models\Message::createNewMessage($topic->forum_id, $topic->id, $form->getValue('message'), ++$topic->messages, $topic->forum_topics))) {
|
||||
$form->setError(Zira\Locale::t('An error occurred'));
|
||||
} else {
|
||||
// redirect to last page
|
||||
$total = Forum\Models\Message::getCollection()
|
||||
->count()
|
||||
->where('topic_id','=',$topic->id)
|
||||
->get('co');
|
||||
|
||||
$pages = ceil($total / $limit);
|
||||
if ($page>$pages) $page = $pages;
|
||||
if ($page<1) $page = 1;
|
||||
|
||||
if (!Zira\View::isAjax() && $page<$pages) {
|
||||
Zira\Response::redirect(Forum\Models\Topic::generateUrl($topic) . '?page='.$pages);
|
||||
return;
|
||||
} else if (Zira\View::isAjax()) {
|
||||
$hash = '#forum-message-'.$message->id;
|
||||
if ($pages>1) {
|
||||
$url = Forum\Models\Topic::generateUrl($topic) . '?page='.$pages.'&t='.time().$hash;
|
||||
} else {
|
||||
$url = Forum\Models\Topic::generateUrl($topic).'?t='.time().$hash;
|
||||
}
|
||||
Zira\Page::render(array('redirect'=>Zira\Helper::url($url)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Zira\Request::isPost() && Zira\View::isAjax() && $form->getError()) {
|
||||
Zira\Page::render(array('error'=>$form->getError()));
|
||||
return;
|
||||
}
|
||||
|
||||
if ($total===null) {
|
||||
$total = Forum\Models\Message::getCollection()
|
||||
->count()
|
||||
->where('topic_id', '=', $topic->id)
|
||||
->get('co');
|
||||
|
||||
$pages = ceil($total / $limit);
|
||||
if ($page>$pages) $page = $pages;
|
||||
if ($page<1) $page = 1;
|
||||
}
|
||||
|
||||
$rows = Forum\Models\Message::getCollection()
|
||||
->select(Forum\Models\Message::getFields())
|
||||
->left_join(Zira\Models\User::getClass(), array('user_group_id'=>'group_id', 'user_firstname'=>'firstname', 'user_secondname'=>'secondname', 'user_username'=>'username', 'user_image'=>'image', 'user_posts'=>'posts'))
|
||||
->where('topic_id','=',$topic->id)
|
||||
->order_by('id','asc')
|
||||
->limit($limit, ($page-1)*$limit)
|
||||
->get();
|
||||
|
||||
$status = $topic->status ? Forum\Models\Topic::getStatus($topic->status) : '';
|
||||
$_status = !empty($status) ? '['.$status.'] ' : '';
|
||||
|
||||
$title = Zira\Locale::t($topic->title);
|
||||
$meta_title = $topic->meta_title ? Zira\Locale::t($topic->meta_title) : $title;
|
||||
$description = $topic->description ? Zira\Locale::t($topic->description) : '';
|
||||
$meta_description = $topic->meta_description ? Zira\Locale::t($topic->meta_description) : $description;
|
||||
$keywords = $topic->meta_keywords ? Zira\Locale::t($topic->meta_keywords) : '';
|
||||
|
||||
Zira\Page::addTitle($_status.$meta_title);
|
||||
Zira\Page::setKeywords($keywords);
|
||||
Zira\Page::setDescription($meta_description);
|
||||
|
||||
Zira\Page::addBreadcrumb(Forum\Forum::ROUTE, Zira\Locale::tm('Forum', 'forum'));
|
||||
Zira\Page::addBreadcrumb(Forum\Models\Category::generateUrl($topic->category_id), Zira\Locale::t($topic->category_title));
|
||||
|
||||
if ($topic->category_layout) {
|
||||
Zira\Page::setLayout($topic->category_layout);
|
||||
} else if (Zira\Config::get('forum_layout')) {
|
||||
Zira\Page::setLayout(Zira\Config::get('forum_layout'));
|
||||
}
|
||||
Zira\Page::setView('forum/page');
|
||||
|
||||
$pagination = new Zira\Pagination();
|
||||
$pagination->setLimit($limit);
|
||||
$pagination->setTotal($total);
|
||||
$pagination->setPages($pages);
|
||||
$pagination->setPage($page);
|
||||
|
||||
Zira\View::addPlaceholderView(Zira\View::VAR_CONTENT, array(
|
||||
'items'=>$rows,
|
||||
'pagination' => $pagination,
|
||||
'forum_title' => $topic->forum_title,
|
||||
'forum_url' => Forum\Models\Forum::generateUrl($topic->forum_id),
|
||||
'info' => $topic->info,
|
||||
'user_groups' => Zira\Models\Group::getArray(true),
|
||||
'form' => Zira\User::isAuthorized() ? $form : null,
|
||||
'topic_active' => $topic->active,
|
||||
'topic_url' => Forum\Models\Topic::generateUrl($topic),
|
||||
'topic_page' => $page
|
||||
), 'forum/thread');
|
||||
|
||||
Zira\Page::render(array(
|
||||
Forum\Forum::VIEW_PLACEHOLDER_LABEL => $status,
|
||||
Zira\Page::VIEW_PLACEHOLDER_TITLE => $title,
|
||||
Zira\Page::VIEW_PLACEHOLDER_DESCRIPTION => $description,
|
||||
Zira\Page::VIEW_PLACEHOLDER_CONTENT => ''
|
||||
));
|
||||
}
|
||||
|
||||
public function compose($forum_id) {
|
||||
if (empty($forum_id)) Zira\Response::notFound();
|
||||
|
||||
if (!Zira\User::isAuthorized()) {
|
||||
Zira\Response::redirect('user/login?redirect='.Forum\Forum::ROUTE.'/compose/'.intval($forum_id), true);
|
||||
}
|
||||
|
||||
$category_fields = Forum\Models\Category::getFields();
|
||||
$_category_fields = array();
|
||||
foreach($category_fields as $field) {
|
||||
$_category_fields['category_'.$field] = $field;
|
||||
}
|
||||
|
||||
$forum = Forum\Models\Forum::getCollection()
|
||||
->select(Forum\Models\Forum::getFields())
|
||||
->join(Forum\Models\Category::getClass(), $_category_fields)
|
||||
->where('id','=',$forum_id)
|
||||
->get(0);
|
||||
|
||||
if (!$forum || !$forum->active) Zira\Response::notFound();
|
||||
|
||||
// checking permission
|
||||
if (($forum->access_check || $forum->category_access_check) && !Zira\Permission::check(Zira\Permission::TO_VIEW_RECORDS)) {
|
||||
if (!Zira\User::isAuthorized()) {
|
||||
Zira\Response::redirect('user/login?redirect='.Forum\Forum::ROUTE.'/compose/'.$forum->id, true);
|
||||
} else {
|
||||
Zira\Response::forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
$form = new Forum\Forms\Compose();
|
||||
if (Zira\Request::isPost() && $form->isValid()) {
|
||||
if (!($topic=Forum\Models\Topic::createNewTopic($forum->category_id, $forum->id, $form->getValue('title'), $form->getValue('message'), ++$forum->topics))) {
|
||||
$form->setError(Zira\Locale::t('An error occurred'));
|
||||
} else {
|
||||
if (!Zira\View::isAjax()) {
|
||||
Zira\Response::redirect(Forum\Models\Topic::generateUrl($topic));
|
||||
} else {
|
||||
Zira\Page::render(array('redirect'=>Zira\Helper::url(Forum\Models\Topic::generateUrl($topic))));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$title = Zira\Locale::tm('New thread', 'forum');
|
||||
$meta_title = $title .' - '.Zira\Locale::t($forum->title);
|
||||
|
||||
Zira\Page::addTitle($meta_title);
|
||||
|
||||
Zira\Page::addBreadcrumb(Forum\Forum::ROUTE, Zira\Locale::tm('Forum', 'forum'));
|
||||
Zira\Page::addBreadcrumb(Forum\Models\Category::generateUrl($forum->category_id), Zira\Locale::t($forum->category_title));
|
||||
|
||||
if ($forum->category_layout) {
|
||||
Zira\Page::setLayout($forum->category_layout);
|
||||
} else if (Zira\Config::get('forum_layout')) {
|
||||
Zira\Page::setLayout(Zira\Config::get('forum_layout'));
|
||||
}
|
||||
|
||||
Zira\Page::setView('forum/page');
|
||||
|
||||
Zira\Page::render(array(
|
||||
Zira\Page::VIEW_PLACEHOLDER_TITLE => $title,
|
||||
Zira\Page::VIEW_PLACEHOLDER_DESCRIPTION => Zira\Locale::t($forum->title),
|
||||
Zira\Page::VIEW_PLACEHOLDER_CONTENT => $form
|
||||
));
|
||||
}
|
||||
|
||||
public function poll() {
|
||||
Zira\View::setAjax(true);
|
||||
|
||||
if (!Zira\Request::isPost()) return;
|
||||
$value = Zira\Request::post('value');
|
||||
$id = Zira\Request::post('id');
|
||||
$type = Zira\Request::post('type');
|
||||
$token = Zira\Request::post('token');
|
||||
|
||||
if (!isset($value) || empty($id) || empty($type) || empty($token)) return;
|
||||
if (!Zira\User::checkToken($token)) return;
|
||||
|
||||
$user_id = Zira\User::isAuthorized() ? Zira\User::getCurrent()->id : 0;
|
||||
$anonymous_id = Zira\User::getAnonymousUserId();
|
||||
if (empty($user_id) && empty($anonymous_id)) return;
|
||||
|
||||
$message = new Forum\Models\Message($id);
|
||||
if (!$message->loaded()) return;
|
||||
|
||||
$query = Forum\Models\Forumlike::getCollection()
|
||||
->where('message_id','=',$message->id);
|
||||
|
||||
if (!empty($user_id)) {
|
||||
$query->and_where();
|
||||
$query->open_where();
|
||||
$query->where('user_id','=',$user_id);
|
||||
$query->or_where('anonymous_id','=',$anonymous_id);
|
||||
$query->close_where();
|
||||
} else if (!empty($anonymous_id)) {
|
||||
$query->and_where('anonymous_id','=',$anonymous_id);
|
||||
}
|
||||
|
||||
$exists = $query->get(0, true);
|
||||
|
||||
if (!$exists || $exists['rate'] != $value) {
|
||||
$like = new Forum\Models\Forumlike();
|
||||
if (!$exists) {
|
||||
$like->message_id = $message->id;
|
||||
$like->user_id = $user_id;
|
||||
$like->anonymous_id = $anonymous_id;
|
||||
$like->creation_date = date('Y-m-d H:i:s');
|
||||
} else {
|
||||
$like->loadFromArray($exists);
|
||||
if ($exists['rate']>0) $message->rating--;
|
||||
else $message->rating++;
|
||||
}
|
||||
$like->rate = $value;
|
||||
$like->save();
|
||||
|
||||
if ($value>0) $message->rating++;
|
||||
else $message->rating--;
|
||||
$message->save();
|
||||
}
|
||||
|
||||
Zira\Page::render(array('rating'=>$message->rating));
|
||||
}
|
||||
}
|
79
forum/forms/category.php
Normal file
79
forum/forms/category.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* category.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Forms;
|
||||
|
||||
use Zira;
|
||||
use Zira\Form;
|
||||
use Zira\Locale;
|
||||
|
||||
class Category extends Form
|
||||
{
|
||||
protected $_id = 'dash-forum-category-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';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->_id);
|
||||
}
|
||||
|
||||
protected function _init()
|
||||
{
|
||||
$this->setRenderPanel(false);
|
||||
$this->setFormClass('form-horizontal dash-window-form');
|
||||
}
|
||||
|
||||
protected function _render()
|
||||
{
|
||||
$html = $this->open();
|
||||
$html .= $this->hidden('id');
|
||||
$html .= $this->input(Locale::t('Title').'*', 'title');
|
||||
$html .= $this->selectDropdown(Locale::t('Layout'),'layout',array_merge(array(Locale::t('Default layout')),Zira\View::getLayouts()));
|
||||
$html .= $this->textarea(Locale::t('Description'), 'description');
|
||||
$html .= $this->input(Locale::t('Window title'), 'meta_title');
|
||||
$html .= $this->input(Locale::t('Keywords'), 'meta_keywords');
|
||||
$html .= $this->input(Locale::tm('Meta description', 'forum'), 'meta_description');
|
||||
$html .= $this->checkbox(Locale::t('Restrict access'), 'access_check', null, false);
|
||||
$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('meta_title', null, 255, false, Locale::t('Invalid value "%s"',Locale::t('Window title')));
|
||||
$validator->registerNoTags('meta_title', Locale::t('Invalid value "%s"',Locale::t('Window title')));
|
||||
$validator->registerUtf8('meta_title', Locale::t('Invalid value "%s"',Locale::t('Window title')));
|
||||
|
||||
$validator->registerString('meta_keywords', null, 255, false, Locale::t('Invalid value "%s"',Locale::t('Keywords')));
|
||||
$validator->registerNoTags('meta_keywords', Locale::t('Invalid value "%s"',Locale::t('Keywords')));
|
||||
$validator->registerUtf8('meta_keywords', Locale::t('Invalid value "%s"',Locale::t('Keywords')));
|
||||
|
||||
$validator->registerString('meta_description', null, 255, false, Locale::t('Invalid value "%s"',Locale::tm('Meta description', 'forum')));
|
||||
$validator->registerNoTags('meta_description', Locale::t('Invalid value "%s"',Locale::tm('Meta description', 'forum')));
|
||||
$validator->registerUtf8('meta_description', Locale::t('Invalid value "%s"',Locale::tm('Meta description', 'forum')));
|
||||
|
||||
$validator->registerCustom(array(get_class(), 'checkLayout'), 'layout', Locale::t('Invalid value "%s"',Locale::t('Layout')));
|
||||
}
|
||||
|
||||
public static function checkLayout($layout) {
|
||||
if (empty($layout)) return true;
|
||||
$layouts = Zira\View::getLayouts();
|
||||
return array_key_exists($layout, $layouts);
|
||||
}
|
||||
}
|
72
forum/forms/compose.php
Normal file
72
forum/forms/compose.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* compose.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Forms;
|
||||
|
||||
use Zira\Config;
|
||||
use Zira\Form;
|
||||
use Zira\Helper;
|
||||
use Zira\Locale;
|
||||
use Zira\View;
|
||||
|
||||
class Compose extends Form {
|
||||
protected $_id = 'forum-message-form';
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct($this->_id);
|
||||
}
|
||||
|
||||
protected function _init() {
|
||||
$this->setAjax(true);
|
||||
$this->setTitle(Locale::tm('New thread', 'forum'));
|
||||
$this->setDescription(Locale::t('Message should contain at least %s characters', Config::get('forum_min_chars', 10)));
|
||||
$script = Helper::tag_open('script', array('type'=>'text/javascript'));
|
||||
$script .= 'jQuery(document).ready(function(){';
|
||||
$script .= 'jQuery(\'#'.$this->getId().'\').bind(\'xhr-submit-success\', function(e, response){ ';
|
||||
$script .= 'zira_forum_form_submit_success(response);';
|
||||
$script .= '});';
|
||||
$script .= '});';
|
||||
$script .= Helper::tag_close('script');
|
||||
View::addHTML($script, View::VAR_BODY_BOTTOM);
|
||||
}
|
||||
|
||||
protected function _render() {
|
||||
$html = $this->open();
|
||||
$html .= $this->input(Locale::tm('Title', 'forum').'*', 'title');
|
||||
$extra_items = \Zira\Hook::run(\Zira\Page::USER_TEXTAREA_HOOK);
|
||||
if (!empty($extra_items)) {
|
||||
$html .= Helper::tag_open('div',array('class'=>'user-text-form-extra-items'));
|
||||
foreach($extra_items as $item) {
|
||||
$html .= Helper::tag_open('div',array('class'=>'user-text-form-extra-item'));
|
||||
$html .= $item;
|
||||
$html .= Helper::tag_close('div');
|
||||
}
|
||||
$html .= Helper::tag_close('div');
|
||||
}
|
||||
|
||||
$html .= $this->textarea(Locale::t('Message').'*','message', array('class'=>'form-control user-rich-input', 'rows'=>6));
|
||||
$html .= $this->captcha(Locale::t('Enter result').'*');
|
||||
$html .= $this->submit(Locale::t('Submit'));
|
||||
$html .= $this->close();
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function _validate() {
|
||||
$validator = $this->getValidator();
|
||||
$validator->registerCaptcha(Locale::t('Wrong CAPTCHA result'));
|
||||
$validator->registerString('title', 0, 255, true, Locale::tm('Invalid thread title', 'forum'));
|
||||
$validator->registerNoTags('title', Locale::tm('Invalid thread title', 'forum'));
|
||||
$validator->registerUtf8('title', Locale::tm('Invalid thread title', 'forum'));
|
||||
$validator->registerCustom(array(get_class(), 'checkMessageMinLength'), 'message', Locale::t('Message should contain at least %s characters', Config::get('forum_min_chars', 10)));
|
||||
$validator->registerNoTags('message', Locale::t('Message contains bad character'));
|
||||
//$validator->registerUtf8('message', Locale::t('Message contains bad character'));
|
||||
}
|
||||
|
||||
public static function checkMessageMinLength($message) {
|
||||
return (mb_strlen(html_entity_decode($message), CHARSET)>=Config::get('forum_min_chars', 10));
|
||||
}
|
||||
}
|
94
forum/forms/forum.php
Normal file
94
forum/forms/forum.php
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* forum.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Forms;
|
||||
|
||||
use Zira;
|
||||
use Zira\Form;
|
||||
use Zira\Locale;
|
||||
|
||||
class Forum extends Form
|
||||
{
|
||||
protected $_id = 'dash-forum-forum-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';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->_id);
|
||||
}
|
||||
|
||||
protected function _init()
|
||||
{
|
||||
$this->setRenderPanel(false);
|
||||
$this->setFormClass('form-horizontal dash-window-form');
|
||||
}
|
||||
|
||||
protected function _render()
|
||||
{
|
||||
$html = $this->open();
|
||||
$html .= $this->hidden('id');
|
||||
$html .= $this->input(Locale::t('Title').'*', 'title');
|
||||
$html .= $this->textarea(Locale::t('Description'), 'description');
|
||||
$html .= $this->input(Locale::t('Window title'), 'meta_title');
|
||||
$html .= $this->input(Locale::t('Keywords'), 'meta_keywords');
|
||||
$html .= $this->input(Locale::tm('Meta description', 'forum'), 'meta_description');
|
||||
$html .= $this->textarea(Locale::tm('Information message', 'forum'), 'info');
|
||||
$id = $this->getValue('id');
|
||||
if (empty($id)) {
|
||||
$html .= $this->hidden('category_id');
|
||||
} else {
|
||||
$categories_arr = array();
|
||||
$categories = \Forum\Models\Category::getCategpries();
|
||||
foreach($categories as $category) {
|
||||
$categories_arr[$category->id] = $category->title;
|
||||
}
|
||||
$html .= $this->select(Locale::tm('Forum category', 'forum'), 'category_id', $categories_arr);
|
||||
}
|
||||
$html .= $this->checkbox(Locale::t('Restrict access'), 'access_check', null, false);
|
||||
$html .= $this->checkbox(Locale::t('Forum activated', 'forum'), 'active', null, false);
|
||||
$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('meta_title', null, 255, false, Locale::t('Invalid value "%s"',Locale::t('Window title')));
|
||||
$validator->registerNoTags('meta_title', Locale::t('Invalid value "%s"',Locale::t('Window title')));
|
||||
$validator->registerUtf8('meta_title', Locale::t('Invalid value "%s"',Locale::t('Window title')));
|
||||
|
||||
$validator->registerString('meta_keywords', null, 255, false, Locale::t('Invalid value "%s"',Locale::t('Keywords')));
|
||||
$validator->registerNoTags('meta_keywords', Locale::t('Invalid value "%s"',Locale::t('Keywords')));
|
||||
$validator->registerUtf8('meta_keywords', Locale::t('Invalid value "%s"',Locale::t('Keywords')));
|
||||
|
||||
$validator->registerString('meta_description', null, 255, false, Locale::t('Invalid value "%s"',Locale::tm('Meta description', 'forum')));
|
||||
$validator->registerNoTags('meta_description', Locale::t('Invalid value "%s"',Locale::tm('Meta description', 'forum')));
|
||||
$validator->registerUtf8('meta_description', Locale::t('Invalid value "%s"',Locale::tm('Meta description', 'forum')));
|
||||
|
||||
$validator->registerNoTags('info', Locale::t('Invalid value "%s"',Locale::t('Information message')));
|
||||
$validator->registerUtf8('info', Locale::t('Invalid value "%s"',Locale::t('Information message')));
|
||||
|
||||
$validator->registerCustom(array(get_class(), 'checkCategory'), 'category_id', Locale::t('An error occurred'));
|
||||
}
|
||||
|
||||
public static function checkCategory($category_id) {
|
||||
$category = new \Forum\Models\Category($category_id);
|
||||
return $category->loaded();
|
||||
}
|
||||
}
|
62
forum/forms/message.php
Normal file
62
forum/forms/message.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* message.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Forms;
|
||||
|
||||
use Zira;
|
||||
use Zira\Form;
|
||||
use Zira\Locale;
|
||||
|
||||
class Message extends Form
|
||||
{
|
||||
protected $_id = 'dash-forum-message-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';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->_id);
|
||||
}
|
||||
|
||||
protected function _init()
|
||||
{
|
||||
$this->setRenderPanel(false);
|
||||
$this->setFormClass('form-horizontal dash-window-form');
|
||||
}
|
||||
|
||||
protected function _render()
|
||||
{
|
||||
$html = $this->open();
|
||||
$html .= $this->hidden('id');
|
||||
$html .= $this->hidden('topic_id');
|
||||
$html .= $this->textarea(Locale::t('Message').'*', 'content');
|
||||
$html .= $this->select(Locale::tm('Status','forum'), 'status', \Forum\Models\Message::getStatuses());
|
||||
$html .= $this->close();
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function _validate()
|
||||
{
|
||||
$validator = $this->getValidator();
|
||||
|
||||
$validator->registerNumber('topic_id', 1, null, true, Locale::t('An error occurred'));
|
||||
|
||||
$validator->registerText('content', null, true, Locale::t('Invalid value "%s"',Locale::t('Message')));
|
||||
$validator->registerNoTags('content', Locale::t('Invalid value "%s"',Locale::t('Message')));
|
||||
$validator->registerUtf8('content', Locale::t('Invalid value "%s"',Locale::t('Message')));
|
||||
|
||||
$validator->registerCustom(array(get_class(), 'checkStatus'), 'status', Locale::t('An error occurred'));
|
||||
}
|
||||
|
||||
public static function checkStatus($status) {
|
||||
$statuses = \Forum\Models\Message::getStatuses();
|
||||
return array_key_exists($status, $statuses);
|
||||
}
|
||||
}
|
68
forum/forms/reply.php
Normal file
68
forum/forms/reply.php
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* message.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Forms;
|
||||
|
||||
use Zira\Config;
|
||||
use Zira\Form;
|
||||
use Zira\Helper;
|
||||
use Zira\Locale;
|
||||
use Zira\View;
|
||||
|
||||
class Reply extends Form {
|
||||
protected $_id = 'forum-message-form';
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct($this->_id);
|
||||
}
|
||||
|
||||
protected function _init() {
|
||||
$this->setAjax(true);
|
||||
$this->setTitle(Locale::t('Reply'));
|
||||
$this->setDescription(Locale::t('Message should contain at least %s characters', Config::get('forum_min_chars', 10)));
|
||||
$script = Helper::tag_open('script', array('type'=>'text/javascript'));
|
||||
$script .= 'jQuery(document).ready(function(){';
|
||||
$script .= 'jQuery(\'#'.$this->getId().'\').bind(\'xhr-submit-success\', function(e, response){ ';
|
||||
$script .= 'zira_forum_form_submit_success(response);';
|
||||
$script .= '});';
|
||||
$script .= '});';
|
||||
$script .= Helper::tag_close('script');
|
||||
View::addHTML($script, View::VAR_BODY_BOTTOM);
|
||||
}
|
||||
|
||||
protected function _render() {
|
||||
$html = $this->open();
|
||||
$extra_items = \Zira\Hook::run(\Zira\Page::USER_TEXTAREA_HOOK);
|
||||
if (!empty($extra_items)) {
|
||||
$html .= Helper::tag_open('div',array('class'=>'user-text-form-extra-items'));
|
||||
foreach($extra_items as $item) {
|
||||
$html .= Helper::tag_open('div',array('class'=>'user-text-form-extra-item'));
|
||||
$html .= $item;
|
||||
$html .= Helper::tag_close('div');
|
||||
}
|
||||
$html .= Helper::tag_close('div');
|
||||
}
|
||||
|
||||
$html .= $this->textarea(Locale::t('Message').'*','message', array('class'=>'form-control user-rich-input', 'rows'=>6));
|
||||
$html .= $this->captcha(Locale::t('Enter result').'*');
|
||||
$html .= $this->submit(Locale::t('Submit'));
|
||||
$html .= $this->close();
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function _validate() {
|
||||
$validator = $this->getValidator();
|
||||
$validator->registerCaptcha(Locale::t('Wrong CAPTCHA result'));
|
||||
$validator->registerCustom(array(get_class(), 'checkMessageMinLength'), 'message', Locale::t('Message should contain at least %s characters', Config::get('forum_min_chars', 10)));
|
||||
$validator->registerNoTags('message', Locale::t('Message contains bad character'));
|
||||
//$validator->registerUtf8('message', Locale::t('Message contains bad character'));
|
||||
}
|
||||
|
||||
public static function checkMessageMinLength($message) {
|
||||
return (mb_strlen(html_entity_decode($message), CHARSET)>=Config::get('forum_min_chars', 10));
|
||||
}
|
||||
}
|
84
forum/forms/settings.php
Normal file
84
forum/forms/settings.php
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* settings.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Forms;
|
||||
|
||||
use Zira;
|
||||
use Zira\Form;
|
||||
use Zira\Locale;
|
||||
|
||||
class Settings extends Form
|
||||
{
|
||||
protected $_id = 'dash-forum-settings-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';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->_id);
|
||||
}
|
||||
|
||||
protected function _init()
|
||||
{
|
||||
$this->setRenderPanel(false);
|
||||
$this->setFormClass('form-horizontal dash-window-form');
|
||||
}
|
||||
|
||||
protected function _render()
|
||||
{
|
||||
$html = $this->open();
|
||||
$html .= $this->selectDropdown(Locale::t('Layout'),'forum_layout',array_merge(array(Locale::t('Default layout')),Zira\View::getLayouts()));
|
||||
$html .= $this->input(Locale::t('Title'), 'forum_title');
|
||||
$html .= $this->input(Locale::t('Description'), 'forum_description');
|
||||
$html .= $this->input(Locale::t('Window title'), 'forum_meta_title');
|
||||
$html .= $this->input(Locale::t('Keywords'), 'forum_meta_keywords');
|
||||
$html .= $this->input(Locale::tm('Meta description', 'forum'), 'forum_meta_description');
|
||||
$html .= $this->input(Locale::t('Records limit'), 'forum_limit');
|
||||
$html .= $this->input(Locale::tm('Message min. length', 'forum'), 'forum_min_chars');
|
||||
$html .= $this->close();
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function _validate()
|
||||
{
|
||||
$validator = $this->getValidator();
|
||||
|
||||
$validator->registerString('forum_title', null, 255, false, Locale::t('Invalid value "%s"',Locale::t('Title')));
|
||||
$validator->registerNoTags('forum_title', Locale::t('Invalid value "%s"',Locale::t('Title')));
|
||||
$validator->registerUtf8('forum_title', Locale::t('Invalid value "%s"',Locale::t('Title')));
|
||||
|
||||
$validator->registerString('forum_description', null, 255, false, Locale::t('Invalid value "%s"',Locale::t('Description')));
|
||||
$validator->registerNoTags('forum_description', Locale::t('Invalid value "%s"',Locale::t('Description')));
|
||||
$validator->registerUtf8('forum_description', Locale::t('Invalid value "%s"',Locale::t('Description')));
|
||||
|
||||
$validator->registerString('forum_meta_title', null, 255, false, Locale::t('Invalid value "%s"',Locale::t('Window title')));
|
||||
$validator->registerNoTags('forum_meta_title', Locale::t('Invalid value "%s"',Locale::t('Window title')));
|
||||
$validator->registerUtf8('forum_meta_title', Locale::t('Invalid value "%s"',Locale::t('Window title')));
|
||||
|
||||
$validator->registerString('forum_meta_keywords', null, 255, false, Locale::t('Invalid value "%s"',Locale::t('Keywords')));
|
||||
$validator->registerNoTags('forum_meta_keywords', Locale::t('Invalid value "%s"',Locale::t('Keywords')));
|
||||
$validator->registerUtf8('forum_meta_keywords', Locale::t('Invalid value "%s"',Locale::t('Keywords')));
|
||||
|
||||
$validator->registerString('forum_meta_description', null, 255, false, Locale::t('Invalid value "%s"',Locale::tm('Meta description', 'forum')));
|
||||
$validator->registerNoTags('forum_meta_description', Locale::t('Invalid value "%s"',Locale::tm('Meta description', 'forum')));
|
||||
$validator->registerUtf8('forum_meta_description', Locale::t('Invalid value "%s"',Locale::tm('Meta description', 'forum')));
|
||||
|
||||
$validator->registerNumber('forum_limit', 1, null, false, Locale::t('Invalid value "%s"',Locale::t('Records limit')));
|
||||
|
||||
$validator->registerNumber('forum_min_chars', 1, null, false, Locale::t('Invalid value "%s"',Locale::tm('Message min. length', 'forum')));
|
||||
|
||||
$validator->registerCustom(array(get_class(), 'checkLayout'), 'forum_layout', Locale::t('Invalid value "%s"',Locale::t('Layout')));
|
||||
}
|
||||
|
||||
public static function checkLayout($layout) {
|
||||
if (empty($layout)) return true;
|
||||
$layouts = Zira\View::getLayouts();
|
||||
return array_key_exists($layout, $layouts);
|
||||
}
|
||||
}
|
102
forum/forms/topic.php
Normal file
102
forum/forms/topic.php
Normal file
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* topic.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Forms;
|
||||
|
||||
use Zira;
|
||||
use Zira\Form;
|
||||
use Zira\Locale;
|
||||
|
||||
class Topic extends Form
|
||||
{
|
||||
protected $_id = 'dash-forum-topic-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';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->_id);
|
||||
}
|
||||
|
||||
protected function _init()
|
||||
{
|
||||
$this->setRenderPanel(false);
|
||||
$this->setFormClass('form-horizontal dash-window-form');
|
||||
}
|
||||
|
||||
protected function _render()
|
||||
{
|
||||
$html = $this->open();
|
||||
$html .= $this->hidden('id');
|
||||
$html .= $this->hidden('category_id');
|
||||
$html .= $this->input(Locale::t('Title').'*', 'title');
|
||||
$html .= $this->textarea(Locale::t('Description'), 'description');
|
||||
$html .= $this->input(Locale::t('Window title'), 'meta_title');
|
||||
$html .= $this->input(Locale::t('Keywords'), 'meta_keywords');
|
||||
$html .= $this->input(Locale::tm('Meta description', 'forum'), 'meta_description');
|
||||
$html .= $this->textarea(Locale::tm('Information message', 'forum'), 'info');
|
||||
$id = $this->getValue('id');
|
||||
$category_id = $this->getValue('category_id');
|
||||
if ($id && $category_id) {
|
||||
$html .= $this->select(Locale::tm('Forum', 'forum').'*', 'forum_id', \Forum\Models\Forum::getArray($category_id));
|
||||
} else {
|
||||
$html .= $this->hidden('forum_id');
|
||||
}
|
||||
$html .= $this->select(Locale::tm('Status','forum'), 'status', \Forum\Models\Topic::getStatuses());
|
||||
$html .= $this->checkbox(Locale::t('Thread is open', 'forum'), 'active', null, false);
|
||||
$html .= $this->checkbox(Locale::t('Thread is sticky', 'forum'), 'sticky', null, false);
|
||||
$html .= $this->close();
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function _validate()
|
||||
{
|
||||
$validator = $this->getValidator();
|
||||
|
||||
$validator->registerNumber('forum_id', 1, null, true, Locale::t('An error occurred'));
|
||||
$validator->registerNumber('category_id', 1, null, true, Locale::t('An error occurred'));
|
||||
|
||||
$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('meta_title', null, 255, false, Locale::t('Invalid value "%s"',Locale::t('Window title')));
|
||||
$validator->registerNoTags('meta_title', Locale::t('Invalid value "%s"',Locale::t('Window title')));
|
||||
$validator->registerUtf8('meta_title', Locale::t('Invalid value "%s"',Locale::t('Window title')));
|
||||
|
||||
$validator->registerString('meta_keywords', null, 255, false, Locale::t('Invalid value "%s"',Locale::t('Keywords')));
|
||||
$validator->registerNoTags('meta_keywords', Locale::t('Invalid value "%s"',Locale::t('Keywords')));
|
||||
$validator->registerUtf8('meta_keywords', Locale::t('Invalid value "%s"',Locale::t('Keywords')));
|
||||
|
||||
$validator->registerString('meta_description', null, 255, false, Locale::t('Invalid value "%s"',Locale::tm('Meta description', 'forum')));
|
||||
$validator->registerNoTags('meta_description', Locale::t('Invalid value "%s"',Locale::tm('Meta description', 'forum')));
|
||||
$validator->registerUtf8('meta_description', Locale::t('Invalid value "%s"',Locale::tm('Meta description', 'forum')));
|
||||
|
||||
$validator->registerNoTags('info', Locale::t('Invalid value "%s"',Locale::t('Information message')));
|
||||
$validator->registerUtf8('info', Locale::t('Invalid value "%s"',Locale::t('Information message')));
|
||||
|
||||
$validator->registerCustom(array(get_class(), 'checkStatus'), 'status', Locale::t('An error occurred'));
|
||||
|
||||
$validator->registerCustom(array(get_class(), 'checkForum'), array('category_id', 'forum_id'), Locale::t('An error occurred'));
|
||||
}
|
||||
|
||||
public static function checkStatus($status) {
|
||||
$statuses = \Forum\Models\Topic::getStatuses();
|
||||
return array_key_exists($status, $statuses);
|
||||
}
|
||||
|
||||
public static function checkForum($category_id, $forum_id) {
|
||||
$forum = new \Forum\Models\Forum($forum_id);
|
||||
return ($forum->loaded() && $forum->category_id == $category_id);
|
||||
}
|
||||
}
|
57
forum/forum.php
Normal file
57
forum/forum.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* forum.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum;
|
||||
|
||||
use Zira;
|
||||
use Dash;
|
||||
|
||||
class Forum {
|
||||
const ROUTE = 'forum';
|
||||
const VIEW_PLACEHOLDER_LABEL = 'label';
|
||||
|
||||
private static $_instance;
|
||||
|
||||
public static function getInstance() {
|
||||
if (self::$_instance === null) {
|
||||
self::$_instance = new self();
|
||||
}
|
||||
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
public function beforeDispatch() {
|
||||
Zira\Router::addRoute(self::ROUTE,'forum/index/index');
|
||||
Zira\Router::addRoute(self::ROUTE.'/group','forum/index/group');
|
||||
Zira\Router::addRoute(self::ROUTE.'/threads','forum/index/threads');
|
||||
Zira\Router::addRoute(self::ROUTE.'/thread','forum/index/thread');
|
||||
Zira\Router::addRoute(self::ROUTE.'/compose','forum/index/compose');
|
||||
Zira\Router::addRoute(self::ROUTE.'/poll','forum/index/poll');
|
||||
|
||||
Zira\Assets::registerCSSAsset('forum/forum.css');
|
||||
Zira\Assets::registerJSAsset('forum/forum.js');
|
||||
}
|
||||
|
||||
public function bootstrap() {
|
||||
Zira\View::addDefaultAssets();
|
||||
Zira\View::addStyle('forum/forum.css');
|
||||
Zira\View::addScript('forum/forum.js');
|
||||
|
||||
if (ENABLE_CONFIG_DATABASE && Dash\Dash::getInstance()->isPanelEnabled() && Zira\Permission::check(Zira\Permission::TO_ACCESS_DASHBOARD) && Zira\Permission::check(Zira\Permission::TO_CHANGE_OPTIONS)) {
|
||||
Dash\Dash::getInstance()->addPanelModulesGroupItem('glyphicon glyphicon-comment', Zira\Locale::tm('Forum', 'forum'), null, 'forumsWindow()');
|
||||
Dash\Dash::getInstance()->registerModuleWindowClass('forumsWindow', 'Forum\Windows\Forums', 'Forum\Models\Forums');
|
||||
Dash\Dash::getInstance()->registerModuleWindowClass('forumCategoriesWindow', 'Forum\Windows\Categories', 'Forum\Models\Categories');
|
||||
Dash\Dash::getInstance()->registerModuleWindowClass('forumCategoryWindow', 'Forum\Windows\Category', 'Forum\Models\Categories');
|
||||
Dash\Dash::getInstance()->registerModuleWindowClass('forumWindow', 'Forum\Windows\Forum', 'Forum\Models\Forums');
|
||||
Dash\Dash::getInstance()->registerModuleWindowClass('forumTopicsWindow', 'Forum\Windows\Topics', 'Forum\Models\Topics');
|
||||
Dash\Dash::getInstance()->registerModuleWindowClass('forumTopicWindow', 'Forum\Windows\Topic', 'Forum\Models\Topics');
|
||||
Dash\Dash::getInstance()->registerModuleWindowClass('forumMessagesWindow', 'Forum\Windows\Messages', 'Forum\Models\Messages');
|
||||
Dash\Dash::getInstance()->registerModuleWindowClass('forumMessageWindow', 'Forum\Windows\Message', 'Forum\Models\Messages');
|
||||
Dash\Dash::getInstance()->registerModuleWindowClass('forumSettingsWindow', 'Forum\Windows\Settings', 'Forum\Models\Settings');
|
||||
}
|
||||
}
|
||||
}
|
64
forum/install/category.php
Normal file
64
forum/install/category.php
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* category.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Install;
|
||||
|
||||
use Zira\Db\Table;
|
||||
use Zira\Db\Field;
|
||||
use Zira\Locale;
|
||||
|
||||
class Category extends Table {
|
||||
protected $_table = 'forum_categories';
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct($this->_table);
|
||||
}
|
||||
|
||||
public function getFields() {
|
||||
return array(
|
||||
'id' => Field::primary(),
|
||||
'title' => Field::string(true),
|
||||
'description' => Field::text(),
|
||||
'layout' => Field::string(),
|
||||
'meta_title' => Field::string(),
|
||||
'meta_keywords' => Field::string(),
|
||||
'meta_description' => Field::string(),
|
||||
'access_check' => Field::tinyint(true, true, 0),
|
||||
'sort_order' => Field::int(true, false, 0),
|
||||
'tpl' => Field::string()
|
||||
);
|
||||
}
|
||||
|
||||
public function getKeys() {
|
||||
return array(
|
||||
'sort_order' => array('sort_order')
|
||||
);
|
||||
}
|
||||
|
||||
public function getUnique() {
|
||||
return array(
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
public function getDefaults() {
|
||||
return array(
|
||||
array(
|
||||
'id' => null,
|
||||
'title' => Locale::tm('Default category', 'forum'),
|
||||
'description' => null,
|
||||
'layout' => null,
|
||||
'meta_title' => null,
|
||||
'meta_keywords' => null,
|
||||
'meta_description' => null,
|
||||
'access_check' => 0,
|
||||
'sort_order' => 1,
|
||||
'tpl' => null
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
73
forum/install/forum.php
Normal file
73
forum/install/forum.php
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* forum.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Install;
|
||||
|
||||
use Zira\Db\Table;
|
||||
use Zira\Db\Field;
|
||||
use Zira\Locale;
|
||||
|
||||
class Forum extends Table {
|
||||
protected $_table = 'forum_forums';
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct($this->_table);
|
||||
}
|
||||
|
||||
public function getFields() {
|
||||
return array(
|
||||
'id' => Field::primary(),
|
||||
'category_id' => Field::int(true, true),
|
||||
'title' => Field::string(true),
|
||||
'description' => Field::text(),
|
||||
'meta_title' => Field::string(),
|
||||
'meta_keywords' => Field::string(),
|
||||
'meta_description' => Field::string(),
|
||||
'access_check' => Field::tinyint(true, true, 0),
|
||||
'info' => Field::text(),
|
||||
'date_created' => Field::datetime(true),
|
||||
'date_modified' => Field::datetime(true),
|
||||
'topics' => Field::int(true, true, 0),
|
||||
'last_user_id' => Field::int(),
|
||||
'sort_order' => Field::int(true, false, 0),
|
||||
'active' => Field::tinyint(true, true, 1)
|
||||
);
|
||||
}
|
||||
|
||||
public function getKeys() {
|
||||
return array(
|
||||
'forum' => array('category_id', 'active', 'sort_order')
|
||||
);
|
||||
}
|
||||
|
||||
public function getUnique() {
|
||||
return array(
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
public function getDefaults() {
|
||||
return array(
|
||||
array(
|
||||
'id' => null,
|
||||
'category_id' => 1,
|
||||
'title' => Locale::tm('Default forum', 'forum'),
|
||||
'description' => null,
|
||||
'meta_title' => null,
|
||||
'meta_keywords' => null,
|
||||
'meta_description' => null,
|
||||
'access_check' => 0,
|
||||
'info' => null,
|
||||
'date_created' => date('Y-m-d H:i:s'),
|
||||
'date_modified' => date('Y-m-d H:i:s'),
|
||||
'last_user_id' => null,
|
||||
'sort_order' => 1,
|
||||
'active' => 1
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
48
forum/install/forumlike.php
Normal file
48
forum/install/forumlike.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* forumlike.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Install;
|
||||
|
||||
use Zira\Db\Table;
|
||||
use Zira\Db\Field;
|
||||
|
||||
class Forumlike extends Table {
|
||||
protected $_table = 'forum_likes';
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct($this->_table);
|
||||
}
|
||||
|
||||
public function getFields() {
|
||||
return array(
|
||||
'id' => Field::primary(),
|
||||
'message_id' => Field::int(true, true),
|
||||
'user_id' => Field::int(true, true),
|
||||
'anonymous_id' => Field::string(true),
|
||||
'rate' => Field::tinyint(true),
|
||||
'creation_date' => Field::datetime(true)
|
||||
);
|
||||
}
|
||||
|
||||
public function getKeys() {
|
||||
return array(
|
||||
'like' => array('message_id', 'user_id', 'anonymous_id')
|
||||
);
|
||||
}
|
||||
|
||||
public function getUnique() {
|
||||
return array(
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
public function getDefaults() {
|
||||
return array(
|
||||
|
||||
);
|
||||
}
|
||||
}
|
51
forum/install/message.php
Normal file
51
forum/install/message.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* message.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Install;
|
||||
|
||||
use Zira\Db\Table;
|
||||
use Zira\Db\Field;
|
||||
|
||||
class Message extends Table {
|
||||
protected $_table = 'forum_messages';
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct($this->_table);
|
||||
}
|
||||
|
||||
public function getFields() {
|
||||
return array(
|
||||
'id' => Field::primary(),
|
||||
'topic_id' => Field::int(true, true),
|
||||
'creator_id' => Field::int(true, true),
|
||||
'content' => Field::text(true),
|
||||
'date_created' => Field::datetime(true),
|
||||
'date_modified' => Field::datetime(true),
|
||||
'modified_by' => Field::int(),
|
||||
'rating' => Field::int(true, false, 0),
|
||||
'status' => Field::tinyint(true, true, 0)
|
||||
);
|
||||
}
|
||||
|
||||
public function getKeys() {
|
||||
return array(
|
||||
'topic_id' => array('topic_id')
|
||||
);
|
||||
}
|
||||
|
||||
public function getUnique() {
|
||||
return array(
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
public function getDefaults() {
|
||||
return array(
|
||||
|
||||
);
|
||||
}
|
||||
}
|
59
forum/install/topic.php
Normal file
59
forum/install/topic.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* topic.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Install;
|
||||
|
||||
use Zira\Db\Table;
|
||||
use Zira\Db\Field;
|
||||
|
||||
class Topic extends Table {
|
||||
protected $_table = 'forum_topics';
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct($this->_table);
|
||||
}
|
||||
|
||||
public function getFields() {
|
||||
return array(
|
||||
'id' => Field::primary(),
|
||||
'category_id' => Field::int(true, true),
|
||||
'forum_id' => Field::int(true, true),
|
||||
'creator_id' => Field::int(true, true),
|
||||
'title' => Field::string(true),
|
||||
'description' => Field::text(),
|
||||
'meta_title' => Field::string(),
|
||||
'meta_keywords' => Field::string(),
|
||||
'meta_description' => Field::string(),
|
||||
'info' => Field::text(),
|
||||
'date_created' => Field::datetime(true),
|
||||
'date_modified' => Field::datetime(true),
|
||||
'messages' => Field::int(true, true, 0),
|
||||
'last_user_id' => Field::int(),
|
||||
'active' => Field::tinyint(true, true, 1),
|
||||
'status' => Field::tinyint(true, true, 0),
|
||||
'sticky' => Field::tinyint(true, true, 0)
|
||||
);
|
||||
}
|
||||
|
||||
public function getKeys() {
|
||||
return array(
|
||||
'forum' => array('category_id','forum_id','sticky')
|
||||
);
|
||||
}
|
||||
|
||||
public function getUnique() {
|
||||
return array(
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
public function getDefaults() {
|
||||
return array(
|
||||
|
||||
);
|
||||
}
|
||||
}
|
113
forum/models/categories.php
Normal file
113
forum/models/categories.php
Normal file
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* categories.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Models;
|
||||
|
||||
use Zira;
|
||||
use Dash;
|
||||
use Forum;
|
||||
use Zira\Permission;
|
||||
|
||||
class Categories extends Dash\Models\Model {
|
||||
public function save($data) {
|
||||
if (!Permission::check(Permission::TO_CHANGE_OPTIONS)) {
|
||||
return array('error' => Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$form = new Forum\Forms\Category();
|
||||
if ($form->isValid()) {
|
||||
$id = (int)$form->getValue('id');
|
||||
if ($id) {
|
||||
$category = new Forum\Models\Category($id);
|
||||
if (!$category->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
|
||||
} else {
|
||||
$max_order = Forum\Models\Category::getCollection()->max('sort_order')->get('mx');
|
||||
|
||||
$category = new Forum\Models\Category();
|
||||
$category->sort_order = ++$max_order;
|
||||
}
|
||||
$category->title = $form->getValue('title');
|
||||
$layout = $form->getValue('layout');
|
||||
$category->layout = !empty($layout) ? $layout : null;
|
||||
$description = $form->getValue('description');
|
||||
$category->description = !empty($description) ? $description : null;
|
||||
$meta_title = $form->getValue('meta_title');
|
||||
$category->meta_title = !empty($meta_title) ? $meta_title : null;
|
||||
$meta_description = $form->getValue('meta_description');
|
||||
$category->meta_description = !empty($meta_description) ? $meta_description : null;
|
||||
$meta_keywords = $form->getValue('meta_keywords');
|
||||
$category->meta_keywords = !empty($meta_keywords) ? $meta_keywords : null;
|
||||
$category->access_check = (int)$form->getValue('access_check') ? 1 : 0;
|
||||
|
||||
$category->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_OPTIONS)) {
|
||||
return array('error'=>Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$categories = array();
|
||||
foreach($data as $category_id) {
|
||||
$category = new Forum\Models\Category($category_id);
|
||||
if (!$category->loaded()) {
|
||||
return array('error' => Zira\Locale::t('An error occurred'));
|
||||
};
|
||||
|
||||
$co = Forum\Models\Forum::getCollection()
|
||||
->count()
|
||||
->where('category_id', '=', $category_id)
|
||||
->get('co');
|
||||
if ($co>0) return array('error' => Zira\Locale::tm('Category "%s" has forums.','forum', $category->title));
|
||||
|
||||
$categories []= $category;
|
||||
}
|
||||
|
||||
foreach($categories as $category) {
|
||||
$category->delete();
|
||||
}
|
||||
|
||||
return array('reload' => $this->getJSClassName());
|
||||
}
|
||||
|
||||
public function drag($categories, $orders) {
|
||||
if (empty($categories) || !is_array($categories) || count($categories)<2 || empty($orders) || !is_array($orders) || count($orders)<2 || count($categories)!=count($orders)) {
|
||||
return array('error' => Zira\Locale::t('An error occurred'));
|
||||
}
|
||||
if (!Permission::check(Permission::TO_CHANGE_OPTIONS)) {
|
||||
return array('error'=>Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$_categories = array();
|
||||
$_orders = array();
|
||||
foreach($categories as $id) {
|
||||
$_category = new Forum\Models\Category($id);
|
||||
if (!$_category->loaded()) {
|
||||
return array('error' => Zira\Locale::t('An error occurred'));
|
||||
}
|
||||
$_categories []= $_category;
|
||||
$_orders []= $_category->sort_order;
|
||||
}
|
||||
foreach($orders as $order) {
|
||||
if (!in_array($order, $_orders)) {
|
||||
return array('error' => Zira\Locale::t('An error occurred'));
|
||||
}
|
||||
}
|
||||
foreach($_categories as $index=>$category) {
|
||||
$category->sort_order = intval($orders[$index]);
|
||||
$category->save();
|
||||
}
|
||||
|
||||
return array('reload'=>$this->getJSClassName());
|
||||
}
|
||||
}
|
59
forum/models/category.php
Normal file
59
forum/models/category.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* category.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Models;
|
||||
|
||||
use Zira;
|
||||
use Zira\Orm;
|
||||
|
||||
class Category extends Orm {
|
||||
public static $table = 'forum_categories';
|
||||
public static $pk = 'id';
|
||||
public static $alias = 'frm_cat';
|
||||
|
||||
public static function getFields() {
|
||||
return array(
|
||||
'id',
|
||||
'title',
|
||||
'description',
|
||||
'layout',
|
||||
'meta_title',
|
||||
'meta_keywords',
|
||||
'meta_description',
|
||||
'access_check',
|
||||
'sort_order',
|
||||
'tpl'
|
||||
);
|
||||
}
|
||||
|
||||
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 getCategpries() {
|
||||
return self::getCollection()
|
||||
->order_by('sort_order', 'asc')
|
||||
->get();
|
||||
}
|
||||
|
||||
public static function generateUrl($category) {
|
||||
$id = is_numeric($category) ? intval($category) : $category->id;
|
||||
return \Forum\Forum::ROUTE . '/group/' . $id;
|
||||
}
|
||||
}
|
74
forum/models/forum.php
Normal file
74
forum/models/forum.php
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* forum.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Models;
|
||||
|
||||
use Zira;
|
||||
use Zira\Orm;
|
||||
|
||||
class Forum extends Orm {
|
||||
public static $table = 'forum_forums';
|
||||
public static $pk = 'id';
|
||||
public static $alias = 'frm_frm';
|
||||
|
||||
public static function getFields() {
|
||||
return array(
|
||||
'id',
|
||||
'category_id',
|
||||
'title',
|
||||
'description',
|
||||
'meta_title',
|
||||
'meta_keywords',
|
||||
'meta_description',
|
||||
'access_check',
|
||||
'info',
|
||||
'date_created',
|
||||
'date_modified',
|
||||
'topics',
|
||||
'last_user_id',
|
||||
'sort_order',
|
||||
'active'
|
||||
);
|
||||
}
|
||||
|
||||
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(
|
||||
Category::getClass() => 'category_id',
|
||||
Zira\Models\User::getClass() => 'last_user_id'
|
||||
);
|
||||
}
|
||||
|
||||
public static function generateUrl($forum) {
|
||||
$id = is_numeric($forum) ? intval($forum) : $forum->id;
|
||||
return \Forum\Forum::ROUTE . '/threads/' . $id;
|
||||
}
|
||||
|
||||
public static function getArray($category_id) {
|
||||
$forums = self::getCollection()
|
||||
->where('category_id', '=', $category_id)
|
||||
->get();
|
||||
|
||||
$forums_arr = array();
|
||||
foreach($forums as $forum) {
|
||||
$forums_arr[$forum->id] = $forum->title;
|
||||
}
|
||||
|
||||
return $forums_arr;
|
||||
}
|
||||
}
|
36
forum/models/forumlike.php
Normal file
36
forum/models/forumlike.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* forumlike.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Models;
|
||||
|
||||
use Zira;
|
||||
use Zira\Orm;
|
||||
|
||||
class Forumlike extends Orm {
|
||||
public static $table = 'forum_likes';
|
||||
public static $pk = 'id';
|
||||
public static $alias = 'frm_lke';
|
||||
|
||||
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(
|
||||
Message::getClass() => 'message_id',
|
||||
Zira\Models\User::getClass() => 'user_id'
|
||||
);
|
||||
}
|
||||
}
|
117
forum/models/forums.php
Normal file
117
forum/models/forums.php
Normal file
|
@ -0,0 +1,117 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* forums.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Models;
|
||||
|
||||
use Zira;
|
||||
use Dash;
|
||||
use Forum;
|
||||
use Zira\Permission;
|
||||
|
||||
class Forums extends Dash\Models\Model {
|
||||
public function save($data) {
|
||||
if (!Permission::check(Permission::TO_CHANGE_OPTIONS)) {
|
||||
return array('error' => Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$form = new Forum\Forms\Forum();
|
||||
if ($form->isValid()) {
|
||||
$id = (int)$form->getValue('id');
|
||||
if ($id) {
|
||||
$forum = new Forum\Models\Forum($id);
|
||||
if (!$forum->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
|
||||
} else {
|
||||
$max_order = Forum\Models\Forum::getCollection()->max('sort_order')->get('mx');
|
||||
|
||||
$forum = new Forum\Models\Forum();
|
||||
$forum->sort_order = ++$max_order;
|
||||
$forum->date_created = date('Y-m-d H:i:s');
|
||||
$forum->date_modified = date('Y-m-d H:i:s');
|
||||
}
|
||||
$forum->title = $form->getValue('title');
|
||||
$description = $form->getValue('description');
|
||||
$forum->description = !empty($description) ? $description : null;
|
||||
$meta_title = $form->getValue('meta_title');
|
||||
$forum->meta_title = !empty($meta_title) ? $meta_title : null;
|
||||
$meta_description = $form->getValue('meta_description');
|
||||
$forum->meta_description = !empty($meta_description) ? $meta_description : null;
|
||||
$meta_keywords = $form->getValue('meta_keywords');
|
||||
$forum->meta_keywords = !empty($meta_keywords) ? $meta_keywords : null;
|
||||
$info = $form->getValue('info');
|
||||
$forum->info = !empty($info) ? $info : null;
|
||||
$forum->category_id = (int)$form->getValue('category_id');
|
||||
$forum->access_check = (int)$form->getValue('access_check') ? 1 : 0;
|
||||
$forum->active = (int)$form->getValue('active') ? 1 : 0;
|
||||
|
||||
$forum->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_OPTIONS)) {
|
||||
return array('error'=>Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$forums = array();
|
||||
foreach($data as $forum_id) {
|
||||
$forum = new Forum\Models\Forum($forum_id);
|
||||
if (!$forum->loaded()) {
|
||||
return array('error' => Zira\Locale::t('An error occurred'));
|
||||
};
|
||||
|
||||
$co = Forum\Models\Topic::getCollection()
|
||||
->count()
|
||||
->where('forum_id', '=', $forum_id)
|
||||
->get('co');
|
||||
if ($co>0) return array('error' => Zira\Locale::tm('Forum "%s" has topics.','forum', $forum->title));
|
||||
|
||||
$forums []= $forum;
|
||||
}
|
||||
|
||||
foreach($forums as $forum) {
|
||||
$forum->delete();
|
||||
}
|
||||
|
||||
return array('reload' => $this->getJSClassName());
|
||||
}
|
||||
|
||||
public function drag($forums, $orders) {
|
||||
if (empty($forums) || !is_array($forums) || count($forums)<2 || empty($orders) || !is_array($orders) || count($orders)<2 || count($forums)!=count($orders)) {
|
||||
return array('error' => Zira\Locale::t('An error occurred'));
|
||||
}
|
||||
if (!Permission::check(Permission::TO_CHANGE_OPTIONS)) {
|
||||
return array('error'=>Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$_forums = array();
|
||||
$_orders = array();
|
||||
foreach($forums as $id) {
|
||||
$_forum = new Forum\Models\Forum($id);
|
||||
if (!$_forum->loaded()) {
|
||||
return array('error' => Zira\Locale::t('An error occurred'));
|
||||
}
|
||||
$_forums []= $_forum;
|
||||
$_orders []= $_forum->sort_order;
|
||||
}
|
||||
foreach($orders as $order) {
|
||||
if (!in_array($order, $_orders)) {
|
||||
return array('error' => Zira\Locale::t('An error occurred'));
|
||||
}
|
||||
}
|
||||
foreach($_forums as $index=>$forum) {
|
||||
$forum->sort_order = intval($orders[$index]);
|
||||
$forum->save();
|
||||
}
|
||||
|
||||
return array('reload'=>$this->getJSClassName());
|
||||
}
|
||||
}
|
131
forum/models/message.php
Normal file
131
forum/models/message.php
Normal file
|
@ -0,0 +1,131 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* message.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Models;
|
||||
|
||||
use Zira;
|
||||
use Zira\Orm;
|
||||
|
||||
class Message extends Orm {
|
||||
public static $table = 'forum_messages';
|
||||
public static $pk = 'id';
|
||||
public static $alias = 'frm_msg';
|
||||
|
||||
const STATUS_NONE = 0;
|
||||
const STATUS_INFO = 1;
|
||||
const STATUS_MESSAGE = 2;
|
||||
const STATUS_WARNING = 3;
|
||||
|
||||
public static function getFields() {
|
||||
return array(
|
||||
'id',
|
||||
'topic_id',
|
||||
'creator_id',
|
||||
'content',
|
||||
'date_created',
|
||||
'date_modified',
|
||||
'modified_by',
|
||||
'rating',
|
||||
'status'
|
||||
);
|
||||
}
|
||||
|
||||
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(
|
||||
Topic::getClass() => 'topic_id',
|
||||
Zira\Models\User::getClass() => 'creator_id'
|
||||
);
|
||||
}
|
||||
|
||||
public static function getStatuses() {
|
||||
return array(
|
||||
self::STATUS_NONE => Zira\Locale::tm('Default', 'forum'),
|
||||
self::STATUS_INFO => Zira\Locale::tm('Information', 'forum'),
|
||||
self::STATUS_MESSAGE => Zira\Locale::tm('Message', 'forum'),
|
||||
self::STATUS_WARNING => Zira\Locale::tm('Warning', 'forum')
|
||||
);
|
||||
}
|
||||
|
||||
public static function createNewMessage($forum_id, $topic_id, $content, $topic_messages_co, $forum_topics_co, $status=null) {
|
||||
if (!Zira\User::isAuthorized()) return false;
|
||||
|
||||
$message = new self();
|
||||
$message->topic_id = $topic_id;
|
||||
$message->creator_id = Zira\User::getCurrent()->id;
|
||||
$message->content = Zira\Helper::utf8Entity(html_entity_decode($content));
|
||||
$message->date_created = date('Y-m-d H:i:s');
|
||||
$message->date_modified = date('Y-m-d H:i:s');
|
||||
if ($status!==null) $message->status = $status;
|
||||
$message->save();
|
||||
|
||||
Topic::getCollection()
|
||||
->update(array(
|
||||
'date_modified' => date('Y-m-d H:i:s'),
|
||||
'last_user_id' => Zira\User::getCurrent()->id,
|
||||
'messages' => $topic_messages_co
|
||||
))->where('id','=',$topic_id)
|
||||
->execute();
|
||||
|
||||
Forum::getCollection()
|
||||
->update(array(
|
||||
'date_modified' => date('Y-m-d H:i:s'),
|
||||
'last_user_id' => Zira\User::getCurrent()->id,
|
||||
'topics' => $forum_topics_co
|
||||
))->where('id','=',$forum_id)
|
||||
->execute();
|
||||
|
||||
Zira\User::getCurrent()->posts++;
|
||||
Zira\User::getCurrent()->save();
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
public static function deleteMessage($message_id) {
|
||||
$message = new self($message_id);
|
||||
if (!$message->loaded()) return false;
|
||||
|
||||
$message->delete();
|
||||
|
||||
$user = new Zira\Models\User($message->creator_id);
|
||||
if ($user->loaded()) {
|
||||
$user->posts--;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
$topic = new Topic($message->topic_id);
|
||||
if ($topic->loaded()) {
|
||||
if ($topic->last_user_id == $message->creator_id) {
|
||||
$topic->last_user_id = null;
|
||||
}
|
||||
$topic->messages--;
|
||||
if ($topic->messages<0) $topic->messages = 0;
|
||||
$topic->save();
|
||||
}
|
||||
|
||||
if ($topic->loaded()) {
|
||||
$forum = new Forum($topic->forum_id);
|
||||
if ($forum->loaded() && $forum->last_user_id == $message->creator_id) {
|
||||
$forum->last_user_id = null;
|
||||
$forum->save();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
84
forum/models/messages.php
Normal file
84
forum/models/messages.php
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* messages.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Models;
|
||||
|
||||
use Zira;
|
||||
use Dash;
|
||||
use Forum;
|
||||
use Zira\Permission;
|
||||
|
||||
class Messages extends Dash\Models\Model {
|
||||
public function save($data) {
|
||||
if (!Permission::check(Permission::TO_CHANGE_OPTIONS)) {
|
||||
return array('error' => Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$form = new Forum\Forms\Message();
|
||||
if ($form->isValid()) {
|
||||
$id = (int)$form->getValue('id');
|
||||
|
||||
$content = $form->getValue('content');
|
||||
$content = str_replace("\r",'',$content);
|
||||
$content = str_replace("\n","\r\n",$content);
|
||||
$content = Zira\Helper::utf8Entity($content);
|
||||
|
||||
if ($id) {
|
||||
$message = new Forum\Models\Message($id);
|
||||
if (!$message->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
|
||||
$message->modified_by = Zira\User::getCurrent()->id;
|
||||
$message->content = $content;
|
||||
$message->date_modified = date('Y-m-d H:i:s');
|
||||
$message->status = (int)$form->getValue('status');
|
||||
|
||||
$message->save();
|
||||
} else {
|
||||
$topic_id = $form->getValue('topic_id');
|
||||
|
||||
$category_fields = Forum\Models\Category::getFields();
|
||||
$_category_fields = array();
|
||||
foreach($category_fields as $field) {
|
||||
$_category_fields['category_'.$field] = $field;
|
||||
}
|
||||
|
||||
$forum_fields = Forum\Models\Forum::getFields();
|
||||
$_forum_fields = array();
|
||||
foreach($forum_fields as $field) {
|
||||
$_forum_fields['forum_'.$field] = $field;
|
||||
}
|
||||
|
||||
$topic = Forum\Models\Topic::getCollection()
|
||||
->select(Forum\Models\Topic::getFields())
|
||||
->join(Forum\Models\Category::getClass(), $_category_fields)
|
||||
->join(Forum\Models\Forum::getClass(), $_forum_fields)
|
||||
->where('id','=',$topic_id)
|
||||
->get(0);
|
||||
|
||||
if (!$topic) return array('error' => Zira\Locale::t('An error occurred'));
|
||||
|
||||
Forum\Models\Message::createNewMessage($topic->forum_id, $topic->id, $content, ++$topic->messages, $topic->forum_topics, (int)$form->getValue('status'));
|
||||
}
|
||||
|
||||
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_OPTIONS)) {
|
||||
return array('error'=>Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
foreach($data as $message_id) {
|
||||
Forum\Models\Message::deleteMessage($message_id);
|
||||
}
|
||||
|
||||
return array('reload' => $this->getJSClassName());
|
||||
}
|
||||
}
|
63
forum/models/settings.php
Normal file
63
forum/models/settings.php
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* settings.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Models;
|
||||
|
||||
use Zira;
|
||||
use Dash;
|
||||
use Forum;
|
||||
use Zira\Permission;
|
||||
|
||||
class Settings extends Dash\Models\Model {
|
||||
public function save($data) {
|
||||
if (!Permission::check(Permission::TO_CHANGE_OPTIONS)) {
|
||||
return array('error' => Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$form = new Forum\Forms\Settings();
|
||||
if ($form->isValid()) {
|
||||
$options = array(
|
||||
'forum_layout' => 'string',
|
||||
'forum_title' => 'string',
|
||||
'forum_description' => 'string',
|
||||
'forum_meta_title' => 'string',
|
||||
'forum_meta_description' => 'string',
|
||||
'forum_meta_keywords' => 'string',
|
||||
'forum_limit' => 'int',
|
||||
'forum_min_chars' => 'int'
|
||||
);
|
||||
|
||||
$config_ids = array();
|
||||
$user_configs = Zira\Models\Option::getCollection()->get();
|
||||
foreach($user_configs as $user_config) {
|
||||
$config_ids[$user_config->name] = $user_config->id;
|
||||
}
|
||||
|
||||
foreach($options as $option=>$type) {
|
||||
if (!array_key_exists($option, $config_ids)) {
|
||||
$optionObj = new Zira\Models\Option();
|
||||
} else {
|
||||
$optionObj = new Zira\Models\Option($config_ids[$option]);
|
||||
}
|
||||
$optionObj->name = $option;
|
||||
$value = $form->getValue($option);
|
||||
|
||||
if ($type=='int') $value=intval($value);
|
||||
|
||||
$optionObj->value = $value;
|
||||
$optionObj->module = 'forum';
|
||||
$optionObj->save();
|
||||
}
|
||||
|
||||
Zira\Models\Option::raiseVersion();
|
||||
|
||||
return array('message'=>Zira\Locale::t('Successfully saved'));
|
||||
} else {
|
||||
return array('error'=>$form->getError());
|
||||
}
|
||||
}
|
||||
}
|
140
forum/models/topic.php
Normal file
140
forum/models/topic.php
Normal file
|
@ -0,0 +1,140 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* topic.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Models;
|
||||
|
||||
use Zira;
|
||||
use Zira\Orm;
|
||||
|
||||
class Topic extends Orm {
|
||||
public static $table = 'forum_topics';
|
||||
public static $pk = 'id';
|
||||
public static $alias = 'frm_tpc';
|
||||
|
||||
const STATUS_NONE = 0;
|
||||
const STATUS_SOLVED = 1;
|
||||
const STATUS_DENIED = 2;
|
||||
|
||||
public static function getFields() {
|
||||
return array(
|
||||
'id',
|
||||
'category_id',
|
||||
'forum_id',
|
||||
'creator_id',
|
||||
'title',
|
||||
'description',
|
||||
'meta_title',
|
||||
'meta_keywords',
|
||||
'meta_description',
|
||||
'info',
|
||||
'date_created',
|
||||
'date_modified',
|
||||
'messages',
|
||||
'last_user_id',
|
||||
'active',
|
||||
'status',
|
||||
'sticky'
|
||||
);
|
||||
}
|
||||
|
||||
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(
|
||||
Category::getClass() => 'category_id',
|
||||
Forum::getClass() => 'forum_id',
|
||||
Zira\Models\User::getClass() => 'last_user_id'
|
||||
);
|
||||
}
|
||||
|
||||
public static function generateUrl($topic) {
|
||||
$id = is_numeric($topic) ? intval($topic) : $topic->id;
|
||||
return \Forum\Forum::ROUTE . '/thread/' . $id;
|
||||
}
|
||||
|
||||
public static function getStatuses() {
|
||||
return array(
|
||||
self::STATUS_NONE => Zira\Locale::tm('Default', 'forum'),
|
||||
self::STATUS_SOLVED => Zira\Locale::tm('Solved', 'forum'),
|
||||
self::STATUS_DENIED => Zira\Locale::tm('Denied', 'forum')
|
||||
);
|
||||
}
|
||||
|
||||
public static function getStatus($status) {
|
||||
$statuses = self::getStatuses();
|
||||
if (!array_key_exists($status, $statuses)) return '';
|
||||
return $statuses[$status];
|
||||
}
|
||||
|
||||
public static function createNewTopic($category_id, $forum_id, $title, $message, $forum_topic_co) {
|
||||
if (!Zira\User::isAuthorized()) return false;
|
||||
|
||||
$topic = new self();
|
||||
$topic->category_id = $category_id;
|
||||
$topic->forum_id = $forum_id;
|
||||
$topic->creator_id = Zira\User::getCurrent()->id;
|
||||
$topic->title = $title;
|
||||
$topic->date_created = date('Y-m-d H:i:s');
|
||||
$topic->date_modified = date('Y-m-d H:i:s');
|
||||
$topic->save();
|
||||
|
||||
if (!Message::createNewMessage($forum_id, $topic->id, $message, 1, $forum_topic_co)) return false;
|
||||
|
||||
return $topic;
|
||||
}
|
||||
|
||||
public static function deleteTopic($topic_id) {
|
||||
$topic = new self($topic_id);
|
||||
if (!$topic->loaded()) return false;
|
||||
|
||||
$topic->delete();
|
||||
|
||||
$messages = Message::getCollection()
|
||||
->count()
|
||||
->select('creator_id')
|
||||
->where('topic_id','=',$topic->id)
|
||||
->group_by('creator_id')
|
||||
->get();
|
||||
|
||||
if ($messages) {
|
||||
foreach($messages as $message) {
|
||||
$user = new Zira\Models\User($message->creator_id);
|
||||
if (!$user->loaded()) continue;
|
||||
$user->posts -= $message->co;
|
||||
if ($user->posts<0) $user->posts = 0;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
Message::getCollection()
|
||||
->delete()
|
||||
->where('topic_id','=',$topic->id)
|
||||
->execute();
|
||||
}
|
||||
|
||||
$forum = new Forum($topic->forum_id);
|
||||
if ($forum->loaded()) {
|
||||
if ($forum->last_user_id == $topic->creator_id) {
|
||||
$forum->last_user_id = null;
|
||||
}
|
||||
$forum->topics--;
|
||||
if ($forum->topics<0) $forum->topics = 0;
|
||||
$forum->save();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
93
forum/models/topics.php
Normal file
93
forum/models/topics.php
Normal file
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* topics.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Models;
|
||||
|
||||
use Zira;
|
||||
use Dash;
|
||||
use Forum;
|
||||
use Zira\Permission;
|
||||
|
||||
class Topics extends Dash\Models\Model {
|
||||
public function save($data) {
|
||||
if (!Permission::check(Permission::TO_CHANGE_OPTIONS)) {
|
||||
return array('error' => Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$form = new Forum\Forms\Topic();
|
||||
if ($form->isValid()) {
|
||||
$id = (int)$form->getValue('id');
|
||||
if ($id) {
|
||||
$thread = new Forum\Models\Topic($id);
|
||||
if (!$thread->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
|
||||
|
||||
if ($thread->forum_id != $form->getValue('forum_id')) {
|
||||
$forum_old = new \Forum\Models\Forum($thread->forum_id);
|
||||
if (!$forum_old->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
|
||||
$forum_new = new \Forum\Models\Forum($form->getValue('forum_id'));
|
||||
if (!$forum_new->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
|
||||
|
||||
$forum_old->topics--;
|
||||
if ($forum_old->topics < 0) $forum_old->topics = 0;
|
||||
$forum_old->save();
|
||||
|
||||
$forum_new->topics++;
|
||||
$forum_new->save();
|
||||
|
||||
$thread->forum_id = (int)$form->getValue('forum_id');
|
||||
}
|
||||
} else {
|
||||
$forum = new \Forum\Models\Forum($form->getValue('forum_id'));
|
||||
if (!$forum->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
|
||||
|
||||
$forum->topics++;
|
||||
$forum->save();
|
||||
|
||||
$thread = new Forum\Models\Topic();
|
||||
$thread->category_id = $forum->category_id;
|
||||
$thread->forum_id = $forum->id;
|
||||
$thread->creator_id = Zira\User::getCurrent()->id;
|
||||
$thread->date_created = date('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
$thread->title = $form->getValue('title');
|
||||
$description = $form->getValue('description');
|
||||
$thread->description = !empty($description) ? $description : null;
|
||||
$meta_title = $form->getValue('meta_title');
|
||||
$thread->meta_title = !empty($meta_title) ? $meta_title : null;
|
||||
$meta_description = $form->getValue('meta_description');
|
||||
$thread->meta_description = !empty($meta_description) ? $meta_description : null;
|
||||
$meta_keywords = $form->getValue('meta_keywords');
|
||||
$thread->meta_keywords = !empty($meta_keywords) ? $meta_keywords : null;
|
||||
$info = $form->getValue('info');
|
||||
$thread->info = !empty($info) ? $info : null;
|
||||
$thread->status = (int)$form->getValue('status');
|
||||
$thread->active = (int)$form->getValue('active') ? 1 : 0;
|
||||
$thread->sticky = (int)$form->getValue('sticky') ? 1 : 0;
|
||||
$thread->date_modified = date('Y-m-d H:i:s');
|
||||
|
||||
$thread->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_OPTIONS)) {
|
||||
return array('error'=>Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
foreach($data as $topic_id) {
|
||||
Forum\Models\Topic::deleteTopic($topic_id);
|
||||
}
|
||||
|
||||
return array('reload' => $this->getJSClassName());
|
||||
}
|
||||
}
|
5
forum/module.meta
Normal file
5
forum/module.meta
Normal file
|
@ -0,0 +1,5 @@
|
|||
[meta]
|
||||
name = Forum
|
||||
description = Simple and lightweight forum
|
||||
author = Zira
|
||||
version = 1.0
|
62
forum/windows/categories.php
Normal file
62
forum/windows/categories.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* categories.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Windows;
|
||||
|
||||
use Dash;
|
||||
use Zira;
|
||||
use Forum;
|
||||
use Zira\Permission;
|
||||
|
||||
class Categories extends Dash\Windows\Window {
|
||||
protected static $_icon_class = 'glyphicon glyphicon-folder-close';
|
||||
protected static $_title = 'Forum categories';
|
||||
|
||||
|
||||
public function init() {
|
||||
$this->setIconClass(self::$_icon_class);
|
||||
$this->setTitle(Zira\Locale::t(self::$_title));
|
||||
$this->setViewSwitcherEnabled(false);
|
||||
$this->setSelectionLinksEnabled(true);
|
||||
$this->setBodyViewListVertical(true);
|
||||
$this->setSidebarEnabled(false);
|
||||
|
||||
$this->setCreateActionWindowClass(Forum\Windows\Category::getClass());
|
||||
$this->setEditActionWindowClass(Forum\Windows\Category::getClass());
|
||||
|
||||
$this->setDeleteActionEnabled(true);
|
||||
|
||||
$this->setOnOpenJSCallback(
|
||||
$this->createJSCallback('desk_call(dash_forum_categories_drag, this);')
|
||||
);
|
||||
|
||||
$this->includeJS('forum/dash');
|
||||
}
|
||||
|
||||
public function create() {
|
||||
$this->addDefaultToolbarItem(
|
||||
$this->createToolbarButton(Zira\Locale::t('New category'), Zira\Locale::t('New category'), 'glyphicon glyphicon-plus-sign', 'desk_call(desk_window_create_item, this, this);', 'create')
|
||||
);
|
||||
}
|
||||
|
||||
public function load() {
|
||||
if (!Permission::check(Permission::TO_CHANGE_OPTIONS)) {
|
||||
$this->setBodyItems(array());
|
||||
return array('error'=>Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$categories = Forum\Models\Category::getCollection()
|
||||
->order_by('sort_order', 'asc')
|
||||
->get();
|
||||
|
||||
$items = array();
|
||||
foreach($categories as $category) {
|
||||
$items[]=$this->createBodyItem($category->title, $category->description, Zira\Helper::imgUrl('drag.png'), $category->id, null, false, array('sort_order'=>$category->sort_order));
|
||||
}
|
||||
$this->setBodyItems($items);
|
||||
}
|
||||
}
|
54
forum/windows/category.php
Normal file
54
forum/windows/category.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* category.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Windows;
|
||||
|
||||
use Zira;
|
||||
use Dash;
|
||||
use Zira\Permission;
|
||||
|
||||
class Category extends Dash\Windows\Window {
|
||||
protected static $_icon_class = 'glyphicon glyphicon-folder-close';
|
||||
protected static $_title = 'Forum category';
|
||||
|
||||
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_OPTIONS)) {
|
||||
return array('error' => Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$form = new \Forum\Forms\Category();
|
||||
if (!empty($this->item)) {
|
||||
$category = new \Forum\Models\Category($this->item);
|
||||
if (!$category->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
|
||||
$form->setValues($category->toArray());
|
||||
$this->setTitle(Zira\Locale::tm(self::$_title,'forum').' - '.$category->title);
|
||||
} else {
|
||||
$this->setTitle(Zira\Locale::tm('New forum category','forum'));
|
||||
}
|
||||
|
||||
$this->setBodyContent($form);
|
||||
}
|
||||
}
|
63
forum/windows/forum.php
Normal file
63
forum/windows/forum.php
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* forum.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Windows;
|
||||
|
||||
use Zira;
|
||||
use Dash;
|
||||
use Zira\Permission;
|
||||
|
||||
class Forum extends Dash\Windows\Window {
|
||||
protected static $_icon_class = 'glyphicon glyphicon-comment';
|
||||
protected static $_title = 'Forum';
|
||||
|
||||
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_OPTIONS)) {
|
||||
return array('error' => Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$category_id = Zira\Request::post('category_id');
|
||||
if (empty($category_id)) return array('error' => Zira\Locale::t('An error occurred'));
|
||||
$category = new \Forum\Models\Category($category_id);
|
||||
if (!$category->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
|
||||
|
||||
$form = new \Forum\Forms\Forum();
|
||||
if (!empty($this->item)) {
|
||||
$forum = new \Forum\Models\Forum($this->item);
|
||||
if (!$forum->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
|
||||
$form->setValues($forum->toArray());
|
||||
$this->setTitle(Zira\Locale::tm(self::$_title,'forum').' - '.$forum->title.' - '.$category->title);
|
||||
} else {
|
||||
$form->setValues(array(
|
||||
'category_id'=>$category_id,
|
||||
'active'=>1
|
||||
));
|
||||
$this->setTitle(Zira\Locale::tm('New forum','forum').' - '.$category->title);
|
||||
}
|
||||
|
||||
$this->setBodyContent($form);
|
||||
}
|
||||
}
|
168
forum/windows/forums.php
Normal file
168
forum/windows/forums.php
Normal file
|
@ -0,0 +1,168 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* forums.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Windows;
|
||||
|
||||
use Dash;
|
||||
use Zira;
|
||||
use Forum;
|
||||
use Zira\Permission;
|
||||
|
||||
class Forums extends Dash\Windows\Window {
|
||||
protected static $_icon_class = 'glyphicon glyphicon-comment';
|
||||
protected static $_title = 'Forums';
|
||||
|
||||
|
||||
public function init() {
|
||||
$this->setIconClass(self::$_icon_class);
|
||||
$this->setTitle(Zira\Locale::t(self::$_title));
|
||||
$this->setViewSwitcherEnabled(false);
|
||||
$this->setSelectionLinksEnabled(true);
|
||||
$this->setBodyViewListVertical(true);
|
||||
|
||||
$this->setCreateActionText(Zira\Locale::tm('New forum', 'forum'));
|
||||
|
||||
$this->setOnCreateItemJSCallback(
|
||||
$this->createJSCallback('desk_call(dash_forum_forum_create, this);')
|
||||
);
|
||||
$this->setOnEditItemJSCallback(
|
||||
$this->createJSCallback('desk_call(dash_forum_forum_edit, this);')
|
||||
);
|
||||
|
||||
$this->setOnSelectJSCallback(
|
||||
$this->createJSCallback('desk_call(dash_forum_forums_select, this);')
|
||||
);
|
||||
|
||||
$this->setDeleteActionEnabled(true);
|
||||
}
|
||||
|
||||
public function create() {
|
||||
$this->addDefaultSidebarItem(
|
||||
$this->createSidebarItem(Zira\Locale::t('Categories'), 'glyphicon glyphicon-folder-close', 'desk_call(dash_forum_categories, this)', 'create')
|
||||
);
|
||||
$this->addDefaultSidebarItem(
|
||||
$this->createSidebarItem(Zira\Locale::t('Threads'), 'glyphicon glyphicon-comment', 'desk_call(dash_forum_threads, this)', 'edit')
|
||||
);
|
||||
|
||||
$this->addDefaultMenuDropdownItem(
|
||||
$this->createMenuDropdownSeparator()
|
||||
);
|
||||
$this->addDefaultMenuDropdownItem(
|
||||
$this->createMenuDropdownItem(Zira\Locale::tm('Forum threads', 'forum'), 'glyphicon glyphicon-comment', 'desk_call(dash_forum_threads, this);', 'edit', true, array('typo'=>'threads'))
|
||||
);
|
||||
$this->addDefaultMenuDropdownItem(
|
||||
$this->createMenuDropdownSeparator()
|
||||
);
|
||||
$this->addDefaultMenuDropdownItem(
|
||||
$this->createMenuDropdownItem(Zira\Locale::tm('Open forum page', 'forum'), 'glyphicon glyphicon-new-window', 'desk_call(dash_forum_page, this);', 'edit', true, array('typo'=>'page'))
|
||||
);
|
||||
|
||||
$this->addDefaultContextMenuItem(
|
||||
$this->createContextMenuSeparator()
|
||||
);
|
||||
$this->addDefaultContextMenuItem(
|
||||
$this->createContextMenuItem(Zira\Locale::tm('Forum threads', 'forum'), 'glyphicon glyphicon-comment', 'desk_call(dash_forum_threads, this);', 'edit', true, array('typo'=>'threads'))
|
||||
);
|
||||
$this->addDefaultContextMenuItem(
|
||||
$this->createContextMenuSeparator()
|
||||
);
|
||||
$this->addDefaultContextMenuItem(
|
||||
$this->createContextMenuItem(Zira\Locale::tm('Open forum page', 'forum'), 'glyphicon glyphicon-new-window', 'desk_call(dash_forum_page, this);', 'edit', true, array('typo'=>'page'))
|
||||
);
|
||||
|
||||
$category_menu = array(
|
||||
$this->createMenuDropdownItem(Zira\Locale::t('Edit'), 'glyphicon glyphicon-pencil', 'desk_call(dash_forum_categories, this);', 'create')
|
||||
);
|
||||
|
||||
$this->setMenuItems(array(
|
||||
$this->createMenuItem($this->_default_menu_title, $this->getDefaultMenuDropdown()),
|
||||
$this->createMenuItem(Zira\Locale::t('Categories'), $category_menu)
|
||||
));
|
||||
|
||||
$this->addDefaultToolbarItem(
|
||||
$this->createToolbarButton(null, Zira\Locale::tm('Forum settings', 'forum'), 'glyphicon glyphicon-cog', 'desk_call(dash_forum_settings, this);', 'settings', false, true)
|
||||
);
|
||||
|
||||
$this->setOnOpenJSCallback(
|
||||
$this->createJSCallback('desk_call(dash_forum_forums_drag, this);')
|
||||
);
|
||||
|
||||
$this->addDefaultOnLoadScript('desk_call(dash_forum_forums_load, this);');
|
||||
|
||||
$this->addVariables(array(
|
||||
'dash_forum_route' => Forum\Forum::ROUTE,
|
||||
'dash_forum_categories_wnd' => Dash\Dash::getInstance()->getWindowJSName(Categories::getClass()),
|
||||
'dash_forum_forum_wnd' => Dash\Dash::getInstance()->getWindowJSName(Forum\Windows\Forum::getClass()),
|
||||
'dash_forum_threads_wnd' => Dash\Dash::getInstance()->getWindowJSName(Forum\Windows\Topics::getClass()),
|
||||
'dash_forum_thread_wnd' => Dash\Dash::getInstance()->getWindowJSName(Forum\Windows\Topic::getClass()),
|
||||
'dash_forum_messages_wnd' => Dash\Dash::getInstance()->getWindowJSName(Forum\Windows\Messages::getClass()),
|
||||
'dash_forum_message_wnd' => Dash\Dash::getInstance()->getWindowJSName(Forum\Windows\Message::getClass()),
|
||||
'dash_forum_settings_wnd' => Dash\Dash::getInstance()->getWindowJSName(Forum\Windows\Settings::getClass())
|
||||
));
|
||||
|
||||
$this->includeJS('forum/dash');
|
||||
|
||||
$this->setData(array(
|
||||
'category_id' => 0
|
||||
));
|
||||
}
|
||||
|
||||
public function load() {
|
||||
if (!Permission::check(Permission::TO_CHANGE_OPTIONS)) {
|
||||
$this->setBodyItems(array());
|
||||
return array('error'=>Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$category_id = 0;
|
||||
$category_title = '';
|
||||
$_category_id = (int)Zira\Request::post('category_id');
|
||||
|
||||
$category_menu = array(
|
||||
$this->createMenuDropdownItem(Zira\Locale::t('Edit'), 'glyphicon glyphicon-pencil', 'desk_call(dash_forum_categories, this);', 'create'),
|
||||
$this->createMenuDropdownSeparator()
|
||||
);
|
||||
|
||||
$categories = Forum\Models\Category::getCategpries();
|
||||
foreach($categories as $category) {
|
||||
if (!$_category_id) $_category_id = $category->id;
|
||||
if (!$category_id && $_category_id == $category->id) {
|
||||
$category_id = $category->id;
|
||||
$category_title = $category->title;
|
||||
}
|
||||
|
||||
if (empty($category_id) || $category_id!=$category->id) $class = 'glyphicon-filter';
|
||||
else $class = 'glyphicon-ok';
|
||||
$category_menu []= $this->createMenuDropdownItem($category->title, 'glyphicon '.$class, 'desk_call(dash_forum_category_filter, this, '.$category->id.');', 'categories', false, array('category_id'=>$category->id));
|
||||
}
|
||||
|
||||
$this->setSidebarItems($this->getDefaultSidebar());
|
||||
|
||||
$forums = Forum\Models\Forum::getCollection()
|
||||
->where('category_id','=',$category_id)
|
||||
->order_by('sort_order', 'asc')
|
||||
->get();
|
||||
|
||||
$items = array();
|
||||
foreach($forums as $forum) {
|
||||
$items[]=$this->createBodyItem($forum->title, $forum->description, Zira\Helper::imgUrl('drag.png'), $forum->id, null, false, array('sort_order'=>$forum->sort_order,'inactive'=>$forum->active ? 0 : 1, 'page'=>Forum\Models\Forum::generateUrl($forum)));
|
||||
}
|
||||
$this->setBodyItems($items);
|
||||
|
||||
$this->setMenuItems(array(
|
||||
$this->createMenuItem($this->_default_menu_title, $this->getDefaultMenuDropdown()),
|
||||
$this->createMenuItem(Zira\Locale::t('Categories'), $category_menu)
|
||||
));
|
||||
|
||||
if (!empty($category_title)) {
|
||||
$this->setTitle(Zira\Locale::t(self::$_title).' - '.$category_title);
|
||||
}
|
||||
|
||||
$this->setData(array(
|
||||
'category_id' => $category_id
|
||||
));
|
||||
}
|
||||
}
|
60
forum/windows/message.php
Normal file
60
forum/windows/message.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* message.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Windows;
|
||||
|
||||
use Zira;
|
||||
use Dash;
|
||||
use Zira\Permission;
|
||||
|
||||
class Message extends Dash\Windows\Window {
|
||||
protected static $_icon_class = 'glyphicon glyphicon-comment';
|
||||
protected static $_title = 'Topic message';
|
||||
|
||||
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() {
|
||||
$topic_id = (int)Zira\Request::post('topic_id');
|
||||
if (!$topic_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_OPTIONS)) {
|
||||
return array('error' => Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$topic = new \Forum\Models\Topic($topic_id);
|
||||
if (!$topic->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
|
||||
|
||||
$form = new \Forum\Forms\Message();
|
||||
if ($this->item) {
|
||||
$message = new \Forum\Models\Message($this->item);
|
||||
if (!$message->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
|
||||
$form->setValues($message->toArray());
|
||||
} else {
|
||||
$form->setValues(array('topic_id'=>$topic_id));
|
||||
}
|
||||
|
||||
$this->setTitle(Zira\Locale::t(self::$_title) . ' - '. $topic->title);
|
||||
|
||||
$this->setBodyContent($form);
|
||||
}
|
||||
}
|
103
forum/windows/messages.php
Normal file
103
forum/windows/messages.php
Normal file
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* messages.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Windows;
|
||||
|
||||
use Dash;
|
||||
use Zira;
|
||||
use Zira\Permission;
|
||||
|
||||
class Messages extends Dash\Windows\Window {
|
||||
protected static $_icon_class = 'glyphicon glyphicon-comment';
|
||||
protected static $_title = 'Topic messages';
|
||||
|
||||
public $item;
|
||||
|
||||
public $page = 0;
|
||||
public $pages = 0;
|
||||
public $order = 'desc';
|
||||
|
||||
protected $limit = 50;
|
||||
protected $total = 0;
|
||||
|
||||
public function init() {
|
||||
$this->setIconClass(self::$_icon_class);
|
||||
$this->setTitle(Zira\Locale::t(self::$_title));
|
||||
$this->setViewSwitcherEnabled(false);
|
||||
$this->setSelectionLinksEnabled(true);
|
||||
$this->setBodyViewListVertical(true);
|
||||
$this->setSidebarEnabled(false);
|
||||
|
||||
$this->setOnCreateItemJSCallback(
|
||||
$this->createJSCallback(
|
||||
'desk_call(dash_forum_message_create, this);'
|
||||
)
|
||||
);
|
||||
$this->setOnEditItemJSCallback(
|
||||
$this->createJSCallback(
|
||||
'desk_call(dash_forum_message_edit, this);'
|
||||
)
|
||||
);
|
||||
|
||||
$this->setDeleteActionEnabled(true);
|
||||
}
|
||||
|
||||
public function create() {
|
||||
$this->setData(array(
|
||||
'items' => array($this->item),
|
||||
'page'=>$this->page,
|
||||
'pages'=>$this->pages,
|
||||
'order'=>$this->order,
|
||||
));
|
||||
}
|
||||
|
||||
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_OPTIONS)) {
|
||||
$this->setBodyItems(array());
|
||||
return array('error'=>Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$topic = new \Forum\Models\Topic($this->item);
|
||||
if (!$topic->loaded()) return array('error'=>Zira\Locale::t('An error occurred'));
|
||||
|
||||
$this->total = \Forum\Models\Message::getCollection()
|
||||
->count()
|
||||
->where('topic_id','=',$topic->id)
|
||||
->get('co');
|
||||
|
||||
$this->pages = ceil($this->total / $this->limit);
|
||||
if ($this->page > $this->pages) $this->page = $this->pages;
|
||||
if ($this->page < 1) $this->page = 1;
|
||||
|
||||
$messages = \Forum\Models\Message::getCollection()
|
||||
->select(\Forum\Models\Message::getFields())
|
||||
->left_join(Zira\Models\User::getClass(), array('user_login'=>'username'))
|
||||
->where('topic_id','=',$topic->id)
|
||||
->order_by('id', $this->order)
|
||||
->limit($this->limit, ($this->page - 1) * $this->limit)
|
||||
->get();
|
||||
|
||||
$items = array();
|
||||
foreach($messages as $message) {
|
||||
$content = Zira\Helper::html($message->content);
|
||||
$username = $message->user_login ? $message->user_login : Zira\Locale::tm('User deleted', 'forum');
|
||||
$items[]=$this->createBodyFileItem($content, $username, $message->id, null, false, array('type'=>'txt'));
|
||||
}
|
||||
$this->setBodyItems($items);
|
||||
|
||||
$this->setTitle(Zira\Locale::t(self::$_title).' - '.$topic->title);
|
||||
|
||||
$this->setData(array(
|
||||
'items' => array($this->item),
|
||||
'page'=>$this->page,
|
||||
'pages'=>$this->pages,
|
||||
'order'=>$this->order
|
||||
));
|
||||
}
|
||||
}
|
51
forum/windows/settings.php
Normal file
51
forum/windows/settings.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* settings.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Windows;
|
||||
|
||||
use Zira;
|
||||
use Dash;
|
||||
use Zira\Permission;
|
||||
|
||||
class Settings extends Dash\Windows\Window {
|
||||
protected static $_icon_class = 'glyphicon glyphicon-cog';
|
||||
protected static $_title = 'Forum settings';
|
||||
|
||||
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_OPTIONS)) {
|
||||
return array('error' => Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$configs = Zira\Config::getArray();
|
||||
|
||||
$form = new \Forum\Forms\Settings();
|
||||
if (!array_key_exists('forum_limit', $configs)) $configs['forum_limit'] = 10;
|
||||
if (!array_key_exists('forum_min_chars', $configs)) $configs['forum_min_chars'] = 10;
|
||||
$form->setValues($configs);
|
||||
|
||||
$this->setBodyContent($form);
|
||||
}
|
||||
}
|
65
forum/windows/topic.php
Normal file
65
forum/windows/topic.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* topic.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Windows;
|
||||
|
||||
use Zira;
|
||||
use Dash;
|
||||
use Zira\Permission;
|
||||
|
||||
class Topic extends Dash\Windows\Window {
|
||||
protected static $_icon_class = 'glyphicon glyphicon-comment';
|
||||
protected static $_title = 'Forum thread';
|
||||
|
||||
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() {
|
||||
$category_id = (int)Zira\Request::post('category_id');
|
||||
$forum_id = (int)Zira\Request::post('forum_id');
|
||||
if (!$category_id || !$forum_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_OPTIONS)) {
|
||||
return array('error' => Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$forum = new \Forum\Models\Forum($forum_id);
|
||||
if (!$forum->loaded() || $forum->category_id!=$category_id) return array('error' => Zira\Locale::t('An error occurred'));
|
||||
|
||||
$form = new \Forum\Forms\Topic();
|
||||
if (!empty($this->item)) {
|
||||
$thread = new \Forum\Models\Topic($this->item);
|
||||
if (!$thread->loaded()) return array('error' => Zira\Locale::t('An error occurred'));
|
||||
$form->setValues($thread->toArray());
|
||||
} else {
|
||||
$form->setValues(array(
|
||||
'category_id' => $category_id,
|
||||
'forum_id' => $forum_id,
|
||||
'active' => 1
|
||||
));
|
||||
}
|
||||
|
||||
$this->setTitle(Zira\Locale::tm(self::$_title,'forum').' - '.$forum->title);
|
||||
|
||||
$this->setBodyContent($form);
|
||||
}
|
||||
}
|
133
forum/windows/topics.php
Normal file
133
forum/windows/topics.php
Normal file
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* threads.php
|
||||
* (c)2016 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Forum\Windows;
|
||||
|
||||
use Dash;
|
||||
use Zira;
|
||||
use Zira\Permission;
|
||||
|
||||
class Topics extends Dash\Windows\Window {
|
||||
protected static $_icon_class = 'glyphicon glyphicon-comment';
|
||||
protected static $_title = 'Forum threads';
|
||||
|
||||
public $item;
|
||||
|
||||
public $page = 0;
|
||||
public $pages = 0;
|
||||
public $order = 'desc';
|
||||
|
||||
protected $limit = 50;
|
||||
protected $total = 0;
|
||||
|
||||
public function init() {
|
||||
$this->setIconClass(self::$_icon_class);
|
||||
$this->setTitle(Zira\Locale::t(self::$_title));
|
||||
$this->setViewSwitcherEnabled(false);
|
||||
$this->setSelectionLinksEnabled(true);
|
||||
$this->setBodyViewListVertical(true);
|
||||
$this->setSidebarEnabled(false);
|
||||
|
||||
$this->setOnCreateItemJSCallback(
|
||||
$this->createJSCallback(
|
||||
'desk_call(dash_forum_thread_create, this);'
|
||||
)
|
||||
);
|
||||
$this->setOnEditItemJSCallback(
|
||||
$this->createJSCallback(
|
||||
'desk_call(dash_forum_thread_edit, this);'
|
||||
)
|
||||
);
|
||||
|
||||
$this->setDeleteActionEnabled(true);
|
||||
}
|
||||
|
||||
public function create() {
|
||||
$this->addDefaultMenuDropdownItem(
|
||||
$this->createMenuDropdownSeparator()
|
||||
);
|
||||
$this->addDefaultMenuDropdownItem(
|
||||
$this->createMenuDropdownItem(Zira\Locale::tm('Topic messages', 'forum'), 'glyphicon glyphicon-comment', 'desk_call(dash_forum_messages, this);', 'edit', true, array('typo'=>'messages'))
|
||||
);
|
||||
$this->addDefaultMenuDropdownItem(
|
||||
$this->createMenuDropdownSeparator()
|
||||
);
|
||||
$this->addDefaultMenuDropdownItem(
|
||||
$this->createMenuDropdownItem(Zira\Locale::tm('Open thread page', 'forum'), 'glyphicon glyphicon-new-window', 'desk_call(dash_forum_page, this);', 'edit', true, array('typo'=>'page'))
|
||||
);
|
||||
|
||||
$this->addDefaultContextMenuItem(
|
||||
$this->createContextMenuSeparator()
|
||||
);
|
||||
$this->addDefaultContextMenuItem(
|
||||
$this->createContextMenuItem(Zira\Locale::tm('Topic messages', 'forum'), 'glyphicon glyphicon-comment', 'desk_call(dash_forum_messages, this);', 'edit', true, array('typo'=>'messages'))
|
||||
);
|
||||
$this->addDefaultContextMenuItem(
|
||||
$this->createContextMenuSeparator()
|
||||
);
|
||||
$this->addDefaultContextMenuItem(
|
||||
$this->createContextMenuItem(Zira\Locale::tm('Open thread page', 'forum'), 'glyphicon glyphicon-new-window', 'desk_call(dash_forum_page, this);', 'edit', true, array('typo'=>'page'))
|
||||
);
|
||||
|
||||
$this->includeJS('forum/dash');
|
||||
|
||||
$this->setData(array(
|
||||
'items' => array($this->item),
|
||||
'page'=>$this->page,
|
||||
'pages'=>$this->pages,
|
||||
'order'=>$this->order,
|
||||
'category_id'=>0
|
||||
));
|
||||
}
|
||||
|
||||
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_OPTIONS)) {
|
||||
$this->setBodyItems(array());
|
||||
return array('error'=>Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$forum = new \Forum\Models\Forum($this->item);
|
||||
if (!$forum->loaded()) return array('error'=>Zira\Locale::t('An error occurred'));
|
||||
|
||||
$this->total = \Forum\Models\Topic::getCollection()
|
||||
->count()
|
||||
->where('category_id','=',$forum->category_id)
|
||||
->and_where('forum_id','=',$forum->id)
|
||||
->get('co');
|
||||
|
||||
$this->pages = ceil($this->total / $this->limit);
|
||||
if ($this->page > $this->pages) $this->page = $this->pages;
|
||||
if ($this->page < 1) $this->page = 1;
|
||||
|
||||
$threads = \Forum\Models\Topic::getCollection()
|
||||
->where('category_id','=',$forum->category_id)
|
||||
->and_where('forum_id','=',$forum->id)
|
||||
->order_by('id', $this->order)
|
||||
->limit($this->limit, ($this->page - 1) * $this->limit)
|
||||
->get();
|
||||
|
||||
$items = array();
|
||||
foreach($threads as $thread) {
|
||||
$title = Zira\Helper::html($thread->title);
|
||||
$description = Zira\Helper::html($thread->description);
|
||||
$items[]=$this->createBodyFileItem($title, $description, $thread->id, null, false, array('type'=>'txt', 'page'=>\Forum\Models\Topic::generateUrl($thread)));
|
||||
}
|
||||
$this->setBodyItems($items);
|
||||
|
||||
$this->setTitle(Zira\Locale::t(self::$_title).' - '.$forum->title);
|
||||
|
||||
$this->setData(array(
|
||||
'items' => array($this->item),
|
||||
'page'=>$this->page,
|
||||
'pages'=>$this->pages,
|
||||
'order'=>$this->order,
|
||||
'category_id'=>$forum->category_id
|
||||
));
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
return array(
|
||||
'Email forms' => 'Формы отправки почты',
|
||||
'Add email forms to your website' => 'Добавьте почтовые формы в свой сайт',
|
||||
'Email forms' => 'Почтовые формы',
|
||||
'Accept email messages from your website' => 'Принимайте почтовые сообщения с вашего сайта',
|
||||
'Form fields' => 'Поля формы',
|
||||
'Email form' => 'Форма отправки почты',
|
||||
'New email form' => 'Новая форма отправки почты',
|
||||
|
|
47
languages/ru/forum.php
Normal file
47
languages/ru/forum.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
return array(
|
||||
'Forum' => 'Форум',
|
||||
'Forums' => 'Форумы',
|
||||
'Simple and lightweight forum' => 'Простой и легкий форум',
|
||||
'Default category' => 'Категория по-умолчанию',
|
||||
'Default forum' => 'Форум по-умолчанию',
|
||||
'Forum categories' => 'Категории форумов',
|
||||
'Forum category' => 'Категория форума',
|
||||
'New forum category' => 'Новая категория форума',
|
||||
'Meta description' => 'Мета описание',
|
||||
'New forum' => 'Новый форум',
|
||||
'Information message' => 'Информационное сообщение',
|
||||
'Category "%s" has forums.' => 'Категория "%s" имеет форумы',
|
||||
'Forum "%s" has topics.' => 'Форум "%s" имеет темы',
|
||||
'Forum activated' => 'Форум активен',
|
||||
'Open forum page' => 'Открыть страницу форума',
|
||||
'Open thread page' => 'Открыть страницу темы',
|
||||
'Forum settings' => 'Настройки форума',
|
||||
'User deleted' => 'Пользователь удален',
|
||||
'Forum threads' => 'Темы форума',
|
||||
'Forum thread' => 'Тема форума',
|
||||
'Thread is open' => 'Тема открыта',
|
||||
'Status' => 'Статус',
|
||||
'Default' => 'По-умолчанию',
|
||||
'Solved' => 'Решено',
|
||||
'Denied' => 'Отклонено',
|
||||
'Threads' => 'Темы',
|
||||
'Thread is closed' => 'Тема закрыта',
|
||||
'Posts: %s' => 'Сообщений: %s',
|
||||
'Message min. length' => 'Мин. длина сообщения',
|
||||
'New thread' => 'Новая тема',
|
||||
'Title' => 'Заголовок',
|
||||
'Invalid thread title' => 'Некорректный заголовок темы',
|
||||
'Link' => 'Ссылка',
|
||||
'Threads: %s' => 'Тем: %s',
|
||||
'Messages: %s' => 'Сообщений: %s',
|
||||
'Topic messages' => 'Сообщения темы',
|
||||
'Topic message' => 'Сообщение темы',
|
||||
'Information' => 'Информация',
|
||||
'Message' => 'Сообщение',
|
||||
'Warning' => 'Предупреждение',
|
||||
'Edited by moderator' => 'Отредактировано модератором',
|
||||
'%s to reply' => '%s, чтобы ответить',
|
||||
'Thread is sticky' => 'Тема закреплена'
|
||||
);
|
|
@ -647,7 +647,9 @@ article .rating .share-wrapper .share-btn {
|
|||
overflow: hidden;
|
||||
}
|
||||
.list .list-item a.list-title:link,
|
||||
.list .list-item a.list-title:visited {
|
||||
.list .list-item a.list-title:visited,
|
||||
.list .list-item .list-title-wrapper a:link,
|
||||
.list .list-item .list-title-wrapper a:visited {
|
||||
font-size: 18px;
|
||||
margin: 0px 0px 5px;
|
||||
text-shadow: 1px 1px 0px #ffffff;
|
||||
|
@ -819,6 +821,10 @@ article .rating .share-wrapper .share-btn {
|
|||
background-color: #FBFBFB;
|
||||
border-radius: 0px;
|
||||
}
|
||||
.parse-content q:before,
|
||||
.parse-content q:after {
|
||||
content: '';
|
||||
}
|
||||
blockquote {
|
||||
color: #757D93;
|
||||
font-size: 100%;
|
||||
|
@ -1155,6 +1161,7 @@ a.scroll-top.visible:visited {
|
|||
display: inline-block;
|
||||
vertical-align: top;
|
||||
margin-right: 1%;
|
||||
margin-right: 0\9; /** ie8 hack **/
|
||||
}
|
||||
.grid-category-wrapper .list .list-item:nth-child(2) {
|
||||
margin-right: 0px;
|
||||
|
|
|
@ -63,7 +63,8 @@ dt {
|
|||
}
|
||||
.breadcrumb {
|
||||
padding: 10px 15px;
|
||||
background-color: #ececec;
|
||||
background: #EFEFEF;
|
||||
background: rgba(239, 239, 239, 0.7);
|
||||
}
|
||||
.page-header {
|
||||
border-bottom: 1px solid #DBDCEA;
|
||||
|
@ -688,7 +689,9 @@ article .rating .share-wrapper .share-btn {
|
|||
overflow: hidden;
|
||||
}
|
||||
.list .list-item a.list-title:link,
|
||||
.list .list-item a.list-title:visited {
|
||||
.list .list-item a.list-title:visited,
|
||||
.list .list-item .list-title-wrapper a:link,
|
||||
.list .list-item .list-title-wrapper a:visited {
|
||||
font-size: 18px;
|
||||
margin: 0px 0px 5px;
|
||||
text-shadow: 1px 1px 0px #ffffff;
|
||||
|
@ -863,6 +866,10 @@ article .rating .share-wrapper .share-btn {
|
|||
background-color: #F8F8F8;
|
||||
border-radius: 0px;
|
||||
}
|
||||
.parse-content q:before,
|
||||
.parse-content q:after {
|
||||
content: '';
|
||||
}
|
||||
blockquote {
|
||||
color: #6E7899;
|
||||
font-size: 100%;
|
||||
|
@ -875,6 +882,17 @@ pre {
|
|||
border: 1px solid #eee;
|
||||
}
|
||||
/** sidebar **/
|
||||
.sidebar.col-sm-4 {
|
||||
background: #EFEFEF;
|
||||
background: rgba(239, 239, 239, 0.7);
|
||||
border-radius: 7px;
|
||||
padding-top: 15px;
|
||||
padding-bottom: 15px;
|
||||
min-height: 43px;
|
||||
}
|
||||
.sidebar.col-sm-4 > aside > div:last-child {
|
||||
margin-bottom: 0px !important;
|
||||
}
|
||||
.sidebar .page-header {
|
||||
margin: 0px;
|
||||
padding-bottom: 4px;
|
||||
|
@ -929,6 +947,11 @@ pre {
|
|||
display: block;
|
||||
}
|
||||
/** secondary menu **/
|
||||
.sidebar.col-sm-4 #secondary-menu-wrapper {
|
||||
margin-top: -15px;
|
||||
margin-left: -15px;
|
||||
margin-right: -15px;
|
||||
}
|
||||
#secondary-menu-wrapper {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
@ -938,7 +961,7 @@ pre {
|
|||
color: #333333;
|
||||
}
|
||||
#secondary-menu-wrapper ul li a:hover {
|
||||
background-color: #f5f5f5;
|
||||
background-color: #E1E8EA;
|
||||
color: #337AB7;
|
||||
}
|
||||
#secondary-menu-wrapper ul li.active a {
|
||||
|
@ -1203,6 +1226,7 @@ a.scroll-top.visible:visited {
|
|||
display: inline-block;
|
||||
vertical-align: top;
|
||||
margin-right: 1%;
|
||||
margin-right: 0\9; /** ie8 hack **/
|
||||
}
|
||||
.grid-category-wrapper .list .list-item:nth-child(2) {
|
||||
margin-right: 0px;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</p>
|
||||
<?php endif; ?>
|
||||
<?php if (isset($content)): ?>
|
||||
<div class="article<?php if (!empty($class)) echo ' '.$class ?>">
|
||||
<div class="article eform<?php if (!empty($class)) echo ' '.$class ?>">
|
||||
<?php echo $content; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
|
24
themes/default/forum/group.php
Normal file
24
themes/default/forum/group.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php if (!empty($items)): ?>
|
||||
<ul class="forum-list list">
|
||||
<?php $co = 0; ?>
|
||||
<?php foreach($items as $item): ?>
|
||||
<li class="list-item no-thumb <?php echo ($co%2==0 ? 'odd-b' : 'even-b') ?>">
|
||||
<?php $ticon = date('Y-m-d', strtotime($item->date_modified)) == date('Y-m-d') ? '<span class="glyphicon glyphicon-flag"></span> ' : ''; ?>
|
||||
<h3 class="list-title-wrapper">
|
||||
<a class="list-title" href="<?php echo Zira\Helper::html(Zira\Helper::url(Forum\Models\Forum::generateUrl($item))) ?>" title="<?php echo Zira\Helper::html($item->title) ?>"><?php echo $ticon ?><?php echo Zira\Helper::html($item->title) ?></a>
|
||||
</h3>
|
||||
<div class="list-content-wrapper">
|
||||
<p><?php echo Zira\Helper::nl2br(Zira\Helper::html($item->description)) ?></p>
|
||||
</div>
|
||||
<div class="list-info-wrapper">
|
||||
<span class="list-info date"><span class="glyphicon glyphicon-time"></span> <?php echo date(Zira\Config::get('date_format'), strtotime($item->date_modified)) ?></span>
|
||||
<?php if ($item->last_user_id && $item->user_username): ?>
|
||||
<span class="list-info author"><span class="glyphicon glyphicon-user"></span> <?php echo Zira\User::generateUserProfileLink($item->last_user_id, $item->user_firstname, $item->user_secondname, $item->user_username) ?></span>
|
||||
<?php endif; ?>
|
||||
<span class="list-info counter"><span class="glyphicon glyphicon-comment"></span> <?php echo Zira\Helper::html(tm('Threads: %s', 'forum', $item->topics)) ?></span>
|
||||
</div>
|
||||
</li>
|
||||
<?php $co++; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
9
themes/default/forum/index.php
Normal file
9
themes/default/forum/index.php
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php if (!empty($categories)): ?>
|
||||
<?php foreach($categories as $category): ?>
|
||||
<?php if (!$category->forums || count($category->forums)==0) continue; ?>
|
||||
<div class="page-header forum-page-header">
|
||||
<h2 class="forum-category-title"><a href="<?php echo Zira\Helper::html(Zira\Helper::url(Forum\Models\Category::generateUrl($category))) ?>" title="<?php echo Zira\Helper::html($category->title) ?>"><span class="glyphicon glyphicon-link"></span> <?php echo Zira\Helper::html($category->title) ?></a></h2>
|
||||
</div>
|
||||
<?php Zira\View::renderView(array('items'=>$category->forums), 'forum/group'); ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
19
themes/default/forum/page.php
Normal file
19
themes/default/forum/page.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<main>
|
||||
<article>
|
||||
<?php if (!empty($title)): ?>
|
||||
<div class="page-header forum-page-title">
|
||||
<h1><?php if (!empty($label)) echo '<span class="label label-warning forum-label">'.Zira\Helper::html($label).'</span>'; ?><?php echo Zira\Helper::html($title) ?></h1>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($description)): ?>
|
||||
<p class="description">
|
||||
<?php echo nl2br(Zira\Helper::html($description)); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<?php if (isset($content)): ?>
|
||||
<div class="article forum<?php if (!empty($class)) echo ' '.$class ?>">
|
||||
<?php echo $content; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</article>
|
||||
</main>
|
100
themes/default/forum/thread.php
Normal file
100
themes/default/forum/thread.php
Normal file
|
@ -0,0 +1,100 @@
|
|||
<?php if (!empty($info)): ?>
|
||||
<div class="alert alert-info forum-info" role="alert"><span class="glyphicon glyphicon-info-sign"></span> <?php echo Zira\Helper::nl2br(Zira\Helper::html($info)) ?></div>
|
||||
<?php endif; ?>
|
||||
<div class="messages-panel forum-messages-panel">
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#user-messages-panel" aria-expanded="false">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="<?php echo Zira\Helper::html(Zira\Helper::url($forum_url)) ?>"><span class="glyphicon glyphicon-share-alt"></span> <?php echo Zira\Helper::html(t($forum_title)) ?></a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="user-messages-panel">
|
||||
<?php if (isset($form) && !empty($topic_active)): ?>
|
||||
<button onclick="zira_scroll_to_forum_form()" class="btn btn-default navbar-btn navbar-right reply-btn"><span class="glyphicon glyphicon-pencil"></span> <?php echo t('Reply') ?></button>
|
||||
<?php endif; ?>
|
||||
<?php if (isset($form) && empty($topic_active)): ?>
|
||||
<button class="btn btn-default navbar-btn navbar-right disabled" title="<?php echo tm('Thread is closed','forum') ?>"><span class="glyphicon glyphicon-lock"></span></button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($items)): ?>
|
||||
<ul class="forum-list list">
|
||||
<?php $co = 0; ?>
|
||||
<?php foreach($items as $item): ?>
|
||||
<li id="forum-message-<?php echo $item->id; ?>" class="list-item no-thumb <?php echo ($co%2==0 ? 'odd' : 'even') ?>">
|
||||
<h3 class="list-title-wrapper">
|
||||
<?php if (isset($form) && !empty($topic_active)): ?>
|
||||
<a href="javascript:void(0)" class="forum-reply-inline forum-right-item"><span class="glyphicon glyphicon-pencil"></span> <?php echo tm('Reply', 'forum') ?></a>
|
||||
<?php endif; ?>
|
||||
<?php if ($item->user_username): ?>
|
||||
<?php echo Zira\User::generateUserProfileLink($item->creator_id, $item->user_firstname, $item->user_secondname, $item->user_username, 'author') ?>
|
||||
<?php else: ?>
|
||||
<?php echo tm('User deleted', 'forum'); ?>
|
||||
<?php endif; ?>
|
||||
</h3>
|
||||
<div class="list-content-wrapper forum-message-wrapper">
|
||||
<div class="forum-avatar-wrapper">
|
||||
<?php if ($item->user_username): ?>
|
||||
<?php echo Zira\User::generateUserProfileThumbLink($item->creator_id, $item->user_firstname, $item->user_secondname, $item->user_username, null, $item->user_image, null, array('class'=>'forum-avatar')) ?>
|
||||
<?php else: ?>
|
||||
<?php echo Zira\User::generateUserProfileThumb($item->user_image, null, array('class'=>'forum-avatar')) ?>
|
||||
<?php endif; ?>
|
||||
<div class="forum-user-info">
|
||||
<?php $user_group_name = !empty($user_groups) && $item->user_group_id && array_key_exists($item->user_group_id, $user_groups) ? $user_groups[$item->user_group_id] : ''; ?>
|
||||
<?php if (!empty($user_group_name) && $item->user_group_id == Zira\User::GROUP_SUPERADMIN) $user_group_name = '<span class="forum-group-super-admin">'.$user_group_name.'</span>'; ?>
|
||||
<?php if (!empty($user_group_name) && $item->user_group_id == Zira\User::GROUP_ADMIN) $user_group_name = '<span class="forum-group-admin">'.$user_group_name.'</span>'; ?>
|
||||
<?php if (!empty($user_group_name)) echo '<div>'.$user_group_name.'</div>' ?>
|
||||
<?php if ($item->user_posts) echo '<div>'.tm('Posts: %s', 'forum', $item->user_posts).'</div>' ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php $mclass = ''; ?>
|
||||
<?php if ($item->status == Forum\Models\Message::STATUS_MESSAGE) $mclass = ' alert alert-success'; ?>
|
||||
<?php if ($item->status == Forum\Models\Message::STATUS_INFO) $mclass = ' alert alert-info'; ?>
|
||||
<?php if ($item->status == Forum\Models\Message::STATUS_WARNING) $mclass = ' alert alert-danger'; ?>
|
||||
<?php $micon = ''; ?>
|
||||
<?php if ($item->status == Forum\Models\Message::STATUS_MESSAGE) $micon = '<span class="glyphicon glyphicon-info-sign"></span> '; ?>
|
||||
<?php if ($item->status == Forum\Models\Message::STATUS_INFO) $micon = '<span class="glyphicon glyphicon-exclamation-sign"></span> '; ?>
|
||||
<?php if ($item->status == Forum\Models\Message::STATUS_WARNING) $micon = '<span class="glyphicon glyphicon-warning-sign"></span> '; ?>
|
||||
<p class="parse-content forum-message<?php echo $mclass ?>"><?php echo $micon ?><?php echo Zira\Content\Parse::bbcode(Zira\Helper::nl2br(Zira\Helper::html($item->content))) ?></p>
|
||||
</div>
|
||||
<div class="list-info-wrapper forum-info-wrapper">
|
||||
<a class="list-info link" href="<?php echo Zira\Helper::url($topic_url.($topic_page>1 ? '?page='.$topic_page : '').'#forum-message-'.$item->id) ?>" title="<?php echo tm('Link','forum') ?>"><span class="glyphicon glyphicon-new-window"></span></a>
|
||||
<?php if ($item->modified_by): ?>
|
||||
<span class="list-info note" title="<?php echo tm('Edited by moderator', 'forum') ?>"><span class="glyphicon glyphicon-warning-sign"></span></span>
|
||||
<?php endif; ?>
|
||||
<span class="list-info date"><span class="glyphicon glyphicon-time"></span> <?php echo date(Zira\Config::get('date_format'), strtotime($item->date_modified)) ?></span>
|
||||
<a href="javascript:void(0)" class="list-info forum-rating forum-like" data-value="1" data-type="forum_message" data-id="<?php echo intval($item->id) ?>" data-token="<?php echo Zira\User::getToken() ?>" data-url="<?php echo Zira\Helper::url('forum/poll') ?>">
|
||||
<span class="glyphicon glyphicon-thumbs-up"></span>
|
||||
</a>
|
||||
<a href="javascript:void(0)" class="list-info forum-rating forum-dislike" data-value="-1" data-type="forum_message" data-id="<?php echo intval($item->id) ?>" data-token="<?php echo Zira\User::getToken() ?>" data-url="<?php echo Zira\Helper::url('forum/poll') ?>">
|
||||
<span class="glyphicon glyphicon-thumbs-down"></span>
|
||||
</a>
|
||||
<?php $rating = intval($item->rating); ?>
|
||||
<?php if ($rating>0) $rating = '<span class="positive-rating">+'.$rating.'</span>'; ?>
|
||||
<?php if ($rating<0) $rating = '<span class="negative-rating">'.$rating.'</span>'; ?>
|
||||
<span class="list-info forum-rating-value"><?php echo $rating; ?></span>
|
||||
</div>
|
||||
</li>
|
||||
<?php $co++; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php if (isset($pagination)) echo $pagination ?>
|
||||
<?php endif; ?>
|
||||
<?php if (isset($form) && !empty($topic_active)) echo $form; ?>
|
||||
<?php if (empty($topic_active)) echo '<span class="label label-danger forum-label forum-bottom-label"><span class="glyphicon glyphicon-warning-sign"></span> '.tm('Thread is closed','forum').'</span>' ?>
|
||||
<?php if (!isset($form) && !empty($topic_active) && !Zira\User::isAuthorized()): ?>
|
||||
<?php echo tm('%s to reply', 'forum', '<a href="'.Zira\Helper::url('user/login?redirect='.$topic_url).'">'.t('Login').'</a>') ?>
|
||||
<?php endif; ?>
|
||||
<script type="text/javascript">
|
||||
zira_scroll_to_forum_form = function() {
|
||||
var top = $('.container #content form#form-forum-message-form').parents('.form-panel').offset().top;
|
||||
$('html, body').animate({'scrollTop':top},800);
|
||||
};
|
||||
</script>
|
70
themes/default/forum/threads.php
Normal file
70
themes/default/forum/threads.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php if (!empty($info)): ?>
|
||||
<div class="alert alert-info forum-info" role="alert"><span class="glyphicon glyphicon-info-sign"></span> <?php echo Zira\Helper::nl2br(Zira\Helper::html($info)) ?></div>
|
||||
<?php endif; ?>
|
||||
<div class="messages-panel forum-messages-panel">
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#user-messages-panel" aria-expanded="false">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="<?php echo Zira\Helper::html(Zira\Helper::url($category_url)) ?>"><span class="glyphicon glyphicon-share-alt"></span> <?php echo Zira\Helper::html(t($category_title)) ?></a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="user-messages-panel">
|
||||
<a href="<?php echo Zira\Helper::html(Zira\Helper::url($compose_url)) ?>" class="btn btn-default navbar-btn navbar-right forum-btn"><span class="glyphicon glyphicon-plus-sign"></span> <?php echo tm('New thread','forum') ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($top_items)): ?>
|
||||
<ul class="forum-list forum-top-list list">
|
||||
<?php $co = 0; ?>
|
||||
<?php foreach($top_items as $item): ?>
|
||||
<li class="list-item no-thumb <?php echo ($co%2==0 ? 'odd-b' : 'even-b') ?>">
|
||||
<?php $ticon = $item->active && date('Y-m-d', strtotime($item->date_modified)) == date('Y-m-d') ? '<span class="glyphicon glyphicon-flag"></span> ' : ''; ?>
|
||||
<h3 class="list-title-wrapper">
|
||||
<span class="glyphicon glyphicon-pushpin forum-right-item"></span>
|
||||
<?php $title_ico = $item->active ? 'thread-open' : 'glyphicon glyphicon-lock'; ?>
|
||||
<?php $status = $item->status ? '['.Forum\Models\Topic::getStatus($item->status).'] ' : '' ?>
|
||||
<a class="list-title" href="<?php echo Zira\Helper::html(Zira\Helper::url(Forum\Models\Topic::generateUrl($item))) ?>" title="<?php echo Zira\Helper::html($item->title) ?>"><?php echo $ticon ?><span class="<?php echo $title_ico ?>"></span> <?php echo Zira\Helper::html($status.$item->title) ?></a>
|
||||
</h3>
|
||||
<div class="list-info-wrapper">
|
||||
<span class="list-info date"><span class="glyphicon glyphicon-time"></span> <?php echo date(Zira\Config::get('date_format'), strtotime($item->date_modified)) ?></span>
|
||||
<?php if ($item->last_user_id && $item->user_username): ?>
|
||||
<span class="list-info author"><span class="glyphicon glyphicon-user"></span> <?php echo Zira\User::generateUserProfileLink($item->last_user_id, $item->user_firstname, $item->user_secondname, $item->user_username) ?></span>
|
||||
<?php endif; ?>
|
||||
<span class="list-info counter"><span class="glyphicon glyphicon-comment"></span> <?php echo Zira\Helper::html(tm('Messages: %s', 'forum', $item->messages)) ?></span>
|
||||
</div>
|
||||
</li>
|
||||
<?php $co++; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($items)): ?>
|
||||
<ul class="forum-list list">
|
||||
<?php $co = 0; ?>
|
||||
<?php foreach($items as $item): ?>
|
||||
<li class="list-item no-thumb <?php echo ($co%2==0 ? 'odd-b' : 'even-b') ?>">
|
||||
<?php $ticon = $item->active && date('Y-m-d', strtotime($item->date_modified)) == date('Y-m-d') ? '<span class="glyphicon glyphicon-flag"></span> ' : ''; ?>
|
||||
<h3 class="list-title-wrapper">
|
||||
<?php $title_ico = $item->active ? 'thread-open' : 'glyphicon glyphicon-lock'; ?>
|
||||
<?php $status = $item->status ? '['.Forum\Models\Topic::getStatus($item->status).'] ' : '' ?>
|
||||
<a class="list-title" href="<?php echo Zira\Helper::html(Zira\Helper::url(Forum\Models\Topic::generateUrl($item))) ?>" title="<?php echo Zira\Helper::html($item->title) ?>"><?php echo $ticon ?><span class="<?php echo $title_ico ?>"></span> <?php echo Zira\Helper::html($status.$item->title) ?></a>
|
||||
</h3>
|
||||
<div class="list-info-wrapper">
|
||||
<span class="list-info date"><span class="glyphicon glyphicon-time"></span> <?php echo date(Zira\Config::get('date_format'), strtotime($item->date_modified)) ?></span>
|
||||
<?php if ($item->last_user_id && $item->user_username): ?>
|
||||
<span class="list-info author"><span class="glyphicon glyphicon-user"></span> <?php echo Zira\User::generateUserProfileLink($item->last_user_id, $item->user_firstname, $item->user_secondname, $item->user_username) ?></span>
|
||||
<?php endif; ?>
|
||||
<span class="list-info counter"><span class="glyphicon glyphicon-comment"></span> <?php echo Zira\Helper::html(tm('Messages: %s', 'forum', $item->messages)) ?></span>
|
||||
</div>
|
||||
</li>
|
||||
<?php $co++; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php if (isset($pagination)) echo $pagination ?>
|
||||
<?php endif; ?>
|
|
@ -11,7 +11,7 @@ use Dash;
|
|||
use Zira;
|
||||
use Zira\Permission;
|
||||
|
||||
class Options extends Dash\WIndows\Window {
|
||||
class Options extends Dash\Windows\Window {
|
||||
protected static $_icon_class = 'glyphicon glyphicon-th-list';
|
||||
protected static $_title = 'Vote options';
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ use Zira;
|
|||
use Vote;
|
||||
use Zira\Permission;
|
||||
|
||||
class Votes extends Dash\WIndows\Window {
|
||||
class Votes extends Dash\Windows\Window {
|
||||
protected static $_icon_class = 'glyphicon glyphicon-stats';
|
||||
protected static $_title = 'Votes';
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ class Menu {
|
|||
foreach($categories as $category) {
|
||||
if ($category->name == $url) return true;
|
||||
}
|
||||
return $url == Router::getRequest();
|
||||
return $url == Router::getRequest() || mb_strpos(Router::getRequest(), $url . '/', null, CHARSET) === 0;
|
||||
}
|
||||
|
||||
public static function getPrimaryMenuActiveURL() {
|
||||
|
|
Loading…
Reference in a new issue