Skip to content

Commit a140e08

Browse files
Inital port to Backdrop CMS
1 parent b14a805 commit a140e08

8 files changed

+460
-23
lines changed

LICENSE.txt

Lines changed: 339 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Views Delimited List
2+
<!--
3+
The first paragraph of this file should be kept short as it will be used as the
4+
project summary on BackdropCMS.org. Aim for about 240 characters (three lines at
5+
80 characters each).
6+
7+
All lines in this file should be no more than 80 characters long for legibility,
8+
unless including a URL or example that requires the line to not wrap.
9+
|<- - - - - - - This line is exactly 80 characters for reference - - - - - - ->|
10+
11+
Detail in READMEs should be limited to the minimum required for installation and
12+
getting started. More detailed documentation should be moved to a GitHub wiki
13+
page; for example: https://github.com/backdrop-contrib/setup/wiki/Documentation.
14+
-->
15+
Views Delimited List allows you to format the row results of a view as a comma
16+
(or other delimiter) separated list. You can additionally define a different
17+
final delimiter and configure how it behaves with smaller result sets.
18+
19+
The module adds a new display style with configuration for the delimiter, final
20+
delimiter and optional prefix/suffix. Each row should have a single line to work
21+
well so combine fields inline. No additional white space is added so add
22+
whitespace to the field and/or to the configured delimiters.
23+
24+
With a 'HTML list' display, the results might have looked like:
25+
- Item 1
26+
- Item 2
27+
- Item 3
28+
29+
But with the module, the results can look like:
30+
`Item 1, Item 2 and Item 3`
31+
32+
## Installation
33+
<!--
34+
List the steps needed to install and configure the module. Add/remove steps as
35+
necessary.
36+
-->
37+
- Install this module using the official Backdrop CMS instructions at
38+
https://docs.backdropcms.org/documentation/extend-with-modules.
39+
40+
## Issues
41+
<!--
42+
Link to the repo's issue queue.
43+
-->
44+
Bugs and Feature Requests should be reported in the Issue Queue:
45+
https://github.com/backdrop-contrib/views_delimited_list/issues.
46+
47+
## Current Maintainers
48+
<!--
49+
List the current maintainer(s) of the module, and note if this module needs
50+
new/additional maintainers.
51+
-->
52+
- [Martin Price](https://github.com/yorkshire-pudding) - [System Horizons Ltd](https://www.systemhorizons.co.uk)
53+
- Collaboration and co-maintainers welcome!
54+
55+
## Credits
56+
<!--
57+
Give credit where credit's due.
58+
If this is a Drupal port, state who ported it, and who wrote the original Drupal
59+
module. If this module is based on another project, or uses third-party
60+
libraries, list them here. You can also mention any organisations/companies who
61+
sponsored the module's development.
62+
-->
63+
- Ported to Backdrop CMS by - [Martin Price](https://github.com/yorkshire-pudding) - [System Horizons Ltd](https://www.systemhorizons.co.uk).
64+
- Port and ongoing development sponsored by [System Horizons Ltd](https://www.systemhorizons.co.uk).
65+
- Original [module for Drupal](https://www.drupal.org/project/views_delimited_list):
66+
- Written, ported to Drupal 7 and maintained for Drupal 7 by
67+
[Jason Zhang (zhangtaihao)](https://www.drupal.org/user/858312)
68+
69+
## License
70+
<!--
71+
Mention what license this module is released under, and where people can find
72+
it.
73+
-->
74+
75+
This project is GPL v2 software.
76+
See the LICENSE.txt file in this directory for complete text.

views-delimited-list-fields.tpl.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
<?php
22
/**
33
* @file views-delimited-list-fields.tpl.php
4-
* Default simple view template to all the fields as a row. This template overrides
5-
* the original template from Views to output no extra whitespace.
4+
* Default simple view template to all the fields as a row. This template
5+
* overrides the original template from Views to output no extra whitespace.
66
*
77
* - $view: The view in use.
88
* - $fields: an array of $field objects. Each one contains:
99
* - $field->content: The output of the field.
10-
* - $field->raw: The raw data for the field, if it exists. This is NOT output safe.
10+
* - $field->raw: The raw data for the field, if it exists. This is NOT
11+
* output safe.
1112
* - $field->class: The safe class id to use.
12-
* - $field->handler: The Views field handler object controlling this field. Do not use
13+
* - $field->handler: The Views field handler object controlling this field.
14+
* Do not use
1315
* var_export to dump this object, as it can't handle the recursion.
1416
* - $field->inline: Whether or not the field should be inline.
1517
* - $field->inline_html: either div or span based on the above flag.
16-
* - $field->wrapper_prefix: A complete wrapper containing the inline_html to use.
18+
* - $field->wrapper_prefix: A complete wrapper containing the inline_html to
19+
* use.
1720
* - $field->wrapper_suffix: The closing tag for the wrapper.
1821
* - $field->separator: an optional separator that may appear before a field.
1922
* - $field->label: The wrap label text to use.

views-view-delimited-list.tpl.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,21 @@
66
* @ingroup views_templates
77
*/
88

9-
// Prepare variables
9+
// Prepare variables.
1010
$count = count($rows);
1111
$separator = ($count == 2 && $count != $options['long_count']) ? $options['separator_two'] : $options['separator_long'];
1212
$last_delimiter = $separator == 'both' || $separator == 'delimiter';
1313
$last_conjunctive = $separator == 'both' || $separator == 'conjunctive';
1414

1515
?>
16-
<?php if (!empty($title)): ?>
17-
<h3><?php print $title; ?></h3>
16+
<?php if (!empty($title)) : ?>
17+
<h3>
18+
<?php print $title; ?>
19+
</h3>
1820
<?php endif; ?>
1921
<div class="views-delimited-list">
2022
<?php
21-
// Prefix
23+
// Prefix.
2224
if (!empty($options['prefix'])) {
2325
print '<span class="views-delimited-list-prefix">';
2426
print $options['prefix'];
@@ -28,27 +30,27 @@
2830
foreach ($rows as $i => $row) {
2931
$index = $i + 1;
3032

31-
// Row
33+
// Row.
3234
print '<span class="' . $classes_array[$i] . '">';
3335
print trim($row);
3436
print '</span>';
3537

36-
// Delimiter
38+
// Delimiter.
3739
if ($index < $count - 1 || $index == $count - 1 && $last_delimiter) {
3840
print '<span class="views-row-delimiter">' . $options['delimiter'] . '</span>';
3941
}
4042

41-
// Conjunctive
43+
// Conjunctive.
4244
if ($index == $count - 1 && $last_conjunctive && is_string($options['conjunctive']) && $options['conjunctive'] !== '') {
4345
print '<span class="views-row-conjunctive">' . $options['conjunctive'] . '</span>';
4446
}
4547
}
4648

47-
// Suffix
49+
// Suffix.
4850
if (!empty($options['suffix'])) {
4951
print '<span class="views-delimited-list-suffix">';
5052
print $options['suffix'];
5153
print '</span>';
5254
}
5355
?>
54-
</div>
56+
</div>

views_delimited_list.info

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name = Views Delimited List
22
description = Displays the results of a view as a delimited text list.
3+
backdrop = 1.x
4+
type = module
5+
36
dependencies[] = views
4-
files[] = views_plugin_style_delimited_list.inc
5-
core = 7.x
6-
package = Views
7+
8+
package = Views
9+
tags[] = Content
10+
tags[] = Structure

views_delimited_list.module

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,27 @@ function views_delimited_list_theme_registry_alter(&$hooks) {
3030
function views_delimited_list_views_api() {
3131
return array(
3232
'api' => 3,
33+
'path' => backdrop_get_path('module', 'views_delimited_list'),
3334
);
3435
}
3536

37+
/**
38+
* Implements hook_autoload_info().
39+
*/
40+
function views_delimited_list_autoload_info() {
41+
return array(
42+
'views_plugin_style_delimited_list' => 'views_plugin_style_delimited_list.inc',
43+
);
44+
}
45+
46+
3647
/**
3748
* Implements template_preprocess_HOOK().
3849
*/
3950
function template_preprocess_views_view_delimited_list(&$vars) {
4051
$view = $vars['view'];
4152

42-
// Process row classes
53+
// Process row classes.
4354
$vars['classes_array'] = array();
4455
foreach ($vars['rows'] as $id => $_) {
4556
$vars['classes_array'][$id] = 'views-row';
@@ -51,7 +62,8 @@ function template_preprocess_views_view_delimited_list(&$vars) {
5162
*/
5263
function views_delimited_list_preprocess_views_view_fields(&$vars) {
5364
if (class_exists('views_plugin_style_delimited_list') && $vars['view']->style_plugin instanceof views_plugin_style_delimited_list) {
54-
// Inject the view template name to dispose Drupal towards using our template
65+
// Inject the view template name to dispose Backdrop towards using our
66+
// template.
5567
array_unshift($vars['theme_hook_suggestions'], 'views_delimited_list_fields');
5668
}
5769
}

views_delimited_list.views.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
* Implements hook_views_plugins().
99
*/
1010
function views_delimited_list_views_plugins() {
11-
$path = drupal_get_path('module', 'views_delimited_list');
11+
$path = backdrop_get_path('module', 'views_delimited_list');
1212
$plugins = array(
1313
'style' => array(
1414
'views_delimited_list' => array(
1515
'title' => t('Delimited text list'),
1616
'path' => $path,
1717
'help' => ('Display rows as an inline, delimited list of text.'),
1818
'handler' => 'views_plugin_style_delimited_list',
19+
'theme path' => $path,
1920
'theme' => 'views_view_delimited_list',
2021
'uses row plugin' => TRUE,
2122
'uses fields' => TRUE,

views_plugin_style_delimited_list.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class views_plugin_style_delimited_list extends views_plugin_style {
66
/**
77
* Default options.
88
*/
9-
function option_definition() {
9+
public function option_definition() {
1010
$options = parent::option_definition();
1111
$options['delimiter'] = array('default' => ', ');
1212
$options['conjunctive'] = array('default' => ' and&nbsp;');
@@ -21,7 +21,7 @@ class views_plugin_style_delimited_list extends views_plugin_style {
2121
/**
2222
* Add widgets for selecting fields for the feature rotator.
2323
*/
24-
function options_form(&$form, &$form_state) {
24+
public function options_form(&$form, &$form_state) {
2525
parent::options_form($form, $form_state);
2626

2727
$form['delimiter'] = array(
@@ -97,4 +97,4 @@ class views_plugin_style_delimited_list extends views_plugin_style {
9797
'#description' => t('Text to insert inline after the delimited list.'),
9898
);
9999
}
100-
}
100+
}

0 commit comments

Comments
 (0)