Skip to content

Commit

Permalink
Merge pull request #184 from iMattPro/updates
Browse files Browse the repository at this point in the history
Twig macro for ad template
  • Loading branch information
iMattPro authored Nov 18, 2024
2 parents 35b22e6 + ff0766b commit 919fd8f
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 61 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,14 @@ jobs:
db: "mcr.microsoft.com/mssql/server:2017-latest"
db_alias: 'MSSQL 2017'
- php: '7.2'
db: "mcr.microsoft.com/mssql/server:2019-latest"
db: "mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04"
db_alias: 'MSSQL 2019'

name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }}

services:
mssql:
image: ${{ matrix.db != 'mcr.microsoft.com/mssql/server:2017-latest' && matrix.db != 'mcr.microsoft.com/mssql/server:2019-latest' && 'mcr.microsoft.com/mssql/server:2017-latest' || matrix.db }}
image: ${{ matrix.db != 'mcr.microsoft.com/mssql/server:2017-latest' && matrix.db != 'mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04' && 'mcr.microsoft.com/mssql/server:2017-latest' || matrix.db }}
env:
SA_PASSWORD: "Pssw0rd_12"
ACCEPT_EULA: "y"
Expand Down Expand Up @@ -415,7 +415,7 @@ jobs:
env:
MATRIX_DB: ${{ matrix.db }}
run: |
if [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2017-latest' ] || [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2019-latest' ]
if [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2017-latest' ] || [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04' ]
then
db='mssql'
else
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This is the repository for the development of the Advertisement Management extension, a Google Summer of Code project developed by Jakub Senko for phpBB.

