Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
ContextGridHandler.inc.php
1 <?php
2 
16 import('lib.pkp.classes.controllers.grid.GridHandler');
17 import('lib.pkp.controllers.grid.admin.context.ContextGridRow');
18 
23  function ContextGridHandler() {
24  parent::GridHandler();
25  $this->addRoleAssignment(array(
26  ROLE_ID_SITE_ADMIN),
27  array('fetchGrid', 'fetchRow', 'createContext', 'editContext', 'updateContext',
28  'deleteContext', 'saveSequence')
29  );
30  }
31 
32 
33  //
34  // Implement template methods from PKPHandler.
35  //
39  function authorize($request, &$args, $roleAssignments) {
40  import('lib.pkp.classes.security.authorization.PolicySet');
41  $rolePolicy = new PolicySet(COMBINING_PERMIT_OVERRIDES);
42 
43  import('lib.pkp.classes.security.authorization.RoleBasedHandlerOperationPolicy');
44  foreach($roleAssignments as $role => $operations) {
45  $rolePolicy->addPolicy(new RoleBasedHandlerOperationPolicy($request, $role, $operations));
46  }
47  $this->addPolicy($rolePolicy);
48 
49  return parent::authorize($request, $args, $roleAssignments);
50  }
51 
55  function initialize($request) {
56  parent::initialize($request);
57 
58  // Load user-related translations.
60  LOCALE_COMPONENT_PKP_USER,
61  LOCALE_COMPONENT_APP_MANAGER,
62  LOCALE_COMPONENT_APP_ADMIN
63  );
64 
65  // Grid actions.
66  $router = $request->getRouter();
67 
68  import('lib.pkp.classes.linkAction.request.AjaxModal');
69  $this->addAction(
70  new LinkAction(
71  'createContext',
72  new AjaxModal(
73  $router->url($request, null, null, 'createContext', null, null),
74  __('admin.contexts.create'),
75  'modal_add_item',
76  true
77  ),
78  __('admin.contexts.create'),
79  'add_item'
80  )
81  );
82 
83  //
84  // Grid columns.
85  //
86  import('lib.pkp.controllers.grid.admin.context.ContextGridCellProvider');
87  $contextGridCellProvider = new ContextGridCellProvider();
88 
89  // Context name.
90  $this->addColumn(
91  new GridColumn(
92  'name',
93  'common.name',
94  null,
95  'controllers/grid/gridCell.tpl',
96  $contextGridCellProvider
97  )
98  );
99 
100  // Context path.
101  $this->addColumn(
102  new GridColumn(
103  'path',
104  'context.path',
105  null,
106  'controllers/grid/gridCell.tpl',
107  $contextGridCellProvider
108  )
109  );
110  }
111 
112 
113  //
114  // Implement methods from GridHandler.
115  //
120  function getRowInstance() {
121  return new ContextGridRow();
122  }
123 
129  function loadData($request) {
130  // Get all contexts.
131  $contextDao = Application::getContextDAO();
132  $contexts = $contextDao->getAll();
133 
134  return $contexts->toAssociativeArray();
135  }
136 
140  function setDataElementSequence($request, $rowId, $context, $newSequence) {
141  $contextDao = Application::getContextDAO();
142  $context->setSequence($newSequence);
143  $contextDao->updateObject($context);
144  }
145 
149  function getDataElementSequence($context) {
150  return $context->getSequence();
151  }
152 
156  function initFeatures($request, $args) {
157  import('lib.pkp.classes.controllers.grid.feature.OrderGridItemsFeature');
158  return array(new OrderGridItemsFeature());
159  }
160 
167  return array('updateHeader');
168  }
169 
170 
171  //
172  // Public grid actions.
173  //
179  function createContext($args, $request) {
180  // Calling editContext with an empty row id will add a new context.
181  return $this->editContext($args, $request);
182  }
183 
184 
185  //
186  // Protected helper methods.
187  //
194  protected function _getRedirectEvent($request, $newContextPath, $openWizard) {
195  $dispatcher = $request->getDispatcher();
196 
197  $url = $dispatcher->url($request, ROUTE_PAGE, $newContextPath, 'admin', 'contexts', null, array('openWizard' => $openWizard));
198  return $request->redirectUrlJson($url);
199  }
200 }
201 
202 ?>
An ordered list of policies. Policy sets can be added to decision managers like policies. The decision manager will evaluate the contained policies in the order they were added.
addPolicy($authorizationPolicy, $addToTop=false)
static requireComponents()
addAction($action, $position=GRID_ACTION_POSITION_ABOVE)
addColumn($column)
Class defining basic operations for handling HTML grids.
Class to control access to handler operations via role based access control.
addRoleAssignment($roleIds, $operations)
A modal that retrieves its content from via AJAX.
Subclass for a context grid column&#39;s cell provider.
_getRedirectEvent($request, $newContextPath, $openWizard)
setDataElementSequence($request, $rowId, $context, $newSequence)
initFeatures($request, $args)
authorize($request, &$args, $roleAssignments)
Implements grid ordering functionality.
Handle context grid requests.
Context grid row definition.
createContext($args, $request)
static getContextDAO()
Represents a column within a grid. It is used to configure the way cells within a column are displaye...
Base class defining an action that can be performed by the user in the user interface.