We are moving to Git Issues for bug tracking in future releases. During transition, content will be in both tools. If you'd like to file a new bug, please create an issue.

View | Details | Raw Unified | Return to bug 4474 | Differences between
and this patch

Collapse All | Expand All

(-)ojs2/plugins/generic/customBlockManager/CustomBlockEditForm.inc.php (-13 / +13 lines)
 Lines 9-23    Link Here 
9
 * @package plugins.generic.customBlockManager
9
 * @package plugins.generic.customBlockManager
10
 * @class CustomBlockEditForm
10
 * @class CustomBlockEditForm
11
 *
11
 *
12
 * Form for journal managers to create and modify sidebar blocks
12
 * Form for conference managers to create and modify sidebar blocks
13
 * 
13
 * 
14
 */
14
 */
15
15
16
import('form.Form');
16
import('form.Form');
17
17
18
class CustomBlockEditForm extends Form {
18
class CustomBlockEditForm extends Form {
19
	/** @var $journalId int */
19
	/** @var $conferenceId int */
20
	var $journalId;
20
	var $conferenceId;
21
21
22
	/** @var $plugin object */
22
	/** @var $plugin object */
23
	var $plugin;
23
	var $plugin;
 Lines 27-39    Link Here 
27
27
28
	/**
28
	/**
29
	 * Constructor
29
	 * Constructor
30
	 * @param $journalId int
30
	 * @param $conferenceId int
31
	 */
31
	 */
32
	function CustomBlockEditForm(&$plugin, $journalId) {
32
	function CustomBlockEditForm(&$plugin, $conferenceId) {
33
33
34
		parent::Form($plugin->getTemplatePath() . 'editCustomBlockForm.tpl');
34
		parent::Form($plugin->getTemplatePath() . 'editCustomBlockForm.tpl');
35
35
36
		$this->journalId = $journalId;
36
		$this->conferenceId = $conferenceId;
37
		$this->plugin =& $plugin;
37
		$this->plugin =& $plugin;
38
38
39
		$this->addCheck(new FormValidatorPost($this));
39
		$this->addCheck(new FormValidatorPost($this));
 Lines 45-70    Link Here 
45
	 * Initialize form data from current group group.
45
	 * Initialize form data from current group group.
46
	 */
46
	 */
47
	function initData() {
47
	function initData() {
48
		$journalId = $this->journalId;
48
		$conferenceId = $this->conferenceId;
49
		$plugin =& $this->plugin;
49
		$plugin =& $this->plugin;
50
50
51
		// add the tiny MCE script 
51
		// add the tiny MCE script 
52
		$this->addTinyMCE();
52
		$this->addTinyMCE();
53
		$this->setData('blockContent', $plugin->getSetting($journalId, 'blockContent'));
53
		$this->setData('blockContent', $plugin->getSetting($conferenceId, 0, 'blockContent'));
54
	}
54
	}
55
55
56
	/**
56
	/**
57
	 * Add the tinyMCE script for editing sidebar blocks with a WYSIWYG editor
57
	 * Add the tinyMCE script for editing sidebar blocks with a WYSIWYG editor
58
	 */
58
	 */
59
	function addTinyMCE() {
59
	function addTinyMCE() {
60
		$journalId = $this->journalId;
60
		$conferenceId = $this->conferenceId;
61
		$plugin =& $this->plugin;
61
		$plugin =& $this->plugin;
62
		$templateMgr =& TemplateManager::getManager();
62
		$templateMgr =& TemplateManager::getManager();
63
63
64
		// Enable TinyMCE with specific params
64
		// Enable TinyMCE with specific params
65
		$additionalHeadData = $templateMgr->get_template_vars('additionalHeadData');
65
		$additionalHeadData = $templateMgr->get_template_vars('additionalHeadData');
66
66
67
		import('file.JournalFileManager');
67
		import('file.ConferenceFileManager');
68
		$publicFileManager = new PublicFileManager();
68
		$publicFileManager = new PublicFileManager();
69
		$tinyMCE_script = '
69
		$tinyMCE_script = '
70
		<script language="javascript" type="text/javascript" src="'.Request::getBaseUrl().'/'.TINYMCE_JS_PATH.'/tiny_mce.js"></script>
70
		<script language="javascript" type="text/javascript" src="'.Request::getBaseUrl().'/'.TINYMCE_JS_PATH.'/tiny_mce.js"></script>
 Lines 80-86    Link Here 
80
			theme_advanced_toolbar_align : "left",
80
			theme_advanced_toolbar_align : "left",
81
			content_css : "' . Request::getBaseUrl() . '/styles/common.css", 
81
			content_css : "' . Request::getBaseUrl() . '/styles/common.css", 
82
			relative_urls : false, 		
82
			relative_urls : false, 		
83
			document_base_url : "'. Request::getBaseUrl() .'/'.$publicFileManager->getJournalFilesPath($journalId) .'/", 
83
			document_base_url : "'. Request::getBaseUrl() .'/'.$publicFileManager->getConferenceFilesPath($conferenceId) .'/", 
84
			extended_valid_elements : "span[*], div[*]"
84
			extended_valid_elements : "span[*], div[*]"
85
			});
85
			});
86
		</script>';
86
		</script>';
 Lines 101-108    Link Here 
101
	 */	 
101
	 */	 
102
	function save() {
102
	function save() {
103
		$plugin =& $this->plugin;
103
		$plugin =& $this->plugin;
104
		$journalId = $this->journalId;
104
		$conferenceId = $this->conferenceId;
105
		$plugin->updateSetting($journalId, 'blockContent', $this->getData('blockContent'));		
105
		$plugin->updateSetting($conferenceId, 0, 'blockContent', $this->getData('blockContent'));		
106
	}
106
	}
107
107
108
}
108
}
(-)ojs2/plugins/generic/customBlockManager/CustomBlockManagerPlugin.inc.php (-19 / +14 lines)
 Lines 54-63    Link Here 
