Cotonti / Open Source PHP Content Management FrameworkContent Management Framework

Forums / Cotonti / Core Labs / Archive / Module config format

Choosing the best one

Trustmaster
#1 2010-02-13 00:52
I'm currently working on modules support in siena/trunk. As you know, each module (e.g. forums) has its own configuration. In Siena it will come with them module either in an SQL file or in modulename.setup.php.

I'm currently considering different formats of declaring the module configuration. The best format is:
  • easy to understand
  • easy to write
  • flexible to store different possible values

Please read these example of configuration options for forums module and tell which you like more and why. Or suggest your own.

1) The plain SQL way in modulename.sql:
INSERT INTO `sed_config` (`config_owner`, `config_cat`, `config_order`, `config_name`, `config_type`, `config_value`, `config_default`, `config_variants`, `config_text`) VALUES
('core','forums','01','disable_forums',3,'0','0','',''),
('core','forums','02','hideprivateforums',3,'0','0','',''),
('core','forums','03','hottopictrigger',2,'20','20','5,10,15,20,25,30,35,40,50',''),
('core','forums','04','maxtopicsperpage',2,'30','30','5,10,15,20,25,30,40,50,60,70,100,200,500',''),
('core','forums','05','antibumpforums',3,'0','0','',''),
('core','forums','06','mergeforumposts',3,'1','1','',''),
('core','forums','07','mergetimeout',2,'0','0','0,1,2,3,6,12,24,36,48,72',''),
('core','forums','08','maxpostsperpage',2,'15','15','5,10,15,20,25,30,40,50,60,70,100,200,500','');

2) The Seditio way in modulename.setup.php:
/*
[COT_MODULE_CONFIG]
disable_forums=01:radio::0:
hideprivateforums=02:radio::0:
hottopictrigger=03:select:5,10,15,20,25,30,35,40,50:20:
maxtopicsperpage=04:select:5,10,15,20,25,30,40,50,60,70,100,200,500:30:
antibumpforums=05:radio::0:
mergeforumposts=06:radio::1:
mergetimeout=07:select:0,1,2,3,6,12,24,36,48,72:0:
maxpostsperpage=08:select:5,10,15,20,25,30,40,50,60,70,100,200,500:15:
[/COT_MODULE_CONFIG]
*/

3) Verbose PHP arrays in modulename.setup.php:
$config_options = array(
	array(
		'name' => 'disable_forums',
		'type' => COT_CONFIG_TYPE_RADIO,
		'default' => '0'
	),
	array(
		'name' => 'hideprivateforums',
		'type' => COT_CONFIG_TYPE_RADIO,
		'default' => '0'
	),
	array(
		'name' => 'hottopictrigger',
		'type' => COT_CONFIG_TYPE_SELECT,
		'default' => '20',
		'variants' => '5,10,15,20,25,30,35,40,50'
	),
	array(
		'name' => 'maxtopicsperpage',
		'type' => COT_CONFIG_TYPE_SELECT,
		'default' => '30',
		'variants' => '5,10,15,20,25,30,40,50,60,70,100,200,500'
	),
	array(
		'name' => 'antibumpforums',
		'type' => COT_CONFIG_TYPE_RADIO,
		'default' => '0'
	),
	array(
		'name' => 'mergeforumposts',
		'type' => COT_CONFIG_TYPE_RADIO,
		'default' => '1'
	),
	array(
		'name' => 'mergetimeout',
		'type' => COT_CONFIG_TYPE_SELECT,
		'default' => '0',
		'variants' => '0,1,2,3,6,12,24,36,48,72'
	),
	array(
		'name' => 'maxpostsperpage',
		'type' => COT_CONFIG_TYPE_SELECT,
		'default' => '15',
		'variants' => '5,10,15,20,25,30,40,50,60,70,100,200,500'
	)
);
May the Source be with you!
Dr2005alex
#2 2010-02-13 02:00
I like it 2) The Seditio way in modulename.setup.php. Very convenient to edit and graphically.
WebKaa.ru - Cotonti Relax
esclkm
#3 2010-02-13 02:47
3!
and make plugs in this style!

Добавлено 20 Минут спустя:

I think it is just big - but it easy for understand and there is easy to add land files
littledev.ru - мой маленький зарождающийся блог о котонти.
снижение стоимости программирования и снижение стоимости производства разные вещи. Первое можно скорее сравнить с раздачей работникам дешевых инструментов, чем со снижением зарплаты

This post was edited by esclkm (2010-02-13 03:07, 10 years ago)
Kort
#4 2010-02-13 04:06
I like most versatile #3!
Seditio.by - создание сайтов, разработка плагинов и тем для Котонти
Alex300
#5 2010-02-13 04:21
3!

I think it easy for understand and and the most flexible
Приходится бежать со всех ног, чтобы только оставаться на месте. А чтобы куда-то попасть, приходится бежать еще быстрее...
...Sorry for my english...
Бесплатные расширения для Cotonti: http://portal30.ru/sozdanie-internet-sajtov/free-scripts/
Sergeich
#6 2010-02-13 04:31
3.
But then the plug-ins to do well
Born in the Wild Wild East!
Dayver
#7 2010-02-13 05:00
I like it 2) The Seditio way in modulename.setup.php

very simple, clear, concise and very powerful
Pavel Tkachenko aka Dayver. Гик и веб мастер который делает сайты, увлекается электроникой и очень любит смотреть кино.
О себе: Я злой и страшный серый волк, я в поросятах знааааюююю толк
Trustmaster
#8 2010-04-12 19:03
I'd like to get more opinions from plugin developers.
May the Source be with you!