[![Build Status](https://github.com/phpbb-extensions/ad-management/workflows/Tests/badge.svg)](https://github.com/phpbb-extensions/ad-management/actions)
[![Build Status](https://github.com/phpbb-extensions/ad-management/actions/workflows/tests.yml/badge.svg)](https://github.com/phpbb-extensions/ad-management/actions)
[![codecov](https://codecov.io/gh/phpbb-extensions/ad-management/branch/master/graph/badge.svg?token=ezeD03g3Lt)](https://codecov.io/gh/phpbb-extensions/ad-management)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/phpbb-extensions/ad-management/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/phpbb-extensions/ad-management/?branch=master)

Expand Down
6 changes: 3 additions & 3 deletions adm/style/manage_ads.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ <h1>{% if S_ADD_AD %}{{ lang('ACP_ADS_ADD') }}{% else %}{{ lang('ACP_ADS_EDIT')
{% if PREVIEW %}
<fieldset>
<legend>{{ lang('PREVIEW') }}</legend>
{% set PHPBB_ADS_CODE, S_PHPBB_ADS_CENTER = PREVIEW, AD_CENTERING %}
{% include '@phpbb_ads/phpbb_ads_default.html' %}
{% import '@phpbb_ads/phpbb_ads_macro.html' as preview %}
{{ preview.renderAds(PREVIEW, 0, AD_CENTERING) }}
</fieldset>
{% endif %}

Expand Down Expand Up @@ -89,7 +89,7 @@ <h3>{{ lang('WARNING') }}</h3>
{% for location in loops.ad_locations %}
{% if location.CATEGORY_NAME %}
{% if not loop.first %}</optgroup>{% endif %}
<optgroup label="{{ location.CATEGORY_NAME }}">
<optgroup label="{{ location.CATEGORY_NAME }}" style="border:none;">
{% else %}
<option value="{{ location.LOCATION_ID }}"{% if location.S_SELECTED %} selected{% endif %} title="{{ location.LOCATION_DESC }}">{{ location.LOCATION_NAME }}</option>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"composer/installers": "~1.0"
},
"require-dev": {
"phing/phing": "2.4.*"
"phing/phing": "~2.4"
},
"extra": {
"display-name": "Advertisement Management",
Expand Down
5 changes: 2 additions & 3 deletions styles/all/template/event/memberlist_view_content_append.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{# begin ad location #}
{% set PHPBB_ADS_STYLE = 'margin: 10px 0;' %}
{% set PHPBB_ADS_CODE, PHPBB_ADS_ID, S_PHPBB_ADS_CENTER = AD_AFTER_PROFILE, AD_AFTER_PROFILE_ID, AD_AFTER_PROFILE_CENTER %}
{% include '@phpbb_ads/phpbb_ads_default.html' %}
{% import '@phpbb_ads/phpbb_ads_macro.html' as ad %}
{{ ad.renderAds(AD_AFTER_PROFILE, AD_AFTER_PROFILE_ID, AD_AFTER_PROFILE_CENTER) }}
{# end ad location #}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{# begin ad location #}
{% set PHPBB_ADS_STYLE = 'margin: 10px 0;' %}
{% set PHPBB_ADS_CODE, PHPBB_ADS_ID, S_PHPBB_ADS_CENTER = AD_BEFORE_PROFILE, AD_BEFORE_PROFILE_ID,AD_BEFORE_PROFILE_CENTER %}
{% include '@phpbb_ads/phpbb_ads_default.html' %}
{% import '@phpbb_ads/phpbb_ads_macro.html' as ad %}
{{ ad.renderAds(AD_BEFORE_PROFILE, AD_BEFORE_PROFILE_ID,AD_BEFORE_PROFILE_CENTER) }}
{# end ad location #}
5 changes: 2 additions & 3 deletions styles/all/template/event/overall_footer_after.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{# begin ad location #}
{% set PHPBB_ADS_STYLE = 'margin: 10px 0;' %}
{% set PHPBB_ADS_CODE, PHPBB_ADS_ID, S_PHPBB_ADS_CENTER = AD_BELOW_FOOTER, AD_BELOW_FOOTER_ID, AD_BELOW_FOOTER_CENTER %}
{% include '@phpbb_ads/phpbb_ads_default.html' %}
{% import '@phpbb_ads/phpbb_ads_macro.html' as ad %}
{{ ad.renderAds(AD_BELOW_FOOTER, AD_BELOW_FOOTER_ID, AD_BELOW_FOOTER_CENTER) }}
{# end ad location #}

{% include '@phpbb_ads/includes/ad_views.html' %}
Expand Down
4 changes: 0 additions & 4 deletions styles/all/template/event/overall_footer_body_after.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{% if AD_POP_UP and AD_POP_UP_ID %}
{% set PHPBB_ADS_STYLE = '' %}
{% set PHPBB_ADS_CODE, PHPBB_ADS_ID, S_PHPBB_ADS_CENTER = AD_POP_UP, AD_POP_UP_ID, AD_POP_UP_CENTER %}
{% include '@phpbb_ads/includes/phpbb_ads_pop_up.html' %}
{% endif %}

{% if AD_SLIDE_UP and AD_SLIDE_UP_ID %}
{% set PHPBB_ADS_STYLE = '' %}
{% set PHPBB_ADS_CODE, PHPBB_ADS_ID, S_PHPBB_ADS_CENTER = AD_SLIDE_UP, AD_SLIDE_UP_ID, AD_SLIDE_UP_CENTER %}
{% include '@phpbb_ads/includes/phpbb_ads_slide_up.html' %}
{% endif %}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% set PHPBB_ADS_STYLE = 'margin: 10px 0;' %}
{% set PHPBB_ADS_CODE, PHPBB_ADS_ID, S_PHPBB_ADS_CENTER = AD_AFTER_FOOTER_NAVBAR, AD_AFTER_FOOTER_NAVBAR_ID, AD_AFTER_FOOTER_NAVBAR_CENTER %}
{% include '@phpbb_ads/phpbb_ads_default.html' %}
{# begin ad location #}
{% import '@phpbb_ads/phpbb_ads_macro.html' as ad %}
{{ ad.renderAds(AD_AFTER_FOOTER_NAVBAR, AD_AFTER_FOOTER_NAVBAR_ID, AD_AFTER_FOOTER_NAVBAR_CENTER) }}
{# end ad location #}
5 changes: 2 additions & 3 deletions styles/all/template/event/overall_footer_page_body_after.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{# begin ad location #}
{# clear: both; is introduced because of jumpbox in user profile which is floating right #}
{% set PHPBB_ADS_STYLE = 'margin: 10px 0; clear: both;' %}
{% set PHPBB_ADS_CODE, PHPBB_ADS_ID, S_PHPBB_ADS_CENTER = AD_ABOVE_FOOTER, AD_ABOVE_FOOTER_ID, AD_ABOVE_FOOTER_CENTER %}
{% include '@phpbb_ads/phpbb_ads_default.html' %}
{% import '@phpbb_ads/phpbb_ads_macro.html' as ad %}
{{ ad.renderAds(AD_ABOVE_FOOTER, AD_ABOVE_FOOTER_ID, AD_ABOVE_FOOTER_CENTER, 'clear: both;') }}
{# end ad location #}
5 changes: 2 additions & 3 deletions styles/all/template/event/overall_header_body_before.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{# begin ad location #}
{% set PHPBB_ADS_STYLE = 'margin-bottom: 10px;' %}
{% set PHPBB_ADS_CODE, PHPBB_ADS_ID, S_PHPBB_ADS_CENTER = AD_ABOVE_HEADER, AD_ABOVE_HEADER_ID, AD_ABOVE_HEADER_CENTER %}
{% include '@phpbb_ads/phpbb_ads_default.html' %}
{% import '@phpbb_ads/phpbb_ads_macro.html' as ad %}
{{ ad.renderAds(AD_ABOVE_HEADER, AD_ABOVE_HEADER_ID, AD_ABOVE_HEADER_CENTER, 'margin: 0 0 10px 0;') }}
{# end ad location #}
5 changes: 2 additions & 3 deletions styles/all/template/event/overall_header_navbar_before.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{# begin ad location #}
{% set PHPBB_ADS_STYLE = 'margin: 10px 0;' %}
{% set PHPBB_ADS_CODE, PHPBB_ADS_ID, S_PHPBB_ADS_CENTER = AD_BELOW_HEADER, AD_BELOW_HEADER_ID, AD_BELOW_HEADER_CENTER %}
{% include '@phpbb_ads/phpbb_ads_default.html' %}
{% import '@phpbb_ads/phpbb_ads_macro.html' as ad %}
{{ ad.renderAds(AD_BELOW_HEADER, AD_BELOW_HEADER_ID, AD_BELOW_HEADER_CENTER) }}
{# end ad location #}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% set PHPBB_ADS_STYLE = 'margin: 10px 0;' %}
{% set PHPBB_ADS_CODE, PHPBB_ADS_ID, S_PHPBB_ADS_CENTER = AD_AFTER_HEADER_NAVBAR, AD_AFTER_HEADER_NAVBAR_ID, AD_AFTER_HEADER_NAVBAR_CENTER %}
{% include '@phpbb_ads/phpbb_ads_default.html' %}
{# begin ad location #}
{% import '@phpbb_ads/phpbb_ads_macro.html' as ad %}
{{ ad.renderAds(AD_AFTER_HEADER_NAVBAR, AD_AFTER_HEADER_NAVBAR_ID, AD_AFTER_HEADER_NAVBAR_CENTER) }}
{# end ad location #}
5 changes: 2 additions & 3 deletions styles/all/template/event/quickreply_editor_panel_after.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{# begin ad location #}
{% set PHPBB_ADS_STYLE = 'margin: 10px 0;' %}
{% set PHPBB_ADS_CODE, PHPBB_ADS_ID, S_PHPBB_ADS_CENTER = AD_AFTER_QUICKREPLY, AD_AFTER_QUICKREPLY_ID, AD_AFTER_QUICKREPLY_CENTER %}
{% include '@phpbb_ads/phpbb_ads_default.html' %}
{% import '@phpbb_ads/phpbb_ads_macro.html' as ad %}
{{ ad.renderAds(AD_AFTER_QUICKREPLY, AD_AFTER_QUICKREPLY_ID, AD_AFTER_QUICKREPLY_CENTER) }}
{# end ad location #}
5 changes: 2 additions & 3 deletions styles/all/template/event/quickreply_editor_panel_before.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{# begin ad location #}
{% set PHPBB_ADS_STYLE = 'margin: 10px 0;' %}
{% set PHPBB_ADS_CODE, PHPBB_ADS_ID, S_PHPBB_ADS_CENTER = AD_BEFORE_QUICKREPLY, AD_BEFORE_QUICKREPLY_ID, AD_BEFORE_QUICKREPLY_CENTER %}
{% include '@phpbb_ads/phpbb_ads_default.html' %}
{% import '@phpbb_ads/phpbb_ads_macro.html' as ad %}
{{ ad.renderAds(AD_BEFORE_QUICKREPLY, AD_BEFORE_QUICKREPLY_ID, AD_BEFORE_QUICKREPLY_CENTER) }}
{# end ad location #}
5 changes: 2 additions & 3 deletions styles/all/template/event/viewtopic_body_poll_after.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{# begin ad location #}
{% set PHPBB_ADS_STYLE = 'margin: 10px 0;' %}
{% set PHPBB_ADS_CODE, PHPBB_ADS_ID, S_PHPBB_ADS_CENTER = AD_BEFORE_POSTS, AD_BEFORE_POSTS_ID, AD_BEFORE_POSTS_CENTER %}
{% include '@phpbb_ads/phpbb_ads_default.html' %}
{% import '@phpbb_ads/phpbb_ads_macro.html' as ad %}
{{ ad.renderAds(AD_BEFORE_POSTS, AD_BEFORE_POSTS_ID, AD_BEFORE_POSTS_CENTER) }}
{# end ad location #}
12 changes: 6 additions & 6 deletions styles/all/template/event/viewtopic_body_postrow_post_after.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{# begin ad location #}
{% if loops.postrow|length > 1 and postrow.S_FIRST_ROW %}
{% set PHPBB_ADS_STYLE = 'margin: 10px 0;' %}
{% set PHPBB_ADS_CODE, PHPBB_ADS_ID, S_PHPBB_ADS_CENTER = AD_AFTER_FIRST_POST, AD_AFTER_FIRST_POST_ID, AD_AFTER_FIRST_POST_CENTER %}
{% include '@phpbb_ads/phpbb_ads_default.html' %}
{% import '@phpbb_ads/phpbb_ads_macro.html' as ad %}
{{ ad.renderAds(AD_AFTER_FIRST_POST, AD_AFTER_FIRST_POST_ID, AD_AFTER_FIRST_POST_CENTER) }}
{% endif %}
{# end ad location #}

{# begin ad location #}
{% if not postrow.S_FIRST_ROW %}
{% set PHPBB_ADS_STYLE = 'margin: 10px 0;' %}
{% set PHPBB_ADS_CODE, PHPBB_ADS_ID, S_PHPBB_ADS_CENTER = AD_AFTER_NOT_FIRST_POST, AD_AFTER_NOT_FIRST_POST_ID, AD_AFTER_NOT_FIRST_POST_CENTER %}
{% include '@phpbb_ads/phpbb_ads_default.html' %}
{% import '@phpbb_ads/phpbb_ads_macro.html' as ad %}
{{ ad.renderAds(AD_AFTER_NOT_FIRST_POST, AD_AFTER_NOT_FIRST_POST_ID, AD_AFTER_NOT_FIRST_POST_CENTER) }}
{% endif %}
{# end ad location #}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{# begin ad location #}
{% set PHPBB_ADS_STYLE = 'margin: 10px 0;' %}
{% set PHPBB_ADS_CODE, PHPBB_ADS_ID, S_PHPBB_ADS_CENTER = AD_AFTER_POSTS, AD_AFTER_POSTS_ID, AD_AFTER_POSTS_CENTER %}
{% include '@phpbb_ads/phpbb_ads_default.html' %}
{% import '@phpbb_ads/phpbb_ads_macro.html' as ad %}
{{ ad.renderAds(AD_AFTER_POSTS, AD_AFTER_POSTS_ID, AD_AFTER_POSTS_CENTER) }}
{# end ad location #}
3 changes: 2 additions & 1 deletion styles/all/template/includes/phpbb_ads_pop_up.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{% import '@phpbb_ads/phpbb_ads_macro.html' as ad %}
<script>
(function($, window, document, phpbb) {
'use strict';

$(window).on('load', function() {
document.cookie = '{{ POP_UP_COOKIE_NAME }}=true; expires={{ POP_UP_COOKIE_EXPIRES }}; path={{ POP_UP_COOKIE_PATH }}';
phpbb.alert('{{ lang('ADVERTISEMENT')|upper|e('js') }}', `{% include '@phpbb_ads/phpbb_ads_default.html' %}`);
phpbb.alert('{{ lang('ADVERTISEMENT')|upper|e('js') }}', `{{ ad.renderAds(AD_POP_UP, AD_POP_UP_ID, AD_POP_UP_CENTER, 'margin: 0;') }}`);
});
})(jQuery, window, document, phpbb);
</script>
3 changes: 2 additions & 1 deletion styles/all/template/includes/phpbb_ads_slide_up.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div class="phpbbad-slide-up">
<div class="phpbbad-slide-up-center"><i class="phpbbad-slide-up-close icon fa-chevron-down fa-fw" title="{{ lang('HIDE_AD') }}"></i></div>
{% include '@phpbb_ads/phpbb_ads_default.html' %}
{% import '@phpbb_ads/phpbb_ads_macro.html' as ad %}
{{ ad.renderAds(AD_SLIDE_UP, AD_SLIDE_UP_ID, AD_SLIDE_UP_CENTER, 'margin: 0;') }}
</div>

<script>
Expand Down
5 changes: 0 additions & 5 deletions styles/all/template/phpbb_ads_default.html

This file was deleted.

7 changes: 7 additions & 0 deletions styles/all/template/phpbb_ads_macro.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% macro renderAds(PHPBB_ADS_CODE, PHPBB_ADS_ID, S_PHPBB_ADS_CENTER = false, PHPBB_ADS_STYLE = '') %}
{% if PHPBB_ADS_CODE %}
<div class="phpbb-ads{% if S_PHPBB_ADS_CENTER %} phpbb-ads-center{% endif %}" style="{{ PHPBB_ADS_STYLE }}" data-phpbb-ads-id="{{ PHPBB_ADS_ID|e('html_attr') }}">
{{ PHPBB_ADS_CODE }}
</div>
{% endif %}
{% endmacro %}
4 changes: 4 additions & 0 deletions styles/all/theme/phpbbads.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.phpbb-ads {
margin: 10px 0;
}

.phpbb-ads-center {
text-align: center;
}
Expand Down

0 comments on commit 919fd8f

Please sign in to comment.