forum language
This commit is contained in:
parent
e625871ef1
commit
0d11490042
|
@ -452,4 +452,30 @@ var dash_forum_message_preview = function() {
|
|||
} catch(e) {}
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
var dash_forum_categories_language = function(element) {
|
||||
var language = this.options.data.language;
|
||||
var id = $(element).attr('id');
|
||||
var item = this.findMenuItemByProperty('id',id);
|
||||
if (item && typeof(item.language)!="undefined") {
|
||||
if (item.language!=language) {
|
||||
this.options.data.language=item.language;
|
||||
desk_window_reload(this);
|
||||
$(element).parents('ul').find('.glyphicon-ok').removeClass('glyphicon-ok').addClass('glyphicon-filter');
|
||||
$(element).find('.glyphicon').removeClass('glyphicon-filter').addClass('glyphicon-ok');
|
||||
} else {
|
||||
this.options.data.language='';
|
||||
desk_window_reload(this);
|
||||
$(element).parents('ul').find('.glyphicon-ok').removeClass('glyphicon-ok').addClass('glyphicon-filter');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var dash_forum_forums_language = function(element) {
|
||||
return dash_forum_categories_language.call(this, element);
|
||||
};
|
||||
|
||||
var dash_forum_topics_language = function(element) {
|
||||
return dash_forum_categories_language.call(this, element);
|
||||
};
|
|
@ -46,16 +46,40 @@ class Index extends Zira\Controller {
|
|||
$this->_renderPlaceholderCategory();
|
||||
|
||||
$categories = Forum\Models\Category::getCollection()
|
||||
->open_query()
|
||||
->where('language', 'is', null)
|
||||
->order_by('sort_order', 'asc')
|
||||
->close_query()
|
||||
->union()
|
||||
->open_query()
|
||||
->where('language', '=', Zira\Locale::getLanguage())
|
||||
->order_by('sort_order', 'asc')
|
||||
->close_query()
|
||||
->merge()
|
||||
->order_by('sort_order', 'asc')
|
||||
->get();
|
||||
|
||||
foreach($categories as $category) {
|
||||
$category->forums = Forum\Models\Forum::getCollection()
|
||||
->open_query()
|
||||
->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)
|
||||
->where('language', 'is', null)
|
||||
->and_where('category_id', '=', $category->id)
|
||||
->and_where('active', '=', 1)
|
||||
->order_by('sort_order', 'asc')
|
||||
->close_query()
|
||||
->union()
|
||||
->open_query()
|
||||
->select(Forum\Models\Forum::getFields())
|
||||
->left_join(Zira\Models\User::getClass(), array('user_firstname' => 'firstname', 'user_secondname' => 'secondname', 'user_username' => 'username'))
|
||||
->where('language', '=', Zira\Locale::getLanguage())
|
||||
->and_where('category_id', '=', $category->id)
|
||||
->and_where('active', '=', 1)
|
||||
->order_by('sort_order', 'asc')
|
||||
->close_query()
|
||||
->merge()
|
||||
->order_by('sort_order', 'asc')
|
||||
->get();
|
||||
}
|
||||
|
||||
|
@ -105,6 +129,7 @@ class Index extends Zira\Controller {
|
|||
->get(0);
|
||||
|
||||
if (!$category) Zira\Response::notFound();
|
||||
if ($category->language && $category->language!=Zira\Locale::getLanguage()) Zira\Response::notFound();
|
||||
|
||||
// checking permission
|
||||
if ($category->access_check && !Zira\Permission::check(Zira\Permission::TO_VIEW_RECORDS)) {
|
||||
|
@ -116,17 +141,31 @@ class Index extends Zira\Controller {
|
|||
}
|
||||
|
||||
$rows = Forum\Models\Forum::getCollection()
|
||||
->open_query()
|
||||
->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)
|
||||
->where('language', 'is', null)
|
||||
->and_where('category_id','=',$category->id)
|
||||
->and_where('active','=',1)
|
||||
->order_by('sort_order','asc')
|
||||
->close_query()
|
||||
->union()
|
||||
->open_query()
|
||||
->select(Forum\Models\Forum::getFields())
|
||||
->left_join(Zira\Models\User::getClass(), array('user_firstname'=>'firstname', 'user_secondname'=>'secondname', 'user_username'=>'username'))
|
||||
->where('language', '=', Zira\Locale::getLanguage())
|
||||
->and_where('category_id','=',$category->id)
|
||||
->and_where('active','=',1)
|
||||
->order_by('sort_order','asc')
|
||||
->close_query()
|
||||
->merge()
|
||||
->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;
|
||||
$description = $category->description ? Zira\Locale::t(str_replace("\r\n", "\n", $category->description)) : '';
|
||||
$meta_description = $category->meta_description ? Zira\Locale::t(str_replace("\r\n", "\n", $category->meta_description)) : $description;
|
||||
$keywords = $category->meta_keywords ? Zira\Locale::t($category->meta_keywords) : '';
|
||||
|
||||
Zira\Page::addTitle($meta_title);
|
||||
|
@ -181,6 +220,7 @@ class Index extends Zira\Controller {
|
|||
->get(0);
|
||||
|
||||
if (!$forum || !$forum->active) Zira\Response::notFound();
|
||||
if ($forum->language && $forum->language!=Zira\Locale::getLanguage()) Zira\Response::notFound();
|
||||
|
||||
// checking permission
|
||||
if (($forum->access_check || $forum->category_access_check) && !Zira\Permission::check(Zira\Permission::TO_VIEW_RECORDS)) {
|
||||
|
@ -192,23 +232,51 @@ class Index extends Zira\Controller {
|
|||
}
|
||||
|
||||
$sticky = Forum\Models\Topic::getCollection()
|
||||
->open_query()
|
||||
->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)
|
||||
->where('language', 'is', null)
|
||||
->and_where('category_id','=',$forum->category_id)
|
||||
->and_where('forum_id','=',$forum->id)
|
||||
->and_where('sticky','=',1)
|
||||
->and_where('published','=',Forum\Models\Topic::STATUS_PUBLISHED)
|
||||
->order_by('id','desc')
|
||||
->close_query()
|
||||
->union()
|
||||
->open_query()
|
||||
->select(Forum\Models\Topic::getFields())
|
||||
->left_join(Zira\Models\User::getClass(), array('user_firstname'=>'firstname', 'user_secondname'=>'secondname', 'user_username'=>'username'))
|
||||
->where('language', '=', Zira\Locale::getLanguage())
|
||||
->and_where('category_id','=',$forum->category_id)
|
||||
->and_where('forum_id','=',$forum->id)
|
||||
->and_where('sticky','=',1)
|
||||
->and_where('published','=',Forum\Models\Topic::STATUS_PUBLISHED)
|
||||
->order_by('id','desc')
|
||||
->close_query()
|
||||
->merge()
|
||||
->order_by('id','desc')
|
||||
->get();
|
||||
|
||||
$total = Forum\Models\Topic::getCollection()
|
||||
$total1 = Forum\Models\Topic::getCollection()
|
||||
->count()
|
||||
->where('category_id','=',$forum->category_id)
|
||||
->where('language', 'is', null)
|
||||
->and_where('category_id','=',$forum->category_id)
|
||||
->and_where('forum_id','=',$forum->id)
|
||||
->and_where('sticky','=',0)
|
||||
->and_where('published','=',Forum\Models\Topic::STATUS_PUBLISHED)
|
||||
->get('co');
|
||||
|
||||
$total2 = Forum\Models\Topic::getCollection()
|
||||
->count()
|
||||
->where('language', '=', Zira\Locale::getLanguage())
|
||||
->and_where('category_id','=',$forum->category_id)
|
||||
->and_where('forum_id','=',$forum->id)
|
||||
->and_where('sticky','=',0)
|
||||
->and_where('published','=',Forum\Models\Topic::STATUS_PUBLISHED)
|
||||
->get('co');
|
||||
|
||||
$total = $total1+$total2;
|
||||
|
||||
$limit = Zira\Config::get('forum_limit') ? intval(Zira\Config::get('forum_limit')) : 10;
|
||||
$page = (int)Zira\Request::get('page');
|
||||
$pages = ceil($total / $limit);
|
||||
|
@ -216,20 +284,38 @@ class Index extends Zira\Controller {
|
|||
if ($page<1) $page = 1;
|
||||
|
||||
$topics = Forum\Models\Topic::getCollection()
|
||||
->open_query()
|
||||
->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)
|
||||
->where('language', 'is', null)
|
||||
->and_where('category_id','=',$forum->category_id)
|
||||
->and_where('forum_id','=',$forum->id)
|
||||
->and_where('sticky','=',0)
|
||||
->and_where('published','=',Forum\Models\Topic::STATUS_PUBLISHED)
|
||||
->order_by('id','desc')
|
||||
->limit($limit*$page)
|
||||
->close_query()
|
||||
->union()
|
||||
->open_query()
|
||||
->select(Forum\Models\Topic::getFields())
|
||||
->left_join(Zira\Models\User::getClass(), array('user_firstname'=>'firstname', 'user_secondname'=>'secondname', 'user_username'=>'username'))
|
||||
->where('language', '=', Zira\Locale::getLanguage())
|
||||
->and_where('category_id','=',$forum->category_id)
|
||||
->and_where('forum_id','=',$forum->id)
|
||||
->and_where('sticky','=',0)
|
||||
->and_where('published','=',Forum\Models\Topic::STATUS_PUBLISHED)
|
||||
->order_by('id','desc')
|
||||
->limit($limit*$page)
|
||||
->close_query()
|
||||
->merge()
|
||||
->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;
|
||||
$description = $forum->description ? Zira\Locale::t(str_replace("\r\n", "\n", $forum->description)) : '';
|
||||
$meta_description = $forum->meta_description ? Zira\Locale::t(str_replace("\r\n", "\n", $forum->meta_description)) : $description;
|
||||
$keywords = $forum->meta_keywords ? Zira\Locale::t($forum->meta_keywords) : '';
|
||||
|
||||
Zira\Page::addTitle($meta_title);
|
||||
|
@ -303,6 +389,7 @@ class Index extends Zira\Controller {
|
|||
->get(0);
|
||||
|
||||
if (!$topic || !$topic->forum_active || $topic->published != Forum\Models\Topic::STATUS_PUBLISHED) Zira\Response::notFound();
|
||||
if ($topic->language && $topic->language!=Zira\Locale::getLanguage()) Zira\Response::notFound();
|
||||
|
||||
// checking permission
|
||||
if (($topic->forum_access_check || $topic->category_access_check) && !Zira\Permission::check(Zira\Permission::TO_VIEW_RECORDS)) {
|
||||
|
@ -426,8 +513,8 @@ class Index extends Zira\Controller {
|
|||
|
||||
$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;
|
||||
$description = $topic->description ? Zira\Locale::t(str_replace("\r\n", "\n", $topic->description)) : '';
|
||||
$meta_description = $topic->meta_description ? Zira\Locale::t(str_replace("\r\n", "\n", $topic->meta_description)) : $description;
|
||||
$keywords = $topic->meta_keywords ? Zira\Locale::t($topic->meta_keywords) : '';
|
||||
|
||||
Zira\Page::addTitle($_status.$meta_title);
|
||||
|
@ -500,6 +587,7 @@ class Index extends Zira\Controller {
|
|||
->get(0);
|
||||
|
||||
if (!$forum || !$forum->active) Zira\Response::notFound();
|
||||
if ($forum->language && $forum->language!=Zira\Locale::getLanguage()) Zira\Response::notFound();
|
||||
|
||||
// checking permission
|
||||
if (($forum->access_check || $forum->category_access_check) && !Zira\Permission::check(Zira\Permission::TO_VIEW_RECORDS)) {
|
||||
|
|
|
@ -34,6 +34,11 @@ class Category extends Form
|
|||
{
|
||||
$html = $this->open();
|
||||
$html .= $this->hidden('id');
|
||||
if (count(Zira\Config::get('languages'))<2) {
|
||||
$html .= $this->hidden('language');
|
||||
} else {
|
||||
$html .= $this->selectDropdown(Locale::t('Language').'*','language',array_merge(array(''=>Locale::t('All languages')), Locale::getLanguagesArray()));
|
||||
}
|
||||
$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');
|
||||
|
@ -69,6 +74,7 @@ class Category extends Form
|
|||
$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')));
|
||||
$validator->registerCustom(array(get_class(), 'checkLanguage'), 'language', Locale::t('An error occurred'));
|
||||
}
|
||||
|
||||
public static function checkLayout($layout) {
|
||||
|
@ -76,4 +82,9 @@ class Category extends Form
|
|||
$layouts = Zira\View::getLayouts();
|
||||
return array_key_exists($layout, $layouts);
|
||||
}
|
||||
|
||||
public static function checkLanguage($language) {
|
||||
if (empty($language)) return true;
|
||||
return in_array($language , Zira\Config::get('languages'));
|
||||
}
|
||||
}
|
|
@ -35,6 +35,11 @@ class Forum extends Form
|
|||
{
|
||||
$html = $this->open();
|
||||
$html .= $this->hidden('id');
|
||||
if (count(Zira\Config::get('languages'))<2) {
|
||||
$html .= $this->hidden('language');
|
||||
} else {
|
||||
$html .= $this->selectDropdown(Locale::t('Language').'*','language',array_merge(array(''=>Locale::t('All languages')), Locale::getLanguagesArray()));
|
||||
}
|
||||
$html .= $this->input(Locale::t('Title').'*', 'title');
|
||||
$html .= $this->textarea(Locale::t('Description'), 'description');
|
||||
$html .= $this->input(Locale::t('Window title'), 'meta_title');
|
||||
|
@ -85,10 +90,16 @@ class Forum extends Form
|
|||
$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'));
|
||||
$validator->registerCustom(array(get_class(), 'checkLanguage'), 'language', Locale::t('An error occurred'));
|
||||
}
|
||||
|
||||
public static function checkCategory($category_id) {
|
||||
$category = new \Forum\Models\Category($category_id);
|
||||
return $category->loaded();
|
||||
}
|
||||
|
||||
public static function checkLanguage($language) {
|
||||
if (empty($language)) return true;
|
||||
return in_array($language , Zira\Config::get('languages'));
|
||||
}
|
||||
}
|
|
@ -35,6 +35,11 @@ class Topic extends Form
|
|||
{
|
||||
$html = $this->open();
|
||||
$html .= $this->hidden('id');
|
||||
if (count(Zira\Config::get('languages'))<2) {
|
||||
$html .= $this->hidden('language');
|
||||
} else {
|
||||
$html .= $this->selectDropdown(Locale::t('Language').'*','language',array_merge(array(''=>Locale::t('All languages')), Locale::getLanguagesArray()));
|
||||
}
|
||||
$html .= $this->hidden('category_id');
|
||||
$html .= $this->input(Locale::t('Title').'*', 'title');
|
||||
$html .= $this->textarea(Locale::t('Description'), 'description');
|
||||
|
@ -88,6 +93,7 @@ class Topic extends Form
|
|||
$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'));
|
||||
$validator->registerCustom(array(get_class(), 'checkLanguage'), 'language', Locale::t('An error occurred'));
|
||||
}
|
||||
|
||||
public static function checkStatus($status) {
|
||||
|
@ -99,4 +105,9 @@ class Topic extends Form
|
|||
$forum = new \Forum\Models\Forum($forum_id);
|
||||
return ($forum->loaded() && $forum->category_id == $category_id);
|
||||
}
|
||||
|
||||
public static function checkLanguage($language) {
|
||||
if (empty($language)) return true;
|
||||
return in_array($language , Zira\Config::get('languages'));
|
||||
}
|
||||
}
|
|
@ -29,13 +29,14 @@ class Category extends Table {
|
|||
'meta_description' => Field::string(),
|
||||
'access_check' => Field::tinyint(true, true, 0),
|
||||
'sort_order' => Field::int(true, false, 0),
|
||||
'language' => Field::string(),
|
||||
'tpl' => Field::string()
|
||||
);
|
||||
}
|
||||
|
||||
public function getKeys() {
|
||||
return array(
|
||||
'sort_order' => array('sort_order')
|
||||
'sort_order' => array('language', 'sort_order')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,13 +34,14 @@ class Forum extends Table {
|
|||
'topics' => Field::int(true, true, 0),
|
||||
'last_user_id' => Field::int(),
|
||||
'sort_order' => Field::int(true, false, 0),
|
||||
'language' => Field::string(),
|
||||
'active' => Field::tinyint(true, true, 1)
|
||||
);
|
||||
}
|
||||
|
||||
public function getKeys() {
|
||||
return array(
|
||||
'forum' => array('category_id', 'active', 'sort_order')
|
||||
'forum' => array('language', 'category_id', 'active', 'sort_order')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ class Topic extends Table {
|
|||
'date_modified' => Field::datetime(true),
|
||||
'messages' => Field::int(true, true, 0),
|
||||
'last_user_id' => Field::int(),
|
||||
'language' => Field::string(),
|
||||
'active' => Field::tinyint(true, true, 1),
|
||||
'status' => Field::tinyint(true, true, 0),
|
||||
'sticky' => Field::tinyint(true, true, 0),
|
||||
|
@ -42,7 +43,7 @@ class Topic extends Table {
|
|||
|
||||
public function getKeys() {
|
||||
return array(
|
||||
'forum' => array('category_id','forum_id','sticky','published')
|
||||
'forum' => array('language', 'category_id','forum_id','sticky','published')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,10 @@ class Categories extends Dash\Models\Model {
|
|||
$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;
|
||||
|
||||
$language = $form->getValue('language');
|
||||
if (empty($language)) $language = null;
|
||||
$category->language = $language;
|
||||
|
||||
$category->save();
|
||||
|
||||
|
|
|
@ -26,7 +26,8 @@ class Category extends Orm {
|
|||
'meta_description',
|
||||
'access_check',
|
||||
'sort_order',
|
||||
'tpl'
|
||||
'tpl',
|
||||
'language'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@ class Forum extends Orm {
|
|||
'topics',
|
||||
'last_user_id',
|
||||
'sort_order',
|
||||
'active'
|
||||
'active',
|
||||
'language'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,10 @@ class Forums extends Dash\Models\Model {
|
|||
$forum->access_check = (int)$form->getValue('access_check') ? 1 : 0;
|
||||
$forum->active = (int)$form->getValue('active') ? 1 : 0;
|
||||
|
||||
$language = $form->getValue('language');
|
||||
if (empty($language)) $language = null;
|
||||
$forum->language = $language;
|
||||
|
||||
$forum->save();
|
||||
|
||||
return array('message'=>Zira\Locale::t('Successfully saved'), 'close'=>true);
|
||||
|
|
|
@ -41,7 +41,8 @@ class Topic extends Orm {
|
|||
'active',
|
||||
'status',
|
||||
'sticky',
|
||||
'published'
|
||||
'published',
|
||||
'language'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -70,6 +71,19 @@ class Topic extends Orm {
|
|||
return \Forum\Forum::ROUTE . '/thread/' . $id;
|
||||
}
|
||||
|
||||
public static function url($topic_id, $language=null) {
|
||||
$url = self::generateUrl($topic_id);
|
||||
if (count(Zira\Config::get('languages'))>1) {
|
||||
if (!$language) $language = Zira\Locale::getLanguage();
|
||||
Zira\Helper::setAddingLanguageToUrl(false);
|
||||
$url = Zira\Helper::url($language.'/'.$url);
|
||||
Zira\Helper::setAddingLanguageToUrl(true);
|
||||
} else {
|
||||
$url = Zira\Helper::url($url);
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
public static function getStatuses() {
|
||||
return array(
|
||||
self::STATUS_NONE => Zira\Locale::tm('Default', 'forum'),
|
||||
|
@ -103,6 +117,10 @@ class Topic extends Orm {
|
|||
$topic->published = self::STATUS_NOT_PUBLISHED;
|
||||
}
|
||||
|
||||
if (count(Zira\Config::get('languages'))>1) {
|
||||
$topic->language = Zira\Locale::getLanguage();
|
||||
}
|
||||
|
||||
try {
|
||||
$topic->save();
|
||||
} catch(\Exception $err) {
|
||||
|
|
|
@ -79,6 +79,10 @@ class Topics extends Dash\Models\Model {
|
|||
$thread->sticky = (int)$form->getValue('sticky') ? 1 : 0;
|
||||
$thread->date_modified = date('Y-m-d H:i:s');
|
||||
|
||||
$language = $form->getValue('language');
|
||||
if (empty($language)) $language = null;
|
||||
$thread->language = $language;
|
||||
|
||||
$thread->save();
|
||||
|
||||
if ($thread->published == Forum\Models\Topic::STATUS_PUBLISHED) {
|
||||
|
|
|
@ -25,14 +25,32 @@ class Discussion extends Widget {
|
|||
$limit = Zira\Config::get('widget_records_limit', 5);
|
||||
|
||||
$rows = Forum\Models\Message::getCollection()
|
||||
->open_query()
|
||||
->select(Forum\Models\Message::getFields())
|
||||
->join(Forum\Models\Topic::getClass(), array('topic_title'=>'title'))
|
||||
->left_join(Zira\Models\User::getClass(), array('user_firstname'=>'firstname', 'user_secondname'=>'secondname', 'user_username'=>'username'))
|
||||
->where('published','=',Forum\Models\Message::STATUS_PUBLISHED)
|
||||
->where('language','is',null, Forum\Models\Topic::getAlias())
|
||||
->and_where('published','=',Forum\Models\Message::STATUS_PUBLISHED)
|
||||
->and_where('published','=',Forum\Models\Topic::STATUS_PUBLISHED, Forum\Models\Topic::getAlias())
|
||||
->group_by('topic_id')
|
||||
->order_by('id','desc')
|
||||
->limit($limit)
|
||||
->close_query()
|
||||
->union()
|
||||
->open_query()
|
||||
->select(Forum\Models\Message::getFields())
|
||||
->join(Forum\Models\Topic::getClass(), array('topic_title'=>'title'))
|
||||
->left_join(Zira\Models\User::getClass(), array('user_firstname'=>'firstname', 'user_secondname'=>'secondname', 'user_username'=>'username'))
|
||||
->where('language','=',Zira\Locale::getLanguage(), Forum\Models\Topic::getAlias())
|
||||
->and_where('published','=',Forum\Models\Message::STATUS_PUBLISHED)
|
||||
->and_where('published','=',Forum\Models\Topic::STATUS_PUBLISHED, Forum\Models\Topic::getAlias())
|
||||
->group_by('topic_id')
|
||||
->order_by('id','desc')
|
||||
->limit($limit)
|
||||
->close_query()
|
||||
->merge()
|
||||
->order_by('id','desc')
|
||||
->limit($limit)
|
||||
->get();
|
||||
|
||||
if (!$rows) return;
|
||||
|
|
|
@ -42,6 +42,25 @@ class Categories extends Dash\Windows\Window {
|
|||
$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')
|
||||
);
|
||||
|
||||
if (count(Zira\Config::get('languages'))>1) {
|
||||
$menu = array(
|
||||
$this->createMenuItem($this->getDefaultMenuTitle(), $this->getDefaultMenuDropdown())
|
||||
);
|
||||
|
||||
$langMenu = array();
|
||||
foreach(Zira\Locale::getLanguagesArray() as $lang_key=>$lang_name) {
|
||||
$icon = 'glyphicon glyphicon-filter';
|
||||
$langMenu []= $this->createMenuDropdownItem($lang_name, $icon, 'desk_call(dash_forum_categories_language, this, element);', 'language', false, array('language'=>$lang_key));
|
||||
}
|
||||
$menu []= $this->createMenuItem(Zira\Locale::t('Languages'), $langMenu);
|
||||
|
||||
$this->setMenuItems($menu);
|
||||
}
|
||||
|
||||
$this->setData(array(
|
||||
'language' => ''
|
||||
));
|
||||
}
|
||||
|
||||
public function load() {
|
||||
|
@ -50,9 +69,15 @@ class Categories extends Dash\Windows\Window {
|
|||
return array('error'=>Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$categories = Forum\Models\Category::getCollection()
|
||||
->order_by('sort_order', 'asc')
|
||||
->get();
|
||||
$categories_q = Forum\Models\Category::getCollection();
|
||||
|
||||
$language = Zira\Request::post('language');
|
||||
if (!empty($language)) {
|
||||
$categories_q->where('language', '=', $language);
|
||||
}
|
||||
|
||||
$categories = $categories_q->order_by('sort_order', 'asc')
|
||||
->get();
|
||||
|
||||
$items = array();
|
||||
foreach($categories as $category) {
|
||||
|
|
|
@ -82,10 +82,12 @@ class Forums extends Dash\Windows\Window {
|
|||
$this->createMenuDropdownItem(Zira\Locale::t('Edit'), 'glyphicon glyphicon-pencil', 'desk_call(dash_forum_categories, this);', 'create')
|
||||
);
|
||||
|
||||
$this->setMenuItems(array(
|
||||
$menu = array(
|
||||
$this->createMenuItem($this->_default_menu_title, $this->getDefaultMenuDropdown()),
|
||||
$this->createMenuItem(Zira\Locale::t('Categories'), $category_menu)
|
||||
));
|
||||
);
|
||||
|
||||
$this->setMenuItems($menu);
|
||||
|
||||
$this->addDefaultToolbarItem(
|
||||
$this->createToolbarButton(null, Zira\Locale::tm('Forum settings', 'forum'), 'glyphicon glyphicon-cog', 'desk_call(dash_forum_settings, this);', 'settings', false, true)
|
||||
|
@ -113,7 +115,8 @@ class Forums extends Dash\Windows\Window {
|
|||
$this->includeJS('forum/dash');
|
||||
|
||||
$this->setData(array(
|
||||
'category_id' => 0
|
||||
'category_id' => 0,
|
||||
'language' => ''
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -126,6 +129,7 @@ class Forums extends Dash\Windows\Window {
|
|||
$category_id = 0;
|
||||
$category_title = '';
|
||||
$_category_id = (int)Zira\Request::post('category_id');
|
||||
$language = Zira\Request::post('language');
|
||||
|
||||
$category_menu = array(
|
||||
$this->createMenuDropdownItem(Zira\Locale::t('Edit'), 'glyphicon glyphicon-pencil', 'desk_call(dash_forum_categories, this);', 'create'),
|
||||
|
@ -145,6 +149,11 @@ class Forums extends Dash\Windows\Window {
|
|||
$category_menu []= $this->createMenuDropdownItem($category->title, 'glyphicon '.$class, 'desk_call(dash_forum_category_filter, this, '.$category->id.');', 'categories', false, array('category_id'=>$category->id));
|
||||
}
|
||||
|
||||
$menu = array(
|
||||
$this->createMenuItem($this->_default_menu_title, $this->getDefaultMenuDropdown()),
|
||||
$this->createMenuItem(Zira\Locale::t('Categories'), $category_menu)
|
||||
);
|
||||
|
||||
$this->setSidebarItems($this->getDefaultSidebar());
|
||||
|
||||
$unpublished = array();
|
||||
|
@ -160,10 +169,17 @@ class Forums extends Dash\Windows\Window {
|
|||
$unpublished[$row->forum_id] = $row->co;
|
||||
}
|
||||
|
||||
$forums = Forum\Models\Forum::getCollection()
|
||||
->where('category_id','=',$category_id)
|
||||
->order_by('sort_order', 'asc')
|
||||
->get();
|
||||
$forums_q = Forum\Models\Forum::getCollection();
|
||||
|
||||
if (!empty($language)) {
|
||||
$forums_q->where('language', '=', $language)
|
||||
->and_where('category_id','=',$category_id);
|
||||
} else {
|
||||
$forums_q->where('category_id','=',$category_id);
|
||||
}
|
||||
|
||||
$forums = $forums_q->order_by('sort_order', 'asc')
|
||||
->get();
|
||||
|
||||
$items = array();
|
||||
foreach($forums as $forum) {
|
||||
|
@ -173,17 +189,25 @@ class Forums extends Dash\Windows\Window {
|
|||
}
|
||||
$this->setBodyItems($items);
|
||||
|
||||
$this->setMenuItems(array(
|
||||
$this->createMenuItem($this->_default_menu_title, $this->getDefaultMenuDropdown()),
|
||||
$this->createMenuItem(Zira\Locale::t('Categories'), $category_menu)
|
||||
));
|
||||
if (count(Zira\Config::get('languages'))>1) {
|
||||
$langMenu = array();
|
||||
foreach(Zira\Locale::getLanguagesArray() as $lang_key=>$lang_name) {
|
||||
if (!empty($language) && $language==$lang_key) $icon = 'glyphicon glyphicon-ok';
|
||||
else $icon = 'glyphicon glyphicon-filter';
|
||||
$langMenu []= $this->createMenuDropdownItem($lang_name, $icon, 'desk_call(dash_forum_forums_language, this, element);', 'language', false, array('language'=>$lang_key));
|
||||
}
|
||||
$menu []= $this->createMenuItem(Zira\Locale::t('Languages'), $langMenu);
|
||||
}
|
||||
|
||||
$this->setMenuItems($menu);
|
||||
|
||||
if (!empty($category_title)) {
|
||||
$this->setTitle(Zira\Locale::t(self::$_title).' - '.$category_title);
|
||||
}
|
||||
|
||||
$this->setData(array(
|
||||
'category_id' => $category_id
|
||||
'category_id' => $category_id,
|
||||
'language' => $language
|
||||
));
|
||||
}
|
||||
}
|
|
@ -109,6 +109,21 @@ class Topics extends Dash\Windows\Window {
|
|||
$this->createContextMenuItem(Zira\Locale::tm('Open thread page', 'forum'), 'glyphicon glyphicon-new-window', 'desk_call(dash_forum_page, this);', 'edit', true, array('typo'=>'page'))
|
||||
);
|
||||
|
||||
if (count(Zira\Config::get('languages'))>1) {
|
||||
$menu = array(
|
||||
$this->createMenuItem($this->getDefaultMenuTitle(), $this->getDefaultMenuDropdown())
|
||||
);
|
||||
|
||||
$langMenu = array();
|
||||
foreach(Zira\Locale::getLanguagesArray() as $lang_key=>$lang_name) {
|
||||
$icon = 'glyphicon glyphicon-filter';
|
||||
$langMenu []= $this->createMenuDropdownItem($lang_name, $icon, 'desk_call(dash_forum_topics_language, this, element);', 'language', false, array('language'=>$lang_key));
|
||||
}
|
||||
$menu []= $this->createMenuItem(Zira\Locale::t('Languages'), $langMenu);
|
||||
|
||||
$this->setMenuItems($menu);
|
||||
}
|
||||
|
||||
$this->setSidebarContent('<div class="topics-infobar" style="white-space:nowrap;text-overflow: ellipsis;width:100%;overflow:hidden"></div>');
|
||||
|
||||
$this->setOnSelectJSCallback(
|
||||
|
@ -124,7 +139,8 @@ class Topics extends Dash\Windows\Window {
|
|||
'page'=>$this->page,
|
||||
'pages'=>$this->pages,
|
||||
'order'=>$this->order,
|
||||
'category_id'=>0
|
||||
'category_id'=>0,
|
||||
'language' => ''
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -136,40 +152,67 @@ class Topics extends Dash\Windows\Window {
|
|||
return array('error'=>Zira\Locale::t('Permission denied'));
|
||||
}
|
||||
|
||||
$language = Zira\Request::post('language');
|
||||
|
||||
$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');
|
||||
$total_q = \Forum\Models\Topic::getCollection()
|
||||
->count();
|
||||
|
||||
if (!empty($language)) {
|
||||
$total_q->where('language', '=', $language)
|
||||
->and_where('category_id','=',$forum->category_id)
|
||||
->and_where('forum_id','=',$forum->id);
|
||||
} else {
|
||||
$total_q->where('category_id','=',$forum->category_id)
|
||||
->and_where('forum_id','=',$forum->id);
|
||||
}
|
||||
|
||||
$this->total = $total_q->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;
|
||||
|
||||
$unpublished = array();
|
||||
$rows = \Forum\Models\Message::getCollection()
|
||||
$rows_q = \Forum\Models\Message::getCollection()
|
||||
->count()
|
||||
->select('topic_id')
|
||||
->join(\Forum\Models\Topic::getClass())
|
||||
->where('category_id','=',$forum->category_id, \Forum\Models\Topic::getAlias())
|
||||
->and_where('forum_id','=',$forum->id, \Forum\Models\Topic::getAlias())
|
||||
->and_where('published','=',\Forum\Models\Message::STATUS_NOT_PUBLISHED)
|
||||
->group_by('topic_id')
|
||||
->get();
|
||||
->join(\Forum\Models\Topic::getClass());
|
||||
|
||||
if (!empty($language)) {
|
||||
$rows_q->where('language', '=', $language, \Forum\Models\Topic::getAlias())
|
||||
->and_where('category_id','=',$forum->category_id, \Forum\Models\Topic::getAlias())
|
||||
->and_where('forum_id','=',$forum->id, \Forum\Models\Topic::getAlias())
|
||||
->and_where('published','=',\Forum\Models\Message::STATUS_NOT_PUBLISHED);
|
||||
} else {
|
||||
$rows_q->where('category_id','=',$forum->category_id, \Forum\Models\Topic::getAlias())
|
||||
->and_where('forum_id','=',$forum->id, \Forum\Models\Topic::getAlias())
|
||||
->and_where('published','=',\Forum\Models\Message::STATUS_NOT_PUBLISHED);
|
||||
}
|
||||
|
||||
$rows = $rows_q->group_by('topic_id')
|
||||
->get();
|
||||
|
||||
foreach($rows as $row) {
|
||||
$unpublished[$row->topic_id] = $row->co;
|
||||
}
|
||||
|
||||
$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();
|
||||
$threads_q = \Forum\Models\Topic::getCollection();
|
||||
|
||||
if (!empty($language)) {
|
||||
$threads_q->where('language', '=', $language)
|
||||
->and_where('category_id','=',$forum->category_id)
|
||||
->and_where('forum_id','=',$forum->id);
|
||||
} else {
|
||||
$threads_q->where('category_id','=',$forum->category_id)
|
||||
->and_where('forum_id','=',$forum->id);
|
||||
}
|
||||
|
||||
$threads = $threads_q->order_by('id', $this->order)
|
||||
->limit($this->limit, ($this->page - 1) * $this->limit)
|
||||
->get();
|
||||
|
||||
$items = array();
|
||||
foreach($threads as $thread) {
|
||||
|
@ -188,7 +231,8 @@ class Topics extends Dash\Windows\Window {
|
|||
'page'=>$this->page,
|
||||
'pages'=>$this->pages,
|
||||
'order'=>$this->order,
|
||||
'category_id'=>$forum->category_id
|
||||
'category_id'=>$forum->category_id,
|
||||
'language' => $language
|
||||
));
|
||||
}
|
||||
}
|
|
@ -30,10 +30,10 @@
|
|||
<li class="list-item no-thumb <?php echo ($co%2==0 ? 'odd-b' : 'even-b') ?>">
|
||||
<?php $ticon = strtotime($item->date_modified) > time()-43200 ? '<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>
|
||||
<a class="list-title" href="<?php echo Zira\Helper::html(Zira\Helper::url(Forum\Models\Forum::generateUrl($item))) ?>" title="<?php echo Zira\Helper::html(t($item->title)) ?>"><?php echo $ticon ?><?php echo Zira\Helper::html(t($item->title)) ?></a>
|
||||
</h3>
|
||||
<div class="list-content-wrapper">
|
||||
<p><?php echo Zira\Helper::nl2br(Zira\Helper::html($item->description)) ?></p>
|
||||
<p><?php echo Zira\Helper::nl2br(Zira\Helper::html(t(str_replace("\r\n","\n",$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>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<?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>
|
||||
<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(t($category->title)) ?>"><span class="glyphicon glyphicon-link"></span> <?php echo Zira\Helper::html(t($category->title)) ?></a></h2>
|
||||
</div>
|
||||
<?php Zira\View::renderView(array('items'=>$category->forums), 'forum/group'); ?>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<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) ?>"><span class="<?php echo $title_ico ?>"></span> <?php echo Zira\Helper::html($status.$item->title) ?></a>
|
||||
<a class="list-title" href="<?php echo Zira\Helper::html(Forum\Models\Topic::url($item->id, $item->language)) ?>" title="<?php echo Zira\Helper::html(t($item->title)) ?>"><span class="<?php echo $title_ico ?>"></span> <?php echo Zira\Helper::html($status.t($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>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<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>
|
||||
<a class="list-title" href="<?php echo Zira\Helper::html(Zira\Helper::url(Forum\Models\Topic::generateUrl($item))) ?>" title="<?php echo Zira\Helper::html(t($item->title)) ?>"><?php echo $ticon ?><span class="<?php echo $title_ico ?>"></span> <?php echo Zira\Helper::html($status.t($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>
|
||||
|
@ -54,7 +54,7 @@
|
|||
<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>
|
||||
<a class="list-title" href="<?php echo Zira\Helper::html(Zira\Helper::url(Forum\Models\Topic::generateUrl($item))) ?>" title="<?php echo Zira\Helper::html(t($item->title)) ?>"><?php echo $ticon ?><span class="<?php echo $title_ico ?>"></span> <?php echo Zira\Helper::html($status.t($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>
|
||||
|
|
|
@ -58,7 +58,9 @@
|
|||
<?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 class="forum-message">
|
||||
<p class="parse-content<?php echo $mclass ?>"><?php echo $micon ?><?php echo Zira\Content\Parse::bbcode(Zira\Helper::nl2br(Zira\Helper::html($item->content))) ?></p>
|
||||
</div>
|
||||
<?php $images = Forum\Models\File::extractItemFiles($item, 'file_', 'images'); ?>
|
||||
<?php $files = Forum\Models\File::extractItemFiles($item, 'file_', 'files'); ?>
|
||||
<?php if (!empty($images) || !empty($files)): ?>
|
||||
|
@ -91,7 +93,7 @@
|
|||
</div>
|
||||
<div class="list-info-wrapper forum-info-wrapper">
|
||||
<?php if ($item->topic_title): ?>
|
||||
<a class="list-info link" href="<?php echo Zira\Helper::html(Zira\Helper::url(Forum\Models\Topic::generateUrl($item->topic_id))) ?>" title="<?php echo Zira\Helper::html($item->topic_title) ?>"><span class="glyphicon glyphicon-new-window"></span></a>
|
||||
<a class="list-info link" href="<?php echo Zira\Helper::html(Forum\Models\Topic::url($item->topic_id, $item->topic_language)) ?>" title="<?php echo Zira\Helper::html($item->topic_title) ?>"><span class="glyphicon glyphicon-new-window"></span></a>
|
||||
<?php endif; ?>
|
||||
<?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>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<?php foreach($items as $item): ?>
|
||||
<li class="list-item no-thumb <?php echo ($co%2==0 ? 'odd' : 'even') ?>">
|
||||
<h3 class="list-title-wrapper">
|
||||
<a class="list-title" href="<?php echo Zira\Helper::html(Zira\Helper::url(Forum\Models\Topic::generateUrl($item->topic_id))) ?>" title="<?php echo Zira\Helper::html($item->topic_title) ?>"><?php echo Zira\Helper::html($item->topic_title) ?></a>
|
||||
<a class="list-title" href="<?php echo Zira\Helper::html(Zira\Helper::url(Forum\Models\Topic::generateUrl($item->topic_id))) ?>" title="<?php echo Zira\Helper::html(t($item->topic_title)) ?>"><?php echo Zira\Helper::html(t($item->topic_title)) ?></a>
|
||||
</h3>
|
||||
<div class="list-content-wrapper forum-widget-content-wrapper">
|
||||
<p class="parse-content"><?php echo Zira\Content\Parse::bbcode(Zira\Helper::nl2br(Zira\Helper::html($item->content))) ?></p>
|
||||
|
|
|
@ -131,6 +131,7 @@ if ($step>0) {
|
|||
$response = array('error' => $e->getMessage());
|
||||
Zira\Log::write($e->getMessage());
|
||||
}
|
||||
Zira\Cache::clear();
|
||||
} else {
|
||||
$response = array('error' => Zira\Locale::t('An error occurred.'));
|
||||
}
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Zira project.
|
||||
* table.php
|
||||
* (c)2017 http://dro1d.ru
|
||||
*/
|
||||
|
||||
namespace Update;
|
||||
|
||||
abstract class Table {
|
||||
protected $_table;
|
||||
|
||||
public function __construct($table_name) {
|
||||
$this->_table = DB_PREFIX . $table_name;
|
||||
}
|
||||
|
||||
public function getFields() {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getKeys() {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getUnique() {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getValues() {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
$primary = null;
|
||||
$fields = array();
|
||||
foreach((array)$this->getFields() as $name=>$type) {
|
||||
if ($type == Field::primary()) $primary = $name;
|
||||
$fields[]= Db::escapeIdentifier($name).' '.$type;
|
||||
}
|
||||
if ($primary!==null) {
|
||||
$fields[]='PRIMARY KEY ('.Db::escapeIdentifier($primary).')';
|
||||
}
|
||||
foreach((array)$this->getKeys() as $name=>$keys) {
|
||||
$index='KEY '.Db::escapeIdentifier($name).' ( ';
|
||||
if (is_string($keys)) $index .= Db::escapeIdentifier($keys);
|
||||
else if (is_array($keys)) {
|
||||
for($i=0; $i<count($keys); $i++) {
|
||||
$keys[$i]= Db::escapeIdentifier($keys[$i]);
|
||||
}
|
||||
$index.=implode(', ',$keys);
|
||||
}
|
||||
$index .= ' )';
|
||||
$fields[]=$index;
|
||||
}
|
||||
foreach((array)$this->getUnique() as $name=>$keys) {
|
||||
$index='UNIQUE KEY '.Db::escapeIdentifier($name).' ( ';
|
||||
if (is_string($keys)) $index .= Db::escapeIdentifier($keys);
|
||||
else if (is_array($keys)) {
|
||||
for($i=0; $i<count($keys); $i++) {
|
||||
$keys[$i]= Db::escapeIdentifier($keys[$i]);
|
||||
}
|
||||
$index.=implode(', ',$keys);
|
||||
}
|
||||
$index .= ' )';
|
||||
$fields[]=$index;
|
||||
}
|
||||
|
||||
$sql = 'CREATE TABLE '.DB::escapeIdentifier($this->_table).' ( ';
|
||||
$sql .= implode(', ', $fields);
|
||||
$sql .= ' ) ENGINE='.$this->getEngine().' DEFAULT CHARSET='.$this->getCharset();
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
public function install() {
|
||||
// creating table
|
||||
$query = (string)$this;
|
||||
Db::query($query);
|
||||
// inserting default values
|
||||
foreach((array)$this->getDefaults() as $insert) {
|
||||
$fields = array();
|
||||
$values = array();
|
||||
$data = array();
|
||||
foreach($insert as $field=>$value) {
|
||||
$fields[]=Db::escapeIdentifier($field);
|
||||
$values[]='?';
|
||||
$data[]=$value;
|
||||
}
|
||||
$query = 'INSERT INTO '.Db::escapeIdentifier($this->_table).' ('.implode(', ',$fields).') VALUES ('.implode(', ',$values).')';
|
||||
Db::query($query, $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function uninstall() {
|
||||
$query = 'DROP TABLE IF EXISTS '.DB::escapeIdentifier($this->_table);
|
||||
Db::query($query);
|
||||
}
|
||||
}
|
32
update/v3/forumcategory.php
Normal file
32
update/v3/forumcategory.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Update\V3;
|
||||
|
||||
use Zira\Db\Alter;
|
||||
use Zira\Db\Field;
|
||||
|
||||
class Forumcategory extends Alter {
|
||||
protected $_table = 'forum_categories';
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct($this->_table);
|
||||
}
|
||||
|
||||
public function getFieldsToAdd() {
|
||||
return array(
|
||||
'language' => Field::string()
|
||||
);
|
||||
}
|
||||
|
||||
public function getKeysToDrop() {
|
||||
return array(
|
||||
'sort_order'
|
||||
);
|
||||
}
|
||||
|
||||
public function getKeysToAdd() {
|
||||
return array(
|
||||
'sort_order' => array('language', 'sort_order')
|
||||
);
|
||||
}
|
||||
}
|
32
update/v3/forumforum.php
Normal file
32
update/v3/forumforum.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Update\V3;
|
||||
|
||||
use Zira\Db\Alter;
|
||||
use Zira\Db\Field;
|
||||
|
||||
class Forumforum extends Alter {
|
||||
protected $_table = 'forum_forums';
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct($this->_table);
|
||||
}
|
||||
|
||||
public function getFieldsToAdd() {
|
||||
return array(
|
||||
'language' => Field::string()
|
||||
);
|
||||
}
|
||||
|
||||
public function getKeysToDrop() {
|
||||
return array(
|
||||
'forum'
|
||||
);
|
||||
}
|
||||
|
||||
public function getKeysToAdd() {
|
||||
return array(
|
||||
'forum' => array('language', 'category_id', 'active', 'sort_order')
|
||||
);
|
||||
}
|
||||
}
|
32
update/v3/forumtopic.php
Normal file
32
update/v3/forumtopic.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Update\V3;
|
||||
|
||||
use Zira\Db\Alter;
|
||||
use Zira\Db\Field;
|
||||
|
||||
class Forumtopic extends Alter {
|
||||
protected $_table = 'forum_topics';
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct($this->_table);
|
||||
}
|
||||
|
||||
public function getFieldsToAdd() {
|
||||
return array(
|
||||
'language' => Field::string()
|
||||
);
|
||||
}
|
||||
|
||||
public function getKeysToDrop() {
|
||||
return array(
|
||||
'forum'
|
||||
);
|
||||
}
|
||||
|
||||
public function getKeysToAdd() {
|
||||
return array(
|
||||
'forum' => array('language', 'category_id','forum_id','sticky','published')
|
||||
);
|
||||
}
|
||||
}
|
|
@ -9,4 +9,19 @@ Zira\Log::write('Updated widgets table');
|
|||
// adding new fields to users table
|
||||
$alterUsers = new \Update\V3\User();
|
||||
$alterUsers->execute();
|
||||
Zira\Log::write('Updated users table');
|
||||
Zira\Log::write('Updated users table');
|
||||
|
||||
$alterForumCategories = new \Update\V3\Forumcategory();
|
||||
if ($alterForumCategories->execute()) {
|
||||
Zira\Log::write('Updated forum categories table');
|
||||
}
|
||||
|
||||
$alterForumForums = new \Update\V3\Forumforum();
|
||||
if ($alterForumForums->execute()) {
|
||||
Zira\Log::write('Updated forum forums table');
|
||||
}
|
||||
|
||||
$alterForumTopics = new \Update\V3\Forumtopic();
|
||||
if ($alterForumTopics->execute()) {
|
||||
Zira\Log::write('Updated forum topics table');
|
||||
}
|
|
@ -82,6 +82,9 @@ abstract class Alter implements \Zira\Db\Implement\Alter {
|
|||
}
|
||||
|
||||
public function execute() {
|
||||
// checking if table is exists
|
||||
$tables = Db::getTables();
|
||||
if (!in_array($this->_table, $tables)) return false;
|
||||
// creating query
|
||||
$query = (string)$this;
|
||||
Db::query($query);
|
||||
|
@ -98,5 +101,6 @@ abstract class Alter implements \Zira\Db\Implement\Alter {
|
|||
$query = 'INSERT INTO '.Db::escapeIdentifier($this->_table).' ('.implode(', ',$fields).') VALUES ('.implode(', ',$values).')';
|
||||
Db::query($query, $data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -106,6 +106,9 @@ abstract class Alter implements \Zira\Db\Implement\Alter {
|
|||
}
|
||||
|
||||
public function execute() {
|
||||
// checking if table is exists
|
||||
$tables = Db::getTables();
|
||||
if (!in_array($this->_table, $tables)) return false;
|
||||
// dropping indexes
|
||||
$this->dropIndexes();
|
||||
// adding fields
|
||||
|
@ -128,5 +131,6 @@ abstract class Alter implements \Zira\Db\Implement\Alter {
|
|||
$query = 'INSERT INTO '.Db::escapeIdentifier($this->_table).' ('.implode(', ',$fields).') VALUES ('.implode(', ',$values).')';
|
||||
Db::query($query, $data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue