16 import(
'classes.handler.Handler');
19 import(
'lib.pkp.classes.linkAction.LinkAction');
20 import(
'lib.pkp.classes.core.JSONMessage');
29 function authorize($request, &$args, $roleAssignments) {
30 import(
'lib.pkp.classes.security.authorization.ContextRequiredPolicy');
32 return parent::authorize($request, $args, $roleAssignments);
45 $page = isset($args[1]) ? (int) $args[1] : 1;
47 $context = $request->getContext();
51 $category = $categoryDao->getByPath($args[0], $context->getId());
55 import(
'lib.pkp.classes.submission.PKPSubmission');
57 $orderOption = $category->getSortOption() ? $category->getSortOption() : ORDERBY_DATE_PUBLISHED .
'-' . SORT_DIRECTION_DESC;
58 list($orderBy, $orderDir) = explode(
'-', $orderOption);
60 $count = $context->getData(
'itemsPerPage') ? $context->getData(
'itemsPerPage') :
Config::getVar(
'interface',
'items_per_page');
61 $offset = $page > 1 ? ($page - 1) * $count : 0;
63 import(
'classes.core.Services');
65 'contextId' => $context->getId(),
66 'categoryIds' => $category->getId(),
67 'orderByFeatured' =>
true,
68 'orderBy' => $orderBy,
69 'orderDirection' => $orderDir == SORT_DIRECTION_ASC ?
'ASC' :
'DESC',
72 'status' => STATUS_PUBLISHED,
74 $submissionsIterator =
Services::get(
'submission')->getMany($params);
78 $parentCategory = $categoryDao->getById($category->getParentId());
79 $subcategories = $categoryDao->getByParentId($category->getId());
83 $templateMgr->assign(array(
84 'category' => $category,
85 'parentCategory' => $parentCategory,
86 'subcategories' => $subcategories,
87 'publishedSubmissions' => iterator_to_array($submissionsIterator),
90 return $templateMgr->display(
'frontend/pages/catalogCategory.tpl');
99 switch ($request->getUserVar(
'type')) {
101 $context = $request->getContext();
103 $category = $categoryDao->getById($request->getUserVar(
'id'), $context->getId());
105 $imageInfo = $category->getImage();
106 import(
'lib.pkp.classes.file.ContextFileManager');
108 $contextFileManager->downloadByPath($contextFileManager->getBasePath() .
'/categories/' . $imageInfo[
'name'],
null,
true);
121 switch ($request->getUserVar(
'type')) {
123 $context = $request->getContext();
125 $category = $categoryDao->getById($request->getUserVar(
'id'), $context->getId());
127 $imageInfo = $category->getImage();
128 import(
'lib.pkp.classes.file.ContextFileManager');
130 $contextFileManager->downloadByPath($contextFileManager->getBasePath() .
'/categories/' . $imageInfo[
'thumbnailName'],
null,
true);
142 parent::setupTemplate($request);
155 $showingStart = $offset + 1;
156 $showingEnd = min($offset + $count, $offset + $submissionsCount);
157 $nextPage = $total > $showingEnd ? $page + 1 :
null;
158 $prevPage = $showingStart > 1 ? $page - 1 :
null;
161 $templateMgr->assign(array(
162 'showingStart' => $showingStart,
163 'showingEnd' => $showingEnd,
165 'nextPage' => $nextPage,
166 'prevPage' => $prevPage,