3 * VanillaVoting class. This is where all the Admin side forms are generated
5 class VanillaVotingForm
extends PostBackControl
7 var $ConfigurationManager;
9 var $CategoryCheckboxes;
11 function VanillaVotingForm(&$Context)
13 $this->Name
= 'VanillaVotingForm';
14 $this->ValidActions
= array('VanillaVoting','ProcessVanillaVoting');
15 $this->Constructor($Context);
19 $SettingsFile = $this->Context
->Configuration
['APPLICATION_PATH'].'conf/settings.php';
20 $this->ConfigurationManager
= $this->Context
->ObjectFactory
->NewContextObject($this->Context
, 'ConfigurationManager');
21 if ($this->PostBackAction
== 'ProcessVanillaVoting')
23 $this->ConfigurationManager
->GetSettingsFromForm($SettingsFile);
24 $this->ConfigurationManager
->DefineSetting('VANILLAVOTING_CATEGORYID', implode(",", $_POST['AllowedCategory']), 0);
25 $this->DelegateParameters
['ConfigurationManager'] = &$this->ConfigurationManager
;
26 // And save everything
27 if ($this->ConfigurationManager
->SaveSettingsToFile($SettingsFile)) {
28 header('location: '.GetUrl($this->Context
->Configuration
, 'settings.php', '', '', '', '', 'PostBackAction=VanillaVoting&Success=1'));
30 $this->PostBackAction
= 'VanillaVoting';
38 if ($this->IsPostBack
)
40 $this->PostBackParams
->Clear();
41 if ($this->PostBackAction
== 'VanillaVoting')
43 $this->AllowedCategory
= explode(",", $this->Context
->Configuration
["VANILLAVOTING_CATEGORYID"]);
44 // Load the category selector
45 $cm = $this->Context
->ObjectFactory
->NewContextObject($this->Context
, 'CategoryManager');
46 $CategoryData = $cm->GetCategories(0, 1);
47 $cat = $this->Context
->ObjectFactory
->NewObject($this->Context
, 'Category');
48 while ($Row = $this->Context
->Database
->GetRow($CategoryData)) {
50 $cat->GetPropertiesFromDataSet($Row);
51 $this->CategoryCheckboxes
.= "<li><p><span>".GetDynamicCheckBox("AllowedCategory[]", $cat->CategoryID
,
52 (in_array($cat->CategoryID
, $this->AllowedCategory
)) ?
1 : 0,
53 "",$cat->Name
,"","Category_".$cat->CategoryID
)."</span></p></li>\r\n";
56 $this->PostBackParams
->Set('PostBackAction', 'ProcessVanillaVoting');
58 echo '<div id="Form" class="Account VanillaVotingSettings Preferences">';
59 if (ForceIncomingInt('Success', 0)) echo '<div id="Success">'.$this->Context
->GetDefinition('ChangesSaved').'</div>';
61 <legend>'.$this->Context
->GetDefinition("VanillaVoting").'</legend>
62 '.$this->Get_Warnings().'
63 '.$this->Get_PostBackForm('frmVanillaVoting').'
66 <p class="Description"><strong>'.$this->Context
->GetDefinition("VanillaVotingCategory").'</strong></p>
67 <p class="Description">Check: <a onclick="CheckAll(\'Category_\'); return false;" href="./">All</a>, <a onclick="CheckNone(\'Category_\'); return false;" href="./">None</a></p>
69 '.$this->CategoryCheckboxes
.'
72 <input type="submit" name="btnSave" value="'.$this->Context
->GetDefinition('Save').'" class="Button SubmitButton" />
73 <a href="'.GetUrl($this->Context
->Configuration
, $this->Context
->SelfUrl
).'" class="CancelButton">'.$this->Context
->GetDefinition('Cancel').'</a>