Skip to content

Commit

Permalink
Use $phpEx
Browse files Browse the repository at this point in the history
  • Loading branch information
iMattPro committed Oct 16, 2017
1 parent 9e53d99 commit 2e14b03
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
1 change: 1 addition & 0 deletions config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ services:
- '@config'
- '@template'
- '@user'
- '%core.php_ext%'
tags:
- { name: event.listener }
14 changes: 10 additions & 4 deletions event/listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,24 @@ class listener implements EventSubscriberInterface
/** @var \phpbb\user */
protected $user;

/** @var string PHP file extension */
protected $php_ext;

/**
* Constructor
*
* @param \phpbb\config\config $config Config object
* @param \phpbb\template\template $template Template object
* @param \phpbb\user $user User object
* @param \phpbb\config\config $config Config object
* @param \phpbb\template\template $template Template object
* @param \phpbb\user $user User object
* @param string $php_ext
* @access public
*/
public function __construct(\phpbb\config\config $config, \phpbb\template\template $template, \phpbb\user $user)
public function __construct(\phpbb\config\config $config, \phpbb\template\template $template, \phpbb\user $user, $php_ext)
{
$this->config = $config;
$this->template = $template;
$this->user = $user;
$this->php_ext = $php_ext;
}

/**
Expand Down Expand Up @@ -69,6 +74,7 @@ public function set_lightbox_tpl_data()
'S_LIGHTBOX_GALLERY' => (int) $this->config['lightbox_gallery'],
'S_LIGHTBOX_SIGNATURES' => (int) $this->config['lightbox_signatures'],
'S_LIGHTBOX_IMG_TITLES' => (int) $this->config['lightbox_img_titles'],
'PHP_EXTENSION' => $this->php_ext,
));
}

Expand Down
1 change: 1 addition & 0 deletions styles/all/template/event/overall_footer_after.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
vseLightbox.lightboxGal = {{ S_LIGHTBOX_GALLERY }};
vseLightbox.lightboxSig = {{ S_LIGHTBOX_SIGNATURES }};
vseLightbox.imageTitles = {{ S_LIGHTBOX_IMG_TITLES }};
vseLightbox.downloadFile = 'download/file.{{ PHP_EXTENSION|escape("js") }}';
</script>
{% endif %}
2 changes: 1 addition & 1 deletion styles/all/template/js/resizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
return $('<a/>').attr({
href: url,
'data-lightbox': galleryName + galIndex,
'data-title': (vseLightbox.imageTitles) ? ((url.indexOf('download/file.php') !== -1) ? $(this).attr('alt') : url.split('/').pop()) : ''
'data-title': (vseLightbox.imageTitles) ? ((url.indexOf(vseLightbox.downloadFile) !== -1) ? $(this).attr('alt') : url.split('/').pop()) : ''
});
}).borderHover();
}
Expand Down
16 changes: 15 additions & 1 deletion tests/event/listener_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class listener_test extends \phpbb_test_case
/** @var \phpbb\user|\PHPUnit_Framework_MockObject_MockObject */
protected $user;

/** @var string PHP file extension */
protected $php_ext;

public function setUp()
{
parent::setUp();
Expand All @@ -39,14 +42,16 @@ public function setUp()
));
$this->template = $this->getMockBuilder('\phpbb\template\template')
->getMock();
$this->php_ext = $phpEx;
}

protected function set_listener()
{
$this->listener = new \vse\lightbox\event\listener(
$this->config,
$this->template,
$this->user
$this->user,
$this->php_ext
);
}

Expand Down Expand Up @@ -77,54 +82,63 @@ public function set_lightbox_tpl_data_test_data()
'S_LIGHTBOX_GALLERY' => 2,
'S_LIGHTBOX_SIGNATURES' => 1,
'S_LIGHTBOX_IMG_TITLES' => 1,
'PHP_EXTENSION' => 'php',
)),
array(400, 1, 1, 1, array(
'LIGHTBOX_RESIZE_WIDTH' => 400,
'S_LIGHTBOX_GALLERY' => 1,
'S_LIGHTBOX_SIGNATURES' => 1,
'S_LIGHTBOX_IMG_TITLES' => 1,
'PHP_EXTENSION' => 'php',
)),
array(400, 0, 1, 1, array(
'LIGHTBOX_RESIZE_WIDTH' => 400,
'S_LIGHTBOX_GALLERY' => 0,
'S_LIGHTBOX_SIGNATURES' => 1,
'S_LIGHTBOX_IMG_TITLES' => 1,
'PHP_EXTENSION' => 'php',
)),
array(0, 1, 1, 1, array(
'LIGHTBOX_RESIZE_WIDTH' => 0,
'S_LIGHTBOX_GALLERY' => 1,
'S_LIGHTBOX_SIGNATURES' => 1,
'S_LIGHTBOX_IMG_TITLES' => 1,
'PHP_EXTENSION' => 'php',
)),
array(0, 0, 0, 0, array(
'LIGHTBOX_RESIZE_WIDTH' => 0,
'S_LIGHTBOX_GALLERY' => 0,
'S_LIGHTBOX_SIGNATURES' => 0,
'S_LIGHTBOX_IMG_TITLES' => 0,
'PHP_EXTENSION' => 'php',
)),
array(null, null, null, null, array(
'LIGHTBOX_RESIZE_WIDTH' => 0,
'S_LIGHTBOX_GALLERY' => 0,
'S_LIGHTBOX_SIGNATURES' => 0,
'S_LIGHTBOX_IMG_TITLES' => 0,
'PHP_EXTENSION' => 'php',
)),
array(400, null, null, null, array(
'LIGHTBOX_RESIZE_WIDTH' => 400,
'S_LIGHTBOX_GALLERY' => 0,
'S_LIGHTBOX_SIGNATURES' => 0,
'S_LIGHTBOX_IMG_TITLES' => 0,
'PHP_EXTENSION' => 'php',
)),
array(null, 1, 0, 1, array(
'LIGHTBOX_RESIZE_WIDTH' => 0,
'S_LIGHTBOX_GALLERY' => 1,
'S_LIGHTBOX_SIGNATURES' => 0,
'S_LIGHTBOX_IMG_TITLES' => 1,
'PHP_EXTENSION' => 'php',
)),
array(null, 1, 0, 0, array(
'LIGHTBOX_RESIZE_WIDTH' => 0,
'S_LIGHTBOX_GALLERY' => 1,
'S_LIGHTBOX_SIGNATURES' => 0,
'S_LIGHTBOX_IMG_TITLES' => 0,
'PHP_EXTENSION' => 'php',
)),
);
}
Expand Down

0 comments on commit 2e14b03

Please sign in to comment.