Skip to content

Commit

Permalink
Merge pull request #5 from VSEphpbb/update-b3
Browse files Browse the repository at this point in the history
Prep beta 3 release
  • Loading branch information
iMattPro committed Feb 19, 2015
2 parents 0016404 + 3531bde commit 6fc7f4d
Show file tree
Hide file tree
Showing 10 changed files with 272 additions and 79 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ env:
- EPV="1" # Should we run EPV (Extension Pre Validator) on your code?
- PHPBB_BRANCH="3.1.x"

#branches:
# only:
# - master
# - develop
# - /^develop-.*$/
branches:
only:
- master
- develop
- /^develop-.*$/

install:
- composer install --dev --no-interaction --prefer-source
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This extension adds the [Lightbox 2](http://lokeshdhakar.com/projects/lightbox2/
[![Build Status](https://travis-ci.org/VSEphpbb/lightbox.png)](https://travis-ci.org/VSEphpbb/lightbox)

## Requirements
* phpBB 3.1.0-RC2 or higher
* phpBB 3.1.0 or higher
* PHP 5.3.3 or higher

Note: This extension is in development. Installation is only recommended for testing purposes and is not supported on live boards. This extension will be officially released following phpBB 3.1.0.
Expand All @@ -17,10 +17,9 @@ Note: This extension is in development. Installation is only recommended for tes
4. Find Lightbox under "Disabled Extensions" and click `Enable`.

## Usage
1. Navigate in the ACP to `Attachment settings`.
2. Set `Create thumbnail` to `Yes`.
3. Set the `Maximum thumbnail width in pixel` to your desired resize width.
4. Click `Submit`.
1. Navigate in the ACP to `Board features -> Lightbox settings`.
2. Set the `Maximum image width in pixel` to your desired resize width.
3. Click `Submit`.

## Uninstallation
1. Navigate in the ACP to `Customise -> Manage extensions`.
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "phpbb-extension",
"description": "Lightbox for phpBB 3.1 will resize posted images to a maximum set width and display them fullscreen in an elegant Lightbox overlay effect.",
"homepage": "https://github.com/VSEphpbb/lightbox",
"version": "1.0.0-b2",
"version": "1.0.0-b3",
"keywords": ["phpbb", "extension", "lightbox", "image", "resizer"],
"license": "GPL-2.0",
"authors": [
Expand All @@ -23,7 +23,7 @@
"extra": {
"display-name": "Lightbox",
"soft-require": {
"phpbb/phpbb": ">=3.1.0-RC2,<3.2.*@dev"
"phpbb/phpbb": ">=3.1.0,<3.2.*@dev"
},
"version-check": {
"host": "vsephpbb.github.io",
Expand Down
1 change: 1 addition & 0 deletions config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ services:
arguments:
- @config
- @template
- @user
tags:
- { name: event.listener }
97 changes: 65 additions & 32 deletions event/listener.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?php
/**
*
* Lightbox extension for the phpBB Forum Software package.
*
* @copyright (c) 2014 Matt Friedman
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
*
* Lightbox extension for the phpBB Forum Software package.
*
* @copyright (c) 2014 Matt Friedman
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

namespace vse\lightbox\event;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* Event listener
*/
* Event listener
*/
class listener implements EventSubscriberInterface
{
/** @var \phpbb\config\config */
Expand All @@ -23,45 +23,78 @@ class listener implements EventSubscriberInterface
/** @var \phpbb\template\template */
protected $template;

/** @var \phpbb\user */
protected $user;

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

/**
* Assign functions defined in this class to event listeners in the core
*
* @return array
* @static
* @access public
*/
* Assign functions defined in this class to event listeners in the core
*
* @return array
* @static
* @access public
*/
static public function getSubscribedEvents()
{
return array(
'core.page_header' => 'lightbox_setup',
'core.page_header' => 'set_lightbox_tpl_data',
'core.acp_board_config_edit_add' => 'add_lightbox_acp_config',
);
}

/**
* Setup Lightbox settings
*
* @param object $event The event object
* @return null
* @access public
*/
public function lightbox_setup($event)
* Set Lightbox template data
*
* @return null
* @access public
*/
public function set_lightbox_tpl_data()
{
$this->template->assign_vars(array(
'S_LIGHTBOX_RESIZE' => $this->config['img_create_thumbnail'],
'LIGHTBOX_RESIZE_WIDTH' => $this->config['img_max_thumb_width'] ?: 0,
'LIGHTBOX_RESIZE_WIDTH' => (int) $this->config['lightbox_max_width'],
'S_LIGHTBOX_GALLERY' => (int) $this->config['lightbox_gallery'],
'S_LIGHTBOX_SIGNATURES' => (int) $this->config['lightbox_signatures'],
));
}

/**
* Add Lightbox settings to the ACP
*
* @param object $event The event object
* @return null
* @access public
*/
public function add_lightbox_acp_config($event)
{
if ($event['mode'] == 'features' && isset($event['display_vars']['vars']['legend2']))
{
$this->user->add_lang_ext('vse/lightbox', 'lightbox');
$display_vars = $event['display_vars'];

$my_config_vars = array(
'legend_lightbox' => 'LIGHTBOX_SETTINGS',
'lightbox_max_width' => array('lang' => 'LIGHTBOX_MAX_WIDTH', 'validate' => 'int:0:99999', 'type' => 'number:0:99999', 'explain' => true, 'append' => ' ' . $this->user->lang('PIXEL')),
'lightbox_gallery' => array('lang' => 'LIGHTBOX_GALLERY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'lightbox_signatures' => array('lang' => 'LIGHTBOX_SIGNATURES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
);

$display_vars['vars'] = phpbb_insert_config_array($display_vars['vars'], $my_config_vars, array('before' => 'legend2'));

$event['display_vars'] = $display_vars;
}
}
}
32 changes: 32 additions & 0 deletions language/en/lightbox.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
*
* Lightbox extension for the phpBB Forum Software package.
*
* @copyright (c) 2015 Matt Friedman
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}

if (empty($lang) || !is_array($lang))
{
$lang = array();
}

$lang = array_merge($lang, array(
'LIGHTBOX_SETTINGS' => 'Lightbox settings',
'LIGHTBOX_MAX_WIDTH' => 'Maximum image width in pixel',
'LIGHTBOX_MAX_WIDTH_EXPLAIN' => 'Images that exceed this width will be resized and can be enlarged using the Lightbox effect. Set this value to 0 to disable image resizing.',
'LIGHTBOX_GALLERY' => 'Allow gallery mode',
'LIGHTBOX_GALLERY_EXPLAIN' => 'Allows easy navigation between all resized images on the page using the Lightbox effect.',
'LIGHTBOX_SIGNATURES' => 'Resize signature images',
'LIGHTBOX_SIGNATURES_EXPLAIN' => 'Allow images used in signatures to be resized.',
));
33 changes: 33 additions & 0 deletions migrations/m1_add_configs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
*
* Lightbox extension for the phpBB Forum Software package.
*
* @copyright (c) 2015 Matt Friedman
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

namespace vse\lightbox\migrations;

class m1_add_configs extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
return isset($this->config['lightbox_max_width']);
}

static public function depends_on()
{
return array('\phpbb\db\migration\data\v310\gold');
}

public function update_data()
{
return array(
array('config.add', array('lightbox_max_width', 0)),
array('config.add', array('lightbox_gallery', 0)),
array('config.add', array('lightbox_signatures', 0)),
);
}
}
11 changes: 7 additions & 4 deletions styles/all/template/event/overall_footer_after.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{% if S_LIGHTBOX_RESIZE %}
{% if LIGHTBOX_RESIZE_WIDTH %}

<!-- IF not $INCLUDED_LIGHTBOXJS -->
<!-- INCLUDEJS @vse_lightbox/lightbox/js/lightbox.min.js -->
<!-- DEFINE $INCLUDED_LIGHTBOXJS = true -->
<!-- ENDIF -->

{% set LIGHTBOX_GALLERY = 'false' %}

<script>

(function($) { // Avoid conflicts with other libraries
Expand Down Expand Up @@ -36,6 +34,11 @@
galleryName = 'post-gallery',
imagesIndex = 0,
mobileWidth = 900;
{% if not S_LIGHTBOX_SIGNATURES %}
targetImage = targetImage.not(function() {
return $(this).closest('.signature').length > 0;
});
{% endif %}
if (resizeWidth > 0 && $(window).width() > mobileWidth) {
targetImage.css('max-width', resizeWidth + 'px');
} else {
Expand All @@ -46,7 +49,7 @@
setTimeout(function() {
targetImage.one('load', function() {
if ($(this).closest('.postlink').length > 0) return;
imagesIndex = ({{ LIGHTBOX_GALLERY }}) ? '' : imagesIndex + 1;
imagesIndex = ({{ S_LIGHTBOX_GALLERY }}) ? '' : imagesIndex + 1;
if ($(this).parent('a').length > 0) {
$(this).parent('a').attr({
'data-lightbox': galleryName + imagesIndex,
Expand Down
2 changes: 1 addition & 1 deletion styles/all/template/event/overall_header_head_append.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{% if S_LIGHTBOX_RESIZE %}
{% if LIGHTBOX_RESIZE_WIDTH %}
<!-- INCLUDECSS @vse_lightbox/../template/lightbox/css/lightbox.css -->
{% endif %}
Loading

0 comments on commit 6fc7f4d

Please sign in to comment.