Форумы / Cotonti / Core Labs / Archive / Module config format

Choosing the best one

Trustmaster
#1 13.02.2010 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 13.02.2010 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 13.02.2010 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 - мой маленький зарождающийся блог о котонти.
снижение стоимости программирования и снижение стоимости производства разные вещи. Первое можно скорее сравнить с раздачей работникам дешевых инструментов, чем со снижением зарплаты
Отредактировано: esclkm (13.02.2010 03:07, 14 лет назад)
Kort
#4 13.02.2010 04:06
I like most versatile #3!
SED.by - создание сайтов, разработка плагинов и тем для Котонти
Alex300
#5 13.02.2010 04:21
3!

I think it easy for understand and and the most flexible
Есть миры, не здесь, там, где небеса горят, и моря засыпают, и реки дремлют; люди сделаны из дыма, а города – из песен. Где-то опасность, где-то несправедливость, даже где-то остыл чай. Идем Эйс, у нас много работы!...
...Sorry for my english...
Бесплатные расширения для Cotonti: https://lily-software.com/free-scripts/
Sergeich
#6 13.02.2010 04:31
3.
But then the plug-ins to do well
Dayver
#7 13.02.2010 05:00
I like it 2) The Seditio way in modulename.setup.php

very simple, clear, concise and very powerful
Pavlo Tkachenko aka Dayver
Trustmaster
#8 12.04.2010 19:03
I'd like to get more opinions from plugin developers.
May the Source be with you!