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