2013-10-28 15:39:42 +00:00
|
|
|
<?php
|
2013-11-01 10:55:10 +00:00
|
|
|
/* -- BEGIN LICENSE BLOCK ----------------------------------
|
|
|
|
#
|
|
|
|
# This file is part of Categories Page, a plugin for Dotclear 2.
|
|
|
|
#
|
|
|
|
# Copyright (c) 2013 Pierre Van Glabeke, Bernard Le Roux
|
|
|
|
# Licensed under the GPL version 2.0 license.
|
|
|
|
# See LICENSE file or
|
|
|
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
#
|
|
|
|
# -- END LICENSE BLOCK ------------------------------------ */
|
|
|
|
if (!defined('DC_RC_PATH')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
publicCategoriesPage::main();
|
|
|
|
|
|
|
|
class publicCategoriesPage {
|
|
|
|
|
|
|
|
public static function main() {
|
|
|
|
|
|
|
|
$core = $GLOBALS['core'];
|
2013-12-30 13:47:09 +00:00
|
|
|
require_once __DIR__.'/_widgets.php';
|
2013-11-01 10:55:10 +00:00
|
|
|
|
|
|
|
// Adds news Categories' templates tags :
|
|
|
|
$tpl = $core->tpl;
|
|
|
|
$tpl->addValue('CategoryCount', array('tplCategories', 'CategoryCount'));
|
|
|
|
$tpl->addValue('CategoriesURL', array('tplCategories', 'CategoriesURL'));
|
|
|
|
// Adds a new template behavior :
|
|
|
|
$core->addBehavior('publicBeforeDocument', array('behaviorCategoriesPage', 'addTplPath'));
|
|
|
|
// 'categories' urlHandler :
|
|
|
|
$core->url->register('categories', 'categories', '^categories$', array('urlCategories', 'categories'));
|
|
|
|
// compatibilité avec Breadcrumb
|
|
|
|
$core->addBehavior('publicBreadcrumb', array('extCategoriesPage', 'publicBreadcrumb'));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class tplCategories {
|
2013-10-28 15:39:42 +00:00
|
|
|
/*
|
2013-11-01 10:55:10 +00:00
|
|
|
Use tag : {{tpl:CategoryCount}}
|
|
|
|
*/
|
|
|
|
public static function CategoryCount($attr) {
|
2013-10-28 15:39:42 +00:00
|
|
|
$f = $GLOBALS['core']->tpl->getFilters($attr);
|
|
|
|
return
|
2013-11-01 10:55:10 +00:00
|
|
|
'<?php echo ' . sprintf($f, '$_ctx->categories->nb_post') . '; ?>';
|
2013-10-28 15:39:42 +00:00
|
|
|
}
|
|
|
|
/*
|
2013-11-01 10:55:10 +00:00
|
|
|
Use tag : {{tpl:CategoriesURL}}
|
2013-10-28 15:39:42 +00:00
|
|
|
*/
|
2013-11-01 10:55:10 +00:00
|
|
|
public static function CategoriesURL($attr) {
|
2013-10-28 15:39:42 +00:00
|
|
|
$f = $GLOBALS['core']->tpl->getFilters($attr);
|
|
|
|
return
|
2013-11-01 10:55:10 +00:00
|
|
|
'<?php echo ' . sprintf($f, '$core->blog->url.$core->url->getBase("categories")') . '; ?>';
|
2013-10-28 15:39:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-01 10:55:10 +00:00
|
|
|
class behaviorCategoriesPage {
|
2013-10-28 15:39:42 +00:00
|
|
|
|
2013-11-01 10:55:10 +00:00
|
|
|
public static function addTplPath($core) {
|
2014-12-14 14:11:06 +00:00
|
|
|
$tplset = $core->themes->moduleInfo($core->blog->settings->system->theme,'tplset');
|
|
|
|
if (!empty($tplset) && is_dir(dirname(__FILE__).'/default-templates/'.$tplset)) {
|
|
|
|
$core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates/'.$tplset);
|
|
|
|
} else {
|
|
|
|
$core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates/'.DC_DEFAULT_TPLSET);
|
|
|
|
}
|
2013-10-28 15:39:42 +00:00
|
|
|
}
|
2013-11-01 10:55:10 +00:00
|
|
|
|
2013-10-28 15:39:42 +00:00
|
|
|
}
|
|
|
|
|
2013-11-01 10:55:10 +00:00
|
|
|
class urlCategories extends dcUrlHandlers {
|
2013-10-28 15:39:42 +00:00
|
|
|
|
2013-11-01 10:55:10 +00:00
|
|
|
public static function categories($args) {
|
2013-10-28 15:39:42 +00:00
|
|
|
# The entry
|
|
|
|
self::serveDocument('categories.html');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-19 23:17:10 +00:00
|
|
|
class extCategoriesPage
|
|
|
|
{
|
|
|
|
public static function publicBreadcrumb($context,$separator)
|
|
|
|
{
|
|
|
|
if ($context == 'categories') {
|
|
|
|
return __('Categories Page');
|
|
|
|
}
|
|
|
|
}
|
2013-10-28 15:39:42 +00:00
|
|
|
}
|