Document Gallery - Version 2.3

Version Description

  • Enhancement: Taxonomy support now includes handling for both relationships between different taxons and relationships between different terms within a single taxon. See installation tab for more details.
  • Enhancement: You can now limit how many results are displayed in the gallery with the limit attribute.
  • Enhancement: The post_type and post_status used when generating a gallery are now configurable. (In most cases, these should be left at their default values, however advanced users may find a use case for this functionality.)
  • Enhancement: Support was added for detecting when your site is running behind a firewall or on a local network where Google Drive Viewer will not be able to function.
  • Enhancement: Handling of custom CSS was improved. Page load speed should be improved in some cases.
  • Bug Fix: When Ghostscript chokes on a PDF, it will no longer print the error message in the Document Gallery output (instead it will end up in Document Gallery Logging).
Download this release

Release Info

Developer dan.rossiter
Plugin Icon 128x128 Document Gallery
Version 2.3
Comparing to
See all releases

Code changes from version 2.2.7 to 2.3

README.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: dan.rossiter, demur
3
  Tags: attachments, thumbnail, documents, gallery, MS office, pdf
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=EE5LWRLG933EN&lc=US&item_name=Document%20Gallery%20Plugin&item_number=document%2dgallery&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
5
  Requires at least: 3.6
6
- Tested up to: 4.0
7
- Stable tag: 2.2.7
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -24,13 +24,14 @@ Read more in the **Installation** tab!
24
 
25
  = Translation =
26
 
27
- Document Gallery has to-date been translated into **5** languages, listed below.
28
 
