Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
BrowseController.php 3.03 KiB
<?php
/**
 * Browse Module Controller
 *
 * PHP version 7
 *
 * Copyright (C) Villanova University 2011.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category VuFind
 * @package  Controller
 * @author   Chris Hallberg <challber@villanova.edu>
 * @author   Dorian Merz <merz@ub.uni-leipzig.de>
 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
 * @link     https://vufind.org/wiki/development:plugins:controllers Wiki
 */
namespace fid_bbi\Controller;

use VuFind\Controller\BrowseController as BaseController;

/**
 * BrowseController Class
 *
 * Controls the browsing feature
 *
 * This fid_bbi specific instance removes the letter
 * level for alphabetical tag browsing
 *
 * @category VuFind
 * @package  Controller
 * @author   Dorian Merz <merz@ub.uni-leipzig.de>
 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
 * @link     https://vufind.org/wiki/development:plugins:controllers Wiki
 */
class BrowseController extends BaseController
{
    /**
     * Browse tags
     * this is mostly a copy of the
     * parent method with the alphabetical special case
     * removed
     *
     * @return \Zend\View\Model\ViewModel
     */
    public function tagAction()
    {
        if (!$this->tagsEnabled()) {
            throw new ForbiddenException('Tags disabled.');
        }

        $this->setCurrentAction('Tag');
        $view = $this->createViewModel();

        $view->categoryList = [
            'alphabetical' => 'By Alphabetical',
            'popularity'   => 'By Popularity',
            'recent'       => 'By Recent'
        ];

        if ($this->params()->fromQuery('findby')) {
            $params = $this->getRequest()->getQuery()->toArray();
            $tagTable = $this->getTable('Tags');
            // Default case: always display tag list for non-alphabetical modes:
            $tagList = $tagTable->getTagList(
                $params['findby'],
                $this->config->Browse->result_limit
            );
            $resultList = [];
            foreach ($tagList as $i => $tag) {
                $resultList[$i] = [
                    'displayText' => $tag['tag'],
                    'value' => $tag['tag'],
                    'count'    => $tag['cnt']
                ];
            }
            $view->resultList = $resultList;
            $view->paramTitle = 'lookfor=';
            $view->searchParams = [];
        }

        return $this->performSearch($view);
    }
}