Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
CarouselHandler.inc.php
1 <?php
2 
16 // Import the base Handler.
17 import('classes.handler.Handler');
18 
19 // Import JSON class for use with all AJAX requests.
20 import('lib.pkp.classes.core.JSONMessage');
21 
22 class CarouselHandler extends Handler {
23 
27  function CarouselHandler() {
28  parent::Handler();
29  }
30 
31 
32  function authorize($request, &$args, $roleAssignments) {
33  import('lib.pkp.classes.security.authorization.ContextRequiredPolicy');
34  $this->addPolicy(new ContextRequiredPolicy($request));
35 
36  return parent::authorize($request, $args, $roleAssignments);
37  }
38 
39  //
40  // Public handler methods
41  //
49  function fetch($args, $request) {
50  $this->setupTemplate($request);
51 
52  $press = $request->getPress();
53  $templateMgr = TemplateManager::getManager($request);
54 
55  // Expose the featured monograph IDs and associated params
56  $featureDao = DAORegistry::getDAO('FeatureDAO');
57  $featuredMonographIds = $featureDao->getSequencesByAssoc(ASSOC_TYPE_PRESS, $press->getId());
58 
59  if (empty($featuredMonographIds)) {
60  $returner = null;
61  } else {
62  $templateMgr->assign('featuredMonographIds', $featuredMonographIds);
63 
64  // Fetch the monographs to display
65  $publishedMonographDao = DAORegistry::getDAO('PublishedMonographDAO');
66  $publishedMonographs = $publishedMonographDao->getByPressId($press->getId());
67  $templateMgr->assign('publishedMonographs', $publishedMonographs->toAssociativeArray());
68 
69  // Render the carousel.
70  $returner = $templateMgr->fetch('catalog/carousel.tpl');
71  }
72 
73  $json = new JSONMessage(true, $returner);
74  return $json->getString();
75  }
76 }
77 ?>
static & getDAO($name, $dbconn=null)
addPolicy($authorizationPolicy, $addToTop=false)
Policy to deny access if a context cannot be found in the request.
setupTemplate($request)
Class to represent a JSON (Javascript Object Notation) message.
Base request handler application class.
Definition: Handler.inc.php:20
fetch($args, $request)
Class defining basic operations for carousel widget.