Skip to content
Snippets Groups Projects
Commit d332418d authored by Robert Lange's avatar Robert Lange
Browse files

refs #21064 [fid] View Helper: fix codestyles

* with minimal changes in GetIt ViewHelper - will be refactored later
parent ea4df2a7
No related merge requests found
...@@ -38,8 +38,6 @@ use Interop\Container\ContainerInterface; ...@@ -38,8 +38,6 @@ use Interop\Container\ContainerInterface;
* @author Demian Katz <demian.katz@villanova.edu> * @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki * @link https://vufind.org/wiki/development Wiki
*
* @codeCoverageIgnore
*/ */
class Factory class Factory
{ {
......
...@@ -46,19 +46,13 @@ class GetIt extends AbstractHelper ...@@ -46,19 +46,13 @@ class GetIt extends AbstractHelper
{ {
use TranslatorAwareTrait; use TranslatorAwareTrait;
/** /* @var \Zend\Config\Config */
* @var \Zend\Config\Config
*/
protected $config; protected $config;
/** /* @var AbstractBase */
* @var AbstractBase
*/
protected $driver; protected $driver;
/** /* @var array list of available source ID definitions from config */
* @var array list of available source ID definitions from config
*/
protected $sids = [ protected $sids = [
'source_idsV1', 'source_idsV1',
'source_idsV3', 'source_idsV3',
...@@ -165,7 +159,7 @@ class GetIt extends AbstractHelper ...@@ -165,7 +159,7 @@ class GetIt extends AbstractHelper
protected $accordeonColorDefault; protected $accordeonColorDefault;
/** /**
* second color of the accordeon * Second color of the accordeon
* *
* @var * @var
*/ */
...@@ -179,7 +173,7 @@ class GetIt extends AbstractHelper ...@@ -179,7 +173,7 @@ class GetIt extends AbstractHelper
protected $accordeonHeadlineDefault; protected $accordeonHeadlineDefault;
/** /**
* second headline text of the get it box * Second headline text of the get it box
* *
* @var * @var
*/ */
...@@ -188,7 +182,9 @@ class GetIt extends AbstractHelper ...@@ -188,7 +182,9 @@ class GetIt extends AbstractHelper
/** /**
* GetIt constructor. * GetIt constructor.
* *
* @param Config $getItConfig Get It box Configuration * @param $getItConfig Config
* @param $fidClient FIDIS Client
* @param $permissionManager Permission Manager
*/ */
public function __construct($getItConfig, $fidClient, $permissionManager) public function __construct($getItConfig, $fidClient, $permissionManager)
{ {
...@@ -200,7 +196,9 @@ class GetIt extends AbstractHelper ...@@ -200,7 +196,9 @@ class GetIt extends AbstractHelper
/** /**
* Get Solr field data * Get Solr field data
* *
* @param $driver * @param $driver Record Driver
*
* @return GetIt GetIt View Helper
*/ */
public function __invoke($driver) public function __invoke($driver)
{ {
...@@ -224,6 +222,13 @@ class GetIt extends AbstractHelper ...@@ -224,6 +222,13 @@ class GetIt extends AbstractHelper
return $this; return $this;
} }
/**
* Check if User is authorized
*
* @param $permission Permission
*
* @return bool
*/
protected function hasPermission($permission) protected function hasPermission($permission)
{ {
return $this->permissionManager->isAuthorized($permission); return $this->permissionManager->isAuthorized($permission);
...@@ -232,7 +237,7 @@ class GetIt extends AbstractHelper ...@@ -232,7 +237,7 @@ class GetIt extends AbstractHelper
/** /**
* Retrieve SIDs from config (getit.ini) * Retrieve SIDs from config (getit.ini)
* *
* @param $value * @param $value sid
* *
* @return array * @return array
*/ */
...@@ -245,7 +250,7 @@ class GetIt extends AbstractHelper ...@@ -245,7 +250,7 @@ class GetIt extends AbstractHelper
/** /**
* Retrieve NonSIDs from config (getit.ini) * Retrieve NonSIDs from config (getit.ini)
* *
* @param $value * @param $value sid
* *
* @return string * @return string
*/ */
...@@ -259,7 +264,7 @@ class GetIt extends AbstractHelper ...@@ -259,7 +264,7 @@ class GetIt extends AbstractHelper
* Read specific config of given record * Read specific config of given record
* Set default Values of getit box * Set default Values of getit box
* *
* @return array config of given record * @return array config of given record
*/ */
public function getConfig() public function getConfig()
{ {
...@@ -340,6 +345,8 @@ class GetIt extends AbstractHelper ...@@ -340,6 +345,8 @@ class GetIt extends AbstractHelper
* @param $hideNotice boolean hide notice * @param $hideNotice boolean hide notice
* @param $isAiSidRecord boolean is given record an ai record * @param $isAiSidRecord boolean is given record an ai record
* @param $noticeLinkType string type of link * @param $noticeLinkType string type of link
*
* @return void
*/ */
public function get_config_source_idsV1( public function get_config_source_idsV1(
&$accordeonColor, &$accordeonColor,
...@@ -379,6 +386,8 @@ class GetIt extends AbstractHelper ...@@ -379,6 +386,8 @@ class GetIt extends AbstractHelper
* @param $hideNotice boolean hide notice * @param $hideNotice boolean hide notice
* @param $isAiSidRecord boolean is given record an ai record * @param $isAiSidRecord boolean is given record an ai record
* @param $noticeLinkType string type of link * @param $noticeLinkType string type of link
*
* @return void
*/ */
public function get_config_source_idsV3( public function get_config_source_idsV3(
&$accordeonColor, &$accordeonColor,
...@@ -397,7 +406,8 @@ class GetIt extends AbstractHelper ...@@ -397,7 +406,8 @@ class GetIt extends AbstractHelper
) { ) {
$accordeonColor = $this->accordeonColorAlternative; $accordeonColor = $this->accordeonColorAlternative;
$accordeonHeadline = $this->accordeonHeadlineAlternative; $accordeonHeadline = $this->accordeonHeadlineAlternative;
$boxHeadline = $this->fidClient->isLoggedOn() ? $this->translate('Get it') : $this->translate('getit_logged_not'); $boxHeadline = $this->fidClient->isLoggedOn() ?
$this->translate('Get it') : $this->translate('getit_logged_not');
$notice = ''; $notice = '';
$isAiSidRecord = true; $isAiSidRecord = true;
$showArticleButton = $this->config->Permission->allowSubitoArticleCopy ?? true; $showArticleButton = $this->config->Permission->allowSubitoArticleCopy ?? true;
...@@ -421,6 +431,8 @@ class GetIt extends AbstractHelper ...@@ -421,6 +431,8 @@ class GetIt extends AbstractHelper
* @param $hideNotice boolean hide notice * @param $hideNotice boolean hide notice
* @param $isAiSidRecord boolean is given record an ai record * @param $isAiSidRecord boolean is given record an ai record
* @param $noticeLinkType string type of link * @param $noticeLinkType string type of link
*
* @return void
*/ */
public function get_config_source_idsV4( public function get_config_source_idsV4(
&$accordeonColor, &$accordeonColor,
...@@ -437,7 +449,8 @@ class GetIt extends AbstractHelper ...@@ -437,7 +449,8 @@ class GetIt extends AbstractHelper
&$isAiSidRecord, &$isAiSidRecord,
&$noticeLinkType &$noticeLinkType
) { ) {
$boxHeadline = $this->fidClient->isLoggedOn() ? $this->translate('Get it') : $this->translate('getit_logged_not'); $boxHeadline = $this->fidClient->isLoggedOn() ?
$this->translate('Get it') : $this->translate('getit_logged_not');
if ($this->fidClient->isLoggedOn()) { if ($this->fidClient->isLoggedOn()) {
$notice = $this->translate('getit_text_12'); $notice = $this->translate('getit_text_12');
} else { } else {
...@@ -465,6 +478,8 @@ class GetIt extends AbstractHelper ...@@ -465,6 +478,8 @@ class GetIt extends AbstractHelper
* @param $hideNotice boolean hide notice * @param $hideNotice boolean hide notice
* @param $isAiSidRecord boolean is given record an ai record * @param $isAiSidRecord boolean is given record an ai record
* @param $noticeLinkType string type of link * @param $noticeLinkType string type of link
*
* @return void
*/ */
public function get_config_source_idsV5( public function get_config_source_idsV5(
&$accordeonColor, &$accordeonColor,
...@@ -499,7 +514,8 @@ class GetIt extends AbstractHelper ...@@ -499,7 +514,8 @@ class GetIt extends AbstractHelper
$notice = $this->translate('getit_text_3_1'); $notice = $this->translate('getit_text_3_1');
$noticeLinkType = "register"; $noticeLinkType = "register";
} }
$boxHeadline = $this->fidClient->isLoggedOn() ? $this->translate('Get it') : $this->translate('getit_logged_not'); $boxHeadline = $this->fidClient->isLoggedOn() ?
$this->translate('Get it') : $this->translate('getit_logged_not');
$showLinks = $this->fidClient->isLoggedOn() && $hasEBookAccess; $showLinks = $this->fidClient->isLoggedOn() && $hasEBookAccess;
} }
...@@ -521,6 +537,8 @@ class GetIt extends AbstractHelper ...@@ -521,6 +537,8 @@ class GetIt extends AbstractHelper
* @param $hideNotice boolean hide notice * @param $hideNotice boolean hide notice
* @param $isAiSidRecord boolean is given record an ai record * @param $isAiSidRecord boolean is given record an ai record
* @param $noticeLinkType string type of link * @param $noticeLinkType string type of link
*
* @return void
*/ */
public function get_config_source_idsV6( public function get_config_source_idsV6(
&$accordeonColor, &$accordeonColor,
...@@ -558,6 +576,8 @@ class GetIt extends AbstractHelper ...@@ -558,6 +576,8 @@ class GetIt extends AbstractHelper
* @param $hideNotice boolean hide notice * @param $hideNotice boolean hide notice
* @param $isAiSidRecord boolean is given record an ai record * @param $isAiSidRecord boolean is given record an ai record
* @param $noticeLinkType string type of link * @param $noticeLinkType string type of link
*
* @return void
*/ */
public function get_config_source_idsV7( public function get_config_source_idsV7(
&$accordeonColor, &$accordeonColor,
...@@ -597,6 +617,8 @@ class GetIt extends AbstractHelper ...@@ -597,6 +617,8 @@ class GetIt extends AbstractHelper
* @param $hideNotice boolean hide notice * @param $hideNotice boolean hide notice
* @param $isAiSidRecord boolean is given record an ai record * @param $isAiSidRecord boolean is given record an ai record
* @param $noticeLinkType string type of link * @param $noticeLinkType string type of link
*
* @return void
*/ */
public function get_config_source_idsV8( public function get_config_source_idsV8(
&$accordeonColor, &$accordeonColor,
...@@ -785,6 +807,8 @@ class GetIt extends AbstractHelper ...@@ -785,6 +807,8 @@ class GetIt extends AbstractHelper
* @param $hideNotice boolean hide notice * @param $hideNotice boolean hide notice
* @param $isAiSidRecord boolean is given record an ai record * @param $isAiSidRecord boolean is given record an ai record
* @param $noticeLinkType string type of link * @param $noticeLinkType string type of link
*
* @return void
*/ */
public function get_config_source_idsV9( public function get_config_source_idsV9(
&$accordeonColor, &$accordeonColor,
...@@ -854,6 +878,8 @@ class GetIt extends AbstractHelper ...@@ -854,6 +878,8 @@ class GetIt extends AbstractHelper
* @param $hideNotice boolean hide notice * @param $hideNotice boolean hide notice
* @param $isAiSidRecord boolean is given record an ai record * @param $isAiSidRecord boolean is given record an ai record
* @param $noticeLinkType string type of link * @param $noticeLinkType string type of link
*
* @return void
*/ */
public function get_config_source_idsV10( public function get_config_source_idsV10(
&$accordeonColor, &$accordeonColor,
...@@ -893,6 +919,8 @@ class GetIt extends AbstractHelper ...@@ -893,6 +919,8 @@ class GetIt extends AbstractHelper
* @param $hideNotice boolean hide notice * @param $hideNotice boolean hide notice
* @param $isAiSidRecord boolean is given record an ai record * @param $isAiSidRecord boolean is given record an ai record
* @param $noticeLinkType string type of link * @param $noticeLinkType string type of link
*
* @return void
*/ */
public function get_config_source_idsV11( public function get_config_source_idsV11(
&$accordeonColor, &$accordeonColor,
......
...@@ -19,18 +19,28 @@ ...@@ -19,18 +19,28 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category VuFind FID * @category VuFind
* @package View_Helpers * @package View_Helpers
* @author Alexander Purr <purr@ub.uni-leipzig.de> * @author Alexander Purr <purr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/ */
namespace fid\View\Helper\Root; namespace fid\View\Helper\Root;
use finc\View\Helper\Root\RecordDataFormatterFactory as FincRecordDataFormatterFactory; use finc\View\Helper\Root\RecordDataFormatterFactory as Base;
use VuFind\View\Helper\Root\RecordDataFormatter; use VuFind\View\Helper\Root\RecordDataFormatter;
use VuFind\View\Helper\Root\RecordDataFormatter\SpecBuilder; use VuFind\View\Helper\Root\RecordDataFormatter\SpecBuilder;
class RecordDataFormatterFactory extends FincRecordDataFormatterFactory /**
* Record Data Formatter Factory for Record view
*
* @category VuFind
* @package View_Helpers
* @author Alexander Purr <purr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
class RecordDataFormatterFactory extends Base
{ {
/** /**
* Create the helper. * Create the helper.
......
...@@ -49,11 +49,17 @@ class UserGroups extends AbstractHelper ...@@ -49,11 +49,17 @@ class UserGroups extends AbstractHelper
protected $displayOrder; protected $displayOrder;
private $groups; private $_groups;
/**
* UserGroups constructor.
*
* @param $fidConfig fid.ini
*/
public function __construct($fidConfig) public function __construct($fidConfig)
{ {
$this->displayRoles = $fidConfig->UserProfile['role_display']->toArray() ?? []; $this->displayRoles = $fidConfig->UserProfile['role_display']
->toArray() ?? [];
foreach ($fidConfig->UserProfile['role_display_priority'] ?? [] as $prios) { foreach ($fidConfig->UserProfile['role_display_priority'] ?? [] as $prios) {
$roles = explode('>', $prios); $roles = explode('>', $prios);
while (count($roles) > 1) { while (count($roles) > 1) {
...@@ -63,22 +69,33 @@ class UserGroups extends AbstractHelper ...@@ -63,22 +69,33 @@ class UserGroups extends AbstractHelper
} }
} }
} }
$this->displayOrder = explode('>', $fidConfig->UserProfile['role_display_order'] ?? ''); $this->displayOrder = explode(
'>',
$fidConfig->UserProfile['role_display_order'] ?? ''
);
} }
/**
* Invoke UserGroups
*
* @param $permissions Permissions
*
* @return $this
*/
public function __invoke($permissions) public function __invoke($permissions)
{ {
$this->groups['requested'] = $this->_groups['requested']
$this->groups['granted'] = array_fill_keys($this->displayOrder, null); = $this->_groups['granted']
= array_fill_keys($this->displayOrder, null);
foreach ($permissions as $permission => $status) { foreach ($permissions as $permission => $status) {
// $status is in ['granted','requested'] // $status is in ['granted','requested']
if (in_array($permission, $this->displayRoles)) { if (in_array($permission, $this->displayRoles)) {
$this->groups[$status][$permission] = $this->_groups[$status][$permission]
$this->translate('fid::label_access_level_' . $permission); = $this->translate('fid::label_access_level_' . $permission);
} }
} }
foreach (['granted','requested'] as $status) { foreach (['granted','requested'] as $status) {
$groups = array_filter($this->groups[$status]); $groups = array_filter($this->_groups[$status]);
foreach ((array)$this->rolePriority as $role => $prioritized) { foreach ((array)$this->rolePriority as $role => $prioritized) {
if (isset($groups[$role])) { if (isset($groups[$role])) {
foreach ($prioritized as $prio) { foreach ($prioritized as $prio) {
...@@ -89,18 +106,29 @@ class UserGroups extends AbstractHelper ...@@ -89,18 +106,29 @@ class UserGroups extends AbstractHelper
} }
} }
} }
$this->groups[$status] = $groups; $this->_groups[$status] = $groups;
} }
return $this; return $this;
} }
/**
* Get granted user groups
*
* @return string|null
*/
public function granted() public function granted()
{ {
return !empty($this->groups['granted']) ? implode("; ", $this->groups['granted']) : null; return !empty($this->_groups['granted']) ?
implode("; ", $this->_groups['granted']) : null;
} }
/**
* Get user groups, which are requested for access
*
* @return string|null
*/
public function requested() public function requested()
{ {
return !empty($this->groups['requested']) ? implode('; ', $this->groups['requested']) : null; return !empty($this->_groups['requested']) ? implode('; ', $this->_groups['requested']) : null;
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment