diff --git a/ConstCategoriesPage.php b/ConstCategoriesPage.php
new file mode 100644
index 0000000..c10e2f4
--- /dev/null
+++ b/ConstCategoriesPage.php
@@ -0,0 +1,20 @@
+addBehavior('adminBlogPreferencesForm',array('categoriespageAdminBehaviors','adminBlogPreferencesForm'));
-$core->addBehavior('adminBeforeBlogSettingsUpdate',array('categoriespageAdminBehaviors','adminBeforeBlogSettingsUpdate'));
+categoriespageAdminBehaviors::main();
class categoriespageAdminBehaviors
{
- public static function adminBlogPreferencesForm($core,$settings)
- {
- echo
- '
'.__('Categories Page').'
'.
- '
'.
- '
';
- }
-
- public static function adminBeforeBlogSettingsUpdate($settings)
- {
- $settings->addNameSpace('categoriespage');
- $settings->categoriespage->put('categoriespage_active',!empty($_POST['categoriespage_active']),'boolean');
- $settings->addNameSpace('system');
- }
+ public static function main() {
+
+ require_once '/_widgets.php';
+
+ $menu = $GLOBALS['_menu'];
+ $core = $GLOBALS['core'];
+ $menu['Plugins']->addItem(
+ ConstCategoriesPage::NS,
+ 'plugin.php?p='.ConstCategoriesPage::PARAM,
+ 'index.php?pf='.ConstCategoriesPage::PARAM.'/icon.png',
+ preg_match('/plugin.php\?p='.ConstCategoriesPage::PARAM.'(&.*)?$/',$_SERVER['REQUEST_URI']),
+ $core->auth->isSuperAdmin());
+ }
}
diff --git a/_define.php b/_define.php
index 8f9806b..d29d128 100644
--- a/_define.php
+++ b/_define.php
@@ -1,21 +1,24 @@
registerModule(
- /* Name */ "Categories Page",
- /* Description*/ "Add a category list page",
- /* Author */ "Adjaya, Pierre Van Glabeke",
- /* Version */ '0.1',
+ /* Name */ 'Categories Page',
+ /* Description*/ 'Add a category list page / Ajoute une page listant les catégories',
+ /* Author */ 'Pierre Van Glabeke, Bernard Le Roux',
+ /* Version */ ConstCategoriesPage::VERSION,
/* Properties */
array(
'permissions' => 'admin',
diff --git a/_public.php b/_public.php
index 1ab4562..3977ab0 100644
--- a/_public.php
+++ b/_public.php
@@ -1,91 +1,89 @@
blog->settings->categoriespage->categoriespage_active) { return; }
+publicCategoriesPage::main();
-require_once dirname(__FILE__).'/_widgets.php';
+class publicCategoriesPage {
-# Adds news Categories' templates tags :
-$GLOBALS['core']->tpl->addValue('CategoryCount',array('tplCategories','CategoryCount'));
-$GLOBALS['core']->tpl->addBlock('EntryIfCategoriesPage',array('tplCategories','EntryIfCategoriesPage'));
-$GLOBALS['core']->tpl->addValue('CategoriesURL',array('tplCategories','CategoriesURL'));
+ public static function main() {
-class tplCategories
-{
+ require_once 'ConstCategoriesPage.php';
+
+ $core = $GLOBALS['core'];
+ $ns = $core->blog->settings->addNamespace(ConstCategoriesPage::NS);
+
+ // If categoriesPage is not active we stop here :
+ if (!$ns->get(ConstCategoriesPage::PLUGIN_IS_ACTIVE)) {
+ return;
+ }
+ require_once '/_widgets.php';
+
+ // 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 {
/*
- Use tag : {{tpl:CategoryCount}}
- */
- public static function CategoryCount($attr)
- {
+ Use tag : {{tpl:CategoryCount}}
+ */
+ public static function CategoryCount($attr) {
$f = $GLOBALS['core']->tpl->getFilters($attr);
return
- 'categories->nb_post').'; ?>';
+ 'categories->nb_post') . '; ?>';
}
/*
- Use :
-
{{tpl:lang Categories}}
-
-
-
+
{{tpl:lang Categories}} :
+
{{tpl:CategoryDescription}}
@@ -77,4 +75,4 @@
{{tpl:include src="_footer.html"}}