17 import(
'lib.pkp.classes.controllers.grid.GridHandler');
21 import(
'controllers.grid.content.spotlights.SpotlightsGridCellProvider');
22 import(
'controllers.grid.content.spotlights.SpotlightsGridRow');
23 import(
'controllers.grid.content.spotlights.form.SpotlightForm');
26 import(
'classes.spotlight.Spotlight');
29 import(
'lib.pkp.classes.linkAction.request.AjaxModal');
42 parent::__construct();
44 array(ROLE_ID_MANAGER),
45 array(
'fetchGrid',
'fetchRow',
'addSpotlight',
'editSpotlight',
46 'updateSpotlight',
'deleteSpotlight',
'itemAutocomplete'));
65 $this->_press =& $press;
77 function authorize($request, &$args, $roleAssignments) {
78 import(
'lib.pkp.classes.security.authorization.ContextAccessPolicy');
80 $returner = parent::authorize($request, $args, $roleAssignments);
82 $spotlightId = $request->getUserVar(
'spotlightId');
84 $press = $request->getPress();
86 $spotlight = $spotlightDao->getById($spotlightId);
87 if ($spotlight ==
null || $spotlight->getPressId() != $press->getId()) {
99 parent::initialize($request, $args);
105 $this->
setTitle(
'spotlight.spotlights');
110 $press = $request->getPress();
114 import(
'controllers.grid.content.spotlights.SpotlightsGridCellProvider');
118 'grid.content.spotlights.form.title',
121 $spotlightsGridCellProvider,
128 'grid.content.spotlights.spotlightItemTitle',
131 $spotlightsGridCellProvider,
141 $spotlightsGridCellProvider
146 $router = $request->getRouter();
147 import(
'lib.pkp.classes.linkAction.request.AjaxModal');
152 $router->url($request,
null,
null,
'addSpotlight',
null,
null),
153 __(
'grid.action.addSpotlight'),
156 __(
'grid.action.addSpotlight'),
176 function loadData($request, $filter =
null) {
180 return $spotlightDao->getByPressId($press->getId());
191 'pressId' => $press->getId()
210 $spotlightId = (int)$request->getUserVar(
'spotlightId');
211 $press = $request->getPress();
212 $pressId = $press->getId();
215 $spotlightForm->initData();
217 return new JSONMessage(
true, $spotlightForm->fetch($request));
228 $spotlightId = $request->getUserVar(
'spotlightId');
233 $spotlight = $spotlightDao->getById($spotlightId, $press->getId());
236 $spotlightForm =
new SpotlightForm($press->getId(), $spotlightId);
238 $spotlightForm->readInputData();
239 if ($spotlightForm->validate()) {
240 $spotlightId = $spotlightForm->execute();
242 if(!isset($spotlight)) {
244 $spotlight = $spotlightDao->getById($spotlightId, $press->getId());
246 $notificationContent = __(
'notification.addedSpotlight');
249 $notificationContent = __(
'notification.editedSpotlight');
253 $currentUser = $request->getUser();
255 $notificationMgr->createTrivialNotification($currentUser->getId(), NOTIFICATION_TYPE_SUCCESS, array(
'contents' => $notificationContent));
259 $row->setGridId($this->
getId());
260 $row->setId($spotlightId);
261 $row->setData($spotlight);
262 $row->initialize($request);
268 return new JSONMessage(
true, $spotlightForm->fetch($request));
281 $spotlightId = $request->getUserVar(
'spotlightId');
285 $spotlight = $spotlightDao->getById($spotlightId, $press->getId());
286 if ($spotlight !=
null) {
288 $result = $spotlightDao->deleteObject($spotlight);
291 $currentUser = $request->getUser();
293 $notificationMgr->createTrivialNotification($currentUser->getId(), NOTIFICATION_TYPE_SUCCESS, array(
'contents' => __(
'notification.removedSpotlight')));
296 return new JSONMessage(
false, __(
'manager.setup.errorDeletingItem'));
309 $name = $request->getUserVar(
'name');
316 import(
'lib.pkp.classes.submission.PKPSubmission');
318 'status' => STATUS_PUBLISHED,
319 'contextId' => $press->getId(),
324 $args[
'searchPhrase'] = $name;
327 $submissionsIterator =
Services::get(
'submission')->getMany($args);
328 foreach ($submissionsIterator as $submission) {
329 $matches[] = array(
'label' => $submission->getLocalizedTitle(),
'value' => $submission->getId() .
':' . SPOTLIGHT_TYPE_BOOK);
332 if (!empty($matches)) {
334 $itemList = array_merge($itemList, $matches);
340 $allSeries = $seriesDao->getByPressId($press->getId());
341 while ($series = $allSeries->next()) {
342 if ($name ==
'' || preg_match(
'/'. preg_quote($name,
'/') .
'/i', $series->getLocalizedTitle())) {
343 $matches[] = array(
'label' => $series->getLocalizedTitle(),
'value' => $series->getId() .
':' . SPOTLIGHT_TYPE_SERIES);
347 if (!empty($matches)) {
349 $itemList = array_merge($itemList, $matches);
352 if (count($itemList) == 0) {