Open Preprint Systems  3.3.0
PubIdExportRepresentationsListGridHandler.inc.php
1 <?php
2 
16 import('lib.pkp.classes.controllers.grid.GridHandler');
17 import('controllers.grid.pubIds.PubIdExportRepresentationsListGridCellProvider');
18 
21  var $_plugin;
22 
26  function __construct() {
27  parent::__construct();
28  $this->addRoleAssignment(
29  array(ROLE_ID_MANAGER),
30  array('fetchGrid', 'fetchRow')
31  );
32  }
33 
34  //
35  // Implement template methods from PKPHandler
36  //
40  function authorize($request, &$args, $roleAssignments) {
41  import('lib.pkp.classes.security.authorization.PolicySet');
42  $rolePolicy = new PolicySet(COMBINING_PERMIT_OVERRIDES);
43 
44  import('lib.pkp.classes.security.authorization.RoleBasedHandlerOperationPolicy');
45  foreach($roleAssignments as $role => $operations) {
46  $rolePolicy->addPolicy(new RoleBasedHandlerOperationPolicy($request, $role, $operations));
47  }
48  $this->addPolicy($rolePolicy);
49 
50  return parent::authorize($request, $args, $roleAssignments);
51  }
52 
56  function initialize($request, $args = null) {
57  parent::initialize($request, $args);
58  $context = $request->getContext();
59 
60  // Basic grid configuration.
61  $this->setTitle('plugins.importexport.common.export.articles');
62 
63  // Load submission-specific translations.
65  LOCALE_COMPONENT_APP_SUBMISSION, // title filter
66  LOCALE_COMPONENT_PKP_SUBMISSION, // authors filter
67  LOCALE_COMPONENT_APP_MANAGER
68  );
69 
70  $pluginCategory = $request->getUserVar('category');
71  $pluginPathName = $request->getUserVar('plugin');
72  $this->_plugin = PluginRegistry::loadPlugin($pluginCategory, $pluginPathName);
73  assert(isset($this->_plugin));
74 
75  // Fetch the authorized roles.
76  $authorizedRoles = $this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES);
77 
78  // Grid columns.
79  $cellProvider = new PubIdExportRepresentationsListGridCellProvider($this->_plugin, $authorizedRoles);
80  $this->addColumn(
81  new GridColumn(
82  'id',
83  null,
84  __('common.id'),
85  'controllers/grid/gridCell.tpl',
86  $cellProvider,
87  array('alignment' => COLUMN_ALIGNMENT_LEFT,
88  'width' => 10)
89  )
90  );
91  $this->addColumn(
92  new GridColumn(
93  'title',
94  'grid.submission.itemTitle',
95  null,
96  null,
97  $cellProvider,
98  array('html' => true,
99  'alignment' => COLUMN_ALIGNMENT_LEFT)
100  )
101  );
102  $this->addColumn(
103  new GridColumn(
104  'galley',
105  'submission.layout.galleyLabel',
106  null,
107  null,
108  $cellProvider,
109  array('alignment' => COLUMN_ALIGNMENT_LEFT,
110  'width' => 20)
111  )
112  );
113  $this->addColumn(
114  new GridColumn(
115  'pubId',
116  null,
117  $this->_plugin->getPubIdDisplayType(),
118  null,
119  $cellProvider,
120  array('alignment' => COLUMN_ALIGNMENT_LEFT,
121  'width' => 15)
122  )
123  );
124  $this->addColumn(
125  new GridColumn(
126  'status',
127  'common.status',
128  null,
129  null,
130  $cellProvider,
131  array('alignment' => COLUMN_ALIGNMENT_LEFT,
132  'width' => 10)
133  )
134  );
135 
136  }
137 
138 
139  //
140  // Implemented methods from GridHandler.
141  //
145  function initFeatures($request, $args) {
146  import('lib.pkp.classes.controllers.grid.feature.selectableItems.SelectableItemsFeature');
147  import('lib.pkp.classes.controllers.grid.feature.PagingFeature');
148  return array(new SelectableItemsFeature(), new PagingFeature());
149  }
150 
154  function getRequestArgs() {
155  return array_merge(parent::getRequestArgs(), array('category' => $this->_plugin->getCategory(), 'plugin' => basename($this->_plugin->getPluginPath())));
156  }
157 
161  function isDataElementSelected($gridDataElement) {
162  return false; // Nothing is selected by default
163  }
164 
168  function getSelectName() {
169  return 'selectedRepresentations';
170  }
171 
175  protected function getFilterForm() {
176  return 'controllers/grid/pubIds/pubIdExportRepresentationsGridFilter.tpl';
177  }
178 
182  function renderFilter($request, $filterData = array()) {
183  $context = $request->getContext();
184  $statusNames = $this->_plugin->getStatusNames();
185  $filterColumns = $this->getFilterColumns();
186  $allFilterData = array_merge(
187  $filterData,
188  array(
189  'columns' => $filterColumns,
190  'status' => $statusNames,
191  'gridId' => $this->getId(),
192  ));
193  return parent::renderFilter($request, $allFilterData);
194  }
195 
199  function getFilterSelectionData($request) {
200  $search = (string) $request->getUserVar('search');
201  $column = (string) $request->getUserVar('column');
202  $statusId = (string) $request->getUserVar('statusId');
203  return array(
204  'search' => $search,
205  'column' => $column,
206  'statusId' => $statusId,
207  );
208  }
209 
213  protected function loadData($request, $filter) {
214  $articleGalleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
215  $context = $request->getContext();
216  list($search, $column, $statusId) = $this->getFilterValues($filter);
217  $title = $author = null;
218  if ($column == 'title') {
219  $title = $search;
220  } elseif ($column == 'author') {
221  $author = $search;
222  }
223  $pubIdStatusSettingName = null;
224  if ($statusId) {
225  $pubIdStatusSettingName = $this->_plugin->getDepositStatusSettingName();
226  }
227  return $articleGalleyDao->getExportable(
228  $context->getId(),
229  $this->_plugin->getPubIdType(),
230  $title,
231  $author,
232  $pubIdStatusSettingName,
233  $statusId,
234  $this->getGridRangeInfo($request, $this->getId())
235  );
236  }
237 
238 
239  //
240  // Own protected methods
241  //
246  protected function getFilterColumns() {
247  return array(
248  'title' => __('submission.title'),
249  'author' => __('submission.authors')
250  );
251  }
252 
258  protected function getFilterValues($filter) {
259  if (isset($filter['search']) && $filter['search']) {
260  $search = $filter['search'];
261  } else {
262  $search = null;
263  }
264  if (isset($filter['column']) && $filter['column']) {
265  $column = $filter['column'];
266  } else {
267  $column = null;
268  }
269  if (isset($filter['statusId']) && $filter['statusId'] != EXPORT_STATUS_ANY) {
270  $statusId = $filter['statusId'];
271  } else {
272  $statusId = null;
273  }
274  return array($search, $column, $statusId);
275  }
276 
277 }
278 
279 
PKPHandler\addRoleAssignment
addRoleAssignment($roleIds, $operations)
Definition: PKPHandler.inc.php:213
GridColumn
The GridColumn class represents a column within a grid. It is used to format the data presented in a ...
Definition: GridColumn.inc.php:27
PubIdExportRepresentationsListGridHandler\getRequestArgs
getRequestArgs()
Definition: PubIdExportRepresentationsListGridHandler.inc.php:157
AppLocale\requireComponents
static requireComponents()
Definition: env1/MockAppLocale.inc.php:56
PubIdExportRepresentationsListGridHandler\getFilterColumns
getFilterColumns()
Definition: PubIdExportRepresentationsListGridHandler.inc.php:249
PubIdExportRepresentationsListGridCellProvider
Definition: PubIdExportRepresentationsListGridCellProvider.inc.php:19
PubIdExportRepresentationsListGridHandler\__construct
__construct()
Definition: PubIdExportRepresentationsListGridHandler.inc.php:29
DAORegistry\getDAO
static & getDAO($name, $dbconn=null)
Definition: DAORegistry.inc.php:57
PubIdExportRepresentationsListGridHandler\initFeatures
initFeatures($request, $args)
Definition: PubIdExportRepresentationsListGridHandler.inc.php:148
PKPHandler\getId
getId()
Definition: PKPHandler.inc.php:107
GridHandler\addColumn
addColumn($column)
Definition: GridHandler.inc.php:335
PubIdExportRepresentationsListGridHandler
Handle exportable representations with pub ids list grid requests.
Definition: PubIdExportRepresentationsListGridHandler.inc.php:19
PubIdExportRepresentationsListGridHandler\getSelectName
getSelectName()
Definition: PubIdExportRepresentationsListGridHandler.inc.php:171
PubIdExportRepresentationsListGridHandler\isDataElementSelected
isDataElementSelected($gridDataElement)
Definition: PubIdExportRepresentationsListGridHandler.inc.php:164
PubIdExportRepresentationsListGridHandler\getFilterValues
getFilterValues($filter)
Definition: PubIdExportRepresentationsListGridHandler.inc.php:261
PubIdExportRepresentationsListGridHandler\renderFilter
renderFilter($request, $filterData=array())
Definition: PubIdExportRepresentationsListGridHandler.inc.php:185
SelectableItemsFeature
Implements grid widgets selectable items functionality.
Definition: SelectableItemsFeature.inc.php:19
PagingFeature
Add paging functionality to grids.
Definition: PagingFeature.inc.php:19
PubIdExportRepresentationsListGridHandler\initialize
initialize($request, $args=null)
Definition: PubIdExportRepresentationsListGridHandler.inc.php:59
GridHandler\setTitle
setTitle($title)
Definition: GridHandler.inc.php:215
PluginRegistry\loadPlugin
static loadPlugin($category, $pathName, $mainContextId=null)
Definition: PluginRegistry.inc.php:175
PubIdExportRepresentationsListGridHandler\getFilterSelectionData
getFilterSelectionData($request)
Definition: PubIdExportRepresentationsListGridHandler.inc.php:202
PKPHandler\getAuthorizedContextObject
& getAuthorizedContextObject($assocType)
Definition: PKPHandler.inc.php:174
PubIdExportRepresentationsListGridHandler\$_plugin
$_plugin
Definition: PubIdExportRepresentationsListGridHandler.inc.php:24
GridHandler
This class defines basic operations for handling HTML grids. Grids are used to implement a standardiz...
Definition: GridHandler.inc.php:58
RoleBasedHandlerOperationPolicy
Class to control access to handler operations via role based access control.
Definition: RoleBasedHandlerOperationPolicy.inc.php:18
PKPHandler\addPolicy
addPolicy($authorizationPolicy, $addToTop=false)
Definition: PKPHandler.inc.php:157
PubIdExportRepresentationsListGridHandler\authorize
authorize($request, &$args, $roleAssignments)
Definition: PubIdExportRepresentationsListGridHandler.inc.php:43
PubIdExportRepresentationsListGridHandler\getFilterForm
getFilterForm()
Definition: PubIdExportRepresentationsListGridHandler.inc.php:178
PolicySet
An ordered list of policies. Policy sets can be added to decision managers like policies....
Definition: PolicySet.inc.php:26
PubIdExportRepresentationsListGridHandler\loadData
loadData($request, $filter)
Definition: PubIdExportRepresentationsListGridHandler.inc.php:216