CategoriesPage/_widgets.php

71 lines
2.0 KiB
PHP
Raw Normal View History

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;
}
widgetsCategoriesPage::main();
class widgetsCategoriesPage {
/*
* initialisation du context widget
*/
public static function main() {
2013-12-30 13:47:09 +00:00
require_once __DIR__.'/ConstCategoriesPage.php';
2013-11-01 10:55:10 +00:00
$core = $GLOBALS['core'];
2013-10-28 15:39:42 +00:00
2013-11-01 10:55:10 +00:00
$core->addBehavior('initWidgets', array('widgetsCategoriesPage', 'initWidgets'));
}
2013-10-28 15:39:42 +00:00
2013-11-01 10:55:10 +00:00
// Widget function
public static function categoriesPageWidgets($widget) {
$core = $GLOBALS['core'];
2013-10-28 15:39:42 +00:00
2013-11-01 10:55:10 +00:00
$url = $core->url;
2014-12-14 14:11:06 +00:00
if ($widget->offline)
return;
2013-10-28 15:39:42 +00:00
2013-11-01 10:55:10 +00:00
if (($widget->homeonly == 1 && $url->type !== 'default') ||
($widget->homeonly == 2 && $url->type === 'default')) {
return;
}
2013-10-28 15:39:42 +00:00
2014-12-14 14:11:06 +00:00
$res =
($widget->title ? $widget->renderTitle(html::escapeHTML($widget->title)) : '').
'<p><a href="'.$core->blog->url.$core->url->getBase('categories').'">'.
($widget->link_title ? html::escapeHTML($widget->link_title) : __('All categories')).
'</a></p>';
return $widget->renderDiv($widget->content_only,'categories '.$widget->class,'',$res);
2013-11-01 10:55:10 +00:00
}
2013-10-28 15:39:42 +00:00
2013-11-01 10:55:10 +00:00
public static function initWidgets($widget) {
2013-11-02 11:43:11 +00:00
$text = __('Categories Page');
2013-11-01 10:55:10 +00:00
$widget->create('CategoriesPage', $text, array('widgetsCategoriesPage', 'categoriesPageWidgets'));
$categoriesPage = $widget->CategoriesPage;
$categoriesPage->setting('title', __('Title:'), $text, 'text');
$categoriesPage->setting('homeonly', __('Display on:'), 0, 'combo', array(
__('All pages') => 0,
__('Home page only') => 1,
__('Except on home page') => 2
2013-10-28 15:39:42 +00:00
)
);
2013-11-01 10:55:10 +00:00
$categoriesPage->setting('content_only', __('Content only'), 0, 'check');
$categoriesPage->setting('class', __('CSS class:'), '');
2014-12-14 14:11:06 +00:00
$categoriesPage->setting('offline',__('Offline'),0,'check');
2013-10-28 15:39:42 +00:00
}
2013-11-01 10:55:10 +00:00
2013-10-28 15:39:42 +00:00
}