4 * Plugin for Nucleus CMS (http://plugins.nucleuscms.org/)
5 * Copyright (C) 2003-2006 The Nucleus Plugins Project
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * see license.txt for the full license
15 class NP_OptionTest extends NucleusPlugin {
23 function getAuthor() {
24 return 'Wouter Demuynck';
27 // an URL to the plugin website
28 // can also be of the form mailto:foor@bar.com
31 return 'http://nucleuscms.org/';
34 // version of the plugin
35 function getVersion() {
39 // a description to be shown on the installed plugins listing
40 function getDescription() {
41 return 'Plugin to test blog and member options by plugins';
44 function getMinNucleusVersion() {
51 echo '<h1>Creating some options</h1>';
53 if (!$this->createBlogOption('my option', 'my description', 'text', 'initial value', 'extra'))
54 array_push($aErrors, 'create blog option failed');
56 if (!$this->createBlogOption('my option2', 'my description2', 'yesno', 'no'))
57 array_push($aErrors, 'create blog option 2 failed');
59 if (!$this->createMemberOption('my option3', 'my description3', 'yesno', 'no'))
60 array_push($aErrors, 'create member option failed');
62 if (!$this->createCategoryOption('my option4', 'my description4', 'yesno', 'yes'))
63 array_push($aErrors, 'create catgeory option failed');
65 echo '<h1>Creating some more options</h1>';
66 // add some thingies with the same name
67 $this->createCategoryOption('idem', 'idemd', 'text', 'category');
68 $this->createOption('idem', 'idemd', 'text', 'global');
69 $this->createBlogOption('idem', 'idemd', 'text', 'blog');
70 $this->createMemberOption('idem', 'idemd', 'text', 'member');
72 echo '<h1>Checking options</h1>';
73 if ($this->getOption('idem') != 'global')
74 array_push($aErrors, 'get should return "global" ' . $this->getOption('idem'));
75 if ($this->getCategoryOption(1, 'idem') != 'category')
76 array_push($aErrors, 'get should return "category" ' . $this->getCategoryOption(1, 'idem'));
77 if ($this->getBlogOption(1, 'idem') != 'blog')
78 array_push($aErrors, 'get should return "blog" ' . $this->getBlogOption(1, 'idem'));
79 if ($this->getMemberOption(1, 'idem') != 'member')
80 array_push($aErrors, 'get should return "member" ' . $this->getMemberOption(1, 'idem'));
82 echo '<h1>Setting options</h1>';
83 if (!$this->setOption('idem','edit-global'))
84 array_push($aErrors, 'set option failed');
85 if (!$this->setCategoryOption(1, 'idem', 'edit-category'))
86 array_push($aErrors, 'set catgeory option failed');
87 if (!$this->setBlogOption(1, 'idem', 'edit-blog'))
88 array_push($aErrors, 'set blog option failed');
89 if (!$this->setMemberOption(1, 'idem', 'edit-member'))
90 array_push($aErrors, 'set member option failed');
92 echo '<h1>Checking options</h1>';
93 if ($this->getOption('idem') != 'edit-global')
94 array_push($aErrors, 'get should return "edit-global"');
95 if ($this->getCategoryOption(1, 'idem') != 'edit-category')
96 array_push($aErrors, 'get should return "edit-category"');
97 if ($this->getBlogOption(1, 'idem') != 'edit-blog')
98 array_push($aErrors, 'get should return "edit-blog"');
99 if ($this->getMemberOption(1, 'idem') != 'edit-member')
100 array_push($aErrors, 'get should return "edit-member"');
102 if (count($aErrors) > 0);
103 echo '<ul><li>' . implode('</li><li>', $aErrors). '</li></ul>';
106 echo "All blog options:\n";
107 print_r($this->getAllBlogOptions('idem'));
109 echo "\nAll category options:\n";
110 print_r($this->getAllCategoryOptions('idem'));
112 echo "\nAll member options:\n";
113 print_r($this->getAllMemberOptions('idem'));