Customization stopped working after update ojs 3.2.0.3 to 3.3.0.8 (Call to undefined method JournalDAO::getPath())

OJS version: 3.3.0.8

Hello, in our site we have an A-Z index customization, to browse by journals by the firsts letters of the names. It worked in OJS 3.2.0.3 but after we upgraded the OJS to version 3.3.0.8 it stopped working. The error occurs when I click in some letter of the index and no one journal is displayed (when Im browsing without use the browse by letter all the journal appear without problems, the error occors only when I try to browse by letters). The error says Uncaught Error: Call to undefined method JournalDAO::getPath().

PHP Fatal error:  Uncaught Error: Call to undefined method JournalDAO::getPath() in /var/www/html/ojs3308/cache/t_compile/65bfc3e024c2e9104f46e23b73376a9455e3df0e^51cfb9321c891ada9323e7942962579e7e4324d1_0.app.frontendpagesindexSite.tp.php:96\nStack trace:\n#0 /var/www/html/ojs3308/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_61705405d24691_68717653(Object(Smarty_Internal_Template))\n#1 /var/www/html/ojs3308/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode(Object(Smarty_Internal_Template))\n#2 /var/www/html/ojs3308/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(216): Smarty_Template_Compiled->render(Object(Smarty_Internal_Template))\n#3 /var/www/html/ojs3308/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(232): Smarty_Internal_Template->render(false, 1)\n#4 /var/www/html/ojs3308/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/sm in /var/www/html/ojs3308/cache/t_compile/65bfc3e024c2e9104f46e23b73376a9455e3df0e^51cfb9321c891ada9323e7942962579e7e4324d1_0.app.frontendpagesindexSite.tp.php on line 96

Line 96 in /var/www/html/ojs3308/cache/t_compile/65bfc3e024c2e9104f46e23b73376a9455e3df0e^51cfb9321c891ada9323e7942962579e7e4324d1_0.app.frontendpagesindexSite.tp.php

echo call_user_func_array( $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['url'][0], array( array('journal'=>$_smarty_tpl->tpl_vars['journal']->value->getPath()),$_smarty_tpl ) );

