SearchHandler::_assignSearchFilters PHP Method

_assignSearchFilters() public method

Private function to transmit current filter values to the template.
public _assignSearchFilters ( $request, &$templateMgr, $searchFilters )
$request PKPRequest
$templateMgr TemplateManager
$searchFilters array
    function _assignSearchFilters($request, &$templateMgr, $searchFilters)
    {
        // Get the journal id (if any).
        $journal =& $searchFilters['searchJournal'];
        $journalId = $journal ? $journal->getId() : null;
        $searchFilters['searchJournal'] = $journalId;
        // Assign all filters except for dates which need special treatment.
        $templateSearchFilters = array();
        foreach ($searchFilters as $filterName => $filterValue) {
            if (in_array($filterName, array('fromDate', 'toDate'))) {
                continue;
            }
            $templateSearchFilters[$filterName] = $filterValue;
        }
        // Assign the filters to the template.
        $templateMgr->assign($templateSearchFilters);
        // Special case: publication date filters.
        foreach (array('From', 'To') as $fromTo) {
            $month = $request->getUserVar("date{$fromTo}Month");
            $day = $request->getUserVar("date{$fromTo}Day");
            $year = $request->getUserVar("date{$fromTo}Year");
            if (empty($year)) {
                $date = '--';
                $hasEmptyFilters = true;
            } else {
                $defaultMonth = $fromTo == 'From' ? 1 : 12;
                $defaultDay = $fromTo == 'From' ? 1 : 31;
                $date = date('Y-m-d H:i:s', mktime(0, 0, 0, empty($month) ? $defaultMonth : $month, empty($day) ? $defaultDay : $day, $year));
                $hasActiveFilters = true;
            }
            $templateMgr->assign(array("date{$fromTo}Month" => $month, "date{$fromTo}Day" => $day, "date{$fromTo}Year" => $year, "date{$fromTo}" => $date));
        }
        // Assign the year range.
        $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
        $yearRange = $publishedArticleDao->getArticleYearRange($journalId);
        $yearStart = substr($yearRange[1], 0, 4);
        $yearEnd = substr($yearRange[0], 0, 4);
        $templateMgr->assign(array('yearStart' => $yearStart, 'yearEnd' => $yearEnd));
    }