29
- 1. **French** — *Thanks, Marc Liotard and [Traffic Influence](http://www.trafic-influence.com/)!*
30
- 1. **Russian** — *Thanks, [demur](http://wordpress.org/support/profile/demur)!*
31
- 1. **Spanish** — *Thanks, Andrew Kurtis and [WebHostingHub](http://www.webhostinghub.com/)!*
32
- 1. **Swedish** — *Thanks, [mepmepmep](http://wordpress.org/support/profile/mepmepmep)!*
33
- 1. **Ukrainian** — *Thanks, [demur](http://wordpress.org/support/profile/demur)!*
 
34
 
35
  = Developers =
36
 
@@ -87,7 +88,8 @@ their assigned category or any other
87
  [custom taxon](http://codex.wordpress.org/Taxonomies). Categories
88
  or any custom taxon can be referenced simply by including `category=category_value`
89
  or `taxon_name=taxon_value`. Multiple values for a single taxon may be separated
90
- by commas.
 
91
 
92
  **Descriptions Option**
93
 
@@ -97,7 +99,7 @@ alongside it.
97
  *Note: this will use the `description` field, **not** the `caption`. Be
98
  careful when entering your document data.*
99
 
100
- **Fancy** *(New in Version 2.0)*
101
 
102
  If `true`, we will try to generate a thumbnail for each document in the gallery.
103
  The success in generating thumbs will depend mostly on what your server supports.
@@ -110,6 +112,11 @@ in order to protect your privacy, since using it requires sending your documents
110
  to Google's servers. If you're not working with confidential documents, you are
111
  encouraged to enable this for optimum performance.*
112
 
 
 
 
 
 
113
  **Order Option**
114
 
115
  This option works alongside the `orderby` option to determine whether the
@@ -164,13 +171,18 @@ or taxonomy* option, though it can be used with any options you chose.
164
  **Relation Option** *(New in Version 1.4)*
165
 
166
  The relation option should only be used when also using the *category or custom
167
- taxonomy* option (see above). Additionally, this option is only effective in
168
- WordPress installs version 3.1 or higher. Older versions cannot use this value
169
- and will ignore it.
 
 
170
 
171
- When using multiple taxa, this option allows you to decide whether the attachments
172
- returned must meet all of the taxa_names specified (AND) or a minimum of one
173
- match (OR).
 
 
 
174
 
175
  = Customize Appearance =
176
 
@@ -374,6 +386,17 @@ would recommend enabling it, since it's currently the only way to generate a
374
  thumbnail for any of the Microsoft Office files, as well as some less common
375
  file types.
376
 
 
 
 
 
 
 
 
 
 
 
 
377
  == Screenshots ==
378
 
379
  1. This is an example of "fancy" thumbnails. The images are a copy of the front
@@ -393,6 +416,22 @@ To see a list of features planned for the future as well as to propose your own
393
  ideas for future Document Gallery development, take a look at our
394
  [issue tracker](https://github.com/thenadz/document-gallery/issues).
395
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
  = 2.2.7 =
397
  * **Bug Fix:** There was an issue with a few phrases not being translated in the
398
  admin dialogs. Dates in the logs were also not being properly translated.
3
  Tags: attachments, thumbnail, documents, gallery, MS office, pdf
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=EE5LWRLG933EN&lc=US&item_name=Document%20Gallery%20Plugin&item_number=document%2dgallery&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
5
  Requires at least: 3.6
6
+ Tested up to: 4.0.1
7
+ Stable tag: 2.3
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
24
 
25
  = Translation =
26
 
27
+ Document Gallery has to-date been translated into **6** languages, listed below.
28
 
29
+ * **Finnish** — *Thanks, [villevetela](https://wordpress.org/support/profile/villevetela)!*
30
+ * **French** — *Thanks, Marc Liotard and [Traffic Influence](http://www.trafic-influence.com/)!*
31
+ * **Russian** — *Thanks, [demur](http://wordpress.org/support/profile/demur)!*
32
+ * **Spanish** — *Thanks, Andrew Kurtis and [WebHostingHub](http://www.webhostinghub.com/)!*
33
+ * **Swedish** — *Thanks, [mepmepmep](http://wordpress.org/support/profile/mepmepmep)!*
34
+ * **Ukrainian** — *Thanks, [demur](http://wordpress.org/support/profile/demur)!*
35
 
36
  = Developers =
37
 
88
  [custom taxon](http://codex.wordpress.org/Taxonomies). Categories
89
  or any custom taxon can be referenced simply by including `category=category_value`
90
  or `taxon_name=taxon_value`. Multiple values for a single taxon may be separated
91
+ by commas. Note that if a taxon value contains spaces then the entire comma-
92
+ delimited list must be quoted.
93
 
94
  **Descriptions Option**
95
 
99
  *Note: this will use the `description` field, **not** the `caption`. Be
100
  careful when entering your document data.*
101
 
102
+ **Fancy Option** *(New in Version 2.0)*
103
 
104
  If `true`, we will try to generate a thumbnail for each document in the gallery.
105
  The success in generating thumbs will depend mostly on what your server supports.
112
  to Google's servers. If you're not working with confidential documents, you are
113
  encouraged to enable this for optimum performance.*
114
 
115
+ **Limit Option** *(New in Version 2.3)*
116
+
117
+ As the name suggests, this value will limit how many results are returned in the gallery.
118
+ If set to *-1*, the limit is infinite.
119
+
120
  **Order Option**
121
 
122
  This option works alongside the `orderby` option to determine whether the
171
  **Relation Option** *(New in Version 1.4)*
172
 
173
  The relation option should only be used when also using the *category or custom
174
+ taxonomy* option (see above).
175
+
176
+ When using multiple taxa this option allows you to decide whether the attachments
177
+ returned must match all of the different taxa specified (AND) or a minimum of one
178
+ taxa match (OR).
179
 
180
+ *NOTE: This has no bearing on the relationship between different terms for a single
181
+ taxon (eg: `[dg category=x,y,z relation=AND]` will return any attachments where the
182
+ category is x, y, OR z). If you wish to return only attachments with all 3 categories,
183
+ you will instead need to use the following syntax:
184
+ `[dg category=x,y,z category_relation=AND]`. This syntax of *taxon*_relation will
185
+ work for any taxon, not just "category."*
186
 
187
  = Customize Appearance =
188
 
386
  thumbnail for any of the Microsoft Office files, as well as some less common
387
  file types.
388
 
389
+ = Q: Ghostscript is installed on my server, but it's not working! =
390
+
391
+ A: Document Gallery does a pretty good job of detecting where Ghostscript is installed,
392
+ but on some installs it may need a little help. To check whether this is the case,
393
+ navigate to `Dashboard -> Settings -> Document Gallery` and see if there is a notice
394
+ next to the Ghostscript checkbox indicating that your server is not properly configured.
395
+ If that notice does exist, the next step is to go to the `Advanced` tab on that same page
396
+ and see if the Ghostscript path is set. If it is not, you'll need to manually fill it
397
+ with the location for your Ghostscript install (eg: `/usr/local/bin/gs`). Once that
398
+ change is saved, the Ghostscript checkbox should be enabled on the first tab.
399
+
400
  == Screenshots ==
401
 
402
  1. This is an example of "fancy" thumbnails. The images are a copy of the front
416
  ideas for future Document Gallery development, take a look at our
417
  [issue tracker](https://github.com/thenadz/document-gallery/issues).
418
 
419
+ = 2.3 =
420
+ * **Enhancement:** Taxonomy support now includes handling for both relationships
421
+ between different taxons and relationships between different terms within a single
422
+ taxon. See installation tab for more details.
423
+ * **Enhancement:** You can now limit how many results are displayed in the gallery with
424
+ the *limit* attribute.
425
+ * **Enhancement:** The *post_type* and *post_status* used when generating
426
+ a gallery are now configurable. (In most cases, these should be left at their default
427
+ values, however advanced users may find a use case for this functionality.)
428
+ * **Enhancement:** Support was added for detecting when your site is running behind a
429
+ firewall or on a local network where Google Drive Viewer will not be able to function.
430
+ * **Enhancement:** Handling of custom CSS was improved. Page load speed should be improved
431
+ in some cases.
432
+ * **Bug Fix:** When Ghostscript chokes on a PDF, it will no longer print the error message
433
+ in the Document Gallery output (instead it will end up in Document Gallery Logging).
434
+
435
  = 2.2.7 =
436
  * **Bug Fix:** There was an issue with a few phrases not being translated in the
437
  admin dialogs. Dates in the logs were also not being properly translated.
admin/class-admin.php CHANGED
@@ -234,6 +234,44 @@ class DG_Admin {
234
  'option_name' => DG_OPTION_NAME,
235
  'description' => __('Whether matched documents must have all taxa_names (AND) or at least one (OR)', 'document-gallery')
236
  ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
 
238
  add_settings_field(
239
  'thumbnail_generation_av', 'Audio/Video',
@@ -428,7 +466,7 @@ class DG_Admin {
428
 
429
  // handle gallery shortcode defaults
430
  $errs = array();
431
- $ret['gallery'] = DG_Gallery::sanitizeDefaults($values['gallery_defaults'], $errs);
432
 
433
  foreach ($errs as $k => $v) {
434
  add_settings_error(DG_OPTION_NAME, str_replace('_', '-', $k), $v);
@@ -495,15 +533,7 @@ class DG_Admin {
495
  // handle modified CSS
496
  if (trim($ret['css']['text']) !== trim($values['css'])) {
497
  $ret['css']['text'] = trim($values['css']);
498
- $ret['css']['version']++;
499
- $ret['css']['last-modified'] = gmdate('D, d M Y H:i:s');
500
- $ret['css']['etag'] = md5($ret['css']['last-modified']);
501
-
502
- if (empty($ret['css']['text'])) {
503
- unset($ret['css']['minified']);
504
- } else {
505
- $ret['css']['minified'] = DocumentGallery::compileCustomCss($ret['css']['text']);
506
- }
507
  }
508
 
509
  return $ret;
@@ -743,8 +773,8 @@ class DG_Admin {
743
  $att_ids = array_slice($att_ids, $offset, $limit);
744
  $atts = get_posts(
745
  array(
746
- 'post_type' => 'attachment',
747
- 'post_status' => 'inherit',
748
  'numberposts' => -1,
749
  'post__in' => $att_ids,
750
  'orderby' => 'post__in'
234
  'option_name' => DG_OPTION_NAME,
235
  'description' => __('Whether matched documents must have all taxa_names (AND) or at least one (OR)', 'document-gallery')
236
  ));
237
+
238
+ add_settings_field(
239
+ 'gallery_defaults_limit', 'limit',
240
+ array(__CLASS__, 'renderTextField'),
241
+ DG_OPTION_NAME, 'gallery_defaults',
242
+ array (
243
+ 'label_for' => 'label_gallery_defaults_limit',
244
+ 'name' => 'gallery_defaults][limit',
245
+ 'value' => esc_attr($defaults['limit']),
246
+ 'type' => 'number" min="-1" step="1',
247
+ 'option_name' => DG_OPTION_NAME,
248
+ 'description' => __('Limit the number of documents included. -1 means no limit.', 'document-gallery')));
249
+
250
+ add_settings_field(
251
+ 'gallery_defaults_post_status', 'post_status',
252
+ array(__CLASS__, 'renderSelectField'),
253
+ DG_OPTION_NAME, 'gallery_defaults',
254
+ array (
255
+ 'label_for' => 'label_gallery_defaults_post_status',
256
+ 'name' => 'gallery_defaults][post_status',
257
+ 'value' => esc_attr($defaults['post_status']),
258
+ 'options' => DG_Gallery::getPostStatuses(),
259
+ 'option_name' => DG_OPTION_NAME,
260
+ 'description' => __('Which post status to look for when querying documents.', 'document-gallery')
261
+ ));
262
+
263
+ add_settings_field(
264
+ 'gallery_defaults_post_type', 'post_type',
265
+ array(__CLASS__, 'renderSelectField'),
266
+ DG_OPTION_NAME, 'gallery_defaults',
267
+ array (
268
+ 'label_for' => 'label_gallery_defaults_post_type',
269
+ 'name' => 'gallery_defaults][post_type',
270
+ 'value' => esc_attr($defaults['post_type']),
271
+ 'options' => DG_Gallery::getPostTypes(),
272
+ 'option_name' => DG_OPTION_NAME,
273
+ 'description' => __('Which post type to look for when querying documents.', 'document-gallery')
274
+ ));
275
 
276
  add_settings_field(
277
  'thumbnail_generation_av', 'Audio/Video',
466
 
467
  // handle gallery shortcode defaults
468
  $errs = array();
469
+ $ret['gallery'] = DG_Gallery::sanitizeDefaults($values['gallery_defaults'], $errs, true);
470
 
471
  foreach ($errs as $k => $v) {
472
  add_settings_error(DG_OPTION_NAME, str_replace('_', '-', $k), $v);
533
  // handle modified CSS
534
  if (trim($ret['css']['text']) !== trim($values['css'])) {
535
  $ret['css']['text'] = trim($values['css']);
536
+ $ret['css']['minified'] = DocumentGallery::compileCustomCss($ret['css']['text']);
 
 
 
 
 
 
 
 
537
  }
538
 
539
  return $ret;
773
  $att_ids = array_slice($att_ids, $offset, $limit);
774
  $atts = get_posts(
775
  array(
776
+ 'post_type' => 'any',
777
+ 'post_status' => 'any',
778
  'numberposts' => -1,
779
  'post__in' => $att_ids,
780
  'orderby' => 'post__in'
document-gallery.php CHANGED
@@ -5,14 +5,14 @@ defined('WPINC') OR exit;
5
  Plugin Name: Document Gallery
6
  Plugin URI: http://wordpress.org/extend/plugins/document-gallery/
7
  Description: Display non-images (and images) in gallery format on a page or post with the [dg] shortcode.
8
- Version: 2.2.7
9
  Author: Dan Rossiter
10
  Author URI: http://danrossiter.org/
11
  License: GPLv2
12
  Text Domain: document-gallery
13
  */
14
 
15
- define('DG_VERSION', '2.2.7');
16
 
17
  // define helper paths & URLs
18
  define('DG_BASENAME', plugin_basename(__FILE__));
@@ -62,13 +62,8 @@ if (is_admin()) {
62
  }
63
  } else {
64
  // styling for gallery
65
- if (empty($dg_options['css']['text'])) {
66
- add_action('wp_enqueue_scripts', array('DocumentGallery', 'enqueueGalleryStyle'));
67
- } else {
68
- add_action('template_redirect', array('DocumentGallery', 'buildCustomCss'));
69
- add_action('wp_enqueue_scripts', array('DocumentGallery', 'enqueueCustomStyle'));
70
- add_filter('query_vars', array('DocumentGallery', 'addCustomStyleQueryVar'));
71
- }
72
  }
73
 
74
  // adds 'dg' shortcode
@@ -80,12 +75,7 @@ add_shortcode('dg', array('DocumentGallery', 'doShortcode'));
80
  * @author drossiter
81
  */
82
  class DocumentGallery {
83
-
84
- /**
85
- * @var str Name of the query var used to check whether we should print custom CSS.
86
- */
87
- private static $query_var = 'document-gallery-css';
88
-
89
  /*==========================================================================
90
  * THE SHORTCODE
91
  *=========================================================================*/
@@ -115,43 +105,13 @@ class DocumentGallery {
115
  }
116
 
117
  /**
118
- * Enqueue user's custom DG CSS.
119
  */
120
- public static function enqueueCustomStyle() {
121
  global $dg_options;
122
- wp_register_style('document-gallery', add_query_arg(self::$query_var, 1, home_url('/')),
123
- null, DG_VERSION . ':' . $dg_options['css']['version']);
124
- wp_enqueue_style('document-gallery');
125
- }
126
-
127
- /**
128
- * Add query custom CSS query string.
129
- * Taken from here: http://ottopress.com/2010/dont-include-wp-load-please/
130
- * @param multitype:string $vars Variables to be added.
131
- * @return multitype:string All variables to be included in query string.
132
- */
133
- public static function addCustomStyleQueryVar($vars) {
134
- $vars[] = self::$query_var;
135
- return $vars;
136
- }
137
 
138
- /**
139
- * Constructs user's custom CSS dynamically, then instructs
140
- * browser to cache for a year. Cache is busted by versioning
141
- * CSS any time the user makes a change.
142
- */
143
- public static function buildCustomCss() {
144
- if (1 == intval(get_query_var(self::$query_var))) {
145
- global $dg_options;
146
-
147
- header('Content-type: text/css');
148
- header('Cache-Control: no-transform,public,maxage=' . 31536000);
149
- header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT');
150
- header('Last-Modified: ' . $dg_options['css']['last-modified']);
151
- header('ETag: ' . $dg_options['css']['etag']);
152
-
153
- echo $dg_options['css']['minified'];
154
- exit;
155
  }
156
  }
157
 
@@ -278,20 +238,17 @@ class DocumentGallery {
278
  }
279
 
280
  /**
281
- * Compiles any custom CSS plus the default CSS together,
282
- * minifying in the process.
283
  * @param string $custom The custom CSS to compile.
284
- * @return string Compiled CSS, including both standard and any custom.
285
  */
286
  public static function compileCustomCss($custom) {
287
- $css = file_get_contents(DG_PATH . 'assets/css/style.css');
288
- $css .= str_replace('>', '>', esc_html($custom));
289
-
290
- return $css;
291
  }
292
 
293
  /**
294
- * Removes all comments & space from CSS string.
295
  * Source: http://stackoverflow.com/a/15195752/866618
296
  */
297
  private static function minifyCss($css) {
5
  Plugin Name: Document Gallery
6
  Plugin URI: http://wordpress.org/extend/plugins/document-gallery/
7
  Description: Display non-images (and images) in gallery format on a page or post with the [dg] shortcode.
8
+ Version: 2.3
9
  Author: Dan Rossiter
10
  Author URI: http://danrossiter.org/
11
  License: GPLv2
12
  Text Domain: document-gallery
13
  */
14
 
15
+ define('DG_VERSION', '2.3');
16
 
17
  // define helper paths & URLs
18
  define('DG_BASENAME', plugin_basename(__FILE__));
62
  }
63
  } else {
64
  // styling for gallery
65
+ add_action('wp_enqueue_scripts', array('DocumentGallery', 'enqueueGalleryStyle'));
66
+ add_action('wp_print_scripts', array('DocumentGallery', 'printCustomStyle'));
 
 
 
 
 
67
  }
68
 
69
  // adds 'dg' shortcode
75
  * @author drossiter
76
  */
77
  class DocumentGallery {
78
+
 
 
 
 
 
79
  /*==========================================================================
80
  * THE SHORTCODE
81
  *=========================================================================*/
105
  }
106
 
107
  /**
108
+ * Prints user's custom CSS.
109
  */
110
+ public static function printCustomStyle() {
111
  global $dg_options;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
 
113
+ if (!empty($dg_options['css']['minified'])) {
114
+ echo "<style type='text/css'>{$dg_options['css']['minified']}</style>" . PHP_EOL;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  }
116
  }
117
 
238
  }
239
 
240
  /**
241
+ * Compiles any custom CSS, including minification and escaping HTML.
 
242
  * @param string $custom The custom CSS to compile.
243
+ * @return string Compiled CSS.
244
  */
245
  public static function compileCustomCss($custom) {
246
+ $css = str_replace('&gt;', '>', esc_html($custom));
247
+ return self::minifyCss($css);
 
 
248
  }
249
 
250
  /**
251
+ * Minifies CSS string.
252
  * Source: http://stackoverflow.com/a/15195752/866618
253
  */
254
  private static function minifyCss($css) {
inc/class-gallery.php CHANGED
@@ -19,10 +19,7 @@ class DG_Gallery {
19
  private $errs = array();
20
 
21
  // templates for HTML output
22
- private static $no_docs = null;
23
- private static $comment = null;
24
-
25
- private static $binary_err = null;
26
 
27
  /*==========================================================================
28
  * PUBLIC FUNCTIONS
@@ -80,12 +77,13 @@ class DG_Gallery {
80
  * Initializes static values for this class.
81
  */
82
  public static function init() {
83
- if (is_null(self::$comment))
84
  {
85
  self::$comment =
86
  PHP_EOL . '<!-- ' . __('Generated using Document Gallery. Get yours here: ', 'document-gallery') .
87
  'http://wordpress.org/extend/plugins/document-gallery -->' . PHP_EOL;
88
  self::$no_docs = '<!-- ' . __('No attachments to display. How boring! :(', 'document-gallery') . ' -->';
 
89
  self::$binary_err = __('The %s parameter may only be "%s" or "%s." You entered "%s."', 'document-gallery');
90
  }
91
  }
@@ -125,81 +123,81 @@ class DG_Gallery {
125
  * Cleans up user input, making sure we don't pass crap on to WP core.
126
  * @param multitype:string $defaults The defaults array to sanitize.
127
  * @param multitype:string &$errs The array of errors, which will be appended with any errors found.
 
128
  */
129
- public static function sanitizeDefaults($defaults, &$errs) {
130
  $old_defaults = self::getOptions();
131
-
132
  // remove invalid keys
133
- $defaults = array_intersect_key($defaults, $old_defaults);
134
-
135
- // add any missing keys
136
  foreach ($old_defaults as $k => $v) {
137
- if (!isset($defaults[$k])) {
138
  if (is_bool($v)) {
139
  // checkbox
140
- $defaults[$k] = false;
141
  } else {
142
  // missing value
143
- $defaults[$k] = $v;
144
  }
145
  }
 
 
 
146
  }
147
-
148
- $defaults['attachment_pg'] = self::sanitizeAttachmentPg($defaults['attachment_pg'], $err);
149
- if (isset($err)) {
150
- $errs['attachment_pg'] = $err;
151
- unset($err);
152
- }
153
-
154
- $defaults['descriptions'] = self::sanitizeDescriptions($defaults['descriptions'], $err);
155
- if (isset($err)) {
156
- $errs['descriptions'] = $err;
157
- unset($err);
158
- }
159
-
160
- $defaults['fancy'] = self::sanitizeFancy($defaults['fancy'], $err);
161
- if (isset($err)) {
162
- $errs['fancy'] = $err;
163
- unset($err);
164
- }
165
-
166
- $defaults['ids'] = self::sanitizeIds($defaults['ids'], $err);
167
- if (isset($err)) {
168
- $errs['ids'] = $err;
169
- unset($err);
170
- }
171
-
172
- $defaults['images'] = self::sanitizeImages($defaults['images'], $err);
173
- if (isset($err)) {
174
- $errs['images'] = $err;
175
- unset($err);
176
- }
177
-
178
- $defaults['localpost'] = self::sanitizeLocalpost($defaults['localpost'], $err);
179
- if (isset($err)) {
180
- $errs['localpost'] = $err;
181
- unset($err);
182
- }
183
-
184
- $defaults['order'] = self::sanitizeOrder($defaults['order'], $err);
185
- if (isset($err)) {
186
- $errs['order'] = $err;
187
- unset($err);
188
  }
189
 
190
- $defaults['orderby'] = self::sanitizeOrderby($defaults['orderby'], $err);
191
- if (isset($err)) {
192
- $errs['orderby'] = $err;
193
- unset($err);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  }
195
 
196
- $defaults['relation'] = self::sanitizeRelation($defaults['relation'], $err);
197
- if (isset($err)) {
198
- $errs['relation'] = $err;
199
- unset($err);
 
 
 
 
 
200
  }
201
-
202
- return $defaults;
203
  }
204
 
205
  /**
@@ -209,15 +207,10 @@ class DG_Gallery {
209
  * @return bool The sanitized attachment_pg value.
210
  */
211
  private static function sanitizeAttachmentPg($value, &$err) {
212
- $defaults = self::getOptions();
213
- $ret = $defaults['attachment_pg'];
214
-
215
- $attachment_pg = self::toBool($value);
216
 
217
- if(is_null($attachment_pg)) {
218
  $err = sprintf(self::$binary_err, 'attachment_pg', 'true', 'false', $value);
219
- } else {
220
- $ret = $attachment_pg;
221
  }
222
 
223
  return $ret;
@@ -230,15 +223,10 @@ class DG_Gallery {
230
  * @return bool The sanitized descriptions value.
231
  */
232
  private static function sanitizeDescriptions($value, &$err) {
233
- $defaults = self::getOptions();
234
- $ret = $defaults['descriptions'];
235
-
236
- $descriptions = self::toBool($value);
237
 
238
- if(is_null($descriptions)) {
239
  $err = sprintf(self::$binary_err, 'descriptions', 'true', 'false', $value);
240
- } else {
241
- $ret = $descriptions;
242
  }
243
 
244
  return $ret;
@@ -251,15 +239,10 @@ class DG_Gallery {
251
  * @return bool The sanitized fancy value.
252
  */
253
  private static function sanitizeFancy($value, &$err) {
254
- $defaults = self::getOptions();
255
- $ret = $defaults['fancy'];
256
-
257
- $fancy = self::toBool($value);
258
 
259
- if(is_null($fancy)) {
260
  $err = sprintf(self::$binary_err, 'fancy', 'true', 'false', $value);
261
- } else {
262
- $ret = $fancy;
263
  }
264
 
265
  return $ret;
@@ -272,22 +255,18 @@ class DG_Gallery {
272
  * @return bool|multitype:int The sanitized ids value.
273
  */
274
  private static function sanitizeIds($value, &$err) {
275
- $defaults = self::getOptions();
276
- $ret = $defaults['ids'];
277
-
278
  if(false === self::toBool($value)) {
279
  $ret = false;
280
  } else {
281
  $value = trim($value);
282
- $ids = $value ? explode(',', $value) : array();
283
  $bad = array_filter($ids, array(__CLASS__, 'negativeInt'));
284
 
285
  if(!empty($bad)) {
286
  $err = _n('The following ID is invalid: ',
287
  'The following IDs are invalid: ',
288
  count($bad), 'document-gallery') . implode(', ', $bad);
289
- } else {
290
- $ret = $ids;
291
  }
292
  }
293
 
@@ -301,20 +280,32 @@ class DG_Gallery {
301
  * @return bool The sanitized images value.
302
  */
303
  private static function sanitizeImages($value, &$err) {
304
- $defaults = self::getOptions();
305
- $ret = $defaults['images'];
306
 
307
- $images = self::toBool($value);
308
-
309
- if(is_null($images)) {
310
  $err = sprintf(self::$binary_err, 'images', 'true', 'false', $value);
311
- } else {
312
- $ret = $images;
313
  }
314
 
315
  return $ret;
316
  }
317
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
318
  /**
319
  * Takes the provided value and returns a sanitized value.
320
  * @param string $value The localpost value to be sanitized.
@@ -322,20 +313,40 @@ class DG_Gallery {
322
  * @return bool The sanitized localpost value.
323
  */
324
  private static function sanitizeLocalpost($value, &$err) {
325
- $defaults = self::getOptions();
326
- $ret = $defaults['localpost'];
327
-
328
- $localpost = self::toBool($value);
329
 
330
- if(is_null($localpost)) {
331
  $err = sprintf(self::$binary_err, 'localpost', 'true', 'false', $value);
332
- } else {
333
- $ret = $localpost;
334
  }
335
 
336
  return $ret;
337
  }
338
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  /**
340
  * Takes the provided value and returns a sanitized value.
341
  * @param string $value The order value to be sanitized.
@@ -343,14 +354,11 @@ class DG_Gallery {
343
  * @return string The sanitized order value.
344
  */
345
  private static function sanitizeOrder($value, &$err) {
346
- $defaults = self::getOptions();
347
- $ret = $defaults['order'];
348
-
349
- $order = strtoupper($value);
350
- if(!in_array($order, self::getOrderOptions())) {
351
  $err = sprintf(self::$binary_err, 'order', 'ASC', 'DESC', $value);
352
- } else {
353
- $ret = $order;
354
  }
355
 
356
  return $ret;
@@ -370,16 +378,11 @@ class DG_Gallery {
370
  * @return string The sanitized orderby value.
371
  */
372
  private static function sanitizeOrderby($value, &$err) {
373
- $defaults = self::getOptions();
374
- $ret = $defaults['orderby'];
375
-
376
- $orderby = 'ID' === strtoupper($value) ? 'ID' : strtolower($value);
377
- if (!in_array($orderby, self::getOrderbyOptions())) {
378
- $err = sprintf(
379
- __('The orderby value entered, "%s," is not valid.', 'document-gallery'),
380
- $value);
381
- } else {
382
- $ret = $orderby;
383
  }
384
 
385
  return $ret;
@@ -393,6 +396,72 @@ class DG_Gallery {
393
  'menu_order', 'modified', 'name', 'none',
394
  'parent', 'post__in', 'rand', 'title');
395
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
 
397
  /**
398
  * Takes the provided value and returns a sanitized value.
@@ -401,14 +470,11 @@ class DG_Gallery {
401
  * @return string The sanitized relation value.
402
  */
403
  private static function sanitizeRelation($value, &$err) {
404
- $defaults = self::getOptions();
405
- $ret = $defaults['relation'];
406
-
407
- $relation = strtoupper($value);
408
- if(!in_array($relation, self::getRelationOptions())) {
409
  $err = sprintf(self::$binary_err, 'relation', 'AND', 'OR', $value);
410
- } else {
411
- $ret = $relation;
412
  }
413
 
414
  return $ret;
@@ -421,24 +487,44 @@ class DG_Gallery {
421
  return array('AND', 'OR');
422
  }
423
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
424
  /**
425
  * Gets all valid Documents based on the attributes passed by the user.
426
  * @return multitype:unknown Contains all documents matching the query.
427
  * @throws InvalidArgumentException Thrown when $this->errs is not empty.
428
  */
429
  private function getDocuments() {
430
- $mime_types = array('application', 'video', 'text', 'audio');
431
- if ($this->atts['images']) {
432
- $mime_types[] = 'image';
433
- }
434
-
435
  $query = array(
436
- 'numberposts' => -1,
437
  'orderby' => $this->atts['orderby'],
438
  'order' => $this->atts['order'],
439
- 'post_status' => 'any',
440
- 'post_type' => 'attachment',
441
- 'post_mime_type' => implode(',', $mime_types));
442
 
443
  $query['post_parent'] =
444
  $this->atts['localpost']
@@ -459,25 +545,36 @@ class DG_Gallery {
459
  * Function loops through all attributes passed that did not match
460
  * self::$defaults. If they are the name of a taxonomy, they are plugged
461
  * into the query, otherwise $this->errs is appended with an error string.
462
- * @global string $wp_version Determines which tax query to use.
463
  * @param multitype:unknown $query Query to insert tax query into.
464
  */
465
  private function setTaxa(&$query) {
466
- if(!empty($this->taxa)) {
467
- $taxa = array();
468
-
469
- // only include relation if we have multiple taxa
470
- if(count($this->taxa) > 1) {
471
- $taxa['relation'] = $this->atts['relation'];
 
 
 
 
 
 
 
 
 
 
472
  }
473
-
 
474
  foreach ($this->taxa as $taxon => $terms) {
475
  $terms = $this->getTermIdsByNames($taxon, explode(',', $terms));
476
 
477
  $taxa[] = array(
478
- 'taxonomy' => $taxon,
479
- 'field' => 'id',
480
- 'terms' => $terms
 
481
  );
482
  }
483
 
@@ -525,13 +622,29 @@ class DG_Gallery {
525
  */
526
  private function getTermXByNames($x, $taxon, $term_names) {
527
  $ret = array();
528
-
529
- foreach ($term_names as $name) {
530
- if (($term = get_term_by('name', $name, $taxon))) {
531
- $ret[] = $term->{$x};
 
 
 
 
532
  } else {
533
- $this->errs[] = sprintf(__('%s is not a valid term name in %s.',
534
- 'document-gallery'), $name, $taxon);
 
 
 
 
 
 
 
 
 
 
 
 
535
  }
536
  }
537
 
@@ -544,9 +657,9 @@ class DG_Gallery {
544
  */
545
  private function getAttachmentsByIds() {
546
  $args = array(
547
- 'post_type' => 'attachment',
548
- 'post_status' => 'inherit',
549
- 'numberposts' => -1,
550
  'post__in' => $this->atts['ids'],
551
  'orderby' => 'post__in'
552
  );
@@ -554,6 +667,14 @@ class DG_Gallery {
554
  return count($args['post__in']) ? get_posts($args) : array();
555
  }
556
 
 
 
 
 
 
 
 
 
557
  /**
558
  * Function returns false for positive ints, true otherwise.
559
  * @param string $var could be anything.
@@ -571,9 +692,23 @@ class DG_Gallery {
571
  * @return bool|NULL Bool value if can be parsed, else NULL.
572
  */
573
  private static function toBool($val) {
 
 
 
 
574
  if (is_bool($val)) {
575
  return $val;
576
  }
 
 
 
 
 
 
 
 
 
 
577
 
578
  if (is_string($val)) {
579
  $val = strtolower($val);
@@ -586,10 +721,6 @@ class DG_Gallery {
586
  }
587
  }
588
 
589
- if (is_null($val)) {
590
- return false;
591
- }
592
-
593
  return null;
594
  }
595
 
19
  private $errs = array();
20
 
21
  // templates for HTML output
22
+ private static $no_docs, $comment, $unary_err, $binary_err;
 
 
 
23
 
24
  /*==========================================================================
25
  * PUBLIC FUNCTIONS
77
  * Initializes static values for this class.
78
  */
79
  public static function init() {
80
+ if (!isset(self::$comment))
81
  {
82
  self::$comment =
83
  PHP_EOL . '<!-- ' . __('Generated using Document Gallery. Get yours here: ', 'document-gallery') .
84
  'http://wordpress.org/extend/plugins/document-gallery -->' . PHP_EOL;
85
  self::$no_docs = '<!-- ' . __('No attachments to display. How boring! :(', 'document-gallery') . ' -->';
86
+ self::$unary_err = __('The %s value entered, "%s", is not valid.', 'document-gallery');
87
  self::$binary_err = __('The %s parameter may only be "%s" or "%s." You entered "%s."', 'document-gallery');
88
  }
89
  }
123
  * Cleans up user input, making sure we don't pass crap on to WP core.
124
  * @param multitype:string $defaults The defaults array to sanitize.
125
  * @param multitype:string &$errs The array of errors, which will be appended with any errors found.
126
+ * @param bool $isDefaults Whether we're sanitizing the defaults array (from DG_Admin).
127
  */
128
+ public static function sanitizeDefaults($defaults, &$errs, $isDefaults = false) {
129
  $old_defaults = self::getOptions();
130
+
131
  // remove invalid keys
132
+ $sanitized = array_intersect_key($defaults, $old_defaults);
133
+
134
+ // add any missing keys & sanitize each value
135
  foreach ($old_defaults as $k => $v) {
136
+ if (!isset($sanitized[$k])) {
137
  if (is_bool($v)) {
138
  // checkbox
139
+ $sanitized[$k] = false;
140
  } else {
141
  // missing value
142
+ $sanitized[$k] = $v;
143
  }
144
  }
145
+
146
+ // sanitize value
147
+ $sanitized[$k] = self::sanitizeParameter($k, $sanitized[$k], $errs);
148
  }
149
+
150
+ // process mime_types attribute separately since default value varies depending on images attribute
151
+ // TODO: Cleaner way to handle this?
152
+ if (!$isDefaults) {
153
+ if (isset($defaults['mime_types'])) {
154
+ $sanitized['mime_types'] = self::sanitizeMimeTypes($defaults['mime_types'], $err);
155
+ if (isset($err)) {
156
+ $errs['mime_types'] = $err;
157
+ unset($err);
158
+ }
159
+ } else {
160
+ $sanitized['mime_types'] = self::getDefaultMimeTypes($sanitized['images']);
161
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  }
163
 
164
+ return $sanitized;
165
+ }
166
+
167
+ /**
168
+ *
169
+ * @param string $key The key to reference the current value in the defaults array.
170
+ * @param unknown $value The value to be sanitized.
171
+ * @param unknown $errs multitype:string The array of errors, which will be appended with any errors found.
172
+ * @return unknown The sanitized value, falling back to the current default value when invalid value given.
173
+ */
174
+ private static function sanitizeParameter($key, $value, &$errs) {
175
+ // all sanitize methods must be in the following form: sanitize<UpperCammelCaseKey>
176
+ $funct = $key;
177
+ $funct[0] = strtoupper($funct[0]);
178
+ $funct = 'sanitize' . preg_replace_callback('/_([a-z])/', array(__CLASS__, 'secondCharToUpper'), $funct);
179
+
180
+ $callable = array(__CLASS__, $funct);
181
+
182
+ if (DG_Logger::logEnabled() && !method_exists(__CLASS__, $funct)) {
183
+ DG_Logger::writeLog(
184
+ DG_LogLevel::Error,
185
+ __('Attempted to call invalid function: ', 'document-gallery') . implode('::', $callable),
186
+ true);
187
  }
188
 
189
+ // call param-specific sanitization
190
+ $ret = call_user_func_array($callable, array($value, &$err));
191
+
192
+ // check for error and return default
193
+ if (is_null($ret)) {
194
+ $defaults = self::getOptions();
195
+ $ret = $defaults[$key];
196
+
197
+ $errs[$key] = $err;
198
  }
199
+
200
+ return $ret;
201
  }
202
 
203
  /**
207
  * @return bool The sanitized attachment_pg value.
208
  */
209
  private static function sanitizeAttachmentPg($value, &$err) {
210
+ $ret = self::toBool($value);
 
 
 
211
 
212
+ if(is_null($ret)) {
213
  $err = sprintf(self::$binary_err, 'attachment_pg', 'true', 'false', $value);
 
 
214
  }
215
 
216
  return $ret;
223
  * @return bool The sanitized descriptions value.
224
  */
225
  private static function sanitizeDescriptions($value, &$err) {
226
+ $ret = self::toBool($value);
 
 
 
227
 
228
+ if(is_null($ret)) {
229
  $err = sprintf(self::$binary_err, 'descriptions', 'true', 'false', $value);
 
 
230
  }
231
 
232
  return $ret;
239
  * @return bool The sanitized fancy value.
240
  */
241
  private static function sanitizeFancy($value, &$err) {
242
+ $ret = self::toBool($value);
 
 
 
243
 
244
+ if(is_null($ret)) {
245
  $err = sprintf(self::$binary_err, 'fancy', 'true', 'false', $value);
 
 
246
  }
247
 
248
  return $ret;
255
  * @return bool|multitype:int The sanitized ids value.
256
  */
257
  private static function sanitizeIds($value, &$err) {
 
 
 
258
  if(false === self::toBool($value)) {
259
  $ret = false;
260
  } else {
261
  $value = trim($value);
262
+ $ret = $value ? explode(',', $value) : array();
263
  $bad = array_filter($ids, array(__CLASS__, 'negativeInt'));
264
 
265
  if(!empty($bad)) {
266
  $err = _n('The following ID is invalid: ',
267
  'The following IDs are invalid: ',
268
  count($bad), 'document-gallery') . implode(', ', $bad);
269
+ $ret = null;
 
270
  }
271
  }
272
 
280
  * @return bool The sanitized images value.
281
  */
282
  private static function sanitizeImages($value, &$err) {
283
+ $ret = self::toBool($value);
 
284
 
285
+ if(is_null($ret)) {
 
 
286
  $err = sprintf(self::$binary_err, 'images', 'true', 'false', $value);
 
 
287
  }
288
 
289
  return $ret;
290
  }
291
 
292
+ /**
293
+ * Takes the provided value and returns a sanitized value.
294
+ * @param string $value The limit value to be sanitized.
295
+ * @param multitype:string &$errs The array of errors, which will be appended with any errors found.
296
+ * @return int The sanitized limit value.
297
+ */
298
+ private static function sanitizeLimit($value, &$err) {
299
+ $ret = intval($value);
300
+
301
+ if (is_null($ret) || $ret < -1) {
302
+ $err = sprintf(self::$unary_err, 'limit', '>= -1');
303
+ $ret = null;
304
+ }
305
+
306
+ return $ret;
307
+ }
308
+
309
  /**
310
  * Takes the provided value and returns a sanitized value.
311
  * @param string $value The localpost value to be sanitized.
313
  * @return bool The sanitized localpost value.
314
  */
315
  private static function sanitizeLocalpost($value, &$err) {
316
+ $ret = self::toBool($value);
 
 
 
317
 
318
+ if(is_null($ret)) {
319
  $err = sprintf(self::$binary_err, 'localpost', 'true', 'false', $value);
 
 
320
  }
321
 
322
  return $ret;
323
  }
324
 
325
+ /**
326
+ * Takes the provided value and returns a sanitized value.
327
+ * @param string $value The mime_types value to be sanitized.
328
+ * @param multitype:string &$errs The array of errors, which will be appended with any errors found.
329
+ * @return string The sanitized mime_types value.
330
+ */
331
+ private static function sanitizeMimeTypes($value, &$err) {
332
+ // TODO: do some actual sanitization...
333
+ return $value;
334
+ }
335
+
336
+ /**
337
+ * Gets the default mime types if no attribute is set.
338
+ * @param bool $ingImages Whether images are included in this gallery.
339
+ * @return string The comma-delimited mime types.
340
+ */
341
+ private static function getDefaultMimeTypes($incImages) {
342
+ $mime_types = array('application', 'video', 'text', 'audio');
343
+ if ($incImages) {
344
+ $mime_types[] = 'image';
345
+ }
346
+
347
+ return implode(',', $mime_types);
348
+ }
349
+
350
  /**
351
  * Takes the provided value and returns a sanitized value.
352
  * @param string $value The order value to be sanitized.
354
  * @return string The sanitized order value.
355
  */
356
  private static function sanitizeOrder($value, &$err) {
357
+ $ret = strtoupper($value);
358
+
359
+ if(!in_array($ret, self::getOrderOptions())) {
 
 
360
  $err = sprintf(self::$binary_err, 'order', 'ASC', 'DESC', $value);
361
+ $ret = null;
 
362
  }
363
 
364
  return $ret;
378
  * @return string The sanitized orderby value.
379
  */
380
  private static function sanitizeOrderby($value, &$err) {
381
+ $ret = ('ID' === strtoupper($value)) ? 'ID' : strtolower($value);
382
+
383
+ if (!in_array($ret, self::getOrderbyOptions())) {
384
+ $err = sprintf(self::$unary_err, 'orderby', $value);
385
+ $ret = null;
 
 
 
 
 
386
  }
387
 
388
  return $ret;
396
  'menu_order', 'modified', 'name', 'none',
397
  'parent', 'post__in', 'rand', 'title');
398
  }
399
+
400
+ /**
401
+ * Takes the provided value and returns a sanitized value.
402
+ * @param string $value The post_status value to be sanitized.
403
+ * @param multitype:string &$errs The array of errors, which will be appended with any errors found.
404
+ * @return string The sanitized post_status value.
405
+ */
406
+ private static function sanitizePostStatus($value, &$err) {
407
+ $ret = preg_grep('/' . preg_quote($value) .'/i', self::getPostStatuses());
408
+ $ret = !empty($ret) ? $ret[0] : null;
409
+
410
+ if(is_null($ret)) {
411
+ $err = sprintf(
412
+ __(self::$unary_err, 'post_status', $value, 'document-gallery'),
413
+ $value);
414
+ }
415
+
416
+ return $ret;
417
+ }
418
+
419
+ /**
420
+ * @return multitype:string All registered post statuses.
421
+ */
422
+ public static function getPostStatuses() {
423
+ static $statuses;
424
+ if (!isset($statuses)) {
425
+ $statuses = get_post_stati();
426
+ $statuses[] = 'any';
427
+ asort($statuses);
428
+ }
429
+
430
+ return $statuses;
431
+ }
432
+
433
+ /**
434
+ * Takes the provided value and returns a sanitized value.
435
+ * @param string $value The post_type value to be sanitized.
436
+ * @param multitype:string &$errs The array of errors, which will be appended with any errors found.
437
+ * @return string The sanitized post_type value.
438
+ */
439
+ private static function sanitizePostType($value, &$err) {
440
+ $ret = preg_grep('/' . preg_quote($value) .'/i', self::getPostTypes());
441
+ $ret = !empty($ret) ? $ret[0] : null;
442
+
443
+ if(is_null($ret)) {
444
+ $err = sprintf(
445
+ __(self::$unary_err, 'post_type', $value, 'document-gallery'),
446
+ $value);
447
+ }
448
+
449
+ return $ret;
450
+ }
451
+
452
+ /**
453
+ * @return multitype:string All registered post types.
454
+ */
455
+ public static function getPostTypes() {
456
+ static $types;
457
+ if (!isset($types)) {
458
+ $types = get_post_types();
459
+ $types[] = 'any';
460
+ asort($types);
461
+ }
462
+
463
+ return $types;
464
+ }
465
 
466
  /**
467
  * Takes the provided value and returns a sanitized value.
470
  * @return string The sanitized relation value.
471
  */
472
  private static function sanitizeRelation($value, &$err) {
473
+ $ret = strtoupper($value);
474
+
475
+ if(!in_array($ret, self::getRelationOptions())) {
 
 
476
  $err = sprintf(self::$binary_err, 'relation', 'AND', 'OR', $value);
477
+ $ret = null;
 
478
  }
479
 
480
  return $ret;
487
  return array('AND', 'OR');
488
  }
489
 
490
+ /**
491
+ * Takes the provided value and returns a sanitized value.
492
+ * @param string $operator The operator value to be sanitized.
493
+ * @return string The sanitized operator value.
494
+ */
495
+ private function sanitizeOperator($operator) {
496
+ $ret = strtoupper($operator);
497
+
498
+ if (!in_array($ret, self::getOperatorOptions())) {
499
+ $this->errs[] = sprintf(self::$binary_err, $key, 'IN", "NOT IN", "OR', 'AND', $operator);
500
+ $ret = null;
501
+ } else if ($ret === 'OR') {
502
+ $ret = 'IN';
503
+ }
504
+
505
+ return $ret;
506
+ }
507
+
508
+ /**
509
+ * @return multitype:string The valid options for *_relation/*_operator parameter.
510
+ */
511
+ public static function getOperatorOptions() {
512
+ return array('IN', 'NOT IN', 'AND', 'OR');
513
+ }
514
+
515
  /**
516
  * Gets all valid Documents based on the attributes passed by the user.
517
  * @return multitype:unknown Contains all documents matching the query.
518
  * @throws InvalidArgumentException Thrown when $this->errs is not empty.
519
  */
520
  private function getDocuments() {
 
 
 
 
 
521
  $query = array(
522
+ 'numberposts' => $this->atts['limit'],
523
  'orderby' => $this->atts['orderby'],
524
  'order' => $this->atts['order'],
525
+ 'post_status' => $this->atts['post_status'],
526
+ 'post_type' => $this->atts['post_type'],
527
+ 'post_mime_type' => $this->atts['mime_types']);
528
 
529
  $query['post_parent'] =
530
  $this->atts['localpost']
545
  * Function loops through all attributes passed that did not match
546
  * self::$defaults. If they are the name of a taxonomy, they are plugged
547
  * into the query, otherwise $this->errs is appended with an error string.
 
548
  * @param multitype:unknown $query Query to insert tax query into.
549
  */
550
  private function setTaxa(&$query) {
551
+ if (!empty($this->taxa)) {
552
+ $taxa = array('relation' => $this->atts['relation']);
553
+ $operator = array();
554
+ $suffix = array('relation', 'operator');
555
+ $pattern = '/(.+)_(?:' . implode('|', $suffix) . ')$/i';
556
+
557
+ // find any relations for taxa
558
+ $iterable = $this->taxa;
559
+ foreach ($iterable as $key => $value) {
560
+ if (preg_match($pattern, $key, $matches)) {
561
+ $base = $matches[1];
562
+ if (array_key_exists($base, $this->taxa)) {
563
+ $operator[$base] = self::sanitizeOperator($value);
564
+ unset($this->taxa[$key]);
565
+ }
566
+ }
567
  }
568
+
569
+ // build tax query
570
  foreach ($this->taxa as $taxon => $terms) {
571
  $terms = $this->getTermIdsByNames($taxon, explode(',', $terms));
572
 
573
  $taxa[] = array(
574
+ 'taxonomy' => $taxon,
575
+ 'field' => 'id',
576
+ 'terms' => $terms,
577
+ 'operator' => isset($operator[$taxon]) ? $operator[$taxon] : 'IN'
578
  );
579
  }
580
 
622
  */
623
  private function getTermXByNames($x, $taxon, $term_names) {
624
  $ret = array();
625
+ $valid = true;
626
+
627
+ // taxons may optionally be prefixed by 'tax_' --
628
+ // this is only useful when avoiding collisions with other attributes
629
+ if (!taxonomy_exists($taxon)) {
630
+ $tmp = preg_replace('^tax_(.*)', '$1', $taxon, 1, $count);
631
+ if ($count > 0 && taxonomy_exists($tmp)) {
632
+ $taxon = $tmp;
633
  } else {
634
+ $this->errs[] = sprintf(self::$unary_err, 'taxon', $taxon);
635
+ $valid = false;
636
+ }
637
+ }
638
+
639
+ // only check terms if we first have a valid taxon
640
+ if ($valid) {
641
+ foreach ($term_names as $name) {
642
+ if (($term = get_term_by('name', $name, $taxon))) {
643
+ $ret[] = $term->{$x};
644
+ } else {
645
+ $this->errs[] = sprintf(__('%s is not a valid term name in %s.',
646
+ 'document-gallery'), $name, $taxon);
647
+ }
648
  }
649
  }
650
 
657
  */
658
  private function getAttachmentsByIds() {
659
  $args = array(
660
+ 'post_type' => $this->atts['post_type'],
661
+ 'post_status' => $this->atts['post_status'],
662
+ 'numberposts' => $this->atts['limit'],
663
  'post__in' => $this->atts['ids'],
664
  'orderby' => 'post__in'
665
  );
667
  return count($args['post__in']) ? get_posts($args) : array();
668
  }
669
 
670
+ /**
671
+ * @param string $string To take second char from.
672
+ * @return char Capitalized second char of given string.
673
+ */
674
+ private static function secondCharToUpper($string) {
675
+ return strtoupper($string[1]);
676
+ }
677
+
678
  /**
679
  * Function returns false for positive ints, true otherwise.
680
  * @param string $var could be anything.
692
  * @return bool|NULL Bool value if can be parsed, else NULL.
693
  */
694
  private static function toBool($val) {
695
+ if (is_null($val)) {
696
+ return false;
697
+ }
698
+
699
  if (is_bool($val)) {
700
  return $val;
701
  }
702
+
703
+ if (is_int($val)) {
704
+ if (1 === $val) {
705
+ return true;
706
+ }
707
+
708
+ if (0 === $val) {
709
+ return false;
710
+ }
711
+ }
712
 
713
  if (is_string($val)) {
714
  $val = strtolower($val);
721
  }
722
  }
723
 
 
 
 
 
724
  return null;
725
  }
726
 
inc/class-setup.php CHANGED
@@ -16,10 +16,8 @@ class DG_Setup {
16
  public static function getDefaultOptions($skeleton = false) {
17
  include_once DG_PATH . 'inc/class-thumber.php';
18
 
19
- $date = $etag = $gs = null;
20
  if (!$skeleton) {
21
- $date = gmdate('D, d M Y H:i:s');
22
- $etag = md5($date);
23
  $gs = DG_Thumber::getGhostscriptExecutable();
24
  }
25
 
@@ -69,23 +67,23 @@ class DG_Setup {
69
  'orderby' => 'menu_order',
70
 
71
  // AND or OR
72
- 'relation' => 'AND'
 
 
 
 
 
 
 
 
 
73
  ),
74
  'css' => array(
75
  // plain text of CSS to be edited by user
76
  'text' => '',
77
 
78
  // "minified" text to be rendered on pages
79
- 'minified' => '',
80
-
81
- // date/time last modified
82
- 'last-modified' => $date,
83
-
84
- // used when telling browser whether to load from cache
85
- 'etag' => $etag,
86
-
87
- // used in cache busting after user modifies CSS
88
- 'version' => 0
89
  ),
90
 
91
  // current DG version
@@ -106,7 +104,7 @@ class DG_Setup {
106
  global $dg_options;
107
 
108
  // do update
109
- if (null != $dg_options && DG_VERSION !== $dg_options['version']) {
110
  $blogs = array(null);
111
 
112
  if (is_multisite()) {
@@ -131,17 +129,11 @@ class DG_Setup {
131
 
132
  // version-specific updates
133
  self::twoPointTwo($options);
 
134
 
135
  // update plugin version
136
  $options['version'] = DG_VERSION;
137
 
138
- // setup CSS
139
- $options['css']['minified'] = isset($options['css']['text'])
140
- ? DocumentGallery::compileCustomCss($options['css']['text'])
141
- : '';
142
- $options['css']['last-modified'] = gmdate('D, d M Y H:i:s');
143
- $options['css']['etag'] = md5($options['css']['last-modified']);
144
-
145
  // remove previously-failed thumbs
146
  $thumbs = $options['thumber']['thumbs'];
147
  foreach ($thumbs as $k => $v) {
@@ -194,6 +186,32 @@ class DG_Setup {
194
  }
195
  }
196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  /**
198
  * Sets up Document Gallery on all blog(s) activated.
199
  * @param bool $networkwide Whether this is a network-wide update (multisite only).
16
  public static function getDefaultOptions($skeleton = false) {
17
  include_once DG_PATH . 'inc/class-thumber.php';
18
 
19
+ $gs = null;
20
  if (!$skeleton) {
 
 
21
  $gs = DG_Thumber::getGhostscriptExecutable();
22
  }
23
 
67
  'orderby' => 'menu_order',
68
 
69
  // AND or OR
70
+ 'relation' => 'AND',
71
+
72
+ // the status the post must be in when returned by DG
73
+ 'post_status' => 'any',
74
+
75
+ // the type of post to be returned
76
+ 'post_type' => 'attachment',
77
+
78
+ // the max number of thumbnails to return
79
+ 'limit' => -1,
80
  ),
81
  'css' => array(
82
  // plain text of CSS to be edited by user
83
  'text' => '',
84
 
85
  // "minified" text to be rendered on pages
86
+ 'minified' => ''
 
 
 
 
 
 
 
 
 
87
  ),
88
 
89
  // current DG version
104
  global $dg_options;
105
 
106
  // do update
107
+ if (!is_null($dg_options) && DG_VERSION !== $dg_options['version']) {
108
  $blogs = array(null);
109
 
110
  if (is_multisite()) {
129
 
130
  // version-specific updates
131
  self::twoPointTwo($options);
132
+ self::twoPointThree($options);
133
 
134
  // update plugin version
135
  $options['version'] = DG_VERSION;
136
 
 
 
 
 
 
 
 
137
  // remove previously-failed thumbs
138
  $thumbs = $options['thumber']['thumbs'];
139
  foreach ($thumbs as $k => $v) {
186
  }
187
  }
188
 
189
+ /**
190
+ * Some of the data previously stored along with custom CSS is no longer needed.
191
+ *
192
+ * @param array $options The options to be modified.
193
+ */
194
+ private static function twoPointThree(&$options) {
195
+ if (version_compare($options['version'], '2.3', '<')) {
196
+ unset($options['css']['last-modified']);
197
+ unset($options['css']['etag']);
198
+ unset($options['css']['version']);
199
+
200
+ // need to recalculate minified, excluding static CSS which was previously included
201
+ $options['css']['minified'] = DocumentGallery::compileCustomCss($options['css']['text']);
202
+
203
+ // if user inadvertantly enabled google drive viewer on system where it's not supported
204
+ // then avoid locking it in the on state
205
+ if ($options['thumber']['active']['google']) {
206
+ $options['thumber']['active']['google'] = DG_Thumber::isGoogleDriveAvailable();
207
+ }
208
+
209
+ $options['gallery']['post_status'] = 'any';
210
+ $options['gallery']['post_type'] = 'attachment';
211
+ $options['gallery']['limit'] = -1;
212
+ }
213
+ }
214
+
215
  /**
216
  * Sets up Document Gallery on all blog(s) activated.
217
  * @param bool $networkwide Whether this is a network-wide update (multisite only).
inc/class-thumber.php CHANGED
@@ -52,7 +52,7 @@ class DG_Thumber {
52
  $file = get_attached_file($ID);
53
 
54
  foreach (self::getThumbers() as $ext_preg => $thumber) {
55
- $ext_preg = '!\.(' . $ext_preg . ')$!i';
56
 
57
  if (preg_match($ext_preg, $file)) {
58
  if (DG_Logger::logEnabled()) {
@@ -232,7 +232,7 @@ class DG_Thumber {
232
 
233
  if (false !== $gs) {
234
  $gs = escapeshellarg($gs) . ' -sDEVICE=png16m -dFirstPage=%d'
235
- . ' -dLastPage=%d -dBATCH -dNOPAUSE -dPDFFitPage -sOutputFile=%s %s';
236
  }
237
  }
238
 
@@ -414,11 +414,37 @@ class DG_Thumber {
414
  }
415
 
416
  /**
417
- * TODO: Currently always returns true.
418
  * @return bool Whether Google Drive can access files on this system.
419
  */
420
  public static function isGoogleDriveAvailable() {
421
- return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
422
  }
423
 
424
  /*==========================================================================
52
  $file = get_attached_file($ID);
53
 
54
  foreach (self::getThumbers() as $ext_preg => $thumber) {
55
+ $ext_preg = '!\.(?:' . $ext_preg . ')$!i';
56
 
57
  if (preg_match($ext_preg, $file)) {
58
  if (DG_Logger::logEnabled()) {
232
 
233
  if (false !== $gs) {
234
  $gs = escapeshellarg($gs) . ' -sDEVICE=png16m -dFirstPage=%d'
235
+ . ' -dLastPage=%d -dBATCH -dNOPAUSE -dPDFFitPage -sOutputFile=%s %s 2>&1';
236
  }
237
  }
238
 
414
  }
415
 
416
  /**
 
417
  * @return bool Whether Google Drive can access files on this system.
418
  */
419
  public static function isGoogleDriveAvailable() {
420
+ static $available = null;
421
+
422
+ if (is_null($available)) {
423
+ // to check if we're visible externally, retrieve image for file we know exists.
424
+ $user_agent = 'Lynx/2.8.7rel.2 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/1.0.0a';
425
+ $google_viewer = 'https://docs.google.com/viewer?url=%s&a=bi&pagenumber=1&w=1';
426
+ $google_viewer = sprintf($google_viewer, urlencode(DG_URL . 'LICENSE.txt'));
427
+
428
+ // args for use in HTTP request
429
+ $args = array(
430
+ 'redirection' => 5,
431
+ 'httpversion' => '1.0',
432
+ 'user-agent' => $user_agent,
433
+ 'blocking' => true,
434
+ 'headers' => array(),
435
+ 'cookies' => array(),
436
+ 'body' => null,
437
+ 'compress' => false,
438
+ 'decompress' => true,
439
+ 'sslverify' => true
440
+ );
441
+
442
+ $response = wp_remote_get($google_viewer, $args);
443
+
444
+ $available = ($response['response']['code'] != 404);
445
+ }
446
+
447
+ return $available;
448
  }
449
 
450
  /*==========================================================================
languages/document-gallery-fi_FI.mo ADDED
Binary file
languages/document-gallery-fi_FI.po ADDED
@@ -0,0 +1,446 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2014 Document Gallery
2
+ # This file is distributed under the same license as the Document Gallery package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Document Gallery 2.2.5\n"
6
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/document-gallery\n"
7
+ "POT-Creation-Date: 2014-10-17 04:20:59+00:00\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2014-11-07 23:21+0200\n"
12
+ "Last-Translator: artzi\n"
13
+ "Language-Team: \n"
14
+ "X-Generator: Poedit 1.6.10\n"
15
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
+ "Language: fi\n"
17
+
18
+ #: admin/class-admin.php:28
19
+ msgid "General"
20
+ msgstr "Yleistä"
21
+
22
+ #: admin/class-admin.php:29
23
+ msgid "Thumbnail Management"
24
+ msgstr "Pikkukuvien halllinta"
25
+
26
+ #: admin/class-admin.php:30 admin/class-admin.php:898
27
+ msgid "Logging"
28
+ msgstr "Kirjautuminen"
29
+
30
+ #: admin/class-admin.php:31
31
+ msgid "Advanced"
32
+ msgstr "Lisäasetukset"
33
+
34
+ #: admin/class-admin.php:68
35
+ msgid "Settings"
36
+ msgstr "Asetukset"
37
+
38
+ #: admin/class-admin.php:78
39
+ msgid "Document Gallery Settings"
40
+ msgstr "Document Gallery asetukset"
41
+
42
+ #. Plugin Name of the plugin/theme
43
+ #: admin/class-admin.php:79
44
+ msgid "Document Gallery"
45
+ msgstr "Document Gallery"
46
+
47
+ #: admin/class-admin.php:124
48
+ msgid "Default Settings"
49
+ msgstr "Oletusasetukset"
50
+
51
+ #: admin/class-admin.php:128
52
+ msgid "Thumbnail Generation"
53
+ msgstr "Pikkukuvien teko"
54
+
55
+ #: admin/class-admin.php:132
56
+ msgid "Custom CSS"
57
+ msgstr "Omat CSS tyylit"
58
+
59
+ #: admin/class-admin.php:144
60
+ msgid "Link to attachment page rather than to file"
61
+ msgstr "Linkitä kytketty sivu, ei tiedosto"
62
+
63
+ #: admin/class-admin.php:156
64
+ msgid "Include document descriptions"
65
+ msgstr "Lisää dokumentin esittely"
66
+
67
+ #: admin/class-admin.php:168
68
+ msgid "Use auto-generated document thumbnails"
69
+ msgstr "Käytä automaattisesti tehtyjä pikkukuvia"
70
+
71
+ #: admin/class-admin.php:180
72
+ msgid "Include image attachments in gallery"
73
+ msgstr "Sisällytä myös kuvat galleriaan"
74
+
75
+ #: admin/class-admin.php:192
76
+ msgid "Only look for attachments in post where [dg] is used"
77
+ msgstr "Etsi liitteitä vain artikkeileihin joissa [dg] on käytössä"
78
+
79
+ #: admin/class-admin.php:205
80
+ msgid "Ascending or descending sorting of documents"
81
+ msgstr "Nouseva vai laskeva lajittelu dokumenteille"
82
+
83
+ #: admin/class-admin.php:218
84
+ msgid "Which field to order documents by"
85
+ msgstr "Mitä kenttää käytetään dokumenttien lajitteluun"
86
+
87
+ #: admin/class-admin.php:231
88
+ msgid ""
89
+ "Whether matched documents must have all taxa_names (AND) or at least one (OR)"
90
+ msgstr ""
91
+ "Löytyvissä documenteissä pitää olla kaikki hakusanat (JA) tai vähintään yksi "
92
+ "(TAI)"
93
+
94
+ #: admin/class-admin.php:243
95
+ msgid "Locally generate thumbnails for audio & video files."
96
+ msgstr "Luo paikallisesti pikkukuvat äänille ja videoille."
97
+
98
+ #: admin/class-admin.php:256
99
+ msgid ""
100
+ "Use <a href=\"http://www.ghostscript.com/\" target=\"_blank\">Ghostscript</"
101
+ "a> for faster local PDF processing (compared to Imagick)."
102
+ msgstr ""
103
+ "Käytä <a href=\"http://www.ghostscript.com/\" target=\"_blank"
104
+ "\">Ghostscript</a> jotta paikallinen PDF prosessoidaan nopeammin (vertailuna "
105
+ "Imagick)."
106
+
107
+ #: admin/class-admin.php:257
108
+ msgid ""
109
+ "Your server is not configured to run <a href=\"http://www.ghostscript.com/\" "
110
+ "target=\"_blank\">Ghostscript</a>."
111
+ msgstr ""
112
+ "Palvelimesi ei ole asetettu toimimaan <a href=\"http://www.ghostscript.com/"
113
+ "\" target=\"_blank\">Ghostscript</a> kanssa."
114
+
115
+ #: admin/class-admin.php:271
116
+ msgid ""
117
+ "Use <a href=\"http://www.php.net/manual/en/book.imagick.php\" target=\"_blank"
118
+ "\">Imagick</a> to handle lots of filetypes locally."
119
+ msgstr ""
120
+ "Käytä <a href=\"http://www.php.net/manual/en/book.imagick.php\" target="
121
+ "\"_blank\">Imagick</a> käsittelemään paljon tiedostotyyppejä paikallisesti."
122
+
123
+ #: admin/class-admin.php:272
124
+ msgid ""
125
+ "Your server is not configured to run <a href=\"http://www.php.net/manual/en/"
126
+ "book.imagick.php\" target=\"_blank\">Imagick</a>."
127
+ msgstr ""
128
+ "Palvelimesi ei ole asetettu käyttämään <a href=\"http://www.php.net/manual/"
129
+ "en/book.imagick.php\" target=\"_blank\">Imagick</a>."
130
+
131
+ #: admin/class-admin.php:286
132
+ msgid ""
133
+ "Use <a href=\"https://drive.google.com/viewer\" target=\"_blank\">Google "
134
+ "Drive Viewer</a> to generate thumbnails for MS Office files and many other "
135
+ "file types remotely."
136
+ msgstr ""
137
+ "Käytä <a href=\"https://drive.google.com/viewer\" target=\"_blank\">Google "
138
+ "Drive Viewer</a> pikkukuvien tekemiseen MS Office sekä joihinkin muihinkin "
139
+ "tiedostoihin."
140
+
141
+ #: admin/class-admin.php:287
142
+ msgid "Your server does not allow remote HTTP access."
143
+ msgstr "Palvelimesi ei salli ulkoista HTTP yhteyttä."
144
+
145
+ #: admin/class-admin.php:309
146
+ msgid "The max width and height (in pixels) that thumbnails will be generated."
147
+ msgstr "Pikkukuvien maksimi leveys ja korkeus (pisteinä)."
148
+
149
+ #: admin/class-admin.php:338
150
+ msgid "Advanced Thumbnail Generation"
151
+ msgstr "Pikkukuvien tekemisen lisäasetukset"
152
+
153
+ #: admin/class-admin.php:350
154
+ msgid "Whether to log debug and error information related to Document Gallery."
155
+ msgstr "Tallennetaanko testi- ja virhetiedot joita Document Gallery antaa."
156
+
157
+ #: admin/class-admin.php:362
158
+ msgid ""
159
+ "Whether option structure should be validated before save. This is not "
160
+ "generally necessary."
161
+ msgstr ""
162
+ "Tarkistetaanko valinnan rakenne ennen tallennusta. Tämä ei yleensä ole "
163
+ "tarpeen."
164
+
165
+ #: admin/class-admin.php:375
166
+ msgid ""
167
+ "Max number of seconds to wait for thumbnail generation before defaulting to "
168
+ "filetype icons."
169
+ msgstr ""
170
+ "Kuinka kauan odotetaan pikkukuvien valkmistumista, ennenkuin käytetään "
171
+ "oletuskuvia."
172
+
173
+ #: admin/class-admin.php:376
174
+ msgid ""
175
+ "Note that generation will continue where timeout happened next time the "
176
+ "gallery is loaded."
177
+ msgstr ""
178
+ "Huomio että luominen jatkuu keskeytyksen kohdasta seuraavalla kerralla kun "
179
+ "galleria ladataan."
180
+
181
+ #: admin/class-admin.php:388
182
+ msgid "Successfully auto-detected the location of Ghostscript."
183
+ msgstr "Ghostscript löydetty automaattisesti."
184
+
185
+ #: admin/class-admin.php:389
186
+ msgid "Failed to auto-detect the location of Ghostscript."
187
+ msgstr "Ghostscript ei onnistuttu löytämään."
188
+
189
+ #: admin/class-admin.php:393
190
+ msgid "Options Array Dump"
191
+ msgstr "Valintataulukon vedos"
192
+
193
+ #: admin/class-admin.php:440
194
+ msgid "Invalid width given: "
195
+ msgstr "Väärä leveys:"
196
+
197
+ #: admin/class-admin.php:453
198
+ msgid "Invalid height given: "
199
+ msgstr "Väärä korkeus:"
200
+
201
+ #: admin/class-admin.php:566
202
+ msgid "Invalid Ghostscript path given: "
203
+ msgstr "Ghostscript polku väärä:"
204
+
205
+ #: admin/class-admin.php:577
206
+ msgid "Invalid timeout given: "
207
+ msgstr "Virheellinen aikakatkaisuarvo:"
208
+
209
+ #: admin/class-admin.php:608
210
+ msgid ""
211
+ "The following values will be used by default in the shortcode. You can still "
212
+ "manually set each of these values in each individual shortcode."
213
+ msgstr ""
214
+ "Näitä arvoja käytetään oletuksena lyhytkoodeissa. Voit silti asettaa näitä "
215
+ "myös manuaalisesti lyhytkoodiin."
216
+
217
+ #: admin/class-admin.php:615
218
+ msgid "Select which tools to use when generating thumbnails."
219
+ msgstr "Valitse millä työkaluilla pikkkukuvat tehdään."
220
+
221
+ #: admin/class-admin.php:624
222
+ msgid ""
223
+ "Enter custom CSS styling for use with document galleries. To see which ids "
224
+ "and classes you can style, take a look at <a href=\"%s\" target=\"_blank"
225
+ "\">style.css</a>."
226
+ msgstr ""
227
+ "Lisää omat CSS-tyylit gallerioiden kayttöön. Näet mahdolliset id:t ja luokat "
228
+ "katsomalla <a href=\"%s\" target=\"_blank\">style.css</a>."
229
+
230
+ #: admin/class-admin.php:642
231
+ msgid ""
232
+ "Unless you <em>really</em> know what you're doing, you should not touch "
233
+ "these values."
234
+ msgstr ""
235
+ "Jollet <em>todella</em> tarkkaan tiedä mitä teet, älä muuta näitä asetuksia."
236
+
237
+ #: admin/class-admin.php:645
238
+ msgid ""
239
+ "NOTE: <code>exec()</code> is not accessible. Ghostscript will not function."
240
+ msgstr "HUOM: <code>exec()</code> ei ole käytettävissä. Ghostscript ei toimi."
241
+
242
+ #: admin/class-admin.php:656
243
+ msgid ""
244
+ "The following <em>readonly text</em> should be provided when <a href="
245
+ "\"http://wordpress.org/support/plugin/document-gallery\" target=\"_blank"
246
+ "\">reporting a bug</a>:"
247
+ msgstr ""
248
+ "Seuraava <em>kirjoitussuojattu teksti</em> pitää antaa kun <a href=\"http://"
249
+ "wordpress.org/support/plugin/document-gallery\" target=\"_blank\"> ilmoittaa "
250
+ "virheestä</a>:"
251
+
252
+ #: admin/class-admin.php:757
253
+ msgid "Select All"
254
+ msgstr "Valitse kaikki"
255
+
256
+ #: admin/class-admin.php:760
257
+ msgid "Thumbnail"
258
+ msgstr "Pikkukuva"
259
+
260
+ #: admin/class-admin.php:761
261
+ msgid "File name"
262
+ msgstr "Tiedoston nimi"
263
+
264
+ #: admin/class-admin.php:762 admin/class-admin.php:834
265
+ msgid "Date"
266
+ msgstr "Päiväys"
267
+
268
+ #: admin/class-admin.php:765
269
+ msgid "Delete Selected"
270
+ msgstr "Poista valitut"
271
+
272
+ #: admin/class-admin.php:767
273
+ msgid "item"
274
+ msgid_plural "items"
275
+ msgstr[0] "kohde"
276
+ msgstr[1] "kohteet"
277
+
278
+ #: admin/class-admin.php:770
279
+ msgid "Go to the first page"
280
+ msgstr "Ensimmäiselle sivulle"
281
+
282
+ #: admin/class-admin.php:771
283
+ msgid "Go to the previous page"
284
+ msgstr "Edelliselle sivulle"
285
+
286
+ #: admin/class-admin.php:773
287
+ msgid "Current page"
288
+ msgstr "Nykyinen sivu"
289
+
290
+ #: admin/class-admin.php:773
291
+ msgid "of"
292
+ msgstr " "
293
+
294
+ #: admin/class-admin.php:774
295
+ msgid "Go to the next page"
296
+ msgstr "Seuraavalle sivulle"
297
+
298
+ #: admin/class-admin.php:775
299
+ msgid "Go to the last page"
300
+ msgstr "Viimeiselle sivulle"
301
+
302
+ #: admin/class-admin.php:777
303
+ msgid "items per page"
304
+ msgstr "kohdetta sivulla"
305
+
306
+ #: admin/class-admin.php:815
307
+ msgid "View"
308
+ msgstr "Näytä"
309
+
310
+ #: admin/class-admin.php:816
311
+ msgid "attachment page"
312
+ msgstr "liitteen sivu"
313
+
314
+ #: admin/class-admin.php:816
315
+ msgid "Attachment not found"
316
+ msgstr "Liitettä ei löytynyt"
317
+
318
+ #: admin/class-admin.php:835
319
+ msgid "Level"
320
+ msgstr "Taso"
321
+
322
+ #: admin/class-admin.php:836
323
+ msgid "Message"
324
+ msgstr "Viesti"
325
+
326
+ #: admin/class-admin.php:845
327
+ msgid "Expand All"
328
+ msgstr "Laajenna kaikki"
329
+
330
+ #: admin/class-admin.php:848
331
+ msgid "Collapse All"
332
+ msgstr "Tiivistä kaikki"
333
+
334
+ #: admin/class-admin.php:891
335
+ msgid "Clear Log"
336
+ msgstr "Tyhjennä loki"
337
+
338
+ #: admin/class-admin.php:898
339
+ msgid "There are no log entries at this time."
340
+ msgstr "Lokitiedosto on tyhjä"
341
+
342
+ #: admin/class-admin.php:898
343
+ msgid "For Your information:"
344
+ msgstr "Tiedoksi:"
345
+
346
+ #: admin/class-admin.php:898
347
+ msgid "is turned ON"
348
+ msgstr "ON päällä"
349
+
350
+ #: admin/class-admin.php:898
351
+ msgid "is turned OFF"
352
+ msgstr "EI ole päällä"
353
+
354
+ #: inc/class-gallery.php:86
355
+ msgid "Generated using Document Gallery. Get yours here: "
356
+ msgstr "Luotu käyttäen Document Gallery. Hanki omasi täältä:"
357
+
358
+ #: inc/class-gallery.php:88
359
+ msgid "No attachments to display. How boring! :("
360
+ msgstr "Liitteitä ei löytynyt. Onpas tylsää! :("
361
+
362
+ #: inc/class-gallery.php:89
363
+ msgid "The %s parameter may only be \"%s\" or \"%s.\" You entered \"%s.\""
364
+ msgstr "Antamasi %s voi olla vain \"%s\" tai \"%s.\" antamastasi \"%s.\""
365
+
366
+ #: inc/class-gallery.php:286
367
+ msgid "The following ID is invalid: "
368
+ msgid_plural "The following IDs are invalid: "
369
+ msgstr[0] "Seuraava ID on väärä: "
370
+ msgstr[1] "Seuraavat ID:t ovat vääriä: "
371
+
372
+ #: inc/class-gallery.php:379
373
+ msgid "The orderby value entered, \"%s,\" is not valid."
374
+ msgstr "Lajittelumääritys jonka annoit, \"%s,\" ei ole oikeanlainen."
375
+
376
+ #: inc/class-gallery.php:533
377
+ msgid "%s is not a valid term name in %s."
378
+ msgstr "%s ei ole oikeantyyppinen termi %s ssa."
379
+
380
+ #: inc/class-image-editor-imagick.php:37
381
+ msgid "Failed to set Imagick page number"
382
+ msgstr "Imagick sivunumeron asettaminen epäonnnistui"
383
+
384
+ #: inc/class-thumber.php:59
385
+ msgid "Attempting to generate thumbnail for attachment #%d with (%s)"
386
+ msgstr "Yritetään luoda pikkukuva, #%d (%s):lla "
387
+
388
+ #: inc/class-thumber.php:138
389
+ msgid "Could not open file: "
390
+ msgstr "Tiedoston avaus epäonnistui:"
391
+
392
+ #: inc/class-thumber.php:143
393
+ msgid "Could not write file: "
394
+ msgstr "Tiedostoon ei voi kirjoittaa:"
395
+
396
+ #: inc/class-thumber.php:180
397
+ msgid "Failed to open file in Imagick: "
398
+ msgstr "Tiedoston avaus epäonnistui, Imagick: "
399
+
400
+ #: inc/class-thumber.php:191
401
+ msgid "Failed to save image in Imagick: "
402
+ msgstr "Kuvan tallennus epäonnistui, Imagick: "
403
+
404
+ #: inc/class-thumber.php:249
405
+ msgid "Ghostscript failed: "
406
+ msgstr "Ghostscript virhe:"
407
+
408
+ #: inc/class-thumber.php:387
409
+ msgid "Failed to retrieve thumbnail from Google: "
410
+ msgstr "Pikkukuvan tuonti Googlesta epäonnistui:"
411
+
412
+ #: inc/class-thumber.php:631
413
+ msgid "Thumbnail Generators: "
414
+ msgstr "Pikkukuvién ohjelmat."
415
+
416
+ #: inc/class-thumber.php:642
417
+ msgid "No thumbnail generators enabled."
418
+ msgstr "Pikkukuvien tekoon ei löytynyt ohjelmaa."
419
+
420
+ #: inc/class-thumber.php:685
421
+ msgid "Failed to get image editor: "
422
+ msgstr "Kuvaeditoria ei löytynyt:"
423
+
424
+ #: inc/class-thumber.php:697
425
+ msgid "Failed to save image: "
426
+ msgstr "Kuvan tallennus epäonnistui:"
427
+
428
+ #. Plugin URI of the plugin/theme
429
+ msgid "http://wordpress.org/extend/plugins/document-gallery/"
430
+ msgstr "http://wordpress.org/extend/plugins/document-gallery/"
431
+
432
+ #. Description of the plugin/theme
433
+ msgid ""
434
+ "Display non-images (and images) in gallery format on a page or post with the "
435
+ "[dg] shortcode."
436
+ msgstr ""
437
+ "Näytä tiedostot (myös kuvat) galleriana sivulla tai artikkelissa [dg] "
438
+ "koodilla. "
439
+
440
+ #. Author of the plugin/theme
441
+ msgid "Dan Rossiter"
442
+ msgstr "Dan Rossiter"
443
+
444
+ #. Author URI of the plugin/theme
445
+ msgid "http://danrossiter.org/"
446
+ msgstr "http://danrossiter.org/"