Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
AddThisSettingsForm.inc.php
1 <?php
2 
16 import('lib.pkp.classes.form.Form');
17 
18 class AddThisSettingsForm extends Form {
20  var $_press;
21 
23  var $_plugin;
24 
30  function AddThisSettingsForm($plugin, $press) {
31  parent::Form($plugin->getTemplatePath() . 'settings.tpl');
32  $this->setPress($press);
33  $this->setPlugin($plugin);
34 
35  // Validation checks for this form
36  $this->addCheck(new FormValidatorPost($this));
37  }
38 
39  //
40  // Getters and Setters
41  //
46  function getPress() {
47  return $this->_press;
48  }
49 
54  function setPress($press) {
55  $this->_press = $press;
56  }
57 
62  function getPlugin() {
63  return $this->_plugin;
64  }
65 
70  function setPlugin($plugin) {
71  $this->_plugin = $plugin;
72  }
73 
74  //
75  // Overridden template methods
76  //
80  function initData() {
81  $plugin = $this->getPlugin();
82  $press = $this->getPress();
83 
84  if (isset($plugin)) {
85  $this->_data = array(
86  'addThisProfileId' => $press->getSetting('addThisProfileId'),
87  'addThisUsername' => $press->getSetting('addThisUsername'),
88  'addThisPassword' => $press->getSetting('addThisPassword'),
89  'addThisDisplayStyle' => $press->getSetting('addThisDisplayStyle'),
90  );
91  }
92  }
93 
99  function fetch($request) {
100  $plugin = $this->getPlugin();
101  $press = $this->getPress();
102 
103  $templateMgr = TemplateManager::getManager($request);
104  $templateMgr->assign('pluginName', $plugin->getName());
105  $templateMgr->assign('pluginBaseUrl', $request->getBaseUrl() . '/' . $plugin->getPluginPath());
106 
107  $displayStyles = array(
108  'small_toolbox' => 'img/toolbox-small.png',
109  'plus_one_share_counter' => 'img/plusone-share.gif',
110  'small_toolbox_with_share' => 'img/small-toolbox.jpg',
111  'large_toolbox' => 'img/toolbox-large.png',
112  'simple_button' => 'img/share.jpg',
113  'button' => 'img/button.jpg',
114  );
115 
116  $templateMgr->assign('displayStyles', $displayStyles);
117 
118  foreach ($this->_data as $key => $value) {
119  $templateMgr->assign($key, $value);
120  }
121 
122  return $templateMgr->fetch($plugin->getTemplatePath() . 'settings.tpl');
123  }
124 
129  function readInputData() {
130  $this->readUserVars(array(
131  'addThisDisplayStyle',
132  'addThisUsername',
133  'addThisPassword',
134  'addThisProfileId',
135  ));
136  }
137 
142  function execute() {
143  $plugin = $this->getPlugin();
144  $press = $this->getPress();
145 
146  $press->updateSetting('addThisDisplayStyle', trim($this->getData('addThisDisplayStyle'), "\"\';"), 'string');
147  $press->updateSetting('addThisProfileId', trim($this->getData('addThisProfileId'), "\"\';"), 'string');
148  $press->updateSetting('addThisUsername', trim($this->getData('addThisUsername'), "\"\';"), 'string');
149  $press->updateSetting('addThisPassword', trim($this->getData('addThisPassword'), "\"\';"), 'string');
150  }
151 }
152 ?>
addCheck($formValidator)
Definition: Form.inc.php:396
Form validation check to make sure the form is POSTed.
Form for adding/editing the settings for the AddThis plugin.
readUserVars($vars)
Definition: Form.inc.php:364
Class defining basic operations for handling HTML forms.
Definition: Form.inc.php:47
getData($key)
Definition: Form.inc.php:210
AddThisSettingsForm($plugin, $press)