mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-26 03:30:48 +03:00
Функционал категорий для блогов
This commit is contained in:
parent
fda4b407a0
commit
9a2bcee1d1
|
@ -62,6 +62,11 @@ class ActionAdmin extends Action {
|
|||
$this->AddEvent('recalcfavourite','EventRecalculateFavourite');
|
||||
$this->AddEvent('recalcvote','EventRecalculateVote');
|
||||
$this->AddEvent('recalctopic','EventRecalculateTopic');
|
||||
$this->AddEventPreg('/^blogcategory$/i','/^modal-add$/i','EventBlogCategoryModalAdd');
|
||||
$this->AddEventPreg('/^blogcategory$/i','/^modal-edit$/i','EventBlogCategoryModalEdit');
|
||||
$this->AddEventPreg('/^blogcategory$/i','/^add$/i','EventBlogCategoryAdd');
|
||||
$this->AddEventPreg('/^blogcategory$/i','/^edit$/i','EventBlogCategoryEdit');
|
||||
$this->AddEvent('blogcategory','EventBlogCategory');
|
||||
}
|
||||
|
||||
|
||||
|
@ -77,6 +82,146 @@ class ActionAdmin extends Action {
|
|||
protected function EventIndex() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Список категорий блогов
|
||||
*/
|
||||
protected function EventBlogCategory() {
|
||||
/**
|
||||
* Обработка удаления
|
||||
*/
|
||||
if ($this->GetParam(0)=='delete' and $oCategory=$this->Blog_GetCategoryById($this->GetParam(1))) {
|
||||
$this->Security_ValidateSendForm();
|
||||
/**
|
||||
* Получаем все дочернии категории
|
||||
*/
|
||||
$aCategoriesId=$this->Blog_GetChildrenCategoriesById($oCategory->getId(),true);
|
||||
$aCategoriesId[]=$oCategory->getId();
|
||||
/**
|
||||
* У блогов проставляем category_id = null
|
||||
*/
|
||||
$this->Blog_ReplaceBlogsCategoryByCategoryId($aCategoriesId,null);
|
||||
/**
|
||||
* Удаляем категории
|
||||
*/
|
||||
$this->Blog_DeleteCategoryByArrayId($aCategoriesId);
|
||||
}
|
||||
/**
|
||||
* Обработка изменения сортировки
|
||||
*/
|
||||
if ($this->GetParam(0)=='sort' and $oCategory=$this->Blog_GetCategoryById($this->GetParam(1))) {
|
||||
$this->Security_ValidateSendForm();
|
||||
$sWay=$this->GetParam(2)=='down' ? 'down' : 'up';
|
||||
$iSortOld=$oCategory->getSort();
|
||||
if ($oCategoryPrev=$this->Blog_GetNextCategoryBySort($iSortOld,$oCategory->getPid(),$sWay)) {
|
||||
$iSortNew=$oCategoryPrev->getSort();
|
||||
$oCategoryPrev->setSort($iSortOld);
|
||||
$this->Blog_UpdateCategory($oCategoryPrev);
|
||||
} else {
|
||||
if ($sWay=='down') {
|
||||
$iSortNew=$iSortOld-1;
|
||||
} else {
|
||||
$iSortNew=$iSortOld+1;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Меняем значения сортировки местами
|
||||
*/
|
||||
$oCategory->setSort($iSortNew);
|
||||
$this->Blog_UpdateCategory($oCategory);
|
||||
}
|
||||
$aCategories=$this->Blog_GetCategoriesTree();
|
||||
$this->Viewer_Assign("aCategories",$aCategories);
|
||||
}
|
||||
|
||||
/**
|
||||
* Загружает модальное окно создания категории бога
|
||||
*/
|
||||
protected function EventBlogCategoryModalAdd() {
|
||||
$this->Viewer_SetResponseAjax('json');
|
||||
$aCategories=$this->Blog_GetCategoriesTree();
|
||||
$oViewer=$this->Viewer_GetLocalViewer();
|
||||
$oViewer->Assign('aCategories',$aCategories);
|
||||
/**
|
||||
* Устанавливаем переменные для ajax ответа
|
||||
*/
|
||||
$this->Viewer_AssignAjax('sText',$oViewer->Fetch("actions/ActionAdmin/blogcategory_form_add.tpl"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Загружает модальное окно редактирования категории бога
|
||||
*/
|
||||
protected function EventBlogCategoryModalEdit() {
|
||||
$this->Viewer_SetResponseAjax('json');
|
||||
if (!($oCategory=$this->Blog_GetCategoryById(getRequestStr('id')))) {
|
||||
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
||||
return;
|
||||
}
|
||||
$aCategories=$this->Blog_GetCategoriesTree();
|
||||
$oViewer=$this->Viewer_GetLocalViewer();
|
||||
$oViewer->Assign('oCategory',$oCategory);
|
||||
$oViewer->Assign('aCategories',$aCategories);
|
||||
/**
|
||||
* Устанавливаем переменные для ajax ответа
|
||||
*/
|
||||
$this->Viewer_AssignAjax('sText',$oViewer->Fetch("actions/ActionAdmin/blogcategory_form_add.tpl"));
|
||||
}
|
||||
|
||||
protected function EventBlogCategoryAdd() {
|
||||
$this->Viewer_SetResponseAjax('json');
|
||||
|
||||
/**
|
||||
* Создаем категорию
|
||||
*/
|
||||
$oCategory=Engine::GetEntity('ModuleBlog_EntityBlogCategory');
|
||||
$oCategory->setTitle(getRequestStr('title'));
|
||||
$oCategory->setUrl(getRequestStr('url'));
|
||||
$oCategory->setSort(getRequestStr('sort'));
|
||||
$oCategory->setPid(getRequestStr('pid'));
|
||||
|
||||
if ($oCategory->_Validate()) {
|
||||
if ($this->Blog_AddCategory($oCategory)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$this->Message_AddError($oCategory->_getValidateError(),$this->Lang_Get('error'));
|
||||
}
|
||||
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
||||
}
|
||||
|
||||
protected function EventBlogCategoryEdit() {
|
||||
$this->Viewer_SetResponseAjax('json');
|
||||
|
||||
if (!($oCategory=$this->Blog_GetCategoryById(getRequestStr('id')))) {
|
||||
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Создаем категорию
|
||||
*/
|
||||
$oCategory->setTitle(getRequestStr('title'));
|
||||
$oCategory->setUrl(getRequestStr('url'));
|
||||
$oCategory->setSort(getRequestStr('sort'));
|
||||
$oCategory->setPid(getRequestStr('pid'));
|
||||
|
||||
if ($oCategory->_Validate()) {
|
||||
if ($this->Blog_UpdateCategory($oCategory)) {
|
||||
/**
|
||||
* Проверяем корректность вложений
|
||||
*/
|
||||
if (count($this->Blog_GetCategoriesTree())<$this->Blog_GetCountCategories()) {
|
||||
$oCategory->setPid(null);
|
||||
$oCategory->setUrlFull($oCategory->getUrl());
|
||||
$this->Blog_UpdateCategory($oCategory);
|
||||
}
|
||||
$this->Blog_RebuildCategoryUrlFull($oCategory);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$this->Message_AddError($oCategory->_getValidateError(),$this->Lang_Get('error'));
|
||||
}
|
||||
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
||||
}
|
||||
/**
|
||||
* Перестроение дерева комментариев, актуально при $config['module']['comment']['use_nested'] = true;
|
||||
*
|
||||
|
|
|
@ -186,6 +186,11 @@ class ActionBlog extends Action {
|
|||
return Router::Action('error');
|
||||
}
|
||||
$this->Hook_Run('blog_add_show');
|
||||
/**
|
||||
* Прогружаем категории блогов
|
||||
*/
|
||||
$aCategories=$this->Blog_GetCategoriesTree();
|
||||
$this->Viewer_Assign('aBlogCategories',$aCategories);
|
||||
/**
|
||||
* Запускаем проверку корректности ввода полей при добалении блога.
|
||||
* Дополнительно проверяем, что был отправлен POST запрос.
|
||||
|
@ -220,6 +225,16 @@ class ActionBlog extends Action {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Устанавливаем категорию для блога
|
||||
*/
|
||||
if (Config::Get('module.blog.category_allow') and ($this->oUserCurrent->isAdministrator() or !Config::Get('module.blog.category_only_admin'))) {
|
||||
if (getRequestStr('blog_category')) {
|
||||
$oBlog->setCategoryId(getRequestStr('blog_category'));
|
||||
} elseif (Config::Get('module.blog.category_allow_empty')) {
|
||||
$oBlog->setCategoryId(null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Создаём блог
|
||||
*/
|
||||
|
@ -230,6 +245,12 @@ class ActionBlog extends Action {
|
|||
* Получаем блог, это для получение полного пути блога, если он в будущем будет зависит от других сущностей(компании, юзер и т.п.)
|
||||
*/
|
||||
$oBlog->Blog_GetBlogById($oBlog->getId());
|
||||
/**
|
||||
* Меняем количество блогов в категории
|
||||
*/
|
||||
if ($oBlog->getCategoryId()) {
|
||||
$this->Blog_IncreaseCategoryCountBlogs($oBlog->getCategoryId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Добавляем событие в ленту
|
||||
|
@ -278,6 +299,11 @@ class ActionBlog extends Action {
|
|||
}
|
||||
|
||||
$this->Hook_Run('blog_edit_show',array('oBlog'=>$oBlog));
|
||||
/**
|
||||
* Прогружаем категории блогов
|
||||
*/
|
||||
$aCategories=$this->Blog_GetCategoriesTree();
|
||||
$this->Viewer_Assign('aBlogCategories',$aCategories);
|
||||
/**
|
||||
* Устанавливаем title страницы
|
||||
*/
|
||||
|
@ -317,6 +343,17 @@ class ActionBlog extends Action {
|
|||
if ($this->oUserCurrent->isAdministrator()) {
|
||||
$oBlog->setUrl(getRequestStr('blog_url')); // разрешаем смену URL блога только админу
|
||||
}
|
||||
/**
|
||||
* Устанавливаем категорию для блога
|
||||
*/
|
||||
$iCategoryIdOld=$oBlog->getCategoryId();
|
||||
if (Config::Get('module.blog.category_allow') and ($this->oUserCurrent->isAdministrator() or !Config::Get('module.blog.category_only_admin'))) {
|
||||
if (getRequestStr('blog_category')) {
|
||||
$oBlog->setCategoryId(getRequestStr('blog_category'));
|
||||
} elseif (Config::Get('module.blog.category_allow_empty')) {
|
||||
$oBlog->setCategoryId(null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Загрузка аватара, делаем ресайзы
|
||||
*/
|
||||
|
@ -341,6 +378,17 @@ class ActionBlog extends Action {
|
|||
$this->Hook_Run('blog_edit_before', array('oBlog'=>$oBlog));
|
||||
if ($this->Blog_UpdateBlog($oBlog)) {
|
||||
$this->Hook_Run('blog_edit_after', array('oBlog'=>$oBlog));
|
||||
|
||||
/**
|
||||
* Меняем количество блогов в категории
|
||||
*/
|
||||
if ($iCategoryIdOld and $iCategoryIdOld!=$oBlog->getCategoryId()) {
|
||||
$this->Blog_DecreaseCategoryCountBlogs($iCategoryIdOld);
|
||||
}
|
||||
if ($oBlog->getCategoryId()) {
|
||||
$this->Blog_IncreaseCategoryCountBlogs($oBlog->getCategoryId());
|
||||
}
|
||||
|
||||
Router::Location($oBlog->getUrlFull());
|
||||
} else {
|
||||
$this->Message_AddErrorSingle($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
||||
|
@ -353,6 +401,7 @@ class ActionBlog extends Action {
|
|||
$_REQUEST['blog_title']=$oBlog->getTitle();
|
||||
$_REQUEST['blog_url']=$oBlog->getUrl();
|
||||
$_REQUEST['blog_type']=$oBlog->getType();
|
||||
$_REQUEST['blog_category']=$oBlog->getCategoryId();
|
||||
$_REQUEST['blog_description']=$oBlog->getDescription();
|
||||
$_REQUEST['blog_limit_rating_topic']=$oBlog->getLimitRatingTopic();
|
||||
$_REQUEST['blog_id']=$oBlog->getId();
|
||||
|
@ -562,6 +611,26 @@ class ActionBlog extends Action {
|
|||
$this->Message_AddError($this->Lang_Get('blog_create_rating_error'),$this->Lang_Get('error'));
|
||||
$bOk=false;
|
||||
}
|
||||
/**
|
||||
* Проверяем категорию блога
|
||||
*/
|
||||
if (Config::Get('module.blog.category_allow')) {
|
||||
if ($oCategory=$this->Blog_GetCategoryById(getRequestStr('blog_category'))) {
|
||||
/**
|
||||
* Проверяем есть ли у этой категории дочернии
|
||||
*/
|
||||
if (Config::Get('module.blog.category_only_children') and $this->Blog_GetCategoriesByPid($oCategory->getId())) {
|
||||
$this->Message_AddError($this->Lang_Get('blog_create_category_error_only_children'),$this->Lang_Get('error'));
|
||||
$bOk=false;
|
||||
}
|
||||
} else {
|
||||
$_REQUEST['blog_category']=null;
|
||||
if (!Config::Get('module.blog.category_allow_empty')) {
|
||||
$this->Message_AddError($this->Lang_Get('blog_create_category_error'),$this->Lang_Get('error'));
|
||||
$bOk=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Выполнение хуков
|
||||
*/
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
* @since 1.0
|
||||
*/
|
||||
class ActionBlogs extends Action {
|
||||
|
||||
protected $iPageCurrent=1;
|
||||
protected $sPageRoot=null;
|
||||
protected $aCategoriesCurrent=array();
|
||||
/**
|
||||
* Инициализация
|
||||
*/
|
||||
|
@ -32,6 +36,7 @@ class ActionBlogs extends Action {
|
|||
$this->Lang_AddLangJs(array(
|
||||
'blog_join','blog_leave'
|
||||
));
|
||||
$this->sPageRoot=Router::GetPath('blogs');
|
||||
}
|
||||
/**
|
||||
* Регистрируем евенты
|
||||
|
@ -39,6 +44,7 @@ class ActionBlogs extends Action {
|
|||
protected function RegisterEvent() {
|
||||
$this->AddEventPreg('/^(page([1-9]\d{0,5}))?$/i','EventShowBlogs');
|
||||
$this->AddEventPreg('/^ajax-search$/i','EventAjaxSearch');
|
||||
$this->AddEventPreg('/^[\w\-\_]+$/i','EventShowBlogsCategory');
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,6 +84,42 @@ class ActionBlogs extends Action {
|
|||
$oViewer->Assign('sBlogsEmptyList',$this->Lang_Get('blogs_search_empty'));
|
||||
$this->Viewer_AssignAjax('sText',$oViewer->Fetch("blog_list.tpl"));
|
||||
}
|
||||
|
||||
protected function EventShowBlogsCategory() {
|
||||
$aParams=$this->GetParams();
|
||||
if (count($aParams)) {
|
||||
if (preg_match('/^page(\d{1,5})$/i',$aParams[count($aParams)-1],$aMatch)) {
|
||||
$this->iPageCurrent=$aMatch[1];
|
||||
array_pop($aParams);
|
||||
}
|
||||
}
|
||||
$sUrlFull=join('/',$aParams);
|
||||
if ($sUrlFull!='') {
|
||||
$sUrlFull=$this->sCurrentEvent.'/'.$sUrlFull;
|
||||
} else {
|
||||
$sUrlFull=$this->sCurrentEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получаем текущую категорию
|
||||
*/
|
||||
if ($oCategory=$this->Blog_GetCategoryByUrlFull($sUrlFull)) {
|
||||
/**
|
||||
* Получаем все дочерние категории
|
||||
*/
|
||||
$aCategoriesId=$this->Blog_GetChildrenCategoriesById($oCategory->getId(),true);
|
||||
$aCategoriesId[]=$oCategory->getId();
|
||||
|
||||
$this->aCategoriesCurrent=$aCategoriesId;
|
||||
$this->sPageRoot=$oCategory->getUrlWeb();
|
||||
$this->Viewer_Assign('oBlogCategoryCurrent',$oCategory);
|
||||
$this->Viewer_Assign('sBlogsRootPage',$oCategory->getUrlWeb());
|
||||
} else {
|
||||
return $this->EventNotFound();
|
||||
}
|
||||
|
||||
return $this->EventShowBlogs();
|
||||
}
|
||||
/**
|
||||
* Отображение списка блогов
|
||||
*/
|
||||
|
@ -105,7 +147,13 @@ class ActionBlogs extends Action {
|
|||
/**
|
||||
* Передан ли номер страницы
|
||||
*/
|
||||
$iPage= preg_match("/^\d+$/i",$this->GetEventMatch(2)) ? $this->GetEventMatch(2) : 1;
|
||||
$iPage=$this->iPageCurrent;
|
||||
if ($this->GetEventMatch(2)) {
|
||||
$iPage=$this->GetEventMatch(2);
|
||||
}
|
||||
if ($this->aCategoriesCurrent) {
|
||||
$aFilter['category_id']=$this->aCategoriesCurrent;
|
||||
}
|
||||
/**
|
||||
* Получаем список блогов
|
||||
*/
|
||||
|
@ -114,7 +162,7 @@ class ActionBlogs extends Action {
|
|||
/**
|
||||
* Формируем постраничность
|
||||
*/
|
||||
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.blog.per_page'),Config::Get('pagination.pages.count'),Router::GetPath('blogs'),array('order'=>$sOrder,'order_way'=>$sOrderWay));
|
||||
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.blog.per_page'),Config::Get('pagination.pages.count'),$this->sPageRoot,array('order'=>$sOrder,'order_way'=>$sOrderWay));
|
||||
/**
|
||||
* Загружаем переменные в шаблон
|
||||
*/
|
||||
|
|
35
classes/blocks/BlockCategoryBlog.class.php
Normal file
35
classes/blocks/BlockCategoryBlog.class.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Обрабатывает блок категорий для блогов
|
||||
*
|
||||
* @package blocks
|
||||
* @since 1.1
|
||||
*/
|
||||
class BlockCategoryBlog extends Block {
|
||||
/**
|
||||
* Запуск обработки
|
||||
*/
|
||||
public function Exec() {
|
||||
$aCategories=$this->Blog_GetCategoriesTree();
|
||||
$aBlogsAll=$this->Blog_GetBlogsByFilter(array('exclude_type' => 'personal'),array(),1,1,array());
|
||||
$this->Viewer_Assign("aBlogCategories",$aCategories);
|
||||
$this->Viewer_Assign("iCountBlogsAll",$aBlogsAll['count']);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -754,7 +754,10 @@ class ModuleBlog extends Module {
|
|||
*/
|
||||
public function DeleteBlog($iBlogId) {
|
||||
if($iBlogId instanceof ModuleBlog_EntityBlog){
|
||||
$iBlogId = $iBlogId->getId();
|
||||
$oBlog=$iBlogId;
|
||||
$iBlogId = $oBlog->getId();
|
||||
} else {
|
||||
$oBlog=$this->Blog_GetBlogById($iBlogId);
|
||||
}
|
||||
/**
|
||||
* Получаем идентификаторы топиков блога. Удаляем топики блога.
|
||||
|
@ -793,6 +796,12 @@ class ModuleBlog extends Module {
|
|||
* Удаляем голосование за блог
|
||||
*/
|
||||
$this->Vote_DeleteVoteByTarget($iBlogId, 'blog');
|
||||
/**
|
||||
* Обновляем категорию блога
|
||||
*/
|
||||
if ($oBlog->getCategoryId()) {
|
||||
$this->DecreaseCategoryCountBlogs($oBlog->getCategoryId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
|
@ -901,5 +910,232 @@ class ModuleBlog extends Module {
|
|||
public function GetBlogItemsByArrayId($aBlogId) {
|
||||
return $this->GetBlogsByArrayId($aBlogId);
|
||||
}
|
||||
/**
|
||||
* Получает список категорий блогов
|
||||
*
|
||||
* @param int|null|bool $iPid ID родительской категории, если false, то не учитывается в выборке
|
||||
* @return array
|
||||
*/
|
||||
public function GetCategoriesByPid($iPid) {
|
||||
return $this->oMapperBlog->GetCategoriesByPid($iPid);
|
||||
}
|
||||
/**
|
||||
* Получает категорию по полному урлу
|
||||
*
|
||||
* @param string $sUrl УРЛ
|
||||
* @return ModuleBlog_EntityBlogCategory|null
|
||||
*/
|
||||
public function GetCategoryByUrlFull($sUrl) {
|
||||
return $this->oMapperBlog->GetCategoryByUrlFull($sUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает дерево категорий блогов
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetCategoriesTree() {
|
||||
$aResult=array();
|
||||
$aCategoriesRow=$this->oMapperBlog->GetCategoriesTree();
|
||||
if (count($aCategoriesRow)) {
|
||||
$aResult=$this->BuildCategoriesRecursive($aCategoriesRow);
|
||||
}
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает дочерние категории
|
||||
*
|
||||
* @param int $iId ID Основной категории
|
||||
* @param bool $bOnlyIds Возвращать сами объекты или только ID
|
||||
* @param array $aCategories Служебный параметр - дочерний список категорий
|
||||
* @param bool $bBegin Служебный параметр - старт рекурсии
|
||||
* @param null $iIdParent Служебный параметр - ID родительской категории
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetChildrenCategoriesById($iId,$bOnlyIds=false,$aCategories=array(),$bBegin=true,$iIdParent=null) {
|
||||
static $aResult;
|
||||
if ($bBegin) {
|
||||
$aResult=array();
|
||||
$aCategories=$this->oMapperBlog->GetCategoriesTree();
|
||||
}
|
||||
|
||||
foreach ($aCategories as $aCategory) {
|
||||
$aCategory['children']=array();
|
||||
$aTmp=$aCategory;
|
||||
unset($aTmp['childNodes']);
|
||||
$aResult[$aCategory['id']]=$aTmp;
|
||||
|
||||
if ($iIdParent) {
|
||||
$aResult[$iIdParent]['children'][]=$bOnlyIds ? $aCategory['id'] : Engine::GetEntity('ModuleBlog_EntityBlogCategory',$aTmp);
|
||||
}
|
||||
if (isset($aCategory['childNodes']) and count($aCategory['childNodes'])>0) {
|
||||
$this->GetChildrenCategoriesById($iId,$bOnlyIds,$aCategory['childNodes'],false,$aCategory['id']);
|
||||
if ($iIdParent) {
|
||||
$aResult[$iIdParent]['children']=array_merge($aResult[$iIdParent]['children'],$aResult[$aCategory['id']]['children']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($aResult[$iId])) {
|
||||
return $aResult[$iId]['children'];
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
/**
|
||||
* Строит дерево категорий блогов
|
||||
*
|
||||
* @param array $aCategories
|
||||
* @param bool $bBegin
|
||||
* @param ModuleBlog_EntityBlogCategory|null $oCategoryParent
|
||||
* @return array
|
||||
*/
|
||||
protected function BuildCategoriesRecursive($aCategories,$bBegin=true,$oCategoryParent=null) {
|
||||
static $aResult;
|
||||
static $iLevel;
|
||||
if ($bBegin) {
|
||||
$aResult=array();
|
||||
$iLevel=0;
|
||||
}
|
||||
foreach ($aCategories as $aCategory) {
|
||||
$aTemp=$aCategory;
|
||||
$aTemp['level']=$iLevel;
|
||||
unset($aTemp['childNodes']);
|
||||
$oCategory=Engine::GetEntity('ModuleBlog_EntityBlogCategory',$aTemp);
|
||||
|
||||
$aResult[]=$oCategory;
|
||||
if (isset($aCategory['childNodes']) and count($aCategory['childNodes'])>0) {
|
||||
$iLevel++;
|
||||
$this->BuildCategoriesRecursive($aCategory['childNodes'],false,$oCategory);
|
||||
}
|
||||
if ($oCategoryParent) {
|
||||
$oCategoryParent->setCountBlogs($oCategory->getCountBlogs()+$oCategoryParent->getCountBlogs());
|
||||
}
|
||||
}
|
||||
$iLevel--;
|
||||
|
||||
return $aResult;
|
||||
}
|
||||
/**
|
||||
* Получает категорию по ID
|
||||
*
|
||||
* @param int $iId УРЛ
|
||||
* @return ModuleBlog_EntityBlogCategory|null
|
||||
*/
|
||||
public function GetCategoryById($iId) {
|
||||
return $this->oMapperBlog->GetCategoryById($iId);
|
||||
}
|
||||
/**
|
||||
* Получает следующую категорию по сортировке
|
||||
*
|
||||
* @param $iSort
|
||||
* @param $sPid
|
||||
* @param $sWay
|
||||
*
|
||||
* @return ModuleBlog_EntityBlogCategory|null
|
||||
*/
|
||||
public function GetNextCategoryBySort($iSort,$sPid,$sWay='up') {
|
||||
return $this->oMapperBlog->GetNextCategoryBySort($iSort,$sPid,$sWay);
|
||||
}
|
||||
/**
|
||||
* Обновление категории
|
||||
*
|
||||
* @param ModuleBlog_EntityBlogCategory $oObject Объект категории
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function UpdateCategory($oObject) {
|
||||
return $this->oMapperBlog->UpdateCategory($oObject);
|
||||
}
|
||||
/**
|
||||
* Добавление категории
|
||||
*
|
||||
* @param ModuleBlog_EntityBlogCategory $oObject
|
||||
*
|
||||
* @return int|bool
|
||||
*/
|
||||
public function AddCategory($oObject) {
|
||||
return $this->oMapperBlog->AddCategory($oObject);
|
||||
}
|
||||
/**
|
||||
* Возвращает максимальное значение сортировки для родительской категории
|
||||
*
|
||||
* @param int|null $sPid
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function GetCategoryMaxSortByPid($sPid) {
|
||||
return $this->oMapperBlog->GetCategoryMaxSortByPid($sPid);
|
||||
}
|
||||
public function RebuildCategoryUrlFull($oCategoryStart,$bStart=true) {
|
||||
static $aRebuildIds;
|
||||
if ($bStart) {
|
||||
$aRebuildIds=array();
|
||||
}
|
||||
$aCategories=$this->GetCategoriesByPid($oCategoryStart->getId());
|
||||
foreach ($aCategories as $oCategory) {
|
||||
if ($oCategory->getId()==$oCategoryStart->getId()) {
|
||||
continue;
|
||||
}
|
||||
if (in_array($oCategory->getId(),$aRebuildIds)) {
|
||||
continue;
|
||||
}
|
||||
$aRebuildIds[]=$oCategory->getId();
|
||||
$oCategory->setUrlFull($oCategoryStart->getUrlFull().'/'.$oCategory->getUrl());
|
||||
$this->UpdateCategory($oCategory);
|
||||
$this->RebuildCategoryUrlFull($oCategory,false);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Возвращает количество категорий
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function GetCountCategories() {
|
||||
return $this->oMapperBlog->GetCountCategories();
|
||||
}
|
||||
/**
|
||||
* Увеличивает количество блогов у категории
|
||||
*
|
||||
* @param int $sId ID категории
|
||||
* @return bool
|
||||
*/
|
||||
public function IncreaseCategoryCountBlogs($sId) {
|
||||
return $this->oMapperBlog->IncreaseCategoryCountBlogs($sId);
|
||||
}
|
||||
/**
|
||||
* Уменьшает количество блогов у категории
|
||||
*
|
||||
* @param int $sId ID категории
|
||||
* @return bool
|
||||
*/
|
||||
public function DecreaseCategoryCountBlogs($sId) {
|
||||
return $this->oMapperBlog->DecreaseCategoryCountBlogs($sId);
|
||||
}
|
||||
/**
|
||||
* Удаляет категории по списку их ID
|
||||
*
|
||||
* @param array $aArrayId Список ID категорий
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function DeleteCategoryByArrayId($aArrayId) {
|
||||
return $this->oMapperBlog->DeleteCategoryByArrayId($aArrayId);
|
||||
}
|
||||
/**
|
||||
* Заменяет категорию на новую у блогов
|
||||
*
|
||||
* @param int| null $iIdOld Старая категори
|
||||
* @param int| null $iIdNew Новая категория
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function ReplaceBlogsCategoryByCategoryId($iIdOld,$iIdNew) {
|
||||
$res=$this->oMapperBlog->ReplaceBlogsCategoryByCategoryId($iIdOld,$iIdNew);
|
||||
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array('blog_update'));
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -38,6 +38,14 @@ class ModuleBlog_EntityBlog extends Entity {
|
|||
public function getOwnerId() {
|
||||
return $this->_getDataOne('user_owner_id');
|
||||
}
|
||||
/**
|
||||
* Возвращает ID категории
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getCategoryId() {
|
||||
return $this->_getDataOne('category_id');
|
||||
}
|
||||
/**
|
||||
* Возвращает название блога
|
||||
*
|
||||
|
@ -226,6 +234,14 @@ class ModuleBlog_EntityBlog extends Entity {
|
|||
public function setOwnerId($data) {
|
||||
$this->_aData['user_owner_id']=$data;
|
||||
}
|
||||
/**
|
||||
* Устанавливает ID категории блога
|
||||
*
|
||||
* @param int $data
|
||||
*/
|
||||
public function setCategoryId($data) {
|
||||
$this->_aData['category_id']=$data;
|
||||
}
|
||||
/**
|
||||
* Устанавливает заголовок блога
|
||||
*
|
||||
|
|
82
classes/modules/blog/entity/BlogCategory.entity.class.php
Normal file
82
classes/modules/blog/entity/BlogCategory.entity.class.php
Normal file
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Сущность категории блога
|
||||
*
|
||||
* @package modules.blog
|
||||
* @since 1.1
|
||||
*/
|
||||
class ModuleBlog_EntityBlogCategory extends Entity {
|
||||
/**
|
||||
* Определяем правила валидации
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $aValidateRules=array(
|
||||
array('url','regexp','pattern'=>'/^[\w\-_]+$/i','allowEmpty'=>false),
|
||||
array('title','string','max'=>100,'min'=>1,'allowEmpty'=>false),
|
||||
array('sort','number','integerOnly'=>true),
|
||||
array('pid','parent_category'),
|
||||
array('sort','sort_check'),
|
||||
);
|
||||
/**
|
||||
* Проверка родительской категории
|
||||
*
|
||||
* @param string $sValue Валидируемое значение
|
||||
* @param array $aParams Параметры
|
||||
* @return bool
|
||||
*/
|
||||
public function ValidateParentCategory($sValue,$aParams) {
|
||||
if ($this->getPid()) {
|
||||
if ($oCategory=$this->Blog_GetCategoryById($this->getPid())) {
|
||||
if ($oCategory->getId()==$this->getId()) {
|
||||
return 'Попытка вложить категорию в саму себя';
|
||||
}
|
||||
$this->setUrlFull($oCategory->getUrlFull().'/'.$this->getUrl());
|
||||
} else {
|
||||
return 'Неверная категория';
|
||||
}
|
||||
} else {
|
||||
$this->setPid(null);
|
||||
$this->setUrlFull($this->getUrl());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Установка дефолтной сортировки
|
||||
*
|
||||
* @param string $sValue Валидируемое значение
|
||||
* @param array $aParams Параметры
|
||||
* @return bool
|
||||
*/
|
||||
public function ValidateSortCheck($sValue,$aParams) {
|
||||
if (!$this->getSort()) {
|
||||
$this->setSort($this->Blog_GetCategoryMaxSortByPid($this->getPid())+1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Возвращает полный URL категории
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrlWeb() {
|
||||
return Router::GetPath('blogs').$this->getUrlFull().'/';
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -34,14 +34,15 @@ class ModuleBlog_MapperBlog extends Mapper {
|
|||
blog_title,
|
||||
blog_description,
|
||||
blog_type,
|
||||
category_id,
|
||||
blog_date_add,
|
||||
blog_limit_rating_topic,
|
||||
blog_url,
|
||||
blog_avatar
|
||||
)
|
||||
VALUES(?d, ?, ?, ?, ?, ?, ?, ?)
|
||||
VALUES(?d, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
";
|
||||
if ($iId=$this->oDb->query($sql,$oBlog->getOwnerId(),$oBlog->getTitle(),$oBlog->getDescription(),$oBlog->getType(),$oBlog->getDateAdd(),$oBlog->getLimitRatingTopic(),$oBlog->getUrl(),$oBlog->getAvatar())) {
|
||||
if ($iId=$this->oDb->query($sql,$oBlog->getOwnerId(),$oBlog->getTitle(),$oBlog->getDescription(),$oBlog->getType(),$oBlog->getCategoryId(),$oBlog->getDateAdd(),$oBlog->getLimitRatingTopic(),$oBlog->getUrl(),$oBlog->getAvatar())) {
|
||||
return $iId;
|
||||
}
|
||||
return false;
|
||||
|
@ -58,6 +59,7 @@ class ModuleBlog_MapperBlog extends Mapper {
|
|||
blog_title= ?,
|
||||
blog_description= ?,
|
||||
blog_type= ?,
|
||||
category_id= ?,
|
||||
blog_date_edit= ?,
|
||||
blog_rating= ?f,
|
||||
blog_count_vote = ?d,
|
||||
|
@ -69,7 +71,7 @@ class ModuleBlog_MapperBlog extends Mapper {
|
|||
WHERE
|
||||
blog_id = ?d
|
||||
";
|
||||
if ($this->oDb->query($sql,$oBlog->getTitle(),$oBlog->getDescription(),$oBlog->getType(),$oBlog->getDateEdit(),$oBlog->getRating(),$oBlog->getCountVote(),$oBlog->getCountUser(),$oBlog->getCountTopic(),$oBlog->getLimitRatingTopic(),$oBlog->getUrl(),$oBlog->getAvatar(),$oBlog->getId())) {
|
||||
if ($this->oDb->query($sql,$oBlog->getTitle(),$oBlog->getDescription(),$oBlog->getType(),$oBlog->getCategoryId(),$oBlog->getDateEdit(),$oBlog->getRating(),$oBlog->getCountVote(),$oBlog->getCountUser(),$oBlog->getCountTopic(),$oBlog->getLimitRatingTopic(),$oBlog->getUrl(),$oBlog->getAvatar(),$oBlog->getId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -116,6 +118,242 @@ class ModuleBlog_MapperBlog extends Mapper {
|
|||
}
|
||||
return $aBlogs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получает список категорий блогов
|
||||
*
|
||||
* @param int|null|bool $iPid ID родительской категории, если false, то не учитывается в выборке
|
||||
* @return array
|
||||
*/
|
||||
public function GetCategoriesByPid($iPid) {
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
".Config::Get('db.table.blog_category')."
|
||||
WHERE
|
||||
1 = 1
|
||||
{ AND pid = ?d }
|
||||
{ AND pid IS NULL and 1=?d }
|
||||
ORDER by title asc
|
||||
";
|
||||
$aReturn=array();
|
||||
if ($aRows=$this->oDb->select($sql,$iPid ? $iPid : DBSIMPLE_SKIP,is_null($iPid) ? 1 : DBSIMPLE_SKIP)) {
|
||||
foreach ($aRows as $aRow) {
|
||||
$aReturn[]=Engine::GetEntity('ModuleBlog_EntityBlogCategory',$aRow);
|
||||
}
|
||||
}
|
||||
return $aReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает список категорий с учетом вложенности
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function GetCategoriesTree() {
|
||||
$sql = "SELECT
|
||||
*,
|
||||
id as ARRAY_KEY,
|
||||
pid as PARENT_KEY
|
||||
FROM
|
||||
".Config::Get('db.table.blog_category')."
|
||||
ORDER by sort desc;
|
||||
";
|
||||
if ($aRows=$this->oDb->select($sql)) {
|
||||
return $aRows;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Получает категорию по полному урлу
|
||||
*
|
||||
* @param string $sUrl УРЛ
|
||||
* @return ModuleBlog_EntityBlogCategory|null
|
||||
*/
|
||||
public function GetCategoryByUrlFull($sUrl) {
|
||||
$sql = "SELECT * FROM ".Config::Get('db.table.blog_category')." WHERE url_full = ? ";
|
||||
if ($aRow=$this->oDb->selectRow($sql,$sUrl)) {
|
||||
return Engine::GetEntity('ModuleBlog_EntityBlogCategory',$aRow);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Получает категорию по ID
|
||||
*
|
||||
* @param int $iId УРЛ
|
||||
* @return ModuleBlog_EntityBlogCategory|null
|
||||
*/
|
||||
public function GetCategoryById($iId) {
|
||||
$sql = "SELECT * FROM ".Config::Get('db.table.blog_category')." WHERE id = ?d ";
|
||||
if ($aRow=$this->oDb->selectRow($sql,$iId)) {
|
||||
return Engine::GetEntity('ModuleBlog_EntityBlogCategory',$aRow);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получает следующую категорию по сортировке
|
||||
*
|
||||
* @param $iSort
|
||||
* @param $sPid
|
||||
* @param $sWay
|
||||
*
|
||||
* @return ModuleBlog_EntityBlogCategory|null
|
||||
*/
|
||||
public function GetNextCategoryBySort($iSort,$sPid,$sWay) {
|
||||
if ($sWay=='up') {
|
||||
$sWay='>';
|
||||
$sOrder='asc';
|
||||
} else {
|
||||
$sWay='<';
|
||||
$sOrder='desc';
|
||||
}
|
||||
$sPidNULL='';
|
||||
if (is_null($sPid)) {
|
||||
$sPidNULL='pid IS NULL and';
|
||||
}
|
||||
$sql = "SELECT * FROM ".Config::Get('db.table.blog_category')." WHERE { pid = ? and } {$sPidNULL} sort {$sWay} ? order by sort {$sOrder} limit 0,1";
|
||||
if ($aRow=$this->oDb->selectRow($sql,is_null($sPid) ? DBSIMPLE_SKIP : $sPid, $iSort)) {
|
||||
return Engine::GetEntity('ModuleBlog_EntityBlogCategory',$aRow);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает максимальное значение сортировки для родительской категории
|
||||
*
|
||||
* @param int|null $sPid
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function GetCategoryMaxSortByPid($sPid) {
|
||||
$sql = "SELECT max(sort) as max_sort FROM ".Config::Get('db.table.blog_category')." WHERE 1=1 { and pid = ? } { and pid IS NULL and 1=?d } ";
|
||||
if ($aRow=$this->oDb->selectRow($sql,is_null($sPid) ? DBSIMPLE_SKIP : $sPid,!is_null($sPid) ? DBSIMPLE_SKIP : 1)) {
|
||||
return $aRow['max_sort'];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* Обновление категории
|
||||
*
|
||||
* @param ModuleBlog_EntityBlogCategory $oObject Объект категории
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function UpdateCategory($oObject) {
|
||||
$sql = "UPDATE ".Config::Get('db.table.blog_category')." SET ?a WHERE id = ?d ";
|
||||
$res=$this->oDb->query($sql,$oObject->_getData(array('pid','title','url','url_full','sort','count_blogs')),$oObject->getId());
|
||||
return $res===false or is_null($res) ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Добавление категории
|
||||
*
|
||||
* @param ModuleBlog_EntityBlogCategory $oObject
|
||||
*
|
||||
* @return int|bool
|
||||
*/
|
||||
public function AddCategory($oObject) {
|
||||
$sql = "INSERT INTO ".Config::Get('db.table.blog_category')." SET ?a ";
|
||||
if ($iId=$this->oDb->query($sql,$oObject->_getData())) {
|
||||
return $iId;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает количество категорий
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function GetCountCategories() {
|
||||
$sql = "SELECT count(*) as count FROM ".Config::Get('db.table.blog_category')." ";
|
||||
if ($aRow=$this->oDb->selectRow($sql)) {
|
||||
return $aRow['count'];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* Увеличивает количество блогов у категории
|
||||
*
|
||||
* @param int $sId ID категории
|
||||
* @return bool
|
||||
*/
|
||||
public function IncreaseCategoryCountBlogs($sId) {
|
||||
$sql = "UPDATE ".Config::Get('db.table.blog_category')."
|
||||
SET
|
||||
count_blogs=count_blogs+1
|
||||
WHERE
|
||||
id = ?
|
||||
";
|
||||
if ($this->oDb->query($sql,$sId)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Уменьшает количество блогов у категории
|
||||
*
|
||||
* @param int $sId ID категории
|
||||
* @return bool
|
||||
*/
|
||||
public function DecreaseCategoryCountBlogs($sId) {
|
||||
$sql = "UPDATE ".Config::Get('db.table.blog_category')."
|
||||
SET
|
||||
count_blogs=count_blogs-1
|
||||
WHERE
|
||||
id = ?
|
||||
";
|
||||
if ($this->oDb->query($sql,$sId)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Удаляет категории по списку их ID
|
||||
*
|
||||
* @param array $aArrayId Список ID категорий
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function DeleteCategoryByArrayId($aArrayId) {
|
||||
if (!is_array($aArrayId)) {
|
||||
$aArrayId=array($aArrayId);
|
||||
}
|
||||
$sql = "DELETE FROM ".Config::Get('db.table.blog_category')."
|
||||
WHERE
|
||||
id IN (?a)
|
||||
";
|
||||
if ($this->oDb->query($sql,$aArrayId)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Заменяет категорию на новую у блогов
|
||||
*
|
||||
* @param int|array|null $iIdOld Старая категори
|
||||
* @param int|null $iIdNew Новая категория
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function ReplaceBlogsCategoryByCategoryId($iIdOld,$iIdNew) {
|
||||
if (!is_null($iIdOld) and !is_array($iIdOld)) {
|
||||
$iIdOld=array($iIdOld);
|
||||
}
|
||||
$sql = "UPDATE ".Config::Get('db.table.blog')."
|
||||
SET
|
||||
category_id = ?
|
||||
WHERE
|
||||
1 = 1
|
||||
{ and category_id IN ( ?a ) }
|
||||
{ and category_id IS NULL and 1 = ?d }
|
||||
";
|
||||
if ($this->oDb->query($sql,$iIdNew,is_null($iIdOld) ? DBSIMPLE_SKIP : $iIdOld,!is_null($iIdOld) ? DBSIMPLE_SKIP : 1)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Добавляет свзяь пользователя с блогом в БД
|
||||
*
|
||||
|
@ -528,6 +766,9 @@ class ModuleBlog_MapperBlog extends Mapper {
|
|||
if (isset($aFilter['type']) and !is_array($aFilter['type'])) {
|
||||
$aFilter['type']=array($aFilter['type']);
|
||||
}
|
||||
if (isset($aFilter['category_id']) and !is_array($aFilter['category_id'])) {
|
||||
$aFilter['category_id']=array($aFilter['category_id']);
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
blog_id
|
||||
|
@ -541,6 +782,8 @@ class ModuleBlog_MapperBlog extends Mapper {
|
|||
{ AND blog_type not IN (?a) }
|
||||
{ AND blog_url = ? }
|
||||
{ AND blog_title LIKE ? }
|
||||
{ AND category_id IN (?a) }
|
||||
{ AND category_id IS NULL and 1=?d}
|
||||
ORDER by {$sOrder}
|
||||
LIMIT ?d, ?d ;
|
||||
";
|
||||
|
@ -552,6 +795,8 @@ class ModuleBlog_MapperBlog extends Mapper {
|
|||
(isset($aFilter['exclude_type']) and count($aFilter['exclude_type']) ) ? $aFilter['exclude_type'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['url']) ? $aFilter['url'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['title']) ? $aFilter['title'] : DBSIMPLE_SKIP,
|
||||
(isset($aFilter['category_id']) and count($aFilter['category_id'])) ? $aFilter['category_id'] : DBSIMPLE_SKIP,
|
||||
(array_key_exists('category_id',$aFilter) and is_null($aFilter['category_id'])) ? 1 : DBSIMPLE_SKIP,
|
||||
($iCurrPage-1)*$iPerPage, $iPerPage
|
||||
)) {
|
||||
foreach ($aRows as $aRow) {
|
||||
|
|
|
@ -188,6 +188,10 @@ $config['module']['blog']['collective_good'] = -3; // рейтинг топи
|
|||
$config['module']['blog']['index_good'] = 8; // Рейтинг топика выше которого(включительно) он попадает на главную
|
||||
$config['module']['blog']['encrypt'] = 'livestreet'; // Ключ XXTEA шифрования идентификаторов в ссылках приглашения в блоги
|
||||
$config['module']['blog']['avatar_size'] = array(100,64,48,24,0); // Список размеров аватаров у блога. 0 - исходный размер
|
||||
$config['module']['blog']['category_allow'] = true; // Разрешить использование категорий бля блогов
|
||||
$config['module']['blog']['category_only_admin'] = true; // Задавать и менять категории для блога может только админ
|
||||
$config['module']['blog']['category_only_children'] = true; // Для блога можно выбрать только конечную категорию, у которой нет других вложенных
|
||||
$config['module']['blog']['category_allow_empty'] = true; // Разрешить блоги без категории
|
||||
// Модуль Topic
|
||||
$config['module']['topic']['new_time'] = 60*60*24*1; // Время в секундах в течении которого топик считается новым
|
||||
$config['module']['topic']['per_page'] = 10; // Число топиков на одну страницу
|
||||
|
@ -323,6 +327,7 @@ $config['db']['table']['prefix'] = 'prefix_';
|
|||
|
||||
$config['db']['table']['user'] = '___db.table.prefix___user';
|
||||
$config['db']['table']['blog'] = '___db.table.prefix___blog';
|
||||
$config['db']['table']['blog_category'] = '___db.table.prefix___blog_category';
|
||||
$config['db']['table']['topic'] = '___db.table.prefix___topic';
|
||||
$config['db']['table']['topic_tag'] = '___db.table.prefix___topic_tag';
|
||||
$config['db']['table']['comment'] = '___db.table.prefix___comment';
|
||||
|
@ -447,7 +452,7 @@ $config['block']['rule_tag'] = array(
|
|||
);
|
||||
$config['block']['rule_blogs'] = array(
|
||||
'action' => array( 'blogs' ),
|
||||
'blocks' => array( 'right' => array('stream') ),
|
||||
'blocks' => array( 'right' => array('categoryBlog') ),
|
||||
);
|
||||
|
||||
$config['block']['userfeedBlogs'] = array(
|
||||
|
@ -532,6 +537,7 @@ $config['head']['default']['js'] = array(
|
|||
"___path.static.framework___/js/livestreet/toolbar.js",
|
||||
"___path.static.framework___/js/livestreet/settings.js",
|
||||
"___path.static.framework___/js/livestreet/topic.js",
|
||||
"___path.static.framework___/js/livestreet/admin.js",
|
||||
|
||||
"http://yandex.st/share/share.js" => array('merge'=>false),
|
||||
);
|
||||
|
|
|
@ -1,2 +1,32 @@
|
|||
ALTER TABLE `prefix_subscribe` ADD `user_id` INT( 11 ) UNSIGNED NULL DEFAULT NULL AFTER `target_id` ,
|
||||
ADD INDEX ( `user_id` ) ;
|
||||
ADD INDEX ( `user_id` ) ;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `prefix_blog_category` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`pid` int(11) DEFAULT NULL,
|
||||
`title` varchar(200) NOT NULL,
|
||||
`url` varchar(100) NOT NULL,
|
||||
`url_full` varchar(200) NOT NULL,
|
||||
`sort` int(11) NOT NULL DEFAULT '0',
|
||||
`count_blogs` int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `pid` (`pid`),
|
||||
KEY `count_blogs` (`count_blogs`),
|
||||
KEY `title` (`title`),
|
||||
KEY `url` (`url`),
|
||||
KEY `url_full` (`url_full`),
|
||||
KEY `sort` (`sort`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
ALTER TABLE `prefix_blog_category`
|
||||
ADD CONSTRAINT `prefix_blog_category_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `prefix_blog_category` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
|
||||
ALTER TABLE `prefix_blog` ADD `category_id` INT NULL DEFAULT NULL AFTER `user_owner_id` ,
|
||||
ADD INDEX ( `category_id` ) ;
|
||||
|
||||
ALTER TABLE `prefix_blog` ADD FOREIGN KEY ( `category_id` ) REFERENCES `prefix_blog_category` (
|
||||
`id`
|
||||
) ON DELETE CASCADE ON UPDATE CASCADE ;
|
41
templates/framework/js/livestreet/admin.js
Normal file
41
templates/framework/js/livestreet/admin.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
var ls = ls || {};
|
||||
|
||||
/**
|
||||
* JS функционал админки
|
||||
*/
|
||||
ls.admin = (function ($) {
|
||||
|
||||
this.addCategoryBlog = function(form) {
|
||||
var url = aRouter.admin+'blogcategory/add/';
|
||||
ls.ajaxSubmit(url, form, function(result) {
|
||||
if (typeof(form)=='string') {
|
||||
form=$('#'+form);
|
||||
}
|
||||
|
||||
if (result.bStateError) {
|
||||
ls.msg.error(result.sMsgTitle,result.sMsg);
|
||||
} else {
|
||||
$(form.parents('.modal-ajax')).jqmHide();
|
||||
window.location.href=window.location.href;
|
||||
}
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
this.editCategoryBlog = function(form) {
|
||||
var url = aRouter.admin+'blogcategory/edit/';
|
||||
ls.ajaxSubmit(url, form, function(result) {
|
||||
if (typeof(form)=='string') {
|
||||
form=$('#'+form);
|
||||
}
|
||||
|
||||
if (result.bStateError) {
|
||||
ls.msg.error(result.sMsgTitle,result.sMsg);
|
||||
} else {
|
||||
$(form.parents('.modal-ajax')).jqmHide();
|
||||
window.location.href=window.location.href;
|
||||
}
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
return this;
|
||||
}).call(ls.admin || {},jQuery);
|
|
@ -115,6 +115,10 @@ return array(
|
|||
'blog_delete' => 'Delete',
|
||||
'blog_create' => 'Create new blog',
|
||||
'blog_create_acl' => "You don't have enough power to create a blog",
|
||||
'blog_create_category' => 'Category',
|
||||
'blog_create_category_notice' => 'Blogs can assign a category, it will allow a more structured site',
|
||||
'blog_create_category_error' => 'Could not find the category',
|
||||
'blog_create_category_error_only_children' => 'You can select only the final category (without children)',
|
||||
'blog_create_title' => "Blog's title",
|
||||
'blog_create_title_notice' => "Blog's title should be meaningful.",
|
||||
'blog_create_title_error' => "Blog's title should be at least 2 and upto 200 characters",
|
||||
|
@ -762,6 +766,8 @@ return array(
|
|||
'block_friends_check' => 'Check all',
|
||||
'block_friends_uncheck' => 'Uncheck',
|
||||
'block_friends_empty' => 'Empty friends list',
|
||||
'block_category_blog' => 'Categories',
|
||||
'block_category_blog_all' => 'All',
|
||||
'site_history_back' => 'Go back',
|
||||
'site_go_main' => 'Go to the main page',
|
||||
/**
|
||||
|
@ -925,10 +931,27 @@ return array(
|
|||
'admin_header' => 'Admin panel',
|
||||
'admin_list_plugins' => 'Manage plugins',
|
||||
'admin_list_userfields' => 'Configuring custom fields',
|
||||
'admin_list_blogcategory' => 'Settings categories of blogs',
|
||||
'admin_list_restorecomment' => 'Rebuilding a tree comments',
|
||||
'admin_list_recalcfavourite' => 'Recalculate counters of favorites',
|
||||
'admin_list_recalcvote' => 'Recalculate counters of votes',
|
||||
'admin_list_recalctopic' => 'Recalculate count topics of blogs',
|
||||
/**
|
||||
* Setting categories of blogs
|
||||
*/
|
||||
'admin_blogcategory_add' => 'Create new category',
|
||||
'admin_blogcategory_items_title' => 'Title',
|
||||
'admin_blogcategory_items_url' => 'URL',
|
||||
'admin_blogcategory_items_action' => 'Action',
|
||||
'admin_blogcategory_items_delete_confirm' => 'Really delete this category with all attachments?',
|
||||
'admin_blogcategory_form_add' => 'Create category',
|
||||
'admin_blogcategory_form_edit' => 'Update category',
|
||||
'admin_blogcategory_form_field_parent' => 'Attach to',
|
||||
'admin_blogcategory_form_field_title' => 'Title',
|
||||
'admin_blogcategory_form_field_url' => 'URL',
|
||||
'admin_blogcategory_form_field_sort' => 'Sort',
|
||||
'admin_blogcategory_form_add_submit' => 'Add',
|
||||
'admin_blogcategory_form_edit_submit' => 'Save',
|
||||
/**
|
||||
* Rating TOP
|
||||
*/
|
||||
|
|
|
@ -115,6 +115,10 @@ return array(
|
|||
'blog_delete' => 'Удалить',
|
||||
'blog_create' => 'Создание нового блога',
|
||||
'blog_create_acl' => 'Вы еще не достаточно окрепли, чтобы создавать свой блог',
|
||||
'blog_create_category' => 'Категория бога',
|
||||
'blog_create_category_notice' => 'Блогу можно назначить категорию, что позволяет более глубоко структурировать сайт',
|
||||
'blog_create_category_error' => 'Не удалось найти категорию блога',
|
||||
'blog_create_category_error_only_children' => 'Можно выбрать только конечную категорию (без дочерних)',
|
||||
'blog_create_title' => 'Название блога',
|
||||
'blog_create_title_notice' => 'Название блога должно быть наполнено смыслом, чтобы можно было понять, о чем будет блог.',
|
||||
'blog_create_title_error' => 'Название блога должно быть от 2 до 200 символов',
|
||||
|
@ -764,6 +768,8 @@ return array(
|
|||
'block_friends_check' => 'Отметить всех',
|
||||
'block_friends_uncheck' => 'Снять отметку',
|
||||
'block_friends_empty' => 'Список ваших друзей пуст',
|
||||
'block_category_blog' => 'Категории',
|
||||
'block_category_blog_all' => 'Все',
|
||||
'site_history_back' => 'Вернуться назад',
|
||||
'site_go_main' => 'перейти на главную',
|
||||
/**
|
||||
|
@ -926,10 +932,27 @@ return array(
|
|||
'admin_header' => 'Админка',
|
||||
'admin_list_plugins' => 'Управление плагинами',
|
||||
'admin_list_userfields' => 'Настройка пользовательских полей',
|
||||
'admin_list_blogcategory' => 'Настройка категорий блогов',
|
||||
'admin_list_restorecomment' => 'Перестроение дерева комментариев',
|
||||
'admin_list_recalcfavourite' => 'Пересчитать счетчики избранных',
|
||||
'admin_list_recalcvote' => 'Пересчитать счетчики голосований',
|
||||
'admin_list_recalctopic' => 'Пересчитать количество топиков в блогах',
|
||||
/**
|
||||
* Управление категориями блогов
|
||||
*/
|
||||
'admin_blogcategory_add' => 'Добавить новую категорию',
|
||||
'admin_blogcategory_items_title' => 'Название',
|
||||
'admin_blogcategory_items_url' => 'УРЛ',
|
||||
'admin_blogcategory_items_action' => 'Действие',
|
||||
'admin_blogcategory_items_delete_confirm' => 'Действительно удалить категорию со всеми вложенными?',
|
||||
'admin_blogcategory_form_add' => 'Добавление категории',
|
||||
'admin_blogcategory_form_edit' => 'Редактирование категории',
|
||||
'admin_blogcategory_form_field_parent' => 'Вложить в',
|
||||
'admin_blogcategory_form_field_title' => 'Название',
|
||||
'admin_blogcategory_form_field_url' => 'УРЛ',
|
||||
'admin_blogcategory_form_field_sort' => 'Сортировка',
|
||||
'admin_blogcategory_form_add_submit' => 'Добавить',
|
||||
'admin_blogcategory_form_edit_submit' => 'Сохранить',
|
||||
/**
|
||||
* Рейтинг TOP
|
||||
*/
|
||||
|
@ -1045,7 +1068,7 @@ return array(
|
|||
'validate_compare_must_less' => 'Поле %%field%% должно быть меньше чем %%compare_value%%',
|
||||
'validate_compare_must_less_equal' => 'Поле %%field%% должно быть меньше или равно %%compare_value%%',
|
||||
'validate_compare_invalid_operator' => 'У поля %%field%% неверный оператор сравнения %%operator%%',
|
||||
'validate_regexp_not_valid' => 'Поля %%field%% неверное',
|
||||
'validate_regexp_not_valid' => 'Поле %%field%% неверное',
|
||||
'validate_regexp_invalid_pattern' => 'У поля %%field%% неверное регулярное выражение',
|
||||
'validate_tags_count_more' => 'Поле %%field%% содержит слишком много тегов (максимально допустимо %%count%%)',
|
||||
'validate_tags_empty' => 'Поле %%field%% не содержит тегов, либо содержит неверные теги (размер тега допустим от %%min%% до %%max%% символов)',
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
{include file='header.tpl'}
|
||||
|
||||
<h3>{$aLang.admin_list_blogcategory}</h3>
|
||||
|
||||
<a href="#" data-type="modal-toggle" data-option-url="{router page='admin'}blogcategory/modal-add/">{$aLang.admin_blogcategory_add}</a>
|
||||
|
||||
<table cellspacing="0" class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="180px">{$aLang.admin_blogcategory_items_title}</th>
|
||||
<th align="center" >{$aLang.admin_blogcategory_items_url}</th>
|
||||
<th align="center" width="80px">{$aLang.admin_blogcategory_items_action}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{foreach from=$aCategories item=oCategory}
|
||||
<tr>
|
||||
<td>
|
||||
<img src="{$aTemplateWebPathPlugin.page|cat:'images/'}{if $oCategory->getLevel()==0}folder{else}document{/if}.gif" alt="" title="" style="margin-left: {$oCategory->getLevel()*20}px;" />
|
||||
<a href="{$oCategory->getUrlWeb()}" border="0">{$oCategory->getTitle()|escape:'html'}</a>
|
||||
</td>
|
||||
<td>
|
||||
/{$oCategory->getUrlFull()}/
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="#" data-type="modal-toggle" data-option-url="{router page='admin'}blogcategory/modal-edit/" data-param-id="{$oCategory->getId()}"><img src="{$aTemplateWebPathPlugin.page|cat:'images/edit.png'}" /></a>
|
||||
<a href="{router page='admin'}blogcategory/delete/{$oCategory->getId()}/?security_ls_key={$LIVESTREET_SECURITY_KEY}" onclick="return confirm('«{$oCategory->getTitle()|escape:'html'}»: {$aLang.admin_blogcategory_items_delete_confirm}');"><img src="{$aTemplateWebPathPlugin.page|cat:'images/delete.png'}" /></a>
|
||||
|
||||
<a href="{router page='admin'}blogcategory/sort/{$oCategory->getId()}/?security_ls_key={$LIVESTREET_SECURITY_KEY}"><img src="{$aTemplateWebPathPlugin.page|cat:'images/up.png'}" /></a>
|
||||
<a href="{router page='admin'}blogcategory/sort/{$oCategory->getId()}/down/?security_ls_key={$LIVESTREET_SECURITY_KEY}"><img src="{$aTemplateWebPathPlugin.page|cat:'images/down.png'}" /></a>
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
{include file='footer.tpl'}
|
|
@ -0,0 +1,46 @@
|
|||
{extends file='modals/modal_base.tpl'}
|
||||
|
||||
{block name='options'}
|
||||
{assign var='noFooter' value=true}
|
||||
{/block}
|
||||
|
||||
{block name='id'}modal-category-add{/block}
|
||||
{block name='class'}js-modal-default{/block}
|
||||
{block name='title'}
|
||||
{if $oCategory}
|
||||
{$aLang.admin_blogcategory_form_edit}
|
||||
{else}
|
||||
{$aLang.admin_blogcategory_form_add}
|
||||
{/if}
|
||||
{/block}
|
||||
|
||||
{block name='content'}
|
||||
<form action="" method="post" id="form-category-blog-add" onsubmit="ls.admin.{if $oCategory}editCategoryBlog{else}addCategoryBlog{/if}('form-category-blog-add'); return false;">
|
||||
{$aLang.admin_blogcategory_form_field_parent}<br/>
|
||||
<select name="pid">
|
||||
<option value="0"></option>
|
||||
{foreach from=$aCategories item=oCategoryItem}
|
||||
<option {if $oCategory and $oCategory->getPid()==$oCategoryItem->getId()}selected="selected"{/if} style="margin-left: {$oCategoryItem->getLevel()*20}px;" value="{$oCategoryItem->getId()}">{$oCategoryItem->getTitle()|escape:'html'}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<br/>
|
||||
|
||||
{$aLang.admin_blogcategory_form_field_title}<br/>
|
||||
<input type="text" name="title" value="{if $oCategory}{$oCategory->getTitle()}{/if}">
|
||||
<br/>
|
||||
|
||||
{$aLang.admin_blogcategory_form_field_url}<br/>
|
||||
<input type="text" name="url" value="{if $oCategory}{$oCategory->getUrl()}{/if}">
|
||||
<br/>
|
||||
|
||||
{$aLang.admin_blogcategory_form_field_sort}<br/>
|
||||
<input type="text" name="sort" value="{if $oCategory}{$oCategory->getSort()}{/if}">
|
||||
<br/>
|
||||
|
||||
<button type="submit" name="submit" class="button button-primary">{if $oCategory}{$aLang.admin_blogcategory_form_edit_submit}{else}{$aLang.admin_blogcategory_form_add_submit}{/if}</button>
|
||||
|
||||
{if $oCategory}
|
||||
<input type="hidden" name="id" value="{$oCategory->getId()}">
|
||||
{/if}
|
||||
</form>
|
||||
{/block}
|
|
@ -7,6 +7,7 @@
|
|||
<ul>
|
||||
<li><a href="{router page="admin"}plugins/">{$aLang.admin_list_plugins}</a></li>
|
||||
<li><a href="{router page="admin"}userfields/">{$aLang.admin_list_userfields}</a></li>
|
||||
<li><a href="{router page="admin"}blogcategory/">{$aLang.admin_list_blogcategory}</a></li>
|
||||
<li><a href="{router page="admin"}restorecomment/?security_ls_key={$LIVESTREET_SECURITY_KEY}">{$aLang.admin_list_restorecomment}</a></li>
|
||||
<li><a href="{router page="admin"}recalcfavourite/?security_ls_key={$LIVESTREET_SECURITY_KEY}">{$aLang.admin_list_recalcfavourite}</a></li>
|
||||
<li><a href="{router page="admin"}recalcvote/?security_ls_key={$LIVESTREET_SECURITY_KEY}">{$aLang.admin_list_recalcvote}</a></li>
|
||||
|
|
|
@ -29,7 +29,19 @@
|
|||
<p><label for="blog_url">{$aLang.blog_create_url}:</label>
|
||||
<input type="text" id="blog_url" name="blog_url" value="{$_aRequest.blog_url}" class="input-text input-width-full" {if $_aRequest.blog_id and !$oUserCurrent->isAdministrator()}disabled{/if} />
|
||||
<small class="note">{$aLang.blog_create_url_notice}</small></p>
|
||||
|
||||
|
||||
{if Config::Get('module.blog.category_allow') and ($oUserCurrent->isAdministrator() or !Config::Get('module.blog.category_only_admin'))}
|
||||
<p><label for="blog_category">{$aLang.blog_create_category}:</label>
|
||||
<select name="blog_category" id="blog_category" class="input-width-200" >
|
||||
{if Config::Get('module.blog.category_allow_empty')}
|
||||
<option value="0"></option>
|
||||
{/if}
|
||||
{foreach from=$aBlogCategories item=oBlogCategory}
|
||||
<option {if $_aRequest.blog_category==$oBlogCategory->getId()}selected{/if} value="{$oBlogCategory->getId()}" style="margin-left: {$oBlogCategory->getLevel()*20}px;">{$oBlogCategory->getTitle()|escape:'html'}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<small class="note" id="blog_category_note">{$aLang.blog_create_category_notice}</small></p>
|
||||
{/if}
|
||||
|
||||
<p><label for="blog_type">{$aLang.blog_create_type}:</label>
|
||||
<select name="blog_type" id="blog_type" class="input-width-200" onChange="ls.blog.loadInfoType(jQuery(this).val());">
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
<div id="blogs-list-search" style="display:none;"></div>
|
||||
|
||||
<div id="blogs-list-original">
|
||||
{router page='blogs' assign=sBlogsRootPage}
|
||||
{if !$sBlogsRootPage}
|
||||
{router page='blogs' assign=sBlogsRootPage}
|
||||
{/if}
|
||||
{include file='blog_list.tpl' bBlogsUseOrder=true sBlogsRootPage=$sBlogsRootPage}
|
||||
{include file='paging.tpl' aPaging=$aPaging}
|
||||
</div>
|
||||
|
|
17
templates/skin/developer/blocks/block.categoryBlog.tpl
Normal file
17
templates/skin/developer/blocks/block.categoryBlog.tpl
Normal file
|
@ -0,0 +1,17 @@
|
|||
{if $aBlogCategories}
|
||||
<section class="block">
|
||||
<header class="block-header">
|
||||
<h3>{$aLang.block_category_blog}</h3>
|
||||
</header>
|
||||
|
||||
|
||||
<div class="block-content">
|
||||
<ul>
|
||||
<li {if !$oBlogCategoryCurrent}class="active"{/if}><a href="{router page='blogs'}">{$aLang.block_category_blog_all} ({$iCountBlogsAll})</a></li>
|
||||
{foreach from=$aBlogCategories item=oCategory}
|
||||
<li {if $oBlogCategoryCurrent and $oBlogCategoryCurrent->getId()==$oCategory->getId()}class="active"{/if}><a style="margin-left: {$oCategory->getLevel()*20}px;" href="{$oCategory->getUrlWeb()}">{$oCategory->getTitle()|escape:'html'} ({$oCategory->getCountBlogs()})</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
40
templates/skin/synio/actions/ActionAdmin/blogcategory.tpl
Normal file
40
templates/skin/synio/actions/ActionAdmin/blogcategory.tpl
Normal file
|
@ -0,0 +1,40 @@
|
|||
{include file='header.tpl'}
|
||||
|
||||
<h3>{$aLang.admin_list_blogcategory}</h3>
|
||||
|
||||
<a href="#" data-type="modal-toggle" data-option-url="{router page='admin'}blogcategory/modal-add/">{$aLang.admin_blogcategory_add}</a>
|
||||
|
||||
<table cellspacing="0" class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="180px">{$aLang.admin_blogcategory_items_title}</th>
|
||||
<th align="center" >{$aLang.admin_blogcategory_items_url}</th>
|
||||
<th align="center" width="80px">{$aLang.admin_blogcategory_items_action}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{foreach from=$aCategories item=oCategory}
|
||||
<tr>
|
||||
<td>
|
||||
<img src="{$aTemplateWebPathPlugin.page|cat:'images/'}{if $oCategory->getLevel()==0}folder{else}document{/if}.gif" alt="" title="" style="margin-left: {$oCategory->getLevel()*20}px;" />
|
||||
<a href="{$oCategory->getUrlWeb()}" border="0">{$oCategory->getTitle()|escape:'html'}</a>
|
||||
</td>
|
||||
<td>
|
||||
/{$oCategory->getUrlFull()}/
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="#" data-type="modal-toggle" data-option-url="{router page='admin'}blogcategory/modal-edit/" data-param-id="{$oCategory->getId()}"><img src="{$aTemplateWebPathPlugin.page|cat:'images/edit.png'}" /></a>
|
||||
<a href="{router page='admin'}blogcategory/delete/{$oCategory->getId()}/?security_ls_key={$LIVESTREET_SECURITY_KEY}" onclick="return confirm('«{$oCategory->getTitle()|escape:'html'}»: {$aLang.admin_blogcategory_items_delete_confirm}');"><img src="{$aTemplateWebPathPlugin.page|cat:'images/delete.png'}" /></a>
|
||||
|
||||
<a href="{router page='admin'}blogcategory/sort/{$oCategory->getId()}/?security_ls_key={$LIVESTREET_SECURITY_KEY}"><img src="{$aTemplateWebPathPlugin.page|cat:'images/up.png'}" /></a>
|
||||
<a href="{router page='admin'}blogcategory/sort/{$oCategory->getId()}/down/?security_ls_key={$LIVESTREET_SECURITY_KEY}"><img src="{$aTemplateWebPathPlugin.page|cat:'images/down.png'}" /></a>
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
{include file='footer.tpl'}
|
|
@ -0,0 +1,46 @@
|
|||
{extends file='modals/modal_base.tpl'}
|
||||
|
||||
{block name='options'}
|
||||
{assign var='noFooter' value=true}
|
||||
{/block}
|
||||
|
||||
{block name='id'}modal-category-add{/block}
|
||||
{block name='class'}js-modal-default{/block}
|
||||
{block name='title'}
|
||||
{if $oCategory}
|
||||
{$aLang.admin_blogcategory_form_edit}
|
||||
{else}
|
||||
{$aLang.admin_blogcategory_form_add}
|
||||
{/if}
|
||||
{/block}
|
||||
|
||||
{block name='content'}
|
||||
<form action="" method="post" id="form-category-blog-add" onsubmit="ls.admin.{if $oCategory}editCategoryBlog{else}addCategoryBlog{/if}('form-category-blog-add'); return false;">
|
||||
{$aLang.admin_blogcategory_form_field_parent}<br/>
|
||||
<select name="pid">
|
||||
<option value="0"></option>
|
||||
{foreach from=$aCategories item=oCategoryItem}
|
||||
<option {if $oCategory and $oCategory->getPid()==$oCategoryItem->getId()}selected="selected"{/if} style="margin-left: {$oCategoryItem->getLevel()*20}px;" value="{$oCategoryItem->getId()}">{$oCategoryItem->getTitle()|escape:'html'}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<br/>
|
||||
|
||||
{$aLang.admin_blogcategory_form_field_title}<br/>
|
||||
<input type="text" name="title" value="{if $oCategory}{$oCategory->getTitle()}{/if}">
|
||||
<br/>
|
||||
|
||||
{$aLang.admin_blogcategory_form_field_url}<br/>
|
||||
<input type="text" name="url" value="{if $oCategory}{$oCategory->getUrl()}{/if}">
|
||||
<br/>
|
||||
|
||||
{$aLang.admin_blogcategory_form_field_sort}<br/>
|
||||
<input type="text" name="sort" value="{if $oCategory}{$oCategory->getSort()}{/if}">
|
||||
<br/>
|
||||
|
||||
<button type="submit" name="submit" class="button button-primary">{if $oCategory}{$aLang.admin_blogcategory_form_edit_submit}{else}{$aLang.admin_blogcategory_form_add_submit}{/if}</button>
|
||||
|
||||
{if $oCategory}
|
||||
<input type="hidden" name="id" value="{$oCategory->getId()}">
|
||||
{/if}
|
||||
</form>
|
||||
{/block}
|
|
@ -7,6 +7,7 @@
|
|||
<ul>
|
||||
<li><a href="{router page="admin"}plugins/">{$aLang.admin_list_plugins}</a></li>
|
||||
<li><a href="{router page="admin"}userfields/">{$aLang.admin_list_userfields}</a></li>
|
||||
<li><a href="{router page="admin"}blogcategory/">{$aLang.admin_list_blogcategory}</a></li>
|
||||
<li><a href="{router page="admin"}restorecomment/?security_ls_key={$LIVESTREET_SECURITY_KEY}">{$aLang.admin_list_restorecomment}</a></li>
|
||||
<li><a href="{router page="admin"}recalcfavourite/?security_ls_key={$LIVESTREET_SECURITY_KEY}">{$aLang.admin_list_recalcfavourite}</a></li>
|
||||
<li><a href="{router page="admin"}recalcvote/?security_ls_key={$LIVESTREET_SECURITY_KEY}">{$aLang.admin_list_recalcvote}</a></li>
|
||||
|
|
|
@ -30,7 +30,19 @@
|
|||
<p><label for="blog_url">{$aLang.blog_create_url}:</label>
|
||||
<input type="text" id="blog_url" name="blog_url" value="{$_aRequest.blog_url}" class="input-text input-width-full" {if $_aRequest.blog_id and !$oUserCurrent->isAdministrator()}disabled{/if} />
|
||||
<small class="note">{$aLang.blog_create_url_notice}</small></p>
|
||||
|
||||
|
||||
{if Config::Get('module.blog.category_allow') and ($oUserCurrent->isAdministrator() or !Config::Get('module.blog.category_only_admin'))}
|
||||
<p><label for="blog_category">{$aLang.blog_create_category}:</label>
|
||||
<select name="blog_category" id="blog_category" class="input-width-200" >
|
||||
{if Config::Get('module.blog.category_allow_empty')}
|
||||
<option value="0"></option>
|
||||
{/if}
|
||||
{foreach from=$aBlogCategories item=oBlogCategory}
|
||||
<option {if $_aRequest.blog_category==$oBlogCategory->getId()}selected{/if} value="{$oBlogCategory->getId()}" style="margin-left: {$oBlogCategory->getLevel()*20}px;">{$oBlogCategory->getTitle()|escape:'html'}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<small class="note" id="blog_category_note">{$aLang.blog_create_category_notice}</small></p>
|
||||
{/if}
|
||||
|
||||
<p><label for="blog_type">{$aLang.blog_create_type}:</label>
|
||||
<select name="blog_type" id="blog_type" class="input-width-200" onChange="ls.blog.loadInfoType(jQuery(this).val());">
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
<div id="blogs-list-search" style="display:none;"></div>
|
||||
|
||||
<div id="blogs-list-original">
|
||||
{router page='blogs' assign=sBlogsRootPage}
|
||||
{if !$sBlogsRootPage}
|
||||
{router page='blogs' assign=sBlogsRootPage}
|
||||
{/if}
|
||||
{include file='blog_list.tpl' bBlogsUseOrder=true sBlogsRootPage=$sBlogsRootPage}
|
||||
{include file='paging.tpl' aPaging=$aPaging}
|
||||
</div>
|
||||
|
|
17
templates/skin/synio/blocks/block.categoryBlog.tpl
Normal file
17
templates/skin/synio/blocks/block.categoryBlog.tpl
Normal file
|
@ -0,0 +1,17 @@
|
|||
{if $aBlogCategories}
|
||||
<section class="block">
|
||||
<header class="block-header">
|
||||
<h3>{$aLang.block_category_blog}</h3>
|
||||
</header>
|
||||
|
||||
|
||||
<div class="block-content">
|
||||
<ul>
|
||||
<li {if !$oBlogCategoryCurrent}class="active"{/if}><a href="{router page='blogs'}">{$aLang.block_category_blog_all} ({$iCountBlogsAll})</a></li>
|
||||
{foreach from=$aBlogCategories item=oCategory}
|
||||
<li {if $oBlogCategoryCurrent and $oBlogCategoryCurrent->getId()==$oCategory->getId()}class="active"{/if}><a style="margin-left: {$oCategory->getLevel()*20}px;" href="{$oCategory->getUrlWeb()}">{$oCategory->getTitle()|escape:'html'} ({$oCategory->getCountBlogs()})</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
Loading…
Reference in a new issue