I read that some properties from ADODB has been removed on 3.3 (Remove ADODB · Issue #6264 · pkp/pkp-lib · GitHub and OJS/OMP/OPS 3.3 Release Notebook - OJS/OMP/OPS) so I refactored the code in the function getJournalsByLetter on the file JournalDAO.inc.php (I will put the JournalDAO.inc.php bellow) using now the query builder and the error persists:

PHP Fatal error:  Uncaught Error: Call to undefined method stdClass::getPath() in /var/www/html/ojs3308/cache/t_compile/65bfc3e024c2e9104f46e23b73376a9455e3df0e^51cfb9321c891ada9323e7942962579e7e4324d1_0.app.frontendpagesindexSite.tp.php:96\nStack trace:\n#0 /var/www/html/ojs3308/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_6170814734a8f5_92241670(Object(Smarty_Internal_Template))\n#1 /var/www/html/ojs3308/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode(Object(Smarty_Internal_Template))\n#2 /var/www/html/ojs3308/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(216): Smarty_Template_Compiled->render(Object(Smarty_Internal_Template))\n#3 /var/www/html/ojs3308/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(232): Smarty_Internal_Template->render(false, 1)\n#4 /var/www/html/ojs3308/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smar in /var/www/html/ojs3308/cache/t_compile/65bfc3e024c2e9104f46e23b73376a9455e3df0e^51cfb9321c891ada9323e7942962579e7e4324d1_0.app.frontendpagesindexSite.tp.php on line 96

We made modifications on the following files:

  • ojs/classes/journal/JournalDAO.inc.php
  • ojs/pages/index/IndexHandler.inc.php
  • ojs/pages/search/SearchHandler.inc.php
  • ojs/plugins/themes/[theme-name]/templates/frontend/pages/indexSite.tpl

JournalDAO.inc.php

<?php

/**
 * @file classes/journal/JournalDAO.inc.php
 *
 * Copyright (c) 2014-2021 Simon Fraser University
 * Copyright (c) 2003-2021 John Willinsky
 * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
 *
 * @class JournalDAO
 * @ingroup journal
 * @see Journal
 *
 * @brief Operations for retrieving and modifying Journal objects.
 */

import('lib.pkp.classes.context.ContextDAO');
import('classes.journal.Journal');
import('lib.pkp.classes.metadata.MetadataTypeDescription');

use Illuminate\Database\Capsule\Manager as Capsule;

define('JOURNAL_FIELD_TITLE', 1);
define('JOURNAL_FIELD_SEQUENCE', 2);

class JournalDAO extends ContextDAO {
	/** @copydoc SchemaDAO::$schemaName */
	var $schemaName = 'context';

	/** @copydoc SchemaDAO::$tableName */
	var $tableName = 'journals';

	/** @copydoc SchemaDAO::$settingsTableName */
	var $settingsTableName = 'journal_settings';

	/** @copydoc SchemaDAO::$primaryKeyColumn */
	var $primaryKeyColumn = 'journal_id';

	/** @var array Maps schema properties for the primary table to their column names */
	var $primaryTableColumns = [
		'id' => 'journal_id',
		'urlPath' => 'path',
		'enabled' => 'enabled',
		'seq' => 'seq',
		'primaryLocale' => 'primary_locale',
	];

	/**
	 * Create a new DataObject of the appropriate class
	 *
	 * @return DataObject
	 */
	public function newDataObject() {
		return new Journal();
	}

	/**
	 * Retrieve the IDs and titles of all journals in an associative array.
	 * @return array
	 */
	function getTitles($enabledOnly = false) {
		$journals = array();
		$journalIterator = $this->getAll($enabledOnly);
		while ($journal = $journalIterator->next()) {
			$journals[$journal->getId()] = $journal->getLocalizedName();
		}

		return $journals;
	}

	/**
	 * Delete the public IDs of all publishing objects in a journal.
	 * @param $journalId int
	 * @param $pubIdType string One of the NLM pub-id-type values or
	 * 'other::something' if not part of the official NLM list
	 * (see <http://dtd.nlm.nih.gov/publishing/tag-library/n-4zh0.html>).
	 */
	function deleteAllPubIds($journalId, $pubIdType) {
		$pubObjectDaos = array('IssueDAO', 'PublicationDAO', 'ArticleGalleyDAO');
		foreach($pubObjectDaos as $daoName) {
			$dao = DAORegistry::getDAO($daoName);
			$dao->deleteAllPubIds($journalId, $pubIdType);
		}

                import('classes.submission.SubmissionFileDAO');
                $submissionFileDao = new SubmissionFileDAO();
                $submissionFileDao->deleteAllPubIds($journalId, $pubIdType);

	}

	/**
	 * Check whether the given public ID exists for any publishing
	 * object in a journal.
	 * @param $journalId int
	 * @param $pubIdType string One of the NLM pub-id-type values or
	 * 'other::something' if not part of the official NLM list
	 * (see <http://dtd.nlm.nih.gov/publishing/tag-library/n-4zh0.html>).
	 * @param $pubId string
	 * @param $assocType int The object type of an object to be excluded from
	 *  the search. Identified by one of the ASSOC_TYPE_* constants.
	 * @param $assocId int The id of an object to be excluded from the search.
	 * @param $forSameType boolean Whether only the same objects should be considered.
	 * @return boolean
	 */
	function anyPubIdExists($journalId, $pubIdType, $pubId,
			$assocType = ASSOC_TYPE_ANY, $assocId = 0, $forSameType = false) {

		$pubObjectDaos = array(
			ASSOC_TYPE_ISSUE => DAORegistry::getDAO('IssueDAO'),
			ASSOC_TYPE_SUBMISSION => DAORegistry::getDAO('SubmissionDAO'),
			ASSOC_TYPE_GALLEY => Application::getRepresentationDAO(),
			ASSOC_TYPE_ISSUE_GALLEY => DAORegistry::getDAO('IssueGalleyDAO'),
			ASSOC_TYPE_SUBMISSION_FILE => DAORegistry::getDAO('SubmissionFileDAO')
		);
		if ($forSameType) {
			$dao = $pubObjectDaos[$assocType];
			$excludedId = $assocId;
			if ($dao->pubIdExists($pubIdType, $pubId, $excludedId, $journalId)) return true;
			return false;
		}
		foreach($pubObjectDaos as $daoAssocType => $dao) {
			if ($assocType == $daoAssocType) {
				$excludedId = $assocId;
			} else {
				$excludedId = 0;
			}
			if ($dao->pubIdExists($pubIdType, $pubId, $excludedId, $journalId)) return true;
		}
		return false;
	}
	
        /**modified
         * Retorno as revistas que comecam com a letra inicial passada
         * * @param $searchInitial string
         */
        function getJournalsByLetter($enabledOnly = false, $searchInitial = '', $rangeInfo = null) {

		$locale = AppLocale::getLocale();

		/* old code
		$sql = 'SELECT j.* FROM journals j, journal_settings js ' .
				' where j.journal_id = js.journal_id and'.
				' js.setting_name = \'name\' and'.
				' js.locale = \''. $locale . '\' and'.
				' LOWER(js.setting_value) like LOWER(\'' . $searchInitial .'%\')' .
				' GROUP BY j.journal_id' .
				' ORDER BY js.setting_value';

		$result = $this->retrieveRange(
				$sql,
				false,
                                //[]
				$rangeInfo
		);

		$result = $this->retrieveRange(
				'SELECT j.*
				FROM journals j, journal_settings js
				WHERE j.journal_id = js.journal_id
				AND js.setting_name = name
				AND js.locale = ?
				AND LOWER(js.setting_value) LIKE LOWER(?)
				GROUP BY j.journal_id
				ORDER BY js.setting_value',
				[(string) $locale, (string) $searchInitial],
				$rangeInfo
		);


		return new DAOResultFactory($result, $this, '_fromRow');
		old code end*/

		//new code with query build
		$result = Capsule::table('journals')
			->join('journal_settings', 'journals.journal_id', '=', 'journal_settings.journal_id')
			->where('journal_settings.setting_name', '=', 'name')
			->where('journal_settings.locale', $locale)
			->where('journal_settings.setting_value', 'LIKE',  $searchInitial . '%')
			->groupBy('journals.journal_id')
			->orderBy('journal_settings.setting_value')
			->get();
			//->toArray();
			//->dd(); //dump and die	
		
		return $result;
        }
        /*modified*/
}

IndexHandler.inc.php

<?php

/**
 * @file pages/index/IndexHandler.inc.php
 *
 * Copyright (c) 2014-2021 Simon Fraser University
 * Copyright (c) 2003-2021 John Willinsky
 * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
 *
 * @class IndexHandler
 * @ingroup pages_index
 *
 * @brief Handle site index requests.
 */

import('lib.pkp.pages.index.PKPIndexHandler');

class IndexHandler extends PKPIndexHandler {
	//
	// Public handler operations
	//
	/**
	 * If no journal is selected, display list of journals.
	 * Otherwise, display the index page for the selected journal.
	 * @param $args array
	 * @param $request Request
	 */
	function index($args, $request) {
		$this->validate(null, $request);
		$journal = $request->getJournal();

		if (!$journal) {
			$hasNoContexts = null; // Avoid scrutinizer warnings
			$journal = $this->getTargetContext($request, $hasNoContexts);
			if ($journal) {
				// There's a target context but no journal in the current request. Redirect.
				$request->redirect($journal->getPath());
			}
			if ($hasNoContexts && Validation::isSiteAdmin()) {
				// No contexts created, and this is the admin.
				$request->redirect(null, 'admin', 'contexts');
			}
		}

		$this->setupTemplate($request);
		$router = $request->getRouter();
		$templateMgr = TemplateManager::getManager($request);
		if ($journal) {
			// Assign header and content for home page
			$templateMgr->assign(array(
				'additionalHomeContent' => $journal->getLocalizedData('additionalHomeContent'),
				'homepageImage' => $journal->getLocalizedData('homepageImage'),
				'homepageImageAltText' => $journal->getLocalizedData('homepageImageAltText'),
				'journalDescription' => $journal->getLocalizedData('description'),
			));

			$issueDao = DAORegistry::getDAO('IssueDAO'); /* @var $issueDao IssueDAO */
			$issue = $issueDao->getCurrent($journal->getId(), true);
			if (isset($issue) && $journal->getData('publishingMode') != PUBLISHING_MODE_NONE) {
				import('pages.issue.IssueHandler');
				// The current issue TOC/cover page should be displayed below the custom home page.
				IssueHandler::_setupIssueTemplate($request, $issue);
			}

			$this->_setupAnnouncements($journal, $templateMgr);

			$templateMgr->display('frontend/pages/indexJournal.tpl');
		} else {
			$journalDao = DAORegistry::getDAO('JournalDAO'); /* @var $journalDao JournalDAO */
			$site = $request->getSite();

			if ($site->getRedirect() && ($journal = $journalDao->getById($site->getRedirect())) != null) {
				$request->redirect($journal->getPath());
			}

			$templateMgr->assign([
				'pageTitleTranslated' => $site->getLocalizedTitle(),
				'about' => $site->getLocalizedAbout(),
				'journalFilesPath' => $request->getBaseUrl() . '/' . Config::getVar('files', 'public_files_dir') . '/journals/',
				'journals' => $journalDao->getAll(true)->toArray(),
				'site' => $site,
			]);
		
			/* modified */
			unset($journalIterator);

			// Fetch the alpha list parameters
			$searchInitial = $request->getUserVar('searchInitial');
			//var_dump($searchInitial);
			$sort = $request->getUserVar('sort');	
                        //var_dump($sort);

			$templateMgr->assign('searchInitial', $searchInitial); 
                        //var_dump($templateMgr);

			$initialLetters = array();			
			$journalIterator = $journalDao->getAll(true);
                        //var_dump($journalIterator);

			if($searchInitial){
				switch ($sort) {
					case 'title':
						$newJournals = $journalDao->getJournalsByLetter(true, $searchInitial);
						//var_dump($newJournals);
		
						$templateMgr->assign('journals', $newJournals);
					break;
				}				
			}
											
			$initialLetters = $this->getInitialLetters($journalDao);
			//var_dump($initialLetters);
			$templateMgr->assign('usedAlphas', $initialLetters);
			$templateMgr->assign('site', $site);
			$templateMgr->assign('alphaList', explode(' ', __('common.alphaList')));


			/*$templateMgr->assign([
				'usedAlphas' => $initialLetters,
				'site' => $site,
				'alphaList' => explode(' ', __('common.alphaList'))
			]);*/
			
			//var_dump($templateMgr);
			
			/* modified */


			$templateMgr->setCacheability(CACHEABILITY_PUBLIC);
			$templateMgr->display('frontend/pages/indexSite.tpl');
		}
	}


	/** modified
	 *
	 * Retorno as letras usadas nos titulos das revistas
	 */
	function getInitialLetters($journalDao){

		$journalIterator = $journalDao->getAll(true);
		$initialLetters = array();

		while ($journal = $journalIterator->next()) {

			$journalTitle = $journal->getLocalizedName();
        	        //var_dump($journalTitle);	
			$initialLetter = $journalTitle[0];
			$journalId = $journal->getId();
			$initialLetters[strtoupper($initialLetter)] = strtoupper($initialLetter);
		}
		//echo "initial letters: ";
		//var_dump($initialLetters);
		return $initialLetters;
	}
	/*modified*/


}

SearchHandler.inc.php

<?php

/**
 * @file pages/search/SearchHandler.inc.php
 *
 * Copyright (c) 2014-2021 Simon Fraser University
 * Copyright (c) 2003-2021 John Willinsky
 * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
 *
 * @class SearchHandler
 * @ingroup pages_search
 *
 * @brief Handle site index requests.
 */

import('classes.search.ArticleSearch');
import('classes.handler.Handler');

class SearchHandler extends Handler {

	/**
	 * @copydoc PKPHandler::authorize()
	 */
	function authorize($request, &$args, $roleAssignments) {
		import('classes.security.authorization.OjsJournalMustPublishPolicy');
		if ($request->getContext()) $this->addPolicy(new OjsJournalMustPublishPolicy($request));

		return parent::authorize($request, $args, $roleAssignments);
	}

	/**
	 * Show the search form
	 * @param $args array
	 * @param $request PKPRequest
	 */
	function index($args, $request) {
		$this->validate(null, $request);
		$this->search($args, $request);
	}

	/**
	 * Private function to transmit current filter values
	 * to the template.
	 * @param $request PKPRequest
	 * @param $templateMgr TemplateManager
	 * @param $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 = NULL;
				$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.
		$yearRange = Services::get('publication')->getDateBoundaries(['contextIds' => $journalId]);
		$yearStart = substr($yearRange[0], 0, 4);
		$yearEnd = substr($yearRange[1], 0, 4);
		$templateMgr->assign(array(
			'yearStart' => $yearStart,
			'yearEnd' => $yearEnd,
		));
	}

	/**
	 * Show the search form
	 * @param $args array
	 * @param $request PKPRequest
	 */
	function search($args, $request) {
		$this->validate(null, $request);

		// Get and transform active filters.
		$articleSearch = new ArticleSearch();
		$searchFilters = $articleSearch->getSearchFilters($request);
		$keywords = $articleSearch->getKeywordsFromSearchFilters($searchFilters);

		// Get the range info.
		$rangeInfo = $this->getRangeInfo($request, 'search');

		// Retrieve results.
		$error = '';
		$results = $articleSearch->retrieveResults(
			$request, $searchFilters['searchJournal'], $keywords, $error,
			$searchFilters['fromDate'], $searchFilters['toDate'],
			$rangeInfo
		);


		// Prepare and display the search template.
		$this->setupTemplate($request);
		$templateMgr = TemplateManager::getManager($request);
		$templateMgr->setCacheability(CACHEABILITY_NO_STORE);

		// Result set ordering options.
		$orderByOptions = $articleSearch->getResultSetOrderingOptions($request);
		$templateMgr->assign('searchResultOrderOptions', $orderByOptions);
		$orderDirOptions = $articleSearch->getResultSetOrderingDirectionOptions();
		$templateMgr->assign('searchResultOrderDirOptions', $orderDirOptions);

		// Result set ordering selection.
		list($orderBy, $orderDir) = $articleSearch->getResultSetOrdering($request);
		$templateMgr->assign('orderBy', $orderBy);
		$templateMgr->assign('orderDir', $orderDir);

		// Similar documents.
		$templateMgr->assign('simDocsEnabled', true);

		// Result set display.
		$this->_assignSearchFilters($request, $templateMgr, $searchFilters);
		$templateMgr->assign('results', $results);
		$templateMgr->assign('error', $error);
		$templateMgr->display('frontend/pages/search.tpl');
	}

	/**
	 * Redirect to a search query that shows documents
	 * similar to the one identified by an article id in the
	 * request.
	 * @param $args array
	 * @param $request Request
	 */
	function similarDocuments($args, &$request) {
		$this->validate(null, $request);

		// Retrieve the (mandatory) ID of the article that
		// we want similar documents for.
		$articleId = $request->getUserVar('articleId');
		if (!is_numeric($articleId)) {
			$request->redirect(null, 'search');
		}

		// Check whether a search plugin provides terms for a similarity search.
		$articleSearch = new ArticleSearch();
		$searchTerms = $articleSearch->getSimilarityTerms($articleId);

		// Redirect to a search query with the identified search terms (if any).
		if (empty($searchTerms)) {
			$searchParams = null;
		} else {
			$searchParams = array('query' => implode(' ', $searchTerms));
		}
		$request->redirect(null, 'search', 'search', null, $searchParams);
	}

	/**
	 * Show index of published submissions by author.
	 * @param $args array
	 * @param $request PKPRequest
	 */
	function authors($args, $request) {
		$this->validate(null, $request);
		$this->setupTemplate($request);

		$journal = $request->getJournal();
		$user = $request->getUser();

		$authorDao = DAORegistry::getDAO('AuthorDAO'); /* @var $authorDao AuthorDAO */

		if (isset($args[0]) && $args[0] == 'view') {
			// View a specific author
			$authorName = $request->getUserVar('authorName');
			$givenName = $request->getUserVar('givenName');
			$familyName = $request->getUserVar('familyName');
			$affiliation = $request->getUserVar('affiliation');
			$country = $request->getUserVar('country');

			$authorRecords = iterator_to_array(Services::get('author')->getMany([
				'contextIds' => $journal?[$journal->getId()]:[],
				'givenName' => $givenName,
				'familyName' => $familyName,
				'affiliation' => $affiliation,
				'country' => $country,
			]));
			$publicationIds = array_map(function($author) {
				return $author->getData('publicationId');
			}, $authorRecords);
			$submissionIds = array_filter(array_map(function($publicationId) {
				$publication = Services::get('publication')->get($publicationId);
				return $publication->getData('status') == STATUS_PUBLISHED ? $publication->getData('submissionId') : null;
			}, array_unique($publicationIds)));
			$submissions = array_map(function($submissionId) {
				return Services::get('submission')->get($submissionId);
			}, array_unique($submissionIds));

			// Load information associated with each article.
			$journals = array();
			$issues = array();
			$sections = array();
			$issuesUnavailable = array();

			$issueDao = DAORegistry::getDAO('IssueDAO'); /* @var $issueDao IssueDAO */
			$sectionDao = DAORegistry::getDAO('SectionDAO'); /* @var $sectionDao SectionDAO */
			$journalDao = DAORegistry::getDAO('JournalDAO'); /* @var $journalDao JournalDAO */

			foreach ($submissions as $article) {
				$articleId = $article->getId();
				$issueId = $article->getCurrentPublication()->getData('issueId');
				$sectionId = $article->getSectionId();
				$journalId = $article->getData('contextId');

				if (!isset($journals[$journalId])) {
					$journals[$journalId] = $journalDao->getById($journalId);
				}
				if (!isset($issues[$issueId])) {
					import('classes.issue.IssueAction');
					$issue = $issueDao->getById($issueId);
					$issues[$issueId] = $issue;
					$issueAction = new IssueAction();
					$issuesUnavailable[$issueId] = $issueAction->subscriptionRequired($issue, $journals[$journalId]) && (!$issueAction->subscribedUser($user, $journals[$journalId], $issueId, $articleId) && !$issueAction->subscribedDomain($request, $journals[$journalId], $issueId, $articleId));
				}
				if (!isset($sections[$sectionId])) {
					$sections[$sectionId] = $sectionDao->getById($sectionId, $journalId, true);
				}
			}

			if (empty($submissions)) {
				$request->redirect(null, $request->getRequestedPage());
			}

			$templateMgr = TemplateManager::getManager($request);
			$templateMgr->assign(array(
				'submissions' => $submissions,
				'issues' => $issues,
				'issuesUnavailable' => $issuesUnavailable,
				'sections' => $sections,
				'journals' => $journals,
				'givenName' => $givenName,
				'familyName' => $familyName,
				'affiliation' => $affiliation,
				'authorName' => $authorName
			));

			$isoCodes = new \Sokil\IsoCodes\IsoCodesFactory();
			$countries = $countries = $isoCodes->getCountries();
			$country = $countries->getByAlpha2($country);
			$templateMgr->assign('country', $country?$country->getLocalName():'');

			$templateMgr->display('frontend/pages/searchAuthorDetails.tpl');
		} else {
			// Show the author index
			$searchInitial = $request->getUserVar('searchInitial');
			$rangeInfo = $this->getRangeInfo($request, 'authors');

			$authors = $authorDao->getAuthorsAlphabetizedByJournal(
				isset($journal)?$journal->getId():null,
				$searchInitial,
				$rangeInfo
			);

			$templateMgr = TemplateManager::getManager($request);
			$templateMgr->assign(array(
				'searchInitial' => $request->getUserVar('searchInitial'),
				'alphaList' => array_merge(array('-'), explode(' ', __('common.alphaList'))),
				'authors' => $authors,
			));


			/**
			 * Lista das letras usadas
			 */
			//modified 
			 $authorsIterator = $authorDao->getAuthorsAlphabetizedByJournal(
				isset($journal)?$journal->getId():null,
				$searchInitial,
				$rangeInfo
			);
			$initialLetters = $this->getInitialLetters($authorsIterator);
			
			//var_dump($initialLetters);
			$templateMgr->assign('usedAlphas', $initialLetters);
			//$templateMgr->assign(array('usedAlphas' => $initialLetters));
			//modified

			$templateMgr->display('frontend/pages/searchAuthorIndex.tpl');
		}
	}


	/**Retorno as letras usadas nos titulos dos autores da revista 
	 * modified
	 */
	function getInitialLetters($authorsIterator){

		$initialLetters = array();

		while ($author = $authorsIterator->next()) {
			$authorName = $author->getLastName();
			$initialLetter = $authorName[0];
			$initialLetters[strtoupper($initialLetter)] = strtoupper($initialLetter);
		}
		

		return $initialLetters;
	}

	function titles($args, $request) {
	 }


	/**
	 * Setup common template variables.
	 * @param $request PKPRequest
	 */
	function setupTemplate($request) {
		parent::setupTemplate($request);
		$templateMgr = TemplateManager::getManager($request);
		$journal = $request->getJournal();
		if (!$journal || !$journal->getData('restrictSiteAccess')) {
			$templateMgr->setCacheability(CACHEABILITY_PUBLIC);
		}
	}
}

indexSite.tpl

{**
 * templates/frontend/pages/indexSite.tpl
 *
 * Copyright (c) 2014-2021 Simon Fraser University
 * Copyright (c) 2003-2021 John Willinsky
 * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
 *
 * Site index.
 *
 *}
{include file="frontend/components/header.tpl"}

<div class="page_index_site">

	{if $about}
		<div class="about_site">
			{$about}
		</div>
	{/if}
	
	{* modified - alfabeto na tela inicial que retorna as revistas por titulo *}
	
	<p><strong>{translate key="plugins.themes.ensinoinovativo.searchText"}</strong></p>
	
	<p class="revistasPorLetra">
		{foreach from=$alphaList item=letter}
			<a class="{if $letter|array_key_exists:$usedAlphas}
							letraUsada
						{else}
							letraNaoUsada
						{/if}" 
				href="{url searchInitial=$letter sort="title"}">
				{if $letter == $searchInitial}
					<strong>{$letter|escape}</strong>
				{else}
					{$letter|escape}
				{/if}
			</a> 
		{/foreach}
		<a href="{url}">
			{if $searchInitial==''}
				<strong>{translate key="common.all"}</strong>
			{else}
				{translate key="common.all"}
			{/if}
		</a>
	</p>
	{* modified *}
	
	<div class="journals">
		<h2>
			{translate key="context.contexts"}
		</h2>
		{if !$journals|@count}
			{translate key="site.noJournals"}
		{else}
			<ul>
				{foreach from=$journals item=journal}
					{capture assign="url"}{url journal=$journal->getPath()}{/capture}
					{assign var="thumb" value=$journal->getLocalizedData('journalThumbnail')}
					{assign var="description" value=$journal->getLocalizedDescription()}
					<li{if $thumb} class="has_thumb"{/if}>
						{if $thumb}
							<div class="thumb">
								<a href="{$url|escape}">
									<img src="{$journalFilesPath}{$journal->getId()}/{$thumb.uploadName|escape:"url"}"{if $thumb.altText} alt="{$thumb.altText|escape|default:''}"{/if}>
								</a>
							</div>
						{/if}

						<div class="body">
							<h3>
								<a href="{$url|escape}" rel="bookmark">
									{$journal->getLocalizedName()}
								</a>
							</h3>
							{if $description}
								<div class="description">
									{$description}
								</div>
							{/if}
							<ul class="links">
								<li class="view">
									<a href="{$url|escape}">
										{translate key="site.journalView"}
									</a>
								</li>
								<li class="current">
									<a href="{url|escape journal=$journal->getPath() page="issue" op="current"}">
										{translate key="site.journalCurrent"}
									</a>
								</li>
							</ul>
						</div>
					</li>
				{/foreach}
			</ul>
		{/if}
	</div>

</div><!-- .page -->

{include file="frontend/components/footer.tpl"}

Any help will be very welcome!

Thanks!

3 Likes