-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a index_event tpl with Title Img Url for Last Event
- Loading branch information
Showing
883 changed files
with
4,728 additions
and
722 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/******************************************** | ||
* Author: Vladimir Linkevich | ||
* e-mail: Vladimir.Linkevich@gmail.com | ||
* since 2011-02-25 | ||
********************************************/ | ||
|
||
if(!class_exists('Plugin')) { | ||
die('Hacking attemp!'); | ||
} | ||
class PluginCategorize extends Plugin { | ||
protected $aInherits = array('entity' => 'ModuleBlog_EntityBlog', 'mapper' => 'ModuleBlog_MapperBlog'); | ||
|
||
public function Activate() { | ||
$oDb = $this -> Database_GetConnect(); | ||
$prefix = Config::Get('db.table.prefix'); | ||
#Create table if not exist | ||
$this -> ExportSQL(dirname(__FILE__) . '/dump.sql'); | ||
#get existing blogs Id's | ||
$blogs = $this -> ModuleBlog_GetBlogs(true); | ||
#get categorized blogs | ||
$sql = "SELECT blog_id FROM " . $prefix . "categorize_blog"; | ||
$tmp = $oDb -> select($sql); | ||
$cats = array(); | ||
foreach($tmp as $aRow) { | ||
$cats[] = $aRow['blog_id']; | ||
} | ||
|
||
#categorize new blogs as NA category | ||
$blogs = array_diff($blogs, $cats); | ||
foreach($blogs as $blog) { | ||
$sql = " | ||
INSERT INTO " . $prefix . "categorize_blog | ||
(blog_id, | ||
blog_category) | ||
VALUES(?,?) | ||
"; | ||
$oDb -> query($sql, $blog, 'NA'); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public function Init() { | ||
$this -> Viewer_Assign('sTemplateWebPathPluginCategorize', Plugin::GetTemplateWebPath(__CLASS__)); | ||
$this -> Viewer_Assign('sTemplatePathPluginCategorize', Plugin::GetTemplatePath(__CLASS__)); | ||
$this -> Viewer_AddBlock('right', 'categorize', array('plugin' => 'categorize')); | ||
$this->Viewer_AppendStyle(Plugin::GetTemplateWebPath(__CLASS__) . 'css/categorize.css'); | ||
return true; | ||
} | ||
|
||
public function Deactivate() { | ||
return true; | ||
} | ||
|
||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Order Deny,Allow | ||
Deny from all |
121 changes: 121 additions & 0 deletions
121
plugins/categorize/classes/actions/ActionCategorize.class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
<?php | ||
class PluginCategorize_ActionCategorize extends Action { | ||
protected $sMenuHeadItemSelect = 'blog'; | ||
|
||
public function Init() { | ||
$this -> SetDefaultEvent('index'); | ||
} | ||
|
||
protected function RegisterEvent() { | ||
$this -> AddEvent('index', 'EventCategorizeBlogs'); | ||
$this -> AddEventPreg('/^(page(\d+))?$/i', 'EventCategorizeBlogs'); | ||
} | ||
|
||
|
||
|
||
public function EventCategorizeBlogs() { | ||
|
||
/** | ||
* Передан ли номер страницы | ||
*/ | ||
$iPage = preg_match("/^\d+$/i", $this -> GetEventMatch(2)) ? $this -> GetEventMatch(2) : 1; | ||
|
||
/* | ||
*Get filter data | ||
*/ | ||
$aCategories = null; | ||
if(isset($_GET['cat'])) { | ||
$aTmp = is_array($_GET['cat']) ? $_GET['cat'] : explode(',', $_GET['cat']); | ||
foreach($aTmp as $cat) { | ||
$aCat = $this -> PluginCategorize_ModuleCategorize_getCategoryChildren($cat); | ||
foreach($aCat as $catready) { | ||
$aCategories[] = $catready; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Получаем список блогов | ||
*/ | ||
|
||
$aResult = $this -> PluginCategorize_ModuleBlog_GetBlogsRatingCategory($aCategories, $iPage, Config::Get('module.blog.per_page')); | ||
$aBlogs = $aResult['collection']; | ||
|
||
/** | ||
* Формируем постраничность | ||
*/ | ||
$aPaging=$this->MakePaging($aResult['count'],$iPage,Config::Get('module.blog.per_page'),4,Router::GetPath('blogs'),$_GET); | ||
/** | ||
* Загружаем переменные в шаблон | ||
*/ | ||
$this -> Viewer_Assign('aPaging', $aPaging); | ||
$this -> Viewer_Assign("aBlogs", $aBlogs); | ||
$this -> Viewer_AddHtmlTitle($this -> Lang_Get('blog_menu_all_list')); | ||
} | ||
|
||
public function EventShutdown() { | ||
#Menu | ||
$this -> Viewer_Assign('sMenuHeadItemSelect', $this -> sMenuHeadItemSelect); | ||
#Modified blogs page template | ||
$this -> SetTemplate(Plugin::GetTemplatePath('categorize') . 'index.blogs.tpl'); | ||
#Add Block | ||
//$this -> Viewer_AddBlock('right', 'categorize', array('plugin' => 'categorize')); | ||
} | ||
/** | ||
* Формирует постраничный вывод | ||
* FIXED BUG | ||
* @param int $iCount | ||
* @param int $iCurrentPage | ||
* @param int $iCountPerPage | ||
* @param int $iCountPageLine | ||
* @param string $sBaseUrl | ||
* @param array(name=>value) $aGetParamsList | ||
* @return array() | ||
*/ | ||
public function MakePaging($iCount,$iCurrentPage,$iCountPerPage,$iCountPageLine,$sBaseUrl,$aGetParamsList=null) { | ||
if ($iCount==0) { | ||
return false; | ||
} | ||
|
||
$iCountPage=ceil($iCount/$iCountPerPage); | ||
if (!preg_match("/^[1-9]\d*$/i",$iCurrentPage)) { | ||
$iCurrentPage=1; | ||
} | ||
if ($iCurrentPage>$iCountPage) { | ||
$iCurrentPage=$iCountPage; | ||
} | ||
|
||
$aPagesLeft=array(); | ||
$iTemp=$iCurrentPage-$iCountPageLine; | ||
$iTemp = $iTemp<1 ? 1 : $iTemp; | ||
for ($i=$iTemp;$i<$iCurrentPage;$i++) { | ||
$aPagesLeft[]=$i; | ||
} | ||
|
||
$aPagesRight=array(); | ||
for ($i=$iCurrentPage+1;$i<=$iCurrentPage+$iCountPageLine and $i<=$iCountPage;$i++) { | ||
$aPagesRight[]=$i; | ||
} | ||
|
||
$iNextPage = $iCurrentPage<$iCountPage ? $iCurrentPage+1 : false; | ||
$iPrevPage = $iCurrentPage>1 ? $iCurrentPage-1 : false; | ||
# CORE FIX | ||
$sGetParams=''; | ||
if (isset($aGetParamsList)){ | ||
$sGetParams=urldecode(is_array($aGetParamsList)? '?'.http_build_query($aGetParamsList):'?'.$aGetParamsList); | ||
} | ||
$aPaging=array( | ||
'aPagesLeft' => $aPagesLeft, | ||
'aPagesRight' => $aPagesRight, | ||
'iCountPage' => $iCountPage, | ||
'iCurrentPage' => $iCurrentPage, | ||
'iNextPage' => $iNextPage, | ||
'iPrevPage' => $iPrevPage, | ||
'sBaseUrl' => rtrim($sBaseUrl,'/'), | ||
'sGetParams' => $sGetParams, | ||
); | ||
return $aPaging; | ||
} | ||
#END OF CLASS | ||
} | ||
?> |
41 changes: 41 additions & 0 deletions
41
plugins/categorize/classes/blocks/BlockCategorize.class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
class PluginCategorize_BlockCategorize extends Block { | ||
protected $aCategories; | ||
/** | ||
* Выполняется при вызове блока | ||
* @return void | ||
*/ | ||
public function Exec() { | ||
#assign category list | ||
$aCategories = $this -> PluginCategorize_ModuleCategorize_getCategories(Config::Get('plugin.categorize.blog.categories')); | ||
$aBlogSelectedCategories = array(); | ||
$aFilter = null; | ||
#_GET filter | ||
if(isset($_GET) && count($_GET) > 0) { | ||
$aGet['get'] = urldecode(http_build_query($_GET)); | ||
$this -> Viewer_Assign('aGet', $aGet); | ||
if(isset($_GET['cat'])) { | ||
$tmp = is_array($_GET['cat']) ? $_GET['cat'] : explode(',', $_GET['cat']); | ||
foreach($tmp as $val) { | ||
$aKill = $_GET; | ||
$sKill = count($tmp) > 1 ? implode(',', array_diff($tmp, array($val))) : null; | ||
$aKill['cat'] = $sKill; | ||
$aFilter['category'][$val] = array('name' => '', 'value' => $val, 'kill' => urldecode(http_build_query($aKill))); | ||
$aBlogSelectedCategories[] = $val; | ||
} | ||
} | ||
|
||
$this -> Viewer_Assign('aFilter', $aFilter); | ||
|
||
################ | ||
} | ||
|
||
$aBlogCategories = $this -> PluginCategorize_ModuleCategorize_GetCategories(Config::Get('plugin.categorize.blog.categories')); | ||
$this -> Viewer_Assign('tgt', Config::Get('plugin.categorize.blog.categorypage')); | ||
$this -> Viewer_Assign('aCategories', $aBlogCategories); | ||
$this -> Viewer_Assign('aSelectedCategories', $aBlogSelectedCategories); | ||
} | ||
|
||
#End Of Class | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
class PluginCategorize_HookCategorize extends Hook { | ||
|
||
public function RegisterHook() { | ||
$this -> AddHook('template_form_add_blog_end', 'InjectBlogAddCategory', __CLASS__); | ||
$this->AddHook('check_blog_fields','CheckBlog'); | ||
$this->AddHook('blog_add_after','AddBlog'); | ||
$this->AddHook('blog_add_before','fillBlogEntity'); | ||
$this->AddHook('blog_edit_before', 'EditBlogBefore'); | ||
$this->AddHook('blog_edit_after', 'EditBlogAfter'); | ||
} | ||
|
||
#Drop-down box in blog posting template | ||
public function InjectBlogAddCategory() { | ||
$this -> Viewer_Assign('aCategories', $this -> PluginCategorize_ModuleCategorize_getCategories(Config::Get('plugin.categorize.blog.categories'))); | ||
$this -> Viewer_Assign('bAllowParentCategory', Config::Get('plugin.categorize.blog.AllowParentCategory')); | ||
return $this -> Viewer_Fetch(Plugin::GetTemplatePath(__CLASS__) . 'inject_blog_end.tpl'); | ||
} | ||
|
||
#validate category | ||
public function CheckBlog($var) { | ||
$bOk = $var['bOk']; | ||
if(!func_check(getRequest('blog_category', null, 'post'), 'text', 2, 255)) { | ||
$this -> Message_AddError($this -> Lang_Get('categorize_blog_error_category'), $this -> Lang_Get('error')); | ||
$var['bOk'] = false; | ||
} | ||
return $var['bOk']; | ||
} | ||
|
||
public function fillBlogEntity($aoBlog){ | ||
return $aoBlog['oBlog']->setCategory($_REQUEST['blog_category']); | ||
} | ||
|
||
public function AddBlog($aoBlog) { | ||
$oBlog = $aoBlog['oBlog']; | ||
$this->PluginCategorize_ModuleCategorize_setBlogCategory($oBlog->getId(),$oBlog->getCategory()); | ||
$_REQUEST['blog_category']=$oBlog->getCategory(); | ||
} | ||
|
||
public function EditBlogBefore($arr) { | ||
$oBlog=$arr['oBlog']; | ||
if(!isset($_REQUEST['blog_category'])){ | ||
$oBlog->setCategory($this->PluginCategorize_ModuleCategorize_addBlogEntityCategory(array('idlist'=>$oBlog->getId(),'collection'=>array($oBlog)))); | ||
}else{ | ||
$oBlog->setCategory(getRequest('blog_category')); | ||
} | ||
$_REQUEST['blog_category']=$oBlog->getCategory(); | ||
return $arr['oBlog']=$oBlog; | ||
} | ||
|
||
public function EditBlogAfter($arr){ | ||
$oBlog = $arr['oBlog']; | ||
$this->PluginCategorize_ModuleCategorize_updateBlogCategory($oBlog->getId(),$oBlog->getCategory()); | ||
$_REQUEST['blog_category']=$oBlog->getCategory(); | ||
return $arr['oBlog']=$oBlog; | ||
} | ||
|
||
#END OF CLASS | ||
} | ||
?> |
Oops, something went wrong.