54
			case 'blocks':
54
			case 'blocks':
55
				$this->import('CustomBlockPlugin');
55
				$this->import('CustomBlockPlugin');
56
				
56
				
57
				$journal =& Request::getJournal();
57
				$conference =& Request::getConference();
58
				if ( !$journal ) return false;
58
				if ( !$conference ) return false;
59
				
59
				
60
				$blocks = $this->getSetting($journal->getJournalId(), 'blocks');
60
				$blocks = $this->getSetting($conference->getConferenceId(), 0, 'blocks');
61
				if ( !is_array($blocks) ) break;
61
				if ( !is_array($blocks) ) break;
62
				$i= 0;
62
				$i= 0;
63
				foreach ( $blocks as $block ) {
63
				foreach ( $blocks as $block ) {
 Lines 84-104    Link Here 
84
	 * Determine whether or not this plugin is enabled.
84
	 * Determine whether or not this plugin is enabled.
85
	 */
85
	 */
86
	function getEnabled() {
86
	function getEnabled() {
87
		$journal =& Request::getJournal();
87
		$conference =& Request::getConference();
88
		if (!$journal) return false;
88
 		$conferenceId = $conference?$conference->getConferenceId():0;
89
		return $this->getSetting($journal->getJournalId(), 'enabled');
89
		return $this->getSetting($conferenceId, 0, 'enabled');
90
	}
90
	}
91
91
92
	/**
92
	/**
93
	 * Set the enabled/disabled state of this plugin
93
	 * Set the enabled/disabled state of this plugin
94
	 */
94
	 */
95
	function setEnabled($enabled) {
95
	function setEnabled($enabled) {
96
		$journal =& Request::getJournal();
96
 		$conference =& Request::getConference();
97
		if ($journal) {
97
 		$conferenceId = $conference?$conference->getConferenceId():0;
98
			$this->updateSetting($journal->getJournalId(), 'enabled', $enabled ? true : false);
98
 		$this->updateSetting($conferenceId, 0, 'enabled', $enabled);
99
			return true;
100
		}
101
		return false;
102
	}
99
	}
103
100
104
	/**
101
	/**
 Lines 135-150    Link Here 
135
132
136
		$pageCrumbs = array(
133
		$pageCrumbs = array(
137
			array(
134
			array(
138
				Request::url(null, 'user'),
135
				Request::url(null, null, 'user'),
139
				'navigation.user'
136
				'navigation.user'
140
			),
137
			),
141
			array(
138
			array(
142
				Request::url(null, 'manager'),
139
				Request::url(null, null, 'manager'),
143
				'user.role.manager'
140
				'user.role.manager'
144
			)
141
			)
145
		);
142
		);
146
		
143
		
147
		$journal =& Request::getJournal();
144
		$conference =& Request::getConference();
148
		
145
		
149
		switch ($verb) {
146
		switch ($verb) {
150
			case 'enable':
147
			case 'enable':
 Lines 155-168    Link Here 
155
				break;
152
				break;
156
			case 'settings':
153
			case 'settings':
157
				$pageCrumbs[] = array(
154
				$pageCrumbs[] = array(
158
					Request::url(null, 'manager', 'plugins'),
155
					Request::url(null, null, 'manager', 'plugins'),
159
					Locale::translate('manager.plugins'),
156
					Locale::translate('manager.plugins'),
160
					true
157
					true
161
				);
158
				);
162
				$templateMgr->assign('pageHierarchy', $pageCrumbs);
159
				$templateMgr->assign('pageHierarchy', $pageCrumbs);
163
160
164
				$this->import('SettingsForm');
161
				$this->import('SettingsForm');
165
				$form = new SettingsForm($this, $journal->getJournalId());
162
				$form = new SettingsForm($this, $conference->getConferenceId());
166
				$form->readInputData();
163
				$form->readInputData();
167
				
164
				
168
				if (Request::getUserVar('addBlock')) {
165
				if (Request::getUserVar('addBlock')) {
 Lines 172-178    Link Here 
172
					$blocks = $form->getData('blocks');
169
					$blocks = $form->getData('blocks');
173
					array_push($blocks, '');
170
					array_push($blocks, '');
174
					$form->_data['blocks'] = $blocks;
171
					$form->_data['blocks'] = $blocks;
175
176
				} else if (($delBlock = Request::getUserVar('delBlock')) && count($delBlock) == 1) {
172
				} else if (($delBlock = Request::getUserVar('delBlock')) && count($delBlock) == 1) {
177
					// Delete an block
173
					// Delete an block
178
					$editData = true;
174
					$editData = true;
 Lines 186-192    Link Here 
186
					}
182
					}
187
					array_splice($blocks, $delBlock, 1);
183
					array_splice($blocks, $delBlock, 1);
188
					$form->_data['blocks'] = $blocks;
184
					$form->_data['blocks'] = $blocks;
189
190
				} else if ( Request::getUserVar('save') ) {
185
				} else if ( Request::getUserVar('save') ) {
191
					$editData = true;
186
					$editData = true;
192
					$form->execute();
187
					$form->execute();
(-)ojs2/plugins/generic/customBlockManager/CustomBlockPlugin.inc.php (-7 / +7 lines)
 Lines 97-106    Link Here 
97
			)
97
			)
98
		);
98
		);
99
		
99
		
100
		$journal =& Request::getJournal();
100
		$conference =& Request::getConference();
101
101
102
		$this->import('CustomBlockEditForm');
102
		$this->import('CustomBlockEditForm');
103
		$form = new CustomBlockEditForm($this, $journal->getJournalId());
103
		$form = new CustomBlockEditForm($this, $conference->getConferenceId());
104
		
104
		
105
		switch ($verb) {
105
		switch ($verb) {
106
			case 'enable':
106
			case 'enable':
 Lines 111-117    Link Here 
111
				break;
111
				break;
112
			case 'edit':
112
			case 'edit':
113
				$pageCrumbs[] = array(
113
				$pageCrumbs[] = array(
114
					Request::url(null, 'manager', 'plugins'),
114
          Request::url(null, null, 'manager', 'plugins'),
115
					Locale::translate('manager.plugins'),
115
					Locale::translate('manager.plugins'),
116
					true
116
					true
117
				);
117
				);
 Lines 131-137    Link Here 
131
						'pageTitleTranslated' => $this->getDisplayName(),
131
						'pageTitleTranslated' => $this->getDisplayName(),
132
						'pageHierarchy' => $pageCrumbs, 
132
						'pageHierarchy' => $pageCrumbs, 
133
						'message' => 'plugins.generic.customBlock.saved',
133
						'message' => 'plugins.generic.customBlock.saved',
134
						'backLink' => Request::url(null, 'manager', 'plugins'),
134
						'backLink' => Request::url(null, null, 'manager', 'plugins'),
135
						'backLinkLabel' => 'common.continue'
135
						'backLinkLabel' => 'common.continue'
136
					));
136
					));
137
					$templateMgr->display('common/message.tpl');
137
					$templateMgr->display('common/message.tpl');
 Lines 152-161    Link Here 
152
	 * @return string
152
	 * @return string
153
	 */
153
	 */
154
	function getContents(&$templateMgr) {
154
	function getContents(&$templateMgr) {
155
		$journal =& Request::getJournal();
155
		$conference =& Request::getConference();
156
		if (!$journal) return '';
156
		if (!$conference) return '';
157
157
158
		$templateMgr->assign('customBlockContent', $this->getSetting($journal->getJournalId(), 'blockContent'));
158
		$templateMgr->assign('customBlockContent', $this->getSetting($conference->getConferenceId(), 0, 'blockContent'));
159
		return parent::getContents($templateMgr);
159
		return parent::getContents($templateMgr);
160
160
161
	}
161
	}
(-)ojs2/plugins/generic/customBlockManager/locale/en_US/locale.xml (-1 / +1 lines)
 Lines 15-21    Link Here 
15
<locale name="en_US" full_name="U.S. English">
15
<locale name="en_US" full_name="U.S. English">
16
	<message key="plugins.generic.customBlockManager.displayName">Custom Block Manager</message>
16
	<message key="plugins.generic.customBlockManager.displayName">Custom Block Manager</message>
17
	<message key="plugins.generic.customBlockManager.description">This plugin lets you create addition sidebar blocks.  Once they are created, you can edit their content and rearrange them within the sidebars.</message>	
17
	<message key="plugins.generic.customBlockManager.description">This plugin lets you create addition sidebar blocks.  Once they are created, you can edit their content and rearrange them within the sidebars.</message>	
18
	<message key="plugin.generic.customBlockManager.introduction"><![CDATA[You can use this plugin to add or delete custom block plugins.  You can then edit the content through the <a href="{$systemPluginsUrl}">System Plugins</a> page (in the Blocks Plugin section).  To place your plugin in the desired location in the sidebar, go to <a href="{$setupStep56}">Setup step 5.6</a>]]></message>
18
	<message key="plugin.generic.customBlockManager.introduction"><![CDATA[You can use this plugin to add or delete custom block plugins.  You can then edit the content through the <a href="{$systemPluginsUrl}">System Plugins</a> page (in the Blocks Plugin section).  To place your plugin in the desired location in the sidebar, go to <a href="{$setupStep4}">Set up step 4</a>]]></message>
19
	<message key="plugins.generic.customBlockManager.settings">Settings</message>
19
	<message key="plugins.generic.customBlockManager.settings">Settings</message>
20
	<message key="plugins.generic.customBlockManager.description">This Plugin lets you manage custom sidebar blocks.  You can edit the blocks in the settings of each plugin that you create here.</message>
20
	<message key="plugins.generic.customBlockManager.description">This Plugin lets you manage custom sidebar blocks.  You can edit the blocks in the settings of each plugin that you create here.</message>
21
	<message key="plugins.generic.customBlockManager.blockName">Block Name</message>	
21
	<message key="plugins.generic.customBlockManager.blockName">Block Name</message>	
(-)ojs2/plugins/generic/customBlockManager/README (-8 / +10 lines)
 Lines 1-12    Link Here 
1
================================
1
================================
2
=== OJS Custom Block Manager Plugin
2
=== OCS Custom Block Manager Plugin
3
=== Version: 1.0
3
=== Version: 1.0
4
=== Author: Juan Pablo Alperin <pkp@alperin.ca>
4
=== Author: Juan Pablo Alperin <pkp@alperin.ca>
5
================================
5
================================
6
6
7
About
7
About
8
-----
8
-----
9
This plugin is intended to enable users to create customizable HTML blocks for the sidebars.  The plugin works in conjunction with Step 5 of the Journal Setup.
9
This plugin is intended to enable users to create customizable HTML blocks for the sidebars.  The plugin works in conjunction with Step 4 of the Conference Setup.
10
11
This plugin was ported from the OJS 2.3 Custom Block Manager Plugin.
10
12
11
License
13
License
12
-------
14
-------
 Lines 14-33    Link Here 
14
16
15
System Requirements
17
System Requirements
16
-------------------
18
-------------------
17
Same requirements as the OJS 2.2 core.
19
??? Same requirements as the OCS 2.3 core.
18
20
19
Installation
21
??? Installation
20
------------
22
------------
21
To install the plugin:
23
To install the plugin:
22
 - copy the plugin tar.gz file to your OJS/plugins/generic directory
24
 - copy the plugin tar.gz file to your OCS/plugins/generic directory
23
 - to unzip the plugin inside the plugins/generic directory:
25
 - to unzip the plugin inside the plugins/generic directory:
24
    $ tar xvzf customBlockManager-1.0.tar.gz 
26
    $ tar xvzf customBlockManager-1.0.tar.gz 
25
 - enable the plugin by going to:  Home > User > Journal Management > Plugin Management > Generic Plugins and selecting "ENABLE" under "Custom Block Manager Plugin"
27
 - enable the plugin by going to:  Home > User > Conference Management > System Plugins > Generic Plugins and selecting "ENABLE" under "Custom Block Manager Plugin"
26
28
27
Configuration
29
Configuration
28
------------
30
------------
29
The Plugin management interface can be found at Home -> User -> Journal Management > Plugin Management > Generic Plugins.  Once the plugin is enabled, blocks can be added and deleted through this interface.  Blocks which are created through this interface will subsequently appear as their own Block Plugin (found under Plugin Management > Block Plugins) and their content can be edited by clicking on the "EDIT" link underneath the name.
31
The Plugin management interface can be found at Home -> User -> Conference Management > System Plugins > Generic Plugins.  Once the plugin is enabled, blocks can be added and deleted through this interface.  Blocks which are created through this interface will subsequently appear as their own Block Plugin (found under Plugin Management > Block Plugins) and their content can be edited by clicking on the "EDIT" link underneath the name.
30
NOTE: The plugin will NOT appear in the sidebar until a sidebar location has bee chosen through Journal Manager -> Setup -> 5. The Look (Specifically, under Journal Layout, step 5.6).
32
NOTE: The plugin will NOT appear in the sidebar until a sidebar location has been chosen through Conference Manager -> Conference Site Management -> 4. Conference Style.
31
33
32
34
33
Contact/Support
35
Contact/Support
(-)ojs2/plugins/generic/customBlockManager/SettingsForm.inc.php (-14 / +14 lines)
 Lines 7-21    Link Here 
7
 *
7
 *
8
 * @class SettingsForm
8
 * @class SettingsForm
9
 *
9
 *
10
 * @brief Form for journal managers to add or delete sidebar blocks
10
 * @brief Form for conference managers to add or delete sidebar blocks
11
 *
11
 *
12
 */
12
 */
13
13
14
import('form.Form');
14
import('form.Form');
15
15
16
class SettingsForm extends Form {
16
class SettingsForm extends Form {
17
	/** @var $journalId int */
17
	/** @var $conferenceId int */
18
	var $journalId;
18
	var $conferenceId;
19
19
20
	/** @var $plugin object */
20
	/** @var $plugin object */
21
	var $plugin;
21
	var $plugin;
 Lines 25-37    Link Here 
25
25
26
	/**
26
	/**
27
	 * Constructor
27
	 * Constructor
28
	 * @param $journalId int
28
	 * @param $conferenceId int
29
	 */
29
	 */
30
	function SettingsForm(&$plugin, $journalId) {
30
	function SettingsForm(&$plugin, $conferenceId) {
31
31
32
		parent::Form($plugin->getTemplatePath() . 'settingsForm.tpl');
32
		parent::Form($plugin->getTemplatePath() . 'settingsForm.tpl');
33
33
34
		$this->journalId = $journalId;
34
		$this->conferenceId = $conferenceId;
35
		$this->plugin =& $plugin;
35
		$this->plugin =& $plugin;
36
36
37
	}
37
	}
 Lines 40-51    Link Here 
40
	 * Initialize form data from  the plugin settings to the form
40
	 * Initialize form data from  the plugin settings to the form
41
	 */
41
	 */
42
	function initData() {
42
	function initData() {
43
		$journalId = $this->journalId;
43
		$conferenceId = $this->conferenceId;
44
		$plugin =& $this->plugin;
44
		$plugin =& $this->plugin;
45
45
46
		$templateMgr =& TemplateManager::getManager();
46
		$templateMgr =& TemplateManager::getManager();
47
47
48
		$blocks = $plugin->getSetting($journalId, 'blocks');
48
		$blocks = $plugin->getSetting($conferenceId, 0, 'blocks');
49
49
50
		if ( !is_array($blocks) ) {
50
		if ( !is_array($blocks) ) {
51
			$this->setData('blocks', array());
51
			$this->setData('blocks', array());
 Lines 71-86    Link Here 
71
	 */
71
	 */
72
	function execute() {
72
	function execute() {
73
		$plugin =& $this->plugin;
73
		$plugin =& $this->plugin;
74
		$journalId = $this->journalId;
74
		$conferenceId = $this->conferenceId;
75
75
76
		$pluginSettingsDAO =& DAORegistry::getDAO('PluginSettingsDAO');
76
		$pluginSettingsDAO =& DAORegistry::getDAO('PluginSettingsDAO');
77
77
78
		$deletedBlocks = explode(':',$this->getData('deletedBlocks'));
78
		$deletedBlocks = explode(':',$this->getData('deletedBlocks'));
79
		foreach ($deletedBlocks as $deletedBlock) {
79
		foreach ($deletedBlocks as $deletedBlock) {
80
			$pluginSettingsDAO->deleteSetting($journalId, $deletedBlock.'CustomBlockPlugin', 'enabled');
80
			$pluginSettingsDAO->deleteSetting($conferenceId, 0, $deletedBlock.'CustomBlockPlugin', 'enabled');
81
			$pluginSettingsDAO->deleteSetting($journalId, $deletedBlock.'CustomBlockPlugin', 'seq');
81
			$pluginSettingsDAO->deleteSetting($conferenceId, 0, $deletedBlock.'CustomBlockPlugin', 'seq');
82
			$pluginSettingsDAO->deleteSetting($journalId, $deletedBlock.'CustomBlockPlugin', 'context');
82
			$pluginSettingsDAO->deleteSetting($conferenceId, 0, $deletedBlock.'CustomBlockPlugin', 'context');
83
			$pluginSettingsDAO->deleteSetting($journalId, $deletedBlock.'CustomBlockPlugin', 'blockContent');
83
			$pluginSettingsDAO->deleteSetting($conferenceId, 0, $deletedBlock.'CustomBlockPlugin', 'blockContent');
84
		}
84
		}
85
85
86
		//sort the blocks in alphabetical order
86
		//sort the blocks in alphabetical order
 Lines 95-101    Link Here 
95
		}
95
		}
96
96
97
		// Update blocks
97
		// Update blocks
98
		$plugin->updateSetting($journalId, 'blocks', $blocks);
98
		$plugin->updateSetting($conferenceId, 0, 'blocks', $blocks);
99
		$this->setData('blocks',$blocks);
99
		$this->setData('blocks',$blocks);
100
	}
100
	}
101
}
101
}

Return to bug 4474