Skip to content

Commit

Permalink
Add a index_event tpl with Title Img Url for Last Event
Browse files Browse the repository at this point in the history
  • Loading branch information
justvitalius committed Oct 1, 2011
2 parents 17e5052 + 7073037 commit 901e8a8
Show file tree
Hide file tree
Showing 883 changed files with 4,728 additions and 722 deletions.
16 changes: 12 additions & 4 deletions classes/actions/ActionBlogs.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,20 @@ protected function EventShowBlogs() {
$this->Viewer_Assign('aCountTopicsInBlogs',$aCountTopicsInBlogs);
$this->Viewer_Assign('aBlogsCategories',$aBlogsCategories);





}

public function TopicsCounter($blog_id){
// Задаем фильтр топиков
$aFilter=array(
'topic_publish' => 1,
'blog_id' => $blod_id,
);

// получаем количество топиков по заданному фильтру
$cnt=$this->Topic_GetCountTopicsByFilter($aFilter);
$this->Viewer_Assign('aTopicsCount',$cnt);
}

/**
* Выполняется при завершении работы экшена
*
Expand Down
4 changes: 1 addition & 3 deletions classes/actions/ActionIndex.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,14 @@ protected function EventIndex() {

/**
* justVitalius
* выводим топик из блога События
* выводим топик из блога События
*/


$aEventResult=$this->Topic_GetTopicsByBlogId(8, 1, 1, array(), false);
$aEvents=$aEventResult['collection'];
$this->Viewer_Assign('aEvents',$aEvents);



/**
* Устанавливаем шаблон вывода
*/
Expand Down
15 changes: 15 additions & 0 deletions logs/sql_error.log
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,18 @@ Array
[context] => /Users/justvitalius/Sites/stels.avatech.in/htdocs/engine/modules/database/Database.class.php line 66
)
]
[2011-10-01 19:18:36][8039][ERROR][SQL Error: Table 'stels.ls_categorize_blog' doesn't exist at /Users/justvitalius/Sites/stels.avatech.in/htdocs/plugins/categorize/classes/modules/blog/mapper/Blog.mapper.class.php line 60<br>
Array
(
[code] => 1146
[message] => Table 'stels.ls_categorize_blog' doesn't exist
[query] => SELECT
count(bc.blog_id) as count
FROM
ls_categorize_blog as bc
WHERE
1=1

[context] => /Users/justvitalius/Sites/stels.avatech.in/htdocs/plugins/categorize/classes/modules/blog/mapper/Blog.mapper.class.php line 60
)
]
1 change: 1 addition & 0 deletions nbproject/private/private.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
auxiliary.org-netbeans-modules-php-phpdoc.target=
copy.src.files=false
copy.src.target=/Applications/MAMP/htdocs/stels
index.file=index.php
Expand Down
21 changes: 20 additions & 1 deletion nbproject/project.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
include.path=${php.global.include.path}
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=4
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
auxiliary.org-netbeans-modules-editor-indent.text.x-php5.CodeStyle.project.continuationIndentSize=2
auxiliary.org-netbeans-modules-editor-indent.text.x-php5.CodeStyle.project.itemsInArrayDeclarationIndentSize=2
auxiliary.org-netbeans-modules-editor-indent.text.x-php5.CodeStyle.project.placeCatchOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-php5.CodeStyle.project.placeElseOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-php5.CodeStyle.project.placeWhileOnNewLine=true
ignore.path=
include.path=\
${php.global.include.path}
php.version=PHP_5
phpunit.bootstrap=
phpunit.bootstrap.create.tests=false
phpunit.configuration=
phpunit.run.test.files=false
phpunit.suite=
source.encoding=UTF-8
src.dir=.
tags.asp=false
Expand Down
58 changes: 58 additions & 0 deletions plugins/categorize/PluginCategorize.class.php
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;
}

}

?>
2 changes: 2 additions & 0 deletions plugins/categorize/classes/.htaccess
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 plugins/categorize/classes/actions/ActionCategorize.class.php
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 plugins/categorize/classes/blocks/BlockCategorize.class.php
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
}
?>
60 changes: 60 additions & 0 deletions plugins/categorize/classes/hooks/HookCategorize.class.php
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
}
?>
Loading

0 comments on commit 901e8a8

Please sign in to comment.