-
Notifications
You must be signed in to change notification settings - Fork 3
/
tom_image_grid.php
333 lines (276 loc) · 11.8 KB
/
tom_image_grid.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<?php
// This is a PLUGIN TEMPLATE for Textpattern CMS.
// Copy this file to a new name like abc_myplugin.php. Edit the code, then
// run this file at the command line to produce a plugin for distribution:
// $ php abc_myplugin.php > abc_myplugin-0.1.txt
// Plugin name is optional. If unset, it will be extracted from the current
// file name. Plugin names should start with a three letter prefix which is
// unique and reserved for each plugin author ("abc" is just an example).
// Uncomment and edit this line to override:
$plugin['name'] = 'tom_image_grid';
// Allow raw HTML help, as opposed to Textile.
// 0 = Plugin help is in Textile format, no raw HTML allowed (default).
// 1 = Plugin help is in raw HTML. Not recommended.
# $plugin['allow_html_help'] = 1;
$plugin['version'] = '0.4.2';
$plugin['author'] = 'Thomas Jund';
$plugin['author_uri'] = 'http://sacripant.fr';
$plugin['description'] = 'An optionnal grid display for images tab';
// Plugin load order:
// The default value of 5 would fit most plugins, while for instance comment
// spam evaluators or URL redirectors would probably want to run earlier
// (1...4) to prepare the environment for everything else that follows.
// Values 6...9 should be considered for plugins which would work late.
// This order is user-overrideable.
$plugin['order'] = '5';
// Plugin 'type' defines where the plugin is loaded
// 0 = public : only on the public side of the website (default)
// 1 = public+admin : on both the public and admin side
// 2 = library : only when include_plugin() or require_plugin() is called
// 3 = admin : only on the admin side (no AJAX)
// 4 = admin+ajax : only on the admin side (AJAX supported)
// 5 = public+admin+ajax : on both the public and admin side (AJAX supported)
$plugin['type'] = '3';
// Plugin "flags" signal the presence of optional capabilities to the core plugin loader.
// Use an appropriately OR-ed combination of these flags.
// The four high-order bits 0xf000 are available for this plugin's private use
if (!defined('PLUGIN_HAS_PREFS')) define('PLUGIN_HAS_PREFS', 0x0001); // This plugin wants to receive "plugin_prefs.{$plugin['name']}" events
if (!defined('PLUGIN_LIFECYCLE_NOTIFY')) define('PLUGIN_LIFECYCLE_NOTIFY', 0x0002); // This plugin wants to receive "plugin_lifecycle.{$plugin['name']}" events
$plugin['flags'] = '';
// Plugin 'textpack' is optional. It provides i18n strings to be used in conjunction with gTxt().
// Syntax:
// ## arbitrary comment
// #@event
// #@language ISO-LANGUAGE-CODE
// abc_string_name => Localized String
/** Uncomment me, if you need a textpack
$plugin['textpack'] = <<< EOT
#@admin
#@language en-gb
abc_sample_string => Sample String
abc_one_more => One more
#@language de-de
abc_sample_string => Beispieltext
abc_one_more => Noch einer
EOT;
**/
// End of textpack
if (!defined('txpinterface'))
@include_once('zem_tpl.php');
# --- BEGIN PLUGIN CODE ---
if (@txpinterface == 'admin') {
register_callback( 'tom_image_grid_markup', 'image_ui', 'extend_controls');
register_callback( 'tom_image_grid_css', "image");
register_callback( 'tom_image_grid_js', "image");
}
function tom_image_grid_markup($event, $step, $default)
{
$out = <<<HTML
<form id="tom_ig_options">
<label><input type="radio" name="tom_ig_option" id="tom_ig_option--grid" /><span class="tom_ig_icon-grid">Grid</span></label>
<label><input type="radio" name="tom_ig_option" id="tom_ig_option--line" /><span class="tom_ig_icon-line">Line</span></label>
</form>
HTML;
echo $default.$out;
}
function tom_image_grid_css()
{
$sortby = gTxt('sort_by');
$out = <<<CSS
<style type="text/css">
/*
** CSS for tom_image_grid plugin
** By Sacripant — Thomas Jund
** http://sacripant.fr
*/
.tom_ig .txp-list * {
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.tom_ig .txp-listtables {
display: block;
}
.tom_ig#page-image .txp-list thead th {
/*display: none;*/
display: inline-block;
position: relative;
width: auto;
}
.tom_ig#page-image .txp-list thead th.images_detail {
display: none !important;
}
.tom_ig#page-image .txp-list thead th.txp-list-col-multi-edit {
margin-right: 1em;
}
.tom_ig#page-image .txp-list thead th.txp-list-col-multi-edit:after {
content: attr(title);
padding-left: .33em;
}
.tom_ig#page-image .txp-list thead th.txp-list-col-id {
margin-left: 3.6em;
}
.tom_ig#page-image .txp-list thead th.txp-list-col-id:before {
content: "Sort by";
display: block;
padding: inherit;
padding-left: 0;
padding-right: .33em;
position: absolute;
width: 3.6em;
right: 100%;
top: 0;
text-align: right;
font-weight: normal;
}
.tom_ig#page-image .txp-list tbody tr {
display: inline-block;
/*vertical-align: mid;*/
width: 15em;
margin: .66em 1em 0 0
}
.tom_ig#page-image .txp-list tbody td,
.tom_ig#page-image .txp-list tbody th {
display: block;
padding: 0.16em 0.33em;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.tom_ig#page-image .txp-list td.txp-list-col-multi-edit {
float: right;
width: auto;
}
.tom_ig#page-image .txp-list td.txp-list-col-multi-edit input {
margin-bottom: 0;
}
.tom_ig#page-image .txp-list td.txp-list-col-thumbnail {
height: 12em;
}
.tom_ig#page-image .txp-list td.txp-list-col-thumbnail img {
max-width: 100%;
max-height: 100%;
height: auto;
width: auto;
}
/* No thumbnail display */
.tom_ig#page-image .txp-list td.txp-list-col-thumbnail:not(.has-thumbnail) {
display: block;
background-color: #eee;
text-align: center;
height: 100%;
width: 100%;
border-width: 5.25em 5.5em;
border-style: solid;
border-top-color: #eee;
border-bottom-color: #eee;
border-left-color: #ddd;
border-right-color: #ddd;
}
@media only screen and (max-width: 480px) {
.tom_ig#page-image .txp-list tbody tr {
width: 140px;
margin: .66em .33em 0 0;
}
.tom_ig#page-image .txp-list td.thumbnail {
height: 112px;
}
.tom_ig .tom_ig--noThumb {
border-width: 45px 40px;
}
}
/*buttons
----------*/
#tom_ig_options input {
display: none;
}
#tom_ig_options label {
padding: .16em;
display: inline-block;
border: 1px solid transparent;
width: 20px;
height: 20px;
overflow: hidden;
}
#tom_ig_options label.selected {
border-color: #aaa;
}
#tom_ig_options label:not(.selected):hover {
cursor: pointer;
background-color: #eee;
}
.tom_ig_icon-grid:before {
content: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSIyMHB4IiBoZWlnaHQ9IjIwcHgiIHZpZXdCb3g9IjAgMCAyMCAyMCI+DQo8ZyBpZD0iZ3JpZCIgc3R5bGU9ImJhY2tncm91bmQtY29sb3I6ICMzMzMiPg0KICAgIDxyZWN0IHg9IjMiICB5PSIzIiAgd2lkdGg9IjYiIGhlaWdodD0iNiIvPg0KICAgIDx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2Zz4NCg==");
}
</style>
CSS;
echo $out;
}
function tom_image_grid_js()
{
$out = <<<JS
<script type="text/javascript">
/*
** JS for tom_image_grid plugin
** By Sacripant — Thomas Jund
** http://sacripant.fr
*/
$(function() {
var imageDisplayOption = $("#tom_ig_options")
, radios = $('input', imageDisplayOption)
, listtables = $('#images_form .txp-listtables')
/*, imagesTr = $('tr', listtables)*/
, cookie = 'tom_image_grid'
, cookieValue = getCookie(cookie)
;
// Add radios in tab
imageDisplayOption.prependTo(listtables);
// Change Layout when radio checked
radios.change(function(event)
{
if ( this.id === "tom_ig_option--grid")
{
$('body').addClass('tom_ig');
setCookie(cookie, 'tom_ig_option--grid');
}
else
{
$('body').removeClass('tom_ig');
setCookie(cookie, 'tom_ig_option--line')
}
radios.parent().removeClass('selected');
$(this).parent().addClass('selected');
});
// Check & create cookie
if ( cookieValue )
{
var targetRadio = document.getElementById(cookieValue);
}
else
{
var targetRadio = document.getElementById('tom_ig_option--line');
setCookie(cookie, 'tom_ig_option--line')
};
$(targetRadio).prop('checked', true).trigger("change");
});
</script>
JS;
echo $out;
}
# --- END PLUGIN CODE ---
if (0) {
?>
<!--
# --- BEGIN PLUGIN HELP ---
h1. tom_image_grid 0.4
p. _tom_image_grid_ is a plugin for Textpattern 4.6.* CMS. It allows a more compact display (as a grid) of the images list.
p. The plugin adds two buttons
!data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIH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dpZHRoPSIxMyIgaGVpZ2h0PSIzIi8+DQogICAgPHJlY3QgeD0iNiIgeT0iOSIgIHdpZHRoPSIxMyIgaGVpZ2h0PSIzIi8+DQogICAgPHJlY3QgeD0iNiIgeT0iMyIgIHdpZHRoPSIxMyIgaGVpZ2h0PSIzIi8+DQo8L2c+DQo8L3N2Zz4NCg==!
in the Image Tab of your back-office allowing you to switch from the standard display to a more compact grid display.
# --- END PLUGIN HELP ---
-->
<?php
}
?>